@sentio/sdk 1.20.1 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (189) hide show
  1. package/lib/aptos/aptos-processor.d.ts +17 -12
  2. package/lib/aptos/aptos-processor.js +65 -13
  3. package/lib/aptos/aptos-processor.js.map +1 -1
  4. package/lib/aptos/bind-options.d.ts +0 -6
  5. package/lib/aptos/bind-options.js +1 -8
  6. package/lib/aptos/bind-options.js.map +1 -1
  7. package/lib/aptos/context.d.ts +5 -4
  8. package/lib/aptos/context.js +9 -6
  9. package/lib/aptos/context.js.map +1 -1
  10. package/lib/aptos/index.d.ts +3 -2
  11. package/lib/aptos/index.js +1 -2
  12. package/lib/aptos/index.js.map +1 -1
  13. package/lib/aptos/runtime.d.ts +2 -0
  14. package/lib/aptos/runtime.js +16 -0
  15. package/lib/aptos/runtime.js.map +1 -0
  16. package/lib/aptos/types.d.ts +28 -0
  17. package/lib/aptos/types.js +159 -0
  18. package/lib/aptos/types.js.map +1 -0
  19. package/lib/aptos/utils.d.ts +6 -0
  20. package/lib/aptos/utils.js +19 -0
  21. package/lib/aptos/utils.js.map +1 -0
  22. package/lib/aptos-codegen/codegen.d.ts +5 -2
  23. package/lib/aptos-codegen/codegen.js +195 -18
  24. package/lib/aptos-codegen/codegen.js.map +1 -1
  25. package/lib/aptos-codegen/typegen.d.ts +18 -0
  26. package/lib/aptos-codegen/typegen.js +196 -0
  27. package/lib/aptos-codegen/typegen.js.map +1 -0
  28. package/lib/binds.d.ts +2 -3
  29. package/lib/binds.js +6 -33
  30. package/lib/binds.js.map +1 -1
  31. package/lib/builtin/aptos/0x1.d.ts +1624 -0
  32. package/lib/builtin/aptos/0x1.js +2502 -0
  33. package/lib/builtin/aptos/0x1.js.map +1 -0
  34. package/lib/builtin/aptos/0x3.d.ts +414 -0
  35. package/lib/builtin/aptos/0x3.js +461 -0
  36. package/lib/builtin/aptos/0x3.js.map +1 -0
  37. package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +2 -2
  38. package/lib/builtin/internal/eacaggregatorproxy_processor.js +12 -11
  39. package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
  40. package/lib/builtin/internal/erc20_processor.d.ts +2 -2
  41. package/lib/builtin/internal/erc20_processor.js +12 -11
  42. package/lib/builtin/internal/erc20_processor.js.map +1 -1
  43. package/lib/builtin/internal/erc20bytes_processor.d.ts +2 -2
  44. package/lib/builtin/internal/erc20bytes_processor.js +12 -11
  45. package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
  46. package/lib/builtin/internal/weth9_processor.d.ts +2 -2
  47. package/lib/builtin/internal/weth9_processor.js +12 -11
  48. package/lib/builtin/internal/weth9_processor.js.map +1 -1
  49. package/lib/builtin/solana/types.d.ts +5 -5
  50. package/lib/builtin/solana/wormhole-processor.d.ts +6 -6
  51. package/lib/builtin/solana/wormhole-processor.js +15 -12
  52. package/lib/builtin/solana/wormhole-processor.js.map +1 -1
  53. package/lib/cli/build.js +17 -16
  54. package/lib/cli/build.js.map +1 -1
  55. package/lib/core/base-processor-template.d.ts +7 -7
  56. package/lib/core/base-processor-template.js.map +1 -1
  57. package/lib/core/base-processor.d.ts +5 -6
  58. package/lib/core/base-processor.js +6 -4
  59. package/lib/core/base-processor.js.map +1 -1
  60. package/lib/core/big-decimal.d.ts +1 -0
  61. package/lib/core/big-decimal.js +6 -0
  62. package/lib/core/big-decimal.js.map +1 -0
  63. package/lib/core/bind-options.d.ts +0 -2
  64. package/lib/core/bind-options.js +4 -4
  65. package/lib/core/bind-options.js.map +1 -1
  66. package/lib/core/context.d.ts +14 -11
  67. package/lib/core/context.js +28 -19
  68. package/lib/core/context.js.map +1 -1
  69. package/lib/core/generic-processor.js +5 -5
  70. package/lib/core/generic-processor.js.map +1 -1
  71. package/lib/core/index.d.ts +5 -5
  72. package/lib/core/index.js +6 -6
  73. package/lib/core/index.js.map +1 -1
  74. package/lib/core/logger.d.ts +2 -3
  75. package/lib/core/logger.js +6 -6
  76. package/lib/core/logger.js.map +1 -1
  77. package/lib/core/metadata.d.ts +7 -4
  78. package/lib/core/metadata.js +13 -10
  79. package/lib/core/metadata.js.map +1 -1
  80. package/lib/core/meter.d.ts +4 -7
  81. package/lib/core/meter.js +12 -13
  82. package/lib/core/meter.js.map +1 -1
  83. package/lib/core/solana-processor.d.ts +7 -4
  84. package/lib/core/solana-processor.js +14 -20
  85. package/lib/core/solana-processor.js.map +1 -1
  86. package/lib/core/sui-processor.d.ts +5 -4
  87. package/lib/core/sui-processor.js +10 -17
  88. package/lib/core/sui-processor.js.map +1 -1
  89. package/lib/error.d.ts +2 -2
  90. package/lib/error.js.map +1 -1
  91. package/lib/gen/processor/protos/processor.d.ts +23 -12
  92. package/lib/gen/processor/protos/processor.js +129 -57
  93. package/lib/gen/processor/protos/processor.js.map +1 -1
  94. package/lib/index.d.ts +1 -2
  95. package/lib/index.js +1 -4
  96. package/lib/index.js.map +1 -1
  97. package/lib/processor-state.d.ts +1 -1
  98. package/lib/processor-state.js.map +1 -1
  99. package/lib/service.js +13 -12
  100. package/lib/service.js.map +1 -1
  101. package/lib/target-ethers-sentio/codegen.js +14 -15
  102. package/lib/target-ethers-sentio/codegen.js.map +1 -1
  103. package/lib/test-abi-code-gen.js.map +1 -1
  104. package/lib/testing/metric-utils.js +2 -2
  105. package/lib/testing/metric-utils.js.map +1 -1
  106. package/lib/tests/aptos.test.js +95 -2
  107. package/lib/tests/aptos.test.js.map +1 -1
  108. package/lib/tests/erc20.js +1 -1
  109. package/lib/tests/erc20.js.map +1 -1
  110. package/lib/tests/erc20.test.js +3 -4
  111. package/lib/tests/erc20.test.js.map +1 -1
  112. package/lib/tests/solana.test.js +5 -1
  113. package/lib/tests/solana.test.js.map +1 -1
  114. package/lib/tests/souffl3.js +17 -4
  115. package/lib/tests/souffl3.js.map +1 -1
  116. package/lib/tests/sui.test.js +1 -4
  117. package/lib/tests/sui.test.js.map +1 -1
  118. package/lib/tests/types/aptos/souffle.d.ts +311 -22
  119. package/lib/tests/types/aptos/souffle.js +142 -6
  120. package/lib/tests/types/aptos/souffle.js.map +1 -1
  121. package/lib/tests/types/solana/basic_1_processor.d.ts +2 -2
  122. package/lib/tests/types/solana/basic_1_processor.js +4 -4
  123. package/lib/tests/types/solana/basic_1_processor.js.map +1 -1
  124. package/lib/tests/wormhole-token-bridge.js +2 -1
  125. package/lib/tests/wormhole-token-bridge.js.map +1 -1
  126. package/lib/utils/chain.d.ts +1 -0
  127. package/lib/utils/chain.js +15 -1
  128. package/lib/utils/chain.js.map +1 -1
  129. package/lib/utils/conversion.d.ts +1 -1
  130. package/lib/utils/conversion.js.map +1 -1
  131. package/package.json +3 -2
  132. package/src/abis/aptos/0x1.json +9205 -0
  133. package/src/abis/aptos/0x3.json +1515 -0
  134. package/src/aptos/aptos-processor.ts +88 -20
  135. package/src/aptos/bind-options.ts +0 -7
  136. package/src/aptos/context.ts +11 -8
  137. package/src/aptos/index.ts +3 -2
  138. package/src/aptos/runtime.ts +13 -0
  139. package/src/aptos/types.ts +203 -0
  140. package/src/aptos/utils.ts +18 -0
  141. package/src/aptos-codegen/codegen.ts +222 -19
  142. package/src/aptos-codegen/typegen.test.ts +29 -0
  143. package/src/aptos-codegen/typegen.ts +216 -0
  144. package/src/binds.ts +5 -39
  145. package/src/builtin/aptos/0x1.ts +3760 -0
  146. package/src/builtin/aptos/0x3.ts +798 -0
  147. package/src/builtin/internal/eacaggregatorproxy_processor.ts +14 -31
  148. package/src/builtin/internal/erc20_processor.ts +14 -25
  149. package/src/builtin/internal/erc20bytes_processor.ts +14 -25
  150. package/src/builtin/internal/weth9_processor.ts +14 -25
  151. package/src/builtin/solana/wormhole-processor.ts +21 -18
  152. package/src/cli/build.ts +19 -17
  153. package/src/core/base-processor-template.ts +7 -7
  154. package/src/core/base-processor.ts +30 -9
  155. package/src/core/big-decimal.ts +1 -0
  156. package/src/core/bind-options.ts +3 -2
  157. package/src/core/context.ts +40 -24
  158. package/src/core/generic-processor.ts +6 -7
  159. package/src/core/index.ts +5 -5
  160. package/src/core/logger.ts +7 -7
  161. package/src/core/metadata.ts +14 -12
  162. package/src/core/meter.ts +12 -14
  163. package/src/core/solana-processor.ts +24 -21
  164. package/src/core/sui-processor.ts +10 -21
  165. package/src/error.ts +2 -2
  166. package/src/gen/processor/protos/processor.ts +158 -68
  167. package/src/index.ts +1 -2
  168. package/src/processor-state.ts +1 -1
  169. package/src/service.ts +22 -15
  170. package/src/target-ethers-sentio/codegen.ts +14 -15
  171. package/src/test-abi-code-gen.ts +1 -0
  172. package/src/testing/metric-utils.ts +2 -2
  173. package/src/tests/aptos.test.ts +102 -3
  174. package/src/tests/erc20.test.ts +3 -4
  175. package/src/tests/erc20.ts +1 -1
  176. package/src/tests/solana.test.ts +5 -1
  177. package/src/tests/souffl3.ts +21 -6
  178. package/src/tests/sui.test.ts +1 -4
  179. package/src/tests/types/aptos/souffle.ts +424 -42
  180. package/src/tests/types/solana/basic_1_processor.ts +6 -6
  181. package/src/tests/wormhole-token-bridge.ts +2 -1
  182. package/src/types/global.d.ts +1 -1
  183. package/src/utils/chain.ts +14 -0
  184. package/src/utils/conversion.ts +1 -1
  185. package/lib/contract-namer.d.ts +0 -6
  186. package/lib/contract-namer.js +0 -20
  187. package/lib/contract-namer.js.map +0 -1
  188. package/src/aptos-codegen/codgen.test.ts +0 -11
  189. package/src/contract-namer.ts +0 -17
