@sentio/sdk 1.27.2 → 1.27.4
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/aptos/types.js +4 -3
- package/lib/aptos/types.js.map +1 -1
- package/lib/{tests/aptos.test.d.ts → aptos/types.test.d.ts} +0 -0
- package/lib/aptos/types.test.js.map +1 -0
- package/lib/aptos/utils.d.ts +2 -1
- package/lib/aptos/utils.js +9 -1
- package/lib/aptos/utils.js.map +1 -1
- package/lib/aptos-codegen/codegen.js +1 -7
- package/lib/aptos-codegen/codegen.js.map +1 -1
- package/lib/processor-runner.js +2 -2
- package/lib/processor-runner.js.map +1 -1
- package/package.json +4 -4
- package/src/aptos/types.ts +5 -4
- package/src/aptos/utils.ts +9 -1
- package/src/aptos-codegen/codegen.ts +2 -9
- package/src/processor-runner.ts +2 -2
- 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.js +0 -304
- 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 -46
- 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-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 -324
- 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 -52
- 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,324 +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(4)
|
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
|
-
|
148
|
-
const testData = {
|
149
|
-
version: '18483034',
|
150
|
-
hash: '0xbf4df6f390546a793ba9b7caff120002b3257986dbea9c697fd64acf7dfeb052',
|
151
|
-
state_change_hash: '0x6063039cca5a1eb33d3986d3665fc783238579961eaa4746c41e25fa4f72aac6',
|
152
|
-
event_root_hash: '0x425e39bcf994672108f83c34f637e84166af7ecedcbe26aed0dff0d62da8055d',
|
153
|
-
state_checkpoint_hash: null,
|
154
|
-
gas_used: '854',
|
155
|
-
success: true,
|
156
|
-
vm_status: 'Executed successfully',
|
157
|
-
accumulator_root_hash: '0x47aa479d9e15993ea2abe04043c89186fb5da0b5eb8b5c6d18bd55d5f0c2c877',
|
158
|
-
changes: [],
|
159
|
-
sender: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
160
|
-
sequence_number: '30',
|
161
|
-
max_gas_amount: '20000',
|
162
|
-
gas_unit_price: '1',
|
163
|
-
expiration_timestamp_secs: '1663144544',
|
164
|
-
payload: {
|
165
|
-
function: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::pull_token_v2',
|
166
|
-
type_arguments: ['0x1::aptos_coin::AptosCoin'],
|
167
|
-
arguments: [
|
168
|
-
'0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
169
|
-
'0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
170
|
-
'Souffl3 BlueBerry',
|
171
|
-
'1',
|
172
|
-
],
|
173
|
-
type: 'entry_function_payload',
|
174
|
-
},
|
175
|
-
signature: {
|
176
|
-
public_key: '0x6c3f579afbf8a728827385039f7604ec1d06e5c802d8f9689ee8ec9d349fedc5',
|
177
|
-
signature:
|
178
|
-
'0xd2db95052e774f095d924030a50c29325a17e8d69d35c748f45bb0e22eb7d3b9e47545c98bd7130fd3ef46cbedc30c9aaeaf39c2d922ee8e7d578c0b1e76f30b',
|
179
|
-
type: 'ed25519_signature',
|
180
|
-
},
|
181
|
-
events: [
|
182
|
-
{
|
183
|
-
guid: {
|
184
|
-
creation_number: '3',
|
185
|
-
account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
186
|
-
},
|
187
|
-
sequence_number: '10',
|
188
|
-
type: '0x1::coin::WithdrawEvent',
|
189
|
-
data: {
|
190
|
-
amount: '1',
|
191
|
-
},
|
192
|
-
},
|
193
|
-
{
|
194
|
-
version: '18483034',
|
195
|
-
guid: {
|
196
|
-
creation_number: '2',
|
197
|
-
account_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
198
|
-
},
|
199
|
-
sequence_number: '11',
|
200
|
-
type: '0x1::coin::DepositEvent',
|
201
|
-
data: {
|
202
|
-
amount: '1',
|
203
|
-
},
|
204
|
-
},
|
205
|
-
{
|
206
|
-
guid: {
|
207
|
-
creation_number: '9',
|
208
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
209
|
-
},
|
210
|
-
sequence_number: '9',
|
211
|
-
type: '0x3::token::CreateTokenDataEvent',
|
212
|
-
data: {
|
213
|
-
description:
|
214
|
-
'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!',
|
215
|
-
id: {
|
216
|
-
collection: 'Souffl3 BlueBerry',
|
217
|
-
creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
218
|
-
name: 'Souffl3 BlueBerry #2',
|
219
|
-
},
|
220
|
-
maximum: '999999999999',
|
221
|
-
mutability_config: {
|
222
|
-
description: true,
|
223
|
-
maximum: true,
|
224
|
-
properties: true,
|
225
|
-
royalty: true,
|
226
|
-
uri: true,
|
227
|
-
},
|
228
|
-
name: 'Souffl3 BlueBerry #2',
|
229
|
-
property_keys: ['author', 'point'],
|
230
|
-
property_types: ['string', 'integer'],
|
231
|
-
property_values: ['0x33454e4a4f59204c616273', '0x30'],
|
232
|
-
royalty_payee_address: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807',
|
233
|
-
royalty_points_denominator: '100',
|
234
|
-
royalty_points_numerator: '20',
|
235
|
-
uri: 'https://y3x4txhvirx5zl57efzbl6dg7psaier5q35hhwuqwzjwuahrycya.arweave.net/xu_J3PVEb9yvvyFyFfhm--QEEj2G-nPakLZTagDxwLA',
|
236
|
-
},
|
237
|
-
},
|
238
|
-
{
|
239
|
-
guid: {
|
240
|
-
creation_number: '2',
|
241
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
242
|
-
},
|
243
|
-
sequence_number: '27',
|
244
|
-
type: '0x3::token::DepositEvent',
|
245
|
-
data: {
|
246
|
-
amount: '1',
|
247
|
-
id: {
|
248
|
-
property_version: '0',
|
249
|
-
token_data_id: {
|
250
|
-
collection: 'Souffl3 BlueBerry',
|
251
|
-
creator: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
252
|
-
name: 'Souffl3 BlueBerry #2',
|
253
|
-
},
|
254
|
-
},
|
255
|
-
},
|
256
|
-
},
|
257
|
-
{
|
258
|
-
version: '18483034',
|
259
|
-
guid: {
|
260
|
-
creation_number: '7',
|
261
|
-
account_address: '0x21d5fe032affa1c8b10d343e9ad5a5618bc13baf5ed4a674fafaa12c54f416cc',
|
262
|
-
},
|
263
|
-
sequence_number: '980533',
|
264
|
-
type: '0x4188c8694687e844677c2aa87171019e23d61cac60de5082a278a8aa47e9d807::SouffleChefCampaign::PullTokenEvent<0x1::aptos_coin::AptosCoin>',
|
265
|
-
data: {
|
266
|
-
receiver: '0x3a80be5daa84f2da7e07b3ec9234da48a5647f757187879c97a1fa03f31f1195',
|
267
|
-
},
|
268
|
-
},
|
269
|
-
],
|
270
|
-
timestamp: '1663143945131218',
|
271
|
-
type: 'user_transaction',
|
272
|
-
}
|
273
|
-
|
274
|
-
const tokenTestData = {
|
275
|
-
guid: {
|
276
|
-
creation_number: '4',
|
277
|
-
account_address: '0x89bc80de59187f707a59ae7a4121718dafe3e6068e0509104ef7e41a56bc97db',
|
278
|
-
},
|
279
|
-
sequence_number: '10',
|
280
|
-
type: '0x3::token::DepositEvent',
|
281
|
-
data: {
|
282
|
-
amount: '1',
|
283
|
-
id: {
|
284
|
-
property_version: '0',
|
285
|
-
token_data_id: {
|
286
|
-
collection: 'Topaz Troopers',
|
287
|
-
creator: '0x9125e4054d884fdc7296b66e12c0d63a7baa0d88c77e8e784987c0a967c670ac',
|
288
|
-
name: 'Topaz Trooper #11293',
|
289
|
-
},
|
290
|
-
},
|
291
|
-
},
|
292
|
-
}
|
293
|
-
|
294
|
-
const createProposalData = {
|
295
|
-
guid: {
|
296
|
-
creation_number: '5',
|
297
|
-
account_address: '0x1',
|
298
|
-
},
|
299
|
-
sequence_number: '3',
|
300
|
-
type: '0x1::voting::CreateProposalEvent',
|
301
|
-
data: {
|
302
|
-
early_resolution_vote_threshold: {
|
303
|
-
vec: ['9272156337856446330'],
|
304
|
-
},
|
305
|
-
execution_hash: '0x31549239ce8abdc1e9c259178614c3d44d015bd6d48635ddcfbfa4a77e7222b0',
|
306
|
-
expiration_secs: '1665463839',
|
307
|
-
metadata: {
|
308
|
-
data: [
|
309
|
-
{
|
310
|
-
key: 'metadata_hash',
|
311
|
-
value:
|
312
|
-
'0x61633230656566373063616466363939663530353564323463356363353931396463306330656562643463303662653332346336323030313561633361653066',
|
313
|
-
},
|
314
|
-
{
|
315
|
-
key: 'metadata_location',
|
316
|
-
value:
|
317
|
-
'0x68747470733a2f2f676973742e67697468756275736572636f6e74656e742e636f6d2f6d6f76656b6576696e2f30353766623134356234303836366566663863323263393166623964613931392f7261772f626162383566306637343334663030386138373831656563376663616464316163356135353438312f6769737466696c65312e747874',
|
318
|
-
},
|
319
|
-
],
|
320
|
-
},
|
321
|
-
min_vote_threshold: '100000000000000',
|
322
|
-
proposal_id: '3',
|
323
|
-
},
|
324
|
-
}
|
@@ -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
|
-
// })
|
@@ -1,82 +0,0 @@
|
|
1
|
-
import { assert } from 'chai'
|
2
|
-
|
3
|
-
import { TestProcessorServer } from '../testing'
|
4
|
-
import { BigNumber } from 'ethers'
|
5
|
-
import { mockApprovalLog, mockOwnershipTransferredLog, mockTransferLog } from '../builtin/erc20/test-utils'
|
6
|
-
import { ERC20Processor } from '../builtin/internal/erc20_processor'
|
7
|
-
import { conversion } from '../utils'
|
8
|
-
import { BigDecimal } from '@sentio/sdk'
|
9
|
-
|
10
|
-
describe('Test Error Capture', () => {
|
11
|
-
const service = new TestProcessorServer(() => {
|
12
|
-
ERC20Processor.bind({ address: '0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91' })
|
13
|
-
.onEventApproval((evt, ctx) => {
|
14
|
-
const v = new BigDecimal(1).div(conversion.toBigDecimal(evt.args.value))
|
15
|
-
ctx.meter.Gauge('xx').record(v)
|
16
|
-
})
|
17
|
-
.onEventTransfer((evt, ctx) => {
|
18
|
-
const v = new BigDecimal(0).div(conversion.toBigDecimal(evt.args.value))
|
19
|
-
ctx.meter.Gauge('xx').record(v)
|
20
|
-
})
|
21
|
-
.onEventOwnershipTransferred((evt, ctx) => {
|
22
|
-
ctx.meter.Gauge('xx').record(BigNumber.from(10 ** 18))
|
23
|
-
})
|
24
|
-
})
|
25
|
-
|
26
|
-
beforeAll(async () => {
|
27
|
-
await service.start()
|
28
|
-
})
|
29
|
-
|
30
|
-
test('Check infinite', async () => {
|
31
|
-
let err: Error | undefined
|
32
|
-
try {
|
33
|
-
// TODO check why order matters
|
34
|
-
// await service.testLog(mockApprovalLog("0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91", {
|
35
|
-
// value: BigNumber.from(3000000),
|
36
|
-
// spender: "0x0000000000000000000000000000000000000000",
|
37
|
-
// owner: "0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91"
|
38
|
-
// }))
|
39
|
-
await service.testLog(
|
40
|
-
mockApprovalLog('0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91', {
|
41
|
-
owner: '0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91',
|
42
|
-
spender: '0x0000000000000000000000000000000000000000',
|
43
|
-
value: BigNumber.from(0),
|
44
|
-
})
|
45
|
-
)
|
46
|
-
} catch (e) {
|
47
|
-
err = e
|
48
|
-
}
|
49
|
-
assert(err?.message.includes('Record infinite value'))
|
50
|
-
})
|
51
|
-
|
52
|
-
test('Check NaN', async () => {
|
53
|
-
let err: Error | undefined
|
54
|
-
try {
|
55
|
-
await service.testLog(
|
56
|
-
mockTransferLog('0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91', {
|
57
|
-
from: '0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91',
|
58
|
-
to: '0x0000000000000000000000000000000000000000',
|
59
|
-
value: BigNumber.from(0),
|
60
|
-
})
|
61
|
-
)
|
62
|
-
} catch (e) {
|
63
|
-
err = e
|
64
|
-
}
|
65
|
-
assert(err?.message.includes('NaN'))
|
66
|
-
})
|
67
|
-
|
68
|
-
test('Check overflow', async () => {
|
69
|
-
let err: Error | undefined
|
70
|
-
try {
|
71
|
-
await service.testLog(
|
72
|
-
mockOwnershipTransferredLog('0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91', {
|
73
|
-
previousOwner: '0x80009ff8154bd5653c6dda2fa5f5053e5a5c1a91',
|
74
|
-
newOwner: '0x0000000000000000000000000000000000000000',
|
75
|
-
})
|
76
|
-
)
|
77
|
-
} catch (e) {
|
78
|
-
err = e
|
79
|
-
}
|
80
|
-
assert(err?.message.includes('overflow'))
|
81
|
-
})
|
82
|
-
})
|