@ar.io/sdk 3.6.2-alpha.1 → 3.7.0-alpha.1

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.
@@ -53,6 +53,16 @@ const utils_js_1 = require("./utils.js");
53
53
  description: 'Get demand factor',
54
54
  action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getDemandFactor(),
55
55
  });
56
+ (0, utils_js_1.makeCommand)({
57
+ name: 'get-demand-factor-settings',
58
+ description: 'Get current settings for demand factor',
59
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getDemandFactorSettings(),
60
+ });
61
+ (0, utils_js_1.makeCommand)({
62
+ name: 'get-epoch-settings',
63
+ description: 'Get current settings for epochs',
64
+ action: (options) => (0, utils_js_1.readARIOFromOptions)(options).getEpochSettings(),
65
+ });
56
66
  (0, utils_js_1.makeCommand)({
57
67
  name: 'get-gateway',
58
68
  description: 'Get the gateway of an address',
@@ -164,6 +174,14 @@ const utils_js_1 = require("./utils.js");
164
174
  .getDistributions((0, utils_js_1.epochInputFromOptions)(o))
165
175
  .then((result) => result ?? { message: 'No distributions found for epoch' }),
166
176
  });
177
+ (0, utils_js_1.makeCommand)({
178
+ name: 'get-eligible-rewards',
179
+ description: 'Get eligible rewards for an epoch',
180
+ options: [...options_js_1.epochOptions, ...options_js_1.paginationOptions],
181
+ action: (o) => (0, utils_js_1.readARIOFromOptions)(o)
182
+ .getEligibleEpochRewards((0, utils_js_1.epochInputFromOptions)(o), (0, utils_js_1.paginationParamsFromOptions)(o))
183
+ .then((result) => result ?? { message: 'No eligible distributions found for epoch' }),
184
+ });
167
185
  (0, utils_js_1.makeCommand)({
168
186
  name: 'get-token-cost',
169
187
  description: 'Get token cost for an intended action',
@@ -511,7 +529,7 @@ const utils_js_1 = require("./utils.js");
511
529
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to transfer ANT ownership to ${target}?`, options);
512
530
  return (0, utils_js_1.writeANTFromOptions)(options).transfer({
513
531
  target,
514
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
532
+ }, (0, utils_js_1.customTagsFromOptions)(options));
515
533
  },
516
534
  });
517
535
  (0, utils_js_1.makeCommand)({
@@ -523,7 +541,7 @@ const utils_js_1 = require("./utils.js");
523
541
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to add ${controller} as a controller?`, options);
524
542
  return (0, utils_js_1.writeANTFromOptions)(options).addController({
525
543
  controller: (0, utils_js_1.requiredStringFromOptions)(options, 'controller'),
526
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
544
+ }, (0, utils_js_1.customTagsFromOptions)(options));
527
545
  },
528
546
  });
529
547
  (0, utils_js_1.makeCommand)({
@@ -533,7 +551,7 @@ const utils_js_1 = require("./utils.js");
533
551
  action: async (options) => {
534
552
  return (0, utils_js_1.writeANTFromOptions)(options).removeController({
535
553
  controller: (0, utils_js_1.requiredStringFromOptions)(options, 'controller'),
536
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
554
+ }, (0, utils_js_1.customTagsFromOptions)(options));
537
555
  },
538
556
  });
539
557
  (0, utils_js_1.makeCommand)({
@@ -563,7 +581,7 @@ const utils_js_1 = require("./utils.js");
563
581
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to remove the record with undername ${undername}?`, options);
564
582
  return (0, utils_js_1.writeANTFromOptions)(options).removeRecord({
565
583
  undername,
566
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
584
+ }, (0, utils_js_1.customTagsFromOptions)(options));
567
585
  },
568
586
  });
569
587
  (0, utils_js_1.makeCommand)({
@@ -575,7 +593,7 @@ const utils_js_1 = require("./utils.js");
575
593
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ticker to ${ticker}?`, options);
576
594
  return (0, utils_js_1.writeANTFromOptions)(options).setTicker({
577
595
  ticker,
578
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
596
+ }, (0, utils_js_1.customTagsFromOptions)(options));
579
597
  },
580
598
  });
