@sentio/sdk 2.40.0-rc.4 → 2.40.0-rc.41

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.
Files changed (224) hide show
  1. package/lib/aptos/aptos-processor.d.ts +1 -1
  2. package/lib/aptos/aptos-processor.d.ts.map +1 -1
  3. package/lib/aptos/aptos-processor.js +1 -1
  4. package/lib/aptos/aptos-processor.js.map +1 -1
  5. package/lib/aptos/context.d.ts +2 -2
  6. package/lib/aptos/context.d.ts.map +1 -1
  7. package/lib/aptos/context.js +1 -1
  8. package/lib/aptos/ext/aptos-dex.d.ts +1 -1
  9. package/lib/aptos/ext/aptos-dex.d.ts.map +1 -1
  10. package/lib/aptos/ext/aptos-dex.js +1 -1
  11. package/lib/aptos/ext/aptos-dex.js.map +1 -1
  12. package/lib/aptos/ext/coin-event.d.ts +1 -1
  13. package/lib/aptos/ext/coin-event.d.ts.map +1 -1
  14. package/lib/aptos/ext/coin.js +2 -2
  15. package/lib/aptos/ext/coin.js.map +1 -1
  16. package/lib/aptos/move-coder.d.ts.map +1 -1
  17. package/lib/aptos/move-coder.js +6 -5
  18. package/lib/aptos/move-coder.js.map +1 -1
  19. package/lib/aptos/network.d.ts +2 -0
  20. package/lib/aptos/network.d.ts.map +1 -1
  21. package/lib/aptos/network.js +7 -1
  22. package/lib/aptos/network.js.map +1 -1
  23. package/lib/eth/account-processor.d.ts +21 -7
  24. package/lib/eth/account-processor.d.ts.map +1 -1
  25. package/lib/eth/account-processor.js +2 -2
  26. package/lib/eth/account-processor.js.map +1 -1
  27. package/lib/eth/base-processor-template.d.ts +24 -8
  28. package/lib/eth/base-processor-template.d.ts.map +1 -1
  29. package/lib/eth/base-processor-template.js.map +1 -1
  30. package/lib/eth/base-processor.d.ts +30 -10
  31. package/lib/eth/base-processor.d.ts.map +1 -1
  32. package/lib/eth/base-processor.js +6 -6
  33. package/lib/eth/base-processor.js.map +1 -1
  34. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +100 -31
  35. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  36. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +1226 -46
  37. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  38. package/lib/eth/builtin/internal/erc1155-processor.d.ts +55 -16
  39. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  40. package/lib/eth/builtin/internal/erc1155-processor.js +486 -16
  41. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  42. package/lib/eth/builtin/internal/erc20-processor.d.ts +79 -24
  43. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  44. package/lib/eth/builtin/internal/erc20-processor.js +985 -36
  45. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  46. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +46 -13
  47. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  48. package/lib/eth/builtin/internal/erc20bytes-processor.js +485 -18
  49. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  50. package/lib/eth/builtin/internal/erc721-processor.d.ts +67 -20
  51. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  52. package/lib/eth/builtin/internal/erc721-processor.js +784 -28
  53. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  54. package/lib/eth/builtin/internal/weth9-processor.d.ts +64 -19
  55. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  56. package/lib/eth/builtin/internal/weth9-processor.js +574 -22
  57. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  58. package/lib/eth/codegen/event-handler.js +1 -1
  59. package/lib/eth/codegen/file.d.ts.map +1 -1
  60. package/lib/eth/codegen/file.js +21 -3
  61. package/lib/eth/codegen/file.js.map +1 -1
  62. package/lib/eth/codegen/function-calls.d.ts +4 -0
  63. package/lib/eth/codegen/function-calls.d.ts.map +1 -1
  64. package/lib/eth/codegen/function-calls.js +80 -5
  65. package/lib/eth/codegen/function-calls.js.map +1 -1
  66. package/lib/eth/codegen/types.d.ts +1 -0
  67. package/lib/eth/codegen/types.d.ts.map +1 -1
  68. package/lib/eth/codegen/types.js +13 -0
  69. package/lib/eth/codegen/types.js.map +1 -1
  70. package/lib/eth/context.d.ts +4 -0
  71. package/lib/eth/context.d.ts.map +1 -1
  72. package/lib/eth/context.js +4 -0
  73. package/lib/eth/context.js.map +1 -1
  74. package/lib/eth/eth-plugin.d.ts +27 -9
  75. package/lib/eth/eth-plugin.d.ts.map +1 -1
  76. package/lib/eth/eth-plugin.js +20 -17
  77. package/lib/eth/eth-plugin.js.map +1 -1
  78. package/lib/eth/eth.d.ts.map +1 -1
  79. package/lib/eth/eth.js +1 -1
  80. package/lib/eth/eth.js.map +1 -1
  81. package/lib/eth/generic-processor.js +1 -1
  82. package/lib/eth/generic-processor.js.map +1 -1
  83. package/lib/eth/generic-processor.test.js.map +1 -1
  84. package/lib/eth/index.d.ts +2 -1
  85. package/lib/eth/index.d.ts.map +1 -1
  86. package/lib/eth/index.js +2 -1
  87. package/lib/eth/index.js.map +1 -1
  88. package/lib/solana/builtin/spl-token-processor.d.ts +1 -1
  89. package/lib/solana/builtin/spl-token-processor.d.ts.map +1 -1
  90. package/lib/solana/builtin/spl-token-processor.js +1 -1
  91. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  92. package/lib/solana/solana-context.d.ts +1 -1
  93. package/lib/solana/solana-context.js +2 -2
  94. package/lib/stark/codegen/codegen.d.ts +2 -0
  95. package/lib/stark/codegen/codegen.d.ts.map +1 -0
  96. package/lib/stark/codegen/codegen.js +109 -0
  97. package/lib/stark/codegen/codegen.js.map +1 -0
  98. package/lib/stark/codegen/index.d.ts +2 -0
  99. package/lib/stark/codegen/index.d.ts.map +1 -0
  100. package/lib/stark/codegen/index.js +2 -0
  101. package/lib/stark/codegen/index.js.map +1 -0
  102. package/lib/stark/codegen/run.d.ts +2 -0
  103. package/lib/stark/codegen/run.d.ts.map +1 -0
  104. package/lib/stark/codegen/run.js +11 -0
  105. package/lib/stark/codegen/run.js.map +1 -0
  106. package/lib/stark/codegen/utils.d.ts +2 -0
  107. package/lib/stark/codegen/utils.d.ts.map +1 -0
  108. package/lib/stark/codegen/utils.js +4 -0
  109. package/lib/stark/codegen/utils.js.map +1 -0
  110. package/lib/stark/context.d.ts +28 -0
  111. package/lib/stark/context.d.ts.map +1 -0
  112. package/lib/stark/context.js +59 -0
  113. package/lib/stark/context.js.map +1 -0
  114. package/lib/stark/contract.d.ts +12 -0
  115. package/lib/stark/contract.d.ts.map +1 -0
  116. package/lib/stark/contract.js +43 -0
  117. package/lib/stark/contract.js.map +1 -0
  118. package/lib/stark/event.d.ts +7 -0
  119. package/lib/stark/event.d.ts.map +1 -0
  120. package/lib/stark/event.js +11 -0
  121. package/lib/stark/event.js.map +1 -0
  122. package/lib/stark/index.d.ts +7 -0
  123. package/lib/stark/index.d.ts.map +1 -0
  124. package/lib/stark/index.js +7 -0
  125. package/lib/stark/index.js.map +1 -0
  126. package/lib/stark/starknet-plugin.d.ts +17 -0
  127. package/lib/stark/starknet-plugin.d.ts.map +1 -0
  128. package/lib/stark/starknet-plugin.js +78 -0
  129. package/lib/stark/starknet-plugin.js.map +1 -0
  130. package/lib/stark/starknet-processor.d.ts +32 -0
  131. package/lib/stark/starknet-processor.d.ts.map +1 -0
  132. package/lib/stark/starknet-processor.js +111 -0
  133. package/lib/stark/starknet-processor.js.map +1 -0
  134. package/lib/stark/types.d.ts +11 -0
  135. package/lib/stark/types.d.ts.map +1 -0
  136. package/lib/stark/types.js +2 -0
  137. package/lib/stark/types.js.map +1 -0
  138. package/lib/store/cache.d.ts +14 -0
  139. package/lib/store/cache.d.ts.map +1 -0
  140. package/lib/store/cache.js +35 -0
  141. package/lib/store/cache.js.map +1 -0
  142. package/lib/store/store.d.ts +2 -3
  143. package/lib/store/store.d.ts.map +1 -1
  144. package/lib/store/store.js +34 -9
  145. package/lib/store/store.js.map +1 -1
  146. package/lib/sui/context.d.ts +1 -1
  147. package/lib/sui/context.d.ts.map +1 -1
  148. package/lib/sui/sui-processor.d.ts +1 -1
  149. package/lib/sui/sui-processor.d.ts.map +1 -1
  150. package/lib/sui/sui-processor.js +1 -1
  151. package/lib/sui/sui-processor.js.map +1 -1
  152. package/lib/testing/aptos-facet.d.ts +1 -1
  153. package/lib/testing/aptos-facet.js +2 -2
  154. package/lib/testing/starknet-facet.d.ts +9 -0
  155. package/lib/testing/starknet-facet.d.ts.map +1 -0
  156. package/lib/testing/starknet-facet.js +52 -0
  157. package/lib/testing/starknet-facet.js.map +1 -0
  158. package/lib/testing/sui-facet.js +1 -1
  159. package/lib/testing/test-processor-server.d.ts +2 -0
  160. package/lib/testing/test-processor-server.d.ts.map +1 -1
  161. package/lib/testing/test-processor-server.js +3 -0
  162. package/lib/testing/test-processor-server.js.map +1 -1
  163. package/lib/tsup.config.ts +3 -15
  164. package/lib/utils/dex-price.d.ts +1 -0
  165. package/lib/utils/dex-price.d.ts.map +1 -1
  166. package/lib/utils/dex-price.js +13 -2
  167. package/lib/utils/dex-price.js.map +1 -1
  168. package/package.json +21 -10
  169. package/src/aptos/aptos-processor.ts +1 -1
  170. package/src/aptos/context.ts +2 -2
  171. package/src/aptos/ext/aptos-dex.ts +1 -1
  172. package/src/aptos/ext/coin-event.ts +1 -1
  173. package/src/aptos/ext/coin.ts +2 -2
  174. package/src/aptos/move-coder.ts +7 -5
  175. package/src/aptos/network.ts +7 -1
  176. package/src/bundle.config.ts +23 -0
  177. package/src/eth/account-processor.ts +28 -12
  178. package/src/eth/base-processor-template.ts +16 -8
  179. package/src/eth/base-processor.ts +25 -16
  180. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +1554 -123
  181. package/src/eth/builtin/internal/erc1155-processor.ts +659 -42
  182. package/src/eth/builtin/internal/erc20-processor.ts +1266 -90
  183. package/src/eth/builtin/internal/erc20bytes-processor.ts +639 -49
  184. package/src/eth/builtin/internal/erc721-processor.ts +1035 -70
  185. package/src/eth/builtin/internal/weth9-processor.ts +758 -63
  186. package/src/eth/codegen/event-handler.ts +1 -1
  187. package/src/eth/codegen/file.ts +26 -3
  188. package/src/eth/codegen/function-calls.ts +96 -8
  189. package/src/eth/codegen/types.ts +22 -1
  190. package/src/eth/context.ts +7 -0
  191. package/src/eth/eth-plugin.ts +34 -26
  192. package/src/eth/eth.ts +1 -2
  193. package/src/eth/generic-processor.ts +1 -1
  194. package/src/eth/index.ts +5 -1
  195. package/src/solana/builtin/spl-token-processor.ts +1 -1
  196. package/src/solana/solana-context.ts +2 -2
  197. package/src/stark/codegen/codegen.ts +124 -0
  198. package/src/stark/codegen/index.ts +1 -0
  199. package/src/stark/codegen/run.ts +10 -0
  200. package/src/stark/codegen/utils.ts +3 -0
  201. package/src/stark/context.ts +78 -0
  202. package/src/stark/contract.ts +55 -0
  203. package/src/stark/event.ts +7 -0
  204. package/src/stark/index.ts +9 -0
  205. package/src/stark/starknet-plugin.ts +108 -0
  206. package/src/stark/starknet-processor.ts +140 -0
  207. package/src/stark/types.ts +11 -0
  208. package/src/store/cache.ts +46 -0
  209. package/src/store/store.ts +40 -22
  210. package/src/sui/context.ts +1 -1
  211. package/src/sui/sui-processor.ts +1 -1
  212. package/src/testing/aptos-facet.ts +2 -2
  213. package/src/testing/starknet-facet.ts +61 -0
  214. package/src/testing/sui-facet.ts +1 -1
  215. package/src/testing/test-processor-server.ts +3 -0
  216. package/src/tsup.config.ts +3 -15
  217. package/src/utils/dex-price.ts +15 -2
  218. package/lib/eth/provider.d.ts +0 -5
  219. package/lib/eth/provider.d.ts.map +0 -1
  220. package/lib/eth/provider.js +0 -134
  221. package/lib/eth/provider.js.map +0 -1
  222. package/lib/utils/chainlink-oracles-sepolia.csv +0 -19
  223. package/lib/utils/chainlink-oracles.csv +0 -217
  224. package/src/eth/provider.ts +0 -163
