@sentio/sdk 2.15.6-rc.1 → 2.15.6-rc.3

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 (43) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +3 -3
  2. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js +81 -114
  3. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.js.map +1 -1
  4. package/lib/eth/builtin/internal/erc1155-processor.d.ts +3 -3
  5. package/lib/eth/builtin/internal/erc1155-processor.js +29 -36
  6. package/lib/eth/builtin/internal/erc1155-processor.js.map +1 -1
  7. package/lib/eth/builtin/internal/erc20-processor.d.ts +3 -3
  8. package/lib/eth/builtin/internal/erc20-processor.js +41 -54
  9. package/lib/eth/builtin/internal/erc20-processor.js.map +1 -1
  10. package/lib/eth/builtin/internal/erc20bytes-processor.d.ts +3 -3
  11. package/lib/eth/builtin/internal/erc20bytes-processor.js +33 -42
  12. package/lib/eth/builtin/internal/erc20bytes-processor.js.map +1 -1
  13. package/lib/eth/builtin/internal/erc721-processor.d.ts +3 -3
  14. package/lib/eth/builtin/internal/erc721-processor.js +45 -60
  15. package/lib/eth/builtin/internal/erc721-processor.js.map +1 -1
  16. package/lib/eth/builtin/internal/weth9-processor.d.ts +3 -3
  17. package/lib/eth/builtin/internal/weth9-processor.js +33 -42
  18. package/lib/eth/builtin/internal/weth9-processor.js.map +1 -1
  19. package/lib/eth/codegen/file.js +12 -9
  20. package/lib/eth/codegen/file.js.map +1 -1
  21. package/lib/eth/codegen/view-function.js +4 -6
  22. package/lib/eth/codegen/view-function.js.map +1 -1
  23. package/lib/eth/index.d.ts +1 -1
  24. package/lib/eth/index.js +1 -1
  25. package/lib/eth/index.js.map +1 -1
  26. package/lib/eth/provider.d.ts +0 -2
  27. package/lib/eth/provider.js +9 -10
  28. package/lib/eth/provider.js.map +1 -1
  29. package/lib/eth/provider.test.js.map +1 -1
  30. package/lib/utils/token.js +9 -2
  31. package/lib/utils/token.js.map +1 -1
  32. package/package.json +3 -3
  33. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +86 -115
  34. package/src/eth/builtin/internal/erc1155-processor.ts +34 -37
  35. package/src/eth/builtin/internal/erc20-processor.ts +46 -55
  36. package/src/eth/builtin/internal/erc20bytes-processor.ts +38 -43
  37. package/src/eth/builtin/internal/erc721-processor.ts +50 -61
  38. package/src/eth/builtin/internal/weth9-processor.ts +38 -43
  39. package/src/eth/codegen/file.ts +12 -11
  40. package/src/eth/codegen/view-function.ts +4 -6
  41. package/src/eth/index.ts +1 -1
  42. package/src/eth/provider.ts +9 -11
  43. package/src/utils/token.ts +9 -2
@@ -18,13 +18,13 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
25
24
 
26
- import { ERC1155, ERC1155__factory } from "./index.js";
25
+ import { ERC1155__factory } from "./index.js";
27
26
  import {
27
+ ERC1155,
28
28
  ApprovalForAllEvent,
29
29
  ApprovalForAllEventFilter,
30
30
  TransferBatchEvent,
@@ -202,12 +202,10 @@ export class ERC1155BoundContractView extends BoundContractView<
202
202
  id: BigNumberish,
203
203
  overrides?: Overrides
204
204
  ): Promise<bigint> {
205
- if (!overrides && this.context) {
206
- overrides = {
207
- blockTag: this.context.blockNumber,
208
- };
209
- }
210
- return await this.view.balanceOf(account, id, overrides || {});
205
+ return await this.view.balanceOf(account, id, {
206
+ blockTag: this.context.blockNumber,
207
+ ...overrides,
208
+ });
211
209
  }
212
210
 