581
599
  (0, utils_js_1.makeCommand)({
@@ -587,7 +605,7 @@ const utils_js_1 = require("./utils.js");
587
605
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the name to ${(0, utils_js_1.requiredStringFromOptions)(options, 'name')}?`, options);
588
606
  return (0, utils_js_1.writeANTFromOptions)(options).setName({
589
607
  name,
590
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
608
+ }, (0, utils_js_1.customTagsFromOptions)(options));
591
609
  },
592
610
  });
593
611
  (0, utils_js_1.makeCommand)({
@@ -599,7 +617,7 @@ const utils_js_1 = require("./utils.js");
599
617
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT description to ${description}?`, options);
600
618
  return (0, utils_js_1.writeANTFromOptions)(options).setDescription({
601
619
  description,
602
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
620
+ }, (0, utils_js_1.customTagsFromOptions)(options));
603
621
  },
604
622
  });
605
623
  (0, utils_js_1.makeCommand)({
@@ -611,7 +629,7 @@ const utils_js_1 = require("./utils.js");
611
629
  await (0, utils_js_1.assertConfirmationPrompt)(`Are you sure you want to set the ANT keywords to ${keywords}?`, options);
612
630
  return (0, utils_js_1.writeANTFromOptions)(options).setKeywords({
613
631
  keywords,
614
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
632
+ }, (0, utils_js_1.customTagsFromOptions)(options));
615
633
  },
616
634
  });
617
635
  (0, utils_js_1.makeCommand)({
@@ -628,7 +646,7 @@ const utils_js_1 = require("./utils.js");
628
646
  return (0, utils_js_1.writeANTFromOptions)(options).setLogo({
629
647
  // TODO: Could take a logo file, upload it to Arweave, get transaction ID
630
648
  txId,
631
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
649
+ }, (0, utils_js_1.customTagsFromOptions)(options));
632
650
  },
633
651
  });
634
652
  (0, utils_js_1.makeCommand)({
@@ -641,7 +659,7 @@ const utils_js_1 = require("./utils.js");
641
659
  return (0, utils_js_1.writeANTFromOptions)(options).releaseName({
642
660
  name,
643
661
  arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
644
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
662
+ }, (0, utils_js_1.customTagsFromOptions)(options));
645
663
  },
646
664
  });
647
665
  (0, utils_js_1.makeCommand)({
@@ -661,7 +679,7 @@ const utils_js_1 = require("./utils.js");
661
679
  name,
662
680
  arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
663
681
  antProcessId: targetProcess,
664
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
682
+ }, (0, utils_js_1.customTagsFromOptions)(options));
665
683
  },
666
684
  });
667
685
  (0, utils_js_1.makeCommand)({
@@ -681,7 +699,7 @@ const utils_js_1 = require("./utils.js");
681
699
  name,
682
700
  address,
683
701
  arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
684
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
702
+ }, (0, utils_js_1.customTagsFromOptions)(options));
685
703
  },
686
704
  });
687
705
  (0, utils_js_1.makeCommand)({
@@ -694,7 +712,7 @@ const utils_js_1 = require("./utils.js");
694
712
  return (0, utils_js_1.writeANTFromOptions)(options).removePrimaryNames({
695
713
  names,
696
714
  arioProcessId: (0, utils_js_1.arioProcessIdFromOptions)(options),
697
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
715
+ }, (0, utils_js_1.customTagsFromOptions)(options));
698
716
  },
699
717
  });
700
718
  (0, utils_js_1.makeCommand)({
@@ -707,11 +725,25 @@ const utils_js_1 = require("./utils.js");
707
725
  logger: (0, utils_js_1.getLoggerFromOptions)(options),
708
726
  });
709
727
  return process.send({
710
- tags: (0, utils_js_1.writeActionTagsFromOptions)(options).tags ?? [],
728
+ tags: (0, utils_js_1.customTagsFromOptions)(options).tags ?? [],
711
729
  signer: (0, utils_js_1.requiredAoSignerFromOptions)(options),
712
730
  });
713
731
  },
714
732
  });
