@@ -4,13 +4,14 @@ import {
44 TotalStakedCoinsResponse ,
55 DidsResponse ,
66 ResourcesResponse ,
7- TransactionDetails ,
7+ DidTransactionDetails ,
8+ ResourceTransactionDetails ,
89 OperationType ,
9- OperationTypes ,
1010 DidDocPayload ,
1111 ResourcePayload ,
1212 Fee ,
1313} from '../types/bigDipper' ;
14+ import { normalizeOperationType } from '../helpers/identity' ;
1415
1516export class BigDipperApi {
1617 constructor ( public readonly graphql_client : GraphQLClient ) { }
@@ -42,16 +43,12 @@ export class BigDipperApi {
4243 return resp . data . staking_pool [ 0 ] . bonded_tokens ;
4344 } ;
4445
45- async getDids ( limit = 100 , offset = 0 , minHeight = 0 ) : Promise < TransactionDetails [ ] > {
46+ async getDids ( limit = 100 , offset = 0 , minHeight = 0 ) : Promise < DidTransactionDetails [ ] > {
4647 const query = `
4748 query GetDids($limit: Int!, $offset: Int!, $minHeight: bigint!) {
4849 message(
4950 where: {
50- type: {_in: [
51- "${ OperationTypes . CREATE_DID } ",
52- "${ OperationTypes . UPDATE_DID } ",
53- "${ OperationTypes . DEACTIVATE_DID } "
54- ]},
51+ type: {_iregex: "^/?cheqd.did.v2"},
5552 height: {_gt: $minHeight}
5653 }
5754 limit: $limit
@@ -89,7 +86,7 @@ export class BigDipperApi {
8986 return {
9087 transactionHash : msg . transaction_hash ,
9188 blockHeight : msg . height ,
92- operationType : msg . type as OperationType ,
89+ operationType : normalizeOperationType ( msg . type ) as OperationType ,
9390 timestamp : msg . transaction . block . timestamp ,
9491 didId : payload . id ,
9592 feePayer : fee . payer ,
@@ -100,14 +97,12 @@ export class BigDipperApi {
10097 } ) ;
10198 }
10299
103- async getResources ( limit = 100 , offset = 0 , minHeight = 0 ) : Promise < TransactionDetails [ ] > {
100+ async getResources ( limit = 100 , offset = 0 , minHeight = 0 ) : Promise < ResourceTransactionDetails [ ] > {
104101 const query = `
105102 query GetResources($limit: Int!, $offset: Int!, $minHeight: bigint!) {
106103 message(
107104 where: {
108- type: {_in: [
109- "${ OperationTypes . CREATE_RESOURCE } ",
110- ]},
105+ type: {_iregex: "^/?cheqd.resource.v2"},
111106 height: {_gt: $minHeight}
112107 }
113108 limit: $limit
@@ -145,7 +140,7 @@ export class BigDipperApi {
145140 return {
146141 transactionHash : msg . transaction_hash ,
147142 blockHeight : msg . height ,
148- operationType : msg . type as OperationType ,
143+ operationType : normalizeOperationType ( msg . type ) as OperationType ,
149144 timestamp : msg . transaction . block . timestamp ,
150145 didId : payload . collection_id ,
151146 resourceId : payload . id ,
0 commit comments