@sentio/sdk 2.0.0-rc.13 → 2.0.0-rc.15
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/api.d.ts +5 -0
- package/lib/aptos/api.js +21 -0
- package/lib/aptos/api.js.map +1 -0
- package/lib/aptos/aptos-plugin.d.ts +14 -0
- package/lib/aptos/aptos-plugin.js +146 -0
- package/lib/aptos/aptos-plugin.js.map +1 -0
- package/lib/aptos/aptos-processor.d.ts +72 -0
- package/lib/aptos/aptos-processor.js +201 -0
- package/lib/aptos/aptos-processor.js.map +1 -0
- package/lib/aptos/builtin/0x1.d.ts +2140 -0
- package/lib/aptos/builtin/0x1.js +2727 -0
- package/lib/aptos/builtin/0x1.js.map +1 -0
- package/lib/aptos/builtin/0x3.d.ts +573 -0
- package/lib/aptos/builtin/0x3.js +496 -0
- package/lib/aptos/builtin/0x3.js.map +1 -0
- package/lib/aptos/builtin/index.d.ts +2 -0
- package/lib/aptos/builtin/index.js +6 -0
- package/lib/aptos/builtin/index.js.map +1 -0
- package/lib/aptos/codegen/codegen.d.ts +23 -0
- package/lib/aptos/codegen/codegen.js +388 -0
- package/lib/aptos/codegen/codegen.js.map +1 -0
- package/lib/aptos/codegen/index.d.ts +1 -0
- package/lib/aptos/codegen/index.js +2 -0
- package/lib/aptos/codegen/index.js.map +1 -0
- package/lib/aptos/codegen/typegen.d.ts +18 -0
- package/lib/aptos/codegen/typegen.js +145 -0
- package/lib/aptos/codegen/typegen.js.map +1 -0
- package/lib/aptos/codegen/typegen.test.d.ts +1 -0
- package/lib/aptos/codegen/typegen.test.js.map +1 -0
- package/lib/aptos/context.d.ts +21 -0
- package/lib/aptos/context.js +59 -0
- package/lib/aptos/context.js.map +1 -0
- package/lib/aptos/index.d.ts +9 -0
- package/lib/aptos/index.js +8 -0
- package/lib/aptos/index.js.map +1 -0
- package/lib/aptos/models.d.ts +37 -0
- package/lib/aptos/models.js +2 -0
- package/lib/aptos/models.js.map +1 -0
- package/lib/aptos/move-coder.d.ts +22 -0
- package/lib/aptos/move-coder.js +164 -0
- package/lib/aptos/move-coder.js.map +1 -0
- package/lib/aptos/move-types.d.ts +10 -0
- package/lib/aptos/move-types.js +2 -0
- package/lib/aptos/move-types.js.map +1 -0
- package/lib/aptos/network.d.ts +11 -0
- package/lib/aptos/network.js +27 -0
- package/lib/aptos/network.js.map +1 -0
- package/lib/aptos/run-codegen.d.ts +1 -0
- package/lib/aptos/run-codegen.js +12 -0
- package/lib/aptos/run-codegen.js.map +1 -0
- package/lib/aptos/tests/aptos.test.d.ts +1 -0
- package/lib/aptos/tests/aptos.test.js.map +1 -0
- package/lib/aptos/tests/souffl3.d.ts +1 -0
- package/lib/aptos/tests/souffl3.js +44 -0
- package/lib/aptos/tests/souffl3.js.map +1 -0
- package/lib/aptos/tests/types/index.d.ts +3 -0
- package/lib/aptos/tests/types/index.js +7 -0
- package/lib/aptos/tests/types/index.js.map +1 -0
- package/lib/aptos/tests/types/reserved.d.ts +445 -0
- package/lib/aptos/tests/types/reserved.js +301 -0
- package/lib/aptos/tests/types/reserved.js.map +1 -0
- package/lib/aptos/tests/types/soffl3.d.ts +1065 -0
- package/lib/aptos/tests/types/soffl3.js +548 -0
- package/lib/aptos/tests/types/soffl3.js.map +1 -0
- package/lib/aptos/tests/types/souffle.d.ts +440 -0
- package/lib/aptos/tests/types/souffle.js +295 -0
- package/lib/aptos/tests/types/souffle.js.map +1 -0
- package/lib/aptos/types.d.ts +9 -0
- package/lib/aptos/types.js +130 -0
- package/lib/aptos/types.js.map +1 -0
- package/lib/aptos/types.test.d.ts +1 -0
- package/lib/aptos/types.test.js.map +1 -0
- package/lib/aptos/utils.d.ts +7 -0
- package/lib/aptos/utils.js +20 -0
- package/lib/aptos/utils.js.map +1 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +90 -180
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc1155_processor.js +25 -50
- package/lib/builtin/internal/erc1155_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.js +40 -80
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.js +30 -60
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/erc721_processor.js +45 -90
- package/lib/builtin/internal/erc721_processor.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.js +30 -60
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/{utils/chain.d.ts → chain.d.ts} +0 -0
- package/lib/{utils/chain.js → chain.js} +0 -0
- package/lib/chain.js.map +1 -0
- package/lib/core/context.js +1 -1
- package/lib/core/context.js.map +1 -1
- package/lib/core/sui-plugin.js +1 -1
- package/lib/core/sui-plugin.js.map +1 -1
- package/lib/error.d.ts +1 -1
- package/lib/error.js +10 -12
- package/lib/error.js.map +1 -1
- package/lib/eth/base-processor-template.d.ts +3 -3
- package/lib/eth/base-processor-template.js.map +1 -1
- package/lib/eth/base-processor.d.ts +3 -3
- package/lib/eth/base-processor.js.map +1 -1
- package/lib/eth/{eth-event.d.ts → eth.d.ts} +1 -1
- package/lib/eth/eth.js +2 -0
- package/lib/eth/eth.js.map +1 -0
- package/lib/eth/index.d.ts +1 -0
- package/lib/eth/index.js +1 -0
- package/lib/eth/index.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/solana/builtin/index.d.ts +1 -0
- package/lib/solana/builtin/index.js +2 -0
- package/lib/solana/builtin/index.js.map +1 -0
- package/lib/solana/builtin/spl-token-processor.d.ts +39 -0
- package/lib/solana/builtin/spl-token-processor.js +254 -0
- package/lib/solana/builtin/spl-token-processor.js.map +1 -0
- package/lib/solana/builtin/types.d.ts +427 -0
- package/lib/solana/builtin/types.js +200 -0
- package/lib/solana/builtin/types.js.map +1 -0
- package/lib/solana/codegen/codegen.d.ts +1 -0
- package/lib/solana/codegen/codegen.js +122 -0
- package/lib/solana/codegen/codegen.js.map +1 -0
- package/lib/solana/codegen/index.d.ts +1 -0
- package/lib/solana/codegen/index.js +2 -0
- package/lib/solana/codegen/index.js.map +1 -0
- package/lib/solana/index.d.ts +4 -0
- package/lib/solana/index.js +5 -0
- package/lib/solana/index.js.map +1 -0
- package/lib/solana/run-codegen.d.ts +2 -0
- package/lib/solana/run-codegen.js +12 -0
- package/lib/solana/run-codegen.js.map +1 -0
- package/lib/solana/solana-context.d.ts +9 -0
- package/lib/solana/solana-context.js +28 -0
- package/lib/solana/solana-context.js.map +1 -0
- package/lib/solana/solana-options.d.ts +10 -0
- package/lib/solana/solana-options.js +10 -0
- package/lib/solana/solana-options.js.map +1 -0
- package/lib/solana/solana-plugin.d.ts +9 -0
- package/lib/solana/solana-plugin.js +87 -0
- package/lib/solana/solana-plugin.js.map +1 -0
- package/lib/solana/solana-processor.d.ts +43 -0
- package/lib/solana/solana-processor.js +72 -0
- package/lib/solana/solana-processor.js.map +1 -0
- package/lib/solana/tests/solana.test.d.ts +1 -0
- package/lib/solana/tests/solana.test.js.map +1 -0
- package/lib/solana/tests/types/basic_1.d.ts +26 -0
- package/lib/solana/tests/types/basic_1.js +63 -0
- package/lib/solana/tests/types/basic_1.js.map +1 -0
- package/lib/solana/tests/types/basic_1_processor.d.ts +21 -0
- package/lib/solana/tests/types/basic_1_processor.js +35 -0
- package/lib/solana/tests/types/basic_1_processor.js.map +1 -0
- package/lib/solana/tests/types/token_bridge.d.ts +29 -0
- package/lib/solana/tests/types/token_bridge.js +938 -0
- package/lib/solana/tests/types/token_bridge.js.map +1 -0
- package/lib/solana/tests/types/token_bridge_processor.d.ts +212 -0
- package/lib/solana/tests/types/token_bridge_processor.js +134 -0
- package/lib/solana/tests/types/token_bridge_processor.js.map +1 -0
- package/lib/solana/tests/wormhole-token-bridge.d.ts +15 -0
- package/lib/solana/tests/wormhole-token-bridge.js +79 -0
- package/lib/solana/tests/wormhole-token-bridge.js.map +1 -0
- package/lib/target-ethers-sentio/view-function.cjs +4 -9
- package/lib/target-ethers-sentio/view-function.cjs.map +1 -1
- package/lib/testing/test-processor-server.js +1 -1
- package/lib/testing/test-processor-server.js.map +1 -1
- package/lib/testing/test-provider.js +1 -1
- package/lib/testing/test-provider.js.map +1 -1
- package/lib/utils/index.d.ts +0 -1
- package/lib/utils/index.js +0 -1
- package/lib/utils/index.js.map +1 -1
- package/package.json +34 -11
- package/src/aptos/abis/0x1.json +9205 -0
- package/src/aptos/abis/0x3.json +1515 -0
- package/src/aptos/api.ts +23 -0
- package/src/aptos/aptos-plugin.ts +183 -0
- package/src/aptos/aptos-processor.ts +331 -0
- package/src/aptos/builtin/0x1.ts +4911 -0
- package/src/aptos/builtin/0x3.ts +1092 -0
- package/src/aptos/builtin/index.ts +5 -0
- package/src/aptos/codegen/codegen.ts +470 -0
- package/src/aptos/codegen/index.ts +1 -0
- package/src/aptos/codegen/tsconfig.json +8 -0
- package/src/aptos/codegen/typegen.ts +165 -0
- package/src/aptos/context.ts +72 -0
- package/src/aptos/index.ts +10 -0
- package/src/aptos/models.ts +47 -0
- package/src/aptos/move-coder.ts +201 -0
- package/src/aptos/move-types.ts +11 -0
- package/src/aptos/network.ts +29 -0
- package/src/aptos/run-codegen.ts +13 -0
- package/src/aptos/tests/abis/reserved.json +402 -0
- package/src/aptos/tests/abis/soffl3.json +1411 -0
- package/src/aptos/tests/abis/souffle.json +389 -0
- package/src/aptos/tests/souffl3.ts +57 -0
- package/src/aptos/tests/types/index.ts +6 -0
- package/src/aptos/tests/types/reserved.ts +881 -0
- package/src/aptos/tests/types/soffl3.ts +1820 -0
- package/src/aptos/tests/types/souffle.ts +880 -0
- package/src/aptos/types.ts +149 -0
- package/src/aptos/utils.ts +26 -0
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +90 -162
- package/src/builtin/internal/erc1155_processor.ts +25 -49
- package/src/builtin/internal/erc20_processor.ts +40 -72
- package/src/builtin/internal/erc20bytes_processor.ts +30 -54
- package/src/builtin/internal/erc721_processor.ts +45 -81
- package/src/builtin/internal/weth9_processor.ts +30 -54
- package/src/{utils/chain.ts → chain.ts} +0 -0
- package/src/core/context.ts +1 -1
- package/src/core/sui-plugin.ts +1 -1
- package/src/error.ts +12 -14
- package/src/eth/base-processor-template.ts +3 -3
- package/src/eth/base-processor.ts +4 -4
- package/src/eth/{eth-event.ts → eth.ts} +1 -1
- package/src/eth/index.ts +2 -0
- package/src/index.ts +2 -2
- package/src/solana/builtin/index.ts +1 -0
- package/src/solana/builtin/spl-token-processor.ts +298 -0
- package/src/solana/builtin/types.ts +279 -0
- package/src/solana/codegen/codegen.ts +140 -0
- package/src/solana/codegen/index.ts +1 -0
- package/src/solana/codegen/tsconfig.json +8 -0
- package/src/solana/index.ts +4 -0
- package/src/solana/run-codegen.ts +13 -0
- package/src/solana/solana-context.ts +30 -0
- package/src/solana/solana-options.ts +11 -0
- package/src/solana/solana-plugin.ts +103 -0
- package/src/solana/solana-processor.ts +102 -0
- package/src/solana/tests/abis/basic_1.json +62 -0
- package/src/solana/tests/abis/token_bridge.json +937 -0
- package/src/solana/tests/types/basic_1.ts +62 -0
- package/src/solana/tests/types/basic_1_processor.ts +42 -0
- package/src/solana/tests/types/token_bridge.ts +937 -0
- package/src/solana/tests/types/token_bridge_processor.ts +150 -0
- package/src/solana/tests/wormhole-token-bridge.ts +96 -0
- package/src/target-ethers-sentio/view-function.cts +4 -11
- package/src/testing/test-processor-server.ts +1 -1
- package/src/testing/test-provider.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/lib/eth/eth-event.js +0 -2
- package/lib/eth/eth-event.js.map +0 -1
- package/lib/utils/chain.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sui-plugin.js","sourceRoot":"","sources":["../../src/core/sui-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAA+B,WAAW,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IACH,CAAC;IAED,iBAAiB,GAAG,EAAE,CAAA;IAEtB,cAAc,CAAC,OAAoB;QACjC,QAAQ,OAAO,CAAC,WAAW,EAAE;YAC3B,KAAK,WAAW,CAAC,eAAe,CAAC;YACjC,6CAA6C;YAC7C;gBACE,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,4BAA4B,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;SACrG;IACH,CAAC;CACF;AAED,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC,CAAA","sourcesContent":["import { Plugin, PluginManager, USER_PROCESSOR } from '@sentio/runtime'\nimport { ContractConfig, DataBinding, HandlerType, ProcessConfigResponse, ProcessResult } from '@sentio/protos'\n\nimport { ServerError, Status } from 'nice-grpc'\n\nimport { CHAIN_IDS } from '../chain.js'\nimport { SuiProcessorState } from './sui-processor.js'\n\nexport class SuiPlugin extends Plugin {\n name: string = 'SuiPlugin'\n\n async configure(config: ProcessConfigResponse) {\n for (const suiProcessor of SuiProcessorState.INSTANCE.getValues()) {\n const contractConfig: ContractConfig = {\n transactionConfig: [],\n processorType: USER_PROCESSOR,\n contract: {\n name: 'sui contract',\n chainId: CHAIN_IDS.SUI_DEVNET,\n address: suiProcessor.address,\n abi: '',\n },\n logConfigs: [],\n intervalConfigs: [],\n traceConfigs: [],\n startBlock: suiProcessor.config.startSeqNumber,\n endBlock: 0n,\n instructionConfig: undefined,\n aptosEventConfigs: [],\n aptosCallConfigs: [],\n }\n config.contractConfigs.push(contractConfig)\n }\n }\n\n supportedHandlers = []\n\n processBinding(request: DataBinding): Promise<ProcessResult> {\n switch (request.handlerType) {\n case HandlerType.SUI_TRANSACTION:\n // return this.processSolInstruction(request)\n default:\n throw new ServerError(Status.INVALID_ARGUMENT, 'No handle type registered ' + request.handlerType)\n }\n }\n}\n\nPluginManager.INSTANCE.register(new SuiPlugin())\n"]}
|
package/lib/error.d.ts
CHANGED
package/lib/error.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// import { errors } from 'ethers/providers'
|
|
2
|
-
export class
|
|
2
|
+
export class SimpleEthersError extends Error {
|
|
3
3
|
e;
|
|
4
4
|
constructor(message, e) {
|
|
5
5
|
super(message);
|
|
@@ -10,11 +10,13 @@ export class EthersError extends Error {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
export function transformEtherError(e, ctx) {
|
|
13
|
+
if (e instanceof SimpleEthersError) {
|
|
14
|
+
return e;
|
|
15
|
+
}
|
|
13
16
|
let msg = '';
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
if (e.data === '0x') {
|
|
17
|
+
const err = e;
|
|
18
|
+
if (err.code === 'CALL_EXCEPTION') {
|
|
19
|
+
if (err.data === '0x') {
|
|
18
20
|
if (ctx) {
|
|
19
21
|
msg =
|
|
20
22
|
"jsonrpc eth_call return '0x' (likely contract not existed) at chain " +
|
|
@@ -23,16 +25,12 @@ export function transformEtherError(e, ctx) {
|
|
|
23
25
|
JSON.stringify(e);
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
|
-
msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(
|
|
28
|
+
msg = "jsonrpc eth_call return '0x' (likely contract not existed): " + JSON.stringify(err);
|
|
27
29
|
}
|
|
30
|
+
return new SimpleEthersError(msg, err);
|
|
28
31
|
}
|
|
29
|
-
return new EthersError(msg, e);
|
|
30
|
-
}
|
|
31
|
-
if (e instanceof EthersError) {
|
|
32
|
-
return e;
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
msg = 'ethers call error\n' + e.message + '\n' + e.stack?.toString();
|
|
33
|
+
msg = 'ethers call error\n' + JSON.stringify(e) + '\n' + e.stack?.toString();
|
|
36
34
|
return new Error(msg);
|
|
37
35
|
}
|
|
38
36
|
//# sourceMappingURL=error.js.map
|
package/lib/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAGA,4CAA4C;AAE5C,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,CAAC,CAAO;IAER,YAAY,OAAe,EAAE,CAAQ;QACnC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;IACrD,CAAC;CACF;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAQ,EAAE,GAA0C;IACtF,IAAI,CAAC,YAAY,iBAAiB,EAAE;QAClC,OAAO,CAAC,CAAA;KACT;IAED,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,MAAM,GAAG,GAAG,CAAuB,CAAA;IACnC,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,EAAE;QACjC,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE;YACrB,IAAI,GAAG,EAAE;gBACP,GAAG;oBACD,sEAAsE;wBACtE,GAAG,CAAC,OAAO;wBACX,IAAI;wBACJ,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;aACpB;iBAAM;gBACL,GAAG,GAAG,8DAA8D,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAA;aAC3F;YACD,OAAO,IAAI,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SACvC;KACF;IAED,GAAG,GAAG,qBAAqB,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;IAC5E,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC","sourcesContent":["// Transform error in more readable format\nimport { ContractContext } from './core/context.js'\nimport { CallExceptionError } from 'ethers'\n// import { errors } from 'ethers/providers'\n\nexport class SimpleEthersError extends Error {\n e: Error\n\n constructor(message: string, e: Error) {\n super(message)\n this.stack = e.stack\n }\n\n toString() {\n return this.message + '\\n' + this.stack?.toString()\n }\n}\n\nexport function transformEtherError(e: Error, ctx: ContractContext<any, any> | undefined): Error {\n if (e instanceof SimpleEthersError) {\n return e\n }\n\n let msg = ''\n const err = e as CallExceptionError\n if (err.code === 'CALL_EXCEPTION') {\n if (err.data === '0x') {\n if (ctx) {\n msg =\n \"jsonrpc eth_call return '0x' (likely contract not existed) at chain \" +\n ctx.chainId +\n ': ' +\n JSON.stringify(e)\n } else {\n msg = \"jsonrpc eth_call return '0x' (likely contract not existed): \" + JSON.stringify(err)\n }\n return new SimpleEthersError(msg, err)\n }\n }\n\n msg = 'ethers call error\\n' + JSON.stringify(e) + '\\n' + e.stack?.toString()\n return new Error(msg)\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { PromiseOrVoid } from '../promise-or-void.js';
|
|
|
7
7
|
import { Trace } from './trace.js';
|
|
8
8
|
import { ListStateStorage } from '@sentio/runtime';
|
|
9
9
|
import { DeferredTopicFilter } from 'ethers/contract';
|
|
10
|
-
import {
|
|
10
|
+
import { Eth } from './eth.js';
|
|
11
11
|
export declare class ProcessorTemplateProcessorState extends ListStateStorage<BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>> {
|
|
12
12
|
static INSTANCE: ProcessorTemplateProcessorState;
|
|
13
13
|
}
|
|
@@ -28,13 +28,13 @@ export declare abstract class BaseProcessorTemplate<TContract extends BaseContra
|
|
|
28
28
|
fetchConfig?: EthFetchConfig;
|
|
29
29
|
}[];
|
|
30
30
|
eventHandlers: {
|
|
31
|
-
handler: (event:
|
|
31
|
+
handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid;
|
|
32
32
|
filter: DeferredTopicFilter | DeferredTopicFilter[];
|
|
33
33
|
fetchConfig?: EthFetchConfig;
|
|
34
34
|
}[];
|
|
35
35
|
constructor();
|
|
36
36
|
bind(options: BindOptions): BaseProcessor<TContract, TBoundContractView> | undefined;
|
|
37
|
-
onEvent(handler: (event:
|
|
37
|
+
onEvent(handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: EthFetchConfig): this;
|
|
38
38
|
onBlockInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, blockInterval?: number, backfillBlockInterval?: number): this;
|
|
39
39
|
onTimeInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeIntervalInMinutes?: number, backfillBlockInterval?: number): this;
|
|
40
40
|
onInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeInterval: HandleInterval | undefined, blockInterval: HandleInterval | undefined): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-processor-template.js","sourceRoot":"","sources":["../../src/eth/base-processor-template.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAI1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAA0B,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAIlE,MAAM,OAAO,+BAAgC,SAAQ,gBAEpD;IACC,MAAM,CAAC,QAAQ,GAAG,IAAI,+BAA+B,EAAE,CAAA;;AAGzD,MAAM,OAAO,qBAAsB,SAAQ,gBAAkC;IAC3E,MAAM,CAAC,QAAQ,GAAG,IAAI,qBAAqB,EAAE,CAAA;;AAG/C,MAAM,OAAgB,qBAAqB;IAIzC,EAAE,CAAQ;IACV,KAAK,GAAG,IAAI,GAAG,EAAU,CAAA;IACzB,aAAa,GAIP,EAAE,CAAA;IACR,aAAa,GAIP,EAAE,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AE,aAAa,EAAE,CAAC,CAAA;QACvG,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,OAAO,CACZ,SAAiB,EACjB,OAA6F;QAE7F,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAA;QAC/C,OAAO,IAAI,CAAA;IACb,CAAC;CAGF","sourcesContent":["import { BoundContractView, ContractContext, ContractView } from '../core/context.js'\nimport { BaseContract, ContractEvent, Block, LogDescription } from 'ethers'\nimport { AddressOrTypeEventFilter, BaseProcessor } from './base-processor.js'\nimport { BindOptions, getOptionsSignature } from '../core/bind-options.js'\nimport { EthFetchConfig, HandleInterval, TemplateInstance } from '@sentio/protos'\nimport { PromiseOrVoid } from '../promise-or-void.js'\nimport { Trace } from './trace.js'\nimport { ListStateStorage } from '@sentio/runtime'\nimport { EventFilter, LogParams, Network } from 'ethers/providers'\nimport { DeferredTopicFilter } from 'ethers/contract'\nimport { Eth } from './eth.js'\n\nexport class ProcessorTemplateProcessorState extends ListStateStorage<\n BaseProcessorTemplate<BaseContract, BoundContractView<BaseContract, any>>\n> {\n static INSTANCE = new ProcessorTemplateProcessorState()\n}\n\nexport class TemplateInstanceState extends ListStateStorage<TemplateInstance> {\n static INSTANCE = new TemplateInstanceState()\n}\n\nexport abstract class BaseProcessorTemplate<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n id: number\n binds = new Set<string>()\n blockHandlers: {\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n }[] = []\n traceHandlers: {\n signature: string\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n fetchConfig?: EthFetchConfig\n }[] = []\n eventHandlers: {\n handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n filter: DeferredTopicFilter | DeferredTopicFilter[]\n fetchConfig?: EthFetchConfig\n }[] = []\n\n constructor() {\n this.id = ProcessorTemplateProcessorState.INSTANCE.getValues().length\n ProcessorTemplateProcessorState.INSTANCE.addValue(this)\n }\n\n public bind(options: BindOptions) {\n const sig = getOptionsSignature(options)\n if (this.binds.has(sig)) {\n return\n }\n this.binds.add(sig)\n\n const processor = this.bindInternal(options)\n\n for (const eh of this.eventHandlers) {\n processor.onEvent(eh.handler, eh.filter, eh.fetchConfig)\n }\n for (const th of this.traceHandlers) {\n processor.onTrace(th.signature, th.handler, th.fetchConfig)\n }\n for (const bh of this.blockHandlers) {\n processor.onInterval(bh.handler, bh.timeIntervalInMinutes, bh.blockInterval)\n }\n\n const instance: TemplateInstance = {\n templateId: this.id,\n contract: {\n address: options.address,\n name: options.name || '',\n chainId: options.network ? Network.from(options.network).chainId.toString() : '1',\n abi: '',\n },\n startBlock: 0n,\n endBlock: 0n,\n }\n if (options.startBlock) {\n instance.startBlock = BigInt(options.startBlock)\n }\n if (options.endBlock) {\n instance.endBlock = BigInt(options.endBlock)\n }\n TemplateInstanceState.INSTANCE.addValue(instance)\n return processor\n }\n\n public onEvent(\n handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: EthFetchConfig\n ) {\n this.eventHandlers.push({\n handler: handler,\n filter: filter,\n fetchConfig: fetchConfig,\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 1000,\n backfillBlockInterval = 4000\n ) {\n return this.onInterval(handler, undefined, {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n })\n }\n\n public onTimeInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillBlockInterval = 240\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillBlockInterval },\n undefined\n )\n }\n\n public onInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined\n ) {\n this.blockHandlers.push({ handler, timeIntervalInMinutes: timeInterval, blockInterval: blockInterval })\n return this\n }\n\n public onTrace(\n signature: string,\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid\n ) {\n this.traceHandlers.push({ signature, handler })\n return this\n }\n\n protected abstract bindInternal(options: BindOptions): BaseProcessor<TContract, TBoundContractView>\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { AddressType, Data_EthBlock, Data_EthLog, Data_EthTrace, EthFetchConfig,
|
|
|
4
4
|
import { BindInternalOptions, BindOptions } from '../core/bind-options.js';
|
|
5
5
|
import { PromiseOrVoid } from '../promise-or-void.js';
|
|
6
6
|
import { Trace } from './trace.js';
|
|
7
|
-
import {
|
|
7
|
+
import { Eth } from './eth.js';
|
|
8
8
|
export interface AddressOrTypeEventFilter extends DeferredTopicFilter {
|
|
9
9
|
addressType?: AddressType;
|
|
10
10
|
address?: string;
|
|
@@ -32,10 +32,10 @@ export declare abstract class BaseProcessor<TContract extends BaseContract, TBou
|
|
|
32
32
|
constructor(config: BindOptions);
|
|
33
33
|
protected abstract CreateBoundContractView(): TBoundContractView;
|
|
34
34
|
getChainId(): number;
|
|
35
|
-
onEvent(handler: (event:
|
|
35
|
+
onEvent(handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, filter: DeferredTopicFilter | DeferredTopicFilter[], fetchConfig?: EthFetchConfig): this;
|
|
36
36
|
onBlockInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, blockInterval?: number, backfillBlockInterval?: number): this;
|
|
37
37
|
onTimeInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeIntervalInMinutes?: number, backfillTimeIntervalInMinutes?: number): this;
|
|
38
38
|
onInterval(handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, timeInterval: HandleInterval | undefined, blockInterval: HandleInterval | undefined): this;
|
|
39
|
-
onAllEvents(handler: (event:
|
|
39
|
+
onAllEvents(handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid): this;
|
|
40
40
|
onTrace(signature: string, handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid, fetchConfig?: EthFetchConfig): this;
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/eth/base-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAqB,eAAe,EAAgB,MAAM,oBAAoB,CAAA;AACrF,OAAO,EAKL,cAAc,EAEd,aAAa,GACd,MAAM,gBAAgB,CAAA;AAIvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAQ/C,MAAM,OAAO,aAAa;IACxB,OAAO,CAA4B;IACnC,OAAO,CAAgD;IACvD,WAAW,CAAgB;CAC5B;AAED,MAAM,OAAO,YAAY;IACvB,SAAS,CAAQ;IACjB,OAAO,CAAkD;IACzD,WAAW,CAAgB;CAC5B;AAED,MAAM,OAAO,aAAa;IACxB,aAAa,CAAiB;IAC9B,qBAAqB,CAAiB;IACtC,OAAO,CAAkD;CAC1D;AAED,MAAM,OAAgB,aAAa;IAIjC,aAAa,GAAoB,EAAE,CAAA;IACnC,aAAa,GAAoB,EAAE,CAAA;IACnC,aAAa,GAAmB,EAAE,CAAA;IAElC,MAAM,CAAqB;IAE3B,YAAY,MAAmB;QAC7B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,EAAE;YACvB,OAAO,EA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KAAK,GAAG,IAAI,CAAC,KAAc,CAAA;gBACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;oBACvB,OAAO,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;iBACrC;gBACD,MAAM,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBACrD,KAAK,CAAC,IAAI,GAAG,iBAAiB,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;gBAE/E,MAAM,GAAG,GAAG,IAAI,eAAe,CAC7B,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,KAAc,EACnB,SAAS,EACT,KAAK,EACL,IAAI,CAAC,WAA0B,EAC/B,IAAI,CAAC,kBAAwC,CAC9C,CAAA;gBACD,MAAM,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;gBACzB,OAAO,GAAG,CAAC,gBAAgB,EAAE,CAAA;YAC/B,CAAC;SACF,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { Block, TransactionReceipt, BaseContract, Transaction, DeferredTopicFilter } from 'ethers'\nimport { LogParams, Network } from 'ethers/providers'\n\nimport { BoundContractView, ContractContext, ContractView } from '../core/context.js'\nimport {\n AddressType,\n Data_EthBlock,\n Data_EthLog,\n Data_EthTrace,\n EthFetchConfig,\n HandleInterval,\n ProcessResult,\n} from '@sentio/protos'\nimport { BindInternalOptions, BindOptions } from '../core/bind-options.js'\nimport { PromiseOrVoid } from '../promise-or-void.js'\nimport { Trace } from './trace.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { EthEvent } from './eth-event.js'\n\nexport interface AddressOrTypeEventFilter extends DeferredTopicFilter {\n addressType?: AddressType\n address?: string\n}\n\nexport class EventsHandler {\n filters: AddressOrTypeEventFilter[]\n handler: (event: Data_EthLog) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TraceHandler {\n signature: string\n handler: (trace: Data_EthTrace) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class BlockHandlder {\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (block: Data_EthBlock) => Promise<ProcessResult>\n}\n\nexport abstract class BaseProcessor<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n blockHandlers: BlockHandlder[] = []\n eventHandlers: EventsHandler[] = []\n traceHandlers: TraceHandler[] = []\n\n config: BindInternalOptions\n\n constructor(config: BindOptions) {\n this.config = {\n address: config.address,\n name: config.name || '',\n network: config.network ? config.network : 1,\n startBlock: 0n,\n }\n if (typeof this.config.network === 'string') {\n const asInt = parseInt(this.config.network)\n if (Number.isFinite(asInt)) {\n this.config.network = asInt\n }\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n protected abstract CreateBoundContractView(): TBoundContractView\n\n public getChainId(): number {\n return Number(Network.from(this.config.network).chainId)\n }\n\n public onEvent(\n handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: EthFetchConfig\n ) {\n const chainId = this.getChainId()\n let _filters: DeferredTopicFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const contractName = this.config.name\n const processor = this\n this.eventHandlers.push({\n filters: _filters,\n fetchConfig: fetchConfig || EthFetchConfig.fromPartial({}),\n handler: async function (data: Data_EthLog) {\n if (!data.log) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')\n }\n const log = data.log as LogParams\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n data.block as Block,\n log,\n undefined,\n data.transaction as Transaction,\n data.transactionReceipt as TransactionReceipt\n )\n const logParam = log as any as { topics: Array<string>; data: string }\n\n const parsed = contractView.rawContract.interface.parseLog(logParam)\n\n if (parsed) {\n const event: EthEvent = { ...log, args: parsed.args }\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000\n ) {\n return this.onInterval(handler, undefined, {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n })\n }\n\n public onTimeInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined\n )\n }\n\n public onInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined\n ) {\n const chainId = this.getChainId()\n const processor = this\n const contractName = this.config.name\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n if (!data.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n const block = data.block as Block\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n new Date(block.timestamp * 1000),\n block,\n undefined,\n undefined\n )\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n })\n return this\n }\n\n public onAllEvents(handler: (event: EthEvent, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {\n const _filters: DeferredTopicFilter[] = []\n const tmpContract = this.CreateBoundContractView()\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'event') {\n const filter = tmpContract.rawContract.filters[fragment.format()]\n _filters.push(filter())\n }\n }\n return this.onEvent(function (log, ctx) {\n return handler(log, ctx)\n }, _filters)\n }\n\n public onTrace(\n signature: string,\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: EthFetchConfig\n ) {\n const chainId = this.getChainId()\n const contractName = this.config.name\n const processor = this\n\n this.traceHandlers.push({\n signature,\n fetchConfig: fetchConfig || EthFetchConfig.fromPartial({}),\n handler: async function (data: Data_EthTrace) {\n const contractView = processor.CreateBoundContractView()\n const contractInterface = contractView.rawContract.interface\n const fragment = contractInterface.getFunction(signature)\n if (!data.trace || !fragment) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace is null')\n }\n const trace = data.trace as Trace\n if (!trace.action.input) {\n return ProcessResult.fromPartial({})\n }\n const traceData = '0x' + trace.action.input.slice(10)\n trace.args = contractInterface.getAbiCoder().decode(fragment.inputs, traceData)\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n data.block as Block,\n undefined,\n trace,\n data.transaction as Transaction,\n data.transactionReceipt as TransactionReceipt\n )\n await handler(trace, ctx)\n return ctx.getProcessResult()\n },\n })\n return this\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-processor.js","sourceRoot":"","sources":["../../src/eth/base-processor.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAqB,eAAe,EAAgB,MAAM,oBAAoB,CAAA;AACrF,OAAO,EAKL,cAAc,EAEd,aAAa,GACd,MAAM,gBAAgB,CAAA;AAIvB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAQ/C,MAAM,OAAO,aAAa;IACxB,OAAO,CAA4B;IACnC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OAAO,IAAI,CAAA;IACb,CAAC;CACF","sourcesContent":["import { Block, TransactionReceipt, BaseContract, Transaction, DeferredTopicFilter } from 'ethers'\nimport { LogParams, Network } from 'ethers/providers'\n\nimport { BoundContractView, ContractContext, ContractView } from '../core/context.js'\nimport {\n AddressType,\n Data_EthBlock,\n Data_EthLog,\n Data_EthTrace,\n EthFetchConfig,\n HandleInterval,\n ProcessResult,\n} from '@sentio/protos'\nimport { BindInternalOptions, BindOptions } from '../core/bind-options.js'\nimport { PromiseOrVoid } from '../promise-or-void.js'\nimport { Trace } from './trace.js'\nimport { ServerError, Status } from 'nice-grpc'\nimport { Eth } from './eth.js'\n\nexport interface AddressOrTypeEventFilter extends DeferredTopicFilter {\n addressType?: AddressType\n address?: string\n}\n\nexport class EventsHandler {\n filters: AddressOrTypeEventFilter[]\n handler: (event: Data_EthLog) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class TraceHandler {\n signature: string\n handler: (trace: Data_EthTrace) => Promise<ProcessResult>\n fetchConfig: EthFetchConfig\n}\n\nexport class BlockHandlder {\n blockInterval?: HandleInterval\n timeIntervalInMinutes?: HandleInterval\n handler: (block: Data_EthBlock) => Promise<ProcessResult>\n}\n\nexport abstract class BaseProcessor<\n TContract extends BaseContract,\n TBoundContractView extends BoundContractView<TContract, ContractView<TContract>>\n> {\n blockHandlers: BlockHandlder[] = []\n eventHandlers: EventsHandler[] = []\n traceHandlers: TraceHandler[] = []\n\n config: BindInternalOptions\n\n constructor(config: BindOptions) {\n this.config = {\n address: config.address,\n name: config.name || '',\n network: config.network ? config.network : 1,\n startBlock: 0n,\n }\n if (typeof this.config.network === 'string') {\n const asInt = parseInt(this.config.network)\n if (Number.isFinite(asInt)) {\n this.config.network = asInt\n }\n }\n if (config.startBlock) {\n this.config.startBlock = BigInt(config.startBlock)\n }\n if (config.endBlock) {\n this.config.endBlock = BigInt(config.endBlock)\n }\n }\n\n protected abstract CreateBoundContractView(): TBoundContractView\n\n public getChainId(): number {\n return Number(Network.from(this.config.network).chainId)\n }\n\n public onEvent(\n handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n filter: DeferredTopicFilter | DeferredTopicFilter[],\n fetchConfig?: EthFetchConfig\n ) {\n const chainId = this.getChainId()\n let _filters: DeferredTopicFilter[] = []\n\n if (Array.isArray(filter)) {\n _filters = filter\n } else {\n _filters.push(filter)\n }\n\n const contractName = this.config.name\n const processor = this\n this.eventHandlers.push({\n filters: _filters,\n fetchConfig: fetchConfig || EthFetchConfig.fromPartial({}),\n handler: async function (data: Data_EthLog) {\n if (!data.log) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Log is empty')\n }\n const log = data.log as LogParams\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n data.block as Block,\n log,\n undefined,\n data.transaction as Transaction,\n data.transactionReceipt as TransactionReceipt\n )\n const logParam = log as any as { topics: Array<string>; data: string }\n\n const parsed = contractView.rawContract.interface.parseLog(logParam)\n\n if (parsed) {\n const event: Eth = { ...log, args: parsed.args }\n await handler(event, ctx)\n return ctx.getProcessResult()\n }\n return ProcessResult.fromPartial({})\n },\n })\n return this\n }\n\n public onBlockInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n blockInterval = 250,\n backfillBlockInterval = 1000\n ) {\n return this.onInterval(handler, undefined, {\n recentInterval: blockInterval,\n backfillInterval: backfillBlockInterval,\n })\n }\n\n public onTimeInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeIntervalInMinutes = 60,\n backfillTimeIntervalInMinutes = 240\n ) {\n return this.onInterval(\n handler,\n { recentInterval: timeIntervalInMinutes, backfillInterval: backfillTimeIntervalInMinutes },\n undefined\n )\n }\n\n public onInterval(\n handler: (block: Block, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n timeInterval: HandleInterval | undefined,\n blockInterval: HandleInterval | undefined\n ) {\n const chainId = this.getChainId()\n const processor = this\n const contractName = this.config.name\n\n this.blockHandlers.push({\n handler: async function (data: Data_EthBlock) {\n if (!data.block) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'Block is empty')\n }\n const block = data.block as Block\n\n const contractView = processor.CreateBoundContractView()\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n new Date(block.timestamp * 1000),\n block,\n undefined,\n undefined\n )\n await handler(block, ctx)\n return ctx.getProcessResult()\n },\n timeIntervalInMinutes: timeInterval,\n blockInterval: blockInterval,\n })\n return this\n }\n\n public onAllEvents(handler: (event: Eth, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid) {\n const _filters: DeferredTopicFilter[] = []\n const tmpContract = this.CreateBoundContractView()\n\n for (const fragment of tmpContract.rawContract.interface.fragments) {\n if (fragment.type === 'event') {\n const filter = tmpContract.rawContract.filters[fragment.format()]\n _filters.push(filter())\n }\n }\n return this.onEvent(function (log, ctx) {\n return handler(log, ctx)\n }, _filters)\n }\n\n public onTrace(\n signature: string,\n handler: (trace: Trace, ctx: ContractContext<TContract, TBoundContractView>) => PromiseOrVoid,\n fetchConfig?: EthFetchConfig\n ) {\n const chainId = this.getChainId()\n const contractName = this.config.name\n const processor = this\n\n this.traceHandlers.push({\n signature,\n fetchConfig: fetchConfig || EthFetchConfig.fromPartial({}),\n handler: async function (data: Data_EthTrace) {\n const contractView = processor.CreateBoundContractView()\n const contractInterface = contractView.rawContract.interface\n const fragment = contractInterface.getFunction(signature)\n if (!data.trace || !fragment) {\n throw new ServerError(Status.INVALID_ARGUMENT, 'trace is null')\n }\n const trace = data.trace as Trace\n if (!trace.action.input) {\n return ProcessResult.fromPartial({})\n }\n const traceData = '0x' + trace.action.input.slice(10)\n trace.args = contractInterface.getAbiCoder().decode(fragment.inputs, traceData)\n\n const ctx = new ContractContext<TContract, TBoundContractView>(\n contractName,\n contractView,\n chainId,\n data.timestamp,\n data.block as Block,\n undefined,\n trace,\n data.transaction as Transaction,\n data.transactionReceipt as TransactionReceipt\n )\n await handler(trace, ctx)\n return ctx.getProcessResult()\n },\n })\n return this\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogParams } from 'ethers/providers';
|
|
2
2
|
import { Result } from 'ethers';
|
|
3
|
-
export interface
|
|
3
|
+
export interface Eth<TArgsArray extends Array<any> = any, TArgsObject = any> extends LogParams {
|
|
4
4
|
args: TArgsArray & TArgsObject & Result;
|
|
5
5
|
}
|
package/lib/eth/eth.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eth.js","sourceRoot":"","sources":["../../src/eth/eth.ts"],"names":[],"mappings":"","sourcesContent":["import { LogParams } from 'ethers/providers'\nimport { Result } from 'ethers'\n\nexport interface Eth<TArgsArray extends Array<any> = any, TArgsObject = any> extends LogParams {\n args: TArgsArray & TArgsObject & Result\n}\n"]}
|
package/lib/eth/index.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ export { BaseProcessorTemplate } from './base-processor-template.js';
|
|
|
4
4
|
export { getProvider, DummyProvider } from './provider.js';
|
|
5
5
|
export type { TypedCallTrace, Trace } from './trace.js';
|
|
6
6
|
export { EthPlugin } from './eth-plugin.js';
|
|
7
|
+
export * from './eth.js';
|
|
7
8
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js';
|
package/lib/eth/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export { GenericProcessor } from './generic-processor.js';
|
|
|
3
3
|
export { BaseProcessorTemplate } from './base-processor-template.js';
|
|
4
4
|
export { getProvider, DummyProvider } from './provider.js';
|
|
5
5
|
export { EthPlugin } from './eth-plugin.js';
|
|
6
|
+
export * from './eth.js';
|
|
6
7
|
export { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js';
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/lib/eth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { BaseProcessor } from './base-processor.js'\nexport { GenericProcessor } from './generic-processor.js'\nexport { BaseProcessorTemplate } from './base-processor-template.js'\nexport { getProvider, DummyProvider } from './provider.js'\nexport type { TypedCallTrace, Trace } from './trace.js'\nexport { EthPlugin } from './eth-plugin.js'\n\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAE3C,cAAc,UAAU,CAAA;AAExB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { BaseProcessor } from './base-processor.js'\nexport { GenericProcessor } from './generic-processor.js'\nexport { BaseProcessorTemplate } from './base-processor-template.js'\nexport { getProvider, DummyProvider } from './provider.js'\nexport type { TypedCallTrace, Trace } from './trace.js'\nexport { EthPlugin } from './eth-plugin.js'\n\nexport * from './eth.js'\n\nexport { getProcessor, addProcessor, getContractByABI, addContractByABI } from './binds.js'\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { transformEtherError,
|
|
1
|
+
export { transformEtherError, SimpleEthersError } from './error.js';
|
|
2
2
|
export * from '@sentio/protos';
|
|
3
3
|
export * from './core/index.js';
|
|
4
4
|
export * from './eth/index.js';
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './chain.js';
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { transformEtherError,
|
|
1
|
+
export { transformEtherError, SimpleEthersError } from './error.js';
|
|
2
2
|
// TODO maybe remove this
|
|
3
3
|
export * from '@sentio/protos';
|
|
4
4
|
export * from './core/index.js';
|
|
5
5
|
export * from './eth/index.js';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './chain.js';
|
|
7
7
|
// export * from './api'
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAEnE,yBAAyB;AACzB,cAAc,gBAAgB,CAAA;AAE9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAE9B,cAAc,YAAY,CAAA;AAC1B,yBAAyB","sourcesContent":["export { transformEtherError, SimpleEthersError } from './error.js'\n\n// TODO maybe remove this\nexport * from '@sentio/protos'\n\nexport * from './core/index.js'\nexport * from './eth/index.js'\n\nexport * from './chain.js'\n// export * from './api'\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './spl-token-processor.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/solana/builtin/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA","sourcesContent":["export * from './spl-token-processor.js'"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from '@sentio/sdk/solana';
|
|
2
|
+
import { Instruction } from '@project-serum/anchor';
|
|
3
|
+
import { AmountToUiAmount, Approve, ApproveChecked, Burn, BurnChecked, CloseAccount, CreateNativeMint, DefaultAccountStateExtension, FreezeAccount, GetAccountDataSize, InitializeAccount, InitializeAccount2, InitializeAccount3, InitializeImmutableOwner, InitializeMint, InitializeMintCloseAuthority, InitializeMultisig, MemoTransferExtension, MintTo, MintToChecked, Reallocate, Revoke, SyncNative, ThawAccount, Transfer, TransferChecked, TransferFeeExtension, UiAmountToAmount } from './types.js';
|
|
4
|
+
export declare class SPLTokenProcessor extends SolanaBaseProcessor {
|
|
5
|
+
static bind(options: SolanaBindOptions): SPLTokenProcessor;
|
|
6
|
+
fromParsedInstruction: (instruction: {
|
|
7
|
+
type: string;
|
|
8
|
+
info: any;
|
|
9
|
+
}) => Instruction | null;
|
|
10
|
+
onInitializeMint(handler: (data: InitializeMint, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
11
|
+
onInitializeAccount(hanlder: (data: InitializeAccount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
12
|
+
onInitializeAccount2(hanlder: (data: InitializeAccount2, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
13
|
+
onInitializeAccount3(hanlder: (data: InitializeAccount3, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
14
|
+
onInitializeMultisig(handler: (data: InitializeMultisig, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
15
|
+
onTransfer(handler: (data: Transfer, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
16
|
+
onApprovend(handler: (data: Approve, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
17
|
+
onRevoke(handler: (data: Revoke, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
18
|
+
onSetAuthority(handler: (data: any, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
19
|
+
onMintTo(handler: (data: MintTo, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
20
|
+
onBurn(handler: (data: Burn, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
21
|
+
onCloseAccount(handler: (data: CloseAccount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
22
|
+
onFreezeAccount(handler: (data: FreezeAccount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
23
|
+
onThawAccount(handler: (data: ThawAccount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
24
|
+
onTransferChecked(handler: (data: TransferChecked, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
25
|
+
onApproveChecked(handler: (data: ApproveChecked, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
26
|
+
onMintToChecked(handler: (data: MintToChecked, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
27
|
+
onBurnChecked(handler: (data: BurnChecked, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
28
|
+
onSyncNative(handler: (data: SyncNative, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
29
|
+
onGetAccountDataSize(handler: (data: GetAccountDataSize, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
30
|
+
onInitializeImmutableOwner(handler: (data: InitializeImmutableOwner, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
31
|
+
onAmountToUiAmount(handler: (data: AmountToUiAmount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
32
|
+
onUiAmountToAmount(handler: (data: UiAmountToAmount, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
33
|
+
onInitializeMintCloseAuthority(handler: (data: InitializeMintCloseAuthority, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
34
|
+
onTransferFeeExtension(handler: (data: TransferFeeExtension, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
35
|
+
onDefaultAccountStateExtension(handler: (data: DefaultAccountStateExtension, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
36
|
+
onReallocate(handler: (data: Reallocate, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
37
|
+
onMemoTransferExtension(handler: (data: MemoTransferExtension, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
38
|
+
onCreateNativeMint(handler: (data: CreateNativeMint, ctx: SolanaContext) => void): SPLTokenProcessor;
|
|
39
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { SolanaBaseProcessor } from '@sentio/sdk/solana';
|
|
2
|
+
export class SPLTokenProcessor extends SolanaBaseProcessor {
|
|
3
|
+
static bind(options) {
|
|
4
|
+
if (options && !options.name) {
|
|
5
|
+
options.name = 'SPL Token Program';
|
|
6
|
+
}
|
|
7
|
+
return new SPLTokenProcessor(options);
|
|
8
|
+
}
|
|
9
|
+
fromParsedInstruction = (instruction) => {
|
|
10
|
+
const instructionType = instruction.type;
|
|
11
|
+
if (!instructionType) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
name: instruction.type,
|
|
16
|
+
data: {
|
|
17
|
+
...instruction.info,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
onInitializeMint(handler) {
|
|
22
|
+
this.onInstruction('initializeMint', (ins, ctx) => {
|
|
23
|
+
if (ins) {
|
|
24
|
+
handler(ins.data, ctx);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
onInitializeAccount(hanlder) {
|
|
30
|
+
this.onInstruction('initializeAccount', (ins, ctx) => {
|
|
31
|
+
if (ins) {
|
|
32
|
+
hanlder(ins.data, ctx);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
onInitializeAccount2(hanlder) {
|
|
38
|
+
this.onInstruction('initializeAccount2', (ins, ctx) => {
|
|
39
|
+
if (ins) {
|
|
40
|
+
hanlder(ins.data, ctx);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
onInitializeAccount3(hanlder) {
|
|
46
|
+
this.onInstruction('initializeAccount3', (ins, ctx) => {
|
|
47
|
+
if (ins) {
|
|
48
|
+
hanlder(ins.data, ctx);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
onInitializeMultisig(handler) {
|
|
54
|
+
this.onInstruction('initializeMultisig', (ins, ctx) => {
|
|
55
|
+
if (ins) {
|
|
56
|
+
handler(ins.data, ctx);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
onTransfer(handler) {
|
|
62
|
+
this.onInstruction('transfer', (ins, ctx) => {
|
|
63
|
+
if (ins) {
|
|
64
|
+
handler(ins.data, ctx);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
onApprovend(handler) {
|
|
70
|
+
this.onInstruction('approve', (ins, ctx) => {
|
|
71
|
+
if (ins) {
|
|
72
|
+
handler(ins.data, ctx);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
onRevoke(handler) {
|
|
78
|
+
this.onInstruction('revoke', (ins, ctx) => {
|
|
79
|
+
if (ins) {
|
|
80
|
+
handler(ins.data, ctx);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
onSetAuthority(handler) {
|
|
86
|
+
this.onInstruction('setAuthority', (ins, ctx) => {
|
|
87
|
+
if (ins) {
|
|
88
|
+
handler(ins.data, ctx);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
onMintTo(handler) {
|
|
94
|
+
this.onInstruction('mintTo', (ins, ctx) => {
|
|
95
|
+
if (ins) {
|
|
96
|
+
handler(ins.data, ctx);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
onBurn(handler) {
|
|
102
|
+
this.onInstruction('burn', (ins, ctx) => {
|
|
103
|
+
if (ins) {
|
|
104
|
+
handler(ins.data, ctx);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
onCloseAccount(handler) {
|
|
110
|
+
this.onInstruction('closeAccount', (ins, ctx) => {
|
|
111
|
+
if (ins) {
|
|
112
|
+
handler(ins.data, ctx);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
onFreezeAccount(handler) {
|
|
118
|
+
this.onInstruction('freezeAccount', (ins, ctx) => {
|
|
119
|
+
if (ins) {
|
|
120
|
+
handler(ins.data, ctx);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
onThawAccount(handler) {
|
|
126
|
+
this.onInstruction('thawAccount', (ins, ctx) => {
|
|
127
|
+
if (ins) {
|
|
128
|
+
handler(ins.data, ctx);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
onTransferChecked(handler) {
|
|
134
|
+
this.onInstruction('transferChecked', (ins, ctx) => {
|
|
135
|
+
if (ins) {
|
|
136
|
+
handler(ins.data, ctx);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
onApproveChecked(handler) {
|
|
142
|
+
this.onInstruction('approveChecked', (ins, ctx) => {
|
|
143
|
+
if (ins) {
|
|
144
|
+
handler(ins.data, ctx);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
onMintToChecked(handler) {
|
|
150
|
+
this.onInstruction('mintToChecked', (ins, ctx) => {
|
|
151
|
+
if (ins) {
|
|
152
|
+
handler(ins.data, ctx);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
onBurnChecked(handler) {
|
|
158
|
+
this.onInstruction('burnChecked', (ins, ctx) => {
|
|
159
|
+
if (ins) {
|
|
160
|
+
handler(ins.data, ctx);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
onSyncNative(handler) {
|
|
166
|
+
this.onInstruction('syncNative', (ins, ctx) => {
|
|
167
|
+
if (ins) {
|
|
168
|
+
handler(ins.data, ctx);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
onGetAccountDataSize(handler) {
|
|
174
|
+
this.onInstruction('getAccountDataSize', (ins, ctx) => {
|
|
175
|
+
if (ins) {
|
|
176
|
+
handler(ins.data, ctx);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
onInitializeImmutableOwner(handler) {
|
|
182
|
+
this.onInstruction('initializeImmutableOwner', (ins, ctx) => {
|
|
183
|
+
if (ins) {
|
|
184
|
+
handler(ins.data, ctx);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return this;
|
|
188
|
+
}
|
|
189
|
+
onAmountToUiAmount(handler) {
|
|
190
|
+
this.onInstruction('amountToUiAmount', (ins, ctx) => {
|
|
191
|
+
if (ins) {
|
|
192
|
+
handler(ins.data, ctx);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
onUiAmountToAmount(handler) {
|
|
198
|
+
this.onInstruction('uiAmountToAmount', (ins, ctx) => {
|
|
199
|
+
if (ins) {
|
|
200
|
+
handler(ins.data, ctx);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
return this;
|
|
204
|
+
}
|
|
205
|
+
onInitializeMintCloseAuthority(handler) {
|
|
206
|
+
this.onInstruction('initializeMintCloseAuthority', (ins, ctx) => {
|
|
207
|
+
if (ins) {
|
|
208
|
+
handler(ins.data, ctx);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
onTransferFeeExtension(handler) {
|
|
214
|
+
this.onInstruction('transferFeeExtension', (ins, ctx) => {
|
|
215
|
+
if (ins) {
|
|
216
|
+
handler(ins.data, ctx);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return this;
|
|
220
|
+
}
|
|
221
|
+
onDefaultAccountStateExtension(handler) {
|
|
222
|
+
this.onInstruction('defaultAccountStateExtension', (ins, ctx) => {
|
|
223
|
+
if (ins) {
|
|
224
|
+
handler(ins.data, ctx);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return this;
|
|
228
|
+
}
|
|
229
|
+
onReallocate(handler) {
|
|
230
|
+
this.onInstruction('reallocate', (ins, ctx) => {
|
|
231
|
+
if (ins) {
|
|
232
|
+
handler(ins.data, ctx);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
onMemoTransferExtension(handler) {
|
|
238
|
+
this.onInstruction('memoTransferExtension', (ins, ctx) => {
|
|
239
|
+
if (ins) {
|
|
240
|
+
handler(ins.data, ctx);
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
onCreateNativeMint(handler) {
|
|
246
|
+
this.onInstruction('createNativeMint', (ins, ctx) => {
|
|
247
|
+
if (ins) {
|
|
248
|
+
handler(ins.data, ctx);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=spl-token-processor.js.map
|