733
+ (0, utils_js_1.makeCommand)({
734
+ name: 'read-action',
735
+ description: 'Send a dry-run read action to an AO Process',
736
+ options: [options_js_1.optionMap.processId, options_js_1.optionMap.tags],
737
+ action: async (options) => {
738
+ const process = new index_js_1.AOProcess({
739
+ processId: (0, utils_js_1.requiredProcessIdFromOptions)(options),
740
+ logger: (0, utils_js_1.getLoggerFromOptions)(options),
741
+ });
742
+ return process.read({
743
+ tags: (0, utils_js_1.customTagsFromOptions)(options).tags ?? [],
744
+ });
745
+ },
746
+ });
715
747
  if (process.argv[1].includes('bin/ar.io') || // Running from global .bin
716
748
  process.argv[1].includes('cli/cli') // Running from source
717
749
  ) {
@@ -15,7 +15,7 @@ async function setAntRecordCLICommand(o) {
15
15
  undername,
16
16
  transactionId,
17
17
  ttlSeconds,
18
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
18
+ }, (0, utils_js_1.customTagsFromOptions)(o));
19
19
  }
20
20
  exports.setAntRecordCLICommand = setAntRecordCLICommand;
21
21
  async function setAntBaseNameCLICommand(o) {
@@ -28,7 +28,7 @@ async function setAntBaseNameCLICommand(o) {
28
28
  return (0, utils_js_1.writeANTFromOptions)(o).setBaseNameRecord({
29
29
  transactionId,
30
30
  ttlSeconds,
31
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
31
+ }, (0, utils_js_1.customTagsFromOptions)(o));
32
32
  }
33
33
  exports.setAntBaseNameCLICommand = setAntBaseNameCLICommand;
34
34
  async function setAntUndernameCLICommand(o) {
@@ -43,6 +43,6 @@ async function setAntUndernameCLICommand(o) {
43
43
  undername,
44
44
  transactionId,
45
45
  ttlSeconds,
46
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
46
+ }, (0, utils_js_1.customTagsFromOptions)(o));
47
47
  }
48
48
  exports.setAntUndernameCLICommand = setAntUndernameCLICommand;
@@ -40,7 +40,7 @@ async function buyRecordCLICommand(o) {
40
40
  type,
41
41
  years,
42
42
  fundFrom: (0, utils_js_1.fundFromFromOptions)(o),
43
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
43
+ }, (0, utils_js_1.customTagsFromOptions)(o));
44
44
  }
45
45
  exports.buyRecordCLICommand = buyRecordCLICommand;
46
46
  async function upgradeRecordCLICommand(o) {
@@ -106,7 +106,7 @@ async function extendLeaseCLICommand(o) {
106
106
  return ario.extendLease({
107
107
  name,
108
108
  years,
109
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
109
+ }, (0, utils_js_1.customTagsFromOptions)(o));
110
110
  }
111
111
  exports.extendLeaseCLICommand = extendLeaseCLICommand;
112
112
  async function increaseUndernameLimitCLICommand(o) {
@@ -137,7 +137,7 @@ async function increaseUndernameLimitCLICommand(o) {
137
137
  return ario.increaseUndernameLimit({
138
138
  name,
139
139
  increaseCount,
140
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
140
+ }, (0, utils_js_1.customTagsFromOptions)(o));
141
141
  }
142
142
  exports.increaseUndernameLimitCLICommand = increaseUndernameLimitCLICommand;
143
143
  async function requestPrimaryNameCLICommand(o) {
@@ -162,6 +162,6 @@ async function requestPrimaryNameCLICommand(o) {
162
162
  return ario.requestPrimaryName({
163
163
  name,
164
164
  fundFrom,
165
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
165
+ }, (0, utils_js_1.customTagsFromOptions)(o));
166
166
  }
167
167
  exports.requestPrimaryNameCLICommand = requestPrimaryNameCLICommand;
@@ -47,7 +47,7 @@ async function joinNetwork(options) {
47
47
  });
48
48
  await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${(0, utils_js_1.formatARIOWithCommas)(mARIOQuantity.toARIO())} ARIO to join the AR.IO network\nAre you sure?\n`, options);
49
49
  }
50
- const result = await ario.joinNetwork(settings, (0, utils_js_1.writeActionTagsFromOptions)(options));
50
+ const result = await ario.joinNetwork(settings, (0, utils_js_1.customTagsFromOptions)(options));
51
51
  const output = {
52
52
  joinNetworkResult: result,
53
53
  joinedAddress: signerAddress,
@@ -64,7 +64,7 @@ async function updateGatewaySettings(options) {
64
64
  throw new Error('No gateway settings provided');
65
65
  }
66
66
  await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${(0, utils_js_1.stringifyJsonForCLIDisplay)(gatewaySettings)}\n\nYou are about to update your gateway settings to the above\nAre you sure?\n`, options);
67
- const result = await ario.updateGatewaySettings(gatewaySettings, (0, utils_js_1.writeActionTagsFromOptions)(options));
67
+ const result = await ario.updateGatewaySettings(gatewaySettings, (0, utils_js_1.customTagsFromOptions)(options));
68
68
  const output = {
69
69
  updateGatewaySettingsResult: result,
70
70
  updatedGatewayAddress: signerAddress,
@@ -85,7 +85,7 @@ async function leaveNetwork(options) {
85
85
  '\n\n' +
86
86
  'Are you sure you want to leave the AR.IO network?', options);
87
87
  }
88
- return (0, utils_js_1.writeARIOFromOptions)(options).ario.leaveNetwork((0, utils_js_1.writeActionTagsFromOptions)(options));
88
+ return (0, utils_js_1.writeARIOFromOptions)(options).ario.leaveNetwork((0, utils_js_1.customTagsFromOptions)(options));
89
89
  }