@@ -1,7 +1,7 @@
1
1
  /* Autogenerated file. Do not edit manually. */
2
2
  /* tslint:disable */
3
3
  /* eslint-disable */
4
- import { BigNumberish, Overrides, BytesLike } from "ethers";
4
+ import { BigNumberish, Overrides, BytesLike, Interface } from "ethers";
5
5
  import {
6
6
  addContractByABI,
7
7
  getContractByABI,
@@ -21,7 +21,9 @@ import {
21
21
  EthContext,
22
22
  EthFetchConfig,
23
23
  PreprocessResult,
24
+ makeEthCallKey,
24
25
  } from "@sentio/sdk/eth";
26
+ import { EthCallParam, EthCallContext, PreparedData } from "@sentio/protos";
25
27
 
26
28
  import { ERC1155__factory } from "./index.js";
27
29
  import {
@@ -128,9 +130,26 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
128
130
  async balanceOf(
129
131
  account: string,
130
132
  id: BigNumberish,
131
- overrides?: Overrides
133
+ overrides?: Overrides,
134
+ preparedData?: PreparedData,
135
+ ethCallContext?: EthCallContext
132
136
  ): Promise<bigint> {
133
137
  try {
138
+ if (preparedData?.ethCallResults && ethCallContext) {
139
+ const iface = new Interface([
140
+ "function balanceOf(address,uint256) view returns (uint256)",
141
+ ]);
142
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
143
+ const key = makeEthCallKey({
144
+ context: ethCallContext,
145
+ calldata,
146
+ });
147
+ const ret = preparedData.ethCallResults[key];
148
+ if (ret) {
149
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
150
+ return result.length == 1 ? result[0] : result;
151
+ }
152
+ }
134
153
  return await this.contract.getFunction("balanceOf(address,uint256)")(
135
154
  account,
136
155
  id,
@@ -145,9 +164,31 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
145
164
  async balanceOfBatch(
146
165
  accounts: string[],
147
166
  ids: BigNumberish[],
148
- overrides?: Overrides
167
+ overrides?: Overrides,
168
+ preparedData?: PreparedData,
169
+ ethCallContext?: EthCallContext
149
170
  ): Promise<bigint[]> {
150
171
  try {
172
+ if (preparedData?.ethCallResults && ethCallContext) {
173
+ const iface = new Interface([
174
+ "function balanceOfBatch(address[],uint256[]) view returns (uint256[])",
175
+ ]);
176
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
177
+ accounts,
178
+ ids,
179
+ ]);
180
+ const key = makeEthCallKey({
181
+ context: ethCallContext,
182
+ calldata,
183
+ });
184
+ const ret = preparedData.ethCallResults[key];
185
+ if (ret) {
186
+ const result = iface
187
+ .decodeFunctionResult("balanceOfBatch", ret)
188
+ .toArray();
189
+ return result.length == 1 ? result[0] : result;
190
+ }
191
+ }
151
192
  return await this.contract.getFunction(
152
193
  "balanceOfBatch(address[],uint256[])"
153
194
  )(accounts, ids, overrides || {});
@@ -160,9 +201,31 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
160
201
  async isApprovedForAll(
161
202
  account: string,
162
203
  operator: string,
163
- overrides?: Overrides
204
+ overrides?: Overrides,
205
+ preparedData?: PreparedData,
206
+ ethCallContext?: EthCallContext
164
207
  ): Promise<boolean> {
165
208
  try {
209
+ if (preparedData?.ethCallResults && ethCallContext) {
210
+ const iface = new Interface([
211
+ "function isApprovedForAll(address,address) view returns (bool)",
212
+ ]);
213
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
214
+ account,
215
+ operator,
216
+ ]);
217
+ const key = makeEthCallKey({
218
+ context: ethCallContext,
219
+ calldata,
220
+ });
221
+ const ret = preparedData.ethCallResults[key];
222
+ if (ret) {
223
+ const result = iface
224
+ .decodeFunctionResult("isApprovedForAll", ret)
225
+ .toArray();
226
+ return result.length == 1 ? result[0] : result;
227
+ }
228
+ }
166
229
  return await this.contract.getFunction(
167
230
  "isApprovedForAll(address,address)"
168
231
  )(account, operator, overrides || {});
@@ -174,9 +237,30 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
174
237
 
175
238
  async supportsInterface(
176
239
  interfaceId: BytesLike,
177
- overrides?: Overrides
240
+ overrides?: Overrides,
241
+ preparedData?: PreparedData,
242
+ ethCallContext?: EthCallContext
178
243
  ): Promise<boolean> {
179
244
  try {
245
+ if (preparedData?.ethCallResults && ethCallContext) {
246
+ const iface = new Interface([
247
+ "function supportsInterface(bytes4) view returns (bool)",
248
+ ]);
249
+ const calldata = iface.encodeFunctionData("supportsInterface", [
250
+ interfaceId,
251
+ ]);
252
+ const key = makeEthCallKey({
253
+ context: ethCallContext,
254
+ calldata,
255
+ });
256
+ const ret = preparedData.ethCallResults[key];
257
+ if (ret) {
258
+ const result = iface
259
+ .decodeFunctionResult("supportsInterface", ret)
260
+ .toArray();
261
+ return result.length == 1 ? result[0] : result;
262
+ }
263
+ }
180
264
  return await this.contract.getFunction("supportsInterface(bytes4)")(
181
265
  interfaceId,
182
266
  overrides || {}
@@ -187,8 +271,28 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
187
271
  }
188
272
  }
189
273
 
190
- async uri(id: BigNumberish, overrides?: Overrides): Promise<string> {
274
+ async uri(
275
+ id: BigNumberish,
276
+ overrides?: Overrides,
277
+ preparedData?: PreparedData,
278
+ ethCallContext?: EthCallContext
279
+ ): Promise<string> {
191
280
  try {
281
+ if (preparedData?.ethCallResults && ethCallContext) {
282
+ const iface = new Interface([
283
+ "function uri(uint256) view returns (string)",
284
+ ]);
285
+ const calldata = iface.encodeFunctionData("uri", [id]);
286
+ const key = makeEthCallKey({
287
+ context: ethCallContext,
288
+ calldata,
289
+ });
290
+ const ret = preparedData.ethCallResults[key];
291
+ if (ret) {
292
+ const result = iface.decodeFunctionResult("uri", ret).toArray();
293
+ return result.length == 1 ? result[0] : result;
294
+ }
295
+ }
192
296
  return await this.contract.getFunction("uri(uint256)")(
193
297
  id,
194
298
  overrides || {}
@@ -208,9 +312,34 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
208
312
  ids: BigNumberish[],
209
313
  amounts: BigNumberish[],
210
314
  data: BytesLike,
211
- overrides?: Overrides
315
+ overrides?: Overrides,
316
+ preparedData?: PreparedData,
317
+ ethCallContext?: EthCallContext
212
318
  ): Promise<void> {
213
319
  try {
320
+ if (preparedData?.ethCallResults && ethCallContext) {
321
+ const iface = new Interface([
322
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) nonpayable returns ()",
323
+ ]);
324
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
325
+ from,
326
+ to,
327
+ ids,
328
+ amounts,
329
+ data,
330
+ ]);
331
+ const key = makeEthCallKey({
332
+ context: ethCallContext,
333
+ calldata,
334
+ });
335
+ const ret = preparedData.ethCallResults[key];
336
+ if (ret) {
337
+ const result = iface
338
+ .decodeFunctionResult("safeBatchTransferFrom", ret)
339
+ .toArray();
340
+ return result.length == 1 ? result[0] : result;
341
+ }
342
+ }
214
343
  return await this.contract
215
344
  .getFunction(
216
345
  "safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)"
@@ -227,9 +356,34 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
227
356
  id: BigNumberish,
228
357
  amount: BigNumberish,
229
358
  data: BytesLike,
230
- overrides?: Overrides
359
+ overrides?: Overrides,
360
+ preparedData?: PreparedData,
361
+ ethCallContext?: EthCallContext
231
362
  ): Promise<void> {
232
363
  try {
364
+ if (preparedData?.ethCallResults && ethCallContext) {
365
+ const iface = new Interface([
366
+ "function safeTransferFrom(address,address,uint256,uint256,bytes) nonpayable returns ()",
367
+ ]);
368
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
369
+ from,
370
+ to,
371
+ id,
372
+ amount,
373
+ data,
374
+ ]);
375
+ const key = makeEthCallKey({
376
+ context: ethCallContext,
377
+ calldata,
378
+ });
379
+ const ret = preparedData.ethCallResults[key];
380
+ if (ret) {
381
+ const result = iface
382
+ .decodeFunctionResult("safeTransferFrom", ret)
383
+ .toArray();
384
+ return result.length == 1 ? result[0] : result;
385
+ }
386
+ }
233
387
  return await this.contract
234
388
  .getFunction(
235
389
  "safeTransferFrom(address,address,uint256,uint256,bytes)"
@@ -243,9 +397,31 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
243
397
  async setApprovalForAll(
244
398
  operator: string,
245
399
  approved: boolean,
246
- overrides?: Overrides
400
+ overrides?: Overrides,
401
+ preparedData?: PreparedData,
402
+ ethCallContext?: EthCallContext
247
403
  ): Promise<void> {
248
404
  try {
405
+ if (preparedData?.ethCallResults && ethCallContext) {
406
+ const iface = new Interface([
407
+ "function setApprovalForAll(address,bool) nonpayable returns ()",
408
+ ]);
409
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
410
+ operator,
411
+ approved,
412
+ ]);
413
+ const key = makeEthCallKey({
414
+ context: ethCallContext,
415
+ calldata,
416
+ });
417
+ const ret = preparedData.ethCallResults[key];
418
+ if (ret) {
419
+ const result = iface
420
+ .decodeFunctionResult("setApprovalForAll", ret)
421
+ .toArray();
422
+ return result.length == 1 ? result[0] : result;
423
+ }
424
+ }
249
425
  return await this.contract
250
426
  .getFunction("setApprovalForAll(address,bool)")
251
427
  .staticCall(operator, approved, overrides || {});
@@ -255,6 +431,179 @@ export class ERC1155ContractView extends ContractView<ERC1155> {
255
431
  }
256
432
  },
257
433
  };
434
+
435
+ encodeCall = {
436
+ balanceOf(
437
+ account: string,
438
+ id: BigNumberish,
439
+ ethCallContext: EthCallContext
440
+ ): EthCallParam {
441
+ try {
442
+ const iface = new Interface(["function balanceOf(address,uint256)"]);
443
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
444
+ return {
445
+ context: ethCallContext,
446
+ calldata,
447
+ };
448
+ } catch (e) {
449
+ const stack = new Error().stack;
450
+ throw transformEtherError(e, undefined, stack);
451
+ }
452
+ },
453
+ balanceOfBatch(
454
+ accounts: string[],
455
+ ids: BigNumberish[],
456
+ ethCallContext: EthCallContext
457
+ ): EthCallParam {
458
+ try {
459
+ const iface = new Interface([
460
+ "function balanceOfBatch(address[],uint256[])",
461
+ ]);
462
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
463
+ accounts,
464
+ ids,
465
+ ]);
466
+ return {
467
+ context: ethCallContext,
468
+ calldata,
469
+ };
470
+ } catch (e) {
471
+ const stack = new Error().stack;
472
+ throw transformEtherError(e, undefined, stack);
473
+ }
474
+ },
475
+ isApprovedForAll(
476
+ account: string,
477
+ operator: string,
478
+ ethCallContext: EthCallContext
479
+ ): EthCallParam {
480
+ try {
481
+ const iface = new Interface([
482
+ "function isApprovedForAll(address,address)",
483
+ ]);
484
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
485
+ account,
486
+ operator,
487
+ ]);
488
+ return {
489
+ context: ethCallContext,
490
+ calldata,
491
+ };
492
+ } catch (e) {
493
+ const stack = new Error().stack;
494
+ throw transformEtherError(e, undefined, stack);
495
+ }
496
+ },
497
+ safeBatchTransferFrom(
498
+ from: string,
499
+ to: string,
500
+ ids: BigNumberish[],
501
+ amounts: BigNumberish[],
502
+ data: BytesLike,
503
+ ethCallContext: EthCallContext
504
+ ): EthCallParam {
505
+ try {
506
+ const iface = new Interface([
507
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)",
508
+ ]);
509
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
510
+ from,
511
+ to,
512
+ ids,
513
+ amounts,
514
+ data,
515
+ ]);
516
+ return {
517
+ context: ethCallContext,
518
+ calldata,
519
+ };
520
+ } catch (e) {
521
+ const stack = new Error().stack;
522
+ throw transformEtherError(e, undefined, stack);
523
+ }
524
+ },
525
+ safeTransferFrom(
526
+ from: string,
527
+ to: string,
528
+ id: BigNumberish,
529
+ amount: BigNumberish,
530
+ data: BytesLike,
531
+ ethCallContext: EthCallContext
532
+ ): EthCallParam {
533
+ try {
534
+ const iface = new Interface([
535
+ "function safeTransferFrom(address,address,uint256,uint256,bytes)",
536
+ ]);
537
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
538
+ from,
539
+ to,
540
+ id,
541
+ amount,
542
+ data,
543
+ ]);
544
+ return {
545
+ context: ethCallContext,
546
+ calldata,
547
+ };
548
+ } catch (e) {
549
+ const stack = new Error().stack;
550
+ throw transformEtherError(e, undefined, stack);
551
+ }
552
+ },
553
+ setApprovalForAll(
554
+ operator: string,
555
+ approved: boolean,
556
+ ethCallContext: EthCallContext
557
+ ): EthCallParam {
558
+ try {
559
+ const iface = new Interface([
560
+ "function setApprovalForAll(address,bool)",
561
+ ]);
562
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
563
+ operator,
564
+ approved,
565
+ ]);
566
+ return {
567
+ context: ethCallContext,
568
+ calldata,
569
+ };
570
+ } catch (e) {
571
+ const stack = new Error().stack;
572
+ throw transformEtherError(e, undefined, stack);
573
+ }
574
+ },
575
+ supportsInterface(
576
+ interfaceId: BytesLike,
577
+ ethCallContext: EthCallContext
578
+ ): EthCallParam {
579
+ try {
580
+ const iface = new Interface(["function supportsInterface(bytes4)"]);
581
+ const calldata = iface.encodeFunctionData("supportsInterface", [
582
+ interfaceId,
583
+ ]);
584
+ return {
585
+ context: ethCallContext,
586
+ calldata,
587
+ };
588
+ } catch (e) {
589
+ const stack = new Error().stack;
590
+ throw transformEtherError(e, undefined, stack);
591
+ }
592
+ },
593
+ uri(id: BigNumberish, ethCallContext: EthCallContext): EthCallParam {
594
+ try {
595
+ const iface = new Interface(["function uri(uint256)"]);
596
+ const calldata = iface.encodeFunctionData("uri", [id]);
597
+ return {
598
+ context: ethCallContext,
599
+ calldata,
600
+ };
601
+ } catch (e) {
602
+ const stack = new Error().stack;
603
+ throw transformEtherError(e, undefined, stack);
604
+ }
605
+ },
606
+ };
258
607
  }
