@sentio/sdk 2.15.5 → 2.15.6-rc.2

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 (46) hide show
  1. package/lib/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +2 -1
  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 +2 -1
  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 +2 -1
  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 +2 -1
  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 +2 -1
  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 +2 -1
  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 +10 -7
  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/sui/ext/coin.js +3 -0
  31. package/lib/sui/ext/coin.js.map +1 -1
  32. package/lib/utils/token.js +9 -2
  33. package/lib/utils/token.js.map +1 -1
  34. package/package.json +5 -5
  35. package/src/eth/builtin/internal/eacaggregatorproxy-processor.ts +84 -114
  36. package/src/eth/builtin/internal/erc1155-processor.ts +32 -36
  37. package/src/eth/builtin/internal/erc20-processor.ts +44 -54
  38. package/src/eth/builtin/internal/erc20bytes-processor.ts +36 -42
  39. package/src/eth/builtin/internal/erc721-processor.ts +48 -60
  40. package/src/eth/builtin/internal/weth9-processor.ts +36 -42
  41. package/src/eth/codegen/file.ts +10 -9
  42. package/src/eth/codegen/view-function.ts +4 -6
  43. package/src/eth/index.ts +1 -1
  44. package/src/eth/provider.ts +9 -11
  45. package/src/sui/ext/coin.ts +4 -1
  46. package/src/utils/token.ts +9 -2
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -421,51 +420,41 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
421
420
  EACAggregatorProxyContractView
