@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 { ERC20Bytes__factory } from "./index.js";
3
7
  const templateContract = ERC20Bytes__factory.connect("0x0", DummyProvider);
4
8
  export class ERC20BytesContractView extends ContractView {
@@ -6,8 +10,21 @@ export class ERC20BytesContractView 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 (bytes32)"]);
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 ERC20BytesContractView 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 ERC20BytesContractView 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 ERC20BytesContractView extends ContractView {
33
82
  throw transformEtherError(e, undefined, stack);
34
83
  }
35
84
  }
36
- async balanceOf(who, overrides) {
85
+ async balanceOf(who, 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", [who]);
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)")(who, overrides || {});
39
103
  }
40
104
  catch (e) {
@@ -42,8 +106,23 @@ export class ERC20BytesContractView 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 (bytes32)",
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,26 @@ export class ERC20BytesContractView extends ContractView {
51
130
  throw transformEtherError(e, undefined, stack);
52
131
  }
53
132
  }
54
- async allowance(owner, spender, overrides) {
133
+ async allowance(owner, spender, 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", [
140
+ owner,
141
+ spender,
142
+ ]);
143
+ const key = makeEthCallKey({
144
+ context: ethCallContext,
145
+ calldata,
146
+ });
147
+ const ret = preparedData.ethCallResults[key];
148
+ if (ret) {
149
+ const result = iface.decodeFunctionResult("allowance", ret).toArray();
150
+ return result.length == 1 ? result[0] : result;
151
+ }
152
+ }
56
153
  return await this.contract.getFunction("allowance(address,address)")(owner, spender, overrides || {});
57
154
  }