259
608
 
260
609
  export class ERC1155BoundContractView extends BoundContractView<
@@ -266,10 +615,21 @@ export class ERC1155BoundContractView extends BoundContractView<
266
615
  id: BigNumberish,
267
616
  overrides?: Overrides
268
617
  ): Promise<bigint> {
269
- return await this.view.balanceOf(account, id, {
270
- blockTag: this.context.blockNumber,
271
- ...overrides,
272
- });
618
+ const ethCallContext = {
619
+ chainId: this.context.chainId,
620
+ blockTag: "0x" + this.context.blockNumber.toString(16),
621
+ address: this.context.address,
622
+ };
623
+ return await this.view.balanceOf(
624
+ account,
625
+ id,
626
+ {
627
+ blockTag: this.context.blockNumber,
628
+ ...overrides,
629
+ },
630
+ this.context.preparedData,
631
+ ethCallContext
632
+ );
273
633
  }
274
634
 
275
635
  async balanceOfBatch(
@@ -277,10 +637,21 @@ export class ERC1155BoundContractView extends BoundContractView<
277
637
  ids: BigNumberish[],
278
638
  overrides?: Overrides
279
639
  ): Promise<bigint[]> {
280
- return await this.view.balanceOfBatch(accounts, ids, {
281
- blockTag: this.context.blockNumber,
282
- ...overrides,
283
- });
640
+ const ethCallContext = {
641
+ chainId: this.context.chainId,
642
+ blockTag: "0x" + this.context.blockNumber.toString(16),
643
+ address: this.context.address,
644
+ };
645
+ return await this.view.balanceOfBatch(
646
+ accounts,
647
+ ids,
648
+ {
649
+ blockTag: this.context.blockNumber,
650
+ ...overrides,
651
+ },
652
+ this.context.preparedData,
653
+ ethCallContext
654
+ );
284
655
  }
