@ar.io/sdk 4.0.0-solana.11 → 4.0.0-solana.12

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.
package/README.md CHANGED
@@ -1043,6 +1043,57 @@ const vaults = await ario.getAllGatewayVaults({
1043
1043
 
1044
1044
  </details>
1045
1045
 
1046
+ #### `getWithdrawals({ address, cursor, limit, sortBy, sortOrder })`
1047
+
1048
+ **Solana-only.** Returns every pending stake withdrawal owned by `address` — covering both operator-stake decreases (`isDelegate: false`) and delegate-stake decreases (`isDelegate: true`). A withdrawal is claimable when `Date.now() >= endTimestamp`; call `claimWithdrawal({ withdrawalId: item.vaultId })` to release the tokens.
1049
+
1050
+ This is the per-owner read needed to drive "you have X claimable withdrawals" UIs without fanning out across every gateway the wallet has interacted with. Throws on the AO backend.
1051
+
1052
+ ```typescript
1053
+ const ario = ARIO.init({ backend: "solana", rpc, rpcSubscriptions, signer });
1054
+
1055
+ const withdrawals = await ario.getWithdrawals({
1056
+ address: "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
1057
+ });
1058
+
1059
+ const claimable = withdrawals.items.filter(
1060
+ (w) => Date.now() >= w.endTimestamp,
1061
+ );
1062
+ ```
1063
+
1064
+ <details>
1065
+ <summary>Output</summary>
1066
+
1067
+ ```json
1068
+ {
1069
+ "hasMore": false,
1070
+ "totalItems": 2,
1071
+ "limit": 100,
1072
+ "items": [
1073
+ {
1074
+ "cursorId": "8CSdSjf7gXqQ5p1U2qfdwHzVw9sZRYHJpDpV87dnvb4d",
1075
+ "vaultId": "0",
1076
+ "gatewayAddress": "Bxz7Q2tWfqr9Q5T6cZjUnVxRk9CnHwShfgUaW5fY1Mvr",
1077
+ "balance": 50000000000,
1078
+ "startTimestamp": 1735843635857,
1079
+ "endTimestamp": 1738435635857,
1080
+ "isDelegate": true
1081
+ },
1082
+ {
1083
+ "cursorId": "FmWUz4w7vSdLcz1nN8H1n2KkjJgrQQXR1n4kV3WqJ7Hf",
1084
+ "vaultId": "1",
1085
+ "gatewayAddress": "9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin",
1086
+ "balance": 10000000000,
1087
+ "startTimestamp": 1735843835857,
1088
+ "endTimestamp": 1738435835857,
1089
+ "isDelegate": false
1090
+ }
1091
+ ]
1092
+ }
1093
+ ```
1094
+
1095
+ </details>
1096
+
1046
1097
  #### `increaseOperatorStake({ qty })`
1047
1098
 
1048
1099
  Increases the callers operator stake. Must be executed with a wallet registered as a gateway operator.
@@ -24,7 +24,7 @@ import { buyRecordCLICommand, extendLeaseCLICommand, increaseUndernameLimitCLICo
24
24
  import { escrowCancelCLICommand, escrowClaimArweaveCLICommand, escrowClaimEthereumCLICommand, escrowDepositCLICommand, escrowStatusCLICommand, escrowUpdateRecipientCLICommand, } from './commands/escrowCommands.js';
25
25
  import { cancelWithdrawal, claimWithdrawal, decreaseDelegateStake, decreaseOperatorStake, delegateStake, increaseOperatorStake, instantWithdrawal, joinNetwork, leaveNetwork, redelegateStake, saveObservations, updateGatewaySettings, } from './commands/gatewayWriteCommands.js';
26
26
  import { closeDrainedWithdrawalCLICommand, closeEmptyDelegationCLICommand, closeExpiredRequestCLICommand, closeObservationCLICommand, finalizeGoneCLICommand, pruneExpiredNamesCLICommand, pruneExpiredReservationCLICommand, pruneGatewayCLICommand, pruneNameToReturnedCLICommand, pruneReturnedNamesCLICommand, releaseVaultCLICommand, } from './commands/pruneCommands.js';
27
- import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, listAllDelegatesCLICommand, listAntsForAddress, listArNSRecords, listArNSRecordsForAddress, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
27
+ import { getAllGatewayVaults, getAllowedDelegates, getArNSRecord, getArNSReservedName, getArNSReturnedName, getCostDetails, getDelegations, getEpoch, getGateway, getGatewayDelegates, getGatewayVaults, getPrescribedNames, getPrescribedObservers, getPrimaryName, getTokenCost, getVault, getWithdrawals, listAllDelegatesCLICommand, listAntsForAddress, listArNSRecords, listArNSRecordsForAddress, listArNSReservedNames, listArNSReturnedNames, listGateways, resolveArNSName, } from './commands/readCommands.js';
28
28
  import { createVaultCLICommand, extendVaultCLICommand, increaseVaultCLICommand, revokeVaultCLICommand, transferCLICommand, vaultedTransferCLICommand, } from './commands/transfer.js';
29
29
  import { addressAndVaultIdOptions, antStateOptions, arnsPurchaseOptions, buyRecordOptions, decreaseDelegateStakeOptions, delegateStakeOptions, epochOptions, getVaultOptions, globalOptions, joinNetworkOptions, operatorStakeOptions, optionMap, paginationAddressOptions, paginationOptions, redelegateStakeOptions, setAntBaseNameOptions, setAntUndernameOptions, tokenCostOptions, transferOptions, transferRecordOwnershipOptions, updateGatewaySettingsOptions, upgradeAntOptions, vaultedTransferOptions, writeActionOptions, } from './options.js';
30
30
  import { applyOptions, arioProcessIdFromOptions, assertConfirmationPrompt, customTagsFromOptions, epochInputFromOptions, formatARIOWithCommas, getANTStateFromOptions, getLoggerFromOptions, makeCommand, paginationParamsFromOptions, readANTFromOptions, readARIOFromOptions, requiredAddressFromOptions, requiredAoSignerFromOptions, requiredProcessIdFromOptions, requiredStringArrayFromOptions, requiredStringFromOptions, writeANTFromOptions, } from './utils.js';
@@ -301,6 +301,12 @@ makeCommand({
301
301
  options: paginationAddressOptions,
302
302
  action: getAllGatewayVaults,
303
303
  });
304
+ makeCommand({
305
+ name: 'get-withdrawals',
306
+ description: 'Get all pending stake withdrawals (operator + delegate) owned by an address (Solana-only)',
307
+ options: paginationAddressOptions,
308
+ action: getWithdrawals,
309
+ });
304
310
  // # Actions
305
311
  makeCommand({
306
312
  name: 'transfer',
@@ -165,6 +165,18 @@ export async function getAllGatewayVaults(o) {
165
165
  message: `No vaults found`,
166
166
  };
167
167
  }
168
+ export async function getWithdrawals(o) {
169
+ const address = requiredAddressFromOptions(o);
170
+ const result = await readARIOFromOptions(o).getWithdrawals({
171
+ address,
172
+ ...paginationParamsFromOptions(o),
173
+ });
174
+ return result.items?.length
175
+ ? result
176
+ : {
177
+ message: `No pending withdrawals found for address ${address}`,
178
+ };
179
+ }
168
180
  export async function getVault(o) {
169
181
  return readARIOFromOptions(o)
170
182
  .getVault({
@@ -758,6 +758,16 @@ export class ARIOReadable {
758
758
  ],
759
759
  });
760
760
  }
761
+ /**
762
+ * AO backend stub — `getWithdrawals` is a Solana-only per-owner read that
763
+ * aggregates operator-stake and delegate-stake withdrawals for a wallet.
764
+ * On AO, withdrawals auto-distribute at maturity; use `getDelegations`
765
+ * (vault-typed entries) and `getGatewayVaults` instead.
766
+ */
767
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
768
+ async getWithdrawals(_params) {
769
+ throw new Error('getWithdrawals is only supported on the Solana backend (use ARIO.init({ backend: "solana", ... })).');
770
+ }
761
771
  async resolveArNSName({ name, }) {
762
772
  // derive baseName & undername using last underscore
763
773
  const lastUnderscore = name.lastIndexOf('_');
@@ -327,7 +327,7 @@ export function deserializeGatewayWithAccumulator(data) {
327
327
  r.skip(8); // weights_epoch — not surfaced on AoGatewayWeights
328
328
  // GatewaySettings2 (auto_stake removed in cfc7a8b2 — never existed on Solana)
329
329
  const allowDelegatedStaking = r.readBool();
330
- const delegateRewardShareRatio = r.readU16();
330
+ const delegateRewardShareRatio = r.readU16() / 100;
331
331
  const minDelegatedStake = r.readU64AsNumber();
332
332
  const allowlistEnabled = r.readBool();
333
333
  // RegistryIndex (index: u32, _reserved: u8 — was is_registered:bool)
@@ -633,6 +633,46 @@ export class SolanaARIOReadable {
633
633
  }
634
634
  return paginate(items, params);
635
635
  }
636
+ /**
637
+ * Return every pending stake withdrawal owned by `address` — operator-stake
638
+ * decreases (`isDelegate: false`) and delegate-stake decreases
639
+ * (`isDelegate: true`) in one paginated result. A withdrawal is claimable
640
+ * when `Date.now() >= endTimestamp`; release the funds via
641
+ * `claimWithdrawal({ withdrawalId: item.vaultId })`.
642
+ *
643
+ * Solana-only: AO releases withdrawals automatically at maturity and has no
644
+ * equivalent per-owner read; the AO backend throws.
645
+ */
646
+ async getWithdrawals(params) {
647
+ const owner = address(params.address);
648
+ // Withdrawal layout: disc(8) + owner(32) + withdrawal_id(8) + gateway(32).
649
+ // Filter by owner at offset 8 — returns both operator-stake (isDelegate=false)
650
+ // and delegate-stake (isDelegate=true) withdrawals for this wallet.
651
+ const accounts = await this.getAccountsByDiscriminator(this.garProgram, WITHDRAWAL_DISCRIMINATOR, [
652
+ {
653
+ memcmp: { offset: 8n, bytes: owner, encoding: 'base58' },
654
+ },
655
+ ]);
656
+ const items = [];
657
+ for (const { pubkey, data } of accounts) {
658
+ try {
659
+ const w = deserializeWithdrawal(data);
660
+ items.push({
661
+ cursorId: pubkey,
662
+ vaultId: w.vaultId,
663
+ balance: w.balance,
664
+ startTimestamp: secToMs(w.startTimestamp),
665
+ endTimestamp: secToMs(w.endTimestamp),
666
+ gatewayAddress: w.gateway,
667
+ isDelegate: w.isDelegate,
668
+ });
669
+ }
670
+ catch {
671
+ // Skip malformed
672
+ }
673
+ }
674
+ return paginate(items, params);
675
+ }
636
676
  // =========================================
637
677
  // ArNS read methods
638
678
  // =========================================
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '4.0.0-solana.11';
17
+ export const version = '4.0.0-solana.12';
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { AoArNSNameDataWithName, AoDelegation, AoGatewayDelegateWithAddress, AoGatewayVault, AoGetCostDetailsParams } from '../../types/io.js';
16
+ import { AoArNSNameDataWithName, AoDelegation, AoGatewayDelegateWithAddress, AoGatewayVault, AoGetCostDetailsParams, AoUserWithdrawal } from '../../types/io.js';
17
17
  import { AddressAndNameCLIOptions, AddressAndVaultIdCLIOptions, AddressCLIOptions, CLIOptionsFromAoParams, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, NameCLIOptions, PaginationAddressCLIOptions, PaginationCLIOptions } from '../types.js';
18
18
  export declare function getGateway(o: AddressCLIOptions): Promise<import("../../types/io.js").AoGateway>;
19
19
  export declare function listGateways(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoGatewayWithAddress> | {
@@ -70,6 +70,9 @@ export declare function getGatewayVaults(o: PaginationAddressCLIOptions): Promis
70
70
  export declare function getAllGatewayVaults(o: PaginationCLIOptions): Promise<import("../../types/io.js").PaginationResult<import("../../types/io.js").AoAllGatewayVaults> | {
71
71
  message: string;
72
72
  }>;
73
+ export declare function getWithdrawals(o: PaginationAddressCLIOptions): Promise<import("../../types/io.js").PaginationResult<AoUserWithdrawal> | {
74
+ message: string;
75
+ }>;
73
76
  export declare function getVault(o: AddressAndVaultIdCLIOptions): Promise<import("../../types/io.js").AoVaultData>;
74
77
  export declare function resolveArNSName(o: NameCLIOptions): Promise<import("../../types/io.js").ArNSNameResolutionData>;
75
78
  export declare function listAntsForAddress(o: AddressCLIOptions): Promise<{
@@ -1,5 +1,5 @@
1
1
  import Arweave from 'arweave';
2
- import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreatePrimaryNameRequest, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, ArNSNameResolutionData, ArNSNameResolver, BuyArNSNameProgressEvents, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, SetPrimaryNameProgressEvents, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
2
+ import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreatePrimaryNameRequest, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoUserWithdrawal, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, ArNSNameResolutionData, ArNSNameResolver, BuyArNSNameProgressEvents, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, SetPrimaryNameProgressEvents, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
3
3
  import { AOProcess } from './contracts/ao-process.js';
4
4
  import { HB } from './hyperbeam/hb.js';
5
5
  import { Logger } from './logger.js';
@@ -176,6 +176,15 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
176
176
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
177
177
  getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
178
178
  getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
179
+ /**
180
+ * AO backend stub — `getWithdrawals` is a Solana-only per-owner read that
181
+ * aggregates operator-stake and delegate-stake withdrawals for a wallet.
182
+ * On AO, withdrawals auto-distribute at maturity; use `getDelegations`
183
+ * (vault-typed entries) and `getGatewayVaults` instead.
184
+ */
185
+ getWithdrawals(_params: PaginationParams<AoUserWithdrawal> & {
186
+ address: WalletAddress;
187
+ }): Promise<PaginationResult<AoUserWithdrawal>>;
179
188
  resolveArNSName({ name, }: {
180
189
  name: string;
181
190
  }): Promise<ArNSNameResolutionData>;
@@ -8,7 +8,7 @@
8
8
  import { type Address, type Commitment } from '@solana/kit';
9
9
  import { type ILogger } from '../common/logger.js';
10
10
  import type { AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, WalletAddress } from '../types/common.js';
11
- import type { AoAddressParams, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributionData, AoEpochObservationData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetArNSRecordsParams, AoGetCostDetailsParams, AoPaginatedAddressParams, AoRegistrationFees, AoReturnedName, AoTokenCostParams, AoTokenSupplyData, AoVaultData, AoWalletVault, AoWeightedObserver, CostDetailsResult, DemandFactorSettings, EpochInput, PaginationParams, PaginationResult } from '../types/io.js';
11
+ import type { AoAddressParams, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributionData, AoEpochObservationData, AoEpochSettings, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetArNSRecordsParams, AoGetCostDetailsParams, AoPaginatedAddressParams, AoRegistrationFees, AoReturnedName, AoTokenCostParams, AoTokenSupplyData, AoUserWithdrawal, AoVaultData, AoWalletVault, AoWeightedObserver, CostDetailsResult, DemandFactorSettings, EpochInput, PaginationParams, PaginationResult } from '../types/io.js';
12
12
  import type { SolanaReadConfig, SolanaRpc } from './types.js';
13
13
  /**
14
14
  * Solana-backed read-only client for the AR.IO protocol.
@@ -132,6 +132,19 @@ export declare class SolanaARIOReadable {
132
132
  getGatewayVaults(params: PaginationParams<AoGatewayVault> & {
133
133
  address: WalletAddress;
134
134
  }): Promise<PaginationResult<AoGatewayVault>>;
135
+ /**
136
+ * Return every pending stake withdrawal owned by `address` — operator-stake
137
+ * decreases (`isDelegate: false`) and delegate-stake decreases
138
+ * (`isDelegate: true`) in one paginated result. A withdrawal is claimable
139
+ * when `Date.now() >= endTimestamp`; release the funds via
140
+ * `claimWithdrawal({ withdrawalId: item.vaultId })`.
141
+ *
142
+ * Solana-only: AO releases withdrawals automatically at maturity and has no
143
+ * equivalent per-owner read; the AO backend throws.
144
+ */
145
+ getWithdrawals(params: PaginationParams<AoUserWithdrawal> & {
146
+ address: WalletAddress;
147
+ }): Promise<PaginationResult<AoUserWithdrawal>>;
135
148
  getArNSRecord({ name }: {
136
149
  name: string;
137
150
  }): Promise<AoArNSNameData>;
@@ -276,6 +276,17 @@ export type AoGatewayVault = {
276
276
  export type AoAllGatewayVaults = AoGatewayVault & {
277
277
  gatewayAddress: WalletAddress;
278
278
  };
279
+ /**
280
+ * A pending or matured stake withdrawal owned by a wallet. Covers both
281
+ * operator-stake decreases and delegate-stake decreases — discriminate with
282
+ * `isDelegate`. A withdrawal is claimable when `Date.now() >= endTimestamp`.
283
+ *
284
+ * Solana-only: AO releases withdrawals automatically at maturity and has no
285
+ * equivalent per-owner read.
286
+ */
287
+ export type AoUserWithdrawal = AoAllGatewayVaults & {
288
+ isDelegate: boolean;
289
+ };
279
290
  export type AoJoinNetworkParams = Pick<AoGateway, 'operatorStake'> & Partial<AoGatewaySettings> & {
280
291
  observerAddress?: WalletAddress;
281
292
  services?: AoGatewayServices;
@@ -557,6 +568,9 @@ export interface AoARIORead extends ArNSNameResolver {
557
568
  getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
558
569
  getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
559
570
  getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
571
+ getWithdrawals(params: PaginationParams<AoUserWithdrawal> & {
572
+ address: WalletAddress;
573
+ }): Promise<PaginationResult<AoUserWithdrawal>>;
560
574
  }
561
575
  export interface AoARIOWrite extends AoARIORead {
562
576
  transfer: AoWriteAction<{
@@ -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 = "4.0.0-solana.10";
16
+ export declare const version = "4.0.0-solana.11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "4.0.0-solana.11",
3
+ "version": "4.0.0-solana.12",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"