@sentio/sdk 2.40.0-rc.5 → 2.40.0-rc.6
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/aptos/builtin/0x1.js +10 -10
- package/lib/aptos/builtin/0x3.js +11 -11
- package/lib/aptos/builtin/index.js +11 -11
- package/lib/aptos/codegen/index.js +3 -3
- package/lib/aptos/ext/index.js +10 -10
- package/lib/aptos/index.js +10 -10
- package/lib/chunk-2QEQTKQY.js +1050 -0
- package/lib/{chunk-Z7QWETBQ.js → chunk-3LE323R2.js} +2 -2
- package/lib/{chunk-QHHXY7LO.js → chunk-5XM56ENY.js} +5 -5
- package/lib/{chunk-RX5G4RN2.js → chunk-7NFMED3E.js} +2 -2
- package/lib/{chunk-KA5CLZU6.js → chunk-7NWX3CH7.js} +90 -53
- package/lib/{chunk-F2IZC2B6.js → chunk-EMF4HXFG.js} +5 -5
- package/lib/{chunk-VP6Y633M.js → chunk-GOWJIAB2.js} +2 -2
- package/lib/chunk-K5OSTLHI.js +916 -0
- package/lib/{chunk-WLLDVQFE.js → chunk-KO4GSZCM.js} +3 -3
- package/lib/chunk-KTAUVRJN.js +1910 -0
- package/lib/{chunk-2QVJGMW4.js → chunk-KVB555XD.js} +2 -2
- package/lib/{chunk-TDPQO2SX.js → chunk-LICAL3XW.js} +2 -2
- package/lib/{chunk-NBZRHB5V.js → chunk-O6QXDRGG.js} +5 -5
- package/lib/{chunk-6DDG76PU.js → chunk-P6T5WFAZ.js} +4 -4
- package/lib/chunk-QKJ5SWA2.js +861 -0
- package/lib/{chunk-VJTNBZMU.js → chunk-QTWMU7GQ.js} +1 -1
- package/lib/{chunk-OAIP7J4S.js → chunk-RXO7SOTL.js} +2757 -1157
- package/lib/{chunk-S727P6WP.js → chunk-SYEQKTIU.js} +1 -1
- package/lib/{chunk-7OBRGY7G.js → chunk-YNJXNOVA.js} +2 -2
- package/lib/{chunk-N4OQDWM2.js → chunk-YOLIZKGZ.js} +1 -1
- package/lib/{chunk-USETTWR7.js → chunk-Z5PQR6UE.js} +100 -54
- package/lib/core/index.js +3 -3
- package/lib/{eacaggregatorproxy-aed46d4a.d.ts → eacaggregatorproxy-cb8e39be.d.ts} +76 -24
- package/lib/{erc1155-80a76eb5.d.ts → erc1155-fb097c50.d.ts} +31 -9
- package/lib/{erc20-39aae019.d.ts → erc20-95ba7721.d.ts} +61 -19
- package/lib/{erc721-0a429bd4.d.ts → erc721-13bf7a61.d.ts} +49 -15
- package/lib/eth/builtin/eacaggregatorproxy.d.ts +1 -1
- package/lib/eth/builtin/eacaggregatorproxy.js +5 -5
- package/lib/eth/builtin/erc1155.d.ts +1 -1
- package/lib/eth/builtin/erc1155.js +5 -5
- package/lib/eth/builtin/erc20.d.ts +1 -1
- package/lib/eth/builtin/erc20.js +4 -4
- package/lib/eth/builtin/erc721.d.ts +1 -1
- package/lib/eth/builtin/erc721.js +4 -4
- package/lib/eth/builtin/index.d.ts +39 -15
- package/lib/eth/builtin/index.js +8 -8
- package/lib/eth/builtin/weth9.d.ts +1 -1
- package/lib/eth/builtin/weth9.js +5 -5
- package/lib/eth/codegen/index.js +130 -39
- package/lib/eth/index.d.ts +1 -0
- package/lib/eth/index.js +7 -4
- package/lib/fuel/index.js +4 -4
- package/lib/index.js +5 -3
- package/lib/move/index.js +4 -4
- package/lib/solana/builtin/index.js +4 -4
- package/lib/solana/index.js +4 -4
- package/lib/store/index.js +3 -3
- package/lib/sui/builtin/0x1.js +12 -12
- package/lib/sui/builtin/0x2.js +13 -13
- package/lib/sui/builtin/0x3.js +14 -14
- package/lib/sui/builtin/index.js +14 -14
- package/lib/sui/codegen/index.js +2 -2
- package/lib/sui/ext/index.js +10 -10
- package/lib/sui/index.js +11 -11
- package/lib/testing/index.js +14 -14
- package/lib/utils/index.js +7 -7
- package/lib/{weth9-08664cb7.d.ts → weth9-2b52cb06.d.ts} +40 -12
- package/package.json +1 -1
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +1446 -115
- package/src/eth/builtin/internal/erc1155-processor.ts +611 -34
- package/src/eth/builtin/internal/erc20-processor.ts +1182 -84
- package/src/eth/builtin/internal/erc20bytes-processor.ts +595 -45
- package/src/eth/builtin/internal/erc721-processor.ts +967 -64
- package/src/eth/builtin/internal/weth9-processor.ts +698 -55
- package/src/eth/codegen/file.ts +26 -3
- package/src/eth/codegen/function-calls.ts +93 -8
- package/src/eth/codegen/types.ts +22 -1
- package/src/eth/eth-plugin.ts +4 -4
- package/src/eth/index.ts +2 -0
- package/lib/chunk-76HTCT5F.js +0 -469
- package/lib/chunk-ERTIHPSD.js +0 -528
- package/lib/chunk-LWKILLQ6.js +0 -820
- package/lib/chunk-S36AAZOU.js +0 -417
package/src/eth/codegen/file.ts
CHANGED
@@ -9,7 +9,12 @@ import {
|
|
9
9
|
import { reservedKeywords } from '@sentio/ethers-v6/dist/codegen/reserved-keywords.js'
|
10
10
|
import { codegenCallTraceTypes, generateCallHandlers } from './functions-handler.js'
|
11
11
|
import { generateEventFilters, generateEventHandlers } from './event-handler.js'
|
12
|
-
import {
|
12
|
+
import {
|
13
|
+
generateBoundFunctionCallEncoders,
|
14
|
+
generateBoundViewFunctions,
|
15
|
+
generateFunctionCallEncoders,
|
16
|
+
generateViewFunctions
|
17
|
+
} from './function-calls.js'
|
13
18
|
|
14
19
|
export function codeGenIndex(contract: Contract): string {
|
15
20
|
return `
|
@@ -44,6 +49,13 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
44
49
|
.flatMap((fs) => generateViewFunctions(false, fs))
|
45
50
|
.join(',\n')}
|
46
51
|
}
|
52
|
+
|
53
|
+
encodeCall = {
|
54
|
+
${Object.values(contract.functions)
|
55
|
+
.filter((f) => !reservedKeywords.has(f[0].name))
|
56
|
+
.flatMap((fs) => generateFunctionCallEncoders(fs))
|
57
|
+
.join(',\n')}
|
58
|
+
}
|
47
59
|
}
|
48
60
|
|
49
61
|
export class ${contract.name}BoundContractView extends BoundContractView<${contract.name},
|
@@ -61,6 +73,15 @@ export function codeGenSentioFile(contract: Contract): string {
|
|
61
73
|
.flatMap((fs) => generateBoundViewFunctions(false, fs))
|
62
74
|
.join(',\n')}
|
63
75
|
}
|
76
|
+
|
77
|
+
encodeCall = {
|
78
|
+
view: this.view,
|
79
|
+
context: this.context,
|
80
|
+
${Object.values(contract.functions)
|
81
|
+
.filter((f) => !reservedKeywords.has(f[0].name))
|
82
|
+
.flatMap((fs) => generateBoundFunctionCallEncoders(fs))
|
83
|
+
.join(',\n')}
|
84
|
+
}
|
64
85
|
}
|
65
86
|
|
66
87
|
export type ${contract.name}Context = ContractContext<${contract.name}, ${contract.name}BoundContractView>
|
@@ -173,7 +194,7 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
173
194
|
|
174
195
|
const imports = createImportsForUsedIdentifiers(
|
175
196
|
{
|
176
|
-
ethers: ['BigNumberish', 'Overrides', 'BytesLike'],
|
197
|
+
ethers: ['BigNumberish', 'Overrides', 'BytesLike', 'Interface'],
|
177
198
|
// 'ethers/providers': ['Networkish'],
|
178
199
|
'@sentio/sdk/eth': [
|
179
200
|
'addContractByABI',
|
@@ -195,10 +216,12 @@ export class ${contract.name}ProcessorTemplate extends BaseProcessorTemplate<${c
|
|
195
216
|
'TypedCallTrace',
|
196
217
|
'EthContext',
|
197
218
|
'EthFetchConfig',
|
198
|
-
'PreprocessResult'
|
219
|
+
'PreprocessResult',
|
220
|
+
'makeEthCallKey'
|
199
221
|
],
|
200
222
|
// '@sentio/sdk/eth': ['BaseContext'],
|
201
223
|
// '@sentio/protos': ['EthFetchConfig'],
|
224
|
+
'@sentio/protos': ['EthCallParam', 'EthCallContext', 'PreparedData'],
|
202
225
|
'./common.js': ['PromiseOrValue'],
|
203
226
|
'./index.js': [`${contract.name}__factory`],
|
204
227
|
[`./${contract.name}.js`]: [`${contract.name}`, ...eventsImports, ...uniqueStructImports]
|
@@ -1,7 +1,11 @@
|
|
1
1
|
// https://github.com/dethcrypto/TypeChain/blob/015abb28bd22826611051f27e0ec96a00f9a0b61/packages/target-ethers-v5/src/codegen/functions.ts#L54
|
2
|
-
import { FunctionDeclaration } from 'typechain'
|
2
|
+
import { FunctionDeclaration, getSignatureForFn } from 'typechain'
|
3
3
|
import { generateInputTypes, generateOutputTypes } from '@sentio/ethers-v6/dist/codegen/types.js'
|
4
|
-
import {
|
4
|
+
import {
|
5
|
+
getFullSignatureAsSymbolForFunction,
|
6
|
+
getFullSignatureForFunction,
|
7
|
+
getFullSignatureWithOutputForFn
|
8
|
+
} from './types.js'
|
5
9
|
|
6
10
|
function generateReturnTypes(fn: FunctionDeclaration) {
|
7
11
|
// sounds like returnResultObject should be true but we need to set false to make it work
|
@@ -34,11 +38,28 @@ export function generateViewFunction(view: boolean, fn: FunctionDeclaration, inc
|
|
34
38
|
`
|
35
39
|
async ${declName}(${generateInputTypes(fn.inputs, {
|
36
40
|
useStructs: true
|
37
|
-
})}overrides?: Overrides): ${generateReturnTypes(fn)} {
|
38
|
-
try {
|
39
|
-
|
40
|
-
|
41
|
-
|
41
|
+
})}overrides?: Overrides, preparedData?: PreparedData, ethCallContext?: EthCallContext): ${generateReturnTypes(fn)} {
|
42
|
+
try {
|
43
|
+
if (preparedData?.ethCallResults && ethCallContext) {
|
44
|
+
const iface = new Interface(["function ${getFullSignatureWithOutputForFn(fn)}"])
|
45
|
+
const calldata = iface.encodeFunctionData(
|
46
|
+
"${fn.name}",[${
|
47
|
+
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
48
|
+
}]
|
49
|
+
)
|
50
|
+
const key = makeEthCallKey({
|
51
|
+
context: ethCallContext,
|
52
|
+
calldata
|
53
|
+
})
|
54
|
+
const ret = preparedData.ethCallResults[key]
|
55
|
+
if (ret) {
|
56
|
+
const result = iface.decodeFunctionResult("${fn.name}", ret).toArray()
|
57
|
+
return result.length == 1? result[0]: result
|
58
|
+
}
|
59
|
+
}
|
60
|
+
return await ${func}${call}(${
|
61
|
+
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
62
|
+
} overrides || {})
|
42
63
|
} catch (e) {
|
43
64
|
const stack = new Error().stack
|
44
65
|
throw transformEtherError(e, undefined, stack)
|
@@ -67,12 +88,76 @@ export function generateBoundViewFunction(view: boolean, fn: FunctionDeclaration
|
|
67
88
|
async ${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
|
68
89
|
useStructs: true
|
69
90
|
})}overrides?: Overrides): ${generateReturnTypes(fn)} {
|
91
|
+
const ethCallContext = {
|
92
|
+
chainId: this.context.chainId,
|
93
|
+
blockTag: this.context.blockNumber.toString(16),
|
94
|
+
address: this.context.address,
|
95
|
+
}
|
70
96
|
return await this.${qualifier}.${declName}(${
|
71
97
|
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
72
98
|
} {
|
73
99
|
blockTag: this.context.blockNumber,
|
74
100
|
...overrides
|
75
|
-
})
|
101
|
+
}, this.context.preparedData, ethCallContext)
|
102
|
+
}
|
103
|
+
`
|
104
|
+
]
|
105
|
+
}
|
106
|
+
|
107
|
+
// TODO add tests for these
|
108
|
+
export function generateFunctionCallEncoders(functions: FunctionDeclaration[]): string[] {
|
109
|
+
const includeArgTypes = functions.length !== 1
|
110
|
+
return functions.flatMap((fn) => generateFunctionCallEncoder(fn, includeArgTypes))
|
111
|
+
}
|
112
|
+
|
113
|
+
export function generateFunctionCallEncoder(fn: FunctionDeclaration, includeArgTypes: boolean): string[] {
|
114
|
+
const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name
|
115
|
+
return [
|
116
|
+
`
|
117
|
+
${declName}(${generateInputTypes(fn.inputs, {
|
118
|
+
useStructs: true
|
119
|
+
})}ethCallContext: EthCallContext): EthCallParam {
|
120
|
+
try {
|
121
|
+
const iface = new Interface(["function ${getSignatureForFn(fn)}"])
|
122
|
+
const calldata = iface.encodeFunctionData(
|
123
|
+
"${fn.name}",[${
|
124
|
+
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
125
|
+
}]
|
126
|
+
)
|
127
|
+
return {
|
128
|
+
context: ethCallContext,
|
129
|
+
calldata
|
130
|
+
}
|
131
|
+
} catch (e) {
|
132
|
+
const stack = new Error().stack
|
133
|
+
throw transformEtherError(e, undefined, stack)
|
134
|
+
}
|
135
|
+
}
|
136
|
+
`
|
137
|
+
]
|
138
|
+
}
|
139
|
+
|
140
|
+
export function generateBoundFunctionCallEncoders(functions: FunctionDeclaration[]): string[] {
|
141
|
+
const includeArgTypes = functions.length !== 1
|
142
|
+
return functions.flatMap((fn) => generateBoundFunctionCallEncoder(fn, includeArgTypes))
|
143
|
+
}
|
144
|
+
|
145
|
+
export function generateBoundFunctionCallEncoder(fn: FunctionDeclaration, includeArgTypes: boolean): string[] {
|
146
|
+
const declName = includeArgTypes ? getFullSignatureAsSymbolForFunction(fn) : fn.name
|
147
|
+
|
148
|
+
// TODO need override address?
|
149
|
+
return [
|
150
|
+
`
|
151
|
+
${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
|
152
|
+
useStructs: true
|
153
|
+
})}overrides?: Overrides): EthCallParam {
|
154
|
+
const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString()
|
155
|
+
const blockTag = overrides?.blockTag?.toString() ?? this.context.blockNumber.toString(16)
|
156
|
+
const address = this.context.address
|
157
|
+
|
158
|
+
return this.view.encodeCall.${declName}(${
|
159
|
+
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
160
|
+
}{chainId, address, blockTag})
|
76
161
|
}
|
77
162
|
`
|
78
163
|
]
|
package/src/eth/codegen/types.ts
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import {
|
2
|
+
AbiOutputParameter,
|
3
|
+
AbiParameter,
|
4
|
+
EventDeclaration,
|
5
|
+
FunctionDeclaration,
|
6
|
+
getArgumentForSignature,
|
7
|
+
getSignatureForFn
|
8
|
+
} from 'typechain'
|
2
9
|
import { EvmType } from 'typechain/dist/parser/parseEvmType.js'
|
3
10
|
|
4
11
|
export function getFullSignatureAsSymbolForFunction(fn: FunctionDeclaration): string {
|
@@ -40,3 +47,17 @@ export function getFullSignatureForFunction(fn: FunctionDeclaration): string {
|
|
40
47
|
})
|
41
48
|
.join(',')})`
|
42
49
|
}
|
50
|
+
|
51
|
+
function getOutputArgumentForSignature(argument: AbiOutputParameter) {
|
52
|
+
if (argument.type.type == 'void') {
|
53
|
+
return ''
|
54
|
+
}
|
55
|
+
return getArgumentForSignature(argument as AbiParameter)
|
56
|
+
}
|
57
|
+
|
58
|
+
export function getFullSignatureWithOutputForFn(fn: FunctionDeclaration) {
|
59
|
+
return `${getSignatureForFn(fn)} ${fn.stateMutability} returns (${fn.outputs
|
60
|
+
.map((i) => getOutputArgumentForSignature(i))
|
61
|
+
.filter((s) => s != '')
|
62
|
+
.join(',')})`
|
63
|
+
}
|
package/src/eth/eth-plugin.ts
CHANGED
@@ -414,7 +414,7 @@ export class EthPlugin extends Plugin {
|
|
414
414
|
const promises: Promise<ProcessResult>[] = []
|
415
415
|
for (const handlerId of request.handlerIds) {
|
416
416
|
const handler = this.handlers.eventHandlers[handlerId]
|
417
|
-
const promise = handler(ethLog).catch((e) => {
|
417
|
+
const promise = handler(ethLog, preparedData).catch((e) => {
|
418
418
|
throw new ServerError(
|
419
419
|
Status.INTERNAL,
|
420
420
|
'error processing log: ' + JSON.stringify(ethLog.log) + '\n' + errorString(e)
|
@@ -437,7 +437,7 @@ export class EthPlugin extends Plugin {
|
|
437
437
|
const promises: Promise<ProcessResult>[] = []
|
438
438
|
|
439
439
|
for (const handlerId of binding.handlerIds) {
|
440
|
-
const promise = this.handlers.traceHandlers[handlerId](ethTrace).catch((e) => {
|
440
|
+
const promise = this.handlers.traceHandlers[handlerId](ethTrace, preparedData).catch((e) => {
|
441
441
|
throw new ServerError(
|
442
442
|
Status.INTERNAL,
|
443
443
|
'error processing trace: ' + JSON.stringify(ethTrace.trace) + '\n' + errorString(e)
|
@@ -459,7 +459,7 @@ export class EthPlugin extends Plugin {
|
|
459
459
|
|
460
460
|
const promises: Promise<ProcessResult>[] = []
|
461
461
|
for (const handlerId of binding.handlerIds) {
|
462
|
-
const promise = this.handlers.blockHandlers[handlerId](ethBlock).catch((e) => {
|
462
|
+
const promise = this.handlers.blockHandlers[handlerId](ethBlock, preparedData).catch((e) => {
|
463
463
|
throw new ServerError(
|
464
464
|
Status.INTERNAL,
|
465
465
|
'error processing block: ' + ethBlock.block?.number + '\n' + errorString(e)
|
@@ -482,7 +482,7 @@ export class EthPlugin extends Plugin {
|
|
482
482
|
const promises: Promise<ProcessResult>[] = []
|
483
483
|
|
484
484
|
for (const handlerId of binding.handlerIds) {
|
485
|
-
const promise = this.handlers.transactionHandlers[handlerId](ethTransaction).catch((e) => {
|
485
|
+
const promise = this.handlers.transactionHandlers[handlerId](ethTransaction, preparedData).catch((e) => {
|
486
486
|
throw new ServerError(
|
487
487
|
Status.INTERNAL,
|
488
488
|
'error processing transaction: ' + JSON.stringify(ethTransaction.transaction) + '\n' + errorString(e)
|