285
656
 
286
657
  async isApprovedForAll(
@@ -288,27 +659,58 @@ export class ERC1155BoundContractView extends BoundContractView<
288
659
  operator: string,
289
660
  overrides?: Overrides
290
661
  ): Promise<boolean> {
291
- return await this.view.isApprovedForAll(account, operator, {
292
- blockTag: this.context.blockNumber,
293
- ...overrides,
294
- });
662
+ const ethCallContext = {
663
+ chainId: this.context.chainId,
664
+ blockTag: "0x" + this.context.blockNumber.toString(16),
665
+ address: this.context.address,
666
+ };
667
+ return await this.view.isApprovedForAll(
668
+ account,
669
+ operator,
670
+ {
671
+ blockTag: this.context.blockNumber,
672
+ ...overrides,
673
+ },
674
+ this.context.preparedData,
675
+ ethCallContext
676
+ );
295
677
  }
296
678
 
297
679
  async supportsInterface(
298
680
  interfaceId: BytesLike,
299
681
  overrides?: Overrides
300
682
  ): Promise<boolean> {
301
- return await this.view.supportsInterface(interfaceId, {
302
- blockTag: this.context.blockNumber,
303
- ...overrides,
304
- });
683
+ const ethCallContext = {
684
+ chainId: this.context.chainId,
685
+ blockTag: "0x" + this.context.blockNumber.toString(16),
686
+ address: this.context.address,
687
+ };
688
+ return await this.view.supportsInterface(
689
+ interfaceId,
690
+ {
691
+ blockTag: this.context.blockNumber,
692
+ ...overrides,
693
+ },
694
+ this.context.preparedData,
695
+ ethCallContext
696
+ );
305
697
  }
