@sentio/sdk 2.12.3 → 2.13.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/aptos-processor.d.ts +3 -3
 - package/lib/aptos/aptos-processor.js +17 -12
 - package/lib/aptos/aptos-processor.js.map +1 -1
 - package/lib/aptos/builtin/0x1.d.ts +168 -168
 - package/lib/aptos/builtin/0x1.js.map +1 -1
 - package/lib/aptos/builtin/0x3.d.ts +35 -35
 - package/lib/aptos/builtin/0x3.js.map +1 -1
 - package/lib/aptos/context.d.ts +2 -1
 - package/lib/aptos/context.js +4 -2
 - package/lib/aptos/context.js.map +1 -1
 - package/lib/move/abstract-codegen.js +2 -2
 - package/lib/move/abstract-codegen.js.map +1 -1
 - package/lib/sui/builtin/0x1.d.ts +6 -6
 - package/lib/sui/builtin/0x1.js.map +1 -1
 - package/lib/sui/builtin/0x2.d.ts +43 -43
 - package/lib/sui/builtin/0x2.js.map +1 -1
 - package/lib/sui/builtin/0x3.d.ts +43 -43
 - package/lib/sui/builtin/0x3.js.map +1 -1
 - package/lib/sui/context.d.ts +2 -1
 - package/lib/sui/context.js +3 -1
 - package/lib/sui/context.js.map +1 -1
 - package/lib/sui/sui-processor.d.ts +2 -2
 - package/lib/sui/sui-processor.js +15 -12
 - package/lib/sui/sui-processor.js.map +1 -1
 - package/lib/testing/aptos-facet.d.ts +2 -2
 - package/lib/testing/aptos-facet.js +14 -21
 - package/lib/testing/aptos-facet.js.map +1 -1
 - package/lib/testing/sui-facet.d.ts +2 -2
 - package/lib/testing/sui-facet.js +16 -26
 - package/lib/testing/sui-facet.js.map +1 -1
 - package/package.json +4 -4
 - package/src/aptos/aptos-processor.ts +30 -23
 - package/src/aptos/builtin/0x1.ts +168 -168
 - package/src/aptos/builtin/0x3.ts +35 -35
 - package/src/aptos/context.ts +5 -2
 - package/src/move/abstract-codegen.ts +2 -2
 - package/src/sui/builtin/0x1.ts +6 -6
 - package/src/sui/builtin/0x2.ts +43 -43
 - package/src/sui/builtin/0x3.ts +43 -43
 - package/src/sui/context.ts +4 -1
 - package/src/sui/sui-processor.ts +27 -22
 - package/src/testing/aptos-facet.ts +13 -27
 - package/src/testing/sui-facet.ts +15 -30
 
    
        package/lib/sui/context.d.ts
    CHANGED
    
    | 
         @@ -9,7 +9,8 @@ export declare class SuiContext extends BaseContext { 
     | 
|
| 
       9 
9 
     | 
    
         
             
                timestamp: Date;
         
     | 
| 
       10 
10 
     | 
    
         
             
                slot: bigint;
         
     | 
| 
       11 
11 
     | 
    
         
             
                transaction: SuiTransactionBlockResponse;
         
     | 
| 
       12 
     | 
    
         
            -
                 
     | 
| 
      
 12 
     | 
    
         
            +
                eventIndex: number;
         
     | 
| 
      
 13 
     | 
    
         
            +
                constructor(moduleName: string, network: SuiNetwork, address: string, timestamp: Date, slot: bigint, transaction: SuiTransactionBlockResponse, eventIndex: number);
         
     | 
| 
       13 
14 
     | 
    
         
             
                getChainId(): string;
         
     | 
| 
       14 
15 
     | 
    
         
             
                getMetaData(name: string, labels: Labels): RecordMetaData;
         
     | 
| 
       15 
16 
     | 
    
         
             
            }
         
     | 
    
        package/lib/sui/context.js
    CHANGED
    
    | 
         @@ -7,13 +7,15 @@ export class SuiContext extends BaseContext { 
     | 
|
| 
       7 
7 
     | 
    
         
             
                timestamp;
         
     | 
| 
       8 
8 
     | 
    
         
             
                slot;
         
     | 
| 
       9 
9 
     | 
    
         
             
                transaction;
         
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 10 
     | 
    
         
            +
                eventIndex;
         
     | 
| 
      
 11 
     | 
    
         
            +
                constructor(moduleName, network, address, timestamp, slot, transaction, eventIndex) {
         
     | 
| 
       11 
12 
     | 
    
         
             
                    super();
         
     | 
| 
       12 
13 
     | 
    
         
             
                    this.address = address.toLowerCase();
         
     | 
| 
       13 
14 
     | 
    
         
             
                    this.network = network;
         
     | 
| 
       14 
15 
     | 
    
         
             
                    this.moduleName = moduleName;
         
     | 
| 
       15 
16 
     | 
    
         
             
                    this.timestamp = timestamp;
         
     | 
| 
       16 
17 
     | 
    
         
             
                    this.slot = slot;
         
     | 
| 
      
 18 
     | 
    
         
            +
                    this.eventIndex = eventIndex;
         
     | 
| 
       17 
19 
     | 
    
         
             
                    if (transaction) {
         
     | 
| 
       18 
20 
     | 
    
         
             
                        this.transaction = transaction;
         
     | 
| 
       19 
21 
     | 
    
         
             
                    }
         
     | 
    
        package/lib/sui/context.js.map
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAc,UAAU,EAAE,MAAM,cAAc,CAAA;AAGrD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,UAAU,CAAQ;IAClB,SAAS,CAAM;IACf,IAAI,CAAQ;IACZ,WAAW,CAA6B; 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/sui/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACvE,OAAO,EAAc,UAAU,EAAE,MAAM,cAAc,CAAA;AAGrD,MAAM,OAAO,UAAW,SAAQ,WAAW;IACzC,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,UAAU,CAAQ;IAClB,SAAS,CAAM;IACf,IAAI,CAAQ;IACZ,WAAW,CAA6B;IACxC,UAAU,CAAQ;IAElB,YACE,UAAkB,EAClB,OAAmB,EACnB,OAAe,EACf,SAAe,EACf,IAAY,EACZ,WAAwC,EACxC,UAAkB;QAElB,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;QACpC,IAA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IAAY,EAAE,MAAc;QACtC,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,YAAY,EAAE,SAAS;YACvB,WAAW,EAAE,IAAI,CAAC,IAAI;YACtB,gBAAgB,EAAE,CAAC;YACnB,eAAe,EAAE,EAAE;YACnB,QAAQ,EAAE,CAAC;YACX,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE;YAC1B,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { RecordMetaData } from '@sentio/protos'\nimport { type Labels, BaseContext, normalizeLabels } from '../index.js'\nimport { SuiNetwork, getChainId } from './network.js'\nimport { SuiTransactionBlockResponse } from '@mysten/sui.js'\n\nexport class SuiContext extends BaseContext {\n  address: string\n  network: SuiNetwork\n  moduleName: string\n  timestamp: Date\n  slot: bigint\n  transaction: SuiTransactionBlockResponse\n  eventIndex: number\n\n  constructor(\n    moduleName: string,\n    network: SuiNetwork,\n    address: string,\n    timestamp: Date,\n    slot: bigint,\n    transaction: SuiTransactionBlockResponse,\n    eventIndex: number\n  ) {\n    super()\n    this.address = address.toLowerCase()\n    this.network = network\n    this.moduleName = moduleName\n    this.timestamp = timestamp\n    this.slot = slot\n    this.eventIndex = eventIndex\n    if (transaction) {\n      this.transaction = transaction\n    }\n  }\n\n  getChainId(): string {\n    return getChainId(this.network)\n  }\n\n  getMetaData(name: string, labels: Labels): RecordMetaData {\n    return {\n      address: this.address,\n      contractName: this.moduleName,\n      blockNumber: this.slot,\n      transactionIndex: 0,\n      transactionHash: this.transaction?.digest || '', // TODO\n      logIndex: 0,\n      chainId: this.getChainId(),\n      name: name,\n      labels: normalizeLabels(labels),\n    }\n  }\n}\n\nexport class SuiObjectsContext extends BaseContext {\n  address: string\n  network: SuiNetwork\n  slot: bigint\n  timestamp: Date\n\n  constructor(network: SuiNetwork, address: string, slot: bigint, timestamp: Date) {\n    super()\n    this.address = address\n    this.network = network\n    this.slot = slot\n    this.timestamp = timestamp\n  }\n\n  getChainId(): string {\n    return getChainId(this.network)\n  }\n\n  getMetaData(name: string, labels: Labels): RecordMetaData {\n    return {\n      address: this.address,\n      contractName: 'objects',\n      blockNumber: this.slot,\n      transactionIndex: 0,\n      transactionHash: '',\n      logIndex: 0,\n      chainId: this.getChainId(),\n      name: name,\n      labels: normalizeLabels(labels),\n    }\n  }\n}\n"]}
         
     | 
| 
         @@ -29,8 +29,8 @@ export declare class SuiBaseProcessor { 
     | 
|
| 
       29 
29 
     | 
    
         
             
                callHandlers: CallHandler<Data_SuiCall>[];
         
     | 
| 
       30 
30 
     | 
    
         
             
                constructor(name: string, options: SuiBindOptions);
         
     | 
| 
       31 
31 
     | 
    
         
             
                getChainId(): string;
         
     | 
| 
       32 
     | 
    
         
            -
                onMoveEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, filter: EventFilter | EventFilter[], fetchConfig?: MoveFetchConfig): SuiBaseProcessor;
         
     | 
| 
       33 
     | 
    
         
            -
                onEntryFunctionCall(handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: MoveFetchConfig): SuiBaseProcessor;
         
     | 
| 
      
 32 
     | 
    
         
            +
                onMoveEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, filter: EventFilter | EventFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
         
     | 
| 
      
 33 
     | 
    
         
            +
                onEntryFunctionCall(handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void, filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[], fetchConfig?: Partial<MoveFetchConfig>): SuiBaseProcessor;
         
     | 
| 
       34 
34 
     | 
    
         
             
            }
         
     | 
| 
       35 
35 
     | 
    
         
             
            declare class ObjectHandler {
         
     | 
| 
       36 
36 
     | 
    
         
             
                type?: string;
         
     | 
    
        package/lib/sui/sui-processor.js
    CHANGED
    
    | 
         @@ -1,9 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import { MoveFetchConfig, MoveOnIntervalConfig_OwnerType, } from '@sentio/protos';
         
     | 
| 
       2 
     | 
    
         
            -
            import { ListStateStorage } from '@sentio/runtime';
         
     | 
| 
      
 2 
     | 
    
         
            +
            import { ListStateStorage, mergeProcessResults } from '@sentio/runtime';
         
     | 
| 
       3 
3 
     | 
    
         
             
            import { getChainId, SuiNetwork } from './network.js';
         
     | 
| 
       4 
4 
     | 
    
         
             
            import { ServerError, Status } from 'nice-grpc';
         
     | 
| 
       5 
5 
     | 
    
         
             
            import { SuiContext, SuiObjectsContext } from './context.js';
         
     | 
| 
       6 
6 
     | 
    
         
             
            import { getProgrammableTransaction, getTransactionKind, } from '@mysten/sui.js';
         
     | 
| 
      
 7 
     | 
    
         
            +
            import { parseMoveType } from '../move/index.js';
         
     | 
| 
       7 
8 
     | 
    
         
             
            import { getMoveCalls } from './utils.js';
         
     | 
| 
       8 
9 
     | 
    
         
             
            import { defaultMoveCoder } from './move-coder.js';
         
     | 
| 
       9 
10 
     | 
    
         
             
            // import { dynamic_field } from './builtin/0x2.js'
         
     | 
| 
         @@ -41,7 +42,7 @@ export class SuiBaseProcessor { 
     | 
|
| 
       41 
42 
     | 
    
         
             
                }
         
     | 
| 
       42 
43 
     | 
    
         
             
                onMoveEvent(handler, filter, fetchConfig) {
         
     | 
| 
       43 
44 
     | 
    
         
             
                    let _filters = [];
         
     | 
| 
       44 
     | 
    
         
            -
                    const _fetchConfig = fetchConfig ||  
     | 
| 
      
 45 
     | 
    
         
            +
                    const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {});
         
     | 
| 
       45 
46 
     | 
    
         
             
                    if (Array.isArray(filter)) {
         
     | 
| 
       46 
47 
     | 
    
         
             
                        _filters = filter;
         
     | 
| 
       47 
48 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -51,6 +52,7 @@ export class SuiBaseProcessor { 
     | 
|
| 
       51 
52 
     | 
    
         
             
                    // const address = this.config.address
         
     | 
| 
       52 
53 
     | 
    
         
             
                    // const moduleName = this.moduleName
         
     | 
| 
       53 
54 
     | 
    
         
             
                    const processor = this;
         
     | 
| 
      
 55 
     | 
    
         
            +
                    const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type));
         
     | 
| 
       54 
56 
     | 
    
         
             
                    this.eventHandlers.push({
         
     | 
| 
       55 
57 
     | 
    
         
             
                        handler: async function (data) {
         
     | 
| 
       56 
58 
     | 
    
         
             
                            if (!data.transaction) {
         
     | 
| 
         @@ -60,17 +62,18 @@ export class SuiBaseProcessor { 
     | 
|
| 
       60 
62 
     | 
    
         
             
                            if (!txn.events || !txn.events.length) {
         
     | 
| 
       61 
63 
     | 
    
         
             
                                throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions');
         
     | 
| 
       62 
64 
     | 
    
         
             
                            }
         
     | 
| 
       63 
     | 
    
         
            -
                            const  
     | 
| 
       64 
     | 
    
         
            -
                            const  
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                                 
     | 
| 
      
 65 
     | 
    
         
            +
                            const processResults = [];
         
     | 
| 
      
 66 
     | 
    
         
            +
                            for (const [idx, evt] of txn.events.entries()) {
         
     | 
| 
      
 67 
     | 
    
         
            +
                                const typeQname = parseMoveType(evt.type).qname;
         
     | 
| 
      
 68 
     | 
    
         
            +
                                if (!allEventType.has(typeQname)) {
         
     | 
| 
      
 69 
     | 
    
         
            +
                                    continue;
         
     | 
| 
      
 70 
     | 
    
         
            +
                                }
         
     | 
| 
      
 71 
     | 
    
         
            +
                                const ctx = new SuiContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, txn, idx);
         
     | 
| 
       69 
72 
     | 
    
         
             
                                const decoded = defaultMoveCoder().decodeEvent(evt);
         
     | 
| 
       70 
73 
     | 
    
         
             
                                await handler(decoded || evt, ctx);
         
     | 
| 
       71 
     | 
    
         
            -
                                 
     | 
| 
      
 74 
     | 
    
         
            +
                                processResults.push(ctx.getProcessResult());
         
     | 
| 
       72 
75 
     | 
    
         
             
                            }
         
     | 
| 
       73 
     | 
    
         
            -
                            return  
     | 
| 
      
 76 
     | 
    
         
            +
                            return mergeProcessResults(processResults);
         
     | 
| 
       74 
77 
     | 
    
         
             
                        },
         
     | 
| 
       75 
78 
     | 
    
         
             
                        filters: _filters,
         
     | 
| 
       76 
79 
     | 
    
         
             
                        fetchConfig: _fetchConfig,
         
     | 
| 
         @@ -79,7 +82,7 @@ export class SuiBaseProcessor { 
     | 
|
| 
       79 
82 
     | 
    
         
             
                }
         
     | 
| 
       80 
83 
     | 
    
         
             
                onEntryFunctionCall(handler, filter, fetchConfig) {
         
     | 
| 
       81 
84 
     | 
    
         
             
                    let _filters = [];
         
     | 
| 
       82 
     | 
    
         
            -
                    const _fetchConfig = fetchConfig ||  
     | 
| 
      
 85 
     | 
    
         
            +
                    const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {});
         
     | 
| 
       83 
86 
     | 
    
         
             
                    if (Array.isArray(filter)) {
         
     | 
| 
       84 
87 
     | 
    
         
             
                        _filters = filter;
         
     | 
| 
       85 
88 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -95,7 +98,7 @@ export class SuiBaseProcessor { 
     | 
|
| 
       95 
98 
     | 
    
         
             
                                throw new ServerError(Status.INVALID_ARGUMENT, 'call is null');
         
     | 
| 
       96 
99 
     | 
    
         
             
                            }
         
     | 
| 
       97 
100 
     | 
    
         
             
                            const tx = data.transaction;
         
     | 
| 
       98 
     | 
    
         
            -
                            const ctx = new SuiContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, tx);
         
     | 
| 
      
 101 
     | 
    
         
            +
                            const ctx = new SuiContext(processor.moduleName, processor.config.network, processor.config.address, data.timestamp || new Date(0), data.slot, tx, 0);
         
     | 
| 
       99 
102 
     | 
    
         
             
                            if (tx) {
         
     | 
| 
       100 
103 
     | 
    
         
             
                                const calls = getMoveCalls(tx);
         
     | 
| 
       101 
104 
     | 
    
         
             
                                if (calls.length !== 1) {
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,EACf,8BAA8B,GAE/B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAKnB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,mDAAmD;AAEnD,MAAM,cAAc;IAClB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,cAAc,CAAQ;CACvB;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAM,OAAO,oBAAoB;IAC/B,QAAQ,CAAQ;IAChB,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAa,iBAAkB,SAAQ,gBAAkC;IACvE,MAAM,CAAC,QAAQ,GAAG,IAAI,iBAAiB,EAAE,CAAA;;SAD9B,iBAAiB;AAI9B,MAAM,OAAO,gBAAgB;IAClB,UAAU,CAAQ;IAC3B,MAAM,CAAgB;IAEtB,aAAa,GAAkC,EAAE,CAAA;IACjD,YAAY,GAAgC,EAAE,CAAA;IA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,cAAc;YACtC,SAAS,EAAE,8BAA8B,CAAC,MAAM;SACjD,CAAC,CAAA;IACJ,CAAC;IAES,gBAAgB,CAAC,OAAwB;QACjD,OAAO,OAAO,CAAA;QACd,iEAAiE;IACnE,CAAC;CACF","sourcesContent":["import {\n  Data_SuiCall,\n  Data_SuiEvent,\n  Data_SuiObject,\n  HandleInterval,\n  MoveFetchConfig,\n  MoveOnIntervalConfig_OwnerType,\n  ProcessResult,\n} from '@sentio/protos'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { getChainId, SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext, SuiObjectsContext } from './context.js'\nimport {\n  getProgrammableTransaction,\n  getTransactionKind,\n  MoveCallSuiTransaction,\n  SuiEvent,\n  SuiMoveObject,\n  SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder } from './move-coder.js'\n// import { dynamic_field } from './builtin/0x2.js'\n\nclass IndexConfigure {\n  address: string\n  network: SuiNetwork\n  startTimestamp: number\n}\n\nexport class SuiBindOptions {\n  address: string\n  network?: SuiNetwork\n  startTimestamp?: number\n}\n\nexport class SuiObjectBindOptions {\n  objectId: string\n  network?: SuiNetwork\n  startTimestamp?: number\n}\n\nexport class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {\n  static INSTANCE = new SuiProcessorState()\n}\n\nexport class SuiBaseProcessor {\n  readonly moduleName: string\n  config: IndexConfigure\n\n  eventHandlers: EventHandler<Data_SuiEvent>[] = []\n  callHandlers: CallHandler<Data_SuiCall>[] = []\n\n  constructor(name: string, options: SuiBindOptions) {\n    this.moduleName = name\n    this.config = configure(options)\n    SuiProcessorState.INSTANCE.addValue(this)\n  }\n\n  getChainId(): string {\n    return getChainId(this.config.network)\n  }\n\n  public onMoveEvent(\n    handler: (event: SuiEvent, ctx: SuiContext) => void,\n    filter: EventFilter | EventFilter[],\n    fetchConfig?: MoveFetchConfig\n  ): SuiBaseProcessor {\n    let _filters: EventFilter[] = []\n    const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\n\n    if (Array.isArray(filter)) {\n      _filters = filter\n    } else {\n      _filters.push(filter)\n    }\n\n    // const address = this.config.address\n    // const moduleName = this.moduleName\n\n    const processor = this\n\n    this.eventHandlers.push({\n      handler: async function (data) {\n        if (!data.transaction) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n        }\n        const txn = data.transaction as SuiTransactionBlockResponse\n        if (!txn.events || !txn.events.length) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n        }\n\n        const ctx = new SuiContext(\n          processor.moduleName,\n          processor.config.network,\n          processor.config.address,\n          data.timestamp || new Date(0),\n          data.slot,\n          txn\n        )\n\n        const events = txn.events\n        txn.events = []\n        for (const evt of events) {\n          // if ('moveEvent' in evt) {\n          //   const eventInstance = evt.moveEvent as SuiEvent\n          const decoded = defaultMoveCoder().decodeEvent<any>(evt)\n          await handler(decoded || evt, ctx)\n          // }\n        }\n\n        return ctx.getProcessResult()\n      },\n      filters: _filters,\n      fetchConfig: _fetchConfig,\n    })\n    return this\n  }\n\n  public onEntryFunctionCall(\n    handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,\n    filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n    fetchConfig?: MoveFetchConfig\n  ): SuiBaseProcessor {\n    let _filters: FunctionNameAndCallFilter[] = []\n    const _fetchConfig = fetchConfig || MoveFetchConfig.fromPartial({})\n\n    if (Array.isArray(filter)) {\n      _filters = filter\n    } else {\n      _filters.push(filter)\n    }\n\n    // const address = this.config.address\n    // const moduleName = this.moduleName\n    const processor = this\n\n    this.callHandlers.push({\n      handler: async function (data) {\n        if (!data.transaction) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n        }\n        const tx = data.transaction as SuiTransactionBlockResponse\n\n        const ctx = new SuiContext(\n          processor.moduleName,\n          processor.config.network,\n          processor.config.address,\n          data.timestamp || new Date(0),\n          data.slot,\n          tx\n        )\n        if (tx) {\n          const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\n          if (calls.length !== 1) {\n            throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)\n          }\n          const txKind = getTransactionKind(tx)\n          if (!txKind) {\n            throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')\n          }\n          const programmableTx = getProgrammableTransaction(txKind)\n\n          const payload = calls[0]\n          const decoded = defaultMoveCoder().decodeFunctionPayload(payload, programmableTx?.inputs || [])\n          await handler(decoded, ctx)\n        }\n        return ctx.getProcessResult()\n      },\n      filters: _filters,\n      fetchConfig: _fetchConfig,\n    })\n    return this\n  }\n}\n\nclass ObjectHandler {\n  type?: string\n  versionInterval?: HandleInterval\n  timeIntervalInMinutes?: HandleInterval\n  handler: (resource: Data_SuiObject) => Promise<ProcessResult>\n}\n\nexport class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectsProcessor<any>> {\n  static INSTANCE = new SuiAccountProcessorState()\n}\n\nclass SuiObjectsBindOptions extends SuiBindOptions {\n  ownerType: MoveOnIntervalConfig_OwnerType\n}\n\nabstract class SuiBaseObjectsProcessor<HandlerType> {\n  config: IndexConfigure\n  ownerType: MoveOnIntervalConfig_OwnerType\n\n  objectHandlers: ObjectHandler[] = []\n\n  // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {\n  //   return new SuiBaseObjectsProcessor(options)\n  // }\n\n  protected constructor(options: SuiObjectsBindOptions) {\n    this.config = configure(options)\n    this.ownerType = options.ownerType\n    SuiAccountProcessorState.INSTANCE.addValue(this)\n  }\n\n  getChainId(): string {\n    return getChainId(this.config.network)\n  }\n\n  protected abstract transformObjects(objects: SuiMoveObject[]): HandlerType[]\n\n  protected onInterval(\n    handler: (resources: HandlerType[], ctx: SuiObjectsContext) => void,\n    timeInterval: HandleInterval | undefined,\n    versionInterval: HandleInterval | undefined,\n    type: string | undefined\n  ): this {\n    const processor = this\n    this.objectHandlers.push({\n      handler: async function (data) {\n        const ctx = new SuiObjectsContext(\n          processor.config.network,\n          processor.config.address,\n          data.slot,\n          data.timestamp || new Date(0)\n        )\n        await handler(processor.transformObjects(data.objects as SuiMoveObject[]), ctx)\n        return ctx.getProcessResult()\n      },\n      timeIntervalInMinutes: timeInterval,\n      versionInterval: versionInterval,\n      type,\n    })\n    return this\n  }\n\n  public onTimeInterval(\n    handler: (objects: HandlerType[], ctx: SuiObjectsContext) => void,\n    timeIntervalInMinutes = 60,\n    backfillTimeIntervalInMinutes = 240,\n    type?: string\n  ): this {\n    return this.onInterval(\n      handler,\n      {\n        recentInterval: timeIntervalInMinutes,\n        backfillInterval: backfillTimeIntervalInMinutes,\n      },\n      undefined,\n      type\n    )\n  }\n\n  public onSlotInterval(\n    handler: (objects: HandlerType[], ctx: SuiObjectsContext) => void,\n    slotInterval = 100000,\n    backfillSlotInterval = 400000,\n    type?: string\n  ): this {\n    return this.onInterval(\n      handler,\n      undefined,\n      { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n      type\n    )\n  }\n}\n\nfunction configure(options: SuiBindOptions): IndexConfigure {\n  return {\n    startTimestamp: options.startTimestamp || 0,\n    address: options.address,\n    network: options.network || SuiNetwork.MAIN_NET,\n  }\n}\n\nexport class SuiAddressObjectsProcessor extends SuiBaseObjectsProcessor<SuiMoveObject> {\n  static bind(options: SuiBindOptions): SuiAddressObjectsProcessor {\n    return new SuiAddressObjectsProcessor({ ...options, ownerType: MoveOnIntervalConfig_OwnerType.ADDRESS })\n  }\n\n  protected transformObjects(objects: SuiMoveObject[]): SuiMoveObject[] {\n    return objects\n  }\n}\n// export class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<dynamic_field.Field<any, any>> {\nexport class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<SuiMoveObject> {\n  static bind(options: SuiObjectBindOptions): SuiDynamicFieldObjectsProcessor {\n    return new SuiDynamicFieldObjectsProcessor({\n      address: options.objectId,\n      network: options.network,\n      startTimestamp: options.startTimestamp,\n      ownerType: MoveOnIntervalConfig_OwnerType.OBJECT,\n    })\n  }\n\n  protected transformObjects(objects: SuiMoveObject[]) {\n    return objects\n    // return defaultMoveCoder().getObjectsFromDynamicFields(objects)\n  }\n}\n"]}
         
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,eAAe,EACf,8BAA8B,GAE/B,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAKnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAqE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,mDAAmD;AAEnD,MAAM,cAAc;IAClB,OAAO,CAAQ;IACf,OAAO,CAAY;IACnB,cAAc,CAAQ;CACvB;AAED,MAAM,OAAO,cAAc;IACzB,OAAO,CAAQ;IACf,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAM,OAAO,oBAAoB;IAC/B,QAAQ,CAAQ;IAChB,OAAO,CAAa;IACpB,cAAc,CAAS;CACxB;AAED,MAAa,iBAAkB,SAAQ,gBAAkC;IACvE,MAAM,CAAC,QAAQ,GAAG,IA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O,EAAE,OAAO,CAAC,OAAO,IAAI,UAAU,CAAC,QAAQ;KAChD,CAAA;AACH,CAAC;AAED,MAAM,OAAO,0BAA2B,SAAQ,uBAAsC;IACpF,MAAM,CAAC,IAAI,CAAC,OAAuB;QACjC,OAAO,IAAI,0BAA0B,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,8BAA8B,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1G,CAAC;IAES,gBAAgB,CAAC,OAAwB;QACjD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AACD,gHAAgH;AAChH,MAAM,OAAO,+BAAgC,SAAQ,uBAAsC;IACzF,MAAM,CAAC,IAAI,CAAC,OAA6B;QACvC,OAAO,IAAI,+BAA+B,CAAC;YACzC,OAAO,EAAE,OAAO,CAAC,QAAQ;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,SAAS,EAAE,8BAA8B,CAAC,MAAM;SACjD,CAAC,CAAA;IACJ,CAAC;IAES,gBAAgB,CAAC,OAAwB;QACjD,OAAO,OAAO,CAAA;QACd,iEAAiE;IACnE,CAAC;CACF","sourcesContent":["import {\n  Data_SuiCall,\n  Data_SuiEvent,\n  Data_SuiObject,\n  HandleInterval,\n  MoveFetchConfig,\n  MoveOnIntervalConfig_OwnerType,\n  ProcessResult,\n} from '@sentio/protos'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport { getChainId, SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext, SuiObjectsContext } from './context.js'\nimport {\n  getProgrammableTransaction,\n  getTransactionKind,\n  MoveCallSuiTransaction,\n  SuiEvent,\n  SuiMoveObject,\n  SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder } from './move-coder.js'\n// import { dynamic_field } from './builtin/0x2.js'\n\nclass IndexConfigure {\n  address: string\n  network: SuiNetwork\n  startTimestamp: number\n}\n\nexport class SuiBindOptions {\n  address: string\n  network?: SuiNetwork\n  startTimestamp?: number\n}\n\nexport class SuiObjectBindOptions {\n  objectId: string\n  network?: SuiNetwork\n  startTimestamp?: number\n}\n\nexport class SuiProcessorState extends ListStateStorage<SuiBaseProcessor> {\n  static INSTANCE = new SuiProcessorState()\n}\n\nexport class SuiBaseProcessor {\n  readonly moduleName: string\n  config: IndexConfigure\n\n  eventHandlers: EventHandler<Data_SuiEvent>[] = []\n  callHandlers: CallHandler<Data_SuiCall>[] = []\n\n  constructor(name: string, options: SuiBindOptions) {\n    this.moduleName = name\n    this.config = configure(options)\n    SuiProcessorState.INSTANCE.addValue(this)\n  }\n\n  getChainId(): string {\n    return getChainId(this.config.network)\n  }\n\n  public onMoveEvent(\n    handler: (event: SuiEvent, ctx: SuiContext) => void,\n    filter: EventFilter | EventFilter[],\n    fetchConfig?: Partial<MoveFetchConfig>\n  ): SuiBaseProcessor {\n    let _filters: EventFilter[] = []\n    const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})\n\n    if (Array.isArray(filter)) {\n      _filters = filter\n    } else {\n      _filters.push(filter)\n    }\n\n    // const address = this.config.address\n    // const moduleName = this.moduleName\n\n    const processor = this\n    const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))\n\n    this.eventHandlers.push({\n      handler: async function (data) {\n        if (!data.transaction) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'event is null')\n        }\n        const txn = data.transaction as SuiTransactionBlockResponse\n        if (!txn.events || !txn.events.length) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')\n        }\n\n        const processResults = []\n        for (const [idx, evt] of (txn.events as SuiEvent[]).entries()) {\n          const typeQname = parseMoveType(evt.type).qname\n          if (!allEventType.has(typeQname)) {\n            continue\n          }\n\n          const ctx = new SuiContext(\n            processor.moduleName,\n            processor.config.network,\n            processor.config.address,\n            data.timestamp || new Date(0),\n            data.slot,\n            txn,\n            idx\n          )\n\n          const decoded = defaultMoveCoder().decodeEvent<any>(evt)\n          await handler(decoded || evt, ctx)\n          processResults.push(ctx.getProcessResult())\n        }\n\n        return mergeProcessResults(processResults)\n      },\n      filters: _filters,\n      fetchConfig: _fetchConfig,\n    })\n    return this\n  }\n\n  public onEntryFunctionCall(\n    handler: (call: MoveCallSuiTransaction, ctx: SuiContext) => void,\n    filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],\n    fetchConfig?: Partial<MoveFetchConfig>\n  ): SuiBaseProcessor {\n    let _filters: FunctionNameAndCallFilter[] = []\n    const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})\n\n    if (Array.isArray(filter)) {\n      _filters = filter\n    } else {\n      _filters.push(filter)\n    }\n\n    // const address = this.config.address\n    // const moduleName = this.moduleName\n    const processor = this\n\n    this.callHandlers.push({\n      handler: async function (data) {\n        if (!data.transaction) {\n          throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')\n        }\n        const tx = data.transaction as SuiTransactionBlockResponse\n\n        const ctx = new SuiContext(\n          processor.moduleName,\n          processor.config.network,\n          processor.config.address,\n          data.timestamp || new Date(0),\n          data.slot,\n          tx,\n          0\n        )\n        if (tx) {\n          const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\n          if (calls.length !== 1) {\n            throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected number of call transactions ' + calls.length)\n          }\n          const txKind = getTransactionKind(tx)\n          if (!txKind) {\n            throw new ServerError(Status.INVALID_ARGUMENT, 'Unexpected getTransactionKind get empty')\n          }\n          const programmableTx = getProgrammableTransaction(txKind)\n\n          const payload = calls[0]\n          const decoded = defaultMoveCoder().decodeFunctionPayload(payload, programmableTx?.inputs || [])\n          await handler(decoded, ctx)\n        }\n        return ctx.getProcessResult()\n      },\n      filters: _filters,\n      fetchConfig: _fetchConfig,\n    })\n    return this\n  }\n}\n\nclass ObjectHandler {\n  type?: string\n  versionInterval?: HandleInterval\n  timeIntervalInMinutes?: HandleInterval\n  handler: (resource: Data_SuiObject) => Promise<ProcessResult>\n}\n\nexport class SuiAccountProcessorState extends ListStateStorage<SuiBaseObjectsProcessor<any>> {\n  static INSTANCE = new SuiAccountProcessorState()\n}\n\nclass SuiObjectsBindOptions extends SuiBindOptions {\n  ownerType: MoveOnIntervalConfig_OwnerType\n}\n\nabstract class SuiBaseObjectsProcessor<HandlerType> {\n  config: IndexConfigure\n  ownerType: MoveOnIntervalConfig_OwnerType\n\n  objectHandlers: ObjectHandler[] = []\n\n  // static bind(options: SuiObjectsBindOptions): SuiBaseObjectsProcessor<any> {\n  //   return new SuiBaseObjectsProcessor(options)\n  // }\n\n  protected constructor(options: SuiObjectsBindOptions) {\n    this.config = configure(options)\n    this.ownerType = options.ownerType\n    SuiAccountProcessorState.INSTANCE.addValue(this)\n  }\n\n  getChainId(): string {\n    return getChainId(this.config.network)\n  }\n\n  protected abstract transformObjects(objects: SuiMoveObject[]): HandlerType[]\n\n  protected onInterval(\n    handler: (resources: HandlerType[], ctx: SuiObjectsContext) => void,\n    timeInterval: HandleInterval | undefined,\n    versionInterval: HandleInterval | undefined,\n    type: string | undefined\n  ): this {\n    const processor = this\n    this.objectHandlers.push({\n      handler: async function (data) {\n        const ctx = new SuiObjectsContext(\n          processor.config.network,\n          processor.config.address,\n          data.slot,\n          data.timestamp || new Date(0)\n        )\n        await handler(processor.transformObjects(data.objects as SuiMoveObject[]), ctx)\n        return ctx.getProcessResult()\n      },\n      timeIntervalInMinutes: timeInterval,\n      versionInterval: versionInterval,\n      type,\n    })\n    return this\n  }\n\n  public onTimeInterval(\n    handler: (objects: HandlerType[], ctx: SuiObjectsContext) => void,\n    timeIntervalInMinutes = 60,\n    backfillTimeIntervalInMinutes = 240,\n    type?: string\n  ): this {\n    return this.onInterval(\n      handler,\n      {\n        recentInterval: timeIntervalInMinutes,\n        backfillInterval: backfillTimeIntervalInMinutes,\n      },\n      undefined,\n      type\n    )\n  }\n\n  public onSlotInterval(\n    handler: (objects: HandlerType[], ctx: SuiObjectsContext) => void,\n    slotInterval = 100000,\n    backfillSlotInterval = 400000,\n    type?: string\n  ): this {\n    return this.onInterval(\n      handler,\n      undefined,\n      { recentInterval: slotInterval, backfillInterval: backfillSlotInterval },\n      type\n    )\n  }\n}\n\nfunction configure(options: SuiBindOptions): IndexConfigure {\n  return {\n    startTimestamp: options.startTimestamp || 0,\n    address: options.address,\n    network: options.network || SuiNetwork.MAIN_NET,\n  }\n}\n\nexport class SuiAddressObjectsProcessor extends SuiBaseObjectsProcessor<SuiMoveObject> {\n  static bind(options: SuiBindOptions): SuiAddressObjectsProcessor {\n    return new SuiAddressObjectsProcessor({ ...options, ownerType: MoveOnIntervalConfig_OwnerType.ADDRESS })\n  }\n\n  protected transformObjects(objects: SuiMoveObject[]): SuiMoveObject[] {\n    return objects\n  }\n}\n// export class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<dynamic_field.Field<any, any>> {\nexport class SuiDynamicFieldObjectsProcessor extends SuiBaseObjectsProcessor<SuiMoveObject> {\n  static bind(options: SuiObjectBindOptions): SuiDynamicFieldObjectsProcessor {\n    return new SuiDynamicFieldObjectsProcessor({\n      address: options.objectId,\n      network: options.network,\n      startTimestamp: options.startTimestamp,\n      ownerType: MoveOnIntervalConfig_OwnerType.OBJECT,\n    })\n  }\n\n  protected transformObjects(objects: SuiMoveObject[]) {\n    return objects\n    // return defaultMoveCoder().getObjectsFromDynamicFields(objects)\n  }\n}\n"]}
         
     | 
| 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import { Transaction_UserTransaction } from '../aptos/index.js';
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { TestProcessorServer } from './test-processor-server.js';
         
     | 
| 
       3 
     | 
    
         
            -
            import { AptosNetwork 
     | 
| 
      
 3 
     | 
    
         
            +
            import { AptosNetwork } from '@sentio/sdk/aptos';
         
     | 
| 
       4 
4 
     | 
    
         
             
            export declare class AptosFacet {
         
     | 
| 
       5 
5 
     | 
    
         
             
                server: TestProcessorServer;
         
     | 
| 
       6 
6 
     | 
    
         
             
                constructor(server: TestProcessorServer);
         
     | 
| 
       7 
7 
     | 
    
         
             
                testEntryFunctionCall(transaction: Transaction_UserTransaction, network?: AptosNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       8 
8 
     | 
    
         
             
                testEntryFunctionCalls(transactions: Transaction_UserTransaction[], network?: AptosNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       9 
9 
     | 
    
         
             
                private buildEntryFunctionCallBinding;
         
     | 
| 
       10 
     | 
    
         
            -
                testEvent(transaction: Transaction_UserTransaction,  
     | 
| 
      
 10 
     | 
    
         
            +
                testEvent(transaction: Transaction_UserTransaction, network?: AptosNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       11 
11 
     | 
    
         
             
                private buildEventBinding;
         
     | 
| 
       12 
12 
     | 
    
         
             
            }
         
     | 
| 
         @@ -47,21 +47,14 @@ export class AptosFacet { 
     | 
|
| 
       47 
47 
     | 
    
         
             
                    }
         
     | 
| 
       48 
48 
     | 
    
         
             
                    return undefined;
         
     | 
| 
       49 
49 
     | 
    
         
             
                }
         
     | 
| 
       50 
     | 
    
         
            -
                testEvent(transaction,  
     | 
| 
       51 
     | 
    
         
            -
                     
     | 
| 
       52 
     | 
    
         
            -
                        const transaction2 = {};
         
     | 
| 
       53 
     | 
    
         
            -
                        Object.assign(transaction2, transaction);
         
     | 
| 
       54 
     | 
    
         
            -
                        transaction = transaction2;
         
     | 
| 
       55 
     | 
    
         
            -
                        transaction.events = [event];
         
     | 
| 
       56 
     | 
    
         
            -
                        event = 0;
         
     | 
| 
       57 
     | 
    
         
            -
                    }
         
     | 
| 
       58 
     | 
    
         
            -
                    const binding = this.buildEventBinding(transaction, event, network);
         
     | 
| 
      
 50 
     | 
    
         
            +
                testEvent(transaction, network = AptosNetwork.MAIN_NET) {
         
     | 
| 
      
 51 
     | 
    
         
            +
                    const binding = this.buildEventBinding(transaction, network);
         
     | 
| 
       59 
52 
     | 
    
         
             
                    if (!binding) {
         
     | 
| 
       60 
53 
     | 
    
         
             
                        throw Error('Invalid test event: ' + JSON.stringify(transaction));
         
     | 
| 
       61 
54 
     | 
    
         
             
                    }
         
     | 
| 
       62 
55 
     | 
    
         
             
                    return this.server.processBinding(binding);
         
     | 
| 
       63 
56 
     | 
    
         
             
                }
         
     | 
| 
       64 
     | 
    
         
            -
                buildEventBinding(transaction,  
     | 
| 
      
 57 
     | 
    
         
            +
                buildEventBinding(transaction, network = AptosNetwork.MAIN_NET) {
         
     | 
| 
       65 
58 
     | 
    
         
             
                    // const allEvents = new Set(transaction.events.map(e => e.type))
         
     | 
| 
       66 
59 
     | 
    
         
             
                    for (const config of this.server.contractConfigs) {
         
     | 
| 
       67 
60 
     | 
    
         
             
                        if (config.contract?.chainId !== getChainId(network)) {
         
     | 
| 
         @@ -69,18 +62,18 @@ export class AptosFacet { 
     | 
|
| 
       69 
62 
     | 
    
         
             
                        }
         
     | 
| 
       70 
63 
     | 
    
         
             
                        for (const eventConfig of config.moveEventConfigs) {
         
     | 
| 
       71 
64 
     | 
    
         
             
                            for (const eventFilter of eventConfig.filters) {
         
     | 
| 
       72 
     | 
    
         
            -
                                 
     | 
| 
       73 
     | 
    
         
            -
                                     
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
                                                 
     | 
| 
      
 65 
     | 
    
         
            +
                                for (const event of transaction.events) {
         
     | 
| 
      
 66 
     | 
    
         
            +
                                    if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
         
     | 
| 
      
 67 
     | 
    
         
            +
                                        return {
         
     | 
| 
      
 68 
     | 
    
         
            +
                                            data: {
         
     | 
| 
      
 69 
     | 
    
         
            +
                                                aptEvent: {
         
     | 
| 
      
 70 
     | 
    
         
            +
                                                    transaction,
         
     | 
| 
      
 71 
     | 
    
         
            +
                                                },
         
     | 
| 
       79 
72 
     | 
    
         
             
                                            },
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                                         
     | 
| 
       83 
     | 
    
         
            -
                                    } 
     | 
| 
      
 73 
     | 
    
         
            +
                                            handlerIds: [eventConfig.handlerId],
         
     | 
| 
      
 74 
     | 
    
         
            +
                                            handlerType: HandlerType.APT_EVENT,
         
     | 
| 
      
 75 
     | 
    
         
            +
                                        };
         
     | 
| 
      
 76 
     | 
    
         
            +
                                    }
         
     | 
| 
       84 
77 
     | 
    
         
             
                                }
         
     | 
| 
       85 
78 
     | 
    
         
             
                            }
         
     | 
| 
       86 
79 
     | 
    
         
             
                        }
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"aptos-facet.js","sourceRoot":"","sources":["../../src/testing/aptos-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,YAAY, 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"aptos-facet.js","sourceRoot":"","sources":["../../src/testing/aptos-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAEhD,MAAM,OAAO,UAAU;IACrB,MAAM,CAAqB;IAC3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAA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AC,SAAS;6BACnC,CAAA;yBACF;qBACF;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF","sourcesContent":["import { Transaction_UserTransaction, TransactionPayload_EntryFunctionPayload } from '../aptos/index.js'\nimport { DataBinding, HandlerType } from '@sentio/protos'\nimport { getChainId } from '../aptos/network.js'\nimport { TestProcessorServer } from './test-processor-server.js'\nimport { AptosNetwork } from '@sentio/sdk/aptos'\nimport { parseMoveType } from '../move/types.js'\n\nexport class AptosFacet {\n  server: TestProcessorServer\n  constructor(server: TestProcessorServer) {\n    this.server = server\n  }\n\n  testEntryFunctionCall(transaction: Transaction_UserTransaction, network: AptosNetwork = AptosNetwork.MAIN_NET) {\n    return this.testEntryFunctionCalls([transaction], network)\n  }\n\n  testEntryFunctionCalls(transactions: Transaction_UserTransaction[], network: AptosNetwork = AptosNetwork.MAIN_NET) {\n    const bindings = []\n    for (const trans of transactions) {\n      const binding = this.buildEntryFunctionCallBinding(trans, network)\n      if (!binding) {\n        throw Error('Invalid test transaction: ' + JSON.stringify(trans))\n      }\n      bindings.push(binding)\n    }\n    return this.server.processBindings({\n      bindings: bindings,\n    })\n  }\n\n  private buildEntryFunctionCallBinding(\n    transaction: Transaction_UserTransaction,\n    network: AptosNetwork = AptosNetwork.MAIN_NET\n  ): DataBinding | undefined {\n    const payload = transaction.payload as TransactionPayload_EntryFunctionPayload\n    for (const config of this.server.contractConfigs) {\n      if (config.contract?.chainId !== getChainId(network)) {\n        continue\n      }\n      for (const callConfig of config.moveCallConfigs) {\n        for (const callFilter of callConfig.filters) {\n          if (config.contract.address + '::' + callFilter.function === payload.function) {\n            return {\n              data: {\n                aptCall: {\n                  transaction,\n                },\n              },\n              handlerIds: [callConfig.handlerId],\n              handlerType: HandlerType.APT_CALL,\n            }\n          }\n        }\n      }\n    }\n    return undefined\n  }\n\n  testEvent(transaction: Transaction_UserTransaction, network: AptosNetwork = AptosNetwork.MAIN_NET) {\n    const binding = this.buildEventBinding(transaction, network)\n    if (!binding) {\n      throw Error('Invalid test event: ' + JSON.stringify(transaction))\n    }\n    return this.server.processBinding(binding)\n  }\n\n  private buildEventBinding(\n    transaction: Transaction_UserTransaction,\n    network: AptosNetwork = AptosNetwork.MAIN_NET\n  ): DataBinding | undefined {\n    // const allEvents = new Set(transaction.events.map(e => e.type))\n    for (const config of this.server.contractConfigs) {\n      if (config.contract?.chainId !== getChainId(network)) {\n        continue\n      }\n      for (const eventConfig of config.moveEventConfigs) {\n        for (const eventFilter of eventConfig.filters) {\n          for (const event of transaction.events) {\n            if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {\n              return {\n                data: {\n                  aptEvent: {\n                    transaction,\n                  },\n                },\n                handlerIds: [eventConfig.handlerId],\n                handlerType: HandlerType.APT_EVENT,\n              }\n            }\n          }\n        }\n      }\n    }\n    return undefined\n  }\n}\n"]}
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import {  
     | 
| 
      
 1 
     | 
    
         
            +
            import { SuiTransactionBlockResponse } from '@mysten/sui.js';
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { TestProcessorServer } from './test-processor-server.js';
         
     | 
| 
       3 
3 
     | 
    
         
             
            import { SuiNetwork } from '../sui/index.js';
         
     | 
| 
       4 
4 
     | 
    
         
             
            export declare class SuiFacet {
         
     | 
| 
         @@ -7,6 +7,6 @@ export declare class SuiFacet { 
     | 
|
| 
       7 
7 
     | 
    
         
             
                testEntryFunctionCall(transaction: SuiTransactionBlockResponse, network?: SuiNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       8 
8 
     | 
    
         
             
                testEntryFunctionCalls(transactions: SuiTransactionBlockResponse[], network?: SuiNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       9 
9 
     | 
    
         
             
                private buildEntryFunctionCallBinding;
         
     | 
| 
       10 
     | 
    
         
            -
                testEvent(transaction: SuiTransactionBlockResponse,  
     | 
| 
      
 10 
     | 
    
         
            +
                testEvent(transaction: SuiTransactionBlockResponse, network?: SuiNetwork): Promise<import("@sentio/protos").ProcessBindingResponse>;
         
     | 
| 
       11 
11 
     | 
    
         
             
                private buildEventBinding;
         
     | 
| 
       12 
12 
     | 
    
         
             
            }
         
     | 
    
        package/lib/testing/sui-facet.js
    CHANGED
    
    | 
         @@ -55,45 +55,35 @@ export class SuiFacet { 
     | 
|
| 
       55 
55 
     | 
    
         
             
                    }
         
     | 
| 
       56 
56 
     | 
    
         
             
                    return undefined;
         
     | 
| 
       57 
57 
     | 
    
         
             
                }
         
     | 
| 
       58 
     | 
    
         
            -
                testEvent(transaction,  
     | 
| 
       59 
     | 
    
         
            -
                     
     | 
| 
       60 
     | 
    
         
            -
                        const transaction2 = {};
         
     | 
| 
       61 
     | 
    
         
            -
                        Object.assign(transaction2, transaction);
         
     | 
| 
       62 
     | 
    
         
            -
                        transaction = transaction2;
         
     | 
| 
       63 
     | 
    
         
            -
                        transaction.events = [event];
         
     | 
| 
       64 
     | 
    
         
            -
                        event = 0;
         
     | 
| 
       65 
     | 
    
         
            -
                    }
         
     | 
| 
       66 
     | 
    
         
            -
                    const binding = this.buildEventBinding(transaction, event, network);
         
     | 
| 
      
 58 
     | 
    
         
            +
                testEvent(transaction, network = SuiNetwork.MAIN_NET) {
         
     | 
| 
      
 59 
     | 
    
         
            +
                    const binding = this.buildEventBinding(transaction, network);
         
     | 
| 
       67 
60 
     | 
    
         
             
                    if (!binding) {
         
     | 
| 
       68 
61 
     | 
    
         
             
                        throw Error('Invalid test event: ' + JSON.stringify(transaction));
         
     | 
| 
       69 
62 
     | 
    
         
             
                    }
         
     | 
| 
       70 
63 
     | 
    
         
             
                    return this.server.processBinding(binding);
         
     | 
| 
       71 
64 
     | 
    
         
             
                }
         
     | 
| 
       72 
     | 
    
         
            -
                buildEventBinding(transaction,  
     | 
| 
      
 65 
     | 
    
         
            +
                buildEventBinding(transaction, network = SuiNetwork.MAIN_NET) {
         
     | 
| 
       73 
66 
     | 
    
         
             
                    // const allEvents = new Set(transaction.events.map(e => e.type))
         
     | 
| 
       74 
     | 
    
         
            -
                    const event = transaction.events?.[eventIdx];
         
     | 
| 
       75 
     | 
    
         
            -
                    if (!event) {
         
     | 
| 
       76 
     | 
    
         
            -
                        throw Error('Invaild test transaction, no event located');
         
     | 
| 
       77 
     | 
    
         
            -
                    }
         
     | 
| 
       78 
67 
     | 
    
         
             
                    for (const config of this.server.contractConfigs) {
         
     | 
| 
       79 
68 
     | 
    
         
             
                        if (config.contract?.chainId !== getChainId(network)) {
         
     | 
| 
       80 
69 
     | 
    
         
             
                            continue;
         
     | 
| 
       81 
70 
     | 
    
         
             
                        }
         
     | 
| 
       82 
71 
     | 
    
         
             
                        for (const eventConfig of config.moveEventConfigs) {
         
     | 
| 
       83 
72 
     | 
    
         
             
                            for (const eventFilter of eventConfig.filters) {
         
     | 
| 
       84 
     | 
    
         
            -
                                 
     | 
| 
       85 
     | 
    
         
            -
                                     
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
      
 73 
     | 
    
         
            +
                                for (const event of transaction.events || []) {
         
     | 
| 
      
 74 
     | 
    
         
            +
                                    if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {
         
     | 
| 
      
 75 
     | 
    
         
            +
                                        return {
         
     | 
| 
      
 76 
     | 
    
         
            +
                                            data: {
         
     | 
| 
      
 77 
     | 
    
         
            +
                                                suiEvent: {
         
     | 
| 
      
 78 
     | 
    
         
            +
                                                    transaction,
         
     | 
| 
      
 79 
     | 
    
         
            +
                                                    timestamp: new Date(transaction.timestampMs || 0),
         
     | 
| 
      
 80 
     | 
    
         
            +
                                                    slot: 10000n,
         
     | 
| 
      
 81 
     | 
    
         
            +
                                                },
         
     | 
| 
       92 
82 
     | 
    
         
             
                                            },
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
                                         
     | 
| 
       96 
     | 
    
         
            -
                                    } 
     | 
| 
      
 83 
     | 
    
         
            +
                                            handlerIds: [eventConfig.handlerId],
         
     | 
| 
      
 84 
     | 
    
         
            +
                                            handlerType: HandlerType.SUI_EVENT,
         
     | 
| 
      
 85 
     | 
    
         
            +
                                        };
         
     | 
| 
      
 86 
     | 
    
         
            +
                                    }
         
     | 
| 
       97 
87 
     | 
    
         
             
                                }
         
     | 
| 
       98 
88 
     | 
    
         
             
                            }
         
     | 
| 
       99 
89 
     | 
    
         
             
                        }
         
     | 
| 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            {"version":3,"file":"sui-facet.js","sourceRoot":"","sources":["../../src/testing/sui-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAqB;IAC3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,qBAAqB,CAAC,WAAwC,EAAE,UAAsB,UAAU,CAAC,QAAQ;QACvG,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IAED,sBAAsB,CAAC,YAA2C,EAAE,UAAsB,UAAU,CAAC,QAAQ;QAC3G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AO;4BACL,IAAI,EAAE;gCACJ,OAAO,EAAE;oCACP,WAAW;oCACX,SAAS,EAAE,IAAI,IAAI,EAAE;oCACrB,IAAI,EAAE,MAAM;iCACb;6BACF;4BACD,UAAU,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC;4BAClC,WAAW,EAAE,WAAW,CAAC,QAAQ;yBAClC,CAAA;qBACF;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,SAAS, 
     | 
| 
      
 1 
     | 
    
         
            +
            {"version":3,"file":"sui-facet.js","sourceRoot":"","sources":["../../src/testing/sui-facet.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,WAAW,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,MAAM,OAAO,QAAQ;IACnB,MAAM,CAAqB;IAC3B,YAAY,MAA2B;QACrC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,qBAAqB,CAAC,WAAwC,EAAE,UAAsB,UAAU,CAAC,QAAQ;QACvG,OAAO,IAAI,CAAC,sBAAsB,CAAC,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAA;IAC5D,CAAC;IAED,sBAAsB,CAAC,YAA2C,EAAE,UAAsB,UAAU,CAAC,QAAQ;QAC3G,MAAM,QAAQ,GAAG,EAAE,CAAA;QACnB,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;YAChC,MAAM,OAAO,GAAG,IAAI,CAAC,6BAA6B,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YAClE,IAAI,CAAC,OAAO,EAAE;gBACZ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AAE,WAAW,CAAC,SAAS;6BACnC,CAAA;yBACF;qBACF;iBACF;aACF;SACF;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;CACF","sourcesContent":["import { SuiTransactionBlockResponse, MoveCallSuiTransaction } from '@mysten/sui.js'\nimport { DataBinding, HandlerType } from '@sentio/protos'\nimport { getChainId } from '../sui/network.js'\nimport { TestProcessorServer } from './test-processor-server.js'\nimport { parseMoveType } from '../move/types.js'\nimport { SuiNetwork } from '../sui/index.js'\nimport { getMoveCalls } from '../sui/utils.js'\nimport { SPLITTER } from '../move/index.js'\n\nexport class SuiFacet {\n  server: TestProcessorServer\n  constructor(server: TestProcessorServer) {\n    this.server = server\n  }\n\n  testEntryFunctionCall(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {\n    return this.testEntryFunctionCalls([transaction], network)\n  }\n\n  testEntryFunctionCalls(transactions: SuiTransactionBlockResponse[], network: SuiNetwork = SuiNetwork.MAIN_NET) {\n    const bindings = []\n    for (const trans of transactions) {\n      const binding = this.buildEntryFunctionCallBinding(trans, network)\n      if (!binding) {\n        throw Error('Invalid test transaction: ' + JSON.stringify(trans))\n      }\n      bindings.push(binding)\n    }\n    return this.server.processBindings({\n      bindings: bindings,\n    })\n  }\n\n  private buildEntryFunctionCallBinding(\n    transaction: SuiTransactionBlockResponse,\n    network: SuiNetwork = SuiNetwork.MAIN_NET\n  ): DataBinding | undefined {\n    const calls: MoveCallSuiTransaction[] = getMoveCalls(transaction)\n    if (calls.length !== 1) {\n      throw Error('Transaction has more than one calls')\n    }\n    const functionType = [calls[0].package, calls[0].module, calls[0].function].join(SPLITTER)\n\n    for (const config of this.server.contractConfigs) {\n      if (config.contract?.chainId !== getChainId(network)) {\n        continue\n      }\n      for (const callConfig of config.moveCallConfigs) {\n        for (const callFilter of callConfig.filters) {\n          if (config.contract.address + '::' + callFilter.function === functionType) {\n            return {\n              data: {\n                suiCall: {\n                  transaction,\n                  timestamp: new Date(),\n                  slot: 10000n,\n                },\n              },\n              handlerIds: [callConfig.handlerId],\n              handlerType: HandlerType.SUI_CALL,\n            }\n          }\n        }\n      }\n    }\n    return undefined\n  }\n\n  testEvent(transaction: SuiTransactionBlockResponse, network: SuiNetwork = SuiNetwork.MAIN_NET) {\n    const binding = this.buildEventBinding(transaction, network)\n    if (!binding) {\n      throw Error('Invalid test event: ' + JSON.stringify(transaction))\n    }\n    return this.server.processBinding(binding)\n  }\n\n  private buildEventBinding(\n    transaction: SuiTransactionBlockResponse,\n    network: SuiNetwork = SuiNetwork.MAIN_NET\n  ): DataBinding | undefined {\n    // const allEvents = new Set(transaction.events.map(e => e.type))\n\n    for (const config of this.server.contractConfigs) {\n      if (config.contract?.chainId !== getChainId(network)) {\n        continue\n      }\n      for (const eventConfig of config.moveEventConfigs) {\n        for (const eventFilter of eventConfig.filters) {\n          for (const event of transaction.events || []) {\n            if (config.contract.address + '::' + eventFilter.type === parseMoveType(event.type).qname) {\n              return {\n                data: {\n                  suiEvent: {\n                    transaction,\n                    timestamp: new Date(transaction.timestampMs || 0),\n                    slot: 10000n,\n                  },\n                },\n                handlerIds: [eventConfig.handlerId],\n                handlerType: HandlerType.SUI_EVENT,\n              }\n            }\n          }\n        }\n      }\n    }\n    return undefined\n  }\n}\n"]}
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
              "name": "@sentio/sdk",
         
     | 
| 
       3 
3 
     | 
    
         
             
              "license": "Apache-2.0",
         
     | 
| 
       4 
     | 
    
         
            -
              "version": "2. 
     | 
| 
      
 4 
     | 
    
         
            +
              "version": "2.13.0-rc.2",
         
     | 
| 
       5 
5 
     | 
    
         
             
              "type": "module",
         
     | 
| 
       6 
6 
     | 
    
         
             
              "scripts": {
         
     | 
| 
       7 
7 
     | 
    
         
             
                "compile": "tsc && cp src/utils/*.csv lib/utils && cp src/tsup.config.ts lib",
         
     | 
| 
         @@ -23,8 +23,8 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
                "@project-serum/anchor": "^0.26.0",
         
     | 
| 
       24 
24 
     | 
    
         
             
                "@sentio/bigdecimal": "^9.1.1-patch.3",
         
     | 
| 
       25 
25 
     | 
    
         
             
                "@sentio/ethers-v6": "^1.0.28",
         
     | 
| 
       26 
     | 
    
         
            -
                "@sentio/protos": "^2. 
     | 
| 
       27 
     | 
    
         
            -
                "@sentio/runtime": "^2. 
     | 
| 
      
 26 
     | 
    
         
            +
                "@sentio/protos": "^2.13.0-rc.2",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "@sentio/runtime": "^2.13.0-rc.2",
         
     | 
| 
       28 
28 
     | 
    
         
             
                "@solana/web3.js": "^1.74.0",
         
     | 
| 
       29 
29 
     | 
    
         
             
                "@types/prettier": "^2.7.2",
         
     | 
| 
       30 
30 
     | 
    
         
             
                "aptos-sdk": "npm:aptos@^1.8.3",
         
     | 
| 
         @@ -88,5 +88,5 @@ 
     | 
|
| 
       88 
88 
     | 
    
         
             
              "engines": {
         
     | 
| 
       89 
89 
     | 
    
         
             
                "node": ">=16"
         
     | 
| 
       90 
90 
     | 
    
         
             
              },
         
     | 
| 
       91 
     | 
    
         
            -
              "gitHead": " 
     | 
| 
      
 91 
     | 
    
         
            +
              "gitHead": "f4e3efabbec7e286e20c3f1b0b081131195dfebe"
         
     | 
| 
       92 
92 
     | 
    
         
             
            }
         
     | 
| 
         @@ -4,7 +4,7 @@ import { MOVE_CODER, MoveCoder } from './move-coder.js' 
     | 
|
| 
       4 
4 
     | 
    
         
             
            import { AptosBindOptions, AptosNetwork, getChainId } from './network.js'
         
     | 
| 
       5 
5 
     | 
    
         
             
            import { AptosContext, AptosResourcesContext } from './context.js'
         
     | 
| 
       6 
6 
     | 
    
         
             
            import { EventInstance } from './models.js'
         
     | 
| 
       7 
     | 
    
         
            -
            import { ListStateStorage } from '@sentio/runtime'
         
     | 
| 
      
 7 
     | 
    
         
            +
            import { ListStateStorage, mergeProcessResults } from '@sentio/runtime'
         
     | 
| 
       8 
8 
     | 
    
         
             
            import {
         
     | 
| 
       9 
9 
     | 
    
         
             
              MoveFetchConfig,
         
     | 
| 
       10 
10 
     | 
    
         
             
              Data_AptResource,
         
     | 
| 
         @@ -14,7 +14,7 @@ import { 
     | 
|
| 
       14 
14 
     | 
    
         
             
              Data_AptCall,
         
     | 
| 
       15 
15 
     | 
    
         
             
            } from '@sentio/protos'
         
     | 
| 
       16 
16 
     | 
    
         
             
            import { ServerError, Status } from 'nice-grpc'
         
     | 
| 
       17 
     | 
    
         
            -
            import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter } from '../move/index.js'
         
     | 
| 
      
 17 
     | 
    
         
            +
            import { CallHandler, EventFilter, EventHandler, FunctionNameAndCallFilter, parseMoveType } from '../move/index.js'
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            type IndexConfigure = {
         
     | 
| 
       20 
20 
     | 
    
         
             
              address: string
         
     | 
| 
         @@ -54,9 +54,9 @@ export class AptosBaseProcessor { 
     | 
|
| 
       54 
54 
     | 
    
         
             
              public onTransaction(
         
     | 
| 
       55 
55 
     | 
    
         
             
                handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => void,
         
     | 
| 
       56 
56 
     | 
    
         
             
                includedFailed = false,
         
     | 
| 
       57 
     | 
    
         
            -
                fetchConfig?: MoveFetchConfig
         
     | 
| 
      
 57 
     | 
    
         
            +
                fetchConfig?: Partial<MoveFetchConfig>
         
     | 
| 
       58 
58 
     | 
    
         
             
              ): this {
         
     | 
| 
       59 
     | 
    
         
            -
                const _fetchConfig = fetchConfig ||  
     | 
| 
      
 59 
     | 
    
         
            +
                const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
         
     | 
| 
       60 
60 
     | 
    
         | 
| 
       61 
61 
     | 
    
         
             
                // const address = this.config.address
         
     | 
| 
       62 
62 
     | 
    
         
             
                // const moduleName = this.moduleName
         
     | 
| 
         @@ -72,7 +72,8 @@ export class AptosBaseProcessor { 
     | 
|
| 
       72 
72 
     | 
    
         
             
                      processor.config.network,
         
     | 
| 
       73 
73 
     | 
    
         
             
                      processor.config.address,
         
     | 
| 
       74 
74 
     | 
    
         
             
                      BigInt(data.transaction.version),
         
     | 
| 
       75 
     | 
    
         
            -
                      call
         
     | 
| 
      
 75 
     | 
    
         
            +
                      call,
         
     | 
| 
      
 76 
     | 
    
         
            +
                      0
         
     | 
| 
       76 
77 
     | 
    
         
             
                    )
         
     | 
| 
       77 
78 
     | 
    
         
             
                    await handler(call, ctx)
         
     | 
| 
       78 
79 
     | 
    
         
             
                    return ctx.getProcessResult()
         
     | 
| 
         @@ -86,10 +87,10 @@ export class AptosBaseProcessor { 
     | 
|
| 
       86 
87 
     | 
    
         
             
              public onMoveEvent(
         
     | 
| 
       87 
88 
     | 
    
         
             
                handler: (event: EventInstance, ctx: AptosContext) => void,
         
     | 
| 
       88 
89 
     | 
    
         
             
                filter: EventFilter | EventFilter[],
         
     | 
| 
       89 
     | 
    
         
            -
                fetchConfig?: MoveFetchConfig
         
     | 
| 
      
 90 
     | 
    
         
            +
                fetchConfig?: Partial<MoveFetchConfig>
         
     | 
| 
       90 
91 
     | 
    
         
             
              ): this {
         
     | 
| 
       91 
92 
     | 
    
         
             
                let _filters: EventFilter[] = []
         
     | 
| 
       92 
     | 
    
         
            -
                const _fetchConfig = fetchConfig ||  
     | 
| 
      
 93 
     | 
    
         
            +
                const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
         
     | 
| 
       93 
94 
     | 
    
         | 
| 
       94 
95 
     | 
    
         
             
                if (Array.isArray(filter)) {
         
     | 
| 
       95 
96 
     | 
    
         
             
                  _filters = filter
         
     | 
| 
         @@ -97,10 +98,10 @@ export class AptosBaseProcessor { 
     | 
|
| 
       97 
98 
     | 
    
         
             
                  _filters.push(filter)
         
     | 
| 
       98 
99 
     | 
    
         
             
                }
         
     | 
| 
       99 
100 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
                // const address = this.config.address
         
     | 
| 
       101 
101 
     | 
    
         
             
                // const moduleName = this.moduleName
         
     | 
| 
       102 
102 
     | 
    
         | 
| 
       103 
103 
     | 
    
         
             
                const processor = this
         
     | 
| 
      
 104 
     | 
    
         
            +
                const allEventType = new Set(_filters.map((f) => processor.config.address + '::' + f.type))
         
     | 
| 
       104 
105 
     | 
    
         | 
| 
       105 
106 
     | 
    
         
             
                this.eventHandlers.push({
         
     | 
| 
       106 
107 
     | 
    
         
             
                  handler: async function (data) {
         
     | 
| 
         @@ -112,23 +113,28 @@ export class AptosBaseProcessor { 
     | 
|
| 
       112 
113 
     | 
    
         
             
                      throw new ServerError(Status.INVALID_ARGUMENT, 'no event in the transactions')
         
     | 
| 
       113 
114 
     | 
    
         
             
                    }
         
     | 
| 
       114 
115 
     | 
    
         | 
| 
       115 
     | 
    
         
            -
                    const  
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
                       
     | 
| 
       118 
     | 
    
         
            -
                       
     | 
| 
       119 
     | 
    
         
            -
             
     | 
| 
       120 
     | 
    
         
            -
                       
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
                    const processResults = []
         
     | 
| 
      
 117 
     | 
    
         
            +
                    for (const [idx, evt] of txn.events.entries()) {
         
     | 
| 
      
 118 
     | 
    
         
            +
                      const typeQname = parseMoveType(evt.type).qname
         
     | 
| 
      
 119 
     | 
    
         
            +
                      if (!allEventType.has(typeQname)) {
         
     | 
| 
      
 120 
     | 
    
         
            +
                        continue
         
     | 
| 
      
 121 
     | 
    
         
            +
                      }
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                      const ctx = new AptosContext(
         
     | 
| 
      
 124 
     | 
    
         
            +
                        processor.moduleName,
         
     | 
| 
      
 125 
     | 
    
         
            +
                        processor.config.network,
         
     | 
| 
      
 126 
     | 
    
         
            +
                        processor.config.address,
         
     | 
| 
      
 127 
     | 
    
         
            +
                        BigInt(txn.version),
         
     | 
| 
      
 128 
     | 
    
         
            +
                        txn,
         
     | 
| 
      
 129 
     | 
    
         
            +
                        idx
         
     | 
| 
      
 130 
     | 
    
         
            +
                      )
         
     | 
| 
       126 
131 
     | 
    
         
             
                      const eventInstance = evt as EventInstance
         
     | 
| 
       127 
132 
     | 
    
         
             
                      const decoded = MOVE_CODER.decodeEvent<any>(eventInstance)
         
     | 
| 
       128 
133 
     | 
    
         
             
                      await handler(decoded || eventInstance, ctx)
         
     | 
| 
      
 134 
     | 
    
         
            +
                      processResults.push(ctx.getProcessResult())
         
     | 
| 
       129 
135 
     | 
    
         
             
                    }
         
     | 
| 
       130 
136 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
                    return  
     | 
| 
      
 137 
     | 
    
         
            +
                    return mergeProcessResults(processResults)
         
     | 
| 
       132 
138 
     | 
    
         
             
                  },
         
     | 
| 
       133 
139 
     | 
    
         
             
                  filters: _filters,
         
     | 
| 
       134 
140 
     | 
    
         
             
                  fetchConfig: _fetchConfig,
         
     | 
| 
         @@ -139,10 +145,10 @@ export class AptosBaseProcessor { 
     | 
|
| 
       139 
145 
     | 
    
         
             
              public onEntryFunctionCall(
         
     | 
| 
       140 
146 
     | 
    
         
             
                handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => void,
         
     | 
| 
       141 
147 
     | 
    
         
             
                filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
         
     | 
| 
       142 
     | 
    
         
            -
                fetchConfig?: MoveFetchConfig
         
     | 
| 
      
 148 
     | 
    
         
            +
                fetchConfig?: Partial<MoveFetchConfig>
         
     | 
| 
       143 
149 
     | 
    
         
             
              ): this {
         
     | 
| 
       144 
150 
     | 
    
         
             
                let _filters: FunctionNameAndCallFilter[] = []
         
     | 
| 
       145 
     | 
    
         
            -
                const _fetchConfig = fetchConfig ||  
     | 
| 
      
 151 
     | 
    
         
            +
                const _fetchConfig = MoveFetchConfig.fromPartial(fetchConfig || {})
         
     | 
| 
       146 
152 
     | 
    
         | 
| 
       147 
153 
     | 
    
         
             
                if (Array.isArray(filter)) {
         
     | 
| 
       148 
154 
     | 
    
         
             
                  _filters = filter
         
     | 
| 
         @@ -166,7 +172,8 @@ export class AptosBaseProcessor { 
     | 
|
| 
       166 
172 
     | 
    
         
             
                      processor.config.network,
         
     | 
| 
       167 
173 
     | 
    
         
             
                      processor.config.address,
         
     | 
| 
       168 
174 
     | 
    
         
             
                      BigInt(tx.version),
         
     | 
| 
       169 
     | 
    
         
            -
                      tx
         
     | 
| 
      
 175 
     | 
    
         
            +
                      tx,
         
     | 
| 
      
 176 
     | 
    
         
            +
                      0
         
     | 
| 
       170 
177 
     | 
    
         
             
                    )
         
     | 
| 
       171 
178 
     | 
    
         
             
                    if (tx) {
         
     | 
| 
       172 
179 
     | 
    
         
             
                      const payload = tx.payload as TransactionPayload_EntryFunctionPayload
         
     |