213
211
  async balanceOfBatch(
@@ -215,12 +213,10 @@ export class ERC1155BoundContractView extends BoundContractView<
215
213
  ids: BigNumberish[],
216
214
  overrides?: Overrides
217
215
  ): Promise<bigint[]> {
218
- if (!overrides && this.context) {
219
- overrides = {
220
- blockTag: this.context.blockNumber,
221
- };
222
- }
223
- return await this.view.balanceOfBatch(accounts, ids, overrides || {});
216
+ return await this.view.balanceOfBatch(accounts, ids, {
217
+ blockTag: this.context.blockNumber,
218
+ ...overrides,
219
+ });
224
220
  }
225
221
 
226
222
  async isApprovedForAll(
@@ -228,33 +224,27 @@ export class ERC1155BoundContractView extends BoundContractView<
228
224
  operator: string,
229
225
  overrides?: Overrides
230
226
  ): Promise<boolean> {
231
- if (!overrides && this.context) {
232
- overrides = {
233
- blockTag: this.context.blockNumber,
234
- };
235
- }
236
- return await this.view.isApprovedForAll(account, operator, overrides || {});
227
+ return await this.view.isApprovedForAll(account, operator, {
228
+ blockTag: this.context.blockNumber,
229
+ ...overrides,
230
+ });
237
231
  }
238
232
 
239
233
  async supportsInterface(
240
234
  interfaceId: BytesLike,
241
235
  overrides?: Overrides
242
236
  ): Promise<boolean> {
243
- if (!overrides && this.context) {
244
- overrides = {
245
- blockTag: this.context.blockNumber,
246
- };
247
- }
248
- return await this.view.supportsInterface(interfaceId, overrides || {});
237
+ return await this.view.supportsInterface(interfaceId, {
238
+ blockTag: this.context.blockNumber,
239
+ ...overrides,
240
+ });
249
241
  }
250
242
 
251
243
  async uri(id: BigNumberish, overrides?: Overrides): Promise<string> {
252
- if (!overrides && this.context) {
253
- overrides = {
254
- blockTag: this.context.blockNumber,
255
- };
256
- }
257
- return await this.view.uri(id, overrides || {});
244
+ return await this.view.uri(id, {
245
+ blockTag: this.context.blockNumber,
246
+ ...overrides,
247
+ });
258
248
  }
259
249
  }
260
250
 
@@ -502,19 +492,26 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
502
492
  }
503
493
 
504
494
  export function getERC1155Contract(
505
- contextOrNetwork: EthContext | EthChainId,
495
+ chainId: EthChainId,
506
496
  address: string
507
497
  ): ERC1155ContractView {
508
- const network = getEthChainId(contextOrNetwork);
509
498
  let contract = getContractByABI(
510
499
  "ERC1155",
511
500
  address,
512
- network
501
+ chainId
513
502
  ) as ERC1155ContractView;
514
503
  if (!contract) {
515
- const rawContract = ERC1155__factory.connect(address, getProvider(network));
504
+ const rawContract = ERC1155__factory.connect(address, getProvider(chainId));
516
505
  contract = new ERC1155ContractView(rawContract);
517
- addContractByABI("ERC1155", address, network, contract);
506
+ addContractByABI("ERC1155", address, chainId, contract);
518
507
  }
519
508
  return contract;
520
509
  }
510
+
511
+ export function getERC1155ContractOnContext(
512
+ context: EthContext,
513
+ address: string
514
+ ): ERC1155BoundContractView {
515
+ const view = getERC1155Contract(context.getChainId(), address);
516
+ return new ERC1155BoundContractView(address, view);
517
+ }
@@ -18,13 +18,13 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
25
24
 