306
698
 
307
699
  async uri(id: BigNumberish, overrides?: Overrides): Promise<string> {
308
- return await this.view.uri(id, {
309
- blockTag: this.context.blockNumber,
310
- ...overrides,
311
- });
700
+ const ethCallContext = {
701
+ chainId: this.context.chainId,
702
+ blockTag: "0x" + this.context.blockNumber.toString(16),
703
+ address: this.context.address,
704
+ };
705
+ return await this.view.uri(
706
+ id,
707
+ {
708
+ blockTag: this.context.blockNumber,
709
+ ...overrides,
710
+ },
711
+ this.context.preparedData,
712
+ ethCallContext
713
+ );
312
714
  }
313
715
 
314
716
  callStatic = {
@@ -323,6 +725,11 @@ export class ERC1155BoundContractView extends BoundContractView<
323
725
  data: BytesLike,
324
726
  overrides?: Overrides
325
727
  ): Promise<void> {
728
+ const ethCallContext = {
729
+ chainId: this.context.chainId,
730
+ blockTag: "0x" + this.context.blockNumber.toString(16),
731
+ address: this.context.address,
732
+ };
326
733
  return await this.view.callStatic.safeBatchTransferFrom(
327
734
  from,
328
735
  to,
@@ -332,7 +739,9 @@ export class ERC1155BoundContractView extends BoundContractView<
332
739
  {
333
740
  blockTag: this.context.blockNumber,
334
741
  ...overrides,
335
- }
742
+ },
743
+ this.context.preparedData,
744
+ ethCallContext
336
745
  );
