@sentio/sdk 1.14.4 → 1.15.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.
- package/lib/builtin/internal/erc20_processor.js.map +1 -1
- package/lib/builtin/internal/erc20bytes_processor.js.map +1 -1
- package/lib/builtin/internal/weth9_processor.js.map +1 -1
- package/lib/cli/upload.js +78 -42
- package/lib/cli/upload.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +3 -2
- package/lib/gen/processor/protos/processor.js +34 -17
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/service.js +14 -11
- package/lib/service.js.map +1 -1
- package/lib/target-ethers-sentio/codegen.js +11 -2
- package/lib/target-ethers-sentio/codegen.js.map +1 -1
- package/lib/test/erc20.js +5 -0
- package/lib/test/erc20.js.map +1 -1
- package/lib/test/erc20.test.js +13 -0
- package/lib/test/erc20.test.js.map +1 -1
- package/lib/test/sui.test.js +2 -1
- package/lib/test/sui.test.js.map +1 -1
- package/package.json +1 -1
- package/src/builtin/internal/erc20_processor.ts +22 -16
- package/src/builtin/internal/erc20bytes_processor.ts +18 -12
- package/src/builtin/internal/weth9_processor.ts +18 -12
- package/src/cli/upload.ts +76 -38
- package/src/gen/processor/protos/processor.ts +37 -19
- package/src/service.ts +15 -11
- package/src/target-ethers-sentio/codegen.ts +13 -3
- package/src/test/erc20.test.ts +15 -1
- package/src/test/erc20.ts +5 -1
- package/src/test/sui.test.ts +2 -1
package/src/service.ts
CHANGED
|
@@ -205,7 +205,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
205
205
|
try {
|
|
206
206
|
this.loader()
|
|
207
207
|
} catch (e) {
|
|
208
|
-
throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor
|
|
208
|
+
throw new ServerError(Status.INVALID_ARGUMENT, 'Failed to load processor: ' + errorString(e))
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
for (const instance of request.templateInstances) {
|
|
@@ -227,7 +227,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
227
227
|
try {
|
|
228
228
|
await this.configure()
|
|
229
229
|
} catch (e) {
|
|
230
|
-
throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + e
|
|
230
|
+
throw new ServerError(Status.INTERNAL, 'Failed to start processor : ' + errorString(e))
|
|
231
231
|
}
|
|
232
232
|
this.started = true
|
|
233
233
|
return {}
|
|
@@ -265,7 +265,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
265
265
|
const log: Log = JSON.parse(jsonString)
|
|
266
266
|
const handler = this.eventHandlers[l.handlerId]
|
|
267
267
|
const promise = handler(log).catch((e) => {
|
|
268
|
-
throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\n' + e
|
|
268
|
+
throw new ServerError(Status.INTERNAL, 'error processing log: ' + jsonString + '\n' + errorString(e))
|
|
269
269
|
})
|
|
270
270
|
|
|
271
271
|
promises.push(promise)
|
|
@@ -310,7 +310,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
310
310
|
logs: [],
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
if (global.PROCESSOR_STATE.suiProcessors) {
|
|
313
|
+
if (request.chainId.toLowerCase().startsWith('sui') && global.PROCESSOR_STATE.suiProcessors) {
|
|
314
314
|
const processorPromises: Promise<void>[] = []
|
|
315
315
|
for (const txn of request.transactions) {
|
|
316
316
|
processorPromises.push(
|
|
@@ -319,14 +319,14 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
319
319
|
const res = processor.handleTransaction(JSON.parse(new TextDecoder().decode(txn.raw)))
|
|
320
320
|
if (res) {
|
|
321
321
|
res.gauges.forEach((g) => {
|
|
322
|
-
if (g.metadata) {
|
|
323
|
-
g.metadata.blockNumber =
|
|
322
|
+
if (g.metadata && txn.slot) {
|
|
323
|
+
g.metadata.blockNumber = txn.slot
|
|
324
324
|
}
|
|
325
325
|
result.gauges.push(g)
|
|
326
326
|
})
|
|
327
327
|
res.counters.forEach((c) => {
|
|
328
|
-
if (c.metadata) {
|
|
329
|
-
c.metadata.blockNumber =
|
|
328
|
+
if (c.metadata && txn.slot) {
|
|
329
|
+
c.metadata.blockNumber = txn.slot
|
|
330
330
|
}
|
|
331
331
|
result.counters.push(c)
|
|
332
332
|
})
|
|
@@ -394,7 +394,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
394
394
|
result.counters.push(c)
|
|
395
395
|
})
|
|
396
396
|
} catch (e) {
|
|
397
|
-
console.error('error processing instruction ' + e
|
|
397
|
+
console.error('error processing instruction ' + errorString(e))
|
|
398
398
|
}
|
|
399
399
|
} else {
|
|
400
400
|
console.warn(
|
|
@@ -455,7 +455,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
455
455
|
const promises: Promise<ProcessResult>[] = []
|
|
456
456
|
for (const handlerId of binding.handlerIds) {
|
|
457
457
|
const promise = this.blockHandlers[handlerId](block).catch((e) => {
|
|
458
|
-
throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\n' + e
|
|
458
|
+
throw new ServerError(Status.INTERNAL, 'error processing block: ' + block.number + '\n' + errorString(e))
|
|
459
459
|
})
|
|
460
460
|
promises.push(promise)
|
|
461
461
|
}
|
|
@@ -496,7 +496,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
|
496
496
|
const trace: Trace = JSON.parse(jsonString)
|
|
497
497
|
|
|
498
498
|
return this.traceHandlers[binding.handlerId](trace).catch((e) => {
|
|
499
|
-
throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\n' + e
|
|
499
|
+
throw new ServerError(Status.INTERNAL, 'error processing trace: ' + jsonString + '\n' + errorString(e))
|
|
500
500
|
})
|
|
501
501
|
}
|
|
502
502
|
}
|
|
@@ -555,3 +555,7 @@ function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
|
|
|
555
555
|
}
|
|
556
556
|
})
|
|
557
557
|
}
|
|
558
|
+
|
|
559
|
+
function errorString(e: Error): string {
|
|
560
|
+
return e.stack || e.message
|
|
561
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from 'typechain'
|
|
8
8
|
|
|
9
9
|
import { reservedKeywords } from '@typechain/ethers-v5/dist/codegen/reserved-keywords'
|
|
10
|
-
import { generateInputTypes } from '@typechain/ethers-v5/dist/codegen/types'
|
|
10
|
+
import { generateInputTypes, generateOutputTypes } from '@typechain/ethers-v5/dist/codegen/types'
|
|
11
11
|
import { getFullSignatureForEvent } from 'typechain/dist/utils/signatures'
|
|
12
12
|
import { codegenCallTraceTypes, codegenFunctions } from './functions'
|
|
13
13
|
|
|
@@ -246,9 +246,17 @@ function generateOnEventFunction(event: EventDeclaration, contractName: string,
|
|
|
246
246
|
`
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
// https://github.com/dethcrypto/TypeChain/blob/015abb28bd22826611051f27e0ec96a00f9a0b61/packages/target-ethers-v5/src/codegen/functions.ts#L54
|
|
250
|
+
function generateReturnTypes(fn: FunctionDeclaration) {
|
|
251
|
+
// sounds like returnResultObject should be true but we need to set false to make it work
|
|
252
|
+
return `Promise<${generateOutputTypes({ returnResultObject: false, useStructs: true }, fn.outputs)}>`
|
|
253
|
+
}
|
|
254
|
+
|
|
249
255
|
function generateViewFunction(func: FunctionDeclaration): string {
|
|
250
256
|
return `
|
|
251
|
-
async ${func.name}(${generateInputTypes(func.inputs, {
|
|
257
|
+
async ${func.name}(${generateInputTypes(func.inputs, {
|
|
258
|
+
useStructs: true,
|
|
259
|
+
})}overrides?: CallOverrides): ${generateReturnTypes(func)} {
|
|
252
260
|
try {
|
|
253
261
|
if (overrides) {
|
|
254
262
|
return await this.contract.${func.name}(${
|
|
@@ -268,7 +276,9 @@ function generateViewFunction(func: FunctionDeclaration): string {
|
|
|
268
276
|
|
|
269
277
|
function generateBoundViewFunction(func: FunctionDeclaration): string {
|
|
270
278
|
return `
|
|
271
|
-
async ${func.name}(${generateInputTypes(func.inputs, {
|
|
279
|
+
async ${func.name}(${generateInputTypes(func.inputs, {
|
|
280
|
+
useStructs: true,
|
|
281
|
+
})}overrides?: CallOverrides): ${generateReturnTypes(func)} {
|
|
272
282
|
try {
|
|
273
283
|
if (!overrides && this.context) {
|
|
274
284
|
overrides = {
|
package/src/test/erc20.test.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { HandlerType } from '..'
|
|
|
7
7
|
import { TestProcessorServer } from './test-processor-server'
|
|
8
8
|
import { firstCounterValue, firstGaugeValue } from './metric-utils'
|
|
9
9
|
import { BigNumber } from 'ethers'
|
|
10
|
-
import { mockTransferLog } from '../builtin/erc20/test-utils'
|
|
10
|
+
import { mockApprovalLog, mockTransferLog } from '../builtin/erc20/test-utils'
|
|
11
11
|
import { Trace } from '../trace'
|
|
12
12
|
|
|
13
13
|
describe('Test Basic Examples', () => {
|
|
@@ -80,6 +80,20 @@ describe('Test Basic Examples', () => {
|
|
|
80
80
|
expect(config).deep.equals(config2)
|
|
81
81
|
})
|
|
82
82
|
|
|
83
|
+
test('Check log exception', async () => {
|
|
84
|
+
const logData = mockApprovalLog('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', {
|
|
85
|
+
owner: '0x0000000000000000000000000000000000000000',
|
|
86
|
+
spender: '0xB329e39Ebefd16f40d38f07643652cE17Ca5Bac1',
|
|
87
|
+
value: BigNumber.from('1111'),
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
await service.testLog(logData, 56)
|
|
92
|
+
} catch (e) {
|
|
93
|
+
expect(e.message.indexOf('sdk/src/test/erc20.ts') != -1).eq(true)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
83
97
|
const blockData = {
|
|
84
98
|
hash: '0x2b9b7cce1f17f3b7e1f3c2472cc806a07bee3f0baca07d021350950d81d73a42',
|
|
85
99
|
number: 14373295,
|
package/src/test/erc20.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ERC20Processor, ERC20ProcessorTemplate } from '../builtin/erc20'
|
|
2
|
+
import { BigNumber } from '@ethersproject/bignumber'
|
|
2
3
|
|
|
3
4
|
export const filter = ERC20Processor.filters.Transfer(
|
|
4
5
|
'0x0000000000000000000000000000000000000000',
|
|
@@ -34,7 +35,10 @@ ERC20Processor.bind({ address: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', net
|
|
|
34
35
|
.onBlock(async function (block, ctx) {
|
|
35
36
|
ctx.meter.Gauge('g2').record(20, { k: 'v' })
|
|
36
37
|
})
|
|
37
|
-
|
|
38
|
+
.onEventApproval(async function (event, ctx) {
|
|
39
|
+
BigNumber.from(10 ** 18)
|
|
40
|
+
// console.log(n)
|
|
41
|
+
})
|
|
38
42
|
ERC20Processor.bind({ address: 'xxxx', network: 56 })
|
|
39
43
|
|
|
40
44
|
ERC20Processor.bind({ address: 'yyyy', network: 1 })
|
package/src/test/sui.test.ts
CHANGED
|
@@ -20,9 +20,10 @@ describe('Test Sui Example', () => {
|
|
|
20
20
|
|
|
21
21
|
test('Check tictactoe transaction dispatch', async () => {
|
|
22
22
|
const request: ProcessTransactionsRequest = {
|
|
23
|
+
chainId: 'SUI_devnet',
|
|
23
24
|
transactions: [
|
|
24
25
|
{
|
|
25
|
-
txHash: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',
|
|
26
|
+
// txHash: 'z3HjnnFFKAaszOi0pMSImtGMpRd2r7ljLjAjUoqs3Kw=',
|
|
26
27
|
raw: new TextEncoder().encode(JSON.stringify(testData)),
|
|
27
28
|
programAccountId: '0xb8252513f0b9efaa3e260842c4b84d8ff933522d',
|
|
28
29
|
},
|