@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.
- package/lib/aptos/aptos-processor.d.ts +17 -12
- package/lib/aptos/aptos-processor.js +65 -13
- package/lib/aptos/aptos-processor.js.map +1 -1
- package/lib/aptos/bind-options.d.ts +0 -6
- package/lib/aptos/bind-options.js +1 -8
- package/lib/aptos/bind-options.js.map +1 -1
- package/lib/aptos/context.d.ts +5 -4
- package/lib/aptos/context.js +9 -6
- package/lib/aptos/context.js.map +1 -1
- package/lib/aptos/index.d.ts +3 -2
- package/lib/aptos/index.js +1 -2
- package/lib/aptos/index.js.map +1 -1
- package/lib/aptos/runtime.d.ts +2 -0
- package/lib/aptos/runtime.js +16 -0
- package/lib/aptos/runtime.js.map +1 -0
- package/lib/aptos/types.d.ts +28 -0
- package/lib/aptos/types.js +159 -0
- package/lib/aptos/types.js.map +1 -0
- package/lib/aptos/utils.d.ts +6 -0
- package/lib/aptos/utils.js +19 -0
- package/lib/aptos/utils.js.map +1 -0
- package/lib/aptos-codegen/codegen.d.ts +5 -2
- package/lib/aptos-codegen/codegen.js +195 -18
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/aptos-codegen/typegen.d.ts +18 -0
- package/lib/aptos-codegen/typegen.js +196 -0
- package/lib/aptos-codegen/typegen.js.map +1 -0
- package/lib/binds.d.ts +2 -3
- package/lib/binds.js +6 -33
- package/lib/binds.js.map +1 -1
- package/lib/builtin/aptos/0x1.d.ts +1624 -0
- package/lib/builtin/aptos/0x1.js +2502 -0
- package/lib/builtin/aptos/0x1.js.map +1 -0
- package/lib/builtin/aptos/0x3.d.ts +414 -0
- package/lib/builtin/aptos/0x3.js +461 -0
- package/lib/builtin/aptos/0x3.js.map +1 -0
- package/lib/builtin/internal/eacaggregatorproxy_processor.d.ts +2 -2
- package/lib/builtin/internal/eacaggregatorproxy_processor.js +12 -11
- package/lib/builtin/internal/eacaggregatorproxy_processor.js.map +1 -1
- package/lib/builtin/internal/erc20_processor.d.ts +2 -2
- package/lib/builtin/internal/erc20_processor.js +12 -11
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.d.ts +2 -2
- package/lib/builtin/internal/erc20bytes_processor.js +12 -11
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.d.ts +2 -2
- package/lib/builtin/internal/weth9_processor.js +12 -11
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/builtin/solana/types.d.ts +5 -5
- package/lib/builtin/solana/wormhole-processor.d.ts +6 -6
- package/lib/builtin/solana/wormhole-processor.js +15 -12
- package/lib/builtin/solana/wormhole-processor.js.map +1 -1
- package/lib/cli/build.js +17 -16
- package/lib/cli/build.js.map +1 -1
- package/lib/core/base-processor-template.d.ts +7 -7
- package/lib/core/base-processor-template.js.map +1 -1
- package/lib/core/base-processor.d.ts +5 -6
- package/lib/core/base-processor.js +6 -4
- package/lib/core/base-processor.js.map +1 -1
- package/lib/core/big-decimal.d.ts +1 -0
- package/lib/core/big-decimal.js +6 -0
- package/lib/core/big-decimal.js.map +1 -0
- package/lib/core/bind-options.d.ts +0 -2
- package/lib/core/bind-options.js +4 -4
- package/lib/core/bind-options.js.map +1 -1
- package/lib/core/context.d.ts +14 -11
- package/lib/core/context.js +28 -19
- package/lib/core/context.js.map +1 -1
- package/lib/core/generic-processor.js +5 -5
- package/lib/core/generic-processor.js.map +1 -1
- package/lib/core/index.d.ts +5 -5
- package/lib/core/index.js +6 -6
- package/lib/core/index.js.map +1 -1
- package/lib/core/logger.d.ts +2 -3
- package/lib/core/logger.js +6 -6
- package/lib/core/logger.js.map +1 -1
- package/lib/core/metadata.d.ts +7 -4
- package/lib/core/metadata.js +13 -10
- package/lib/core/metadata.js.map +1 -1
- package/lib/core/meter.d.ts +4 -7
- package/lib/core/meter.js +12 -13
- package/lib/core/meter.js.map +1 -1
- package/lib/core/solana-processor.d.ts +7 -4
- package/lib/core/solana-processor.js +14 -20
- package/lib/core/solana-processor.js.map +1 -1
- package/lib/core/sui-processor.d.ts +5 -4
- package/lib/core/sui-processor.js +10 -17
- package/lib/core/sui-processor.js.map +1 -1
- package/lib/error.d.ts +2 -2
- package/lib/error.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +23 -12
- package/lib/gen/processor/protos/processor.js +129 -57
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -4
- package/lib/index.js.map +1 -1
- package/lib/processor-state.d.ts +1 -1
- package/lib/processor-state.js.map +1 -1
- package/lib/service.js +13 -12
- package/lib/service.js.map +1 -1
- package/lib/target-ethers-sentio/codegen.js +14 -15
- package/lib/target-ethers-sentio/codegen.js.map +1 -1
- package/lib/test-abi-code-gen.js.map +1 -1
- package/lib/testing/metric-utils.js +2 -2
- package/lib/testing/metric-utils.js.map +1 -1
- package/lib/tests/aptos.test.js +95 -2
- package/lib/tests/aptos.test.js.map +1 -1
- package/lib/tests/erc20.js +1 -1
- package/lib/tests/erc20.js.map +1 -1
- package/lib/tests/erc20.test.js +3 -4
- package/lib/tests/erc20.test.js.map +1 -1
- package/lib/tests/solana.test.js +5 -1
- package/lib/tests/solana.test.js.map +1 -1
- package/lib/tests/souffl3.js +17 -4
- package/lib/tests/souffl3.js.map +1 -1
- package/lib/tests/sui.test.js +1 -4
- package/lib/tests/sui.test.js.map +1 -1
- package/lib/tests/types/aptos/souffle.d.ts +311 -22
- package/lib/tests/types/aptos/souffle.js +142 -6
- package/lib/tests/types/aptos/souffle.js.map +1 -1
- package/lib/tests/types/solana/basic_1_processor.d.ts +2 -2
- package/lib/tests/types/solana/basic_1_processor.js +4 -4
- package/lib/tests/types/solana/basic_1_processor.js.map +1 -1
- package/lib/tests/wormhole-token-bridge.js +2 -1
- package/lib/tests/wormhole-token-bridge.js.map +1 -1
- package/lib/utils/chain.d.ts +1 -0
- package/lib/utils/chain.js +15 -1
- package/lib/utils/chain.js.map +1 -1
- package/lib/utils/conversion.d.ts +1 -1
- package/lib/utils/conversion.js.map +1 -1
- package/package.json +3 -2
- package/src/abis/aptos/0x1.json +9205 -0
- package/src/abis/aptos/0x3.json +1515 -0
- package/src/aptos/aptos-processor.ts +88 -20
- package/src/aptos/bind-options.ts +0 -7
- package/src/aptos/context.ts +11 -8
- package/src/aptos/index.ts +3 -2
- package/src/aptos/runtime.ts +13 -0
- package/src/aptos/types.ts +203 -0
- package/src/aptos/utils.ts +18 -0
- package/src/aptos-codegen/codegen.ts +222 -19
- package/src/aptos-codegen/typegen.test.ts +29 -0
- package/src/aptos-codegen/typegen.ts +216 -0
- package/src/binds.ts +5 -39
- package/src/builtin/aptos/0x1.ts +3760 -0
- package/src/builtin/aptos/0x3.ts +798 -0
- package/src/builtin/internal/eacaggregatorproxy_processor.ts +14 -31
- package/src/builtin/internal/erc20_processor.ts +14 -25
- package/src/builtin/internal/erc20bytes_processor.ts +14 -25
- package/src/builtin/internal/weth9_processor.ts +14 -25
- package/src/builtin/solana/wormhole-processor.ts +21 -18
- package/src/cli/build.ts +19 -17
- package/src/core/base-processor-template.ts +7 -7
- package/src/core/base-processor.ts +30 -9
- package/src/core/big-decimal.ts +1 -0
- package/src/core/bind-options.ts +3 -2
- package/src/core/context.ts +40 -24
- package/src/core/generic-processor.ts +6 -7
- package/src/core/index.ts +5 -5
- package/src/core/logger.ts +7 -7
- package/src/core/metadata.ts +14 -12
- package/src/core/meter.ts +12 -14
- package/src/core/solana-processor.ts +24 -21
- package/src/core/sui-processor.ts +10 -21
- package/src/error.ts +2 -2
- package/src/gen/processor/protos/processor.ts +158 -68
- package/src/index.ts +1 -2
- package/src/processor-state.ts +1 -1
- package/src/service.ts +22 -15
- package/src/target-ethers-sentio/codegen.ts +14 -15
- package/src/test-abi-code-gen.ts +1 -0
- package/src/testing/metric-utils.ts +2 -2
- package/src/tests/aptos.test.ts +102 -3
- package/src/tests/erc20.test.ts +3 -4
- package/src/tests/erc20.ts +1 -1
- package/src/tests/solana.test.ts +5 -1
- package/src/tests/souffl3.ts +21 -6
- package/src/tests/sui.test.ts +1 -4
- package/src/tests/types/aptos/souffle.ts +424 -42
- package/src/tests/types/solana/basic_1_processor.ts +6 -6
- package/src/tests/wormhole-token-bridge.ts +2 -1
- package/src/types/global.d.ts +1 -1
- package/src/utils/chain.ts +14 -0
- package/src/utils/conversion.ts +1 -1
- package/lib/contract-namer.d.ts +0 -6
- package/lib/contract-namer.js +0 -20
- package/lib/contract-namer.js.map +0 -1
- package/src/aptos-codegen/codgen.test.ts +0 -11
- package/src/contract-namer.ts +0 -17
@@ -49,18 +49,19 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
49
49
|
.join('\n')}
|
50
50
|
}
|
51
51
|
|
52
|
-
export type ${contract.name}Context =
|
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
|
-
|
58
|
+
if (!options.name) {
|
59
|
+
options.name = "${contract.name}"
|
60
|
+
}
|
61
|
+
let processor = getProcessor(options) as ${contract.name}Processor
|
59
62
|
if (!processor) {
|
60
|
-
|
61
|
-
|
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
|
-
|
107
|
+
if (!options.name) {
|
108
|
+
options.name = "${contract.name}"
|
109
|
+
}
|
110
|
+
let processor = getProcessor(options) as ${contract.name}Processor
|
107
111
|
if (!processor) {
|
108
|
-
|
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
|
-
'
|
170
|
+
'ContractContext',
|
171
171
|
'ContractView',
|
172
172
|
'DummyProvider',
|
173
|
-
'getContractName',
|
174
173
|
'TypedCallTrace',
|
175
174
|
],
|
176
175
|
'./common': ['PromiseOrValue'],
|
package/src/test-abi-code-gen.ts
CHANGED
@@ -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?.
|
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?.
|
44
|
+
if (gauge.metadata?.dataDescriptor?.name === name) {
|
45
45
|
return MetricValueToNumber(gauge.metricValue)
|
46
46
|
}
|
47
47
|
}
|
package/src/tests/aptos.test.ts
CHANGED
@@ -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(
|
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
|
+
}
|
package/src/tests/erc20.test.ts
CHANGED
@@ -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('
|
26
|
-
|
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')
|
package/src/tests/erc20.ts
CHANGED
@@ -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) {
|
package/src/tests/solana.test.ts
CHANGED
@@ -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(
|
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
|
}
|
package/src/tests/souffl3.ts
CHANGED
@@ -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
|
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(
|
8
|
+
ctx.meter.Counter('pulled').add(call.arguments_typed[3])
|
7
9
|
})
|
8
|
-
.
|
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
|
30
|
-
ctx.meter.Counter('pulled').add(
|
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
|
})
|
package/src/tests/sui.test.ts
CHANGED
@@ -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
|
-
|
14
|
-
options.name = 'TicTacToe'
|
15
|
-
}
|
16
|
-
return new TicTacToeProcessor(options)
|
13
|
+
return new TicTacToeProcessor('TicTacToe', options)
|
17
14
|
}
|
18
15
|
}
|
19
16
|
|