337
746
  },
338
747
  async safeTransferFrom(
@@ -343,6 +752,11 @@ export class ERC1155BoundContractView extends BoundContractView<
343
752
  data: BytesLike,
344
753
  overrides?: Overrides
345
754
  ): Promise<void> {
755
+ const ethCallContext = {
756
+ chainId: this.context.chainId,
757
+ blockTag: "0x" + this.context.blockNumber.toString(16),
758
+ address: this.context.address,
759
+ };
346
760
  return await this.view.callStatic.safeTransferFrom(
347
761
  from,
348
762
  to,
@@ -352,7 +766,9 @@ export class ERC1155BoundContractView extends BoundContractView<
352
766
  {
353
767
  blockTag: this.context.blockNumber,
354
768
  ...overrides,
355
- }
769
+ },
770
+ this.context.preparedData,
771
+ ethCallContext
356
772
  );
357
773
  },
358
774
  async setApprovalForAll(
@@ -360,11 +776,204 @@ export class ERC1155BoundContractView extends BoundContractView<
360
776
  approved: boolean,
361
777
  overrides?: Overrides
362
778
  ): Promise<void> {
363
- return await this.view.callStatic.setApprovalForAll(operator, approved, {
364
- blockTag: this.context.blockNumber,
365
- ...overrides,
779
+ const ethCallContext = {
780
+ chainId: this.context.chainId,
781
+ blockTag: "0x" + this.context.blockNumber.toString(16),
782
+ address: this.context.address,
783
+ };
784
+ return await this.view.callStatic.setApprovalForAll(
785
+ operator,
786
+ approved,
787
+ {
788
+ blockTag: this.context.blockNumber,
789
+ ...overrides,
790
+ },
791
+ this.context.preparedData,
792
+ ethCallContext
793
+ );
794
+ },
795
+ };
796
+
797
+ encodeCall = {
798
+ view: this.view,
799
+ context: this.context,
800
+
801
+ balanceOf(
802
+ account: string,
803
+ id: BigNumberish,
804
+ overrides?: Overrides
805
+ ): EthCallParam {
806
+ const chainId =
807
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
808
+ const address = this.context.address;
809
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
810
+ if (overrides?.blockTag) {
811
+ blockTag =
812
+ typeof overrides.blockTag == "string"
813
+ ? overrides.blockTag
814
+ : "0x" + overrides.blockTag.toString(16);
815
+ }
816
+
817
+ return this.view.encodeCall.balanceOf(account, id, {
818
+ chainId,
819
+ address,
820
+ blockTag,
821
+ });
822
+ },
823
+ balanceOfBatch(
824
+ accounts: string[],
825
+ ids: BigNumberish[],
826
+ overrides?: Overrides
827
+ ): EthCallParam {
828
+ const chainId =
829
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
830
+ const address = this.context.address;
831
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
832
+ if (overrides?.blockTag) {
833
+ blockTag =
834
+ typeof overrides.blockTag == "string"
835
+ ? overrides.blockTag
836
+ : "0x" + overrides.blockTag.toString(16);
837
+ }
838
+
839
+ return this.view.encodeCall.balanceOfBatch(accounts, ids, {
840
+ chainId,
841
+ address,
842
+ blockTag,
843
+ });
844
+ },
845
+ isApprovedForAll(
846
+ account: string,
847
+ operator: string,
848
+ overrides?: Overrides
849
+ ): EthCallParam {
850
+ const chainId =
851
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
852
+ const address = this.context.address;
853
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
854
+ if (overrides?.blockTag) {
855
+ blockTag =
856
+ typeof overrides.blockTag == "string"
857
+ ? overrides.blockTag
858
+ : "0x" + overrides.blockTag.toString(16);
859
+ }
860
+
861
+ return this.view.encodeCall.isApprovedForAll(account, operator, {
862
+ chainId,
863
+ address,
864
+ blockTag,
865
+ });
866
+ },
867
+ safeBatchTransferFrom(
868
+ from: string,
869
+ to: string,
870
+ ids: BigNumberish[],
871
+ amounts: BigNumberish[],
872
+ data: BytesLike,
873
+ overrides?: Overrides
874
+ ): EthCallParam {
875
+ const chainId =
876
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
877
+ const address = this.context.address;
878
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
879
+ if (overrides?.blockTag) {
880
+ blockTag =
881
+ typeof overrides.blockTag == "string"
882
+ ? overrides.blockTag
883
+ : "0x" + overrides.blockTag.toString(16);
884
+ }
885
+
886
+ return this.view.encodeCall.safeBatchTransferFrom(
887
+ from,
888
+ to,
889
+ ids,
890
+ amounts,
891
+ data,
892
+ { chainId, address, blockTag }
893
+ );
894
+ },
895
+ safeTransferFrom(
896
+ from: string,
897
+ to: string,
898
+ id: BigNumberish,
899
+ amount: BigNumberish,
900
+ data: BytesLike,
901
+ overrides?: Overrides
902
+ ): EthCallParam {
903
+ const chainId =
904
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
905
+ const address = this.context.address;
906
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
907
+ if (overrides?.blockTag) {
908
+ blockTag =
909
+ typeof overrides.blockTag == "string"
910
+ ? overrides.blockTag
911
+ : "0x" + overrides.blockTag.toString(16);
912
+ }
913
+
914
+ return this.view.encodeCall.safeTransferFrom(from, to, id, amount, data, {
915
+ chainId,
916
+ address,
917
+ blockTag,
366
918
  });
367
919
  },
920
+ setApprovalForAll(
921
+ operator: string,
922
+ approved: boolean,
923
+ overrides?: Overrides
924
+ ): EthCallParam {
925
+ const chainId =
926
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
927
+ const address = this.context.address;
928
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
929
+ if (overrides?.blockTag) {
930
+ blockTag =
931
+ typeof overrides.blockTag == "string"
932
+ ? overrides.blockTag
933
+ : "0x" + overrides.blockTag.toString(16);
934
+ }
935
+
936
+ return this.view.encodeCall.setApprovalForAll(operator, approved, {
937
+ chainId,
938
+ address,
939
+ blockTag,
940
+ });
941
+ },
942
+ supportsInterface(
943
+ interfaceId: BytesLike,
944
+ overrides?: Overrides
945
+ ): EthCallParam {
946
+ const chainId =
947
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
948
+ const address = this.context.address;
949
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
950
+ if (overrides?.blockTag) {
951
+ blockTag =
952
+ typeof overrides.blockTag == "string"
953
+ ? overrides.blockTag
954
+ : "0x" + overrides.blockTag.toString(16);
955
+ }
956
+
957
+ return this.view.encodeCall.supportsInterface(interfaceId, {
958
+ chainId,
959
+ address,
960
+ blockTag,
961
+ });
962
+ },
963
+ uri(id: BigNumberish, overrides?: Overrides): EthCallParam {
964
+ const chainId =
965
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
966
+ const address = this.context.address;
967
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
968
+ if (overrides?.blockTag) {
969
+ blockTag =
970
+ typeof overrides.blockTag == "string"
971
+ ? overrides.blockTag
972
+ : "0x" + overrides.blockTag.toString(16);
973
+ }
974
+
975
+ return this.view.encodeCall.uri(id, { chainId, address, blockTag });
976
+ },
368
977
  };
369
978
  }
