@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,4 +1,8 @@
1
- import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider, } from "@sentio/sdk/eth";
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ import { Interface } from "ethers";
5
+ import { addContractByABI, getContractByABI, addProcessor, getProcessor, getProvider, transformEtherError, BaseProcessor, BaseProcessorTemplate, BoundContractView, ContractView, DummyProvider, makeEthCallKey, } from "@sentio/sdk/eth";
2
6
  import { WETH9__factory } from "./index.js";
3
7
  const templateContract = WETH9__factory.connect("0x0", DummyProvider);
4
8
  export class WETH9ContractView extends ContractView {
@@ -6,8 +10,21 @@ export class WETH9ContractView extends ContractView {
6
10
  super(contract);
7
11
  this.callStatic.contract = contract;
8
12
  }
9
- async name(overrides) {
13
+ async name(overrides, preparedData, ethCallContext) {
10
14
  try {
15
+ if (preparedData?.ethCallResults && ethCallContext) {
16
+ const iface = new Interface(["function name() view returns (string)"]);
17
+ const calldata = iface.encodeFunctionData("name", []);
18
+ const key = makeEthCallKey({
19
+ context: ethCallContext,
20
+ calldata,
21
+ });
22
+ const ret = preparedData.ethCallResults[key];
23
+ if (ret) {
24
+ const result = iface.decodeFunctionResult("name", ret).toArray();
25
+ return result.length == 1 ? result[0] : result;
26
+ }
27
+ }
11
28
  return await this.contract.getFunction("name()")(overrides || {});
12
29
  }
13
30
  catch (e) {
@@ -15,8 +32,25 @@ export class WETH9ContractView extends ContractView {
15
32
  throw transformEtherError(e, undefined, stack);
16
33
  }
17
34
  }
18
- async totalSupply(overrides) {
35
+ async totalSupply(overrides, preparedData, ethCallContext) {
19
36
  try {
37
+ if (preparedData?.ethCallResults && ethCallContext) {
38
+ const iface = new Interface([
39
+ "function totalSupply() view returns (uint256)",
40
+ ]);
41
+ const calldata = iface.encodeFunctionData("totalSupply", []);
42
+ const key = makeEthCallKey({
43
+ context: ethCallContext,
44
+ calldata,
45
+ });
46
+ const ret = preparedData.ethCallResults[key];
47
+ if (ret) {
48
+ const result = iface
49
+ .decodeFunctionResult("totalSupply", ret)
50
+ .toArray();
51
+ return result.length == 1 ? result[0] : result;
52
+ }
53
+ }
20
54
  return await this.contract.getFunction("totalSupply()")(overrides || {});
21
55
  }
22
56
  catch (e) {
@@ -24,8 +58,23 @@ export class WETH9ContractView extends ContractView {
24
58
  throw transformEtherError(e, undefined, stack);
25
59
  }
26
60
  }
27
- async decimals(overrides) {
61
+ async decimals(overrides, preparedData, ethCallContext) {
28
62
  try {
63
+ if (preparedData?.ethCallResults && ethCallContext) {
64
+ const iface = new Interface([
65
+ "function decimals() view returns (uint8)",
66
+ ]);
67
+ const calldata = iface.encodeFunctionData("decimals", []);
68
+ const key = makeEthCallKey({
69
+ context: ethCallContext,
70
+ calldata,
71
+ });
72
+ const ret = preparedData.ethCallResults[key];
73
+ if (ret) {
74
+ const result = iface.decodeFunctionResult("decimals", ret).toArray();
75
+ return result.length == 1 ? result[0] : result;
76
+ }
77
+ }
29
78
  return await this.contract.getFunction("decimals()")(overrides || {});
30
79
  }
31
80
  catch (e) {
@@ -33,8 +82,23 @@ export class WETH9ContractView extends ContractView {
33
82
  throw transformEtherError(e, undefined, stack);
34
83
  }
35
84
  }
36
- async balanceOf(arg0, overrides) {
85
+ async balanceOf(arg0, overrides, preparedData, ethCallContext) {
37
86
  try {
87
+ if (preparedData?.ethCallResults && ethCallContext) {
88
+ const iface = new Interface([
89
+ "function balanceOf(address) view returns (uint256)",
90
+ ]);
91
+ const calldata = iface.encodeFunctionData("balanceOf", [arg0]);
92
+ const key = makeEthCallKey({
93
+ context: ethCallContext,
94
+ calldata,
95
+ });
96
+ const ret = preparedData.ethCallResults[key];
97
+ if (ret) {
98
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
99
+ return result.length == 1 ? result[0] : result;
100
+ }
101
+ }
38
102
  return await this.contract.getFunction("balanceOf(address)")(arg0, overrides || {});
39
103
  }
40
104
  catch (e) {
@@ -42,8 +106,23 @@ export class WETH9ContractView extends ContractView {
42
106
  throw transformEtherError(e, undefined, stack);
43
107
  }
44
108
  }
45
- async symbol(overrides) {
109
+ async symbol(overrides, preparedData, ethCallContext) {
46
110
  try {
111
+ if (preparedData?.ethCallResults && ethCallContext) {
112
+ const iface = new Interface([
113
+ "function symbol() view returns (string)",
114
+ ]);
115
+ const calldata = iface.encodeFunctionData("symbol", []);
116
+ const key = makeEthCallKey({
117
+ context: ethCallContext,
118
+ calldata,
119
+ });
120
+ const ret = preparedData.ethCallResults[key];
121
+ if (ret) {
122
+ const result = iface.decodeFunctionResult("symbol", ret).toArray();
123
+ return result.length == 1 ? result[0] : result;
124
+ }
125
+ }
47
126
  return await this.contract.getFunction("symbol()")(overrides || {});
48
127
  }
49
128
  catch (e) {
@@ -51,8 +130,23 @@ export class WETH9ContractView extends ContractView {
51
130
  throw transformEtherError(e, undefined, stack);
52
131
  }
53
132
  }
54
- async allowance(arg0, arg1, overrides) {
133
+ async allowance(arg0, arg1, overrides, preparedData, ethCallContext) {
55
134
  try {
135
+ if (preparedData?.ethCallResults && ethCallContext) {
136
+ const iface = new Interface([
137
+ "function allowance(address,address) view returns (uint256)",
138
+ ]);
139
+ const calldata = iface.encodeFunctionData("allowance", [arg0, arg1]);
140
+ const key = makeEthCallKey({
141
+ context: ethCallContext,
142
+ calldata,
143
+ });
144
+ const ret = preparedData.ethCallResults[key];
145
+ if (ret) {
146
+ const result = iface.decodeFunctionResult("allowance", ret).toArray();
147
+ return result.length == 1 ? result[0] : result;
148
+ }
149
+ }
56
150
  return await this.contract.getFunction("allowance(address,address)")(arg0, arg1, overrides || {});
57
151
  }
58
152
  catch (e) {
@@ -62,8 +156,23 @@ export class WETH9ContractView extends ContractView {
62
156
  }
63
157
  callStatic = {
64
158
  contract: this.contract,
65
- async approve(guy, wad, overrides) {
159
+ async approve(guy, wad, overrides, preparedData, ethCallContext) {
66
160
  try {
161
+ if (preparedData?.ethCallResults && ethCallContext) {
162
+ const iface = new Interface([
163
+ "function approve(address,uint256) nonpayable returns (bool)",
164
+ ]);
165
+ const calldata = iface.encodeFunctionData("approve", [guy, wad]);
166
+ const key = makeEthCallKey({
167
+ context: ethCallContext,
168
+ calldata,
169
+ });
170
+ const ret = preparedData.ethCallResults[key];
171
+ if (ret) {
172
+ const result = iface.decodeFunctionResult("approve", ret).toArray();
173
+ return result.length == 1 ? result[0] : result;
174
+ }
175
+ }
67
176
  return await this.contract
68
177
  .getFunction("approve(address,uint256)")
69
178
  .staticCall(guy, wad, overrides || {});
@@ -73,8 +182,29 @@ export class WETH9ContractView extends ContractView {
73
182
  throw transformEtherError(e, undefined, stack);
74
183
  }
75
184
  },
76
- async transferFrom(src, dst, wad, overrides) {
185
+ async transferFrom(src, dst, wad, overrides, preparedData, ethCallContext) {
77
186
  try {
187
+ if (preparedData?.ethCallResults && ethCallContext) {
188
+ const iface = new Interface([
189
+ "function transferFrom(address,address,uint256) nonpayable returns (bool)",
190
+ ]);
191
+ const calldata = iface.encodeFunctionData("transferFrom", [
192
+ src,
193
+ dst,
194
+ wad,
195
+ ]);
196
+ const key = makeEthCallKey({
197
+ context: ethCallContext,
198
+ calldata,
199
+ });
200
+ const ret = preparedData.ethCallResults[key];
201
+ if (ret) {
202
+ const result = iface
203
+ .decodeFunctionResult("transferFrom", ret)
204
+ .toArray();
205
+ return result.length == 1 ? result[0] : result;
206
+ }
207
+ }
78
208
  return await this.contract
79
209
  .getFunction("transferFrom(address,address,uint256)")
80
210
  .staticCall(src, dst, wad, overrides || {});
@@ -84,8 +214,25 @@ export class WETH9ContractView extends ContractView {
84
214
  throw transformEtherError(e, undefined, stack);
85
215
  }
86
216
  },
87
- async withdraw(wad, overrides) {
217
+ async withdraw(wad, overrides, preparedData, ethCallContext) {
88
218
  try {
219
+ if (preparedData?.ethCallResults && ethCallContext) {
220
+ const iface = new Interface([
221
+ "function withdraw(uint256) nonpayable returns ()",
222
+ ]);
223
+ const calldata = iface.encodeFunctionData("withdraw", [wad]);
224
+ const key = makeEthCallKey({
225
+ context: ethCallContext,
226
+ calldata,
227
+ });
228
+ const ret = preparedData.ethCallResults[key];
229
+ if (ret) {
230
+ const result = iface
231
+ .decodeFunctionResult("withdraw", ret)
232
+ .toArray();
233
+ return result.length == 1 ? result[0] : result;
234
+ }
235
+ }
89
236
  return await this.contract
90
237
  .getFunction("withdraw(uint256)")
91
238
  .staticCall(wad, overrides || {});
@@ -95,8 +242,25 @@ export class WETH9ContractView extends ContractView {
95
242
  throw transformEtherError(e, undefined, stack);
96
243
  }
97
244
  },
98
- async transfer(dst, wad, overrides) {
245
+ async transfer(dst, wad, overrides, preparedData, ethCallContext) {
99
246
  try {
247
+ if (preparedData?.ethCallResults && ethCallContext) {
248
+ const iface = new Interface([
249
+ "function transfer(address,uint256) nonpayable returns (bool)",
250
+ ]);
251
+ const calldata = iface.encodeFunctionData("transfer", [dst, wad]);
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("transfer", ret)
260
+ .toArray();
261
+ return result.length == 1 ? result[0] : result;
262
+ }
263
+ }
100
264
  return await this.contract
101
265
  .getFunction("transfer(address,uint256)")
102
266
  .staticCall(dst, wad, overrides || {});
@@ -106,8 +270,23 @@ export class WETH9ContractView extends ContractView {
106
270
  throw transformEtherError(e, undefined, stack);
107
271
  }
108
272
  },
109
- async deposit(overrides) {
273
+ async deposit(overrides, preparedData, ethCallContext) {
110
274
  try {
275
+ if (preparedData?.ethCallResults && ethCallContext) {
276
+ const iface = new Interface([
277
+ "function deposit() payable returns ()",
278
+ ]);
279
+ const calldata = iface.encodeFunctionData("deposit", []);
280
+ const key = makeEthCallKey({
281
+ context: ethCallContext,
282
+ calldata,
283
+ });
284
+ const ret = preparedData.ethCallResults[key];
285
+ if (ret) {
286
+ const result = iface.decodeFunctionResult("deposit", ret).toArray();
287
+ return result.length == 1 ? result[0] : result;
288
+ }
289
+ }
111
290
  return await this.contract
112
291
  .getFunction("deposit()")
113
292
  .staticCall(overrides || {});
@@ -118,75 +297,448 @@ export class WETH9ContractView extends ContractView {
118
297
  }
119
298
  },
120
299
  };
300
+ encodeCall = {
301
+ name(ethCallContext) {
302
+ try {
303
+ const iface = new Interface(["function name()"]);
304
+ const calldata = iface.encodeFunctionData("name", []);
305
+ return {
306
+ context: ethCallContext,
307
+ calldata,
308
+ };
309
+ }
310
+ catch (e) {
311
+ const stack = new Error().stack;
312
+ throw transformEtherError(e, undefined, stack);
313
+ }
314
+ },
315
+ approve(guy, wad, ethCallContext) {
316
+ try {
317
+ const iface = new Interface(["function approve(address,uint256)"]);
318
+ const calldata = iface.encodeFunctionData("approve", [guy, wad]);
319
+ return {
320
+ context: ethCallContext,
321
+ calldata,
322
+ };
323
+ }
324
+ catch (e) {
325
+ const stack = new Error().stack;
326
+ throw transformEtherError(e, undefined, stack);
327
+ }
328
+ },
329
+ totalSupply(ethCallContext) {
330
+ try {
331
+ const iface = new Interface(["function totalSupply()"]);
332
+ const calldata = iface.encodeFunctionData("totalSupply", []);
333
+ return {
334
+ context: ethCallContext,
335
+ calldata,
336
+ };
337
+ }
338
+ catch (e) {
339
+ const stack = new Error().stack;
340
+ throw transformEtherError(e, undefined, stack);
341
+ }
342
+ },
343
+ transferFrom(src, dst, wad, ethCallContext) {
344
+ try {
345
+ const iface = new Interface([
346
+ "function transferFrom(address,address,uint256)",
347
+ ]);
348
+ const calldata = iface.encodeFunctionData("transferFrom", [
349
+ src,
350
+ dst,
351
+ wad,
352
+ ]);
353
+ return {
354
+ context: ethCallContext,
355
+ calldata,
356
+ };
357
+ }
358
+ catch (e) {
359
+ const stack = new Error().stack;
360
+ throw transformEtherError(e, undefined, stack);
361
+ }
362
+ },
363
+ withdraw(wad, ethCallContext) {
364
+ try {
365
+ const iface = new Interface(["function withdraw(uint256)"]);
366
+ const calldata = iface.encodeFunctionData("withdraw", [wad]);
367
+ return {
368
+ context: ethCallContext,
369
+ calldata,
370
+ };
371
+ }
372
+ catch (e) {
373
+ const stack = new Error().stack;
374
+ throw transformEtherError(e, undefined, stack);
375
+ }
376
+ },
377
+ decimals(ethCallContext) {
378
+ try {
379
+ const iface = new Interface(["function decimals()"]);
380
+ const calldata = iface.encodeFunctionData("decimals", []);
381
+ return {
382
+ context: ethCallContext,
383
+ calldata,
384
+ };
385
+ }
386
+ catch (e) {
387
+ const stack = new Error().stack;
388
+ throw transformEtherError(e, undefined, stack);
389
+ }
390
+ },
391
+ balanceOf(arg0, ethCallContext) {
392
+ try {
393
+ const iface = new Interface(["function balanceOf(address)"]);
394
+ const calldata = iface.encodeFunctionData("balanceOf", [arg0]);
395
+ return {
396
+ context: ethCallContext,
397
+ calldata,
398
+ };
399
+ }
400
+ catch (e) {
401
+ const stack = new Error().stack;
402
+ throw transformEtherError(e, undefined, stack);
403
+ }
404
+ },
405
+ symbol(ethCallContext) {
406
+ try {
407
+ const iface = new Interface(["function symbol()"]);
408
+ const calldata = iface.encodeFunctionData("symbol", []);
409
+ return {
410
+ context: ethCallContext,
411
+ calldata,
412
+ };
413
+ }
414
+ catch (e) {
415
+ const stack = new Error().stack;
416
+ throw transformEtherError(e, undefined, stack);
417
+ }
418
+ },
419
+ transfer(dst, wad, ethCallContext) {
420
+ try {
421
+ const iface = new Interface(["function transfer(address,uint256)"]);
422
+ const calldata = iface.encodeFunctionData("transfer", [dst, wad]);
423
+ return {
424
+ context: ethCallContext,
425
+ calldata,
426
+ };
427
+ }
428
+ catch (e) {
429
+ const stack = new Error().stack;
430
+ throw transformEtherError(e, undefined, stack);
431
+ }
432
+ },
433
+ deposit(ethCallContext) {
434
+ try {
435
+ const iface = new Interface(["function deposit()"]);
436
+ const calldata = iface.encodeFunctionData("deposit", []);
437
+ return {
438
+ context: ethCallContext,
439
+ calldata,
440
+ };
441
+ }
442
+ catch (e) {
443
+ const stack = new Error().stack;
444
+ throw transformEtherError(e, undefined, stack);
445
+ }
446
+ },
447
+ allowance(arg0, arg1, ethCallContext) {
448
+ try {
449
+ const iface = new Interface(["function allowance(address,address)"]);
450
+ const calldata = iface.encodeFunctionData("allowance", [arg0, arg1]);
451
+ return {
452
+ context: ethCallContext,
453
+ calldata,
454
+ };
455
+ }
456
+ catch (e) {
457
+ const stack = new Error().stack;
458
+ throw transformEtherError(e, undefined, stack);
459
+ }
460
+ },
461
+ };
121
462
  }
122
463
  export class WETH9BoundContractView extends BoundContractView {
123
464
  async name(overrides) {
465
+ const ethCallContext = {
466
+ chainId: this.context.chainId,
467
+ blockTag: "0x" + this.context.blockNumber.toString(16),
468
+ address: this.context.address,
469
+ };
124
470
  return await this.view.name({
125
471
  blockTag: this.context.blockNumber,
126
472
  ...overrides,
127
- });
473
+ }, this.context.preparedData, ethCallContext);
128
474
  }
129
475
  async totalSupply(overrides) {
476
+ const ethCallContext = {
477
+ chainId: this.context.chainId,
478
+ blockTag: "0x" + this.context.blockNumber.toString(16),
479
+ address: this.context.address,
480
+ };
130
481
  return await this.view.totalSupply({
131
482
  blockTag: this.context.blockNumber,
132
483
  ...overrides,
133
- });
484
+ }, this.context.preparedData, ethCallContext);
134
485
  }
135
486
  async decimals(overrides) {
487
+ const ethCallContext = {
488
+ chainId: this.context.chainId,
489
+ blockTag: "0x" + this.context.blockNumber.toString(16),
490
+ address: this.context.address,
491
+ };
136
492
  return await this.view.decimals({
137
493
  blockTag: this.context.blockNumber,
138
494
  ...overrides,
139
- });
495
+ }, this.context.preparedData, ethCallContext);
140
496
  }
141
497
  async balanceOf(arg0, overrides) {
498
+ const ethCallContext = {
499
+ chainId: this.context.chainId,
500
+ blockTag: "0x" + this.context.blockNumber.toString(16),
501
+ address: this.context.address,
502
+ };
142
503
  return await this.view.balanceOf(arg0, {
143
504
  blockTag: this.context.blockNumber,
144
505
  ...overrides,
145
- });
506
+ }, this.context.preparedData, ethCallContext);
146
507
  }
147
508
  async symbol(overrides) {
509
+ const ethCallContext = {
510
+ chainId: this.context.chainId,
511
+ blockTag: "0x" + this.context.blockNumber.toString(16),
512
+ address: this.context.address,
513
+ };
148
514
  return await this.view.symbol({
149
515
  blockTag: this.context.blockNumber,
150
516
  ...overrides,
151
- });
517
+ }, this.context.preparedData, ethCallContext);
152
518
  }
153
519
  async allowance(arg0, arg1, overrides) {
520
+ const ethCallContext = {
521
+ chainId: this.context.chainId,
522
+ blockTag: "0x" + this.context.blockNumber.toString(16),
523
+ address: this.context.address,
524
+ };
154
525
  return await this.view.allowance(arg0, arg1, {
155
526
  blockTag: this.context.blockNumber,
156
527
  ...overrides,
157
- });
528
+ }, this.context.preparedData, ethCallContext);
158
529
  }
159
530
  callStatic = {
160
531
  view: this.view,
161
532
  context: this.context,
162
533
  async approve(guy, wad, overrides) {
534
+ const ethCallContext = {
535
+ chainId: this.context.chainId,
536
+ blockTag: "0x" + this.context.blockNumber.toString(16),
537
+ address: this.context.address,
538
+ };
163
539
  return await this.view.callStatic.approve(guy, wad, {
164
540
  blockTag: this.context.blockNumber,
165
541
  ...overrides,
166
- });
542
+ }, this.context.preparedData, ethCallContext);
167
543
  },
168
544
  async transferFrom(src, dst, wad, overrides) {
545
+ const ethCallContext = {
546
+ chainId: this.context.chainId,
547
+ blockTag: "0x" + this.context.blockNumber.toString(16),
548
+ address: this.context.address,
549
+ };
169
550
  return await this.view.callStatic.transferFrom(src, dst, wad, {
170
551
  blockTag: this.context.blockNumber,
171
552
  ...overrides,
172
- });
553
+ }, this.context.preparedData, ethCallContext);
173
554
  },
174
555
  async withdraw(wad, overrides) {
556
+ const ethCallContext = {
557
+ chainId: this.context.chainId,
558
+ blockTag: "0x" + this.context.blockNumber.toString(16),
559
+ address: this.context.address,
560
+ };
175
561
  return await this.view.callStatic.withdraw(wad, {
176
562
  blockTag: this.context.blockNumber,
177
563
  ...overrides,
178
- });
564
+ }, this.context.preparedData, ethCallContext);
179
565
  },
180
566
  async transfer(dst, wad, overrides) {
567
+ const ethCallContext = {
568
+ chainId: this.context.chainId,
569
+ blockTag: "0x" + this.context.blockNumber.toString(16),
570
+ address: this.context.address,
571
+ };
181
572
  return await this.view.callStatic.transfer(dst, wad, {
182
573
  blockTag: this.context.blockNumber,
183
574
  ...overrides,
184
- });
575
+ }, this.context.preparedData, ethCallContext);
185
576
  },
186
577
  async deposit(overrides) {
578
+ const ethCallContext = {
579
+ chainId: this.context.chainId,
580
+ blockTag: "0x" + this.context.blockNumber.toString(16),
581
+ address: this.context.address,
582
+ };
187
583
  return await this.view.callStatic.deposit({
188
584
  blockTag: this.context.blockNumber,
189
585
  ...overrides,
586
+ }, this.context.preparedData, ethCallContext);
587
+ },
588
+ };
589
+ encodeCall = {
590
+ view: this.view,
591
+ context: this.context,
592
+ name(overrides) {
593
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
594
+ const address = this.context.address;
595
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
596
+ if (overrides?.blockTag) {
597
+ blockTag =
598
+ typeof overrides.blockTag == "string"
599
+ ? overrides.blockTag
600
+ : "0x" + overrides.blockTag.toString(16);
601
+ }
602
+ return this.view.encodeCall.name({ chainId, address, blockTag });
603
+ },
604
+ approve(guy, wad, overrides) {
605
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
606
+ const address = this.context.address;
607
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
608
+ if (overrides?.blockTag) {
609
+ blockTag =
610
+ typeof overrides.blockTag == "string"
611
+ ? overrides.blockTag
612
+ : "0x" + overrides.blockTag.toString(16);
613
+ }
614
+ return this.view.encodeCall.approve(guy, wad, {
615
+ chainId,
616
+ address,
617
+ blockTag,
618
+ });
619
+ },
620
+ totalSupply(overrides) {
621
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
622
+ const address = this.context.address;
623
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
624
+ if (overrides?.blockTag) {
625
+ blockTag =
626
+ typeof overrides.blockTag == "string"
627
+ ? overrides.blockTag
628
+ : "0x" + overrides.blockTag.toString(16);
629
+ }
630
+ return this.view.encodeCall.totalSupply({ chainId, address, blockTag });
631
+ },
632
+ transferFrom(src, dst, wad, overrides) {
633
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
634
+ const address = this.context.address;
635
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
636
+ if (overrides?.blockTag) {
637
+ blockTag =
638
+ typeof overrides.blockTag == "string"
639
+ ? overrides.blockTag
640
+ : "0x" + overrides.blockTag.toString(16);
641
+ }
642
+ return this.view.encodeCall.transferFrom(src, dst, wad, {
643
+ chainId,
644
+ address,
645
+ blockTag,
646
+ });
647
+ },
648
+ withdraw(wad, overrides) {
649
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
650
+ const address = this.context.address;
651
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
652
+ if (overrides?.blockTag) {
653
+ blockTag =
654
+ typeof overrides.blockTag == "string"
655
+ ? overrides.blockTag
656
+ : "0x" + overrides.blockTag.toString(16);
657
+ }
658
+ return this.view.encodeCall.withdraw(wad, { chainId, address, blockTag });
659
+ },
660
+ decimals(overrides) {
661
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
662
+ const address = this.context.address;
663
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
664
+ if (overrides?.blockTag) {
665
+ blockTag =
666
+ typeof overrides.blockTag == "string"
667
+ ? overrides.blockTag
668
+ : "0x" + overrides.blockTag.toString(16);
669
+ }
670
+ return this.view.encodeCall.decimals({ chainId, address, blockTag });
671
+ },
672
+ balanceOf(arg0, overrides) {
673
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
674
+ const address = this.context.address;
675
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
676
+ if (overrides?.blockTag) {
677
+ blockTag =
678
+ typeof overrides.blockTag == "string"
679
+ ? overrides.blockTag
680
+ : "0x" + overrides.blockTag.toString(16);
681
+ }
682
+ return this.view.encodeCall.balanceOf(arg0, {
683
+ chainId,
684
+ address,
685
+ blockTag,
686
+ });
687
+ },
688
+ symbol(overrides) {
689
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
690
+ const address = this.context.address;
691
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
692
+ if (overrides?.blockTag) {
693
+ blockTag =
694
+ typeof overrides.blockTag == "string"
695
+ ? overrides.blockTag
696
+ : "0x" + overrides.blockTag.toString(16);
697
+ }
698
+ return this.view.encodeCall.symbol({ chainId, address, blockTag });
699
+ },
700
+ transfer(dst, wad, overrides) {
701
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
702
+ const address = this.context.address;
703
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
704
+ if (overrides?.blockTag) {
705
+ blockTag =
706
+ typeof overrides.blockTag == "string"
707
+ ? overrides.blockTag
708
+ : "0x" + overrides.blockTag.toString(16);
709
+ }
710
+ return this.view.encodeCall.transfer(dst, wad, {
711
+ chainId,
712
+ address,
713
+ blockTag,
714
+ });
715
+ },
716
+ deposit(overrides) {
717
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
718
+ const address = this.context.address;
719
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
720
+ if (overrides?.blockTag) {
721
+ blockTag =
722
+ typeof overrides.blockTag == "string"
723
+ ? overrides.blockTag
724
+ : "0x" + overrides.blockTag.toString(16);
725
+ }
726
+ return this.view.encodeCall.deposit({ chainId, address, blockTag });
727
+ },
728
+ allowance(arg0, arg1, overrides) {
729
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
730
+ const address = this.context.address;
731
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
732
+ if (overrides?.blockTag) {
733
+ blockTag =
734
+ typeof overrides.blockTag == "string"
735
+ ? overrides.blockTag
736
+ : "0x" + overrides.blockTag.toString(16);
737
+ }
738
+ return this.view.encodeCall.allowance(arg0, arg1, {
739
+ chainId,
740
+ address,
741
+ blockTag,
190
742
  });
191
743
  },
192
744
  };