@sentio/sdk 2.40.0-rc.3 → 2.40.0-rc.31

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 (147) 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/eth/account-processor.d.ts +21 -7
  17. package/lib/eth/account-processor.d.ts.map +1 -1
  18. package/lib/eth/account-processor.js +2 -2
  19. package/lib/eth/account-processor.js.map +1 -1
  20. package/lib/eth/base-processor-template.d.ts +24 -8
  21. package/lib/eth/base-processor-template.d.ts.map +1 -1
  22. package/lib/eth/base-processor-template.js.map +1 -1
  23. package/lib/eth/base-processor.d.ts +30 -10
  24. package/lib/eth/base-processor.d.ts.map +1 -1
  25. package/lib/eth/base-processor.js +6 -6
  26. package/lib/eth/base-processor.js.map +1 -1
  27. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +100 -31
  28. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +1 -1
  29. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +1295 -46
  30. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  31. package/lib/eth/builtin/internal/erc1155-processor.d.ts +55 -16
  32. package/lib/eth/builtin/internal/erc1155-processor.d.ts.map +1 -1
  33. package/lib/eth/builtin/internal/erc1155-processor.js +510 -16
  34. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  35. package/lib/eth/builtin/internal/erc20-processor.d.ts +79 -24
  36. package/lib/eth/builtin/internal/erc20-processor.d.ts.map +1 -1
  37. package/lib/eth/builtin/internal/erc20-processor.js +1039 -36
  38. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  39. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +46 -13
  40. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts.map +1 -1
  41. package/lib/eth/builtin/internal/erc20bytes-processor.js +512 -18
  42. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  43. package/lib/eth/builtin/internal/erc721-processor.d.ts +67 -20
  44. package/lib/eth/builtin/internal/erc721-processor.d.ts.map +1 -1
  45. package/lib/eth/builtin/internal/erc721-processor.js +826 -28
  46. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  47. package/lib/eth/builtin/internal/weth9-processor.d.ts +64 -19
  48. package/lib/eth/builtin/internal/weth9-processor.d.ts.map +1 -1
  49. package/lib/eth/builtin/internal/weth9-processor.js +607 -22
  50. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  51. package/lib/eth/codegen/event-handler.js +1 -1
  52. package/lib/eth/codegen/file.d.ts.map +1 -1
  53. package/lib/eth/codegen/file.js +21 -3
  54. package/lib/eth/codegen/file.js.map +1 -1
  55. package/lib/eth/codegen/function-calls.d.ts +4 -0
  56. package/lib/eth/codegen/function-calls.d.ts.map +1 -1
  57. package/lib/eth/codegen/function-calls.js +83 -5
  58. package/lib/eth/codegen/function-calls.js.map +1 -1
  59. package/lib/eth/codegen/types.d.ts +1 -0
  60. package/lib/eth/codegen/types.d.ts.map +1 -1
  61. package/lib/eth/codegen/types.js +13 -0
  62. package/lib/eth/codegen/types.js.map +1 -1
  63. package/lib/eth/context.d.ts +4 -0
  64. package/lib/eth/context.d.ts.map +1 -1
  65. package/lib/eth/context.js +4 -0
  66. package/lib/eth/context.js.map +1 -1
  67. package/lib/eth/eth-plugin.d.ts +27 -9
  68. package/lib/eth/eth-plugin.d.ts.map +1 -1
  69. package/lib/eth/eth-plugin.js +20 -17
  70. package/lib/eth/eth-plugin.js.map +1 -1
  71. package/lib/eth/eth.d.ts.map +1 -1
  72. package/lib/eth/eth.js +1 -1
  73. package/lib/eth/eth.js.map +1 -1
  74. package/lib/eth/generic-processor.js +1 -1
  75. package/lib/eth/generic-processor.js.map +1 -1
  76. package/lib/eth/generic-processor.test.js.map +1 -1
  77. package/lib/eth/index.d.ts +2 -1
  78. package/lib/eth/index.d.ts.map +1 -1
  79. package/lib/eth/index.js +2 -1
  80. package/lib/eth/index.js.map +1 -1
  81. package/lib/solana/builtin/spl-token-processor.d.ts +1 -1
  82. package/lib/solana/builtin/spl-token-processor.d.ts.map +1 -1
  83. package/lib/solana/builtin/spl-token-processor.js +1 -1
  84. package/lib/solana/builtin/spl-token-processor.js.map +1 -1
  85. package/lib/solana/solana-context.d.ts +1 -1
  86. package/lib/solana/solana-context.js +2 -2
  87. package/lib/store/cache.d.ts +14 -0
  88. package/lib/store/cache.d.ts.map +1 -0
  89. package/lib/store/cache.js +35 -0
  90. package/lib/store/cache.js.map +1 -0
  91. package/lib/store/store.d.ts +2 -3
  92. package/lib/store/store.d.ts.map +1 -1
  93. package/lib/store/store.js +34 -9
  94. package/lib/store/store.js.map +1 -1
  95. package/lib/sui/context.d.ts +1 -1
  96. package/lib/sui/context.d.ts.map +1 -1
  97. package/lib/sui/sui-processor.d.ts +1 -1
  98. package/lib/sui/sui-processor.d.ts.map +1 -1
  99. package/lib/sui/sui-processor.js +1 -1
  100. package/lib/sui/sui-processor.js.map +1 -1
  101. package/lib/testing/aptos-facet.d.ts +1 -1
  102. package/lib/testing/aptos-facet.js +2 -2
  103. package/lib/testing/sui-facet.js +1 -1
  104. package/lib/utils/dex-price.d.ts +1 -0
  105. package/lib/utils/dex-price.d.ts.map +1 -1
  106. package/lib/utils/dex-price.js +13 -2
  107. package/lib/utils/dex-price.js.map +1 -1
  108. package/package.json +8 -7
  109. package/src/aptos/aptos-processor.ts +1 -1
  110. package/src/aptos/context.ts +2 -2
  111. package/src/aptos/ext/aptos-dex.ts +1 -1
  112. package/src/aptos/ext/coin-event.ts +1 -1
  113. package/src/aptos/ext/coin.ts +2 -2
  114. package/src/eth/account-processor.ts +28 -12
  115. package/src/eth/base-processor-template.ts +16 -8
  116. package/src/eth/base-processor.ts +25 -16
  117. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +1643 -123
  118. package/src/eth/builtin/internal/erc1155-processor.ts +724 -42
  119. package/src/eth/builtin/internal/erc20-processor.ts +1368 -90
  120. package/src/eth/builtin/internal/erc20bytes-processor.ts +685 -49
  121. package/src/eth/builtin/internal/erc721-processor.ts +1116 -70
  122. package/src/eth/builtin/internal/weth9-processor.ts +798 -63
  123. package/src/eth/codegen/event-handler.ts +1 -1
  124. package/src/eth/codegen/file.ts +26 -3
  125. package/src/eth/codegen/function-calls.ts +101 -8
  126. package/src/eth/codegen/types.ts +22 -1
  127. package/src/eth/context.ts +7 -0
  128. package/src/eth/eth-plugin.ts +34 -26
  129. package/src/eth/eth.ts +1 -2
  130. package/src/eth/generic-processor.ts +1 -1
  131. package/src/eth/index.ts +5 -1
  132. package/src/solana/builtin/spl-token-processor.ts +1 -1
  133. package/src/solana/solana-context.ts +2 -2
  134. package/src/store/cache.ts +46 -0
  135. package/src/store/store.ts +40 -22
  136. package/src/sui/context.ts +1 -1
  137. package/src/sui/sui-processor.ts +1 -1
  138. package/src/testing/aptos-facet.ts +2 -2
  139. package/src/testing/sui-facet.ts +1 -1
  140. package/src/utils/dex-price.ts +15 -2
  141. package/lib/eth/provider.d.ts +0 -5
  142. package/lib/eth/provider.d.ts.map +0 -1
  143. package/lib/eth/provider.js +0 -134
  144. package/lib/eth/provider.js.map +0 -1
  145. package/lib/utils/chainlink-oracles-sepolia.csv +0 -19
  146. package/lib/utils/chainlink-oracles.csv +0 -217
  147. 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 { ERC1155__factory } from "./index.js";
