@sentio/sdk 2.45.3-rc.1 → 2.45.3
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/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +23 -23
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +93 -659
- package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.d.ts +8 -8
- package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc1155-processor.js +33 -264
- package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.d.ts +18 -18
- package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20-processor.js +75 -538
- package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +9 -9
- package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc20bytes-processor.js +37 -268
- package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.d.ts +14 -14
- package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/erc721-processor.js +57 -430
- package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.d.ts +11 -11
- package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
- package/lib/eth/builtin/internal/weth9-processor.js +45 -321
- package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
- package/lib/eth/codegen/file.d.ts.map +1 -1
- package/lib/eth/codegen/file.js +3 -6
- package/lib/eth/codegen/file.js.map +1 -1
- package/lib/eth/codegen/function-calls.d.ts.map +1 -1
- package/lib/eth/codegen/function-calls.js +5 -27
- package/lib/eth/codegen/function-calls.js.map +1 -1
- package/lib/eth/context.d.ts +4 -2
- package/lib/eth/context.d.ts.map +1 -1
- package/lib/eth/context.js +15 -0
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/eth.d.ts +2 -0
- package/lib/eth/eth.d.ts.map +1 -1
- package/lib/eth/eth.js +15 -1
- package/lib/eth/eth.js.map +1 -1
- package/package.json +3 -3
- package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +189 -662
- package/src/eth/builtin/internal/erc1155-processor.ts +69 -261
- package/src/eth/builtin/internal/erc20-processor.ts +136 -535
- package/src/eth/builtin/internal/erc20bytes-processor.ts +68 -265
- package/src/eth/builtin/internal/erc721-processor.ts +118 -433
- package/src/eth/builtin/internal/weth9-processor.ts +81 -318
- package/src/eth/codegen/file.ts +2 -6
- package/src/eth/codegen/function-calls.ts +7 -29
- package/src/eth/context.ts +19 -2
- package/src/eth/eth.ts +21 -1
@@ -75,17 +75,12 @@ export function generateBoundViewFunction(view: boolean, fn: FunctionDeclaration
|
|
75
75
|
async ${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
|
76
76
|
useStructs: true
|
77
77
|
})}overrides?: Overrides): ${generateReturnTypes(fn)} {
|
78
|
-
const ethCallContext = {
|
79
|
-
chainId: this.context.chainId,
|
80
|
-
blockTag: "0x" + this.context.blockNumber.toString(16),
|
81
|
-
address: this.context.address,
|
82
|
-
}
|
83
78
|
return await this.${qualifier}.${declName}(${
|
84
79
|
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
85
80
|
} {
|
86
81
|
blockTag: this.context.blockNumber,
|
87
82
|
...overrides
|
88
|
-
}, this.context.preparedData,
|
83
|
+
}, this.context.preparedData, this.context.getEthCallContext())
|
89
84
|
}
|
90
85
|
`
|
91
86
|
]
|
@@ -103,22 +98,10 @@ export function generateFunctionCallEncoder(fn: FunctionDeclaration, includeArgT
|
|
103
98
|
`
|
104
99
|
${declName}(${generateInputTypes(fn.inputs, {
|
105
100
|
useStructs: true
|
106
|
-
})}
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
"${fn.name}",[${
|
111
|
-
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
112
|
-
}]
|
113
|
-
)
|
114
|
-
return {
|
115
|
-
context: ethCallContext,
|
116
|
-
calldata
|
117
|
-
}
|
118
|
-
} catch (e) {
|
119
|
-
const stack = new Error().stack
|
120
|
-
throw transformEtherError(e, undefined, stack)
|
121
|
-
}
|
101
|
+
})}callContext: EthCallContext): EthCallParam {
|
102
|
+
return encodeCallData(callContext, "${fn.name}", "function ${getSignatureForFn(fn)}", [${
|
103
|
+
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
104
|
+
}])
|
122
105
|
}
|
123
106
|
`
|
124
107
|
]
|
@@ -137,15 +120,10 @@ export function generateBoundFunctionCallEncoder(fn: FunctionDeclaration, includ
|
|
137
120
|
`
|
138
121
|
${declName ?? fn.name}(${generateInputTypes(fn.inputs, {
|
139
122
|
useStructs: true
|
140
|
-
})}overrides?: Overrides): EthCallParam {
|
141
|
-
let blockTagWithOverride = "0x" + this.context.blockNumber.toString(16)
|
142
|
-
if (overrides?.blockTag) {
|
143
|
-
blockTagWithOverride = typeof(overrides.blockTag) == 'string'? overrides.blockTag: "0x" + overrides.blockTag.toString(16)
|
144
|
-
}
|
145
|
-
|
123
|
+
})}overrides?: Overrides): EthCallParam {
|
146
124
|
return this.view.encodeCall.${declName}(${
|
147
125
|
fn.inputs.length > 0 ? fn.inputs.map((input, index) => input.name || `arg${index}`).join(',') + ',' : ''
|
148
|
-
}{chainId: this.context.chainId.toString(), address: this.context.address, blockTag:
|
126
|
+
}{chainId: this.context.chainId.toString(), address: this.context.address, blockTag: this.context.getBlockTag(overrides)})
|
149
127
|
}
|
150
128
|
`
|
151
129
|
]
|
package/src/eth/context.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { BaseContract } from 'ethers'
|
1
|
+
import { BaseContract, Overrides } from 'ethers'
|
2
2
|
import { LogParams, BlockParams, TransactionReceiptParams, TransactionResponseParams } from 'ethers/providers'
|
3
3
|
|
4
|
-
import { PreparedData, RecordMetaData } from '@sentio/protos'
|
4
|
+
import { EthCallContext, PreparedData, RecordMetaData } from '@sentio/protos'
|
5
5
|
import { Trace } from './eth.js'
|
6
6
|
import { Labels, normalizeLabels } from '../core/index.js'
|
7
7
|
import { BaseContext } from '../core/base-context.js'
|
@@ -115,6 +115,23 @@ export abstract class EthContext extends BaseContext {
|
|
115
115
|
}
|
116
116
|
throw new Error("Invaid ctx argument can't happen")
|
117
117
|
}
|
118
|
+
|
119
|
+
getBlockTag(overrides?: Overrides) {
|
120
|
+
let blockTagWithOverride = '0x' + this.blockNumber.toString(16)
|
121
|
+
if (overrides?.blockTag) {
|
122
|
+
blockTagWithOverride =
|
123
|
+
typeof overrides.blockTag == 'string' ? overrides.blockTag : '0x' + overrides.blockTag.toString(16)
|
124
|
+
}
|
125
|
+
return blockTagWithOverride
|
126
|
+
}
|
127
|
+
|
128
|
+
getEthCallContext(): EthCallContext {
|
129
|
+
return {
|
130
|
+
chainId: this.chainId,
|
131
|
+
blockTag: '0x' + this.blockNumber.toString(16),
|
132
|
+
address: this.address
|
133
|
+
}
|
134
|
+
}
|
118
135
|
}
|
119
136
|
|
120
137
|
export class AccountContext extends EthContext {
|
package/src/eth/eth.ts
CHANGED
@@ -11,10 +11,11 @@ import {
|
|
11
11
|
object,
|
12
12
|
formatData
|
13
13
|
} from 'ethers/providers'
|
14
|
-
import { CallExceptionError, LogDescription, Result, DeferredTopicFilter, BlockParams } from 'ethers'
|
14
|
+
import { CallExceptionError, LogDescription, Result, DeferredTopicFilter, BlockParams, Interface } from 'ethers'
|
15
15
|
import { ContractContext } from './context.js'
|
16
16
|
import { getAddress } from 'ethers/address'
|
17
17
|
import { getBigInt, getNumber, hexlify } from 'ethers/utils'
|
18
|
+
import { EthCallContext, EthCallParam } from '@sentio/protos'
|
18
19
|
|
19
20
|
export interface IResult {
|
20
21
|
/**
|
@@ -265,3 +266,22 @@ export function validateAndNormalizeAddress(address: string): string {
|
|
265
266
|
const normalizedAddress = getAddress(address)
|
266
267
|
return normalizedAddress.toLowerCase()
|
267
268
|
}
|
269
|
+
|
270
|
+
export function encodeCallData(
|
271
|
+
context: EthCallContext,
|
272
|
+
name: string,
|
273
|
+
funcABI: string,
|
274
|
+
values?: ReadonlyArray<any>
|
275
|
+
): EthCallParam {
|
276
|
+
try {
|
277
|
+
const iface = new Interface([funcABI])
|
278
|
+
const calldata = iface.encodeFunctionData(name, values)
|
279
|
+
return {
|
280
|
+
context,
|
281
|
+
calldata
|
282
|
+
}
|
283
|
+
} catch (e) {
|
284
|
+
const stack = new Error().stack
|
285
|
+
throw transformEtherError(e, undefined, stack)
|
286
|
+
}
|
287
|
+
}
|