diff --git a/packages/sdk/src/aptos/aptos-processor.ts b/packages/sdk/src/aptos/aptos-processor.ts index 9505c5156..24750e93d 100644 --- a/packages/sdk/src/aptos/aptos-processor.ts +++ b/packages/sdk/src/aptos/aptos-processor.ts @@ -32,7 +32,7 @@ import { TransactionIntervalHandler } from '../move/index.js' import { ALL_ADDRESS, Labels, PromiseOrVoid } from '../core/index.js' -import { TypeDescriptor } from '@typemove/move' +import { TypeDescriptor, matchType } from '@typemove/move' import { decodeResourceChange, ResourceChange } from '@typemove/aptos' import { GeneralTransactionResponse } from './models.js' import { getHandlerName, proxyProcessor } from '../utils/metrics.js' @@ -233,6 +233,8 @@ export class AptosTransactionProcessor(data.resources, ctx.coder) - await handler(resources, ctx) + let resources = await decodeResourceChange(data.resources, ctx.coder) + + if (hasAny) { + resources = resources.filter((r) => { + const rt = parseMoveType(r.type) + return matchType(typeDesc, rt) + }) + } + + if (resources.length > 0) { + await handler(resources, ctx) + } return ctx.stopAndGetResult() }, - type: typeDesc.qname + type: hasAny ? typeDesc.qname : typeDesc.getNormalizedSignature() }) return this } @@ -489,6 +501,8 @@ export class AptosResourcesProcessor { typeDesc = parseMoveType(typeDesc) } + const hasAny = typeDesc.existAnyType() + const processor = this this.resourceIntervalHandlers.push({ fetchConfig: DEFAULT_RESOURCE_FETCH_CONFIG, @@ -507,11 +521,21 @@ export class AptosResourcesProcessor { processor.config.baseLabels ) - const resources = (await decodeResourceChange(data.resources, ctx.coder)) as ResourceChange[] - await handler(resources, ctx) + let resources = (await decodeResourceChange(data.resources, ctx.coder)) as ResourceChange[] + + if (hasAny) { + resources = resources.filter((r) => { + const rt = parseMoveType(r.type) + return matchType(typeDesc, rt) + }) + } + + if (resources.length > 0) { + await handler(resources, ctx) + } return ctx.stopAndGetResult() }, - type: typeDesc.qname + type: hasAny ? typeDesc.qname : typeDesc.getNormalizedSignature() }) return this }