@sentio/sdk 1.27.3 → 1.27.4
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/processor-runner.js +2 -2
- package/lib/processor-runner.js.map +1 -1
- package/package.json +4 -4
- package/src/processor-runner.ts +2 -2
- package/lib/aptos/types.test.js +0 -19
- package/lib/core/generic-processor.test.js +0 -58
- package/lib/core/meter.test.js +0 -21
- package/lib/core/numberish.test.js +0 -70
- package/lib/tests/aptos.test.d.ts +0 -1
- package/lib/tests/aptos.test.js +0 -379
- package/lib/tests/aptos.test.js.map +0 -1
- package/lib/tests/codegen.test.d.ts +0 -1
- package/lib/tests/codegen.test.js +0 -49
- package/lib/tests/codegen.test.js.map +0 -1
- package/lib/tests/erc20-template.test.d.ts +0 -1
- package/lib/tests/erc20-template.test.js +0 -56
- package/lib/tests/erc20-template.test.js.map +0 -1
- package/lib/tests/erc20.d.ts +0 -1
- package/lib/tests/erc20.js +0 -54
- package/lib/tests/erc20.js.map +0 -1
- package/lib/tests/erc20.test.d.ts +0 -1
- package/lib/tests/erc20.test.js +0 -94
- package/lib/tests/erc20.test.js.map +0 -1
- package/lib/tests/error-capture.test.d.ts +0 -1
- package/lib/tests/error-capture.test.js +0 -76
- package/lib/tests/error-capture.test.js.map +0 -1
- package/lib/tests/logger.test.d.ts +0 -1
- package/lib/tests/logger.test.js +0 -40
- package/lib/tests/logger.test.js.map +0 -1
- package/lib/tests/solana.test.d.ts +0 -1
- package/lib/tests/solana.test.js +0 -77
- package/lib/tests/solana.test.js.map +0 -1
- package/lib/tests/souffl3.d.ts +0 -1
- package/lib/tests/souffl3.js +0 -49
- package/lib/tests/souffl3.js.map +0 -1
- package/lib/tests/sui.test.d.ts +0 -1
- package/lib/tests/sui.test.js +0 -193
- package/lib/tests/sui.test.js.map +0 -1
- package/lib/tests/types/aptos/soffl3.d.ts +0 -786
- package/lib/tests/types/aptos/soffl3.js +0 -559
- package/lib/tests/types/aptos/soffl3.js.map +0 -1
- package/lib/tests/types/aptos/souffle.d.ts +0 -348
- package/lib/tests/types/aptos/souffle.js +0 -303
- package/lib/tests/types/aptos/souffle.js.map +0 -1
- package/lib/tests/types/solana/basic_1.d.ts +0 -26
- package/lib/tests/types/solana/basic_1.js +0 -66
- package/lib/tests/types/solana/basic_1.js.map +0 -1
- package/lib/tests/types/solana/basic_1_processor.d.ts +0 -13
- package/lib/tests/types/solana/basic_1_processor.js +0 -41
- package/lib/tests/types/solana/basic_1_processor.js.map +0 -1
- package/lib/tests/wormhole-token-bridge.d.ts +0 -1
- package/lib/tests/wormhole-token-bridge.js +0 -22
- package/lib/tests/wormhole-token-bridge.js.map +0 -1
- package/lib/utils/dex-price.test.js +0 -22
- package/lib/utils/erc20.test.js +0 -23
- package/src/aptos/types.test.ts +0 -18
- package/src/aptos-codegen/typegen.test.ts +0 -44
- package/src/core/generic-processor.test.ts +0 -69
- package/src/core/meter.test.ts +0 -23
- package/src/core/numberish.test.ts +0 -82
- package/src/tests/abis/aptos/soffl3.json +0 -1411
- package/src/tests/abis/aptos/souffle.json +0 -389
- package/src/tests/abis/evm/CommitmentPool.json +0 -1034
- package/src/tests/abis/evm/Seaport.json +0 -2595
- package/src/tests/abis/evm/anyswapRouter.json +0 -490
- package/src/tests/abis/solana/basic_1.json +0 -62
- package/src/tests/aptos.test.ts +0 -402
- package/src/tests/codegen.test.ts +0 -29
- package/src/tests/erc20-template.test.ts +0 -60
- package/src/tests/erc20.test.ts +0 -115
- package/src/tests/erc20.ts +0 -60
- package/src/tests/error-capture.test.ts +0 -82
- package/src/tests/logger.test.ts +0 -46
- package/src/tests/solana.test.ts +0 -79
- package/src/tests/souffl3.ts +0 -56
- package/src/tests/sui.test.ts +0 -197
- package/src/tests/types/aptos/soffl3.ts +0 -1377
- package/src/tests/types/aptos/souffle.ts +0 -698
- package/src/tests/types/solana/basic_1.ts +0 -62
- package/src/tests/types/solana/basic_1_processor.ts +0 -41
- package/src/tests/wormhole-token-bridge.ts +0 -21
- package/src/types/global.d.ts +0 -5
- package/src/utils/dex-price.test.ts +0 -25
- package/src/utils/erc20.test.ts +0 -26
- package/templates/aptos/.gitignore +0 -107
- package/templates/aptos/src/processor.test.ts +0 -14
- package/templates/evm/.gitignore +0 -107
- package/templates/evm/src/processor.test.ts +0 -29
- package/templates/raw/.gitignore +0 -107
- package/templates/raw/src/processor.test.ts +0 -14
package/src/tests/aptos.test.ts
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai'
|
|
2
|
-
import { TextEncoder } from 'util'
|
|
3
|
-
import { HandlerType, ProcessBindingsRequest } from '..'
|
|
4
|
-
|
|
5
|
-
import { firstCounterValue, firstGaugeValue, TestProcessorServer } from '../testing'
|
|
6
|
-
|
|
7
|
-
describe('Test Aptos Example', () => {
|
|
8
|
-
const service = new TestProcessorServer(() => {
|
|
9
|
-
require('./souffl3')
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
beforeAll(async () => {
|
|
13
|
-
await service.start({ templateInstances: [] })
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
test('check configuration ', async () => {
|
|
17
|
-
const config = await service.getConfig({})
|
|
18
|
-
expect(config.contractConfigs).length(5)
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test('Check souffl3 transaction dispatch', async () => {
|
|
22
|
-
const request: ProcessBindingsRequest = {
|
|
23
|
-
bindings: [
|
|
24
|
-
{
|
|
25
|
-
data: {
|
|
26
|
-
raw: new TextEncoder().encode(JSON.stringify(testData)),
|
|
27
|
-
},
|
|
28
|
-
handlerId: 1,
|
|
29
|
-
handlerType: HandlerType.APT_CALL,
|
|
30
|
-
},
|
|
31
|
-
],
|
|
32
|
-
}
|
|
33
|
-
const res = await service.processBindings(request)
|
|
34
|
-
expect(res.result?.counters).length(1)
|
|
35
|
-
expect(res.result?.gauges).length(0)
|
|
36
|
-
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034)
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
test('Check souffl3 function call dispatch', async () => {
|
|
40
|
-
const request: ProcessBindingsRequest = {
|
|
41
|
-
bindings: [
|
|
42
|
-
{
|
|
43
|
-
data: {
|
|
44
|
-
raw: new TextEncoder().encode(JSON.stringify(testData)),
|
|
45
|
-
},
|
|
46
|
-
handlerId: 0,
|
|
47
|
-
handlerType: HandlerType.APT_CALL,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}
|
|
51
|
-
const res = await service.processBindings(request)
|
|
52
|
-
expect(res.result?.counters).length(2)
|
|
53
|
-
expect(res.result?.gauges).length(0)
|
|
54
|
-
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034)
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
test('Check souffl3 event dispatch', async () => {
|
|
58
|
-
const request: ProcessBindingsRequest = {
|
|
59
|
-
bindings: [
|
|
60
|
-
{
|
|
61
|
-
data: {
|
|
62
|
-
raw: new TextEncoder().encode(
|
|
63
|
-
JSON.stringify({
|
|
64
|
-
...testData,
|
|
65
|
-
events: [testData.events[testData.events.length - 1]],
|
|
66
|
-
})
|
|
67
|
-
),
|
|
68
|
-
},
|
|
69
|
-
handlerId: 0,
|
|
70
|
-
handlerType: HandlerType.APT_EVENT,
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
}
|
|
74
|
-
const res = await service.processBindings(request)
|
|
75
|
-
expect(res.result?.counters).length(1)
|
|
76
|
-
expect(res.result?.gauges).length(0)
|
|
77
|
-
expect(res.result?.counters[0].metadata?.blockNumber.toInt()).equal(18483034)
|
|
78
|
-
expect(res.result?.events).length(1)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test('Check token deposit event dispatch', async () => {
|
|
82
|
-
const request: ProcessBindingsRequest = {
|
|
83
|
-
bindings: [
|
|
84
|
-
{
|
|
85
|
-
data: {
|
|
86
|
-
raw: new TextEncoder().encode(
|
|
87
|
-
JSON.stringify({
|
|
88
|
-
...testData,
|
|
89
|
-
events: [tokenTestData],
|
|
90
|
-
})
|
|
91
|
-
),
|
|
92
|
-
},
|
|
93
|
-
handlerId: 2,
|
|
94
|
-
handlerType: HandlerType.APT_EVENT,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
}
|
|
98
|
-
const res = await service.processBindings(request)
|
|
99
|
-
expect(firstCounterValue(res.result, 'deposit')).equal(1n)
|
|
100
|
-
expect(firstGaugeValue(res.result, 'version')).equal(0n)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('Check create poposal event dispatch', async () => {
|
|
104
|
-
const request: ProcessBindingsRequest = {
|
|
105
|
-
bindings: [
|
|
106
|
-
{
|
|
107
|
-
data: {
|
|
108
|
-
raw: new TextEncoder().encode(JSON.stringify({ ...testData, events: [createProposalData] })),
|
|
109
|
-
},
|
|
110
|
-
handlerId: 3,
|
|
111
|
-
handlerType: HandlerType.APT_EVENT,
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
}
|
|
115
|
-
const res = await service.processBindings(request)
|
|
116
|
-
expect(firstGaugeValue(res.result, 'size')).equal(2n)
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
test('check on timer', async () => {
|
|
120
|
-
const request: ProcessBindingsRequest = {
|
|
121
|
-
bindings: [
|
|
122
|
-
{
|
|
123
|
-
data: {
|
|
124
|
-
raw: new TextEncoder().encode(
|
|
125
|
-
JSON.stringify({
|
|
126
|
-
version: '12345',
|
|
127
|
-
resources: [
|
|
128
|
-
{
|
|
129
|
-
type: '0x1::coin::SupplyConfig',
|
|
130
|
-
data: {
|
|
131
|
-
allow_upgrades: false,
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
})
|
|
136
|
-
),
|
|
137
|
-
},
|
|
138
|
-
handlerId: 0,
|
|
139
|
-
handlerType: HandlerType.APT_RESOURCE,
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
}
|
|
143
|
-
const res = await service.processBindings(request)
|
|
144
|
-
expect(firstCounterValue(res.result, 'onTimer')).equal(1n)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
test('Check aptos account transaction dispatch', async () => {
|
|
148
|
-
const request: ProcessBindingsRequest = {
|
|
149
|
-
bindings: [
|
|
150
|
-
{
|
|
151
|
-
data: {
|
|
152
|
-
raw: new TextEncoder().encode(JSON.stringify(dataCreate)),
|
|
153
|
-
},
|
|
154
|
-
handlerId: 3,
|
|
155
|
-
handlerType: HandlerType.APT_CALL,
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
}
|
|
159
|
-
const res = await service.processBindings(request)
|
|
160
|
-
expect(res.result?.counters).length(1)
|
|
161
|
-
})
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
const testData = {
|
|
165
|
-
version: '18483034',
|
|
166
|
-
hash: '0xbf4df6f390546a793ba9b7caff120002b3257986dbea9c697fd64acf7dfeb052',
|
|
167
|
-
state_change_hash: '0x6063039cca5a1eb33d3986d3665fc783238579961eaa4746c41e25fa4f72aac6',
|
|
168
|
-
event_root_hash: '0x425e39bcf994672108f83c34f637e84166af7ecedcbe26aed0dff0d62da8055d',
|
|
169
|
-
state_checkpoint_hash: null,
|
|
170
|
-
gas_used: '854',
|
|
171
|
-
success: true,
|
|
172
|
-
vm_status: 'Executed successfully',
|
|
173
|
-
accumulator_root_hash: '0x47aa479d9e15993ea2abe04043c89186fb5da0b5eb8b5c6d18bd55d5f0c2c877',
|
|
174
|
-
changes: [],
|
|
175
|
-
sender: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
176
|
-
sequence_number: '30',
|
|
177
|
-
max_gas_amount: '20000',
|
|
178
|
-
gas_unit_price: '1',
|
|
179
|
-
expiration_timestamp_secs: '1663144544',
|
|
180
|
-
payload: {
|
|
181
|
-
function: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::pull_token_v2',
|
|
182
|
-
type_arguments: ['0x1::aptos_coin::AptosCoin'],
|
|
183
|
-
arguments: [
|
|
184
|
-
'0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
185
|
-
'0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
186
|
-
'Souffl3 BlueBerry',
|
|
187
|
-
'1',
|
|
188
|
-
],
|
|
189
|
-
type: 'entry_function_payload',
|
|
190
|
-
},
|
|
191
|
-
signature: {
|
|
192
|
-
public_key: '0x6c3f579afbf8a728827385039f7604ec1d06e5c802d8f9689ee8ec9d349fedc5',
|
|
193
|
-
signature:
|
|
194
|
-
'0xd2db95052e774f095d924030a50c29325a17e8d69d35c748f45bb0e22eb7d3b9e47545c98bd7130fd3ef46cbedc30c9aaeaf39c2d922ee8e7d578c0b1e76f30b',
|
|
195
|
-
type: 'ed25519_signature',
|
|
196
|
-
},
|
|
197
|
-
events: [
|
|
198
|
-
{
|
|
199
|
-
guid: {
|
|
200
|
-
creation_number: '3',
|
|
201
|
-
account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
202
|
-
},
|
|
203
|
-
sequence_number: '10',
|
|
204
|
-
type: '0x1::coin::WithdrawEvent',
|
|
205
|
-
data: {
|
|
206
|
-
amount: '1',
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
version: '18483034',
|
|
211
|
-
guid: {
|
|
212
|
-
creation_number: '2',
|
|
213
|
-
account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
214
|
-
},
|
|
215
|
-
sequence_number: '11',
|
|
216
|
-
type: '0x1::coin::DepositEvent',
|
|
217
|
-
data: {
|
|
218
|
-
amount: '1',
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
guid: {
|
|
223
|
-
creation_number: '9',
|
|
224
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
|
225
|
-
},
|
|
226
|
-
sequence_number: '9',
|
|
227
|
-
type: '0x3::token::CreateTokenDataEvent',
|
|
228
|
-
data: {
|
|
229
|
-
description:
|
|
230
|
-
'Souffl3 offers a one-stop marketplace for the launch, listing, and trading of NFT assets on APTOS.\nWebsite:https://souffl3.com/\nEveryone can win through our Bake Off campaign on the Aptos Testnet, rewards including Souffl3 Genesis NFT and whitelists of other collab projects, everyone is welcome to participate!',
|
|
231
|
-
id: {
|
|
232
|
-
collection: 'Souffl3 BlueBerry',
|
|
233
|
-
creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
|
234
|
-
name: 'Souffl3 BlueBerry #2',
|
|
235
|
-
},
|
|
236
|
-
maximum: '999999999999',
|
|
237
|
-
mutability_config: {
|
|
238
|
-
description: true,
|
|
239
|
-
maximum: true,
|
|
240
|
-
properties: true,
|
|
241
|
-
royalty: true,
|
|
242
|
-
uri: true,
|
|
243
|
-
},
|
|
244
|
-
name: 'Souffl3 BlueBerry #2',
|
|
245
|
-
property_keys: ['author', 'point'],
|
|
246
|
-
property_types: ['string', 'integer'],
|
|
247
|
-
property_values: ['0x33454e4a4f59204c616273', '0x30'],
|
|
248
|
-
royalty_payee_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
|
249
|
-
royalty_points_denominator: '100',
|
|
250
|
-
royalty_points_numerator: '20',
|
|
251
|
-
uri: 'https://y3x4txhvirx5zl57efzbl6dg7psaier5q35hhwuqwzjwuahrycya.arweave.net/xu_J3PVEb9yvvyFyFfhm--QEEj2G-nPakLZTagDxwLA',
|
|
252
|
-
},
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
guid: {
|
|
256
|
-
creation_number: '2',
|
|
257
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
|
258
|
-
},
|
|
259
|
-
sequence_number: '27',
|
|
260
|
-
type: '0x3::token::DepositEvent',
|
|
261
|
-
data: {
|
|
262
|
-
amount: '1',
|
|
263
|
-
id: {
|
|
264
|
-
property_version: '0',
|
|
265
|
-
token_data_id: {
|
|
266
|
-
collection: 'Souffl3 BlueBerry',
|
|
267
|
-
creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
|
268
|
-
name: 'Souffl3 BlueBerry #2',
|
|
269
|
-
},
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
version: '18483034',
|
|
275
|
-
guid: {
|
|
276
|
-
creation_number: '7',
|
|
277
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
|
278
|
-
},
|
|
279
|
-
sequence_number: '980533',
|
|
280
|
-
type: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::PullTokenEvent<0x1::aptos_coin::AptosCoin>',
|
|
281
|
-
data: {
|
|
282
|
-
receiver: '0x3a80be5daa84f2da7e07b3ec9234da48a5647f757187879c97a1fa03f31f1195',
|
|
283
|
-
},
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
timestamp: '1663143945131218',
|
|
287
|
-
type: 'user_transaction',
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const tokenTestData = {
|
|
291
|
-
guid: {
|
|
292
|
-
creation_number: '4',
|
|
293
|
-
account_address: '0x89bc80de59187f707a59ae7a4121718dafe3e6068e0509104ef7e41a56bc97db',
|
|
294
|
-
},
|
|
295
|
-
sequence_number: '10',
|
|
296
|
-
type: '0x3::token::DepositEvent',
|
|
297
|
-
data: {
|
|
298
|
-
amount: '1',
|
|
299
|
-
id: {
|
|
300
|
-
property_version: '0',
|
|
301
|
-
token_data_id: {
|
|
302
|
-
collection: 'Topaz Troopers',
|
|
303
|
-
creator: '0x9125e4054d884fdc7296b66e12c0d63a7baa0d88c77e8e784987c0a967c670ac',
|
|
304
|
-
name: 'Topaz Trooper #11293',
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
},
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
const createProposalData = {
|
|
311
|
-
guid: {
|
|
312
|
-
creation_number: '5',
|
|
313
|
-
account_address: '0x1',
|
|
314
|
-
},
|
|
315
|
-
sequence_number: '3',
|
|
316
|
-
type: '0x1::voting::CreateProposalEvent',
|
|
317
|
-
data: {
|
|
318
|
-
early_resolution_vote_threshold: {
|
|
319
|
-
vec: ['9272156337856446330'],
|
|
320
|
-
},
|
|
321
|
-
execution_hash: '0x31549239ce8abdc1e9c259178614c3d44d015bd6d48635ddcfbfa4a77e7222b0',
|
|
322
|
-
expiration_secs: '1665463839',
|
|
323
|
-
metadata: {
|
|
324
|
-
data: [
|
|
325
|
-
{
|
|
326
|
-
key: 'metadata_hash',
|
|
327
|
-
value:
|
|
328
|
-
'0x61633230656566373063616466363939663530353564323463356363353931396463306330656562643463303662653332346336323030313561633361653066',
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
key: 'metadata_location',
|
|
332
|
-
value:
|
|
333
|
-
'0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6d6f76656b6576696e2f30353766623134356234303836366566663863323263393166623964613931392f7261772f626162383566306637343334663030386138373831656563376663616464316163356135353438312f6769737466696c65312e747874',
|
|
334
|
-
},
|
|
335
|
-
],
|
|
336
|
-
},
|
|
337
|
-
min_vote_threshold: '100000000000000',
|
|
338
|
-
proposal_id: '3',
|
|
339
|
-
},
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
const dataCreate = {
|
|
343
|
-
id: '',
|
|
344
|
-
round: '',
|
|
345
|
-
previous_block_votes: null,
|
|
346
|
-
proposer: '',
|
|
347
|
-
sender: '0x88252db4dc2484cd9cedb23cd67b7b91f88940142f3eea35df7a9168d9c30896',
|
|
348
|
-
sequence_number: '1510',
|
|
349
|
-
payload: {
|
|
350
|
-
type: 'entry_function_payload',
|
|
351
|
-
type_arguments: [],
|
|
352
|
-
arguments: ['0xd582e092190feda35a2f737123f86e33a1b592596804f40b1d539ab603a82a24'],
|
|
353
|
-
code: { bytecode: '' },
|
|
354
|
-
function: '0x1::aptos_account::create_account',
|
|
355
|
-
},
|
|
356
|
-
max_gas_amount: '2000',
|
|
357
|
-
gas_unit_price: '100',
|
|
358
|
-
expiration_timestamp_secs: '1666174748',
|
|
359
|
-
secondary_signers: null,
|
|
360
|
-
signature: {
|
|
361
|
-
type: 'ed25519_signature',
|
|
362
|
-
public_key: '0xfe1e11c6cb912ae998c9512d21e5781abb64fd4b8d6cfa15aeba3ee481406b64',
|
|
363
|
-
signature:
|
|
364
|
-
'0x98a49f348a3015702e3be33c1d2a92ea7b2726d31b27c857980493fe68cadc83fbef0839e312d6a82a9e6ca69481245fa49b6f25c0ec51660615d03e05738c03',
|
|
365
|
-
public_keys: null,
|
|
366
|
-
signatures: null,
|
|
367
|
-
threshold: 0,
|
|
368
|
-
bitmap: '',
|
|
369
|
-
sender: { type: '', public_key: '', signature: '', public_keys: null, signatures: null, threshold: 0, bitmap: '' },
|
|
370
|
-
secondary_signer_addresses: null,
|
|
371
|
-
secondary_signers: null,
|
|
372
|
-
},
|
|
373
|
-
type: 'user_transaction',
|
|
374
|
-
timestamp: '1666174688494614',
|
|
375
|
-
events: [
|
|
376
|
-
{
|
|
377
|
-
version: '3121410',
|
|
378
|
-
guid: {
|
|
379
|
-
creation_number: '0',
|
|
380
|
-
account_address: '0xd582e092190feda35a2f737123f86e33a1b592596804f40b1d539ab603a82a24',
|
|
381
|
-
},
|
|
382
|
-
sequence_number: '0',
|
|
383
|
-
type: '0x1::account::CoinRegisterEvent',
|
|
384
|
-
data: {
|
|
385
|
-
type_info: {
|
|
386
|
-
account_address: '0x1',
|
|
387
|
-
module_name: '0x6170746f735f636f696e',
|
|
388
|
-
struct_name: '0x4170746f73436f696e',
|
|
389
|
-
},
|
|
390
|
-
},
|
|
391
|
-
},
|
|
392
|
-
],
|
|
393
|
-
version: '3121410',
|
|
394
|
-
hash: '0xcae7d97c9f43d90e247a366688905bc8e83ee0ad4baddbf3cc2fdda56e4d6926',
|
|
395
|
-
state_root_hash: '',
|
|
396
|
-
event_root_hash: '0xfa557e3bb8dff8fd3321f9a4eaa779311c9c795728355686b487b5b0adf7ce3c',
|
|
397
|
-
gas_used: '1538',
|
|
398
|
-
success: true,
|
|
399
|
-
vm_status: 'Executed successfully',
|
|
400
|
-
accumulator_root_hash: '0x7563d6ed58b011e512d53cce2bc1a70716fc6362e12fb6af8fe6d459ae71dffc',
|
|
401
|
-
changes: null,
|
|
402
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { codeGenEthersProcessor } from '../cli/build'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import * as fs from 'fs'
|
|
4
|
-
import os from 'os'
|
|
5
|
-
|
|
6
|
-
describe('Test EVM codegen', () => {
|
|
7
|
-
const codeGenFolder = fs.mkdtempSync(path.join(os.tmpdir(), 'codegen_test'))
|
|
8
|
-
|
|
9
|
-
jest.setTimeout(20000)
|
|
10
|
-
|
|
11
|
-
// TODO make sure code could be compile
|
|
12
|
-
test('code gen for evm', async () => {
|
|
13
|
-
console.log('source code generated to ' + codeGenFolder)
|
|
14
|
-
|
|
15
|
-
await codeGenEthersProcessor(
|
|
16
|
-
path.join(__dirname, 'abis/evm'),
|
|
17
|
-
'lib/target-ethers-sentio',
|
|
18
|
-
`${codeGenFolder}/internal`
|
|
19
|
-
)
|
|
20
|
-
expect(fs.existsSync(codeGenFolder)).toEqual(true)
|
|
21
|
-
expect(fs.readdirSync(codeGenFolder).length).toEqual(4)
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
// afterAll(() => {
|
|
25
|
-
// if (fs.existsSync(codeGenFolder)) {
|
|
26
|
-
// fs.rmSync(codeGenFolder, { recursive: true, force: true })
|
|
27
|
-
// }
|
|
28
|
-
// })
|
|
29
|
-
})
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { expect } from 'chai'
|
|
2
|
-
|
|
3
|
-
import { StartRequest } from '..'
|
|
4
|
-
import Long from 'long'
|
|
5
|
-
import { TestProcessorServer } from '../testing'
|
|
6
|
-
import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/internal/erc20_processor'
|
|
7
|
-
|
|
8
|
-
describe('Test Template', () => {
|
|
9
|
-
const service = new TestProcessorServer(() => {
|
|
10
|
-
const filter = ERC20Processor.filters.Transfer(
|
|
11
|
-
'0x0000000000000000000000000000000000000000',
|
|
12
|
-
'0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
|
|
13
|
-
)
|
|
14
|
-
|
|
15
|
-
const processorTemplate = new ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {
|
|
16
|
-
console.log('')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
ERC20Processor.bind({
|
|
20
|
-
address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
|
|
21
|
-
network: 1,
|
|
22
|
-
name: 'x2y2',
|
|
23
|
-
startBlock: 14201940,
|
|
24
|
-
}).onEventTransfer(async function (event, ctx) {
|
|
25
|
-
processorTemplate.bind({
|
|
26
|
-
address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
27
|
-
network: 3,
|
|
28
|
-
name: 'dynamic',
|
|
29
|
-
})
|
|
30
|
-
// template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')
|
|
31
|
-
ctx.meter.Counter('c1').add(1)
|
|
32
|
-
}, filter)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
beforeAll(async () => {
|
|
36
|
-
const request: StartRequest = {
|
|
37
|
-
templateInstances: [
|
|
38
|
-
{
|
|
39
|
-
contract: {
|
|
40
|
-
address: 'dynamic2',
|
|
41
|
-
name: 'dynamic2',
|
|
42
|
-
chainId: '1',
|
|
43
|
-
abi: '',
|
|
44
|
-
},
|
|
45
|
-
startBlock: Long.ZERO,
|
|
46
|
-
endBlock: Long.ZERO,
|
|
47
|
-
templateId: 0,
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}
|
|
51
|
-
await service.start(request)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('Check template instantiate', async () => {
|
|
55
|
-
const config = await service.getConfig({})
|
|
56
|
-
expect(config.contractConfigs).length(2)
|
|
57
|
-
expect(config.contractConfigs?.[1].contract?.name).equals('dynamic2')
|
|
58
|
-
expect(config.templateInstances).length(1)
|
|
59
|
-
})
|
|
60
|
-
})
|
package/src/tests/erc20.test.ts
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// TODO move out of this package
|
|
2
|
-
|
|
3
|
-
import { expect } from 'chai'
|
|
4
|
-
|
|
5
|
-
import { HandlerType } from '..'
|
|
6
|
-
|
|
7
|
-
import { TestProcessorServer, firstCounterValue, firstGaugeValue } from '../testing'
|
|
8
|
-
import { BigNumber } from 'ethers'
|
|
9
|
-
import { mockTransferLog } from '../builtin/erc20/test-utils'
|
|
10
|
-
import { Trace } from '@sentio/sdk'
|
|
11
|
-
|
|
12
|
-
describe('Test Basic Examples', () => {
|
|
13
|
-
const service = new TestProcessorServer(() => require('./erc20'))
|
|
14
|
-
|
|
15
|
-
beforeAll(async () => {
|
|
16
|
-
await service.start()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test('check configuration', async () => {
|
|
20
|
-
const config = await service.getConfig({})
|
|
21
|
-
expect(config.contractConfigs).length(5)
|
|
22
|
-
|
|
23
|
-
expect(config.contractConfigs?.[2].contract?.name).equals('ERC20')
|
|
24
|
-
expect(config.contractConfigs?.[3].contract?.name).equals('ERC20')
|
|
25
|
-
expect(config.contractConfigs?.[4].contract?.name).equals('ytoken')
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
test('Check block dispatch', async () => {
|
|
29
|
-
const res = (await service.testBlock(blockData)).result
|
|
30
|
-
expect(res?.counters).length(0)
|
|
31
|
-
expect(res?.gauges).length(1)
|
|
32
|
-
expect(firstGaugeValue(res, 'g1')).equals(10n)
|
|
33
|
-
expect(res?.gauges[0].metadata?.contractName).equals('x2y2')
|
|
34
|
-
|
|
35
|
-
const gauge = res?.gauges?.[0]
|
|
36
|
-
expect(gauge?.metadata?.blockNumber?.toString()).equals('14373295')
|
|
37
|
-
expect(gauge?.runtimeInfo?.from).equals(HandlerType.BLOCK)
|
|
38
|
-
|
|
39
|
-
const res2 = (await service.testBlock(blockData, 56)).result
|
|
40
|
-
expect(res2?.counters).length(0)
|
|
41
|
-
expect(res2?.gauges).length(1)
|
|
42
|
-
expect(firstGaugeValue(res2, 'g2')).equals(20n)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('Check log dispatch', async () => {
|
|
46
|
-
const logData = mockTransferLog('0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9', {
|
|
47
|
-
from: '0x0000000000000000000000000000000000000000',
|
|
48
|
-
to: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1',
|
|
49
|
-
value: BigNumber.from('0x9a71db64810aaa0000'),
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
let res = await service.testLog(logData)
|
|
53
|
-
|
|
54
|
-
const counters = res.result?.counters
|
|
55
|
-
expect(counters).length(1)
|
|
56
|
-
expect(firstCounterValue(res.result, 'c1')).equals(1n)
|
|
57
|
-
|
|
58
|
-
expect(counters?.[0].metadata?.chainId).equals('1')
|
|
59
|
-
expect(counters?.[0].runtimeInfo?.from).equals(HandlerType.ETH_LOG)
|
|
60
|
-
expect(res.configUpdated).equals(true)
|
|
61
|
-
|
|
62
|
-
const logData2 = Object.assign({}, logData)
|
|
63
|
-
logData2.address = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
|
|
64
|
-
res = await service.testLog(logData2, 56)
|
|
65
|
-
|
|
66
|
-
expect(firstCounterValue(res.result, 'c2')).equals(2n)
|
|
67
|
-
expect(res.result?.counters[0].metadata?.chainId).equals('56')
|
|
68
|
-
|
|
69
|
-
expect(res.result?.gauges).length(0)
|
|
70
|
-
|
|
71
|
-
const config = await service.getConfig({})
|
|
72
|
-
expect(config.contractConfigs).length(6) //config increased
|
|
73
|
-
expect(config.contractConfigs?.[5].contract?.name).equals('dynamic')
|
|
74
|
-
|
|
75
|
-
// repeat trigger won't bind again
|
|
76
|
-
await service.testLogs([logData])
|
|
77
|
-
const config2 = await service.getConfig({})
|
|
78
|
-
expect(config).deep.equals(config2)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const blockData = {
|
|
82
|
-
hash: '0x2b9b7cce1f17f3b7e1f3c2472cc806a07bee3f0baca07d021350950d81d73a42',
|
|
83
|
-
number: 14373295,
|
|
84
|
-
timestamp: 1647106437,
|
|
85
|
-
extraData: '0xe4b883e5bda9e7a59ee4bb99e9b1bc493421',
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
test('Check trace dispatch', async () => {
|
|
89
|
-
const res = (await service.testTrace(traceData)).result
|
|
90
|
-
expect(res?.counters).length(1)
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
const traceData: Trace = {
|
|
94
|
-
action: {
|
|
95
|
-
from: '0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91',
|
|
96
|
-
callType: 'call',
|
|
97
|
-
gas: 0xbb0a,
|
|
98
|
-
input:
|
|
99
|
-
'0x095ea7b30000000000000000000000003eabf546fff0a41edaaf5b667333a846285713180000000000000000000000000000000000000000000000000000002a03956d85',
|
|
100
|
-
to: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9',
|
|
101
|
-
value: 0x0,
|
|
102
|
-
},
|
|
103
|
-
blockHash: '0xb1fe1fefca4063ab9cc06a10356a6dd397b8c3dd38e21470e107a711ad559c13',
|
|
104
|
-
blockNumber: 15548801,
|
|
105
|
-
result: {
|
|
106
|
-
gasUsed: 0x95df,
|
|
107
|
-
output: '0x0000000000000000000000000000000000000000000000000000000000000001',
|
|
108
|
-
},
|
|
109
|
-
subtraces: 1,
|
|
110
|
-
traceAddress: [],
|
|
111
|
-
transactionHash: '0xc05c37b34e13380d0b7e0475b27a0c77fda826f82c603f9c45922e952d63b7a5',
|
|
112
|
-
transactionPosition: 69,
|
|
113
|
-
type: 'call',
|
|
114
|
-
}
|
|
115
|
-
})
|
package/src/tests/erc20.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'
|
|
2
|
-
import { EventTracker } from '../core/event-tracker'
|
|
3
|
-
import { Exporter } from '../core/exporter'
|
|
4
|
-
|
|
5
|
-
export const filter = ERC20Processor.filters.Transfer(
|
|
6
|
-
'0x0000000000000000000000000000000000000000',
|
|
7
|
-
'0xb329e39ebefd16f40d38f07643652ce17ca5bac1'
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
const tracker = EventTracker.register('sdf')
|
|
11
|
-
const exporter = Exporter.register('transfer', 'xxx')
|
|
12
|
-
|
|
13
|
-
const processorTemplate = new ERC20ProcessorTemplate().onEventTransfer(async function (event, ctx) {
|
|
14
|
-
console.log('')
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
ERC20Processor.bind({
|
|
18
|
-
address: '0x1e4ede388cbc9f4b5c79681b7f94d36a11abebc9',
|
|
19
|
-
// network: 1,
|
|
20
|
-
name: 'x2y2',
|
|
21
|
-
startBlock: 14201940,
|
|
22
|
-
})
|
|
23
|
-
.onEventTransfer(async function (event, ctx) {
|
|
24
|
-
processorTemplate.bind({ address: '0x1E4EDE388cbc9F4b5c79681B7f94d36a11ABEBC9', network: 3, name: 'dynamic' })
|
|
25
|
-
// template.bind('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 3, 'dynamic')
|
|
26
|
-
ctx.meter.Counter('c1').add(1)
|
|
27
|
-
}, filter)
|
|
28
|
-
.onBlock(async function (block, ctx) {
|
|
29
|
-
ctx.meter.Gauge('g1').record(10, { k: 'v' })
|
|
30
|
-
})
|
|
31
|
-
.onCallApprove(function (call, ctx) {
|
|
32
|
-
ctx.meter.Counter('added').add(call.args.amount, { spender: call.args.spender })
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
ERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', network: 56, name: 'usdc' })
|
|
36
|
-
.onEventTransfer(async function (event, ctx) {
|
|
37
|
-
ctx.meter.Counter('c2').add(2)
|
|
38
|
-
tracker.trackEvent(ctx, { distinctId: event.args.from })
|
|
39
|
-
exporter.emit(ctx, event)
|
|
40
|
-
}, filter)
|
|
41
|
-
.onBlock(async function (block, ctx) {
|
|
42
|
-
ctx.meter.Gauge('g2').record(20, { k: 'v' })
|
|
43
|
-
})
|
|
44
|
-
// .onEventApproval(async function (event, ctx) {
|
|
45
|
-
// BigNumber.from(10 ** 18)
|
|
46
|
-
// // console.log(n)
|
|
47
|
-
// })
|
|
48
|
-
ERC20Processor.bind({ address: 'xxxx', network: 56 })
|
|
49
|
-
|
|
50
|
-
ERC20Processor.bind({ address: 'yyyy', network: 1 })
|
|
51
|
-
ERC20Processor.bind({ address: 'yyyy', network: 1 })
|
|
52
|
-
ERC20Processor.bind({ address: 'yyyy', network: 1, startBlock: 21, name: 'ytoken' })
|
|
53
|
-
|
|
54
|
-
// const template = Erc20Processor.template
|
|
55
|
-
// .onTransfer(async function (event, ctx) {
|
|
56
|
-
// ctx.meter.Counter('c2').add(2)
|
|
57
|
-
// }, filter)
|
|
58
|
-
// .onBlock(async function (block, ctx) {
|
|
59
|
-
// ctx.meter.Gauge('h1').record(20, { k: 'v' })
|
|
60
|
-
// })
|