422
421
  > {
423
422
  async accessController(overrides?: Overrides): Promise<string> {
424
- if (!overrides && this.context) {
425
- overrides = {
426
- blockTag: this.context.blockNumber,
427
- };
428
- }
429
- return await this.view.accessController(overrides || {});
423
+ return await this.view.accessController({
424
+ blockTag: this.context.blockNumber,
425
+ ...overrides,
426
+ });
430
427
  }
431
428
 
432
429
  async aggregator(overrides?: Overrides): Promise<string> {
433
- if (!overrides && this.context) {
434
- overrides = {
435
- blockTag: this.context.blockNumber,
436
- };
437
- }
438
- return await this.view.aggregator(overrides || {});
430
+ return await this.view.aggregator({
431
+ blockTag: this.context.blockNumber,
432
+ ...overrides,
433
+ });
439
434
  }
440
435
 
441
436
  async decimals(overrides?: Overrides): Promise<bigint> {
442
- if (!overrides && this.context) {
443
- overrides = {
444
- blockTag: this.context.blockNumber,
445
- };
446
- }
447
- return await this.view.decimals(overrides || {});
437
+ return await this.view.decimals({
438
+ blockTag: this.context.blockNumber,
439
+ ...overrides,
440
+ });
448
441
  }
449
442
 
450
443
  async description(overrides?: Overrides): Promise<string> {
451
- if (!overrides && this.context) {
452
- overrides = {
453
- blockTag: this.context.blockNumber,
454
- };
455
- }
456
- return await this.view.description(overrides || {});
444
+ return await this.view.description({
445
+ blockTag: this.context.blockNumber,
446
+ ...overrides,
447
+ });
457
448
  }
458
449
 
459
450
  async getAnswer(
460
451
  _roundId: BigNumberish,
461
452
  overrides?: Overrides
462
453
  ): Promise<bigint> {
463
- if (!overrides && this.context) {
464
- overrides = {
465
- blockTag: this.context.blockNumber,
466
- };
467
- }
468
- return await this.view.getAnswer(_roundId, overrides || {});
454
+ return await this.view.getAnswer(_roundId, {
455
+ blockTag: this.context.blockNumber,
456
+ ...overrides,
457
+ });
469
458
  }
470
459
 
471
460
  async getRoundData(
@@ -480,42 +469,34 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
480
469
  answeredInRound: bigint;
481
470
  }
482
471
  > {
483
- if (!overrides && this.context) {
484
- overrides = {
485
- blockTag: this.context.blockNumber,
486
- };
487
- }
488
- return await this.view.getRoundData(_roundId, overrides || {});
472
+ return await this.view.getRoundData(_roundId, {
473
+ blockTag: this.context.blockNumber,
474
+ ...overrides,
475
+ });
489
476
  }
490
477
 
491
478
  async getTimestamp(
492
479
  _roundId: BigNumberish,
493
480
  overrides?: Overrides
494
481
  ): Promise<bigint> {
495
- if (!overrides && this.context) {
496
- overrides = {
497
- blockTag: this.context.blockNumber,
498
- };
499
- }
500
- return await this.view.getTimestamp(_roundId, overrides || {});
482
+ return await this.view.getTimestamp(_roundId, {
483
+ blockTag: this.context.blockNumber,
484
+ ...overrides,
485
+ });
501
486
  }
502
487
 
503
488
  async latestAnswer(overrides?: Overrides): Promise<bigint> {
504
- if (!overrides && this.context) {
505
- overrides = {
506
- blockTag: this.context.blockNumber,
507
- };
508
- }
509
- return await this.view.latestAnswer(overrides || {});
489
+ return await this.view.latestAnswer({
490
+ blockTag: this.context.blockNumber,
491
+ ...overrides,
492
+ });
510
493
  }
511
494
 
512
495
  async latestRound(overrides?: Overrides): Promise<bigint> {
513
- if (!overrides && this.context) {
514
- overrides = {
515
- blockTag: this.context.blockNumber,
516
- };
517
- }
518
- return await this.view.latestRound(overrides || {});
496
+ return await this.view.latestRound({
497
+ blockTag: this.context.blockNumber,
498
+ ...overrides,
499
+ });
519
500
  }
520
501
 
521
502
  async latestRoundData(
@@ -529,60 +510,48 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
529
510
  answeredInRound: bigint;
530
511
  }
531
512
  > {
532
- if (!overrides && this.context) {
533
- overrides = {
534
- blockTag: this.context.blockNumber,
535
- };
536
- }
537
- return await this.view.latestRoundData(overrides || {});
513
+ return await this.view.latestRoundData({
514
+ blockTag: this.context.blockNumber,
515
+ ...overrides,
516
+ });
538
517
  }
539
518
 
540
519
  async latestTimestamp(overrides?: Overrides): Promise<bigint> {
541
- if (!overrides && this.context) {
542
- overrides = {
543
- blockTag: this.context.blockNumber,
544
- };
545
- }
546
- return await this.view.latestTimestamp(overrides || {});
520
+ return await this.view.latestTimestamp({
521
+ blockTag: this.context.blockNumber,
522
+ ...overrides,
523
+ });
547
524
  }
548
525
 
549
526
  async owner(overrides?: Overrides): Promise<string> {
550
- if (!overrides && this.context) {
551
- overrides = {
552
- blockTag: this.context.blockNumber,
553
- };
554
- }
555
- return await this.view.owner(overrides || {});
527
+ return await this.view.owner({
528
+ blockTag: this.context.blockNumber,
529
+ ...overrides,
530
+ });
556
531
  }
557
532
 
558
533
  async phaseAggregators(
559
534
  arg0: BigNumberish,
560
535
  overrides?: Overrides
561
536
  ): Promise<string> {
562
- if (!overrides && this.context) {
563
- overrides = {
564
- blockTag: this.context.blockNumber,
565
- };
566
- }
567
- return await this.view.phaseAggregators(arg0, overrides || {});
537
+ return await this.view.phaseAggregators(arg0, {
538
+ blockTag: this.context.blockNumber,
539
+ ...overrides,
540
+ });
568
541
  }
569
542
 
570
543
  async phaseId(overrides?: Overrides): Promise<bigint> {
571
- if (!overrides && this.context) {
572
- overrides = {
573
- blockTag: this.context.blockNumber,
574
- };
575
- }
576
- return await this.view.phaseId(overrides || {});
544
+ return await this.view.phaseId({
545
+ blockTag: this.context.blockNumber,
546
+ ...overrides,
547
+ });
577
548
  }
578
549
 
579
550
  async proposedAggregator(overrides?: Overrides): Promise<string> {
580
- if (!overrides && this.context) {
581
- overrides = {
582
- blockTag: this.context.blockNumber,
583
- };
584
- }
585
- return await this.view.proposedAggregator(overrides || {});
551
+ return await this.view.proposedAggregator({
552
+ blockTag: this.context.blockNumber,
553
+ ...overrides,
554
+ });
586
555
  }
587
556
 
588
557
  async proposedGetRoundData(
@@ -597,12 +566,10 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
597
566
  answeredInRound: bigint;
598
567
  }
599
568
  > {
600
- if (!overrides && this.context) {
601
- overrides = {
602
- blockTag: this.context.blockNumber,
603
- };
604
- }
605
- return await this.view.proposedGetRoundData(_roundId, overrides || {});
569
+ return await this.view.proposedGetRoundData(_roundId, {
570
+ blockTag: this.context.blockNumber,
571
+ ...overrides,
572
+ });
606
573
  }
607
574
 
608
575
  async proposedLatestRoundData(
@@ -616,21 +583,17 @@ export class EACAggregatorProxyBoundContractView extends BoundContractView<
616
583
  answeredInRound: bigint;
617
584
  }
618
585
  > {
619
- if (!overrides && this.context) {
620
- overrides = {
621
- blockTag: this.context.blockNumber,
622
- };
623
- }
624
- return await this.view.proposedLatestRoundData(overrides || {});
586
+ return await this.view.proposedLatestRoundData({
587
+ blockTag: this.context.blockNumber,
588
+ ...overrides,
589
+ });
625
590
  }
626
591
 
627
592
  async version(overrides?: Overrides): Promise<bigint> {
628
- if (!overrides && this.context) {
629
- overrides = {
630
- blockTag: this.context.blockNumber,
631
- };
632
- }
633
- return await this.view.version(overrides || {});
593
+ return await this.view.version({
594
+ blockTag: this.context.blockNumber,
595
+ ...overrides,
596
+ });
634
597
  }
635
598
  }
