@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 } from "ethers";
4
+ import { BigNumberish, Overrides, 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 { ERC20Bytes__factory } from "./index.js";
27
29
  import {
@@ -103,8 +105,25 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
103
105
  this.callStatic.contract = contract;
104
106
  }
105
107
 
106
- async name(overrides?: Overrides): Promise<string> {
108
+ async name(
109
+ overrides?: Overrides,
110
+ preparedData?: PreparedData,
111
+ ethCallContext?: EthCallContext
112
+ ): Promise<string> {
107
113
  try {
114
+ if (preparedData?.ethCallResults && ethCallContext) {
115
+ const iface = new Interface(["function name() view returns (bytes32)"]);
116
+ const calldata = iface.encodeFunctionData("name", []);
117
+ const key = makeEthCallKey({
118
+ context: ethCallContext,
119
+ calldata,
120
+ });
121
+ const ret = preparedData.ethCallResults[key];
122
+ if (ret) {
123
+ const result = iface.decodeFunctionResult("name", ret).toArray();
124
+ return result.length == 1 ? result[0] : result;
125
+ }
126
+ }
108
127
  return await this.contract.getFunction("name()")(overrides || {});
109
128
  } catch (e) {
110
129
  const stack = new Error().stack;
@@ -112,8 +131,29 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
112
131
  }
113
132
  }
114
133
 
115
- async totalSupply(overrides?: Overrides): Promise<bigint> {
134
+ async totalSupply(
135
+ overrides?: Overrides,
136
+ preparedData?: PreparedData,
137
+ ethCallContext?: EthCallContext
138
+ ): Promise<bigint> {
116
139
  try {
140
+ if (preparedData?.ethCallResults && ethCallContext) {
141
+ const iface = new Interface([
142
+ "function totalSupply() view returns (uint256)",
143
+ ]);
144
+ const calldata = iface.encodeFunctionData("totalSupply", []);
145
+ const key = makeEthCallKey({
146
+ context: ethCallContext,
147
+ calldata,
148
+ });
149
+ const ret = preparedData.ethCallResults[key];
150
+ if (ret) {
151
+ const result = iface
152
+ .decodeFunctionResult("totalSupply", ret)
153
+ .toArray();
154
+ return result.length == 1 ? result[0] : result;
155
+ }
156
+ }
117
157
  return await this.contract.getFunction("totalSupply()")(overrides || {});
118
158
  } catch (e) {
119
159
  const stack = new Error().stack;
@@ -121,8 +161,27 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
121
161
  }
122
162
  }
123
163
 
124
- async decimals(overrides?: Overrides): Promise<bigint> {
164
+ async decimals(
165
+ overrides?: Overrides,
166
+ preparedData?: PreparedData,
167
+ ethCallContext?: EthCallContext
168
+ ): Promise<bigint> {
125
169
  try {
170
+ if (preparedData?.ethCallResults && ethCallContext) {
171
+ const iface = new Interface([
172
+ "function decimals() view returns (uint8)",
173
+ ]);
174
+ const calldata = iface.encodeFunctionData("decimals", []);
175
+ const key = makeEthCallKey({
176
+ context: ethCallContext,
177
+ calldata,
178
+ });
179
+ const ret = preparedData.ethCallResults[key];
180
+ if (ret) {
181
+ const result = iface.decodeFunctionResult("decimals", ret).toArray();
182
+ return result.length == 1 ? result[0] : result;
183
+ }
184
+ }
126
185
  return await this.contract.getFunction("decimals()")(overrides || {});
127
186
  } catch (e) {
128
187
  const stack = new Error().stack;
@@ -130,8 +189,28 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
130
189
  }
131
190
  }
132
191
 
133
- async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
192
+ async balanceOf(
193
+ who: string,
194
+ overrides?: Overrides,
195
+ preparedData?: PreparedData,
196
+ ethCallContext?: EthCallContext
197
+ ): Promise<bigint> {
134
198
  try {
199
+ if (preparedData?.ethCallResults && ethCallContext) {
200
+ const iface = new Interface([
201
+ "function balanceOf(address) view returns (uint256)",
202
+ ]);
203
+ const calldata = iface.encodeFunctionData("balanceOf", [who]);
204
+ const key = makeEthCallKey({
205
+ context: ethCallContext,
206
+ calldata,
207
+ });
208
+ const ret = preparedData.ethCallResults[key];
209
+ if (ret) {
210
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
211
+ return result.length == 1 ? result[0] : result;
212
+ }
213
+ }
135
214
  return await this.contract.getFunction("balanceOf(address)")(
136
215
  who,
137
216
  overrides || {}
@@ -142,8 +221,27 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
142
221
  }
143
222
  }
144
223
 
145
- async symbol(overrides?: Overrides): Promise<string> {
224
+ async symbol(
225
+ overrides?: Overrides,
226
+ preparedData?: PreparedData,
227
+ ethCallContext?: EthCallContext
228
+ ): Promise<string> {
146
229
  try {
230
+ if (preparedData?.ethCallResults && ethCallContext) {
231
+ const iface = new Interface([
232
+ "function symbol() view returns (bytes32)",
233
+ ]);
234
+ const calldata = iface.encodeFunctionData("symbol", []);
235
+ const key = makeEthCallKey({
236
+ context: ethCallContext,
237
+ calldata,
238
+ });
239
+ const ret = preparedData.ethCallResults[key];
240
+ if (ret) {
241
+ const result = iface.decodeFunctionResult("symbol", ret).toArray();
242
+ return result.length == 1 ? result[0] : result;
243
+ }
244
+ }
147
245
  return await this.contract.getFunction("symbol()")(overrides || {});
148
246
  } catch (e) {
149
247
  const stack = new Error().stack;
@@ -154,9 +252,29 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
154
252
  async allowance(
155
253
  owner: string,
156
254
  spender: string,
157
- overrides?: Overrides
255
+ overrides?: Overrides,
256
+ preparedData?: PreparedData,
257
+ ethCallContext?: EthCallContext
158
258
  ): Promise<bigint> {
159
259
  try {
260
+ if (preparedData?.ethCallResults && ethCallContext) {
261
+ const iface = new Interface([
262
+ "function allowance(address,address) view returns (uint256)",
263
+ ]);
264
+ const calldata = iface.encodeFunctionData("allowance", [
265
+ owner,
266
+ spender,
267
+ ]);
268
+ const key = makeEthCallKey({
269
+ context: ethCallContext,
270
+ calldata,
271
+ });
272
+ const ret = preparedData.ethCallResults[key];
273
+ if (ret) {
274
+ const result = iface.decodeFunctionResult("allowance", ret).toArray();
275
+ return result.length == 1 ? result[0] : result;
276
+ }
277
+ }
160
278
  return await this.contract.getFunction("allowance(address,address)")(
161
279
  owner,
162
280
  spender,
@@ -174,9 +292,29 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
174
292
  async approve(
175
293
  spender: string,
176
294
  value: BigNumberish,
177
- overrides?: Overrides
295
+ overrides?: Overrides,
296
+ preparedData?: PreparedData,
297
+ ethCallContext?: EthCallContext
178
298
  ): Promise<boolean> {
179
299
  try {
300
+ if (preparedData?.ethCallResults && ethCallContext) {
301
+ const iface = new Interface([
302
+ "function approve(address,uint256) nonpayable returns (bool)",
303
+ ]);
304
+ const calldata = iface.encodeFunctionData("approve", [
305
+ spender,
306
+ value,
307
+ ]);
308
+ const key = makeEthCallKey({
309
+ context: ethCallContext,
310
+ calldata,
311
+ });
312
+ const ret = preparedData.ethCallResults[key];
313
+ if (ret) {
314
+ const result = iface.decodeFunctionResult("approve", ret).toArray();
315
+ return result.length == 1 ? result[0] : result;
316
+ }
317
+ }
180
318
  return await this.contract
181
319
  .getFunction("approve(address,uint256)")
182
320
  .staticCall(spender, value, overrides || {});
@@ -189,9 +327,32 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
189
327
  from: string,
190
328
  to: string,
191
329
  value: BigNumberish,
192
- overrides?: Overrides
330
+ overrides?: Overrides,
331
+ preparedData?: PreparedData,
332
+ ethCallContext?: EthCallContext
193
333
  ): Promise<boolean> {
194
334
  try {
335
+ if (preparedData?.ethCallResults && ethCallContext) {
336
+ const iface = new Interface([
337
+ "function transferFrom(address,address,uint256) nonpayable returns (bool)",
338
+ ]);
339
+ const calldata = iface.encodeFunctionData("transferFrom", [
340
+ from,
341
+ to,
342
+ value,
343
+ ]);
344
+ const key = makeEthCallKey({
345
+ context: ethCallContext,
346
+ calldata,
347
+ });
348
+ const ret = preparedData.ethCallResults[key];
349
+ if (ret) {
350
+ const result = iface
351
+ .decodeFunctionResult("transferFrom", ret)
352
+ .toArray();
353
+ return result.length == 1 ? result[0] : result;
354
+ }
355
+ }
195
356
  return await this.contract
196
357
  .getFunction("transferFrom(address,address,uint256)")
197
358
  .staticCall(from, to, value, overrides || {});
@@ -203,9 +364,28 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
203
364
  async transfer(
204
365
  to: string,
205
366
  value: BigNumberish,
206
- overrides?: Overrides
367
+ overrides?: Overrides,
368
+ preparedData?: PreparedData,
369
+ ethCallContext?: EthCallContext
207
370
  ): Promise<boolean> {
208
371
  try {
372
+ if (preparedData?.ethCallResults && ethCallContext) {
373
+ const iface = new Interface([
374
+ "function transfer(address,uint256) nonpayable returns (bool)",
375
+ ]);
376
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
377
+ const key = makeEthCallKey({
378
+ context: ethCallContext,
379
+ calldata,
380
+ });
381
+ const ret = preparedData.ethCallResults[key];
382
+ if (ret) {
383
+ const result = iface
384
+ .decodeFunctionResult("transfer", ret)
385
+ .toArray();
386
+ return result.length == 1 ? result[0] : result;
387
+ }
388
+ }
209
389
  return await this.contract
210
390
  .getFunction("transfer(address,uint256)")
211
391
  .staticCall(to, value, overrides || {});
@@ -215,6 +395,152 @@ export class ERC20BytesContractView extends ContractView<ERC20Bytes> {
215
395
  }
216
396
  },
217
397
  };
398
+
399
+ encodeCall = {
400
+ name(ethCallContext: EthCallContext): EthCallParam {
401
+ try {
402
+ const iface = new Interface(["function name()"]);
403
+ const calldata = iface.encodeFunctionData("name", []);
404
+ return {
405
+ context: ethCallContext,
406
+ calldata,
407
+ };
408
+ } catch (e) {
409
+ const stack = new Error().stack;
410
+ throw transformEtherError(e, undefined, stack);
411
+ }
412
+ },
413
+ approve(
414
+ spender: string,
415
+ value: BigNumberish,
416
+ ethCallContext: EthCallContext
417
+ ): EthCallParam {
418
+ try {
419
+ const iface = new Interface(["function approve(address,uint256)"]);
420
+ const calldata = iface.encodeFunctionData("approve", [spender, value]);
421
+ return {
422
+ context: ethCallContext,
423
+ calldata,
424
+ };
425
+ } catch (e) {
426
+ const stack = new Error().stack;
427
+ throw transformEtherError(e, undefined, stack);
428
+ }
429
+ },
430
+ totalSupply(ethCallContext: EthCallContext): EthCallParam {
431
+ try {
432
+ const iface = new Interface(["function totalSupply()"]);
433
+ const calldata = iface.encodeFunctionData("totalSupply", []);
434
+ return {
435
+ context: ethCallContext,
436
+ calldata,
437
+ };
438
+ } catch (e) {
439
+ const stack = new Error().stack;
440
+ throw transformEtherError(e, undefined, stack);
441
+ }
442
+ },
443
+ transferFrom(
444
+ from: string,
445
+ to: string,
446
+ value: BigNumberish,
447
+ ethCallContext: EthCallContext
448
+ ): EthCallParam {
449
+ try {
450
+ const iface = new Interface([
451
+ "function transferFrom(address,address,uint256)",
452
+ ]);
453
+ const calldata = iface.encodeFunctionData("transferFrom", [
454
+ from,
455
+ to,
456
+ value,
457
+ ]);
458
+ return {
459
+ context: ethCallContext,
460
+ calldata,
461
+ };
462
+ } catch (e) {
463
+ const stack = new Error().stack;
464
+ throw transformEtherError(e, undefined, stack);
465
+ }
466
+ },
467
+ decimals(ethCallContext: EthCallContext): EthCallParam {
468
+ try {
469
+ const iface = new Interface(["function decimals()"]);
470
+ const calldata = iface.encodeFunctionData("decimals", []);
471
+ return {
472
+ context: ethCallContext,
473
+ calldata,
474
+ };
475
+ } catch (e) {
476
+ const stack = new Error().stack;
477
+ throw transformEtherError(e, undefined, stack);
478
+ }
479
+ },
480
+ balanceOf(who: string, ethCallContext: EthCallContext): EthCallParam {
481
+ try {
482
+ const iface = new Interface(["function balanceOf(address)"]);
483
+ const calldata = iface.encodeFunctionData("balanceOf", [who]);
484
+ return {
485
+ context: ethCallContext,
486
+ calldata,
487
+ };
488
+ } catch (e) {
489
+ const stack = new Error().stack;
490
+ throw transformEtherError(e, undefined, stack);
491
+ }
492
+ },
493
+ symbol(ethCallContext: EthCallContext): EthCallParam {
494
+ try {
495
+ const iface = new Interface(["function symbol()"]);
496
+ const calldata = iface.encodeFunctionData("symbol", []);
497
+ return {
498
+ context: ethCallContext,
499
+ calldata,
500
+ };
501
+ } catch (e) {
502
+ const stack = new Error().stack;
503
+ throw transformEtherError(e, undefined, stack);
504
+ }
505
+ },
506
+ transfer(
507
+ to: string,
508
+ value: BigNumberish,
509
+ ethCallContext: EthCallContext
510
+ ): EthCallParam {
511
+ try {
512
+ const iface = new Interface(["function transfer(address,uint256)"]);
513
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
514
+ return {
515
+ context: ethCallContext,
516
+ calldata,
517
+ };
518
+ } catch (e) {
519
+ const stack = new Error().stack;
520
+ throw transformEtherError(e, undefined, stack);
521
+ }
522
+ },
523
+ allowance(
524
+ owner: string,
525
+ spender: string,
526
+ ethCallContext: EthCallContext
527
+ ): EthCallParam {
528
+ try {
529
+ const iface = new Interface(["function allowance(address,address)"]);
530
+ const calldata = iface.encodeFunctionData("allowance", [
531
+ owner,
532
+ spender,
533
+ ]);
534
+ return {
535
+ context: ethCallContext,
536
+ calldata,
537
+ };
538
+ } catch (e) {
539
+ const stack = new Error().stack;
540
+ throw transformEtherError(e, undefined, stack);
541
+ }
542
+ },
543
+ };
218
544
  }
219
545
 
220
546
  export class ERC20BytesBoundContractView extends BoundContractView<
@@ -222,38 +548,84 @@ export class ERC20BytesBoundContractView extends BoundContractView<
222
548
  ERC20BytesContractView
223
549
  > {
224
550
  async name(overrides?: Overrides): Promise<string> {
225
- return await this.view.name({
226
- blockTag: this.context.blockNumber,
227
- ...overrides,
228
- });
551
+ const ethCallContext = {
552
+ chainId: this.context.chainId,
553
+ blockTag: "0x" + this.context.blockNumber.toString(16),
554
+ address: this.context.address,
555
+ };
556
+ return await this.view.name(
557
+ {
558
+ blockTag: this.context.blockNumber,
559
+ ...overrides,
560
+ },
561
+ this.context.preparedData,
562
+ ethCallContext
563
+ );
229
564
  }
230
565
 
231
566
  async totalSupply(overrides?: Overrides): Promise<bigint> {
232
- return await this.view.totalSupply({
233
- blockTag: this.context.blockNumber,
234
- ...overrides,
235
- });
567
+ const ethCallContext = {
568
+ chainId: this.context.chainId,
569
+ blockTag: "0x" + this.context.blockNumber.toString(16),
570
+ address: this.context.address,
571
+ };
572
+ return await this.view.totalSupply(
573
+ {
574
+ blockTag: this.context.blockNumber,
575
+ ...overrides,
576
+ },
577
+ this.context.preparedData,
578
+ ethCallContext
579
+ );
236
580
  }
237
581
 
238
582
  async decimals(overrides?: Overrides): Promise<bigint> {
239
- return await this.view.decimals({
240
- blockTag: this.context.blockNumber,
241
- ...overrides,
242
- });
583
+ const ethCallContext = {
584
+ chainId: this.context.chainId,
585
+ blockTag: "0x" + this.context.blockNumber.toString(16),
586
+ address: this.context.address,
587
+ };
588
+ return await this.view.decimals(
589
+ {
590
+ blockTag: this.context.blockNumber,
591
+ ...overrides,
592
+ },
593
+ this.context.preparedData,
594
+ ethCallContext
595
+ );
243
596
  }
244
597
 
245
598
  async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
246
- return await this.view.balanceOf(who, {
247
- blockTag: this.context.blockNumber,
248
- ...overrides,
249
- });
599
+ const ethCallContext = {
600
+ chainId: this.context.chainId,
601
+ blockTag: "0x" + this.context.blockNumber.toString(16),
602
+ address: this.context.address,
603
+ };
604
+ return await this.view.balanceOf(
605
+ who,
606
+ {
607
+ blockTag: this.context.blockNumber,
608
+ ...overrides,
609
+ },
610
+ this.context.preparedData,
611
+ ethCallContext
612
+ );
250
613
  }
251
614
 
252
615
  async symbol(overrides?: Overrides): Promise<string> {
253
- return await this.view.symbol({
254
- blockTag: this.context.blockNumber,
255
- ...overrides,
256
- });
616
+ const ethCallContext = {
617
+ chainId: this.context.chainId,
618
+ blockTag: "0x" + this.context.blockNumber.toString(16),
619
+ address: this.context.address,
620
+ };
621
+ return await this.view.symbol(
622
+ {
623
+ blockTag: this.context.blockNumber,
624
+ ...overrides,
625
+ },
626
+ this.context.preparedData,
627
+ ethCallContext
628
+ );
257
629
  }
258
630
 
259
631
  async allowance(
@@ -261,10 +633,21 @@ export class ERC20BytesBoundContractView extends BoundContractView<
261
633
  spender: string,
262
634
  overrides?: Overrides
263
635
  ): Promise<bigint> {
264
- return await this.view.allowance(owner, spender, {
265
- blockTag: this.context.blockNumber,
266
- ...overrides,
267
- });
636
+ const ethCallContext = {
637
+ chainId: this.context.chainId,
638
+ blockTag: "0x" + this.context.blockNumber.toString(16),
639
+ address: this.context.address,
640
+ };
641
+ return await this.view.allowance(
642
+ owner,
643
+ spender,
644
+ {
645
+ blockTag: this.context.blockNumber,
646
+ ...overrides,
647
+ },
648
+ this.context.preparedData,
649
+ ethCallContext
650
+ );
268
651
  }
269
652
 
270
653
  callStatic = {
@@ -276,10 +659,21 @@ export class ERC20BytesBoundContractView extends BoundContractView<
276
659
  value: BigNumberish,
277
660
  overrides?: Overrides
278
661
  ): Promise<boolean> {
279
- return await this.view.callStatic.approve(spender, value, {
280
- blockTag: this.context.blockNumber,
281
- ...overrides,
282
- });
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.callStatic.approve(
668
+ spender,
669
+ value,
670
+ {
671
+ blockTag: this.context.blockNumber,
672
+ ...overrides,
673
+ },
674
+ this.context.preparedData,
675
+ ethCallContext
676
+ );
283
677
  },
284
678
  async transferFrom(
285
679
  from: string,
@@ -287,19 +681,211 @@ export class ERC20BytesBoundContractView extends BoundContractView<
287
681
  value: BigNumberish,
288
682
  overrides?: Overrides
289
683
  ): Promise<boolean> {
290
- return await this.view.callStatic.transferFrom(from, to, value, {
291
- blockTag: this.context.blockNumber,
292
- ...overrides,
293
- });
684
+ const ethCallContext = {
685
+ chainId: this.context.chainId,
686
+ blockTag: "0x" + this.context.blockNumber.toString(16),
687
+ address: this.context.address,
688
+ };
689
+ return await this.view.callStatic.transferFrom(
690
+ from,
691
+ to,
692
+ value,
693
+ {
694
+ blockTag: this.context.blockNumber,
695
+ ...overrides,
696
+ },
697
+ this.context.preparedData,
698
+ ethCallContext
699
+ );
294
700
  },
295
701
  async transfer(
296
702
  to: string,
297
703
  value: BigNumberish,
298
704
  overrides?: Overrides
299
705
  ): Promise<boolean> {
300
- return await this.view.callStatic.transfer(to, value, {
301
- blockTag: this.context.blockNumber,
302
- ...overrides,
706
+ const ethCallContext = {
707
+ chainId: this.context.chainId,
708
+ blockTag: "0x" + this.context.blockNumber.toString(16),
709
+ address: this.context.address,
710
+ };
711
+ return await this.view.callStatic.transfer(
712
+ to,
713
+ value,
714
+ {
715
+ blockTag: this.context.blockNumber,
716
+ ...overrides,
717
+ },
718
+ this.context.preparedData,
719
+ ethCallContext
720
+ );
721
+ },
722
+ };
723
+
724
+ encodeCall = {
725
+ view: this.view,
726
+ context: this.context,
727
+
728
+ name(overrides?: Overrides): EthCallParam {
729
+ const chainId =
730
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
731
+ const address = this.context.address;
732
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
733
+ if (overrides?.blockTag) {
734
+ blockTag =
735
+ typeof overrides.blockTag == "string"
736
+ ? overrides.blockTag
737
+ : "0x" + overrides.blockTag.toString(16);
738
+ }
739
+
740
+ return this.view.encodeCall.name({ chainId, address, blockTag });
741
+ },
742
+ approve(
743
+ spender: string,
744
+ value: BigNumberish,
745
+ overrides?: Overrides
746
+ ): EthCallParam {
747
+ const chainId =
748
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
749
+ const address = this.context.address;
750
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
751
+ if (overrides?.blockTag) {
752
+ blockTag =
753
+ typeof overrides.blockTag == "string"
754
+ ? overrides.blockTag
755
+ : "0x" + overrides.blockTag.toString(16);
756
+ }
757
+
758
+ return this.view.encodeCall.approve(spender, value, {
759
+ chainId,
760
+ address,
761
+ blockTag,
762
+ });
763
+ },
764
+ totalSupply(overrides?: Overrides): EthCallParam {
765
+ const chainId =
766
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
767
+ const address = this.context.address;
768
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
769
+ if (overrides?.blockTag) {
770
+ blockTag =
771
+ typeof overrides.blockTag == "string"
772
+ ? overrides.blockTag
773
+ : "0x" + overrides.blockTag.toString(16);
774
+ }
775
+
776
+ return this.view.encodeCall.totalSupply({ chainId, address, blockTag });
777
+ },
778
+ transferFrom(
779
+ from: string,
780
+ to: string,
781
+ value: BigNumberish,
782
+ overrides?: Overrides
783
+ ): EthCallParam {
784
+ const chainId =
785
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
786
+ const address = this.context.address;
787
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
788
+ if (overrides?.blockTag) {
789
+ blockTag =
790
+ typeof overrides.blockTag == "string"
791
+ ? overrides.blockTag
792
+ : "0x" + overrides.blockTag.toString(16);
793
+ }
794
+
795
+ return this.view.encodeCall.transferFrom(from, to, value, {
796
+ chainId,
797
+ address,
798
+ blockTag,
799
+ });
800
+ },
801
+ decimals(overrides?: Overrides): EthCallParam {
802
+ const chainId =
803
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
804
+ const address = this.context.address;
805
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
806
+ if (overrides?.blockTag) {
807
+ blockTag =
808
+ typeof overrides.blockTag == "string"
809
+ ? overrides.blockTag
810
+ : "0x" + overrides.blockTag.toString(16);
811
+ }
812
+
813
+ return this.view.encodeCall.decimals({ chainId, address, blockTag });
814
+ },
815
+ balanceOf(who: string, overrides?: Overrides): EthCallParam {
816
+ const chainId =
817
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
818
+ const address = this.context.address;
819
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
820
+ if (overrides?.blockTag) {
821
+ blockTag =
822
+ typeof overrides.blockTag == "string"
823
+ ? overrides.blockTag
824
+ : "0x" + overrides.blockTag.toString(16);
825
+ }
826
+
827
+ return this.view.encodeCall.balanceOf(who, {
828
+ chainId,
829
+ address,
830
+ blockTag,
831
+ });
832
+ },
833
+ symbol(overrides?: Overrides): EthCallParam {
834
+ const chainId =
835
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
836
+ const address = this.context.address;
837
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
838
+ if (overrides?.blockTag) {
839
+ blockTag =
840
+ typeof overrides.blockTag == "string"
841
+ ? overrides.blockTag
842
+ : "0x" + overrides.blockTag.toString(16);
843
+ }
844
+
845
+ return this.view.encodeCall.symbol({ chainId, address, blockTag });
846
+ },
847
+ transfer(
848
+ to: string,
849
+ value: BigNumberish,
850
+ overrides?: Overrides
851
+ ): EthCallParam {
852
+ const chainId =
853
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
854
+ const address = this.context.address;
855
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
856
+ if (overrides?.blockTag) {
857
+ blockTag =
858
+ typeof overrides.blockTag == "string"
859
+ ? overrides.blockTag
860
+ : "0x" + overrides.blockTag.toString(16);
861
+ }
862
+
863
+ return this.view.encodeCall.transfer(to, value, {
864
+ chainId,
865
+ address,
866
+ blockTag,
867
+ });
868
+ },
869
+ allowance(
870
+ owner: string,
871
+ spender: string,
872
+ overrides?: Overrides
873
+ ): EthCallParam {
874
+ const chainId =
875
+ overrides?.chainId?.toString() ?? this.context.chainId.toString();
876
+ const address = this.context.address;
877
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
878
+ if (overrides?.blockTag) {
879
+ blockTag =
880
+ typeof overrides.blockTag == "string"
881
+ ? overrides.blockTag
882
+ : "0x" + overrides.blockTag.toString(16);
883
+ }
884
+
885
+ return this.view.encodeCall.allowance(owner, spender, {
886
+ chainId,
887
+ address,
888
+ blockTag,
303
889
  });
304
890
  },
305
891
  };
@@ -320,7 +906,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
320
906
  fetchConfig?: Partial<EthFetchConfig>,
321
907
  preprocessHandler?: (
322
908
  event: ApprovalEvent,
323
- ctx: ERC20BytesContext
909
+ ctx: ERC20BytesContext,
910
+ preprocessStore: { [k: string]: any }
324
911
  ) => Promise<PreprocessResult>
325
912
  ): this {
326
913
  if (!filter) {
@@ -339,7 +926,8 @@ export class ERC20BytesProcessor extends BaseProcessor<
339
926
  fetchConfig?: Partial<EthFetchConfig>,
340
927
  preprocessHandler?: (
341
928
  event: TransferEvent,
342
- ctx: ERC20BytesContext
929
+ ctx: ERC20BytesContext,
930
+ preprocessStore: { [k: string]: any }
343
931
  ) => Promise<PreprocessResult>
344
932
  ): this {
345
933
  if (!filter) {
@@ -564,7 +1152,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
564
1152
  fetchConfig?: Partial<EthFetchConfig>,
565
1153
  preprocessHandler?: (
566
1154
  event: ApprovalEvent,
567
- ctx: ERC20BytesContext
1155
+ ctx: ERC20BytesContext,
1156
+ preprocessStore: { [k: string]: any }
568
1157
  ) => Promise<PreprocessResult>
569
1158
  ): this {
570
1159
  if (!filter) {
@@ -583,7 +1172,8 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
583
1172
  fetchConfig?: Partial<EthFetchConfig>,
584
1173
  preprocessHandler?: (
585
1174
  event: TransferEvent,
586
- ctx: ERC20BytesContext
1175
+ ctx: ERC20BytesContext,
1176
+ preprocessStore: { [k: string]: any }
587
1177
  ) => Promise<PreprocessResult>
588
1178
  ): this {
589
1179
  if (!filter) {