370
979
 
@@ -380,7 +989,8 @@ export class ERC1155Processor extends BaseProcessor<
380
989
  fetchConfig?: Partial<EthFetchConfig>,
381
990
  preprocessHandler?: (
382
991
  event: ApprovalForAllEvent,
383
- ctx: ERC1155Context
992
+ ctx: ERC1155Context,
993
+ preprocessStore: { [k: string]: any }
384
994
  ) => Promise<PreprocessResult>
385
995
  ): this {
386
996
  if (!filter) {
@@ -399,7 +1009,8 @@ export class ERC1155Processor extends BaseProcessor<
399
1009
  fetchConfig?: Partial<EthFetchConfig>,
400
1010
  preprocessHandler?: (
401
1011
  event: TransferBatchEvent,
402
- ctx: ERC1155Context
1012
+ ctx: ERC1155Context,
1013
+ preprocessStore: { [k: string]: any }
403
1014
  ) => Promise<PreprocessResult>
404
1015
  ): this {
405
1016
  if (!filter) {
@@ -416,7 +1027,8 @@ export class ERC1155Processor extends BaseProcessor<
416
1027
  fetchConfig?: Partial<EthFetchConfig>,
417
1028
  preprocessHandler?: (
418
1029
  event: TransferSingleEvent,
419
- ctx: ERC1155Context
1030
+ ctx: ERC1155Context,
1031
+ preprocessStore: { [k: string]: any }
420
1032
  ) => Promise<PreprocessResult>
421
1033
  ): this {
422
1034
  if (!filter) {
@@ -433,7 +1045,8 @@ export class ERC1155Processor extends BaseProcessor<
433
1045
  fetchConfig?: Partial<EthFetchConfig>,
434
1046
  preprocessHandler?: (
435
1047
  event: URIEvent,
436
- ctx: ERC1155Context
1048
+ ctx: ERC1155Context,
1049
+ preprocessStore: { [k: string]: any }
437
1050
  ) => Promise<PreprocessResult>
438
1051
  ): this {
439
1052
  if (!filter) {
@@ -652,7 +1265,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
652
1265
  fetchConfig?: Partial<EthFetchConfig>,
653
1266
  preprocessHandler?: (
654
1267
  event: ApprovalForAllEvent,
655
- ctx: ERC1155Context
1268
+ ctx: ERC1155Context,
1269
+ preprocessStore: { [k: string]: any }
656
1270
  ) => Promise<PreprocessResult>
657
1271
  ): this {
658
1272
  if (!filter) {
@@ -671,7 +1285,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
671
1285
  fetchConfig?: Partial<EthFetchConfig>,
672
1286
  preprocessHandler?: (
673
1287
  event: TransferBatchEvent,
674
- ctx: ERC1155Context
1288
+ ctx: ERC1155Context,
1289
+ preprocessStore: { [k: string]: any }
675
1290
  ) => Promise<PreprocessResult>
676
1291
  ): this {
677
1292
  if (!filter) {
@@ -688,7 +1303,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
688
1303
  fetchConfig?: Partial<EthFetchConfig>,
689
1304
  preprocessHandler?: (
690
1305
  event: TransferSingleEvent,
691
- ctx: ERC1155Context
1306
+ ctx: ERC1155Context,
1307
+ preprocessStore: { [k: string]: any }
692
1308
  ) => Promise<PreprocessResult>
693
1309
  ): this {
694
1310
  if (!filter) {
@@ -705,7 +1321,8 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
705
1321
  fetchConfig?: Partial<EthFetchConfig>,
706
1322
  preprocessHandler?: (
707
1323
  event: URIEvent,
708
- ctx: ERC1155Context
1324
+ ctx: ERC1155Context,
1325
+ preprocessStore: { [k: string]: any }
709
1326
  ) => Promise<PreprocessResult>
710
1327
  ): this {
711
1328
  if (!filter) {