diff --git a/src/api/bigDipperApi.ts b/src/api/bigDipperApi.ts index b280a5dc..5285728d 100644 --- a/src/api/bigDipperApi.ts +++ b/src/api/bigDipperApi.ts @@ -4,13 +4,14 @@ import { TotalStakedCoinsResponse, DidsResponse, ResourcesResponse, - TransactionDetails, + DidTransactionDetails, + ResourceTransactionDetails, OperationType, - OperationTypes, DidDocPayload, ResourcePayload, Fee, } from '../types/bigDipper'; +import { normalizeOperationType } from '../helpers/identity'; export class BigDipperApi { constructor(public readonly graphql_client: GraphQLClient) {} @@ -42,16 +43,12 @@ export class BigDipperApi { return resp.data.staking_pool[0].bonded_tokens; }; - async getDids(limit = 100, offset = 0, minHeight = 0): Promise { + async getDids(limit = 100, offset = 0, minHeight = 0): Promise { const query = ` query GetDids($limit: Int!, $offset: Int!, $minHeight: bigint!) { message( where: { - type: {_in: [ - "${OperationTypes.CREATE_DID}", - "${OperationTypes.UPDATE_DID}", - "${OperationTypes.DEACTIVATE_DID}" - ]}, + type: {_iregex: "^/?cheqd.did.v2"}, height: {_gt: $minHeight} } limit: $limit @@ -89,7 +86,7 @@ export class BigDipperApi { return { transactionHash: msg.transaction_hash, blockHeight: msg.height, - operationType: msg.type as OperationType, + operationType: normalizeOperationType(msg.type) as OperationType, timestamp: msg.transaction.block.timestamp, didId: payload.id, feePayer: fee.payer, @@ -100,14 +97,12 @@ export class BigDipperApi { }); } - async getResources(limit = 100, offset = 0, minHeight = 0): Promise { + async getResources(limit = 100, offset = 0, minHeight = 0): Promise { const query = ` query GetResources($limit: Int!, $offset: Int!, $minHeight: bigint!) { message( where: { - type: {_in: [ - "${OperationTypes.CREATE_RESOURCE}", - ]}, + type: {_iregex: "^/?cheqd.resource.v2"}, height: {_gt: $minHeight} } limit: $limit @@ -145,7 +140,7 @@ export class BigDipperApi { return { transactionHash: msg.transaction_hash, blockHeight: msg.height, - operationType: msg.type as OperationType, + operationType: normalizeOperationType(msg.type) as OperationType, timestamp: msg.transaction.block.timestamp, didId: payload.collection_id, resourceId: payload.id, diff --git a/src/helpers/identity.ts b/src/helpers/identity.ts index 35de3522..d9af0afe 100644 --- a/src/helpers/identity.ts +++ b/src/helpers/identity.ts @@ -454,3 +454,7 @@ export async function syncNetworkData(network: Network, env: Env) { await dbClose(dbInstance); } } + +export function normalizeOperationType(type: string): string { + return type.startsWith('/') ? type.slice(1) : type; +}