58
155
  catch (e) {
@@ -62,8 +159,26 @@ export class ERC20BytesContractView extends ContractView {
62
159
  }
63
160
  callStatic = {
64
161
  contract: this.contract,
65
- async approve(spender, value, overrides) {
162
+ async approve(spender, value, overrides, preparedData, ethCallContext) {
66
163
  try {
164
+ if (preparedData?.ethCallResults && ethCallContext) {
165
+ const iface = new Interface([
166
+ "function approve(address,uint256) nonpayable returns (bool)",
167
+ ]);
168
+ const calldata = iface.encodeFunctionData("approve", [
169
+ spender,
170
+ value,
171
+ ]);
172
+ const key = makeEthCallKey({
173
+ context: ethCallContext,
174
+ calldata,
175
+ });
176
+ const ret = preparedData.ethCallResults[key];
177
+ if (ret) {
178
+ const result = iface.decodeFunctionResult("approve", ret).toArray();
179
+ return result.length == 1 ? result[0] : result;
180
+ }
181
+ }
67
182
  return await this.contract
68
183
  .getFunction("approve(address,uint256)")
69
184
  .staticCall(spender, value, overrides || {});
@@ -73,8 +188,29 @@ export class ERC20BytesContractView extends ContractView {
73
188
  throw transformEtherError(e, undefined, stack);
74
189
  }
75
190
  },
76
- async transferFrom(from, to, value, overrides) {
191
+ async transferFrom(from, to, value, overrides, preparedData, ethCallContext) {
77
192
  try {
193
+ if (preparedData?.ethCallResults && ethCallContext) {
194
+ const iface = new Interface([
195
+ "function transferFrom(address,address,uint256) nonpayable returns (bool)",
196
+ ]);
197
+ const calldata = iface.encodeFunctionData("transferFrom", [
198
+ from,
199
+ to,
200
+ value,
201
+ ]);
202
+ const key = makeEthCallKey({
203
+ context: ethCallContext,
204
+ calldata,
205
+ });
206
+ const ret = preparedData.ethCallResults[key];
207
+ if (ret) {
208
+ const result = iface
209
+ .decodeFunctionResult("transferFrom", ret)
210
+ .toArray();
211
+ return result.length == 1 ? result[0] : result;
212
+ }
213
+ }
78
214
  return await this.contract
79
215
  .getFunction("transferFrom(address,address,uint256)")
80
216
  .staticCall(from, to, value, overrides || {});
@@ -84,8 +220,25 @@ export class ERC20BytesContractView extends ContractView {
84
220
  throw transformEtherError(e, undefined, stack);
85
221
  }
86
222
  },
87
- async transfer(to, value, overrides) {
223
+ async transfer(to, value, overrides, preparedData, ethCallContext) {
88
224
  try {
225
+ if (preparedData?.ethCallResults && ethCallContext) {
226
+ const iface = new Interface([
227
+ "function transfer(address,uint256) nonpayable returns (bool)",
228
+ ]);
229
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
230
+ const key = makeEthCallKey({
231
+ context: ethCallContext,
232
+ calldata,
233
+ });
234
+ const ret = preparedData.ethCallResults[key];
235
+ if (ret) {
236
+ const result = iface
237
+ .decodeFunctionResult("transfer", ret)
238
+ .toArray();
239
+ return result.length == 1 ? result[0] : result;
240
+ }
241
+ }
89
242
  return await this.contract
90
243
  .getFunction("transfer(address,uint256)")
91
244
  .staticCall(to, value, overrides || {});
@@ -96,63 +249,377 @@ export class ERC20BytesContractView extends ContractView {
96
249
  }
97
250
  },
98
251
  };
252
+ encodeCall = {
253
+ name(ethCallContext) {
254
+ try {
255
+ const iface = new Interface(["function name()"]);
256
+ const calldata = iface.encodeFunctionData("name", []);
257
+ return {
258
+ context: ethCallContext,
259
+ calldata,
260
+ };
261
+ }
262
+ catch (e) {
263
+ const stack = new Error().stack;
264
+ throw transformEtherError(e, undefined, stack);
265
+ }
266
+ },
267
+ approve(spender, value, ethCallContext) {
268
+ try {
269
+ const iface = new Interface(["function approve(address,uint256)"]);
270
+ const calldata = iface.encodeFunctionData("approve", [spender, value]);
271
+ return {
272
+ context: ethCallContext,
273
+ calldata,
274
+ };
275
+ }
276
+ catch (e) {
277
+ const stack = new Error().stack;
278
+ throw transformEtherError(e, undefined, stack);
279
+ }
280
+ },
281
+ totalSupply(ethCallContext) {
282
+ try {
283
+ const iface = new Interface(["function totalSupply()"]);
284
+ const calldata = iface.encodeFunctionData("totalSupply", []);
285
+ return {
286
+ context: ethCallContext,
287
+ calldata,
288
+ };
289
+ }
290
+ catch (e) {
291
+ const stack = new Error().stack;
292
+ throw transformEtherError(e, undefined, stack);
293
+ }
294
+ },
295
+ transferFrom(from, to, value, ethCallContext) {
296
+ try {
297
+ const iface = new Interface([
298
+ "function transferFrom(address,address,uint256)",
299
+ ]);
300
+ const calldata = iface.encodeFunctionData("transferFrom", [
301
+ from,
302
+ to,
303
+ value,
304
+ ]);
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
+ decimals(ethCallContext) {
316
+ try {
317
+ const iface = new Interface(["function decimals()"]);
318
+ const calldata = iface.encodeFunctionData("decimals", []);
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
+ balanceOf(who, ethCallContext) {
330
+ try {
331
+ const iface = new Interface(["function balanceOf(address)"]);
332
+ const calldata = iface.encodeFunctionData("balanceOf", [who]);
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
+ symbol(ethCallContext) {
344
+ try {
345
+ const iface = new Interface(["function symbol()"]);
346
+ const calldata = iface.encodeFunctionData("symbol", []);
347
+ return {
348
+ context: ethCallContext,
349
+ calldata,
350
+ };
351
+ }
352
+ catch (e) {
353
+ const stack = new Error().stack;
354
+ throw transformEtherError(e, undefined, stack);
355
+ }
356
+ },
357
+ transfer(to, value, ethCallContext) {
358
+ try {
359
+ const iface = new Interface(["function transfer(address,uint256)"]);
360
+ const calldata = iface.encodeFunctionData("transfer", [to, value]);
361
+ return {
362
+ context: ethCallContext,
363
+ calldata,
364
+ };
365
+ }
366
+ catch (e) {
367
+ const stack = new Error().stack;
368
+ throw transformEtherError(e, undefined, stack);
369
+ }
370
+ },
371
+ allowance(owner, spender, ethCallContext) {
372
+ try {
373
+ const iface = new Interface(["function allowance(address,address)"]);
374
+ const calldata = iface.encodeFunctionData("allowance", [
375
+ owner,
376
+ spender,
377
+ ]);
378
+ return {
379
+ context: ethCallContext,
380
+ calldata,
381
+ };
382
+ }
383
+ catch (e) {
384
+ const stack = new Error().stack;
385
+ throw transformEtherError(e, undefined, stack);
386
+ }
387
+ },
388
+ };
99
389
  }
100
390
  export class ERC20BytesBoundContractView extends BoundContractView {
101
391
  async name(overrides) {
392
+ const ethCallContext = {
393
+ chainId: this.context.chainId,
394
+ blockTag: "0x" + this.context.blockNumber.toString(16),
395
+ address: this.context.address,
396
+ };
102
397
  return await this.view.name({
103
398
  blockTag: this.context.blockNumber,
104
399
  ...overrides,
105
- });
400
+ }, this.context.preparedData, ethCallContext);
106
401
  }
107
402
  async totalSupply(overrides) {
403
+ const ethCallContext = {
404
+ chainId: this.context.chainId,
405
+ blockTag: "0x" + this.context.blockNumber.toString(16),
406
+ address: this.context.address,
407
+ };
108
408
  return await this.view.totalSupply({
109
409
  blockTag: this.context.blockNumber,
110
410
  ...overrides,
111
- });
411
+ }, this.context.preparedData, ethCallContext);
112
412
  }
113
413
  async decimals(overrides) {
414
+ const ethCallContext = {
415
+ chainId: this.context.chainId,
416
+ blockTag: "0x" + this.context.blockNumber.toString(16),
417
+ address: this.context.address,
418
+ };
114
419
  return await this.view.decimals({
115
420
  blockTag: this.context.blockNumber,
116
421
  ...overrides,
117
- });
422
+ }, this.context.preparedData, ethCallContext);
118
423
  }
119
424
  async balanceOf(who, overrides) {
425
+ const ethCallContext = {
426
+ chainId: this.context.chainId,
427
+ blockTag: "0x" + this.context.blockNumber.toString(16),
428
+ address: this.context.address,
429
+ };
120
430
  return await this.view.balanceOf(who, {
121
431
  blockTag: this.context.blockNumber,
122
432
  ...overrides,
123
- });
433
+ }, this.context.preparedData, ethCallContext);
124
434
  }
125
435
  async symbol(overrides) {
436
+ const ethCallContext = {
437
+ chainId: this.context.chainId,
438
+ blockTag: "0x" + this.context.blockNumber.toString(16),
439
+ address: this.context.address,
440
+ };
126
441
  return await this.view.symbol({
127
442
  blockTag: this.context.blockNumber,
128
443
  ...overrides,
129
- });
444
+ }, this.context.preparedData, ethCallContext);
130
445
  }
131
446
  async allowance(owner, spender, overrides) {
447
+ const ethCallContext = {
448
+ chainId: this.context.chainId,
449
+ blockTag: "0x" + this.context.blockNumber.toString(16),
450
+ address: this.context.address,
451
+ };
132
452
  return await this.view.allowance(owner, spender, {
133
453
  blockTag: this.context.blockNumber,
134
454
  ...overrides,
135
- });
455
+ }, this.context.preparedData, ethCallContext);
136
456
  }
137
457
  callStatic = {
138
458
  view: this.view,
139
459
  context: this.context,
140
460
  async approve(spender, value, overrides) {
461
+ const ethCallContext = {
462
+ chainId: this.context.chainId,
463
+ blockTag: "0x" + this.context.blockNumber.toString(16),
464
+ address: this.context.address,
465
+ };
141
466
  return await this.view.callStatic.approve(spender, value, {
142
467
  blockTag: this.context.blockNumber,
143
468
  ...overrides,
144
- });
469
+ }, this.context.preparedData, ethCallContext);
145
470
  },