3
7
  const templateContract = ERC1155__factory.connect("0x0", DummyProvider);
4
8
  export class ERC1155ContractView extends ContractView {
@@ -6,8 +10,26 @@ export class ERC1155ContractView extends ContractView {
6
10
  super(contract);
7
11
  this.callStatic.contract = contract;
8
12
  }
9
- async balanceOf(account, id, overrides) {
13
+ async balanceOf(account, id, overrides, preparedData, ethCallContext) {
10
14
  try {
15
+ if (preparedData?.ethCallResults && ethCallContext) {
16
+ const iface = new Interface([
17
+ "function balanceOf(address,uint256) view returns (uint256)",
18
+ ]);
19
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
20
+ const key = makeEthCallKey({
21
+ context: ethCallContext,
22
+ calldata,
23
+ });
24
+ console.debug("looking up eth call key:", key);
25
+ const ret = preparedData.ethCallResults[key];
26
+ if (ret) {
27
+ console.debug("prepared eth call found:", key);
28
+ const result = iface.decodeFunctionResult("balanceOf", ret).toArray();
29
+ return result.length == 1 ? result[0] : result;
30
+ }
31
+ console.debug("missing eth call key:", "balanceOf", account, id, key);
32
+ }
11
33
  return await this.contract.getFunction("balanceOf(address,uint256)")(account, id, overrides || {});
12
34
  }
13
35
  catch (e) {
@@ -15,8 +37,31 @@ export class ERC1155ContractView extends ContractView {
15
37
  throw transformEtherError(e, undefined, stack);
16
38
  }
17
39
  }
18
- async balanceOfBatch(accounts, ids, overrides) {
40
+ async balanceOfBatch(accounts, ids, overrides, preparedData, ethCallContext) {
19
41
  try {
42
+ if (preparedData?.ethCallResults && ethCallContext) {
43
+ const iface = new Interface([
44
+ "function balanceOfBatch(address[],uint256[]) view returns (uint256[])",
45
+ ]);
46
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
47
+ accounts,
48
+ ids,
49
+ ]);
50
+ const key = makeEthCallKey({
51
+ context: ethCallContext,
52
+ calldata,
53
+ });
54
+ console.debug("looking up eth call key:", key);
55
+ const ret = preparedData.ethCallResults[key];
56
+ if (ret) {
57
+ console.debug("prepared eth call found:", key);
58
+ const result = iface
59
+ .decodeFunctionResult("balanceOfBatch", ret)
60
+ .toArray();
61
+ return result.length == 1 ? result[0] : result;
62
+ }
63
+ console.debug("missing eth call key:", "balanceOfBatch", accounts, ids, key);
64
+ }
20
65
  return await this.contract.getFunction("balanceOfBatch(address[],uint256[])")(accounts, ids, overrides || {});
21
66
  }
22
67
  catch (e) {
@@ -24,8 +69,31 @@ export class ERC1155ContractView extends ContractView {
24
69
  throw transformEtherError(e, undefined, stack);
25
70
  }
26
71
  }
27
- async isApprovedForAll(account, operator, overrides) {
72
+ async isApprovedForAll(account, operator, overrides, preparedData, ethCallContext) {
28
73
  try {
74
+ if (preparedData?.ethCallResults && ethCallContext) {
75
+ const iface = new Interface([
76
+ "function isApprovedForAll(address,address) view returns (bool)",
77
+ ]);
78
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
79
+ account,
80
+ operator,
81
+ ]);
82
+ const key = makeEthCallKey({
83
+ context: ethCallContext,
84
+ calldata,
85
+ });
86
+ console.debug("looking up eth call key:", key);
87
+ const ret = preparedData.ethCallResults[key];
88
+ if (ret) {
89
+ console.debug("prepared eth call found:", key);
90
+ const result = iface
91
+ .decodeFunctionResult("isApprovedForAll", ret)
92
+ .toArray();
93
+ return result.length == 1 ? result[0] : result;
94
+ }
95
+ console.debug("missing eth call key:", "isApprovedForAll", account, operator, key);
96
+ }
29
97
  return await this.contract.getFunction("isApprovedForAll(address,address)")(account, operator, overrides || {});
30
98
  }
31
99
  catch (e) {
@@ -33,8 +101,30 @@ export class ERC1155ContractView extends ContractView {
33
101
  throw transformEtherError(e, undefined, stack);
34
102
  }
35
103
  }
36
- async supportsInterface(interfaceId, overrides) {
104
+ async supportsInterface(interfaceId, overrides, preparedData, ethCallContext) {
37
105
  try {
106
+ if (preparedData?.ethCallResults && ethCallContext) {
107
+ const iface = new Interface([
108
+ "function supportsInterface(bytes4) view returns (bool)",
109
+ ]);
110
+ const calldata = iface.encodeFunctionData("supportsInterface", [
111
+ interfaceId,
112
+ ]);
113
+ const key = makeEthCallKey({
114
+ context: ethCallContext,
115
+ calldata,
116
+ });
117
+ console.debug("looking up eth call key:", key);
118
+ const ret = preparedData.ethCallResults[key];
119
+ if (ret) {
120
+ console.debug("prepared eth call found:", key);
121
+ const result = iface
122
+ .decodeFunctionResult("supportsInterface", ret)
123
+ .toArray();
124
+ return result.length == 1 ? result[0] : result;
125
+ }
126
+ console.debug("missing eth call key:", "supportsInterface", interfaceId, key);
127
+ }
38
128
  return await this.contract.getFunction("supportsInterface(bytes4)")(interfaceId, overrides || {});
39
129
  }
40
130
  catch (e) {
@@ -42,8 +132,26 @@ export class ERC1155ContractView extends ContractView {
42
132
  throw transformEtherError(e, undefined, stack);
43
133
  }
44
134
  }
45
- async uri(id, overrides) {
135
+ async uri(id, overrides, preparedData, ethCallContext) {
46
136
  try {
137
+ if (preparedData?.ethCallResults && ethCallContext) {
138
+ const iface = new Interface([
139
+ "function uri(uint256) view returns (string)",
140
+ ]);
141
+ const calldata = iface.encodeFunctionData("uri", [id]);
142
+ const key = makeEthCallKey({
143
+ context: ethCallContext,
144
+ calldata,
145
+ });
146
+ console.debug("looking up eth call key:", key);
147
+ const ret = preparedData.ethCallResults[key];
148
+ if (ret) {
149
+ console.debug("prepared eth call found:", key);
150
+ const result = iface.decodeFunctionResult("uri", ret).toArray();
151
+ return result.length == 1 ? result[0] : result;
152
+ }
153
+ console.debug("missing eth call key:", "uri", id, key);
154
+ }
47
155
  return await this.contract.getFunction("uri(uint256)")(id, overrides || {});
48
156
  }
49
157
  catch (e) {
@@ -53,8 +161,34 @@ export class ERC1155ContractView extends ContractView {
53
161
  }
54
162
  callStatic = {
55
163
  contract: this.contract,
56
- async safeBatchTransferFrom(from, to, ids, amounts, data, overrides) {
164
+ async safeBatchTransferFrom(from, to, ids, amounts, data, overrides, preparedData, ethCallContext) {
57
165
  try {
166
+ if (preparedData?.ethCallResults && ethCallContext) {
167
+ const iface = new Interface([
168
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes) nonpayable returns ()",
169
+ ]);
170
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
171
+ from,
172
+ to,
173
+ ids,
174
+ amounts,
175
+ data,
176
+ ]);
177
+ const key = makeEthCallKey({
178
+ context: ethCallContext,
179
+ calldata,
180
+ });
181
+ console.debug("looking up eth call key:", key);
182
+ const ret = preparedData.ethCallResults[key];
183
+ if (ret) {
184
+ console.debug("prepared eth call found:", key);
185
+ const result = iface
186
+ .decodeFunctionResult("safeBatchTransferFrom", ret)
187
+ .toArray();
188
+ return result.length == 1 ? result[0] : result;
189
+ }
190
+ console.debug("missing eth call key:", "safeBatchTransferFrom", from, to, ids, amounts, data, key);
191
+ }
58
192
  return await this.contract
59
193
  .getFunction("safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)")
60
194
  .staticCall(from, to, ids, amounts, data, overrides || {});
@@ -64,8 +198,34 @@ export class ERC1155ContractView extends ContractView {
64
198
  throw transformEtherError(e, undefined, stack);
65
199
  }
66
200
  },
67
- async safeTransferFrom(from, to, id, amount, data, overrides) {
201
+ async safeTransferFrom(from, to, id, amount, data, overrides, preparedData, ethCallContext) {
68
202
  try {
203
+ if (preparedData?.ethCallResults && ethCallContext) {
204
+ const iface = new Interface([
205
+ "function safeTransferFrom(address,address,uint256,uint256,bytes) nonpayable returns ()",
206
+ ]);
207
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
208
+ from,
209
+ to,
210
+ id,
211
+ amount,
212
+ data,
213
+ ]);
214
+ const key = makeEthCallKey({
215
+ context: ethCallContext,
216
+ calldata,
217
+ });
218
+ console.debug("looking up eth call key:", key);
219
+ const ret = preparedData.ethCallResults[key];
220
+ if (ret) {
221
+ console.debug("prepared eth call found:", key);
222
+ const result = iface
223
+ .decodeFunctionResult("safeTransferFrom", ret)
224
+ .toArray();
225
+ return result.length == 1 ? result[0] : result;
226
+ }
227
+ console.debug("missing eth call key:", "safeTransferFrom", from, to, id, amount, data, key);
228
+ }
69
229
  return await this.contract
70
230
  .getFunction("safeTransferFrom(address,address,uint256,uint256,bytes)")
71
231
  .staticCall(from, to, id, amount, data, overrides || {});
@@ -75,8 +235,31 @@ export class ERC1155ContractView extends ContractView {
75
235
  throw transformEtherError(e, undefined, stack);
76
236
  }
77
237
  },
78
- async setApprovalForAll(operator, approved, overrides) {
238
+ async setApprovalForAll(operator, approved, overrides, preparedData, ethCallContext) {
79
239
  try {
240
+ if (preparedData?.ethCallResults && ethCallContext) {
241
+ const iface = new Interface([
242
+ "function setApprovalForAll(address,bool) nonpayable returns ()",
243
+ ]);
244
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
245
+ operator,
246
+ approved,
247
+ ]);
248
+ const key = makeEthCallKey({
249
+ context: ethCallContext,
250
+ calldata,
251
+ });
252
+ console.debug("looking up eth call key:", key);
253
+ const ret = preparedData.ethCallResults[key];
254
+ if (ret) {
255
+ console.debug("prepared eth call found:", key);
256
+ const result = iface
257
+ .decodeFunctionResult("setApprovalForAll", ret)
258
+ .toArray();
259
+ return result.length == 1 ? result[0] : result;
260
+ }
261
+ console.debug("missing eth call key:", "setApprovalForAll", operator, approved, key);
262
+ }
80
263
  return await this.contract
81
264
  .getFunction("setApprovalForAll(address,bool)")
82
265
  .staticCall(operator, approved, overrides || {});
@@ -87,59 +270,370 @@ export class ERC1155ContractView extends ContractView {
87
270
  }
88
271
  },
89
272
  };
273
+ encodeCall = {
274
+ balanceOf(account, id, ethCallContext) {
275
+ try {
276
+ const iface = new Interface(["function balanceOf(address,uint256)"]);
277
+ const calldata = iface.encodeFunctionData("balanceOf", [account, id]);
278
+ return {
279
+ context: ethCallContext,
280
+ calldata,
281
+ };
282
+ }
283
+ catch (e) {
284
+ const stack = new Error().stack;
285
+ throw transformEtherError(e, undefined, stack);
286
+ }
287
+ },
288
+ balanceOfBatch(accounts, ids, ethCallContext) {
289
+ try {
290
+ const iface = new Interface([
291
+ "function balanceOfBatch(address[],uint256[])",
292
+ ]);
293
+ const calldata = iface.encodeFunctionData("balanceOfBatch", [
294
+ accounts,
295
+ ids,
296
+ ]);
297
+ return {
298
+ context: ethCallContext,
299
+ calldata,
300
+ };
301
+ }
302
+ catch (e) {
303
+ const stack = new Error().stack;
304
+ throw transformEtherError(e, undefined, stack);
305
+ }
306
+ },
307
+ isApprovedForAll(account, operator, ethCallContext) {
308
+ try {
309
+ const iface = new Interface([
310
+ "function isApprovedForAll(address,address)",
311
+ ]);
312
+ const calldata = iface.encodeFunctionData("isApprovedForAll", [
313
+ account,
314
+ operator,
315
+ ]);
316
+ return {
317
+ context: ethCallContext,
318
+ calldata,
319
+ };
320
+ }
321
+ catch (e) {
322
+ const stack = new Error().stack;
323
+ throw transformEtherError(e, undefined, stack);
324
+ }
325
+ },
326
+ safeBatchTransferFrom(from, to, ids, amounts, data, ethCallContext) {
327
+ try {
328
+ const iface = new Interface([
329
+ "function safeBatchTransferFrom(address,address,uint256[],uint256[],bytes)",
330
+ ]);
331
+ const calldata = iface.encodeFunctionData("safeBatchTransferFrom", [
332
+ from,
333
+ to,
334
+ ids,
335
+ amounts,
336
+ data,
337
+ ]);
338
+ return {
339
+ context: ethCallContext,
340
+ calldata,
341
+ };
342
+ }
343
+ catch (e) {
344
+ const stack = new Error().stack;
345
+ throw transformEtherError(e, undefined, stack);
346
+ }
347
+ },
348
+ safeTransferFrom(from, to, id, amount, data, ethCallContext) {
349
+ try {
350
+ const iface = new Interface([
351
+ "function safeTransferFrom(address,address,uint256,uint256,bytes)",
352
+ ]);
353
+ const calldata = iface.encodeFunctionData("safeTransferFrom", [
354
+ from,
355
+ to,
356
+ id,
357
+ amount,
358
+ data,
359
+ ]);
360
+ return {
361
+ context: ethCallContext,
362
+ calldata,
363
+ };
364
+ }
365
+ catch (e) {
366
+ const stack = new Error().stack;
367
+ throw transformEtherError(e, undefined, stack);
368
+ }
369
+ },
370
+ setApprovalForAll(operator, approved, ethCallContext) {
371
+ try {
372
+ const iface = new Interface([
373
+ "function setApprovalForAll(address,bool)",
374
+ ]);
375
+ const calldata = iface.encodeFunctionData("setApprovalForAll", [
376
+ operator,
377
+ approved,
378
+ ]);
379
+ return {
380
+ context: ethCallContext,
381
+ calldata,
382
+ };
383
+ }
384
+ catch (e) {
385
+ const stack = new Error().stack;
386
+ throw transformEtherError(e, undefined, stack);
387
+ }
388
+ },
389
+ supportsInterface(interfaceId, ethCallContext) {
390
+ try {
391
+ const iface = new Interface(["function supportsInterface(bytes4)"]);
392
+ const calldata = iface.encodeFunctionData("supportsInterface", [
393
+ interfaceId,
394
+ ]);
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
+ uri(id, ethCallContext) {
406
+ try {
407
+ const iface = new Interface(["function uri(uint256)"]);
408
+ const calldata = iface.encodeFunctionData("uri", [id]);
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
+ };
90
420
  }
91
421
  export class ERC1155BoundContractView extends BoundContractView {
92
422
  async balanceOf(account, id, overrides) {
423
+ const ethCallContext = {
424
+ chainId: this.context.chainId,
425
+ blockTag: "0x" + this.context.blockNumber.toString(16),
426
+ address: this.context.address,
427
+ };
93
428
  return await this.view.balanceOf(account, id, {
94
429
  blockTag: this.context.blockNumber,
95
430
  ...overrides,
96
- });
431
+ }, this.context.preparedData, ethCallContext);
97
432
  }
98
433
  async balanceOfBatch(accounts, ids, overrides) {
434
+ const ethCallContext = {
435
+ chainId: this.context.chainId,
436
+ blockTag: "0x" + this.context.blockNumber.toString(16),
437
+ address: this.context.address,
438
+ };
99
439
  return await this.view.balanceOfBatch(accounts, ids, {
100
440
  blockTag: this.context.blockNumber,
101
441
  ...overrides,
102
- });
442
+ }, this.context.preparedData, ethCallContext);
103
443
  }
104
444
  async isApprovedForAll(account, operator, overrides) {
445
+ const ethCallContext = {
446
+ chainId: this.context.chainId,
447
+ blockTag: "0x" + this.context.blockNumber.toString(16),
448
+ address: this.context.address,
449
+ };
105
450
  return await this.view.isApprovedForAll(account, operator, {
106
451
  blockTag: this.context.blockNumber,
107
452
  ...overrides,
108
- });
453
+ }, this.context.preparedData, ethCallContext);
109
454
  }
110
455
  async supportsInterface(interfaceId, overrides) {
456
+ const ethCallContext = {
457
+ chainId: this.context.chainId,
458
+ blockTag: "0x" + this.context.blockNumber.toString(16),
459
+ address: this.context.address,
460
+ };
111
461
  return await this.view.supportsInterface(interfaceId, {
112
462
  blockTag: this.context.blockNumber,
113
463
  ...overrides,
114
- });
464
+ }, this.context.preparedData, ethCallContext);
115
465
  }
116
466
  async uri(id, overrides) {
467
+ const ethCallContext = {
468
+ chainId: this.context.chainId,
469
+ blockTag: "0x" + this.context.blockNumber.toString(16),
470
+ address: this.context.address,
471
+ };
117
472
  return await this.view.uri(id, {
118
473
  blockTag: this.context.blockNumber,
119
474
  ...overrides,
120
- });
475
+ }, this.context.preparedData, ethCallContext);
121
476
  }
122
477
  callStatic = {
123
478
  view: this.view,
124
479
  context: this.context,
125
480
  async safeBatchTransferFrom(from, to, ids, amounts, data, overrides) {
481
+ const ethCallContext = {
482
+ chainId: this.context.chainId,
483
+ blockTag: "0x" + this.context.blockNumber.toString(16),
484
+ address: this.context.address,
485
+ };
126
486
  return await this.view.callStatic.safeBatchTransferFrom(from, to, ids, amounts, data, {
127
487
  blockTag: this.context.blockNumber,
128
488
  ...overrides,
129
- });
489
+ }, this.context.preparedData, ethCallContext);
130
490
  },
