@ar.io/sdk 3.3.0-alpha.12 → 3.3.0-alpha.14

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.
@@ -258,6 +258,12 @@ const utils_js_1 = require("./utils.js");
258
258
  options: options_js_1.paginationAddressOptions,
259
259
  action: readCommands_js_1.getGatewayVaults,
260
260
  });
261
+ (0, utils_js_1.makeCommand)({
262
+ name: 'list-all-gateway-vaults',
263
+ description: 'List vaults from all gateways',
264
+ options: options_js_1.paginationAddressOptions,
265
+ action: readCommands_js_1.getAllGatewayVaults,
266
+ });
261
267
  (0, utils_js_1.makeCommand)({
262
268
  name: 'transfer',
263
269
  description: 'Transfer ARIO to another address',
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVault = exports.getGatewayVaults = exports.getPrimaryName = exports.getCostDetails = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.listArNSReturnedNames = exports.getArNSReturnedName = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listAllDelegatesCLICommand = exports.listGateways = exports.getGateway = void 0;
3
+ exports.getVault = exports.getAllGatewayVaults = exports.getGatewayVaults = exports.getPrimaryName = exports.getCostDetails = exports.getTokenCost = exports.getPrescribedNames = exports.getPrescribedObservers = exports.getEpoch = exports.listArNSReturnedNames = exports.getArNSReturnedName = exports.listArNSReservedNames = exports.getArNSReservedName = exports.listArNSRecords = exports.getArNSRecord = exports.getAllowedDelegates = exports.getDelegations = exports.getGatewayDelegates = exports.listAllDelegatesCLICommand = exports.listGateways = exports.getGateway = void 0;
4
4
  const token_js_1 = require("../../types/token.js");
5
5
  const utils_js_1 = require("../utils.js");
6
6
  async function getGateway(o) {
@@ -173,6 +173,15 @@ async function getGatewayVaults(o) {
173
173
  };
174
174
  }
175
175
  exports.getGatewayVaults = getGatewayVaults;
176
+ async function getAllGatewayVaults(o) {
177
+ const result = await (0, utils_js_1.readARIOFromOptions)(o).getAllGatewayVaults((0, utils_js_1.paginationParamsFromOptions)(o));
178
+ return result.items?.length
179
+ ? result
180
+ : {
181
+ message: `No vaults found`,
182
+ };
183
+ }
184
+ exports.getAllGatewayVaults = getAllGatewayVaults;
176
185
  async function getVault(o) {
177
186
  return (0, utils_js_1.readARIOFromOptions)(o)
178
187
  .getVault({
@@ -449,6 +449,14 @@ class ARIOReadable {
449
449
  ],
450
450
  });
451
451
  }
452
+ async getAllGatewayVaults(params) {
453
+ return this.process.read({
454
+ tags: [
455
+ { name: 'Action', value: 'All-Gateway-Vaults' },
456
+ ...(0, arweave_js_1.paginationParamsToTags)(params),
457
+ ],
458
+ });
459
+ }
452
460
  }
453
461
  exports.ARIOReadable = ARIOReadable;
454
462
  class ARIOWriteable extends ARIOReadable {
@@ -35,22 +35,40 @@ exports.paginationParamsToTags = paginationParamsToTags;
35
35
  * @param arweave - The Arweave instance
36
36
  * @returns The epoch with distribution data
37
37
  */
38
- const getEpochDataFromGql = async ({ arweave, epochIndex, processId = constants_js_1.ARIO_TESTNET_PROCESS_ID, }) => {
38
+ const getEpochDataFromGql = async ({ arweave, epochIndex, processId = constants_js_1.ARIO_TESTNET_PROCESS_ID, retries = 3, }) => {
39
39
  // fetch from gql
40
40
  const query = (0, exports.epochDistributionNoticeGqlQuery)({ epochIndex, processId });
41
- const response = await arweave.api.post('graphql', query);
42
- // parse the nodes to get the id
43
- if (response.data.data.transactions?.edges?.length === 0) {
44
- return undefined;
41
+ // add three retries with exponential backoff
42
+ for (let i = 0; i < retries; i++) {
43
+ try {
44
+ const response = await arweave.api.post('graphql', query);
45
+ // parse the nodes to get the id
46
+ if (response.data?.data?.transactions?.edges?.length === 0) {
47
+ return undefined;
48
+ }
49
+ const id = response.data.data.transactions.edges[0].node.id;
50
+ // fetch the transaction from arweave
51
+ const transaction = await arweave.api.get(id);
52
+ // assert it is the correct type
53
+ return (0, ao_js_1.parseAoEpochData)(transaction.data);
54
+ }
55
+ catch (error) {
56
+ if (i === retries - 1)
57
+ throw error; // Re-throw on final attempt
58
+ // exponential backoff
59
+ await new Promise((resolve) => setTimeout(resolve, Math.pow(2, i) * 1000));
60
+ }
45
61
  }
46
- const id = response.data.data.transactions.edges[0].node.id;
47
- // fetch the transaction from arweave
48
- const transaction = await arweave.api.get(id);
49
- const data = transaction.data;
50
- // assert it is the correct type
51
- return (0, ao_js_1.parseAoEpochData)(data);
62
+ return undefined;
52
63
  };
53
64
  exports.getEpochDataFromGql = getEpochDataFromGql;
65
+ /**
66
+ * Get the epoch with distribution data for the current epoch
67
+ * @param arweave - The Arweave instance
68
+ * @param epochIndex - The index of the epoch
69
+ * @param processId - The process ID (optional, defaults to ARIO_TESTNET_PROCESS_ID)
70
+ * @returns string - The stringified GQL query
71
+ */
54
72
  const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = constants_js_1.ARIO_TESTNET_PROCESS_ID, }) => {
55
73
  // write the query
56
74
  const gqlQuery = JSON.stringify({
@@ -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.3.0-alpha.12';
20
+ exports.version = '3.3.0-alpha.14';
@@ -21,7 +21,7 @@ import { mARIOToken } from '../types/token.js';
21
21
  import { version } from '../version.js';
22
22
  import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICommand, requestPrimaryNameCLICommand, upgradeRecordCLICommand, } from './commands/arnsPurchaseCommands.js';
23
23
  import { cancelWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
24
- import { getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
24
+ import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listArNSRecords, listArNSReservedNames, listArNSReturnedNames, listGateways, } from './commands/readCommands.js';
25
25
  import { transfer } from './commands/transfer.js';
26
26
  import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, tokenCostOptions, transferOptions, updateGatewaySettingsOptions, writeActionOptions, } from './options.js';
27
27
  import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, writeActionTagsFromOptions, } from './utils.js';
@@ -256,6 +256,12 @@ makeCommand({
256
256
  options: paginationAddressOptions,
257
257
  action: getGatewayVaults,
258
258
  });
259
+ makeCommand({
260
+ name: 'list-all-gateway-vaults',
261
+ description: 'List vaults from all gateways',
262
+ options: paginationAddressOptions,
263
+ action: getAllGatewayVaults,
264
+ });
259
265
  makeCommand({
260
266
  name: 'transfer',
261
267
  description: 'Transfer ARIO to another address',
@@ -151,6 +151,14 @@ export async function getGatewayVaults(o) {
151
151
  message: `No vaults found for gateway ${address}`,
152
152
  };
153
153
  }
154
+ export async function getAllGatewayVaults(o) {
155
+ const result = await readARIOFromOptions(o).getAllGatewayVaults(paginationParamsFromOptions(o));
156
+ return result.items?.length
157
+ ? result
158
+ : {
159
+ message: `No vaults found`,
160
+ };
161
+ }
154
162
  export async function getVault(o) {
155
163
  return readARIOFromOptions(o)
156
164
  .getVault({
@@ -445,6 +445,14 @@ export class ARIOReadable {
445
445
  ],
446
446
  });
447
447
  }
448
+ async getAllGatewayVaults(params) {
449
+ return this.process.read({
450
+ tags: [
451
+ { name: 'Action', value: 'All-Gateway-Vaults' },
452
+ ...paginationParamsToTags(params),
453
+ ],
454
+ });
455
+ }
448
456
  }
449
457
  export class ARIOWriteable extends ARIOReadable {
450
458
  signer;
@@ -28,21 +28,39 @@ export const paginationParamsToTags = (params) => {
28
28
  * @param arweave - The Arweave instance
29
29
  * @returns The epoch with distribution data
30
30
  */
31
- export const getEpochDataFromGql = async ({ arweave, epochIndex, processId = ARIO_TESTNET_PROCESS_ID, }) => {
31
+ export const getEpochDataFromGql = async ({ arweave, epochIndex, processId = ARIO_TESTNET_PROCESS_ID, retries = 3, }) => {
32
32
  // fetch from gql
33
33
  const query = epochDistributionNoticeGqlQuery({ epochIndex, processId });
34
- const response = await arweave.api.post('graphql', query);
35
- // parse the nodes to get the id
36
- if (response.data.data.transactions?.edges?.length === 0) {
37
- return undefined;
34
+ // add three retries with exponential backoff
35
+ for (let i = 0; i < retries; i++) {
36
+ try {
37
+ const response = await arweave.api.post('graphql', query);
38
+ // parse the nodes to get the id
39
+ if (response.data?.data?.transactions?.edges?.length === 0) {
40
+ return undefined;
41
+ }
42
+ const id = response.data.data.transactions.edges[0].node.id;
43
+ // fetch the transaction from arweave
44
+ const transaction = await arweave.api.get(id);
45
+ // assert it is the correct type
46
+ return parseAoEpochData(transaction.data);
47
+ }
48
+ catch (error) {
49
+ if (i === retries - 1)
50
+ throw error; // Re-throw on final attempt
51
+ // exponential backoff
52
+ await new Promise((resolve) => setTimeout(resolve, Math.pow(2, i) * 1000));
53
+ }
38
54
  }
39
- const id = response.data.data.transactions.edges[0].node.id;
40
- // fetch the transaction from arweave
41
- const transaction = await arweave.api.get(id);
42
- const data = transaction.data;
43
- // assert it is the correct type
44
- return parseAoEpochData(data);
55
+ return undefined;
45
56
  };
57
+ /**
58
+ * Get the epoch with distribution data for the current epoch
59
+ * @param arweave - The Arweave instance
60
+ * @param epochIndex - The index of the epoch
61
+ * @param processId - The process ID (optional, defaults to ARIO_TESTNET_PROCESS_ID)
62
+ * @returns string - The stringified GQL query
63
+ */
46
64
  export const epochDistributionNoticeGqlQuery = ({ epochIndex, processId = ARIO_TESTNET_PROCESS_ID, }) => {
47
65
  // write the query
48
66
  const gqlQuery = JSON.stringify({
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.3.0-alpha.12';
17
+ export const version = '3.3.0-alpha.14';
@@ -79,6 +79,9 @@ export declare function getPrimaryName(o: AddressAndNameCLIOptions): Promise<imp
79
79
  export declare function getGatewayVaults(o: PaginationAddressCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoGatewayVault> | {
80
80
  message: string;
81
81
  }>;
82
+ export declare function getAllGatewayVaults(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoAllGatewayVaults> | {
83
+ message: string;
84
+ }>;
82
85
  export declare function getVault(o: AddressAndVaultIdCLIOptions): Promise<import("../../types/io.js").AoVaultData | {
83
86
  message: string;
84
87
  }>;
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import Arweave from 'arweave';
17
17
  import { AoArNSNameDataWithName, AoArNSReservedNameData, AoBalanceWithAddress, AoEpochDistributionData, AoEpochObservationData, AoGatewayWithAddress, AoJoinNetworkParams, AoMessageResult, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoReturnedName, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoWeightedObserver, OptionalArweave, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
18
- import { AoARIORead, AoARIOWrite, AoAllDelegates, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
18
+ import { AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSPurchaseParams, AoArNSReservedNameDataWithName, AoBuyRecordParams, AoDelegation, AoEpochData, AoEpochSettings, AoExtendLeaseParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoPaginatedAddressParams, AoRegistrationFees, AoVaultData, AoWalletVault, CostDetailsResult, DemandFactorSettings, EpochInput } from '../types/io.js';
19
19
  import { mARIOToken } from '../types/token.js';
20
20
  import { AOProcess } from './contracts/ao-process.js';
21
21
  type ARIOConfigNoSigner = OptionalArweave<ProcessConfiguration>;
@@ -137,6 +137,7 @@ export declare class ARIOReadable implements AoARIORead {
137
137
  }): Promise<AoRedelegationFeeInfo>;
138
138
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
139
139
  getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
140
+ getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
140
141
  }
141
142
  export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
142
143
  protected process: AOProcess;
@@ -197,6 +197,11 @@ export type AoGatewayDelegate = {
197
197
  export type AoGatewayDelegateWithAddress = AoGatewayDelegate & {
198
198
  address: WalletAddress;
199
199
  };
200
+ export type AoAllDelegates = AoGatewayDelegateWithAddress & {
201
+ gatewayAddress: WalletAddress;
202
+ vaultedStake: number;
203
+ cursorId: string;
204
+ };
200
205
  export type AoGatewaySettings = {
201
206
  allowDelegatedStaking: boolean | 'allowlist';
202
207
  delegateRewardShareRatio: number;
@@ -236,6 +241,7 @@ export type AoStakeDelegation = AoDelegationBase & {
236
241
  balance: number;
237
242
  };
238
243
  export type AoDelegation = AoStakeDelegation | AoVaultDelegation;
244
+ /** Operator stake being withdrawn from a given gateway */
239
245
  export type AoGatewayVault = {
240
246
  cursorId: string;
241
247
  vaultId: TransactionId;
@@ -243,6 +249,10 @@ export type AoGatewayVault = {
243
249
  endTimestamp: Timestamp;
244
250
  startTimestamp: Timestamp;
245
251
  };
252
+ /** Operator stake being withdrawn from all gateway gateways */
253
+ export type AoAllGatewayVaults = AoGatewayVault & {
254
+ gatewayAddress: WalletAddress;
255
+ };
246
256
  export type AoJoinNetworkParams = Pick<AoGateway, 'operatorStake'> & Partial<AoGatewaySettings> & {
247
257
  observerAddress?: WalletAddress;
248
258
  };
@@ -422,15 +432,8 @@ export interface AoARIORead {
422
432
  }): Promise<AoRedelegationFeeInfo>;
423
433
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
424
434
  getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
435
+ getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
425
436
  }
426
- export type AoAllDelegates = {
427
- address: WalletAddress;
428
- gatewayAddress: WalletAddress;
429
- delegatedStake: number;
430
- startTimestamp: Timestamp;
431
- vaultedStake: number;
432
- cursorId: string;
433
- };
434
437
  export interface AoARIOWrite extends AoARIORead {
435
438
  transfer({ target, qty, }: {
436
439
  target: WalletAddress;
@@ -39,11 +39,19 @@ export declare const paginationParamsToTags: <T>(params?: PaginationParams<T>) =
39
39
  * @param arweave - The Arweave instance
40
40
  * @returns The epoch with distribution data
41
41
  */
42
- export declare const getEpochDataFromGql: ({ arweave, epochIndex, processId, }: {
42
+ export declare const getEpochDataFromGql: ({ arweave, epochIndex, processId, retries, }: {
43
43
  arweave: Arweave;
44
44
  epochIndex: number;
45
45
  processId?: string;
46
+ retries?: number;
46
47
  }) => Promise<AoEpochData | undefined>;
48
+ /**
49
+ * Get the epoch with distribution data for the current epoch
50
+ * @param arweave - The Arweave instance
51
+ * @param epochIndex - The index of the epoch
52
+ * @param processId - The process ID (optional, defaults to ARIO_TESTNET_PROCESS_ID)
53
+ * @returns string - The stringified GQL query
54
+ */
47
55
  export declare const epochDistributionNoticeGqlQuery: ({ epochIndex, processId, }: {
48
56
  epochIndex: number;
49
57
  processId?: string;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.3.0-alpha.11";
16
+ export declare const version = "3.3.0-alpha.13";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.3.0-alpha.12",
3
+ "version": "3.3.0-alpha.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"