636
599
 
@@ -1067,22 +1030,29 @@ export class EACAggregatorProxyProcessorTemplate extends BaseProcessorTemplate<
1067
1030
  }
1068
1031
 
1069
1032
  export function getEACAggregatorProxyContract(
1070
- contextOrNetwork: EthContext | EthChainId,
1033
+ chainId: EthChainId,
1071
1034
  address: string
1072
1035
  ): EACAggregatorProxyContractView {
1073
- const network = getEthChainId(contextOrNetwork);
1074
1036
  let contract = getContractByABI(
1075
1037
  "EACAggregatorProxy",
1076
1038
  address,
1077
- network
1039
+ chainId
1078
1040
  ) as EACAggregatorProxyContractView;
1079
1041
  if (!contract) {
1080
1042
  const rawContract = EACAggregatorProxy__factory.connect(
1081
1043
  address,
1082
- getProvider(network)
1044
+ getProvider(chainId)
1083
1045
  );
1084
1046
  contract = new EACAggregatorProxyContractView(rawContract);
1085
- addContractByABI("EACAggregatorProxy", address, network, contract);
1047
+ addContractByABI("EACAggregatorProxy", address, chainId, contract);
1086
1048
  }
1087
1049
  return contract;
1088
1050
  }
1051
+
1052
+ export function getEACAggregatorProxyContractOnContext(
1053
+ context: EthContext,
1054
+ address: string
1055
+ ): EACAggregatorProxyBoundContractView {
1056
+ const view = getEACAggregatorProxyContract(context.getChainId(), address);
1057
+ return new EACAggregatorProxyBoundContractView(address, view);
1058
+ }
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -202,12 +201,10 @@ export class ERC1155BoundContractView extends BoundContractView<
202
201
  id: BigNumberish,
203
202
  overrides?: Overrides
204
203
  ): 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 || {});
204
+ return await this.view.balanceOf(account, id, {
205
+ blockTag: this.context.blockNumber,
206
+ ...overrides,
207
+ });
211
208
  }
212
209
 
213
210
  async balanceOfBatch(
@@ -215,12 +212,10 @@ export class ERC1155BoundContractView extends BoundContractView<
215
212
  ids: BigNumberish[],
216
213
  overrides?: Overrides
217
214
  ): 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 || {});
215
+ return await this.view.balanceOfBatch(accounts, ids, {
216
+ blockTag: this.context.blockNumber,
217
+ ...overrides,
218
+ });
224
219
  }
225
220
 
226
221
  async isApprovedForAll(
@@ -228,33 +223,27 @@ export class ERC1155BoundContractView extends BoundContractView<
228
223
  operator: string,
229
224
  overrides?: Overrides
230
225
  ): 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 || {});
226
+ return await this.view.isApprovedForAll(account, operator, {
227
+ blockTag: this.context.blockNumber,
228
+ ...overrides,
229
+ });
237
230
  }
238
231
 
239
232
  async supportsInterface(
240
233
  interfaceId: BytesLike,
241
234
  overrides?: Overrides
242
235
  ): Promise<boolean> {
243
- if (!overrides && this.context) {
244
- overrides = {
245
- blockTag: this.context.blockNumber,
246
- };
247
- }
248
- return await this.view.supportsInterface(interfaceId, overrides || {});
236
+ return await this.view.supportsInterface(interfaceId, {
237
+ blockTag: this.context.blockNumber,
238
+ ...overrides,
239
+ });
249
240
  }
250
241
 
251
242
  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 || {});
243
+ return await this.view.uri(id, {
244
+ blockTag: this.context.blockNumber,
245
+ ...overrides,
246
+ });
258
247
  }
259
248
  }
260
249
 
