@sentio/sdk 1.20.2 → 1.21.1

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.
Files changed (189) hide show
  1. package/lib/aptos/aptos-processor.d.ts +16 -15
  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 -17
  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 +2570 -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 +474 -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 +24 -12
  92. package/lib/gen/processor/protos/processor.js +147 -58
  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 +15 -13
  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 +172 -20
  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 +89 -25
  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 -18
  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 +3917 -0
  146. package/src/builtin/aptos/0x3.ts +824 -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 +177 -69
  167. package/src/index.ts +1 -2
  168. package/src/processor-state.ts +1 -1
  169. package/src/service.ts +23 -16
  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 +470 -56
  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
package/src/service.ts CHANGED
@@ -28,6 +28,7 @@ import { Empty } from './gen/google/protobuf/empty'
28
28
  import Long from 'long'
29
29
  import { TextDecoder } from 'util'
30
30
  import { Trace } from './core'
31
+ import { Instruction } from '@project-serum/anchor'
31
32
 
32
33
  const DEFAULT_MAX_BLOCK = Long.ZERO
33
34
 
@@ -65,6 +66,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
65
66
  config: undefined,
66
67
  contractConfigs: this.contractConfigs,
67
68
  templateInstances: this.templateInstances,
69
+ accountConfigs: [],
68
70
  }
69
71
  }
70
72
 