90
90
  exports.leaveNetwork = leaveNetwork;
91
91
  async function saveObservations(o) {
@@ -95,7 +95,7 @@ async function saveObservations(o) {
95
95
  return (0, utils_js_1.writeARIOFromOptions)(o).ario.saveObservations({
96
96
  failedGateways: (0, utils_js_1.requiredStringArrayFromOptions)(o, 'failedGateways'),
97
97
  reportTxId: (0, utils_js_1.requiredStringFromOptions)(o, 'transactionId'),
98
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
98
+ }, (0, utils_js_1.customTagsFromOptions)(o));
99
99
  }
100
100
  exports.saveObservations = saveObservations;
101
101
  async function increaseOperatorStake(o) {
@@ -104,7 +104,7 @@ async function increaseOperatorStake(o) {
104
104
  return ((0, utils_js_1.writeARIOFromOptions)(o).ario.increaseOperatorStake({
105
105
  increaseQty,
106
106
  }),
107
- (0, utils_js_1.writeActionTagsFromOptions)(o));
107
+ (0, utils_js_1.customTagsFromOptions)(o));
108
108
  }
109
109
  exports.increaseOperatorStake = increaseOperatorStake;
110
110
  async function decreaseOperatorStake(o) {
@@ -113,7 +113,7 @@ async function decreaseOperatorStake(o) {
113
113
  await (0, utils_js_1.assertConfirmationPrompt)(`You are about to decrease your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(decreaseQty.toARIO())} ARIO\nAre you sure?`, o);
114
114
  return (0, utils_js_1.writeARIOFromOptions)(o).ario.decreaseOperatorStake({
115
115
  decreaseQty,
116
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
116
+ }, (0, utils_js_1.customTagsFromOptions)(o));
117
117
  }
118
118
  exports.decreaseOperatorStake = decreaseOperatorStake;
119
119
  async function instantWithdrawal(o) {
@@ -123,7 +123,7 @@ async function instantWithdrawal(o) {
123
123
  return (0, utils_js_1.writeARIOFromOptions)(o).ario.instantWithdrawal({
124
124
  vaultId,
125
125
  gatewayAddress,
126
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
126
+ }, (0, utils_js_1.customTagsFromOptions)(o));
127
127
  }
128
128
  exports.instantWithdrawal = instantWithdrawal;
129
129
  async function cancelWithdrawal(o) {
@@ -133,7 +133,7 @@ async function cancelWithdrawal(o) {
133
133
  return (0, utils_js_1.writeARIOFromOptions)(o).ario.cancelWithdrawal({
134
134
  vaultId,
135
135
  gatewayAddress,
136
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
136
+ }, (0, utils_js_1.customTagsFromOptions)(o));
137
137
  }
138
138
  exports.cancelWithdrawal = cancelWithdrawal;
139
139
  async function delegateStake(options) {
@@ -166,7 +166,7 @@ async function delegateStake(options) {
166
166
  const result = await ario.delegateStake({
167
167
  target,
168
168
  stakeQty: arioQuantity.toMARIO(),
169
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
169
+ }, (0, utils_js_1.customTagsFromOptions)(options));
170
170
  const output = {
171
171
  senderAddress: signerAddress,
172
172
  transferResult: result,
@@ -19,7 +19,7 @@ async function transferCLICommand(options) {
19
19
  const result = await ario.transfer({
20
20
  target,
21
21
  qty: arioQuantity.toMARIO().valueOf(),
22
- }, (0, utils_js_1.writeActionTagsFromOptions)(options));
22
+ }, (0, utils_js_1.customTagsFromOptions)(options));
23
23
  const output = {
24
24
  senderAddress: signerAddress,
25
25
  transferResult: result,
@@ -50,7 +50,7 @@ async function vaultedTransferCLICommand(o) {
50
50
  quantity: mARIOQuantity,
51
51
  lockLengthMs,
52
52
  revokable: o.revokable,
53
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
53
+ }, (0, utils_js_1.customTagsFromOptions)(o));
54
54
  const output = {
55
55
  senderAddress: signerAddress,
56
56
  transferResult: result,
@@ -76,7 +76,7 @@ async function revokeVaultCLICommand(o) {
76
76
  const result = await ario.revokeVault({
77
77
  vaultId,
78
78
  recipient,
79
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
79
+ }, (0, utils_js_1.customTagsFromOptions)(o));
80
80
  const output = {
81
81
  senderAddress: signerAddress,
82
82
  transferResult: result,
@@ -104,7 +104,7 @@ async function createVaultCLICommand(o) {
104
104
  const result = await ario.createVault({
105
105
  quantity: mARIOQuantity,
106
106
  lockLengthMs,
107
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
107
+ }, (0, utils_js_1.customTagsFromOptions)(o));
108
108
  const output = {
109
109
  senderAddress: signerAddress,
110
110
  transferResult: result,
@@ -131,7 +131,7 @@ async function extendVaultCLICommand(o) {
131
131
  const result = await ario.extendVault({
132
132
  vaultId,
133
133
  extendLengthMs,
134
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
134
+ }, (0, utils_js_1.customTagsFromOptions)(o));
135
135
  const output = {
136
136
  senderAddress: signerAddress,
137
137
  transferResult: result,
@@ -157,7 +157,7 @@ async function increaseVaultCLICommand(o) {
157
157
  const result = await ario.increaseVault({
158
158
  vaultId,
159
159
  quantity: mARIOQuantity,
160
- }, (0, utils_js_1.writeActionTagsFromOptions)(o));
160
+ }, (0, utils_js_1.customTagsFromOptions)(o));
161
161
  const output = {
162
162
  senderAddress: signerAddress,
163
163
  transferResult: result,
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.assertLockLengthInRange = exports.fundFromFromOptions = exports.getTokenCostParamsFromOptions = exports.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.booleanFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughMARIOBalance = exports.assertEnoughBalanceForArNSPurchase = exports.requiredMARIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.writeActionTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.formatMARIOToARIOWithCommas = exports.formatARIOWithCommas = exports.writeARIOFromOptions = exports.requiredAoSignerFromOptions = exports.requiredContractSignerFromOptions = exports.readARIOFromOptions = exports.getLoggerFromOptions = exports.jwkToAddress = exports.requiredJwkFromOptions = exports.arioProcessIdFromOptions = exports.makeCommand = exports.applyOptions = exports.runCommand = exports.stringifyJsonForCLIDisplay = exports.defaultTtlSecondsCLI = void 0;
6
+ exports.assertLockLengthInRange = exports.fundFromFromOptions = exports.getTokenCostParamsFromOptions = exports.getANTStateFromOptions = exports.requiredPositiveIntegerFromOptions = exports.positiveIntegerFromOptions = exports.requiredStringArrayFromOptions = exports.requiredStringFromOptions = exports.booleanFromOptions = exports.writeANTFromOptions = exports.readANTFromOptions = exports.requiredProcessIdFromOptions = exports.assertConfirmationPrompt = exports.confirmationPrompt = exports.assertEnoughMARIOBalance = exports.assertEnoughBalanceForArNSPurchase = exports.requiredMARIOFromOptions = exports.recordTypeFromOptions = exports.redelegateParamsFromOptions = exports.requiredTargetAndQuantityFromOptions = exports.gatewaySettingsFromOptions = exports.customTagsFromOptions = exports.requiredInitiatorFromOptions = exports.epochInputFromOptions = exports.paginationParamsFromOptions = exports.requiredAddressFromOptions = exports.addressFromOptions = exports.formatMARIOToARIOWithCommas = exports.formatARIOWithCommas = exports.writeARIOFromOptions = exports.requiredAoSignerFromOptions = exports.requiredContractSignerFromOptions = exports.readARIOFromOptions = exports.getLoggerFromOptions = exports.jwkToAddress = exports.requiredJwkFromOptions = exports.arioProcessIdFromOptions = exports.makeCommand = exports.applyOptions = exports.runCommand = exports.stringifyJsonForCLIDisplay = exports.defaultTtlSecondsCLI = void 0;
7
7
  /**
8
8
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
9
9
  *
@@ -229,7 +229,7 @@ function requiredInitiatorFromOptions(options) {
229
229
  return requiredAddressFromOptions(options);
230
230
  }
231
231
  exports.requiredInitiatorFromOptions = requiredInitiatorFromOptions;
232
- function writeActionTagsFromOptions(options) {
232
+ function customTagsFromOptions(options) {
233
233
  if (options.tags === undefined) {
234
234
  return {};
235
235
  }
@@ -253,7 +253,7 @@ function writeActionTagsFromOptions(options) {
253
253
  tags,
254
254
  };
255
255
  }
256
- exports.writeActionTagsFromOptions = writeActionTagsFromOptions;
256
+ exports.customTagsFromOptions = customTagsFromOptions;
257
257
  function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, }) {
258
258
  return {
259
259
  observerAddress,
@@ -89,7 +89,7 @@ class ARIOReadable {
89
89
  epochIndex: epochIndex,
90
90
  processId: this.process.processId,
91
91
  });
92
- return epochData;
92
+ return (0, arweave_js_1.removeEligibleRewardsFromEpochData)(epochData);
93
93
  }
94
94
  // go to the process epoch and fetch the epoch data
95
95
  const allTags = [
@@ -298,6 +298,26 @@ class ARIOReadable {
298
298
  tags: (0, arweave_js_1.pruneTags)(allTags),
299
299
  });
300
300
  }
301
+ async getEligibleEpochRewards(epoch, params) {
302
+ const epochIndex = await this.computeEpochIndex(epoch);
303
+ const currentIndex = await this.computeCurrentEpochIndex();
304
+ if (epochIndex !== undefined && epochIndex < currentIndex) {
305
+ const epochData = await (0, arweave_js_1.getEpochDataFromGql)({
306
+ arweave: this.arweave,
307
+ epochIndex: epochIndex,
308
+ processId: this.process.processId,
309
+ });
310
+ return (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(epochData, params);
311
+ }
312
+ // on current epoch, go to process and fetch the distributions
313
+ const allTags = [
314
+ { name: 'Action', value: 'Epoch-Eligible-Rewards' },
315
+ ...(0, arweave_js_1.paginationParamsToTags)(params),
316
+ ];
317
+ return this.process.read({
318
+ tags: (0, arweave_js_1.pruneTags)(allTags),
319
+ });
320
+ }
301
321
  async getTokenCost({ intent, type, years, name, quantity, fromAddress, }) {
302
322
  const replacedBuyRecordWithBuyName = intent === 'Buy-Record' ? 'Buy-Name' : intent;
303
323
  const allTags = [
@@ -1,7 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLeasedArNSRecord = exports.isProcessIdConfiguration = exports.isProcessConfiguration = exports.isValidFundFrom = exports.fundFromOptions = exports.isValidIntent = exports.intentsUsingYears = exports.validIntents = void 0;
3
+ exports.isLeasedArNSRecord = exports.isProcessIdConfiguration = exports.isProcessConfiguration = exports.isValidFundFrom = exports.fundFromOptions = exports.isValidIntent = exports.intentsUsingYears = exports.validIntents = exports.isDistributedEpoch = exports.isDistributedEpochData = void 0;
4
4
  const arweave_js_1 = require("../utils/arweave.js");
5
+ const isDistributedEpochData = (data) => {
6
+ return data.distributedTimestamp !== undefined;
7
+ };
8
+ exports.isDistributedEpochData = isDistributedEpochData;
9
+ const isDistributedEpoch = (data) => {
10
+ return (data !== undefined &&
11
+ data.distributions !== undefined &&
12
+ (0, exports.isDistributedEpochData)(data.distributions));
13
+ };
14
+ exports.isDistributedEpoch = isDistributedEpoch;
5
15
  exports.validIntents = [
6
16
  'Buy-Name',
7
17
  'Buy-Record', // for backwards compatibility
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.epochDistributionNoticeGqlQuery = exports.getEpochDataFromGql = exports.paginationParamsToTags = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
3
+ exports.removeEligibleRewardsFromEpochData = exports.sortAndPaginateEpochDataIntoEligibleDistributions = exports.epochDistributionNoticeGqlQuery = exports.getEpochDataFromGql = exports.paginationParamsToTags = exports.pruneTags = exports.isBlockHeight = exports.validateArweaveId = void 0;
4
4
  const constants_js_1 = require("../constants.js");
5
+ const io_js_1 = require("../types/io.js");
5
6
  const ao_js_1 = require("./ao.js");
6
7
  const validateArweaveId = (id) => {
7
8
  return constants_js_1.ARWEAVE_TX_REGEX.test(id);
@@ -103,3 +104,85 @@ const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = constants_js_
103
104
  return gqlQuery;
104
105
  };
105
106
  exports.epochDistributionNoticeGqlQuery = epochDistributionNoticeGqlQuery;
107
+ function sortAndPaginateEpochDataIntoEligibleDistributions(epochData, params) {
108
+ const rewards = [];
109
+ const sortBy = params?.sortBy ?? 'eligibleReward';
110
+ const sortOrder = params?.sortOrder ?? 'desc';
111
+ const limit = params?.limit ?? 100;
112
+ if (!(0, io_js_1.isDistributedEpoch)(epochData)) {
113
+ return {
114
+ hasMore: false,
115
+ items: [],
116
+ totalItems: 0,
117
+ limit,
118
+ sortOrder,
119
+ sortBy,
120
+ };
121
+ }
122
+ const eligibleDistributions = epochData?.distributions.rewards.eligible;
123
+ for (const [gatewayAddress, reward] of Object.entries(eligibleDistributions)) {
124
+ rewards.push({
125
+ type: 'operatorReward',
126
+ recipient: gatewayAddress,
127
+ eligibleReward: reward.operatorReward,
128
+ cursorId: gatewayAddress + '_' + gatewayAddress,
129
+ gatewayAddress,
130
+ });
131
+ for (const [delegateAddress, delegateRewardQty] of Object.entries(reward.delegateRewards)) {
132
+ rewards.push({
133
+ type: 'delegateReward',
134
+ recipient: delegateAddress,
135
+ eligibleReward: delegateRewardQty,
136
+ cursorId: gatewayAddress + '_' + delegateAddress,
137
+ gatewayAddress,
138
+ });
139
+ }
140
+ }
141
+ // sort the rewards by the sortBy
142
+ rewards.sort((a, b) => {
143
+ const aSort = a[sortBy];
144
+ const bSort = b[sortBy];
145
+ if (aSort === bSort || aSort === undefined || bSort === undefined) {
146
+ return 0;
147
+ }
148
+ if (sortOrder === 'asc') {
149
+ return aSort > bSort ? 1 : -1;
150
+ }
151
+ return aSort < bSort ? 1 : -1;
152
+ });
153
+ // paginate the rewards
154
+ const start = params?.cursor !== undefined
155
+ ? rewards.findIndex((r) => r.cursorId === params.cursor) + 1
156
+ : 0;
157
+ const end = limit ? start + limit : rewards.length;
158
+ return {
159
+ hasMore: end < rewards.length,
160
+ items: rewards.slice(start, end),
161
+ totalItems: rewards.length,
162
+ limit,
163
+ sortOrder,
164
+ nextCursor: rewards[end]?.cursorId,
165
+ sortBy,
166
+ };
167
+ }
168
+ exports.sortAndPaginateEpochDataIntoEligibleDistributions = sortAndPaginateEpochDataIntoEligibleDistributions;
169
+ function removeEligibleRewardsFromEpochData(epochData) {
170
+ if (epochData === undefined) {
171
+ return undefined;
172
+ }
173
+ if (!(0, io_js_1.isDistributedEpoch)(epochData)) {
174
+ return epochData;
175
+ }
176
+ return {
177
+ ...epochData,
178
+ distributions: {
179
+ ...epochData.distributions,
180
+ rewards: {
181
+ ...epochData.distributions.rewards,
182
+ // @ts-expect-error -- remove eligible rewards
183
+ eligible: undefined,
184
+ },
185
+ },
186
+ };
187
+ }
188
+ exports.removeEligibleRewardsFromEpochData = removeEligibleRewardsFromEpochData;
@@ -104,3 +104,101 @@ const index_js_1 = require("./index.js");
104
104
  node_assert_1.strict.equal(errorMessage, 'Already registered (line 128)');
105
105
  });
106
106
  });
107
+ (0, node_test_1.describe)('sortAndPaginateEpochDataIntoEligibleDistributions', () => {
108
+ const mockEpochData = {
109
+ distributions: {
110
+ distributedTimestamp: 1234567890,
111
+ rewards: {
112
+ eligible: {
113
+ gateway1: {
114
+ operatorReward: 50,
115
+ delegateRewards: {
116
+ delegate1: 20,
117
+ delegate2: 30,
118
+ },
119
+ },
120
+ gateway2: {
121
+ operatorReward: 70,
122
+ delegateRewards: {
123
+ delegate3: 40,
124
+ },
125
+ },
126
+ },
127
+ },
128
+ },
129
+ };
130
+ (0, node_test_1.it)('returns empty results when epochData is undefined', () => {
131
+ node_assert_1.strict.deepEqual((0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(undefined), {
132
+ hasMore: false,
133
+ items: [],
134
+ totalItems: 0,
135
+ limit: 100,
136
+ sortOrder: 'desc',
137
+ sortBy: 'eligibleReward',
138
+ });
139
+ });
140
+ (0, node_test_1.it)('sorts rewards in descending order by eligibleReward', () => {
141
+ const result = (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(mockEpochData);
142
+ node_assert_1.strict.deepEqual(result.items, [
143
+ {
144
+ type: 'operatorReward',
145
+ recipient: 'gateway2',
146
+ eligibleReward: 70,
147
+ cursorId: 'gateway2_gateway2',
148
+ gatewayAddress: 'gateway2',
149
+ },
150
+ {
151
+ type: 'operatorReward',
152
+ recipient: 'gateway1',
153
+ eligibleReward: 50,
154
+ cursorId: 'gateway1_gateway1',
155
+ gatewayAddress: 'gateway1',
156
+ },
157
+ {
158
+ type: 'delegateReward',
159
+ recipient: 'delegate3',
160
+ eligibleReward: 40,
161
+ cursorId: 'gateway2_delegate3',
162
+ gatewayAddress: 'gateway2',
163
+ },
164
+ {
165
+ type: 'delegateReward',
166
+ recipient: 'delegate2',
167
+ eligibleReward: 30,
168
+ cursorId: 'gateway1_delegate2',
169
+ gatewayAddress: 'gateway1',
170
+ },
171
+ {
172
+ type: 'delegateReward',
173
+ recipient: 'delegate1',
174
+ eligibleReward: 20,
175
+ cursorId: 'gateway1_delegate1',
176
+ gatewayAddress: 'gateway1',
177
+ },
178
+ ]);
179
+ });
180
+ (0, node_test_1.it)('supports sorting in ascending order', () => {
181
+ const result = (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(mockEpochData, {
182
+ sortOrder: 'asc',
183
+ });
184
+ node_assert_1.strict.equal(result.items[0].eligibleReward, 20);
185
+ node_assert_1.strict.equal(result.items[result.items.length - 1].eligibleReward, 70);
186
+ });
187
+ (0, node_test_1.it)('paginates results correctly', () => {
188
+ const result = (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(mockEpochData, {
189
+ limit: 2,
190
+ });
191
+ node_assert_1.strict.equal(result.items.length, 2);
192
+ node_assert_1.strict.equal(result.hasMore, true);
193
+ node_assert_1.strict.equal(result.nextCursor, 'gateway2_delegate3');
194
+ });
195
+ (0, node_test_1.it)('resumes pagination from cursor', () => {
196
+ const firstPage = (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(mockEpochData, { limit: 2 });
197
+ const secondPage = (0, arweave_js_1.sortAndPaginateEpochDataIntoEligibleDistributions)(mockEpochData, {
198
+ limit: 2,
199
+ cursor: firstPage.nextCursor,
200
+ });
201
+ node_assert_1.strict.equal(secondPage.items.length, 2);
202
+ node_assert_1.strict.equal(secondPage.items[0].cursorId, 'gateway1_delegate2');
203
+ });
204
+ });
@@ -17,4 +17,4 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.version = void 0;
19
19
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
20
- exports.version = '3.6.2-alpha.1';
20
+ exports.version = '3.7.0-alpha.1';