@@ -502,19 +491,26 @@ export class ERC1155ProcessorTemplate extends BaseProcessorTemplate<
502
491
  }
503
492
 
504
493
  export function getERC1155Contract(
505
- contextOrNetwork: EthContext | EthChainId,
494
+ chainId: EthChainId,
506
495
  address: string
507
496
  ): ERC1155ContractView {
508
- const network = getEthChainId(contextOrNetwork);
509
497
  let contract = getContractByABI(
510
498
  "ERC1155",
511
499
  address,
512
- network
500
+ chainId
513
501
  ) as ERC1155ContractView;
514
502
  if (!contract) {
515
- const rawContract = ERC1155__factory.connect(address, getProvider(network));
503
+ const rawContract = ERC1155__factory.connect(address, getProvider(chainId));
516
504
  contract = new ERC1155ContractView(rawContract);
517
- addContractByABI("ERC1155", address, network, contract);
505
+ addContractByABI("ERC1155", address, chainId, contract);
518
506
  }
519
507
  return contract;
520
508
  }
509
+
510
+ export function getERC1155ContractOnContext(
511
+ context: EthContext,
512
+ address: string
513
+ ): ERC1155BoundContractView {
514
+ const view = getERC1155Contract(context.getChainId(), address);
515
+ return new ERC1155BoundContractView(address, view);
516
+ }
@@ -18,7 +18,6 @@ import {
18
18
  DummyProvider,
19
19
  EthChainId,
20
20
  TypedCallTrace,
21
- getEthChainId,
22
21
  EthContext,
23
22
  EthFetchConfig,
24
23
  } from "@sentio/sdk/eth";
@@ -254,75 +253,59 @@ export class ERC20BoundContractView extends BoundContractView<
254
253
  spender: string,
255
254
  overrides?: Overrides
256
255
  ): 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 || {});
256
+ return await this.view.allowance(owner, spender, {
257
+ blockTag: this.context.blockNumber,
258
+ ...overrides,
259
+ });
263
260
  }
264
261
 
265
262
  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 || {});
263
+ return await this.view.balanceOf(account, {
264
+ blockTag: this.context.blockNumber,
265
+ ...overrides,
266
+ });
272
267
  }
273
268
 
274
269
  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 || {});
270
+ return await this.view.decimals({
271
+ blockTag: this.context.blockNumber,
272
+ ...overrides,
273
+ });
281
274
  }
282
275
 
283
276
  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 || {});
277
+ return await this.view.locker({
278
+ blockTag: this.context.blockNumber,
279
+ ...overrides,
280
+ });
290
281
  }
291
282
 
292
283
  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 || {});
284
+ return await this.view.name({
285
+ blockTag: this.context.blockNumber,
286
+ ...overrides,
287
+ });
299
288
  }
300
289
 
301
290
  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 || {});
291
+ return await this.view.owner({
292
+ blockTag: this.context.blockNumber,
293
+ ...overrides,
294
+ });
308
295
  }
309
296
 
310
297
  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 || {});
298
+ return await this.view.symbol({
299
+ blockTag: this.context.blockNumber,
300
+ ...overrides,
301
+ });
317
302
  }
318
303
 
319
304
  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 || {});
305
+ return await this.view.totalSupply({
306
+ blockTag: this.context.blockNumber,
307
+ ...overrides,
308
+ });
326
309
  }
327
310
  }
328
311
 
@@ -610,19 +593,26 @@ export class ERC20ProcessorTemplate extends BaseProcessorTemplate<
610
593
  }
611
594
 
612
595
  export function getERC20Contract(
613
- contextOrNetwork: EthContext | EthChainId,
596
+ chainId: EthChainId,
614
597
  address: string
615
598
  ): ERC20ContractView {
616
- const network = getEthChainId(contextOrNetwork);
617
599
  let contract = getContractByABI(
618
600
  "ERC20",
619
601
  address,
620
- network
602
+ chainId
621
603
  ) as ERC20ContractView;
622
604
  if (!contract) {
623
- const rawContract = ERC20__factory.connect(address, getProvider(network));
605
+ const rawContract = ERC20__factory.connect(address, getProvider(chainId));
624
606
  contract = new ERC20ContractView(rawContract);
625
- addContractByABI("ERC20", address, network, contract);
607
+ addContractByABI("ERC20", address, chainId, contract);
626
608
  }
627
609
  return contract;
628
610
  }
611
+
612
+ export function getERC20ContractOnContext(
613
+ context: EthContext,
614
+ address: string
615
+ ): ERC20BoundContractView {
616
+ const view = getERC20Contract(context.getChainId(), address);
617
+ return new ERC20BoundContractView(address, view);
618
+ }