@@ -211,7 +213,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
211
213
  const contractConfig: ContractConfig = {
212
214
  processorType: USER_PROCESSOR,
213
215
  contract: {
214
- name: aptosProcessor.name,
216
+ name: aptosProcessor.moduleName,
215
217
  chainId: aptosProcessor.getChainId(),
216
218
  address: aptosProcessor.config.address,
217
219
  abi: '',
@@ -242,8 +244,9 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
242
244
  filters: handler.filters.map((filter) => {
243
245
  return {
244
246
  function: filter.function,
245
- typeArguments: filter.typeArguments ?? [],
247
+ typeArguments: filter.typeArguments || [],
246
248
  withTypeArguments: filter.typeArguments ? true : false,
249
+ includeFailed: filter.includeFailed || false,
247
250
  }
248
251
  }),
249
252
  handlerId,
@@ -464,26 +467,30 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
464
467
  new Promise((resolve, _) => {
465
468
  for (const processor of global.PROCESSOR_STATE.solanaProcessors) {
466
469
  if (processor.address === instruction.programAccountId) {
467
- let res: ProcessResult | null
470
+ let parsedInstruction: Instruction | null = null
468
471
  if (instruction.parsed) {
469
- res = processor.handleInstruction(
470
- JSON.parse(new TextDecoder().decode(instruction.parsed)),
471
- instruction.slot
472
+ parsedInstruction = processor.getParsedInstruction(
473
+ JSON.parse(new TextDecoder().decode(instruction.parsed))
472
474
  )
473
475
  } else if (instruction.instructionData) {
474
- res = processor.handleInstruction(instruction.instructionData, instruction.slot)
475
- } else {
476
+ parsedInstruction = processor.getParsedInstruction(instruction.instructionData)
477
+ }
478
+ if (parsedInstruction == null) {
476
479
  continue
477
480
  }
478
- if (res) {
479
- res.gauges.forEach((g) => result.gauges.push(g))
480
- res.counters.forEach((c) => result.counters.push(c))
481
- res.logs.forEach((l) => result.logs.push(l))
482
- } else {
483
- console.warn(
484
- `Failed to decode the instruction: ${instruction.instructionData} with slot: ${instruction.slot}`
485
- )
481
+ const insHandler = processor.getInstructionHandler(parsedInstruction)
482
+ if (insHandler == null) {
483
+ continue
486
484
  }
485
+ const res = processor.handleInstruction(
486
+ parsedInstruction,
487
+ instruction.accounts,
488
+ insHandler,
489
+ instruction.slot
490
+ )
491
+ res.gauges.forEach((g) => result.gauges.push(g))
492
+ res.counters.forEach((c) => result.counters.push(c))
493
+ res.logs.forEach((l) => result.logs.push(l))
487
494
  }
488
495
  }
489
496
  resolve()
@@ -49,18 +49,19 @@ export function codeGenSentioFile(contract: Contract): string {
49
49
  .join('\n')}
50
50
  }
51
51
 
52
- export type ${contract.name}Context = Context<${contract.name}, ${contract.name}BoundContractView>
52
+ export type ${contract.name}Context = ContractContext<${contract.name}, ${contract.name}BoundContractView>
53
53
 
54
54
  export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${contract.name}, ${
55
55
  contract.name
56
56
  }BoundContractView> {
57
57
  bindInternal(options: BindOptions) {
58
- let processor = getProcessor("${contract.name}", options) as ${contract.name}Processor
58
+ if (!options.name) {
59
+ options.name = "${contract.name}"
60
+ }
61
+ let processor = getProcessor(options) as ${contract.name}Processor
59
62
  if (!processor) {
60
- const finalOptions = Object.assign({}, options)
61
- finalOptions.name = getContractName("${contract.name}", options.name, options.address, options.network)
62
- processor = new ${contract.name}Processor(finalOptions)
63
- addProcessor("${contract.name}", options, processor)
63
+ processor = new ${contract.name}Processor(options)
64
+ addProcessor(options, processor)
64
65
  }
65
66
  return processor
66
67
  }
@@ -103,14 +104,13 @@ export function codeGenSentioFile(contract: Contract): string {
103
104
  }
104
105
 
105
106
  public static bind(options: BindOptions): ${contract.name}Processor {
106
- let processor = getProcessor("${contract.name}", options) as ${contract.name}Processor
107
+ if (!options.name) {
108
+ options.name = "${contract.name}"
109
+ }
110
+ let processor = getProcessor(options) as ${contract.name}Processor
107
111
  if (!processor) {
108
- // const wrapper = get${contract.name}Contract(options.address, options.network)
109
-
110
- const finalOptions = Object.assign({}, options)
111
- finalOptions.name = getContractName("${contract.name}", options.name, options.address, options.network)
112
- processor = new ${contract.name}Processor(finalOptions)
113
- addProcessor("${contract.name}", options, processor)
112
+ processor = new ${contract.name}Processor(options)
113
+ addProcessor(options, processor)
114
114
  }
115
115
  return processor
116
116
  }
@@ -167,10 +167,9 @@ export function codeGenSentioFile(contract: Contract): string {
167
167
  'BaseProcessor',
168
168
  'BaseProcessorTemplate',
169
169
  'BoundContractView',
170
- 'Context',
170
+ 'ContractContext',
171
171
  'ContractView',
172
172
  'DummyProvider',
173
- 'getContractName',
174
173
  'TypedCallTrace',
175
174
  ],
176
175
  './common': ['PromiseOrValue'],
@@ -6,6 +6,7 @@ import path from 'path'
6
6
  if (process.argv.length > 3) {
7
7
  const abisDir = process.argv[2]
8
8
  const targetDir = process.argv[3]
9
+
9
10
  codeGenAptosProcessor(path.join(abisDir, 'aptos'), path.join(targetDir, 'aptos'))
10
11
  codeGenSolanaProcessor(path.join(abisDir, 'solana'), path.join(targetDir, 'solana'))
11
12
  } else {
@@ -29,7 +29,7 @@ export function firstCounterValue(result: ProcessResult | undefined, name: strin
29
29
  return undefined
30
30
  }
31
31
  for (const counter of result.counters) {
32
- if (counter.metadata?.descriptor?.name === name) {
32
+ if (counter.metadata?.dataDescriptor?.name === name) {
33
33
  return MetricValueToNumber(counter.metricValue)
34
34
  }
35
35
  }
@@ -41,7 +41,7 @@ export function firstGaugeValue(result: ProcessResult | undefined, name: string)
41
41
  return undefined
42
42
  }
43
43
  for (const gauge of result.gauges) {
44
- if (gauge.metadata?.descriptor?.name === name) {
44
+ if (gauge.metadata?.dataDescriptor?.name === name) {
45
45
  return MetricValueToNumber(gauge.metricValue)
46
46
  }
47
47
  }
@@ -2,7 +2,7 @@ import { expect } from 'chai'
2
2
  import { TextEncoder } from 'util'
3
3
  import { HandlerType, ProcessBindingsRequest } from '..'
4
4
 
5
- import { TestProcessorServer } from '../testing'
5
+ import { firstCounterValue, firstGaugeValue, TestProcessorServer } from '../testing'
6
6
 
7
7
  describe('Test Aptos Example', () => {
8
8
  const service = new TestProcessorServer(() => {
@@ -15,7 +15,7 @@ describe('Test Aptos Example', () => {
15
15
 
16
16
  test('check configuration ', async () => {
17
17
  const config = await service.getConfig({})
18
- expect(config.contractConfigs).length(2)
18
+ expect(config.contractConfigs).length(4)
19
19
  })
20
20
 
21
21
  test('Check souffl3 transaction dispatch', async () => {
@@ -59,7 +59,7 @@ describe('Test Aptos Example', () => {
59
59
  bindings: [
60
60
  {
61
61
  data: {
62
- raw: new TextEncoder().encode(JSON.stringify(testData.events[1])),
62
+ raw: new TextEncoder().encode(JSON.stringify(testData.events[testData.events.length - 1])),
63
63
  },
64
64
  handlerId: 0,
65
65
  handlerType: HandlerType.APT_EVENT,
@@ -71,6 +71,39 @@ describe('Test Aptos Example', () => {
71
71
  expect(res.result?.gauges).length(0)
72
72
  expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034)
73
73
  })
74
+
75
+ test('Check token deposit event dispatch', async () => {
76
+ const request: ProcessBindingsRequest = {
77
+ bindings: [
78
+ {
79
+ data: {
80
+ raw: new TextEncoder().encode(JSON.stringify(tokenTestData)),
81
+ },
82
+ handlerId: 2,
83
+ handlerType: HandlerType.APT_EVENT,
84
+ },
85
+ ],
86
+ }
87
+ const res = await service.processBindings(request)
88
+ expect(firstCounterValue(res.result, 'deposit')).equal(1n)
89
+ expect(firstGaugeValue(res.result, 'version')).equal(0n)
90
+ })
91
+
92
+ test('Check create poposal event dispatch', async () => {
93
+ const request: ProcessBindingsRequest = {
94
+ bindings: [
95
+ {
96
+ data: {
97
+ raw: new TextEncoder().encode(JSON.stringify(createProposalData)),
98
+ },
99
+ handlerId: 3,
100
+ handlerType: HandlerType.APT_EVENT,
101
+ },
102
+ ],
103
+ }
104
+ const res = await service.processBindings(request)
105
+ expect(firstGaugeValue(res.result, 'size')).equal(2n)
106
+ })
74
107
  })
75
108
 
76
109
  const testData = {
@@ -182,7 +215,73 @@ const testData = {
182
215
  },
183
216
  },
184
217
  },
218
+ {
219
+ version: '18483034',
220
+ guid: {
221
+ creation_number: '7',
222
+ account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
223
+ },
224
+ sequence_number: '980533',
225
+ type: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::PullTokenEvent',
226
+ data: {
227
+ receiver: '0x3a80be5daa84f2da7e07b3ec9234da48a5647f757187879c97a1fa03f31f1195',
228
+ },
229
+ },
185
230
  ],
186
231
  timestamp: '1663143945131218',
187
232
  type: 'user_transaction',
188
233
  }
234
+
235
+ const tokenTestData = {
236
+ version: '18483034',
237
+ guid: {
238
+ creation_number: '4',
239
+ account_address: '0x89bc80de59187f707a59ae7a4121718dafe3e6068e0509104ef7e41a56bc97db',
240
+ },
241
+ sequence_number: '10',
242
+ type: '0x3::token::DepositEvent',
243
+ data: {
244
+ amount: '1',
245
+ id: {
246
+ property_version: '0',
247
+ token_data_id: {
248
+ collection: 'Topaz Troopers',
249
+ creator: '0x9125e4054d884fdc7296b66e12c0d63a7baa0d88c77e8e784987c0a967c670ac',
250
+ name: 'Topaz Trooper #11293',
251
+ },
252
+ },
253
+ },
254
+ }
255
+
256
+ const createProposalData = {
257
+ version: '1',
258
+ guid: {
259
+ creation_number: '5',
260
+ account_address: '0x1',
261
+ },
262
+ sequence_number: '3',
263
+ type: '0x1::voting::CreateProposalEvent',
264
+ data: {
265
+ early_resolution_vote_threshold: {
266
+ vec: ['9272156337856446330'],
267
+ },
268
+ execution_hash: '0x31549239ce8abdc1e9c259178614c3d44d015bd6d48635ddcfbfa4a77e7222b0',
269
+ expiration_secs: '1665463839',
270
+ metadata: {
271
+ data: [
272
+ {
273
+ key: 'metadata_hash',
274
+ value:
275
+ '0x61633230656566373063616466363939663530353564323463356363353931396463306330656562643463303662653332346336323030313561633361653066',
276
+ },
277
+ {
278
+ key: 'metadata_location',
279
+ value:
280
+ '0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6d6f76656b6576696e2f30353766623134356234303836366566663863323263393166623964613931392f7261772f626162383566306637343334663030386138373831656563376663616464316163356135353438312f6769737466696c65312e747874',
281
+ },
282
+ ],
283
+ },
284
+ min_vote_threshold: '100000000000000',
285
+ proposal_id: '3',
286
+ },
287
+ }
@@ -20,11 +20,9 @@ describe('Test Basic Examples', () => {
20
20
  const config = await service.getConfig({})
21
21
  expect(config.contractConfigs).length(5)
22
22
 
23
- // check auto rename
24
23
  expect(config.contractConfigs?.[2].contract?.name).equals('ERC20')
25
- expect(config.contractConfigs?.[3].contract?.name).equals('ERC20_1')
26
- // same as above because only differ in parameters
27
- expect(config.contractConfigs?.[4].contract?.name).equals('ERC20_1')
24
+ expect(config.contractConfigs?.[3].contract?.name).equals('ERC20')
25
+ expect(config.contractConfigs?.[4].contract?.name).equals('ytoken')
28
26
  })
29
27
 
30
28
  test('Check block dispatch', async () => {
@@ -32,6 +30,7 @@ describe('Test Basic Examples', () => {
32
30
  expect(res?.counters).length(0)
33
31
  expect(res?.gauges).length(1)
34
32
  expect(firstGaugeValue(res, 'g1')).equals(10n)
33
+ expect(res?.gauges[0].metadata?.contractName).equals('x2y2')
35
34
 
36
35
  const gauge = res?.gauges?.[0]
37
36
  expect(gauge?.metadata?.blockNumber?.toString()).equals('14373295')
@@ -42,7 +42,7 @@ ERC20Processor.bind({ address: 'xxxx', network: 56 })
42
42
 
43
43
  ERC20Processor.bind({ address: 'yyyy', network: 1 })
44
44
  ERC20Processor.bind({ address: 'yyyy', network: 1 })
45
- ERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21 })
45
+ ERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21, name: 'ytoken' })
46
46
 
47
47
  // const template = Erc20Processor.template
48
48
  // .onTransfer(async function (event, ctx) {
@@ -29,19 +29,22 @@ describe('Test Solana Example', () => {
29
29
  instructionData: '33G5T8yXAQWdH8FX7fTy1mBJ6e4dUKfQWbViSrT7qJjpS8UAA3ftEQx9sNzrkaJm56xtENhDsWf',
30
30
  slot: Long.fromNumber(12345),
31
31
  programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',
32
+ accounts: ['worm'],
32
33
  },
33
34
  {
34
35
  instructionData: '33G5T8yXAQWdH8FX7fTy1mBJ6e4dUKfQWbViSrT7qJjpS8UAA3ftEQx9sNzrkaJm56xtENhDsWf',
35
36
  slot: Long.fromNumber(1),
36
37
  programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',
38
+ accounts: ['worm'],
37
39
  },
38
40
  ],
39
41
  }
40
42
  const res = await service.processInstructions(request)
41
- expect(res.result?.counters).length(2)
43
+ expect(res.result?.counters).length(4)
42
44
  expect(res.result?.gauges).length(0)
43
45
  expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(12345)
44
46
  expect(firstCounterValue(res.result, 'total_transfer_amount')).equal(1000000n)
47
+ expect(firstCounterValue(res.result, 'worm')).equal(1000000n)
45
48
  expect(res.result?.counters[0].runtimeInfo?.from).equals(HandlerType.INSTRUCTION)
46
49
  })
47
50
 
@@ -62,6 +65,7 @@ describe('Test Solana Example', () => {
62
65
  slot: Long.fromNumber(0),
63
66
  programAccountId: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',
64
67
  parsed: new TextEncoder().encode(JSON.stringify(parsedIns)),
68
+ accounts: [],
65
69
  },
66
70
  ],
67
71
  }
@@ -1,11 +1,14 @@
1
1
  import { SouffleChefCampaign, CandyMachine } from './types/aptos/souffle'
2
+ import { token } from '../builtin/aptos/0x3'
3
+ import { voting } from '../builtin/aptos/0x1'
2
4
 
3
- SouffleChefCampaign.bind()
4
- .onEntryPullTokenV2((call, ctx) => {
5
+ SouffleChefCampaign.bind({ startVersion: 3212312 })
6
+ .onEntryPullTokenV2((call: SouffleChefCampaign.PullTokenV2Payload<any>, ctx) => {
5
7
  ctx.meter.Counter('call_num').add(1)
6
- ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]))
8
+ ctx.meter.Counter('pulled').add(call.arguments_typed[3])
7
9
  })
8
- .onEventBurnEnjoyEvent((evt, ctx) => {
10
+ .onEventPullTokenEvent((evt, ctx) => {
11
+ console.log(evt.data_typed.receiver)
9
12
  ctx.meter.Counter('burned').add(1)
10
13
  })
11
14
  .onEvent(
@@ -20,12 +23,24 @@ SouffleChefCampaign.bind()
20
23
  if (txn.events) {
21
24
  for (const event of txn.events) {
22
25
  if (event && event.type === '0x3::token::DepositEvent') {
26
+ // const typedEvent = this.dec
23
27
  ctx.meter.Counter('deposit_token_count').add(Number(event.data.amount))
24
28
  }
25
29
  }
26
30
  }
27
31
  })
28
32
 
29
- CandyMachine.bind().onEntryPullToken((call, ctx) => {
30
- ctx.meter.Counter('pulled').add(parseInt(call.arguments[3]))
33
+ CandyMachine.bind().onEntryPullToken((call: CandyMachine.PullTokenPayload<any>, ctx) => {
34
+ ctx.meter.Counter('pulled').add(call.arguments[2])
35
+ })
36
+
37
+ token.bind().onEventDepositEvent((evt: token.DepositEventInstance, ctx) => {
38
+ ctx.meter.Gauge('version').record(evt.data_typed.id.property_version)
39
+ ctx.meter.Counter('deposit').add(evt.data_typed.amount, { token: evt.data_typed.id.token_data_id.name })
40
+ })
41
+
42
+ voting.bind().onEventCreateProposalEvent((evt, ctx) => {
43
+ // console.log(evt)
44
+ evt.data_typed.expiration_secs + evt.data_typed.expiration_secs
45
+ ctx.meter.Gauge('size').record(evt.data_typed.metadata.data.length)
31
46
  })
@@ -10,10 +10,7 @@ describe('Test Sui Example', () => {
10
10
  const service = new TestProcessorServer(() => {
11
11
  class TicTacToeProcessor extends SuiBaseProcessor {
12
12
  static bind(options: SuiBindOptions): TicTacToeProcessor {
13
- if (options && !options.name) {
14
- options.name = 'TicTacToe'
15
- }
16
- return new TicTacToeProcessor(options)
13
+ return new TicTacToeProcessor('TicTacToe', options)
17
14
  }
18
15
  }
19
16