@@ -7,7 +7,7 @@ exports.SolanaBaseProcessor = void 0;
7
7
  const context_1 = require("./context");
8
8
  const long_1 = __importDefault(require("long"));
9
9
  class SolanaBaseProcessor {
10
- instructionHanlderMap = new Map();
10
+ instructionHandlerMap = new Map();
11
11
  address;
12
12
  endpoint;
13
13
  contractName;
@@ -41,32 +41,26 @@ class SolanaBaseProcessor {
41
41
  if (!this.isBind()) {
42
42
  throw new Error("Processor doesn't bind to an address");
43
43
  }
44
- this.instructionHanlderMap.set(instructionName, handler);
44
+ this.instructionHandlerMap.set(instructionName, handler);
45
45
  return this;
46
46
  }
47
- handleInstruction(ins, slot) {
48
- const ctx = new context_1.SolanaContext(this.address, slot);
49
- let parsedInstruction = null;
47
+ getParsedInstruction(ins) {
50
48
  if (ins) {
51
49
  if (ins.info) {
52
- if (this.fromParsedInstruction == null) {
53
- return null;
54
- }
55
- parsedInstruction = this.fromParsedInstruction(ins);
50
+ return this.fromParsedInstruction ? this.fromParsedInstruction(ins) : null;
56
51
  }
57
- else {
58
- if (this.decodeInstruction == null) {
59
- return null;
60
- }
61
- parsedInstruction = this.decodeInstruction(ins);
62
- }
63
- if (parsedInstruction) {
64
- const handler = this.instructionHanlderMap.get(parsedInstruction.name);
65
- if (handler) {
66
- handler(parsedInstruction, ctx);
67
- }
52
+ if (this.decodeInstruction != null) {
53
+ return this.decodeInstruction(ins);
68
54
  }
69
55
  }
56
+ return null;
57
+ }
58
+ getInstructionHandler(parsedInstruction) {
59
+ return this.instructionHandlerMap.get(parsedInstruction.name);
60
+ }
61
+ handleInstruction(parsedInstruction, accounts, handler, slot) {
62
+ const ctx = new context_1.SolanaContext(this.contractName, this.address, slot);
63
+ handler(parsedInstruction, ctx, accounts);
70
64
  return {
71
65
  gauges: ctx.gauges,
72
66
  counters: ctx.counters,
@@ -1 +1 @@
1
- {"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"names":[],"mappings":"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","sourcesContent":["import { ProcessResult } from '../gen'\nimport { SolanaContext } from './context'\nimport Long from 'long'\nimport { Instruction } from '@project-serum/anchor'\nimport { SolanaBindOptions } from './bind-options'\n\ntype IndexConfigure = {\n startSlot: Long\n endSlot?: Long\n}\n\nexport class SolanaBaseProcessor {\n public instructionHanlderMap: Map<string, (instruction: Instruction, ctx: SolanaContext) => void> = new Map()\n address: string\n endpoint: string\n contractName: string\n processInnerInstruction: boolean\n config: IndexConfigure = { startSlot: new Long(0) }\n decodeInstruction: (rawInstruction: string) => Instruction | null\n fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null\n\n constructor(options: SolanaBindOptions) {\n if (options) {\n this.bind(options)\n }\n global.PROCESSOR_STATE.solanaProcessors.push(this)\n }\n\n bind(options: SolanaBindOptions) {\n this.address = options.address\n this.contractName = options.name || ''\n this.processInnerInstruction = options.processInnerInstruction || false\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n this.endpoint = options.network || 'https://api.mainnet-beta.solana.com'\n }\n\n innerInstruction(flag: boolean) {\n this.processInnerInstruction = flag\n return this\n }\n\n public onInstruction(instructionName: string, handler: (instruction: Instruction, ctx: SolanaContext) => void) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.instructionHanlderMap.set(instructionName, handler)\n\n return this\n }\n\n public handleInstruction(ins: string | { type: string; info: any }, slot: Long): ProcessResult | null {\n const ctx = new SolanaContext(this.address, slot)\n let parsedInstruction: Instruction | null = null\n\n if (ins) {\n if ((ins as { type: string; info: any }).info) {\n if (this.fromParsedInstruction == null) {\n return null\n }\n parsedInstruction = this.fromParsedInstruction(ins as { type: string; info: any })\n } else {\n if (this.decodeInstruction == null) {\n return null\n }\n parsedInstruction = this.decodeInstruction(ins as string)\n }\n if (parsedInstruction) {\n const handler = this.instructionHanlderMap.get(parsedInstruction.name)\n if (handler) {\n handler(parsedInstruction, ctx)\n }\n }\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSlot = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSlot = endBlock\n return this\n }\n}\n"]}
1
+ {"version":3,"file":"solana-processor.js","sourceRoot":"","sources":["../../src/core/solana-processor.ts"],"names":[],"mappings":"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","sourcesContent":["import { ProcessResult } from '../gen'\nimport { SolanaContext } from './context'\nimport Long from 'long'\nimport { Instruction } from '@project-serum/anchor'\nimport { SolanaBindOptions } from './bind-options'\n\ntype IndexConfigure = {\n startSlot: Long\n endSlot?: Long\n}\n\nexport type SolanaInstructionHandler = (instruction: Instruction, ctx: SolanaContext, accounts?: string[]) => void\n\nexport class SolanaBaseProcessor {\n public instructionHandlerMap: Map<string, SolanaInstructionHandler> = new Map()\n address: string\n endpoint: string\n contractName: string\n processInnerInstruction: boolean\n config: IndexConfigure = { startSlot: new Long(0) }\n decodeInstruction: (rawInstruction: string) => Instruction | null\n fromParsedInstruction: (instruction: { type: string; info: any }) => Instruction | null\n\n constructor(options: SolanaBindOptions) {\n if (options) {\n this.bind(options)\n }\n global.PROCESSOR_STATE.solanaProcessors.push(this)\n }\n\n bind(options: SolanaBindOptions) {\n this.address = options.address\n this.contractName = options.name || ''\n this.processInnerInstruction = options.processInnerInstruction || false\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n this.endpoint = options.network || 'https://api.mainnet-beta.solana.com'\n }\n\n innerInstruction(flag: boolean) {\n this.processInnerInstruction = flag\n return this\n }\n\n public onInstruction(instructionName: string, handler: SolanaInstructionHandler) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.instructionHandlerMap.set(instructionName, handler)\n\n return this\n }\n\n public getParsedInstruction(ins: string | { type: string; info: any }): Instruction | null {\n if (ins) {\n if ((ins as { type: string; info: any }).info) {\n return this.fromParsedInstruction ? this.fromParsedInstruction(ins as { type: string; info: any }) : null\n }\n if (this.decodeInstruction != null) {\n return this.decodeInstruction(ins as string)\n }\n }\n return null\n }\n\n public getInstructionHandler(parsedInstruction: Instruction): SolanaInstructionHandler | undefined {\n return this.instructionHandlerMap.get(parsedInstruction.name)\n }\n\n public handleInstruction(\n parsedInstruction: Instruction,\n accounts: string[],\n handler: SolanaInstructionHandler,\n slot: Long\n ): ProcessResult {\n const ctx = new SolanaContext(this.contractName, this.address, slot)\n handler(parsedInstruction, ctx, accounts)\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSlot = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSlot = endBlock\n return this\n }\n}\n"]}
@@ -1,4 +1,3 @@
1
- import { SuiBindOptions } from './bind-options';
2
1
  import { SuiContext } from './context';
3
2
  import { ProcessResult } from '../gen';
4
3
  import Long from 'long';
@@ -6,15 +5,17 @@ declare type IndexConfigure = {
6
5
  startSeqNumber: Long;
7
6
  endSeqNumber?: Long;
8
7
  };
8
+ export declare class SuiBindOptions {
9
+ address: string;
10
+ startBlock?: Long | number;
11
+ }
9
12
  export declare class SuiBaseProcessor {
10
13
  transactionHanlder: (transaction: any, ctx: SuiContext) => void;
11
14
  address: string;
12
15
  config: IndexConfigure;
13
- constructor(options: SuiBindOptions);
14
- bind(options: SuiBindOptions): void;
16
+ constructor(name: string, options: SuiBindOptions);
15
17
  onTransaction(handler: (transaction: any, ctx: SuiContext) => void): this;
16
18
  handleTransaction(txn: any, slot: Long): ProcessResult | null;
17
- isBind(): boolean;
18
19
  startSlot(startSlot: Long | number): this;
19
20
  endBlock(endBlock: Long | number): this;
20
21
  }
@@ -3,32 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.SuiBaseProcessor = void 0;
6
+ exports.SuiBaseProcessor = exports.SuiBindOptions = void 0;
7
7
  const context_1 = require("./context");
8
8
  const long_1 = __importDefault(require("long"));
9
+ class SuiBindOptions {
10
+ address;
11
+ // network?: Networkish = 1
12
+ // name?: string
13
+ startBlock;
14
+ }
15
+ exports.SuiBindOptions = SuiBindOptions;
9
16
  class SuiBaseProcessor {
10
17
  transactionHanlder;
11
18
  address;
12
19
  config = { startSeqNumber: new long_1.default(0) };
13
- constructor(options) {
14
- if (options) {
15
- this.bind(options);
16
- }
17
- global.PROCESSOR_STATE.suiProcessors.push(this);
18
- }
19
- bind(options) {
20
+ constructor(name, options) {
20
21
  this.address = options.address;
21
22
  if (options.startBlock) {
22
23
  this.startSlot(options.startBlock);
23
24
  }
24
- if (options.endBlock) {
25
- this.endBlock(options.endBlock);
26
- }
25
+ global.PROCESSOR_STATE.suiProcessors.push(this);
27
26
  }
28
27
  onTransaction(handler) {
29
- if (!this.isBind()) {
30
- throw new Error("Processor doesn't bind to an address");
31
- }
32
28
  this.transactionHanlder = handler;
33
29
  return this;
34
30
  }
@@ -43,9 +39,6 @@ class SuiBaseProcessor {
43
39
  logs: ctx.logs,
44
40
  };
45
41
  }
46
- isBind() {
47
- return this.address !== null;
48
- }
49
42
  startSlot(startSlot) {
50
43
  if (typeof startSlot === 'number') {
51
44
  startSlot = long_1.default.fromNumber(startSlot);
@@ -1 +1 @@
1
- {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/core/sui-processor.ts"],"names":[],"mappings":";;;;;;AACA,uCAAsC;AAEtC,gDAAuB;AAOvB,MAAa,gBAAgB;IACpB,kBAAkB,CAA6C;IACtE,OAAO,CAAQ;IACf,MAAM,GAAmB,EAAE,cAAc,EAAE,IAAI,cAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAExD,YAAY,OAAuB;QACjC,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SACnB;QACD,MAAM,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjD,CAAC;IAED,IAAI,CAAC,OAAuB;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACnC;QACD,IAAI,OAAO,CAAC,QAAQ,EAAE;YACpB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;SAChC;IACH,CAAC;IAEM,aAAa,CAAC,OAAoD;QACvE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE;YAClB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAA;SACxD;QAED,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAA;QAEjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,iBAAiB,CAAC,GAAQ,EAAE,IAAU;QAC3C,MAAM,GAAG,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAE9C,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAClC;QACD,OAAO;YACL,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAA;IACH,CAAC;IAEM,MAAM;QACX,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAA;IAC9B,CAAC;IAEM,SAAS,CAAC,SAAwB;QACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;SACvC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,SAAS,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAuB;QACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAhED,4CAgEC","sourcesContent":["import { SuiBindOptions } from './bind-options'\nimport { SuiContext } from './context'\nimport { ProcessResult } from '../gen'\nimport Long from 'long'\n\ntype IndexConfigure = {\n startSeqNumber: Long\n endSeqNumber?: Long\n}\n\nexport class SuiBaseProcessor {\n public transactionHanlder: (transaction: any, ctx: SuiContext) => void\n address: string\n config: IndexConfigure = { startSeqNumber: new Long(0) }\n\n constructor(options: SuiBindOptions) {\n if (options) {\n this.bind(options)\n }\n global.PROCESSOR_STATE.suiProcessors.push(this)\n }\n\n bind(options: SuiBindOptions) {\n this.address = options.address\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n if (options.endBlock) {\n this.endBlock(options.endBlock)\n }\n }\n\n public onTransaction(handler: (transaction: any, ctx: SuiContext) => void) {\n if (!this.isBind()) {\n throw new Error(\"Processor doesn't bind to an address\")\n }\n\n this.transactionHanlder = handler\n\n return this\n }\n\n public handleTransaction(txn: any, slot: Long): ProcessResult | null {\n const ctx = new SuiContext(this.address, slot)\n\n if (txn) {\n this.transactionHanlder(txn, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n }\n\n public isBind() {\n return this.address !== null\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSeqNumber = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSeqNumber = endBlock\n return this\n }\n}\n"]}
1
+ {"version":3,"file":"sui-processor.js","sourceRoot":"","sources":["../../src/core/sui-processor.ts"],"names":[],"mappings":";;;;;;AAAA,uCAAsC;AAEtC,gDAAuB;AAOvB,MAAa,cAAc;IACzB,OAAO,CAAQ;IACf,2BAA2B;IAC3B,gBAAgB;IAChB,UAAU,CAAgB;CAE3B;AAND,wCAMC;AAED,MAAa,gBAAgB;IACpB,kBAAkB,CAA6C;IACtE,OAAO,CAAQ;IACf,MAAM,GAAmB,EAAE,cAAc,EAAE,IAAI,cAAI,CAAC,CAAC,CAAC,EAAE,CAAA;IAExD,YAAY,IAAY,EAAE,OAAuB;QAC/C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,OAAO,CAAC,UAAU,EAAE;YACtB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;SACnC;QACD,MAAM,CAAC,eAAe,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjD,CAAC;IAEM,aAAa,CAAC,OAAoD;QACvE,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAA;QACjC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,iBAAiB,CAAC,GAAQ,EAAE,IAAU;QAC3C,MAAM,GAAG,GAAG,IAAI,oBAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;QAE9C,IAAI,GAAG,EAAE;YACP,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;SAClC;QACD,OAAO;YACL,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;SACf,CAAA;IACH,CAAC;IAEM,SAAS,CAAC,SAAwB;QACvC,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;YACjC,SAAS,GAAG,cAAI,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;SACvC;QACD,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,SAAS,CAAA;QACtC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,QAAQ,CAAC,QAAuB;QACrC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;YAChC,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;SACrC;QACD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,QAAQ,CAAA;QACnC,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9CD,4CA8CC","sourcesContent":["import { SuiContext } from './context'\nimport { ProcessResult } from '../gen'\nimport Long from 'long'\n\ntype IndexConfigure = {\n startSeqNumber: Long\n endSeqNumber?: Long\n}\n\nexport class SuiBindOptions {\n address: string\n // network?: Networkish = 1\n // name?: string\n startBlock?: Long | number\n // endBlock?: Long | number\n}\n\nexport class SuiBaseProcessor {\n public transactionHanlder: (transaction: any, ctx: SuiContext) => void\n address: string\n config: IndexConfigure = { startSeqNumber: new Long(0) }\n\n constructor(name: string, options: SuiBindOptions) {\n this.address = options.address\n if (options.startBlock) {\n this.startSlot(options.startBlock)\n }\n global.PROCESSOR_STATE.suiProcessors.push(this)\n }\n\n public onTransaction(handler: (transaction: any, ctx: SuiContext) => void) {\n this.transactionHanlder = handler\n return this\n }\n\n public handleTransaction(txn: any, slot: Long): ProcessResult | null {\n const ctx = new SuiContext(this.address, slot)\n\n if (txn) {\n this.transactionHanlder(txn, ctx)\n }\n return {\n gauges: ctx.gauges,\n counters: ctx.counters,\n logs: ctx.logs,\n }\n }\n\n public startSlot(startSlot: Long | number) {\n if (typeof startSlot === 'number') {\n startSlot = Long.fromNumber(startSlot)\n }\n this.config.startSeqNumber = startSlot\n return this\n }\n\n public endBlock(endBlock: Long | number) {\n if (typeof endBlock === 'number') {\n endBlock = Long.fromNumber(endBlock)\n }\n this.config.endSeqNumber = endBlock\n return this\n }\n}\n"]}
package/lib/error.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Context } from './core/context';
1
+ import { ContractContext } from './core/context';
2
2
  export declare class EthersError extends Error {
3
3
  e: Error;
4
4
  constructor(message: string, e: Error);
5
5
  toString(): string;
6
6
  }
7
- export declare function transformEtherError(e: Error, ctx: Context<any, any> | undefined): Error;
7
+ export declare function transformEtherError(e: Error, ctx: ContractContext<any, any> | undefined): Error;
package/lib/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAEA,mCAA+B;AAE/B,MAAa,WAAY,SAAQ,KAAK;IACpC,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;AAXD,kCAWC;AAED,SAAgB,mBAAmB,CAAC,CAAQ,EAAE,GAAkC;IAC9E,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,mCAAmC;IACnC,IAAI,CAAC,CAAC,IAAI,KAAK,eAAM,CAAC,cAAc,EAAE;QACpC,mCAAmC;QACnC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;YACnB,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,CAAC,CAAC,CAAA;aACzF;SACF;QACD,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;KAC/B;IAED,IAAI,CAAC,YAAY,WAAW,EAAE;QAC5B,OAAO,CAAC,CAAA;KACT;IAED,qCAAqC;IAErC,GAAG,GAAG,qBAAqB,GAAG,CAAC,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;IACpE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC;AA3BD,kDA2BC","sourcesContent":["// Transform error in more readable format\nimport { Context } from './core/context'\nimport { errors } from 'ethers'\n\nexport class EthersError 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: Context<any, any> | undefined): Error {\n let msg = ''\n // @ts-ignore expected error fields\n if (e.code === errors.CALL_EXCEPTION) {\n // @ts-ignore expected error fields\n if (e.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(e)\n }\n }\n return new EthersError(msg, e)\n }\n\n if (e instanceof EthersError) {\n return e\n }\n\n // TODO gracefully handle more errors\n\n msg = 'ethers call error\\n' + e.message + '\\n' + e.stack?.toString()\n return new Error(msg)\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAEA,mCAA+B;AAE/B,MAAa,WAAY,SAAQ,KAAK;IACpC,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;AAXD,kCAWC;AAED,SAAgB,mBAAmB,CAAC,CAAQ,EAAE,GAA0C;IACtF,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,mCAAmC;IACnC,IAAI,CAAC,CAAC,IAAI,KAAK,eAAM,CAAC,cAAc,EAAE;QACpC,mCAAmC;QACnC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,EAAE;YACnB,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,CAAC,CAAC,CAAA;aACzF;SACF;QACD,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC,CAAA;KAC/B;IAED,IAAI,CAAC,YAAY,WAAW,EAAE;QAC5B,OAAO,CAAC,CAAA;KACT;IAED,qCAAqC;IAErC,GAAG,GAAG,qBAAqB,GAAG,CAAC,CAAC,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;IACpE,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAA;AACvB,CAAC;AA3BD,kDA2BC","sourcesContent":["// Transform error in more readable format\nimport { ContractContext } from './core/context'\nimport { errors } from 'ethers'\n\nexport class EthersError 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 let msg = ''\n // @ts-ignore expected error fields\n if (e.code === errors.CALL_EXCEPTION) {\n // @ts-ignore expected error fields\n if (e.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(e)\n }\n }\n return new EthersError(msg, e)\n }\n\n if (e instanceof EthersError) {\n return e\n }\n\n // TODO gracefully handle more errors\n\n msg = 'ethers call error\\n' + e.message + '\\n' + e.stack?.toString()\n return new Error(msg)\n}\n"]}
@@ -35,6 +35,7 @@ export interface ProcessConfigResponse {
35
35
  config: ProjectConfig | undefined;
36
36
  contractConfigs: ContractConfig[];
37
37
  templateInstances: TemplateInstance[];
38
+ accountConfigs: AccountConfig[];
38
39
  }
39
40
  export interface ContractConfig {
40
41
  contract: ContractInfo | undefined;
@@ -48,6 +49,8 @@ export interface ContractConfig {
48
49
  endBlock: Long;
49
50
  processorType: string;
50
51
  }
52
+ export interface AccountConfig {
53
+ }
51
54
  export interface ContractInfo {
52
55
  name: string;
53
56
  chainId: string;
@@ -127,6 +130,7 @@ export interface Instruction {
127
130
  instructionData: string;
128
131
  slot: Long;
129
132
  programAccountId: string;
133
+ accounts: string[];
130
134
  parsed?: Uint8Array | undefined;
131
135
  }
132
136
  export interface Data {
@@ -149,20 +153,21 @@ export interface ProcessResult {
149
153
  counters: CounterResult[];
150
154
  logs: LogResult[];
151
155
  }
152
- export interface MetricDescriptor {
156
+ export interface DataDescriptor {
153
157
  name: string;
154
- unit: string;
155
158
  description: string;
159
+ unit: string;
156
160
  sparse: boolean;
157
161
  }
158
162
  export interface RecordMetaData {
159
- contractAddress: string;
163
+ address: string;
164
+ contractName: string;
160
165
  blockNumber: Long;
161
166
  transactionHash: string;
167
+ chainId: string;
162
168
  transactionIndex: number;
163
169
  logIndex: number;
164
- chainId: string;
165
- descriptor: MetricDescriptor | undefined;
170
+ dataDescriptor: DataDescriptor | undefined;
166
171
  labels: {
167
172
  [key: string]: string;
168
173
  };
@@ -195,7 +200,6 @@ export interface CounterResult {
195
200
  runtimeInfo: RuntimeInfo | undefined;
196
201
  }
197
202
  export interface LogResult {
198
- name: string;
199
203
  metadata: RecordMetaData | undefined;
200
204
  level: LogLevel;
201
205
  message: string;
@@ -230,6 +234,13 @@ export declare const ContractConfig: {
230
234
  toJSON(message: ContractConfig): unknown;
231
235
  fromPartial(object: DeepPartial<ContractConfig>): ContractConfig;
232
236
  };
237
+ export declare const AccountConfig: {
238
+ encode(_: AccountConfig, writer?: _m0.Writer): _m0.Writer;
239
+ decode(input: _m0.Reader | Uint8Array, length?: number): AccountConfig;
240
+ fromJSON(_: any): AccountConfig;
241
+ toJSON(_: AccountConfig): unknown;
242
+ fromPartial(_: DeepPartial<AccountConfig>): AccountConfig;
243
+ };
233
244
  export declare const ContractInfo: {
234
245
  encode(message: ContractInfo, writer?: _m0.Writer): _m0.Writer;
235
246
  decode(input: _m0.Reader | Uint8Array, length?: number): ContractInfo;
@@ -405,12 +416,12 @@ export declare const ProcessResult: {
405
416
  toJSON(message: ProcessResult): unknown;
406
417
  fromPartial(object: DeepPartial<ProcessResult>): ProcessResult;
407
418
  };
408
- export declare const MetricDescriptor: {
409
- encode(message: MetricDescriptor, writer?: _m0.Writer): _m0.Writer;
410
- decode(input: _m0.Reader | Uint8Array, length?: number): MetricDescriptor;
411
- fromJSON(object: any): MetricDescriptor;
412
- toJSON(message: MetricDescriptor): unknown;
413
- fromPartial(object: DeepPartial<MetricDescriptor>): MetricDescriptor;
419
+ export declare const DataDescriptor: {
420
+ encode(message: DataDescriptor, writer?: _m0.Writer): _m0.Writer;
421
+ decode(input: _m0.Reader | Uint8Array, length?: number): DataDescriptor;
422
+ fromJSON(object: any): DataDescriptor;
423
+ toJSON(message: DataDescriptor): unknown;
424
+ fromPartial(object: DeepPartial<DataDescriptor>): DataDescriptor;
414
425
  };
415
426
  export declare const RecordMetaData: {
416
427
  encode(message: RecordMetaData, writer?: _m0.Writer): _m0.Writer;