146
471
  async transferFrom(from, to, value, overrides) {
472
+ const ethCallContext = {
473
+ chainId: this.context.chainId,
474
+ blockTag: "0x" + this.context.blockNumber.toString(16),
475
+ address: this.context.address,
476
+ };
147
477
  return await this.view.callStatic.transferFrom(from, to, value, {
148
478
  blockTag: this.context.blockNumber,
149
479
  ...overrides,
150
- });
480
+ }, this.context.preparedData, ethCallContext);
151
481
  },
152
482
  async transfer(to, value, overrides) {
483
+ const ethCallContext = {
484
+ chainId: this.context.chainId,
485
+ blockTag: "0x" + this.context.blockNumber.toString(16),
486
+ address: this.context.address,
487
+ };
153
488
  return await this.view.callStatic.transfer(to, value, {
154
489
  blockTag: this.context.blockNumber,
155
490
  ...overrides,
491
+ }, this.context.preparedData, ethCallContext);
492
+ },
493
+ };
494
+ encodeCall = {
495
+ view: this.view,
496
+ context: this.context,
497
+ name(overrides) {
498
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
499
+ const address = this.context.address;
500
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
501
+ if (overrides?.blockTag) {
502
+ blockTag =
503
+ typeof overrides.blockTag == "string"
504
+ ? overrides.blockTag
505
+ : "0x" + overrides.blockTag.toString(16);
506
+ }
507
+ return this.view.encodeCall.name({ chainId, address, blockTag });
508
+ },
509
+ approve(spender, value, overrides) {
510
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
511
+ const address = this.context.address;
512
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
513
+ if (overrides?.blockTag) {
514
+ blockTag =
515
+ typeof overrides.blockTag == "string"
516
+ ? overrides.blockTag
517
+ : "0x" + overrides.blockTag.toString(16);
518
+ }
519
+ return this.view.encodeCall.approve(spender, value, {
520
+ chainId,
521
+ address,
522
+ blockTag,
523
+ });
524
+ },
525
+ totalSupply(overrides) {
526
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
527
+ const address = this.context.address;
528
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
529
+ if (overrides?.blockTag) {
530
+ blockTag =
531
+ typeof overrides.blockTag == "string"
532
+ ? overrides.blockTag
533
+ : "0x" + overrides.blockTag.toString(16);
534
+ }
535
+ return this.view.encodeCall.totalSupply({ chainId, address, blockTag });
536
+ },
537
+ transferFrom(from, to, value, overrides) {
538
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
539
+ const address = this.context.address;
540
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
541
+ if (overrides?.blockTag) {
542
+ blockTag =
543
+ typeof overrides.blockTag == "string"
544
+ ? overrides.blockTag
545
+ : "0x" + overrides.blockTag.toString(16);
546
+ }
547
+ return this.view.encodeCall.transferFrom(from, to, value, {
548
+ chainId,
549
+ address,
550
+ blockTag,
551
+ });
552
+ },
553
+ decimals(overrides) {
554
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
555
+ const address = this.context.address;
556
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
557
+ if (overrides?.blockTag) {
558
+ blockTag =
559
+ typeof overrides.blockTag == "string"
560
+ ? overrides.blockTag
561
+ : "0x" + overrides.blockTag.toString(16);
562
+ }
563
+ return this.view.encodeCall.decimals({ chainId, address, blockTag });
564
+ },
565
+ balanceOf(who, overrides) {
566
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
567
+ const address = this.context.address;
568
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
569
+ if (overrides?.blockTag) {
570
+ blockTag =
571
+ typeof overrides.blockTag == "string"
572
+ ? overrides.blockTag
573
+ : "0x" + overrides.blockTag.toString(16);
574
+ }
575
+ return this.view.encodeCall.balanceOf(who, {
576
+ chainId,
577
+ address,
578
+ blockTag,
579
+ });
580
+ },
581
+ symbol(overrides) {
582
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
583
+ const address = this.context.address;
584
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
585
+ if (overrides?.blockTag) {
586
+ blockTag =
587
+ typeof overrides.blockTag == "string"
588
+ ? overrides.blockTag
589
+ : "0x" + overrides.blockTag.toString(16);
590
+ }
591
+ return this.view.encodeCall.symbol({ chainId, address, blockTag });
592
+ },
593
+ transfer(to, value, overrides) {
594
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
595
+ const address = this.context.address;
596
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
597
+ if (overrides?.blockTag) {
598
+ blockTag =
599
+ typeof overrides.blockTag == "string"
600
+ ? overrides.blockTag
601
+ : "0x" + overrides.blockTag.toString(16);
602
+ }
603
+ return this.view.encodeCall.transfer(to, value, {
604
+ chainId,
605
+ address,
606
+ blockTag,
607
+ });
608
+ },
609
+ allowance(owner, spender, overrides) {
610
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
611
+ const address = this.context.address;
612
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
613
+ if (overrides?.blockTag) {
614
+ blockTag =
615
+ typeof overrides.blockTag == "string"
616
+ ? overrides.blockTag
617
+ : "0x" + overrides.blockTag.toString(16);
618
+ }
619
+ return this.view.encodeCall.allowance(owner, spender, {
620
+ chainId,
621
+ address,
622
+ blockTag,
156
623
  });
157
624
  },
158
625
  };