26
- import { ERC20, ERC20__factory } from "./index.js";
25
+ import { ERC20__factory } from "./index.js";
27
26
  import {
27
+ ERC20,
28
28
  ApprovalEvent,
29
29
  ApprovalEventFilter,
30
30
  OwnershipTransferredEvent,
@@ -254,75 +254,59 @@ export class ERC20BoundContractView extends BoundContractView<
254
254
  spender: string,
255
255
  overrides?: Overrides
256
256
  ): Promise<bigint> {
257
- if (!overrides && this.context) {
258
- overrides = {
259
- blockTag: this.context.blockNumber,
260
- };
261
- }
262
- return await this.view.allowance(owner, spender, overrides || {});
257
+ return await this.view.allowance(owner, spender, {
258
+ blockTag: this.context.blockNumber,
259
+ ...overrides,
260
+ });
263
261
  }
264
262
 
265
263
  async balanceOf(account: string, overrides?: Overrides): Promise<bigint> {
266
- if (!overrides && this.context) {
267
- overrides = {
268
- blockTag: this.context.blockNumber,
269
- };
270
- }
271
- return await this.view.balanceOf(account, overrides || {});
264
+ return await this.view.balanceOf(account, {
265
+ blockTag: this.context.blockNumber,
266
+ ...overrides,
267
+ });
272
268
  }
273
269
 
274
270
  async decimals(overrides?: Overrides): Promise<bigint> {
275
- if (!overrides && this.context) {
276
- overrides = {
277
- blockTag: this.context.blockNumber,
278
- };
279
- }
280
- return await this.view.decimals(overrides || {});
271
+ return await this.view.decimals({
272
+ blockTag: this.context.blockNumber,
273
+ ...overrides,
274
+ });
281
275
  }
282
276
 
283
277
  async locker(overrides?: Overrides): Promise<string> {
284
- if (!overrides && this.context) {
285
- overrides = {
286
- blockTag: this.context.blockNumber,
287
- };
288
- }
289
- return await this.view.locker(overrides || {});
278
+ return await this.view.locker({
279
+ blockTag: this.context.blockNumber,
280
+ ...overrides,
281
+ });
290
282
  }
291
283
 
292
284
  async name(overrides?: Overrides): Promise<string> {
293
- if (!overrides && this.context) {
294
- overrides = {
295
- blockTag: this.context.blockNumber,
296
- };
297
- }
298
- return await this.view.name(overrides || {});
285
+ return await this.view.name({
286
+ blockTag: this.context.blockNumber,
287
+ ...overrides,
288
+ });
299
289
  }
300
290
 
301
291
  async owner(overrides?: Overrides): Promise<string> {
302
- if (!overrides && this.context) {
303
- overrides = {
304
- blockTag: this.context.blockNumber,
305
- };
306
- }
307
- return await this.view.owner(overrides || {});
292
+ return await this.view.owner({
293
+ blockTag: this.context.blockNumber,
294
+ ...overrides,
295
+ });
308
296
  }
309
297
 
310
298
  async symbol(overrides?: Overrides): Promise<string> {
311
- if (!overrides && this.context) {
312
- overrides = {
313
- blockTag: this.context.blockNumber,
314
- };
315
- }
316
- return await this.view.symbol(overrides || {});
299
+ return await this.view.symbol({
300
+ blockTag: this.context.blockNumber,
301
+ ...overrides,
302
+ });
317
303
  }
318
304
 
319
305
  async totalSupply(overrides?: Overrides): Promise<bigint> {
320
- if (!overrides && this.context) {
321
- overrides = {
322
- blockTag: this.context.blockNumber,
323
- };
324
- }
325
- return await this.view.totalSupply(overrides || {});
306
+ return await this.view.totalSupply({
307
+ blockTag: this.context.blockNumber,
308
+ ...overrides,
309
+ });
326
310
  }
327
311
  }
328
312
 
@@ -610,19 +594,26 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
610
594
  }
611
595
 