131
491
  async safeTransferFrom(from, to, id, amount, data, overrides) {
492
+ const ethCallContext = {
493
+ chainId: this.context.chainId,
494
+ blockTag: "0x" + this.context.blockNumber.toString(16),
495
+ address: this.context.address,
496
+ };
132
497
  return await this.view.callStatic.safeTransferFrom(from, to, id, amount, data, {
133
498
  blockTag: this.context.blockNumber,
134
499
  ...overrides,
135
- });
500
+ }, this.context.preparedData, ethCallContext);
136
501
  },
137
502
  async setApprovalForAll(operator, approved, overrides) {
503
+ const ethCallContext = {
504
+ chainId: this.context.chainId,
505
+ blockTag: "0x" + this.context.blockNumber.toString(16),
506
+ address: this.context.address,
507
+ };
138
508
  return await this.view.callStatic.setApprovalForAll(operator, approved, {
139
509
  blockTag: this.context.blockNumber,
140
510
  ...overrides,
511
+ }, this.context.preparedData, ethCallContext);
512
+ },
513
+ };
514
+ encodeCall = {
515
+ view: this.view,
516
+ context: this.context,
517
+ balanceOf(account, id, overrides) {
518
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
519
+ const address = this.context.address;
520
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
521
+ if (overrides?.blockTag) {
522
+ blockTag =
523
+ typeof overrides.blockTag == "string"
524
+ ? overrides.blockTag
525
+ : "0x" + overrides.blockTag.toString(16);
526
+ }
527
+ return this.view.encodeCall.balanceOf(account, id, {
528
+ chainId,
529
+ address,
530
+ blockTag,
531
+ });
532
+ },
533
+ balanceOfBatch(accounts, ids, overrides) {
534
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
535
+ const address = this.context.address;
536
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
537
+ if (overrides?.blockTag) {
538
+ blockTag =
539
+ typeof overrides.blockTag == "string"
540
+ ? overrides.blockTag
541
+ : "0x" + overrides.blockTag.toString(16);
542
+ }
543
+ return this.view.encodeCall.balanceOfBatch(accounts, ids, {
544
+ chainId,
545
+ address,
546
+ blockTag,
547
+ });
548
+ },
549
+ isApprovedForAll(account, operator, overrides) {
550
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
551
+ const address = this.context.address;
552
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
553
+ if (overrides?.blockTag) {
554
+ blockTag =
555
+ typeof overrides.blockTag == "string"
556
+ ? overrides.blockTag
557
+ : "0x" + overrides.blockTag.toString(16);
558
+ }
559
+ return this.view.encodeCall.isApprovedForAll(account, operator, {
560
+ chainId,
561
+ address,
562
+ blockTag,
563
+ });
564
+ },
565
+ safeBatchTransferFrom(from, to, ids, amounts, data, 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.safeBatchTransferFrom(from, to, ids, amounts, data, { chainId, address, blockTag });
576
+ },
577
+ safeTransferFrom(from, to, id, amount, data, overrides) {
578
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
579
+ const address = this.context.address;
580
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
581
+ if (overrides?.blockTag) {
582
+ blockTag =
583
+ typeof overrides.blockTag == "string"
584
+ ? overrides.blockTag
585
+ : "0x" + overrides.blockTag.toString(16);
586
+ }
587
+ return this.view.encodeCall.safeTransferFrom(from, to, id, amount, data, {
588
+ chainId,
589
+ address,
590
+ blockTag,
591
+ });
592
+ },
593
+ setApprovalForAll(operator, approved, 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.setApprovalForAll(operator, approved, {
604
+ chainId,
605
+ address,
606
+ blockTag,
607
+ });
608
+ },
609
+ supportsInterface(interfaceId, 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.supportsInterface(interfaceId, {
620
+ chainId,
621
+ address,
622
+ blockTag,
141
623
  });
142
624
  },
625
+ uri(id, overrides) {
626
+ const chainId = overrides?.chainId?.toString() ?? this.context.chainId.toString();
627
+ const address = this.context.address;
628
+ let blockTag = "0x" + this.context.blockNumber.toString(16);
629
+ if (overrides?.blockTag) {
630
+ blockTag =
631
+ typeof overrides.blockTag == "string"
632
+ ? overrides.blockTag
633
+ : "0x" + overrides.blockTag.toString(16);
634
+ }
635
+ return this.view.encodeCall.uri(id, { chainId, address, blockTag });
636
+ },
143
637
  };
144
638
  }
145
639
  export class ERC1155Processor extends BaseProcessor {