@ar.io/sdk 3.24.0 → 4.0.0-alpha.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.
- package/README.md +757 -589
- package/lib/esm/cli/cli.js +188 -152
- package/lib/esm/cli/commands/antCommands.js +23 -58
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
- package/lib/esm/cli/commands/escrowCommands.js +227 -0
- package/lib/esm/cli/commands/gatewayWriteCommands.js +140 -23
- package/lib/esm/cli/commands/pruneCommands.js +154 -0
- package/lib/esm/cli/commands/readCommands.js +22 -3
- package/lib/esm/cli/commands/transfer.js +6 -6
- package/lib/esm/cli/options.js +124 -58
- package/lib/esm/cli/utils.js +303 -175
- package/lib/esm/common/ant-registry.js +17 -143
- package/lib/esm/common/ant.js +44 -1167
- package/lib/esm/common/faucet.js +17 -6
- package/lib/esm/common/index.js +0 -4
- package/lib/esm/common/io.js +25 -1412
- package/lib/esm/constants.js +13 -19
- package/lib/esm/solana/ant-readable.js +724 -0
- package/lib/esm/solana/ant-registry-readable.js +133 -0
- package/lib/esm/solana/ant-registry-writeable.js +472 -0
- package/lib/esm/solana/ant-writeable.js +384 -0
- package/lib/esm/solana/ata.js +70 -0
- package/lib/esm/solana/canonical-message.js +128 -0
- package/lib/esm/solana/clusters.js +111 -0
- package/lib/esm/solana/constants.js +146 -0
- package/lib/esm/solana/delegation-math.js +112 -0
- package/lib/esm/solana/deserialize.js +711 -0
- package/lib/esm/solana/escrow.js +839 -0
- package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
- package/lib/esm/solana/funding-plan.js +699 -0
- package/lib/esm/solana/index.js +126 -0
- package/lib/esm/solana/instruction.js +39 -0
- package/lib/esm/solana/io-readable.js +2182 -0
- package/lib/esm/solana/io-writeable.js +3196 -0
- package/lib/esm/solana/json-rpc.js +90 -0
- package/lib/esm/solana/metadata.js +81 -0
- package/lib/esm/solana/mpl-core.js +192 -0
- package/lib/esm/solana/pda.js +332 -0
- package/lib/esm/solana/predict-prescribed-observers.js +110 -0
- package/lib/esm/solana/retry.js +117 -0
- package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
- package/lib/esm/solana/send.js +372 -0
- package/lib/esm/solana/spawn-ant.js +224 -0
- package/lib/esm/solana/types.js +1 -0
- package/lib/esm/types/ant.js +27 -15
- package/lib/esm/types/io.js +8 -11
- package/lib/esm/utils/ant.js +0 -63
- package/lib/esm/utils/index.js +0 -3
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +5 -13
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
- package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
- package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
- package/lib/types/cli/commands/readCommands.d.ts +27 -22
- package/lib/types/cli/commands/transfer.d.ts +9 -9
- package/lib/types/cli/options.d.ts +76 -21
- package/lib/types/cli/types.d.ts +11 -13
- package/lib/types/cli/utils.d.ts +71 -31
- package/lib/types/common/ant-registry.d.ts +49 -47
- package/lib/types/common/ant.d.ts +54 -539
- package/lib/types/common/faucet.d.ts +20 -8
- package/lib/types/common/index.d.ts +0 -3
- package/lib/types/common/io.d.ts +66 -258
- package/lib/types/constants.d.ts +11 -18
- package/lib/types/solana/ant-readable.d.ts +180 -0
- package/lib/types/solana/ant-registry-readable.d.ts +105 -0
- package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
- package/lib/types/solana/ant-writeable.d.ts +177 -0
- package/lib/types/solana/ata.d.ts +44 -0
- package/lib/types/solana/canonical-message.d.ts +121 -0
- package/lib/types/solana/clusters.d.ts +109 -0
- package/lib/types/solana/constants.d.ts +119 -0
- package/lib/types/solana/delegation-math.d.ts +45 -0
- package/lib/types/solana/deserialize.d.ts +262 -0
- package/lib/types/solana/escrow.d.ts +480 -0
- package/lib/types/solana/events.d.ts +38 -0
- package/lib/types/solana/funding-plan.d.ts +225 -0
- package/lib/types/solana/index.d.ts +87 -0
- package/lib/types/solana/instruction.d.ts +39 -0
- package/lib/types/solana/io-readable.d.ts +499 -0
- package/lib/types/solana/io-writeable.d.ts +893 -0
- package/lib/types/solana/json-rpc.d.ts +47 -0
- package/lib/types/solana/metadata.d.ts +84 -0
- package/lib/types/solana/mpl-core.d.ts +120 -0
- package/lib/types/solana/pda.d.ts +95 -0
- package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
- package/lib/types/solana/retry.d.ts +62 -0
- package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
- package/lib/types/solana/send.d.ts +94 -0
- package/lib/types/solana/spawn-ant.d.ts +145 -0
- package/lib/types/solana/types.d.ts +82 -0
- package/lib/types/types/ant-registry.d.ts +43 -4
- package/lib/types/types/ant.d.ts +114 -96
- package/lib/types/types/common.d.ts +18 -74
- package/lib/types/types/faucet.d.ts +2 -2
- package/lib/types/types/io.d.ts +244 -158
- package/lib/types/types/token.d.ts +0 -12
- package/lib/types/utils/ant.d.ts +1 -12
- package/lib/types/utils/index.d.ts +0 -3
- package/lib/types/version.d.ts +1 -1
- package/package.json +36 -33
- package/lib/cjs/cli/cli.js +0 -822
- package/lib/cjs/cli/commands/antCommands.js +0 -113
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
- package/lib/cjs/cli/commands/readCommands.js +0 -215
- package/lib/cjs/cli/commands/transfer.js +0 -159
- package/lib/cjs/cli/options.js +0 -470
- package/lib/cjs/cli/types.js +0 -2
- package/lib/cjs/cli/utils.js +0 -639
- package/lib/cjs/common/ant-registry.js +0 -155
- package/lib/cjs/common/ant-versions.js +0 -93
- package/lib/cjs/common/ant.js +0 -1182
- package/lib/cjs/common/arweave.js +0 -27
- package/lib/cjs/common/contracts/ao-process.js +0 -224
- package/lib/cjs/common/error.js +0 -64
- package/lib/cjs/common/faucet.js +0 -150
- package/lib/cjs/common/hyperbeam/hb.js +0 -173
- package/lib/cjs/common/index.js +0 -42
- package/lib/cjs/common/io.js +0 -1423
- package/lib/cjs/common/logger.js +0 -83
- package/lib/cjs/common/loggers/winston.js +0 -68
- package/lib/cjs/common/marketplace.js +0 -731
- package/lib/cjs/common/turbo.js +0 -223
- package/lib/cjs/constants.js +0 -41
- package/lib/cjs/node/index.js +0 -39
- package/lib/cjs/package.json +0 -1
- package/lib/cjs/types/ant-registry.js +0 -2
- package/lib/cjs/types/ant.js +0 -168
- package/lib/cjs/types/common.js +0 -2
- package/lib/cjs/types/faucet.js +0 -2
- package/lib/cjs/types/index.js +0 -37
- package/lib/cjs/types/io.js +0 -51
- package/lib/cjs/types/token.js +0 -116
- package/lib/cjs/utils/ant.js +0 -108
- package/lib/cjs/utils/ao.js +0 -432
- package/lib/cjs/utils/arweave.js +0 -285
- package/lib/cjs/utils/base64.js +0 -62
- package/lib/cjs/utils/hash.js +0 -56
- package/lib/cjs/utils/index.js +0 -38
- package/lib/cjs/utils/processes.js +0 -173
- package/lib/cjs/utils/random.js +0 -30
- package/lib/cjs/utils/schema.js +0 -15
- package/lib/cjs/utils/url.js +0 -37
- package/lib/cjs/version.js +0 -20
- package/lib/cjs/web/index.js +0 -41
- package/lib/esm/common/ant-versions.js +0 -87
- package/lib/esm/common/arweave.js +0 -21
- package/lib/esm/common/contracts/ao-process.js +0 -220
- package/lib/esm/common/hyperbeam/hb.js +0 -169
- package/lib/esm/common/marketplace.js +0 -724
- package/lib/esm/common/turbo.js +0 -215
- package/lib/esm/node/index.js +0 -20
- package/lib/esm/utils/ao.js +0 -420
- package/lib/esm/utils/arweave.js +0 -271
- package/lib/esm/utils/processes.js +0 -167
- package/lib/esm/web/index.js +0 -20
- package/lib/types/common/ant-versions.d.ts +0 -39
- package/lib/types/common/arweave.d.ts +0 -17
- package/lib/types/common/contracts/ao-process.d.ts +0 -47
- package/lib/types/common/hyperbeam/hb.d.ts +0 -88
- package/lib/types/common/marketplace.d.ts +0 -568
- package/lib/types/common/turbo.d.ts +0 -61
- package/lib/types/node/index.d.ts +0 -20
- package/lib/types/utils/ao.d.ts +0 -80
- package/lib/types/utils/arweave.d.ts +0 -79
- package/lib/types/utils/processes.d.ts +0 -39
- package/lib/types/web/index.d.ts +0 -20
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Solana implementation of the ARIORead interface.
|
|
18
|
+
*
|
|
19
|
+
* Reads AR.IO protocol state directly from Solana PDAs using RPC,
|
|
20
|
+
* returning the same types that the AO implementation returns.
|
|
21
|
+
* This allows consumers to switch backends transparently.
|
|
22
|
+
*/
|
|
23
|
+
import { type Address, type Commitment } from '@solana/kit';
|
|
24
|
+
import { type ILogger } from '../common/logger.js';
|
|
25
|
+
import type { PrimaryName, PrimaryNameRequest, RedelegationFeeInfo, WalletAddress } from '../types/common.js';
|
|
26
|
+
import type { AddressParams, AllDelegates, AllGatewayVaults, ArNSNameData, ArNSNameDataWithName, ArNSReservedNameData, ArNSReservedNameDataWithName, BalanceWithAddress, CostDetailsResult, Delegation, DemandFactorSettings, EligibleDistribution, EpochData, EpochDistributionData, EpochInput, EpochObservationData, EpochSettings, Gateway, GatewayDelegateWithAddress, GatewayRegistrySettings, GatewayVault, GatewayWithAddress, GetArNSRecordsParams, GetCostDetailsParams, PaginatedAddressParams, PaginationParams, PaginationResult, RegistrationFees, ReturnedName, TokenCostParams, TokenSupplyData, UserWithdrawal, VaultData, WalletVault, WeightedObserver } from '../types/io.js';
|
|
27
|
+
import type { SolanaReadConfig, SolanaRpc } from './types.js';
|
|
28
|
+
/**
|
|
29
|
+
* Solana-backed read-only client for the AR.IO protocol.
|
|
30
|
+
*
|
|
31
|
+
* Usage:
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { createSolanaRpc } from '@solana/kit';
|
|
34
|
+
* import { SolanaARIOReadable } from '@ar.io/sdk/solana';
|
|
35
|
+
*
|
|
36
|
+
* const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
|
|
37
|
+
* const ario = new SolanaARIOReadable({ rpc });
|
|
38
|
+
*
|
|
39
|
+
* const gateway = await ario.getGateway({ address: 'GatewayOperatorPubkey...' });
|
|
40
|
+
* const record = await ario.getArNSRecord({ name: 'ardrive' });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class SolanaARIOReadable {
|
|
44
|
+
protected readonly rpc: SolanaRpc;
|
|
45
|
+
protected readonly commitment: Commitment;
|
|
46
|
+
protected readonly logger: ILogger;
|
|
47
|
+
protected readonly coreProgram: Address;
|
|
48
|
+
protected readonly garProgram: Address;
|
|
49
|
+
protected readonly arnsProgram: Address;
|
|
50
|
+
protected readonly antProgram: Address;
|
|
51
|
+
private _arioMint?;
|
|
52
|
+
private _accountCache;
|
|
53
|
+
constructor(config: SolanaReadConfig & {
|
|
54
|
+
logger?: ILogger;
|
|
55
|
+
coreProgramId?: Address;
|
|
56
|
+
garProgramId?: Address;
|
|
57
|
+
arnsProgramId?: Address;
|
|
58
|
+
antProgramId?: Address;
|
|
59
|
+
});
|
|
60
|
+
/** Helper to fetch an encoded account (kit's replacement for Connection.getAccountInfo). */
|
|
61
|
+
private getAccount;
|
|
62
|
+
/**
|
|
63
|
+
* Like {@link getAccount} but caches the result per-PDA for `ttlMs`. Use only
|
|
64
|
+
* for accounts that change slowly (DemandFactor, ArnsConfig) where a few
|
|
65
|
+
* seconds of staleness is acceptable in exchange for collapsing repeated
|
|
66
|
+
* reads. A successful fetch is cached; misses (`exists: false`) are not.
|
|
67
|
+
*/
|
|
68
|
+
private getCachedAccount;
|
|
69
|
+
/**
|
|
70
|
+
* Helper for `getProgramAccounts` with a discriminator memcmp filter.
|
|
71
|
+
*
|
|
72
|
+
* Pass the Codama-generated `<NAME>_DISCRIMINATOR: Uint8Array` constant
|
|
73
|
+
* directly — kit's RPC requires a base58 string for `memcmp.bytes`, so
|
|
74
|
+
* we bs58-encode here to keep call sites from doing it inline (and to
|
|
75
|
+
* keep the IDL-derived bytes as the single source of truth).
|
|
76
|
+
*/
|
|
77
|
+
private getAccountsByDiscriminator;
|
|
78
|
+
/**
|
|
79
|
+
* Batch-fetch the `cumulative_reward_per_token` accumulator for every gateway
|
|
80
|
+
* in `operatorAddresses`. Returns a Map keyed by base58 operator address.
|
|
81
|
+
* Used by the delegate readers below to compute the live delegation balance
|
|
82
|
+
* without an on-chain settlement call (see {@link computeLiveDelegationBalance}
|
|
83
|
+
* and `INVARIANTS.md` in the contracts repo). Missing gateways are silently
|
|
84
|
+
* skipped — callers fall back to the stale `Delegation.amount` for those
|
|
85
|
+
* (the accumulator delta is 0 and live == stored anyway when the gateway
|
|
86
|
+
* has no rewards to distribute).
|
|
87
|
+
*/
|
|
88
|
+
protected getGatewayAccumulators(operatorAddresses: string[]): Promise<Map<string, bigint>>;
|
|
89
|
+
/** Read the gateway registry and return addresses in registry index order */
|
|
90
|
+
protected getRegistryGatewayAddresses(): Promise<string[]>;
|
|
91
|
+
getInfo(): Promise<{
|
|
92
|
+
epochSettings?: {
|
|
93
|
+
epochZeroStartTimestamp: number;
|
|
94
|
+
durationMs: number;
|
|
95
|
+
prescribedNameCount: number;
|
|
96
|
+
maxObservers: number;
|
|
97
|
+
} | undefined;
|
|
98
|
+
totalSupply?: number | undefined;
|
|
99
|
+
protocolBalance?: number | undefined;
|
|
100
|
+
Ticker: string;
|
|
101
|
+
Name: string;
|
|
102
|
+
Logo: string;
|
|
103
|
+
Denomination: number;
|
|
104
|
+
Handlers: never[];
|
|
105
|
+
LastCreatedEpochIndex: number;
|
|
106
|
+
LastDistributedEpochIndex: number;
|
|
107
|
+
}>;
|
|
108
|
+
getTokenSupply(): Promise<TokenSupplyData>;
|
|
109
|
+
/**
|
|
110
|
+
* Read the `amount` (in mARIO) of an SPL token account directly by address.
|
|
111
|
+
* Returns `null` if the account doesn't exist or is too small to be a token
|
|
112
|
+
* account, so callers can distinguish "absent" from a real zero balance.
|
|
113
|
+
*
|
|
114
|
+
* Uses a portable little-endian u64 decode — some browser bundlers strip the
|
|
115
|
+
* BigInt readers from the `buffer` shim's prototype (see `getBalance`).
|
|
116
|
+
*/
|
|
117
|
+
private getTokenAccountAmount;
|
|
118
|
+
/**
|
|
119
|
+
* Resolve the ARIO SPL mint address from the on-chain `ArioConfig`.
|
|
120
|
+
*
|
|
121
|
+
* `ArioConfig` layout: [8 disc][32 authority][32 mint][...]. We decode
|
|
122
|
+
* the mint at offset 40 and cache it for the lifetime of this instance —
|
|
123
|
+
* the mint never changes once the protocol is deployed.
|
|
124
|
+
*/
|
|
125
|
+
protected getArioMint(): Promise<Address>;
|
|
126
|
+
/**
|
|
127
|
+
* Liquid ARIO balance for an address.
|
|
128
|
+
*
|
|
129
|
+
* On Solana the ARIO token is a real SPL mint, so the canonical liquid
|
|
130
|
+
* balance lives on the user's Associated Token Account — *not* the
|
|
131
|
+
* `ario-core::Balance` PDA. The Balance PDA is only populated by the
|
|
132
|
+
* one-shot AO-to-Solana migration importer for legacy snapshot accounts;
|
|
133
|
+
* spending it requires a separate claim flow that mints/transfers SPL
|
|
134
|
+
* tokens to the user's ATA. Steady-state instructions like `buy_name`,
|
|
135
|
+
* gateway/delegate stake, and ARIO transfers all move SPL tokens, so the
|
|
136
|
+
* ATA is what every UI and on-chain caller cares about.
|
|
137
|
+
*
|
|
138
|
+
* Returns 0 if the user has no ATA initialized yet.
|
|
139
|
+
*/
|
|
140
|
+
getBalance({ address: owner, }: {
|
|
141
|
+
address: WalletAddress;
|
|
142
|
+
}): Promise<number>;
|
|
143
|
+
/**
|
|
144
|
+
* Enumerate liquid ARIO balances by querying the SPL Token program for
|
|
145
|
+
* every initialized token account on the ARIO mint.
|
|
146
|
+
*
|
|
147
|
+
* Filters: token-account size = 165, mint at offset 0. We then decode
|
|
148
|
+
* `owner` (offset 32) and `amount` (offset 64) from each.
|
|
149
|
+
*/
|
|
150
|
+
getBalances(params?: PaginationParams<BalanceWithAddress>): Promise<PaginationResult<BalanceWithAddress>>;
|
|
151
|
+
getVault({ address: owner, vaultId, }: {
|
|
152
|
+
address: WalletAddress;
|
|
153
|
+
vaultId: string;
|
|
154
|
+
}): Promise<VaultData>;
|
|
155
|
+
getVaults(params?: PaginationParams<WalletVault>): Promise<PaginationResult<WalletVault>>;
|
|
156
|
+
getGateway({ address: addr }: AddressParams): Promise<Gateway>;
|
|
157
|
+
getGateways(params?: PaginationParams<GatewayWithAddress>): Promise<PaginationResult<GatewayWithAddress>>;
|
|
158
|
+
getGatewayDelegates(params: AddressParams & PaginationParams<GatewayDelegateWithAddress>): Promise<PaginationResult<GatewayDelegateWithAddress>>;
|
|
159
|
+
getGatewayDelegateAllowList(params: PaginatedAddressParams): Promise<PaginationResult<WalletAddress>>;
|
|
160
|
+
/**
|
|
161
|
+
* Returns every delegation a wallet currently has, covering both halves
|
|
162
|
+
* of the `Delegation` union:
|
|
163
|
+
*
|
|
164
|
+
* - `type: 'stake'` — active `Delegation` PDAs (filtered by delegator at
|
|
165
|
+
* memcmp offset 40 = 8 disc + 32 gateway).
|
|
166
|
+
* - `type: 'vault'` — pending delegate-stake withdrawals: `Withdrawal`
|
|
167
|
+
* PDAs filtered by owner at memcmp offset 8 (= 8 disc), then narrowed
|
|
168
|
+
* client-side to `isDelegate: true`. Operator-stake withdrawals are
|
|
169
|
+
* excluded — those are surfaced via `getWithdrawals` /
|
|
170
|
+
* `getGatewayVaults`.
|
|
171
|
+
*
|
|
172
|
+
* Both queries run in parallel; consumers see a single merged result
|
|
173
|
+
* matching the cross-backend interface contract.
|
|
174
|
+
*/
|
|
175
|
+
getDelegations(params: PaginationParams<Delegation> & {
|
|
176
|
+
address: WalletAddress;
|
|
177
|
+
}): Promise<PaginationResult<Delegation>>;
|
|
178
|
+
getAllowedDelegates(params: PaginatedAddressParams): Promise<PaginationResult<WalletAddress>>;
|
|
179
|
+
getGatewayVaults(params: PaginationParams<GatewayVault> & {
|
|
180
|
+
address: WalletAddress;
|
|
181
|
+
}): Promise<PaginationResult<GatewayVault>>;
|
|
182
|
+
/**
|
|
183
|
+
* Return every pending stake withdrawal owned by `address` — operator-stake
|
|
184
|
+
* decreases (`isDelegate: false`) and delegate-stake decreases
|
|
185
|
+
* (`isDelegate: true`) in one paginated result. A withdrawal is claimable
|
|
186
|
+
* when `Date.now() >= endTimestamp`; release the funds via
|
|
187
|
+
* `claimWithdrawal({ withdrawalId: item.vaultId })`.
|
|
188
|
+
*
|
|
189
|
+
* Solana-only: AO releases withdrawals automatically at maturity and has no
|
|
190
|
+
* equivalent per-owner read; the AO backend throws.
|
|
191
|
+
*/
|
|
192
|
+
getWithdrawals(params: PaginationParams<UserWithdrawal> & {
|
|
193
|
+
address: WalletAddress;
|
|
194
|
+
}): Promise<PaginationResult<UserWithdrawal>>;
|
|
195
|
+
getArNSRecord({ name }: {
|
|
196
|
+
name: string;
|
|
197
|
+
}): Promise<ArNSNameData>;
|
|
198
|
+
getArNSRecords(params?: GetArNSRecordsParams): Promise<PaginationResult<ArNSNameDataWithName>>;
|
|
199
|
+
/**
|
|
200
|
+
* Fetch every `ArnsRecord` whose `ant` field equals one of `mints`.
|
|
201
|
+
*
|
|
202
|
+
* Issues one `getProgramAccounts` per mint with a memcmp filter at
|
|
203
|
+
* `ARNS_RECORD_ANT_OFFSET`, in parallel. Cheaper than scanning the
|
|
204
|
+
* whole registry as soon as the caller has fewer mints than the
|
|
205
|
+
* registry has records (today the break-even is ≈ a few hundred
|
|
206
|
+
* mints against ≈ 4k records, and rises as the registry grows).
|
|
207
|
+
*
|
|
208
|
+
* The shape mirrors `getArNSRecord` / `getArNSRecords` — same
|
|
209
|
+
* `ArNSNameDataWithName` items, no pagination wrapper. Callers
|
|
210
|
+
* that want pagination should drive it via `getArNSRecords({
|
|
211
|
+
* filters: { processId: mints } })` instead.
|
|
212
|
+
*/
|
|
213
|
+
getArNSRecordsByAntMints({ mints, }: {
|
|
214
|
+
mints: ReadonlyArray<string>;
|
|
215
|
+
}): Promise<ArNSNameDataWithName[]>;
|
|
216
|
+
private fetchArnsRecordsByAntMints;
|
|
217
|
+
/**
|
|
218
|
+
* Resolve every ArNS record currently controlled by `address`.
|
|
219
|
+
*
|
|
220
|
+
* Mirrors the AO backend: walk the on-chain ANT ACL for the wallet
|
|
221
|
+
* (`Owned ∪ Controlled`), then issue point-queries against the
|
|
222
|
+
* ArNS registry for those mints. This is semantically *not* a query
|
|
223
|
+
* over `ArnsRecord.owner` — that field is a write-once "purchase
|
|
224
|
+
* receipt" and never reflects current control on Solana (see
|
|
225
|
+
* ISSUES.md). Authoritative control flows through the ANT NFT
|
|
226
|
+
* owner / `AntControllers`, which is exactly what the ACL
|
|
227
|
+
* indexes.
|
|
228
|
+
*/
|
|
229
|
+
getArNSRecordsForAddress(params: PaginationParams<ArNSNameDataWithName> & {
|
|
230
|
+
address: WalletAddress;
|
|
231
|
+
antRegistryProcessId?: string;
|
|
232
|
+
}): Promise<PaginationResult<ArNSNameDataWithName>>;
|
|
233
|
+
getArNSReservedNames(params?: PaginationParams<ArNSReservedNameDataWithName>): Promise<PaginationResult<ArNSReservedNameDataWithName>>;
|
|
234
|
+
getArNSReservedName({ name, }: {
|
|
235
|
+
name: string;
|
|
236
|
+
}): Promise<ArNSReservedNameData>;
|
|
237
|
+
getArNSReturnedNames(params?: PaginationParams<ReturnedName>): Promise<PaginationResult<ReturnedName>>;
|
|
238
|
+
getArNSReturnedName({ name, }: {
|
|
239
|
+
name: string;
|
|
240
|
+
}): Promise<ReturnedName>;
|
|
241
|
+
getEpochSettings(): Promise<EpochSettings>;
|
|
242
|
+
/**
|
|
243
|
+
* Resolve an EpochInput to an epoch index number.
|
|
244
|
+
* - undefined: returns current epoch index from EpochSettings
|
|
245
|
+
* - { epochIndex }: returns directly
|
|
246
|
+
* - { timestamp }: computes from genesis timestamp and epoch duration
|
|
247
|
+
*/
|
|
248
|
+
private resolveEpochIndex;
|
|
249
|
+
/** Fetch and deserialize an Epoch account by index */
|
|
250
|
+
private fetchEpoch;
|
|
251
|
+
getEpoch(epoch?: EpochInput): Promise<EpochData>;
|
|
252
|
+
getCurrentEpoch(): Promise<EpochData>;
|
|
253
|
+
getPrescribedObservers(epoch?: EpochInput): Promise<WeightedObserver[]>;
|
|
254
|
+
getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
|
|
255
|
+
getObservations(epoch?: EpochInput): Promise<EpochObservationData>;
|
|
256
|
+
/**
|
|
257
|
+
* Observer pubkeys that have an OPEN Observation PDA for `epochIndex`. Lean —
|
|
258
|
+
* reads only the Observation accounts (no gateway-registry decode like
|
|
259
|
+
* {@link getObservations}). Used by the crank to close observations before
|
|
260
|
+
* `close_epoch`, whose `observations_closed == observations_submitted`
|
|
261
|
+
* precondition would otherwise wedge epoch progression.
|
|
262
|
+
*/
|
|
263
|
+
getEpochObservers(epochIndex: number): Promise<Address[]>;
|
|
264
|
+
getDistributions(epoch?: EpochInput): Promise<EpochDistributionData>;
|
|
265
|
+
getEligibleEpochRewards(epoch?: EpochInput, params?: PaginationParams<EligibleDistribution>): Promise<PaginationResult<EligibleDistribution>>;
|
|
266
|
+
/**
|
|
267
|
+
* Compute the token cost for an ArNS operation.
|
|
268
|
+
*
|
|
269
|
+
* Mirrors the Rust pricing functions in ario-arns/src/pricing.rs.
|
|
270
|
+
* Uses BigInt for u128-equivalent overflow-safe arithmetic.
|
|
271
|
+
*/
|
|
272
|
+
getTokenCost(params: TokenCostParams): Promise<number>;
|
|
273
|
+
getCostDetails(params: GetCostDetailsParams): Promise<CostDetailsResult>;
|
|
274
|
+
/**
|
|
275
|
+
* Project Solana on-chain state into the cross-backend `FundingPlan`
|
|
276
|
+
* shape consumed by UI flows like "how short are you on this purchase,
|
|
277
|
+
* and from which sources?". Always returns the wallet's `balance` and
|
|
278
|
+
* full per-gateway `stakes` breakdown (active delegations + pending
|
|
279
|
+
* delegate-stake withdrawals); `shortfall` is computed against the
|
|
280
|
+
* specific `fundFrom` semantics.
|
|
281
|
+
*
|
|
282
|
+
* Note: the internal `src/solana/funding-plan.ts` `FundingPlan` is a
|
|
283
|
+
* different type — that's the multi-source instruction-building plan
|
|
284
|
+
* used by `buyRecord({ fundFrom: 'any' })`. The two share a concept but
|
|
285
|
+
* not a shape; the public type here is what consumer UIs see.
|
|
286
|
+
*/
|
|
287
|
+
private buildPublicFundingPlan;
|
|
288
|
+
getRegistrationFees(): Promise<RegistrationFees>;
|
|
289
|
+
getDemandFactor(): Promise<number>;
|
|
290
|
+
getDemandFactorSettings(): Promise<DemandFactorSettings>;
|
|
291
|
+
getPrimaryName(params: {
|
|
292
|
+
address: WalletAddress;
|
|
293
|
+
} | {
|
|
294
|
+
name: string;
|
|
295
|
+
}): Promise<PrimaryName>;
|
|
296
|
+
getPrimaryNameRequest(params: {
|
|
297
|
+
initiator: WalletAddress;
|
|
298
|
+
}): Promise<PrimaryNameRequest>;
|
|
299
|
+
getPrimaryNameRequests(params?: PaginationParams<PrimaryNameRequest>): Promise<PaginationResult<PrimaryNameRequest>>;
|
|
300
|
+
getPrimaryNames(params?: PaginationParams<PrimaryName>): Promise<PaginationResult<PrimaryName>>;
|
|
301
|
+
getRedelegationFee(params: {
|
|
302
|
+
address: WalletAddress;
|
|
303
|
+
}): Promise<RedelegationFeeInfo>;
|
|
304
|
+
getGatewayRegistrySettings(): Promise<GatewayRegistrySettings>;
|
|
305
|
+
getAllDelegates(params?: PaginationParams<AllDelegates>): Promise<PaginationResult<AllDelegates>>;
|
|
306
|
+
/**
|
|
307
|
+
* Enumerate every delegation that has pending (unsettled) rewards — the work
|
|
308
|
+
* list for the permissionless `compound_delegation_rewards` crank. Pending is
|
|
309
|
+
* computed from the gateway's reward-per-share accumulator (mirrors
|
|
310
|
+
* {@link computeLiveDelegationBalance}); the crank only changes balances, so
|
|
311
|
+
* rewards already accrue correctly without it.
|
|
312
|
+
*
|
|
313
|
+
* Skips delegations whose gateway is `Leaving` (those settle through
|
|
314
|
+
* `claim_delegate_from_leaving_gateway`, not compounding) and any below
|
|
315
|
+
* `minPendingRewards` — compounding sub-threshold dust just advances
|
|
316
|
+
* `reward_debt` for no balance gain. Feed the result, chunked, to
|
|
317
|
+
* `SolanaARIOWriteable.compoundDelegationRewardsBatch`.
|
|
318
|
+
*/
|
|
319
|
+
getDelegationsToCompound(params?: {
|
|
320
|
+
minPendingRewards?: number;
|
|
321
|
+
}): Promise<Array<{
|
|
322
|
+
gatewayAddress: string;
|
|
323
|
+
delegatorAddress: string;
|
|
324
|
+
pendingRewards: number;
|
|
325
|
+
}>>;
|
|
326
|
+
getAllGatewayVaults(params?: PaginationParams<AllGatewayVaults>): Promise<PaginationResult<AllGatewayVaults>>;
|
|
327
|
+
/**
|
|
328
|
+
* Enumerate ArnsRecord PDAs whose lease has fully expired
|
|
329
|
+
* (`end_timestamp + grace_period + return_auction_duration <= now`).
|
|
330
|
+
* Permabuys (no `end_timestamp`) are excluded. Pass a unix-seconds `now`.
|
|
331
|
+
*/
|
|
332
|
+
getExpiredArnsRecords(now: number): Promise<Array<{
|
|
333
|
+
pubkey: Address;
|
|
334
|
+
name: string;
|
|
335
|
+
endTimestamp: bigint;
|
|
336
|
+
}>>;
|
|
337
|
+
/**
|
|
338
|
+
* Enumerate ReturnedName PDAs whose Dutch auction window has fully
|
|
339
|
+
* elapsed (`returned_at + return_auction_duration <= now`).
|
|
340
|
+
*/
|
|
341
|
+
getExpiredReturnedNames(now: number): Promise<Array<{
|
|
342
|
+
pubkey: Address;
|
|
343
|
+
name: string;
|
|
344
|
+
returnedAt: bigint;
|
|
345
|
+
}>>;
|
|
346
|
+
/**
|
|
347
|
+
* Enumerate ReservedName PDAs whose `expires_at` has passed.
|
|
348
|
+
* Permanent reservations (`expires_at: None`) are excluded.
|
|
349
|
+
*/
|
|
350
|
+
getExpiredReservations(now: number): Promise<Array<{
|
|
351
|
+
pubkey: Address;
|
|
352
|
+
name: string;
|
|
353
|
+
}>>;
|
|
354
|
+
/**
|
|
355
|
+
* Enumerate Gateway PDAs in `Joined` status with
|
|
356
|
+
* `stats.failed_consecutive >= maxFailures`. These are eligible for
|
|
357
|
+
* `pruneGateway` (slash + remove from registry).
|
|
358
|
+
*/
|
|
359
|
+
getDeficientGateways(maxFailures: number): Promise<Array<{
|
|
360
|
+
pubkey: Address;
|
|
361
|
+
operator: Address;
|
|
362
|
+
failedConsecutive: number;
|
|
363
|
+
}>>;
|
|
364
|
+
/**
|
|
365
|
+
* Enumerate Gateway PDAs that are candidates for `finalizeGone` GC — i.e.
|
|
366
|
+
* those whose `status == Leaving`.
|
|
367
|
+
*
|
|
368
|
+
* NOTE: despite the historical name, this returns `Leaving` (not `Gone`)
|
|
369
|
+
* gateways. `Gone` is NOT a persistent discovery state: the on-chain
|
|
370
|
+
* `finalize_gone` instruction accepts a `Leaving` gateway, flips it to
|
|
371
|
+
* `Gone`, and closes the Gateway PDA in the *same* instruction
|
|
372
|
+
* (programs/ario-gar/src/instructions/gateway.rs::finalize_gone), so a
|
|
373
|
+
* gateway is never observably parked at `Gone`. Filtering on `Gone` matched
|
|
374
|
+
* nothing and left Leaving gateways un-GC'd. Time/delegation eligibility is
|
|
375
|
+
* still enforced on-chain (`finalize_gone` reverts early if the leave window
|
|
376
|
+
* hasn't elapsed or delegations remain), so over-returning not-yet-eligible
|
|
377
|
+
* Leaving gateways is safe — the tx just no-ops/reverts.
|
|
378
|
+
*
|
|
379
|
+
* @deprecated Prefer {@link getLeavingGateways} — same result, accurate name.
|
|
380
|
+
*/
|
|
381
|
+
getGoneGateways(): Promise<Array<{
|
|
382
|
+
pubkey: Address;
|
|
383
|
+
operator: Address;
|
|
384
|
+
}>>;
|
|
385
|
+
/**
|
|
386
|
+
* Enumerate Gateway PDAs whose `status == Leaving` — the persistent
|
|
387
|
+
* pre-finalization state that `finalizeGone` GC's. Alias for
|
|
388
|
+
* {@link getGoneGateways} with a name that matches the on-chain state.
|
|
389
|
+
*/
|
|
390
|
+
getLeavingGateways(): Promise<Array<{
|
|
391
|
+
pubkey: Address;
|
|
392
|
+
operator: Address;
|
|
393
|
+
}>>;
|
|
394
|
+
/**
|
|
395
|
+
* Enumerate Joined Gateway PDAs whose delegation has been DISABLED
|
|
396
|
+
* (`allow_delegated_staking == false`) yet still hold delegated stake
|
|
397
|
+
* (`total_delegated_stake > 0`) — i.e. delegates that an operator's disable
|
|
398
|
+
* left stranded (WP §6.3 / Fix #6). Each such gateway's delegates must be
|
|
399
|
+
* cranked out via
|
|
400
|
+
* {@link SolanaARIOWriteable.claimDelegateFromDisabledGateway} (enumerate
|
|
401
|
+
* them with {@link getGatewayDelegates}) before the operator can re-enable
|
|
402
|
+
* delegation. This is the discovery primitive a cranker uses to sweep them.
|
|
403
|
+
*/
|
|
404
|
+
getDisabledGatewaysWithDelegatedStake(): Promise<Array<{
|
|
405
|
+
pubkey: Address;
|
|
406
|
+
operator: Address;
|
|
407
|
+
totalDelegatedStake: bigint;
|
|
408
|
+
}>>;
|
|
409
|
+
/**
|
|
410
|
+
* Enumerate Delegation PDAs with `amount == 0`. Eligible for
|
|
411
|
+
* `closeEmptyDelegation` (rent refund to the original delegator).
|
|
412
|
+
*/
|
|
413
|
+
getEmptyDelegations(): Promise<Array<{
|
|
414
|
+
pubkey: Address;
|
|
415
|
+
gateway: Address;
|
|
416
|
+
delegator: Address;
|
|
417
|
+
}>>;
|
|
418
|
+
/**
|
|
419
|
+
* Enumerate Withdrawal PDAs with `amount == 0` (drained via
|
|
420
|
+
* fund-from-withdrawal payments). Eligible for `closeDrainedWithdrawal`
|
|
421
|
+
* (rent refund to owner).
|
|
422
|
+
*/
|
|
423
|
+
getDrainedWithdrawals(): Promise<Array<{
|
|
424
|
+
pubkey: Address;
|
|
425
|
+
owner: Address;
|
|
426
|
+
withdrawalId: bigint;
|
|
427
|
+
}>>;
|
|
428
|
+
/**
|
|
429
|
+
* Enumerate Vault PDAs whose `end_timestamp` has passed (eligible for
|
|
430
|
+
* `releaseVault`). Note: `releaseVault` is owner-signed, so the cranker
|
|
431
|
+
* can only release its own vaults — the helper still surfaces every
|
|
432
|
+
* expired vault so other consumers (UIs, indexers) can use it too.
|
|
433
|
+
*/
|
|
434
|
+
getExpiredVaults(now: number): Promise<Array<{
|
|
435
|
+
pubkey: Address;
|
|
436
|
+
owner: Address;
|
|
437
|
+
vaultId: bigint;
|
|
438
|
+
endTimestamp: bigint;
|
|
439
|
+
}>>;
|
|
440
|
+
/**
|
|
441
|
+
* Enumerate PrimaryNameRequest PDAs whose `expires_at` has passed.
|
|
442
|
+
* Eligible for `closeExpiredRequest` (rent refund to original initiator).
|
|
443
|
+
*/
|
|
444
|
+
getExpiredPrimaryNameRequests(now: number): Promise<Array<{
|
|
445
|
+
pubkey: Address;
|
|
446
|
+
initiator: Address;
|
|
447
|
+
}>>;
|
|
448
|
+
/**
|
|
449
|
+
* Read the live `ArnsConfig` (used by the cranker to gate
|
|
450
|
+
* `pruneExpiredNames` / `pruneReturnedNames` on the
|
|
451
|
+
* `next_*_prune_timestamp` hints).
|
|
452
|
+
*/
|
|
453
|
+
getArnsConfigRaw(): Promise<{
|
|
454
|
+
nextRecordsPruneTimestamp: bigint;
|
|
455
|
+
nextReturnedNamesPruneTimestamp: bigint;
|
|
456
|
+
gracePeriodSeconds: bigint;
|
|
457
|
+
returnAuctionDurationSeconds: bigint;
|
|
458
|
+
} | null>;
|
|
459
|
+
resolveArNSName({ name }: {
|
|
460
|
+
name: string;
|
|
461
|
+
}): Promise<{
|
|
462
|
+
name: string;
|
|
463
|
+
txId: string;
|
|
464
|
+
type: "lease" | "permabuy";
|
|
465
|
+
processId: string;
|
|
466
|
+
ttlSeconds: number;
|
|
467
|
+
undernameLimit: number;
|
|
468
|
+
}>;
|
|
469
|
+
/**
|
|
470
|
+
* Resolve the gateway operator pubkey backing a given observer pubkey.
|
|
471
|
+
* The `ObserverLookup` PDA is written at `join_network` (and rotated by
|
|
472
|
+
* `update_observer_address`); when present its `gateway` field is the
|
|
473
|
+
* operator pubkey. Returns `undefined` when the observer isn't
|
|
474
|
+
* registered on any gateway.
|
|
475
|
+
*/
|
|
476
|
+
getObserverLookup(observer: Address): Promise<{
|
|
477
|
+
gateway: Address;
|
|
478
|
+
bump: number;
|
|
479
|
+
} | undefined>;
|
|
480
|
+
/**
|
|
481
|
+
* Pre-flight gate for `save_observations` submission. Reads the Epoch
|
|
482
|
+
* account once and reports whether the given observer pubkey is:
|
|
483
|
+
* - `prescribed`: in `epoch.prescribed_observers[..observer_count]`
|
|
484
|
+
* - `observerIdx`: position in the array (matches the `has_observed`
|
|
485
|
+
* bit index when prescribed)
|
|
486
|
+
* - `alreadyObserved`: whether the bit at `observerIdx` is set
|
|
487
|
+
* - `windowOpen`: whether `now < epoch.end_timestamp`
|
|
488
|
+
*
|
|
489
|
+
* Use this from a sink/wrapper to skip cheap-to-skip cases before
|
|
490
|
+
* paying for a transaction simulation that would just bounce.
|
|
491
|
+
*/
|
|
492
|
+
getEpochObservationStatus(epochIndex: number, observer: Address): Promise<{
|
|
493
|
+
prescribed: boolean;
|
|
494
|
+
observerIdx: number;
|
|
495
|
+
alreadyObserved: boolean;
|
|
496
|
+
windowOpen: boolean;
|
|
497
|
+
endTimestampSec: number;
|
|
498
|
+
}>;
|
|
499
|
+
}
|