612
596
  export function getERC20Contract(
613
- contextOrNetwork: EthContext | EthChainId,
597
+ chainId: EthChainId,
614
598
  address: string
615
599
  ): ERC20ContractView {
616
- const network = getEthChainId(contextOrNetwork);
617
600
  let contract = getContractByABI(
618
601
  "ERC20",
619
602
  address,
620
- network
603
+ chainId
621
604
  ) as ERC20ContractView;
622
605
  if (!contract) {
623
- const rawContract = ERC20__factory.connect(address, getProvider(network));
606
+ const rawContract = ERC20__factory.connect(address, getProvider(chainId));
624
607
  contract = new ERC20ContractView(rawContract);
625
- addContractByABI("ERC20", address, network, contract);
608
+ addContractByABI("ERC20", address, chainId, contract);
626
609
  }
627
610
  return contract;
628
611
  }
612
+
613
+ export function getERC20ContractOnContext(
614
+ context: EthContext,
615
+ address: string
616
+ ): ERC20BoundContractView {
617
+ const view = getERC20Contract(context.getChainId(), address);
618
+ return new ERC20BoundContractView(address, view);
619
+ }
@@ -18,13 +18,13 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
25
24
 
26
- import { ERC20Bytes, ERC20Bytes__factory } from "./index.js";
25
+ import { ERC20Bytes__factory } from "./index.js";
27
26
  import {
27
+ ERC20Bytes,
28
28
  ApprovalEvent,
29
29
  ApprovalEventFilter,
30
30
  TransferEvent,
@@ -166,48 +166,38 @@ export class ERC20BytesBoundContractView extends BoundContractView<
166
166
  ERC20BytesContractView
167
167
  > {
168
168
  async name(overrides?: Overrides): Promise<string> {
169
- if (!overrides && this.context) {
170
- overrides = {
171
- blockTag: this.context.blockNumber,
172
- };
173
- }
174
- return await this.view.name(overrides || {});
169
+ return await this.view.name({
170
+ blockTag: this.context.blockNumber,
171
+ ...overrides,
172
+ });
175
173
  }
176
174
 
177
175
  async totalSupply(overrides?: Overrides): Promise<bigint> {
178
- if (!overrides && this.context) {
179
- overrides = {
180
- blockTag: this.context.blockNumber,
181
- };
182
- }
183
- return await this.view.totalSupply(overrides || {});
176
+ return await this.view.totalSupply({
177
+ blockTag: this.context.blockNumber,
178
+ ...overrides,
179
+ });
184
180
  }
185
181
 
186
182
  async decimals(overrides?: Overrides): Promise<bigint> {
187
- if (!overrides && this.context) {
188
- overrides = {
189
- blockTag: this.context.blockNumber,
190
- };
191
- }
192
- return await this.view.decimals(overrides || {});
183
+ return await this.view.decimals({
184
+ blockTag: this.context.blockNumber,
185
+ ...overrides,
186
+ });
193
187
  }
194
188
 
195
189
  async balanceOf(who: string, overrides?: Overrides): Promise<bigint> {
196
- if (!overrides && this.context) {
197
- overrides = {
198
- blockTag: this.context.blockNumber,
199
- };
200
- }
201
- return await this.view.balanceOf(who, overrides || {});
190
+ return await this.view.balanceOf(who, {
191
+ blockTag: this.context.blockNumber,
192
+ ...overrides,
193
+ });
202
194
  }
203
195
 
204
196
  async symbol(overrides?: Overrides): Promise<string> {
205
- if (!overrides && this.context) {
206
- overrides = {
207
- blockTag: this.context.blockNumber,
208
- };
209
- }
210
- return await this.view.symbol(overrides || {});
197
+ return await this.view.symbol({
198
+ blockTag: this.context.blockNumber,
199
+ ...overrides,
200
+ });
211
201
  }
212
202
 
213
203
  async allowance(
@@ -215,12 +205,10 @@ export class ERC20BytesBoundContractView extends BoundContractView<
215
205
  spender: string,
216
206
  overrides?: Overrides
217
207
  ): Promise<bigint> {
218
- if (!overrides && this.context) {
219
- overrides = {
220
- blockTag: this.context.blockNumber,
221
- };
222
- }
223
- return await this.view.allowance(owner, spender, overrides || {});
208
+ return await this.view.allowance(owner, spender, {
209
+ blockTag: this.context.blockNumber,
210
+ ...overrides,
211
+ });
224
212
  }
225
213
  }
226
214
 
@@ -412,22 +400,29 @@ export class ERC20BytesProcessorTemplate extends BaseProcessorTemplate<
412
400
  }
