@sentio/sdk 2.16.2-rc.1 → 2.16.2-rc.3
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 +6 -2
- package/lib/aptos/aptos-processor.js +27 -23
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/index.d.ts +1 -1
- package/lib/aptos/index.js +1 -1
- package/lib/aptos/index.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +1 -1
- package/lib/eth/base-processor-template.js +5 -3
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +4 -4
- package/lib/eth/base-processor.js +17 -17
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +31 -31
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +16 -16
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +24 -24
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +13 -13
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +20 -20
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +19 -19
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/ethers-sentio.js +11 -11
- package/lib/eth/codegen/ethers-sentio.js.map +1 -1
- package/lib/eth/codegen/event-handler.js +1 -1
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +1 -1
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/generic-processor.test.js.map +1 -1
- package/lib/sui/sui-processor.d.ts +8 -3
- package/lib/sui/sui-processor.js +29 -2
- package/lib/sui/sui-processor.js.map +1 -1
- package/package.json +3 -3
- package/src/aptos/aptos-processor.ts +44 -51
- package/src/aptos/index.ts +1 -1
- package/src/eth/base-processor-template.ts +5 -3
- package/src/eth/base-processor.ts +25 -25
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +31 -31
- package/src/eth/builtin/internal/erc1155-processor.ts +16 -16
- package/src/eth/builtin/internal/erc20-processor.ts +24 -24
- package/src/eth/builtin/internal/erc20bytes-processor.ts +13 -13
- package/src/eth/builtin/internal/erc721-processor.ts +20 -20
- package/src/eth/builtin/internal/weth9-processor.ts +19 -19
- package/src/eth/codegen/ethers-sentio.ts +11 -11
- package/src/eth/codegen/event-handler.ts +1 -1
- package/src/eth/codegen/functions-handler.ts +1 -1
- package/src/sui/sui-processor.ts +50 -4
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAInB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAKL,aAAa,EACb,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,CAAA;AAI7D,MAAM,oBAAoB,GAAoB;IAC5C,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE,IAAI;CAChB,CAAA;AAID,MAAM,UAAU,SAAS,CAAC,OAAuB;IAC/C,OAAO;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AAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig } from '@sentio/protos'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport { SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext } from './context.js'\nimport {\n getProgrammableTransaction,\n getTransactionKind,\n MoveCallSuiTransaction,\n SuiEvent,\n SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport {\n CallHandler,\n EventFilter,\n EventHandler,\n FunctionNameAndCallFilter,\n parseMoveType,\n SPLITTER,\n} from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { Labels } from '../core/index.js'\nimport { Required } from 'utility-types'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\nexport type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>\n\nexport function configure(options: SuiBindOptions): IndexConfigure {\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n\nexport interface SuiBindOptions {\n address: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: Labels\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 coder: MoveCoder\n\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n }\n\n getChainId(): string {\n return 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({ ...DEFAULT_FETCH_CONFIG, ...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 processor.config.baseLabels\n )\n\n const decoded = await processor.coder.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({ ...DEFAULT_FETCH_CONFIG, ...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 const allFunctionType = new Set(_filters.map((f) => processor.config.address + '::' + f.function))\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 processor.config.baseLabels\n )\n if (tx) {\n const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\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 // TODO potential pass index\n for (const call of calls) {\n const functionType = [call.package, call.module, call.function].join(SPLITTER)\n if (!allFunctionType.has(functionType)) {\n continue\n }\n\n // TODO maybe do in parallel\n const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || [])\n await handler(decoded, ctx)\n }\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n"]}
|
1
|
+
{"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/sui/sui-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAC7E,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EACL,0BAA0B,EAC1B,kBAAkB,GAInB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAKL,aAAa,EACb,QAAQ,GACT,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAa,MAAM,iBAAiB,C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AAQ,EAAE,EAAE,EAAE,aAAa,EAAE,CAAC;YAC1C,WAAW,EAAE,YAAY;SAC1B,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED,MAAM,OAAO,mBAAoB,SAAQ,gBAAgB;IACvD,YAAY,OAAuB;QACjC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACrB,CAAC;CACF","sourcesContent":["import { Data_SuiCall, Data_SuiEvent, MoveFetchConfig } from '@sentio/protos'\nimport { ListStateStorage, mergeProcessResults } from '@sentio/runtime'\nimport { SuiNetwork } from './network.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { SuiContext } from './context.js'\nimport {\n getProgrammableTransaction,\n getTransactionKind,\n MoveCallSuiTransaction,\n SuiEvent,\n SuiTransactionBlockResponse,\n} from '@mysten/sui.js'\nimport {\n CallHandler,\n EventFilter,\n EventHandler,\n FunctionNameAndCallFilter,\n parseMoveType,\n SPLITTER,\n} from '../move/index.js'\nimport { getMoveCalls } from './utils.js'\nimport { defaultMoveCoder, MoveCoder } from './move-coder.js'\nimport { Labels } from '../core/index.js'\nimport { Required } from 'utility-types'\n\nconst DEFAULT_FETCH_CONFIG: MoveFetchConfig = {\n resourceChanges: false,\n allEvents: true,\n}\n\nexport type IndexConfigure = Required<SuiBindOptions, 'startCheckpoint' | 'network'>\n\nexport function configure(options: SuiBindOptions): IndexConfigure {\n return {\n startCheckpoint: options.startCheckpoint || 0n,\n address: options.address,\n network: options.network || SuiNetwork.MAIN_NET,\n baseLabels: options.baseLabels,\n }\n}\n\nexport interface SuiBindOptions {\n address: string\n network?: SuiNetwork\n startCheckpoint?: bigint\n baseLabels?: Labels\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 coder: MoveCoder\n\n constructor(name: string, options: SuiBindOptions) {\n this.moduleName = name\n this.config = configure(options)\n SuiProcessorState.INSTANCE.addValue(this)\n this.coder = defaultMoveCoder(this.config.network)\n }\n\n getChainId(): string {\n return this.config.network\n }\n\n protected 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({ ...DEFAULT_FETCH_CONFIG, ...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 processor.config.baseLabels\n )\n\n const decoded = await processor.coder.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 protected 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({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const processor = this\n const allFunctionType = new Set(_filters.map((f) => processor.config.address + '::' + f.function))\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 processor.config.baseLabels\n )\n if (tx) {\n const calls: MoveCallSuiTransaction[] = getMoveCalls(tx)\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 // TODO potential pass index\n for (const call of calls) {\n const functionType = [call.package, call.module, call.function].join(SPLITTER)\n if (!allFunctionType.has(functionType)) {\n continue\n }\n\n // TODO maybe do in parallel\n const decoded = await processor.coder.decodeFunctionPayload(call, programmableTx?.inputs || [])\n await handler(decoded, ctx)\n }\n }\n return ctx.getProcessResult()\n },\n filters: _filters,\n fetchConfig: _fetchConfig,\n })\n return this\n }\n\n onEvent(handler: (event: SuiEvent, ctx: SuiContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {\n this.onMoveEvent(handler, { type: '' }, fetchConfig)\n return this\n }\n\n onTransactionBlock(\n handler: (call: SuiTransactionBlockResponse, ctx: SuiContext) => void,\n includeFailed = false,\n fetchConfig?: Partial<MoveFetchConfig>\n ): this {\n const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })\n\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 processor.config.baseLabels\n )\n if (tx) {\n await handler(tx, ctx)\n }\n return ctx.getProcessResult()\n },\n filters: [{ function: '', includeFailed }],\n fetchConfig: _fetchConfig,\n })\n return this\n }\n}\n\nexport class SuiModulesProcessor extends SuiBaseProcessor {\n constructor(options: SuiBindOptions) {\n super('*', options)\n }\n}\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/sdk",
|
3
|
-
"version": "2.16.2-rc.
|
3
|
+
"version": "2.16.2-rc.3",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -71,8 +71,8 @@
|
|
71
71
|
"typedoc": "^0.24.1",
|
72
72
|
"utility-types": "^3.10.0",
|
73
73
|
"yaml": "^2.2.1",
|
74
|
-
"@sentio/protos": "2.16.2-rc.
|
75
|
-
"@sentio/runtime": "^2.16.2-rc.
|
74
|
+
"@sentio/protos": "2.16.2-rc.3",
|
75
|
+
"@sentio/runtime": "^2.16.2-rc.3"
|
76
76
|
},
|
77
77
|
"peerDependencies": {
|
78
78
|
"tsup": "npm:@sentio/tsup@^6.7.0"
|
@@ -60,45 +60,7 @@ export class AptosBaseProcessor {
|
|
60
60
|
// this.loadTypes(this.coder)
|
61
61
|
}
|
62
62
|
|
63
|
-
|
64
|
-
// return undefined
|
65
|
-
// }
|
66
|
-
|
67
|
-
public onTransaction(
|
68
|
-
handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid,
|
69
|
-
includedFailed = false,
|
70
|
-
fetchConfig?: Partial<MoveFetchConfig>
|
71
|
-
): this {
|
72
|
-
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
|
73
|
-
|
74
|
-
// const address = this.config.address
|
75
|
-
// const moduleName = this.moduleName
|
76
|
-
const processor = this
|
77
|
-
this.callHandlers.push({
|
78
|
-
handler: async function (data) {
|
79
|
-
if (!data.transaction) {
|
80
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
81
|
-
}
|
82
|
-
const call = data.transaction as Transaction_UserTransaction
|
83
|
-
const ctx = new AptosContext(
|
84
|
-
processor.moduleName,
|
85
|
-
processor.config.network,
|
86
|
-
processor.config.address,
|
87
|
-
BigInt(data.transaction.version),
|
88
|
-
call,
|
89
|
-
0,
|
90
|
-
processor.config.baseLabels
|
91
|
-
)
|
92
|
-
await handler(call, ctx)
|
93
|
-
return ctx.getProcessResult()
|
94
|
-
},
|
95
|
-
filters: [{ function: '', includeFailed: includedFailed }],
|
96
|
-
fetchConfig: _fetchConfig,
|
97
|
-
})
|
98
|
-
return this
|
99
|
-
}
|
100
|
-
|
101
|
-
public onMoveEvent(
|
63
|
+
protected onMoveEvent(
|
102
64
|
handler: (event: Event, ctx: AptosContext) => void,
|
103
65
|
filter: EventFilter | EventFilter[],
|
104
66
|
fetchConfig?: Partial<MoveFetchConfig>
|
@@ -157,7 +119,7 @@ export class AptosBaseProcessor {
|
|
157
119
|
return this
|
158
120
|
}
|
159
121
|
|
160
|
-
|
122
|
+
protected onEntryFunctionCall(
|
161
123
|
handler: (call: TransactionPayload_EntryFunctionPayload, ctx: AptosContext) => PromiseOrVoid,
|
162
124
|
filter: FunctionNameAndCallFilter | FunctionNameAndCallFilter[],
|
163
125
|
fetchConfig?: Partial<MoveFetchConfig>
|
@@ -204,21 +166,52 @@ export class AptosBaseProcessor {
|
|
204
166
|
return this
|
205
167
|
}
|
206
168
|
|
169
|
+
public onTransaction(
|
170
|
+
handler: (transaction: Transaction_UserTransaction, ctx: AptosContext) => PromiseOrVoid,
|
171
|
+
includedFailed = false,
|
172
|
+
fetchConfig?: Partial<MoveFetchConfig>
|
173
|
+
): this {
|
174
|
+
const _fetchConfig = MoveFetchConfig.fromPartial({ ...DEFAULT_FETCH_CONFIG, ...fetchConfig })
|
175
|
+
|
176
|
+
const processor = this
|
177
|
+
this.callHandlers.push({
|
178
|
+
handler: async function (data) {
|
179
|
+
if (!data.transaction) {
|
180
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'call is null')
|
181
|
+
}
|
182
|
+
const call = data.transaction as Transaction_UserTransaction
|
183
|
+
const ctx = new AptosContext(
|
184
|
+
processor.moduleName,
|
185
|
+
processor.config.network,
|
186
|
+
processor.config.address,
|
187
|
+
BigInt(data.transaction.version),
|
188
|
+
call,
|
189
|
+
0,
|
190
|
+
processor.config.baseLabels
|
191
|
+
)
|
192
|
+
await handler(call, ctx)
|
193
|
+
return ctx.getProcessResult()
|
194
|
+
},
|
195
|
+
filters: [{ function: '', includeFailed: includedFailed }],
|
196
|
+
fetchConfig: _fetchConfig,
|
197
|
+
})
|
198
|
+
return this
|
199
|
+
}
|
200
|
+
|
201
|
+
public onEvent(handler: (event: Event, ctx: AptosContext) => void, fetchConfig?: Partial<MoveFetchConfig>): this {
|
202
|
+
this.onMoveEvent(handler, { type: '' }, fetchConfig)
|
203
|
+
return this
|
204
|
+
}
|
205
|
+
|
207
206
|
getChainId(): string {
|
208
207
|
return this.config.network
|
209
208
|
}
|
209
|
+
}
|
210
210
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
// this.loadTypesInternal(registry)
|
216
|
-
// }
|
217
|
-
//
|
218
|
-
// protected loadTypesInternal(registry: MoveCoder) {
|
219
|
-
// // should be override by subclass
|
220
|
-
// console.log('')
|
221
|
-
// }
|
211
|
+
export class AptosModulesProcessor extends AptosBaseProcessor {
|
212
|
+
constructor(options: AptosBindOptions) {
|
213
|
+
super('*', options)
|
214
|
+
}
|
222
215
|
}
|
223
216
|
|
224
217
|
export class AptosAccountProcessorState extends ListStateStorage<AptosResourcesProcessor> {
|
package/src/aptos/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export * from './move-types.js'
|
2
2
|
export type { TypedEventInstance, TypedFunctionPayload, TypedMoveResource } from './models.js'
|
3
3
|
export { defaultMoveCoder, MoveCoder } from './move-coder.js'
|
4
|
-
export { AptosBaseProcessor, AptosResourcesProcessor } from './aptos-processor.js'
|
4
|
+
export { AptosBaseProcessor, AptosResourcesProcessor, AptosModulesProcessor } from './aptos-processor.js'
|
5
5
|
export { AptosContext, AptosResourcesContext } from './context.js'
|
6
6
|
export { AptosBindOptions, AptosNetwork } from './network.js'
|
7
7
|
export * from './api.js'
|
@@ -64,10 +64,12 @@ export abstract class BaseProcessorTemplate<
|
|
64
64
|
const processor = this.bindInternal(options)
|
65
65
|
|
66
66
|
for (const eh of this.eventHandlers) {
|
67
|
-
|
67
|
+
// @ts-ignore friendly
|
68
|
+
processor.onEthEvent(eh.handler, eh.filter, eh.fetchConfig)
|
68
69
|
}
|
69
70
|
for (const th of this.traceHandlers) {
|
70
|
-
|
71
|
+
// @ts-ignore friendly
|
72
|
+
processor.onEthTrace(th.signature, th.handler, th.fetchConfig)
|
71
73
|
}
|
72
74
|
for (const bh of this.blockHandlers) {
|
73
75
|
processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval, bh.fetchConfig)
|
@@ -94,7 +96,7 @@ export abstract class BaseProcessorTemplate<
|
|
94
96
|
ctx._res.states.configUpdated = true
|
95
97
|
}
|
96
98
|
|
97
|
-
|
99
|
+
protected onEthEvent(
|
98
100
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
99
101
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
100
102
|
fetchConfig?: Partial<EthFetchConfig>
|
@@ -204,6 +204,28 @@ export abstract class BaseProcessor<
|
|
204
204
|
}
|
205
205
|
|
206
206
|
public onEvent(
|
207
|
+
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
208
|
+
fetchConfig?: Partial<EthFetchConfig>
|
209
|
+
): this {
|
210
|
+
const _filters: DeferredTopicFilter[] = []
|
211
|
+
const tmpContract = this.CreateBoundContractView()
|
212
|
+
|
213
|
+
for (const fragment of tmpContract.rawContract.interface.fragments) {
|
214
|
+
if (fragment.type === 'event') {
|
215
|
+
const filter = tmpContract.rawContract.filters[fragment.format()]
|
216
|
+
_filters.push(filter())
|
217
|
+
}
|
218
|
+
}
|
219
|
+
return this.onEthEvent(
|
220
|
+
function (log, ctx) {
|
221
|
+
return handler(log, ctx)
|
222
|
+
},
|
223
|
+
_filters,
|
224
|
+
fetchConfig
|
225
|
+
)
|
226
|
+
}
|
227
|
+
|
228
|
+
protected onEthEvent(
|
207
229
|
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
208
230
|
filter: DeferredTopicFilter | DeferredTopicFilter[],
|
209
231
|
fetchConfig?: Partial<EthFetchConfig>
|
@@ -325,29 +347,7 @@ export abstract class BaseProcessor<
|
|
325
347
|
return this
|
326
348
|
}
|
327
349
|
|
328
|
-
|
329
|
-
handler: (event: TypedEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
330
|
-
fetchConfig?: Partial<EthFetchConfig>
|
331
|
-
): this {
|
332
|
-
const _filters: DeferredTopicFilter[] = []
|
333
|
-
const tmpContract = this.CreateBoundContractView()
|
334
|
-
|
335
|
-
for (const fragment of tmpContract.rawContract.interface.fragments) {
|
336
|
-
if (fragment.type === 'event') {
|
337
|
-
const filter = tmpContract.rawContract.filters[fragment.format()]
|
338
|
-
_filters.push(filter())
|
339
|
-
}
|
340
|
-
}
|
341
|
-
return this.onEvent(
|
342
|
-
function (log, ctx) {
|
343
|
-
return handler(log, ctx)
|
344
|
-
},
|
345
|
-
_filters,
|
346
|
-
fetchConfig
|
347
|
-
)
|
348
|
-
}
|
349
|
-
|
350
|
-
public onTrace(
|
350
|
+
protected onEthTrace(
|
351
351
|
signatures: string | string[],
|
352
352
|
handler: (trace: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
353
353
|
fetchConfig?: Partial<EthFetchConfig>
|
@@ -409,7 +409,7 @@ export abstract class BaseProcessor<
|
|
409
409
|
return this
|
410
410
|
}
|
411
411
|
|
412
|
-
public
|
412
|
+
public onTrace(
|
413
413
|
handler: (event: TypedCallTrace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,
|
414
414
|
fetchConfig?: Partial<EthFetchConfig>
|
415
415
|
): this {
|
@@ -424,7 +424,7 @@ export abstract class BaseProcessor<
|
|
424
424
|
sighashes.push(sighash)
|
425
425
|
}
|
426
426
|
}
|
427
|
-
return this.
|
427
|
+
return this.onEthTrace(
|
428
428
|
sighashes,
|
429
429
|
function (trace, ctx) {
|
430
430
|
return handler(trace, ctx)
|
@@ -620,7 +620,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
620
620
|
"AnswerUpdated(int256,uint256,uint256)"
|
621
621
|
](null, null, null);
|
622
622
|
}
|
623
|
-
return super.
|
623
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
624
624
|
}
|
625
625
|
|
626
626
|
onEventNewRound(
|
@@ -635,7 +635,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
635
635
|
null
|
636
636
|
);
|
637
637
|
}
|
638
|
-
return super.
|
638
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
639
639
|
}
|
640
640
|
|
641
641
|
onEventOwnershipTransferRequested(
|
@@ -653,7 +653,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
653
653
|
"OwnershipTransferRequested(address,address)"
|
654
654
|
](null, null);
|
655
655
|
}
|
656
|
-
return super.
|
656
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
657
657
|
}
|
658
658
|
|
659
659
|
onEventOwnershipTransferred(
|
@@ -671,7 +671,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
671
671
|
"OwnershipTransferred(address,address)"
|
672
672
|
](null, null);
|
673
673
|
}
|
674
|
-
return super.
|
674
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
675
675
|
}
|
676
676
|
|
677
677
|
onCallAcceptOwnership(
|
@@ -681,7 +681,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
681
681
|
) => void,
|
682
682
|
fetchConfig?: Partial<EthFetchConfig>
|
683
683
|
): this {
|
684
|
-
return super.
|
684
|
+
return super.onEthTrace("0x79ba5097", handler as any, fetchConfig);
|
685
685
|
}
|
686
686
|
|
687
687
|
onCallAccessController(
|
@@ -691,7 +691,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
691
691
|
) => void,
|
692
692
|
fetchConfig?: Partial<EthFetchConfig>
|
693
693
|
): this {
|
694
|
-
return super.
|
694
|
+
return super.onEthTrace("0xbc43cbaf", handler as any, fetchConfig);
|
695
695
|
}
|
696
696
|
|
697
697
|
onCallAggregator(
|
@@ -701,7 +701,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
701
701
|
) => void,
|
702
702
|
fetchConfig?: Partial<EthFetchConfig>
|
703
703
|
): this {
|
704
|
-
return super.
|
704
|
+
return super.onEthTrace("0x245a7bfc", handler as any, fetchConfig);
|
705
705
|
}
|
706
706
|
|
707
707
|
onCallConfirmAggregator(
|
@@ -711,14 +711,14 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
711
711
|
) => void,
|
712
712
|
fetchConfig?: Partial<EthFetchConfig>
|
713
713
|
): this {
|
714
|
-
return super.
|
714
|
+
return super.onEthTrace("0xa928c096", handler as any, fetchConfig);
|
715
715
|
}
|
716
716
|
|
717
717
|
onCallDecimals(
|
718
718
|
handler: (call: DecimalsCallTrace, ctx: EACAggregatorProxyContext) => void,
|
719
719
|
fetchConfig?: Partial<EthFetchConfig>
|
720
720
|
): this {
|
721
|
-
return super.
|
721
|
+
return super.onEthTrace("0x313ce567", handler as any, fetchConfig);
|
722
722
|
}
|
723
723
|
|
724
724
|
onCallDescription(
|
@@ -728,14 +728,14 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
728
728
|
) => void,
|
729
729
|
fetchConfig?: Partial<EthFetchConfig>
|
730
730
|
): this {
|
731
|
-
return super.
|
731
|
+
return super.onEthTrace("0x7284e416", handler as any, fetchConfig);
|
732
732
|
}
|
733
733
|
|
734
734
|
onCallGetAnswer(
|
735
735
|
handler: (call: GetAnswerCallTrace, ctx: EACAggregatorProxyContext) => void,
|
736
736
|
fetchConfig?: Partial<EthFetchConfig>
|
737
737
|
): this {
|
738
|
-
return super.
|
738
|
+
return super.onEthTrace("0xb5ab58dc", handler as any, fetchConfig);
|
739
739
|
}
|
740
740
|
|
741
741
|
onCallGetRoundData(
|
@@ -745,7 +745,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
745
745
|
) => void,
|
746
746
|
fetchConfig?: Partial<EthFetchConfig>
|
747
747
|
): this {
|
748
|
-
return super.
|
748
|
+
return super.onEthTrace("0x9a6fc8f5", handler as any, fetchConfig);
|
749
749
|
}
|
750
750
|
|
751
751
|
onCallGetTimestamp(
|
@@ -755,7 +755,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
755
755
|
) => void,
|
756
756
|
fetchConfig?: Partial<EthFetchConfig>
|
757
757
|
): this {
|
758
|
-
return super.
|
758
|
+
return super.onEthTrace("0xb633620c", handler as any, fetchConfig);
|
759
759
|
}
|
760
760
|
|
761
761
|
onCallLatestAnswer(
|
@@ -765,7 +765,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
765
765
|
) => void,
|
766
766
|
fetchConfig?: Partial<EthFetchConfig>
|
767
767
|
): this {
|
768
|
-
return super.
|
768
|
+
return super.onEthTrace("0x50d25bcd", handler as any, fetchConfig);
|
769
769
|
}
|
770
770
|
|
771
771
|
onCallLatestRound(
|
@@ -775,7 +775,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
775
775
|
) => void,
|
776
776
|
fetchConfig?: Partial<EthFetchConfig>
|
777
777
|
): this {
|
778
|
-
return super.
|
778
|
+
return super.onEthTrace("0x668a0f02", handler as any, fetchConfig);
|
779
779
|
}
|
780
780
|
|
781
781
|
onCallLatestRoundData(
|
@@ -785,7 +785,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
785
785
|
) => void,
|
786
786
|
fetchConfig?: Partial<EthFetchConfig>
|
787
787
|
): this {
|
788
|
-
return super.
|
788
|
+
return super.onEthTrace("0xfeaf968c", handler as any, fetchConfig);
|
789
789
|
}
|
790
790
|
|
791
791
|
onCallLatestTimestamp(
|
@@ -795,14 +795,14 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
795
795
|
) => void,
|
796
796
|
fetchConfig?: Partial<EthFetchConfig>
|
797
797
|
): this {
|
798
|
-
return super.
|
798
|
+
return super.onEthTrace("0x8205bf6a", handler as any, fetchConfig);
|
799
799
|
}
|
800
800
|
|
801
801
|
onCallOwner(
|
802
802
|
handler: (call: OwnerCallTrace, ctx: EACAggregatorProxyContext) => void,
|
803
803
|
fetchConfig?: Partial<EthFetchConfig>
|
804
804
|
): this {
|
805
|
-
return super.
|
805
|
+
return super.onEthTrace("0x8da5cb5b", handler as any, fetchConfig);
|
806
806
|
}
|
807
807
|
|
808
808
|
onCallPhaseAggregators(
|
@@ -812,14 +812,14 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
812
812
|
) => void,
|
813
813
|
fetchConfig?: Partial<EthFetchConfig>
|
814
814
|
): this {
|
815
|
-
return super.
|
815
|
+
return super.onEthTrace("0xc1597304", handler as any, fetchConfig);
|
816
816
|
}
|
817
817
|
|
818
818
|
onCallPhaseId(
|
819
819
|
handler: (call: PhaseIdCallTrace, ctx: EACAggregatorProxyContext) => void,
|
820
820
|
fetchConfig?: Partial<EthFetchConfig>
|
821
821
|
): this {
|
822
|
-
return super.
|
822
|
+
return super.onEthTrace("0x58303b10", handler as any, fetchConfig);
|
823
823
|
}
|
824
824
|
|
825
825
|
onCallProposeAggregator(
|
@@ -829,7 +829,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
829
829
|
) => void,
|
830
830
|
fetchConfig?: Partial<EthFetchConfig>
|
831
831
|
): this {
|
832
|
-
return super.
|
832
|
+
return super.onEthTrace("0xf8a2abd3", handler as any, fetchConfig);
|
833
833
|
}
|
834
834
|
|
835
835
|
onCallProposedAggregator(
|
@@ -839,7 +839,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
839
839
|
) => void,
|
840
840
|
fetchConfig?: Partial<EthFetchConfig>
|
841
841
|
): this {
|
842
|
-
return super.
|
842
|
+
return super.onEthTrace("0xe8c4be30", handler as any, fetchConfig);
|
843
843
|
}
|
844
844
|
|
845
845
|
onCallProposedGetRoundData(
|
@@ -849,7 +849,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
849
849
|
) => void,
|
850
850
|
fetchConfig?: Partial<EthFetchConfig>
|
851
851
|
): this {
|
852
|
-
return super.
|
852
|
+
return super.onEthTrace("0x6001ac53", handler as any, fetchConfig);
|
853
853
|
}
|
854
854
|
|
855
855
|
onCallProposedLatestRoundData(
|
@@ -859,7 +859,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
859
859
|
) => void,
|
860
860
|
fetchConfig?: Partial<EthFetchConfig>
|
861
861
|
): this {
|
862
|
-
return super.
|
862
|
+
return super.onEthTrace("0x8f6b4d91", handler as any, fetchConfig);
|
863
863
|
}
|
864
864
|
|
865
865
|
onCallSetController(
|
@@ -869,7 +869,7 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
869
869
|
) => void,
|
870
870
|
fetchConfig?: Partial<EthFetchConfig>
|
871
871
|
): this {
|
872
|
-
return super.
|
872
|
+
return super.onEthTrace("0x92eefe9b", handler as any, fetchConfig);
|
873
873
|
}
|
874
874
|
|
875
875
|
onCallTransferOwnership(
|
@@ -879,14 +879,14 @@ export class EACAggregatorProxyProcessor extends BaseProcessor<
|
|
879
879
|
) => void,
|
880
880
|
fetchConfig?: Partial<EthFetchConfig>
|
881
881
|
): this {
|
882
|
-
return super.
|
882
|
+
return super.onEthTrace("0xf2fde38b", handler as any, fetchConfig);
|
883
883
|
}
|
884
884
|
|
885
885
|
onCallVersion(
|
886
886
|
handler: (call: VersionCallTrace, ctx: EACAggregatorProxyContext) => void,
|
887
887
|
fetchConfig?: Partial<EthFetchConfig>
|
888
888
|
): this {
|
889
|
-
return super.
|
889
|
+
return super.onEthTrace("0x54fd4d50", handler as any, fetchConfig);
|
890
890
|
}
|
891
891
|
|
892
892
|
public static filters = {
|
@@ -975,7 +975,7 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
|
|
975
975
|
"AnswerUpdated(int256,uint256,uint256)"
|
976
976
|
](null, null, null);
|
977
977
|
}
|
978
|
-
return super.
|
978
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
979
979
|
}
|
980
980
|
|
981
981
|
onEventNewRound(
|
@@ -990,7 +990,7 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
|
|
990
990
|
null
|
991
991
|
);
|
992
992
|
}
|
993
|
-
return super.
|
993
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
994
994
|
}
|
995
995
|
|
996
996
|
onEventOwnershipTransferRequested(
|
@@ -1008,7 +1008,7 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
|
|
1008
1008
|
"OwnershipTransferRequested(address,address)"
|
1009
1009
|
](null, null);
|
1010
1010
|
}
|
1011
|
-
return super.
|
1011
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
1012
1012
|
}
|
1013
1013
|
|
1014
1014
|
onEventOwnershipTransferred(
|
@@ -1026,7 +1026,7 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
|
|
1026
1026
|
"OwnershipTransferred(address,address)"
|
1027
1027
|
](null, null);
|
1028
1028
|
}
|
1029
|
-
return super.
|
1029
|
+
return super.onEthEvent(handler, filter!, fetchConfig);
|
1030
1030
|
}
|
1031
1031
|
}
|
1032
1032
|
|