413
401
 
414
402
  export function getERC20BytesContract(
415
- contextOrNetwork: EthContext | EthChainId,
403
+ chainId: EthChainId,
416
404
  address: string
417
405
  ): ERC20BytesContractView {
418
- const network = getEthChainId(contextOrNetwork);
419
406
  let contract = getContractByABI(
420
407
  "ERC20Bytes",
421
408
  address,
422
- network
409
+ chainId
423
410
  ) as ERC20BytesContractView;
424
411
  if (!contract) {
425
412
  const rawContract = ERC20Bytes__factory.connect(
426
413
  address,
427
- getProvider(network)
414
+ getProvider(chainId)
428
415
  );
429
416
  contract = new ERC20BytesContractView(rawContract);
430
- addContractByABI("ERC20Bytes", address, network, contract);
417
+ addContractByABI("ERC20Bytes", address, chainId, contract);
431
418
  }
432
419
  return contract;
433
420
  }
421
+
422
+ export function getERC20BytesContractOnContext(
423
+ context: EthContext,
424
+ address: string
425
+ ): ERC20BytesBoundContractView {
426
+ const view = getERC20BytesContract(context.getChainId(), address);
427
+ return new ERC20BytesBoundContractView(address, view);
428
+ }
@@ -18,13 +18,13 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
25
24
 
26
- import { ERC721, ERC721__factory } from "./index.js";
25
+ import { ERC721__factory } from "./index.js";
27
26
  import {
27
+ ERC721,
28
28
  ApprovalEvent,
29
29
  ApprovalEventFilter,
30
30
  ApprovalForAllEvent,
@@ -261,33 +261,27 @@ export class ERC721BoundContractView extends BoundContractView<
261
261
  ERC721ContractView
262
262
  > {
263
263
  async totalSupply(overrides?: Overrides): Promise<bigint> {
264
- if (!overrides && this.context) {
265
- overrides = {
266
- blockTag: this.context.blockNumber,
267
- };
268
- }
269
- return await this.view.totalSupply(overrides || {});
264
+ return await this.view.totalSupply({
265
+ blockTag: this.context.blockNumber,
266
+ ...overrides,
267
+ });
270
268
  }
271
269
 
272
270
  async balanceOf(owner: string, overrides?: Overrides): Promise<bigint> {
273
- if (!overrides && this.context) {
274
- overrides = {
275
- blockTag: this.context.blockNumber,
276
- };
277
- }
278
- return await this.view.balanceOf(owner, overrides || {});
271
+ return await this.view.balanceOf(owner, {
272
+ blockTag: this.context.blockNumber,
273
+ ...overrides,
274
+ });
279
275
  }
280
276
 
281
277
  async getApproved(
282
278
  tokenId: BigNumberish,
283
279
  overrides?: Overrides
284
280
  ): Promise<string> {
285
- if (!overrides && this.context) {
286
- overrides = {
287
- blockTag: this.context.blockNumber,
288
- };
289
- }
290
- return await this.view.getApproved(tokenId, overrides || {});
281
+ return await this.view.getApproved(tokenId, {
282
+ blockTag: this.context.blockNumber,
283
+ ...overrides,
284
+ });
291
285
  }
292
286
 
293
287
  async isApprovedForAll(
@@ -295,63 +289,51 @@ export class ERC721BoundContractView extends BoundContractView<
295
289
  operator: string,
296
290
  overrides?: Overrides
297
291
  ): Promise<boolean> {
298
- if (!overrides && this.context) {
299
- overrides = {
300
- blockTag: this.context.blockNumber,
301
- };
302
- }
303
- return await this.view.isApprovedForAll(owner, operator, overrides || {});
292
+ return await this.view.isApprovedForAll(owner, operator, {
293
+ blockTag: this.context.blockNumber,
294
+ ...overrides,
295
+ });
304
296
  }
305
297
 
306
298
  async name(overrides?: Overrides): Promise<string> {
307
- if (!overrides && this.context) {
308
- overrides = {
309
- blockTag: this.context.blockNumber,
310
- };
311
- }
312
- return await this.view.name(overrides || {});
299
+ return await this.view.name({
300
+ blockTag: this.context.blockNumber,
301
+ ...overrides,
302
+ });
313
303
  }
314
304
 
315
305
  async ownerOf(tokenId: BigNumberish, overrides?: Overrides): Promise<string> {
316
- if (!overrides && this.context) {
317
- overrides = {
318
- blockTag: this.context.blockNumber,
319
- };
320
- }
321
- return await this.view.ownerOf(tokenId, overrides || {});
306
+ return await this.view.ownerOf(tokenId, {
307
+ blockTag: this.context.blockNumber,
308
+ ...overrides,
309
+ });
322
310
  }
323
311
 
324
312
  async supportsInterface(
325
313
  interfaceId: BytesLike,
326
314
  overrides?: Overrides
327
315
  ): Promise<boolean> {
328
- if (!overrides && this.context) {
329
- overrides = {
330
- blockTag: this.context.blockNumber,
331
- };
332
- }
333
- return await this.view.supportsInterface(interfaceId, overrides || {});
316
+ return await this.view.supportsInterface(interfaceId, {
317
+ blockTag: this.context.blockNumber,
318
+ ...overrides,
319
+ });
334
320
  }
335
321
 
336
322
  async symbol(overrides?: Overrides): Promise<string> {
337
- if (!overrides && this.context) {
338
- overrides = {
339
- blockTag: this.context.blockNumber,
340
- };
341
- }
342
- return await this.view.symbol(overrides || {});
323
+ return await this.view.symbol({
324
+ blockTag: this.context.blockNumber,
325
+ ...overrides,
326
+ });
343
327
  }
344
328
 
345
329
  async tokenURI(
346
330
  tokenId: BigNumberish,
347
331
  overrides?: Overrides
348
332
  ): Promise<string> {
349
- if (!overrides && this.context) {
350
- overrides = {
351
- blockTag: this.context.blockNumber,
352
- };
353
- }
354
- return await this.view.tokenURI(tokenId, overrides || {});
333
+ return await this.view.tokenURI(tokenId, {
334
+ blockTag: this.context.blockNumber,
335
+ ...overrides,
336
+ });
355
337
  }
356
338
  }
357
339
 
@@ -627,19 +609,26 @@ export class ERC721ProcessorTemplate extends BaseProcessorTemplate<
627
609
  }
628
610
 
629
611
  export function getERC721Contract(
630
- contextOrNetwork: EthContext | EthChainId,
612
+ chainId: EthChainId,
631
613
  address: string
632
614
  ): ERC721ContractView {
633
- const network = getEthChainId(contextOrNetwork);
634
615
  let contract = getContractByABI(
635
616
  "ERC721",
636
617
  address,
637
- network
618
+ chainId
638
619
  ) as ERC721ContractView;
639
620
  if (!contract) {
640
- const rawContract = ERC721__factory.connect(address, getProvider(network));
621
+ const rawContract = ERC721__factory.connect(address, getProvider(chainId));
641
622
  contract = new ERC721ContractView(rawContract);
642
- addContractByABI("ERC721", address, network, contract);
623
+ addContractByABI("ERC721", address, chainId, contract);
643
624
  }
644
625
  return contract;
645
626
  }
627
+
628
+ export function getERC721ContractOnContext(
629
+ context: EthContext,
630
+ address: string
631
+ ): ERC721BoundContractView {
632
+ const view = getERC721Contract(context.getChainId(), address);
633
+ return new ERC721BoundContractView(address, view);
634
+ }