@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.
Files changed (169) hide show
  1. package/README.md +757 -589
  2. package/lib/esm/cli/cli.js +188 -152
  3. package/lib/esm/cli/commands/antCommands.js +23 -58
  4. package/lib/esm/cli/commands/arnsPurchaseCommands.js +48 -30
  5. package/lib/esm/cli/commands/escrowCommands.js +227 -0
  6. package/lib/esm/cli/commands/gatewayWriteCommands.js +140 -23
  7. package/lib/esm/cli/commands/pruneCommands.js +154 -0
  8. package/lib/esm/cli/commands/readCommands.js +22 -3
  9. package/lib/esm/cli/commands/transfer.js +6 -6
  10. package/lib/esm/cli/options.js +124 -58
  11. package/lib/esm/cli/utils.js +303 -175
  12. package/lib/esm/common/ant-registry.js +17 -143
  13. package/lib/esm/common/ant.js +44 -1167
  14. package/lib/esm/common/faucet.js +17 -6
  15. package/lib/esm/common/index.js +0 -4
  16. package/lib/esm/common/io.js +25 -1412
  17. package/lib/esm/constants.js +13 -19
  18. package/lib/esm/solana/ant-readable.js +724 -0
  19. package/lib/esm/solana/ant-registry-readable.js +133 -0
  20. package/lib/esm/solana/ant-registry-writeable.js +472 -0
  21. package/lib/esm/solana/ant-writeable.js +384 -0
  22. package/lib/esm/solana/ata.js +70 -0
  23. package/lib/esm/solana/canonical-message.js +128 -0
  24. package/lib/esm/solana/clusters.js +111 -0
  25. package/lib/esm/solana/constants.js +146 -0
  26. package/lib/esm/solana/delegation-math.js +112 -0
  27. package/lib/esm/solana/deserialize.js +711 -0
  28. package/lib/esm/solana/escrow.js +839 -0
  29. package/lib/{cjs/utils/json.js → esm/solana/events.js} +15 -10
  30. package/lib/esm/solana/funding-plan.js +699 -0
  31. package/lib/esm/solana/index.js +126 -0
  32. package/lib/esm/solana/instruction.js +39 -0
  33. package/lib/esm/solana/io-readable.js +2182 -0
  34. package/lib/esm/solana/io-writeable.js +3196 -0
  35. package/lib/esm/solana/json-rpc.js +90 -0
  36. package/lib/esm/solana/metadata.js +81 -0
  37. package/lib/esm/solana/mpl-core.js +192 -0
  38. package/lib/esm/solana/pda.js +332 -0
  39. package/lib/esm/solana/predict-prescribed-observers.js +110 -0
  40. package/lib/esm/solana/retry.js +117 -0
  41. package/lib/esm/solana/rpc-circuit-breaker.js +258 -0
  42. package/lib/esm/solana/send.js +372 -0
  43. package/lib/esm/solana/spawn-ant.js +224 -0
  44. package/lib/esm/solana/types.js +1 -0
  45. package/lib/esm/types/ant.js +27 -15
  46. package/lib/esm/types/io.js +8 -11
  47. package/lib/esm/utils/ant.js +0 -63
  48. package/lib/esm/utils/index.js +0 -3
  49. package/lib/esm/version.js +1 -1
  50. package/lib/types/cli/commands/antCommands.d.ts +5 -13
  51. package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +33 -7
  52. package/lib/types/cli/commands/escrowCommands.d.ts +68 -0
  53. package/lib/types/cli/commands/gatewayWriteCommands.d.ts +12 -11
  54. package/lib/types/cli/commands/pruneCommands.d.ts +31 -0
  55. package/lib/types/cli/commands/readCommands.d.ts +27 -22
  56. package/lib/types/cli/commands/transfer.d.ts +9 -9
  57. package/lib/types/cli/options.d.ts +76 -21
  58. package/lib/types/cli/types.d.ts +11 -13
  59. package/lib/types/cli/utils.d.ts +71 -31
  60. package/lib/types/common/ant-registry.d.ts +49 -47
  61. package/lib/types/common/ant.d.ts +54 -539
  62. package/lib/types/common/faucet.d.ts +20 -8
  63. package/lib/types/common/index.d.ts +0 -3
  64. package/lib/types/common/io.d.ts +66 -258
  65. package/lib/types/constants.d.ts +11 -18
  66. package/lib/types/solana/ant-readable.d.ts +180 -0
  67. package/lib/types/solana/ant-registry-readable.d.ts +105 -0
  68. package/lib/types/solana/ant-registry-writeable.d.ts +249 -0
  69. package/lib/types/solana/ant-writeable.d.ts +177 -0
  70. package/lib/types/solana/ata.d.ts +44 -0
  71. package/lib/types/solana/canonical-message.d.ts +121 -0
  72. package/lib/types/solana/clusters.d.ts +109 -0
  73. package/lib/types/solana/constants.d.ts +119 -0
  74. package/lib/types/solana/delegation-math.d.ts +45 -0
  75. package/lib/types/solana/deserialize.d.ts +262 -0
  76. package/lib/types/solana/escrow.d.ts +480 -0
  77. package/lib/types/solana/events.d.ts +38 -0
  78. package/lib/types/solana/funding-plan.d.ts +225 -0
  79. package/lib/types/solana/index.d.ts +87 -0
  80. package/lib/types/solana/instruction.d.ts +39 -0
  81. package/lib/types/solana/io-readable.d.ts +499 -0
  82. package/lib/types/solana/io-writeable.d.ts +893 -0
  83. package/lib/types/solana/json-rpc.d.ts +47 -0
  84. package/lib/types/solana/metadata.d.ts +84 -0
  85. package/lib/types/solana/mpl-core.d.ts +120 -0
  86. package/lib/types/solana/pda.d.ts +95 -0
  87. package/lib/types/solana/predict-prescribed-observers.d.ts +28 -0
  88. package/lib/types/solana/retry.d.ts +62 -0
  89. package/lib/types/solana/rpc-circuit-breaker.d.ts +78 -0
  90. package/lib/types/solana/send.d.ts +94 -0
  91. package/lib/types/solana/spawn-ant.d.ts +145 -0
  92. package/lib/types/solana/types.d.ts +82 -0
  93. package/lib/types/types/ant-registry.d.ts +43 -4
  94. package/lib/types/types/ant.d.ts +114 -96
  95. package/lib/types/types/common.d.ts +18 -74
  96. package/lib/types/types/faucet.d.ts +2 -2
  97. package/lib/types/types/io.d.ts +244 -158
  98. package/lib/types/types/token.d.ts +0 -12
  99. package/lib/types/utils/ant.d.ts +1 -12
  100. package/lib/types/utils/index.d.ts +0 -3
  101. package/lib/types/version.d.ts +1 -1
  102. package/package.json +36 -33
  103. package/lib/cjs/cli/cli.js +0 -822
  104. package/lib/cjs/cli/commands/antCommands.js +0 -113
  105. package/lib/cjs/cli/commands/arnsPurchaseCommands.js +0 -212
  106. package/lib/cjs/cli/commands/gatewayWriteCommands.js +0 -210
  107. package/lib/cjs/cli/commands/readCommands.js +0 -215
  108. package/lib/cjs/cli/commands/transfer.js +0 -159
  109. package/lib/cjs/cli/options.js +0 -470
  110. package/lib/cjs/cli/types.js +0 -2
  111. package/lib/cjs/cli/utils.js +0 -639
  112. package/lib/cjs/common/ant-registry.js +0 -155
  113. package/lib/cjs/common/ant-versions.js +0 -93
  114. package/lib/cjs/common/ant.js +0 -1182
  115. package/lib/cjs/common/arweave.js +0 -27
  116. package/lib/cjs/common/contracts/ao-process.js +0 -224
  117. package/lib/cjs/common/error.js +0 -64
  118. package/lib/cjs/common/faucet.js +0 -150
  119. package/lib/cjs/common/hyperbeam/hb.js +0 -173
  120. package/lib/cjs/common/index.js +0 -42
  121. package/lib/cjs/common/io.js +0 -1423
  122. package/lib/cjs/common/logger.js +0 -83
  123. package/lib/cjs/common/loggers/winston.js +0 -68
  124. package/lib/cjs/common/marketplace.js +0 -731
  125. package/lib/cjs/common/turbo.js +0 -223
  126. package/lib/cjs/constants.js +0 -41
  127. package/lib/cjs/node/index.js +0 -39
  128. package/lib/cjs/package.json +0 -1
  129. package/lib/cjs/types/ant-registry.js +0 -2
  130. package/lib/cjs/types/ant.js +0 -168
  131. package/lib/cjs/types/common.js +0 -2
  132. package/lib/cjs/types/faucet.js +0 -2
  133. package/lib/cjs/types/index.js +0 -37
  134. package/lib/cjs/types/io.js +0 -51
  135. package/lib/cjs/types/token.js +0 -116
  136. package/lib/cjs/utils/ant.js +0 -108
  137. package/lib/cjs/utils/ao.js +0 -432
  138. package/lib/cjs/utils/arweave.js +0 -285
  139. package/lib/cjs/utils/base64.js +0 -62
  140. package/lib/cjs/utils/hash.js +0 -56
  141. package/lib/cjs/utils/index.js +0 -38
  142. package/lib/cjs/utils/processes.js +0 -173
  143. package/lib/cjs/utils/random.js +0 -30
  144. package/lib/cjs/utils/schema.js +0 -15
  145. package/lib/cjs/utils/url.js +0 -37
  146. package/lib/cjs/version.js +0 -20
  147. package/lib/cjs/web/index.js +0 -41
  148. package/lib/esm/common/ant-versions.js +0 -87
  149. package/lib/esm/common/arweave.js +0 -21
  150. package/lib/esm/common/contracts/ao-process.js +0 -220
  151. package/lib/esm/common/hyperbeam/hb.js +0 -169
  152. package/lib/esm/common/marketplace.js +0 -724
  153. package/lib/esm/common/turbo.js +0 -215
  154. package/lib/esm/node/index.js +0 -20
  155. package/lib/esm/utils/ao.js +0 -420
  156. package/lib/esm/utils/arweave.js +0 -271
  157. package/lib/esm/utils/processes.js +0 -167
  158. package/lib/esm/web/index.js +0 -20
  159. package/lib/types/common/ant-versions.d.ts +0 -39
  160. package/lib/types/common/arweave.d.ts +0 -17
  161. package/lib/types/common/contracts/ao-process.d.ts +0 -47
  162. package/lib/types/common/hyperbeam/hb.d.ts +0 -88
  163. package/lib/types/common/marketplace.d.ts +0 -568
  164. package/lib/types/common/turbo.d.ts +0 -61
  165. package/lib/types/node/index.d.ts +0 -20
  166. package/lib/types/utils/ao.d.ts +0 -80
  167. package/lib/types/utils/arweave.d.ts +0 -79
  168. package/lib/types/utils/processes.d.ts +0 -39
  169. package/lib/types/web/index.d.ts +0 -20
@@ -1,266 +1,74 @@
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';
3
- import { AOProcess } from './contracts/ao-process.js';
4
- import { HB } from './hyperbeam/hb.js';
5
- import { Logger } from './logger.js';
6
- import { TurboArNSPaymentProviderAuthenticated, TurboArNSPaymentProviderUnauthenticated } from './turbo.js';
7
- type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration & {
8
- hyperbeamUrl?: string;
9
- }>>;
10
- type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration & {
11
- hyperbeamUrl?: string;
12
- }>>>;
13
- export declare class ARIO {
14
- static init(): AoARIORead;
15
- static init(config: ARIOConfigWithSigner): AoARIOWrite;
16
- static init(config: ARIOConfigNoSigner): AoARIORead;
17
- static mainnet(): AoARIORead;
18
- static mainnet(config: ARIOConfigNoSigner): AoARIORead;
19
- static mainnet(config: ARIOConfigWithSigner): AoARIOWrite;
20
- static testnet(): ARIOWithFaucet<AoARIORead>;
21
- static testnet(config: ARIOConfigNoSigner & {
22
- faucetUrl?: string;
23
- }): ARIOWithFaucet<AoARIORead>;
24
- static testnet(config: ARIOConfigWithSigner & {
25
- faucetUrl?: string;
26
- }): ARIOWithFaucet<AoARIOWrite>;
27
- }
28
- export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
29
- readonly process: AOProcess;
30
- protected epochSettings: AoEpochSettings | undefined;
31
- protected arweave: Arweave;
32
- protected hyperbeamUrl: string | undefined;
33
- protected paymentProvider: TurboArNSPaymentProviderUnauthenticated;
34
- protected logger: Logger;
35
- protected hb: HB | undefined;
36
- constructor(config?: ARIOConfigNoSigner);
37
- getInfo(): Promise<{
38
- Name: string;
39
- Ticker: string;
40
- Logo: string;
41
- Denomination: number;
42
- Handlers: string[];
43
- LastCreatedEpochIndex: number;
44
- LastDistributedEpochIndex: number;
45
- }>;
46
- getTokenSupply(): Promise<AoTokenSupplyData>;
47
- private computeEpochIndexForTimestamp;
48
- private computeCurrentEpochIndex;
49
- private computeEpochIndex;
50
- getEpochSettings(): Promise<AoEpochSettings>;
51
- getEpoch(): Promise<AoEpochData<AoEpochDistributionTotalsData>>;
52
- getEpoch(epoch: EpochInput): Promise<AoEpochData<AoEpochDistributed>>;
53
- getArNSRecord({ name }: {
54
- name: string;
55
- }): Promise<AoArNSNameData>;
56
- getArNSRecords(params?: PaginationParams<AoArNSNameDataWithName>): Promise<PaginationResult<AoArNSNameDataWithName>>;
57
- getArNSReservedNames(params?: PaginationParams<AoArNSReservedNameDataWithName>): Promise<PaginationResult<AoArNSReservedNameDataWithName>>;
58
- getArNSReservedName({ name, }: {
59
- name: string;
60
- }): Promise<AoArNSReservedNameData>;
61
- getBalance({ address }: {
62
- address: WalletAddress;
63
- }): Promise<number>;
64
- getBalances(params?: PaginationParams<AoBalanceWithAddress>): Promise<PaginationResult<AoBalanceWithAddress>>;
65
- getVault({ address, vaultId, }: {
66
- address: WalletAddress;
67
- vaultId: string;
68
- }): Promise<AoVaultData>;
69
- getVaults(params?: PaginationParams<AoWalletVault>): Promise<PaginationResult<AoWalletVault>>;
70
- getGateway({ address, }: {
71
- address: WalletAddress;
72
- }): Promise<AoGateway>;
73
- getGatewayDelegates({ address, ...pageParams }: {
74
- [x: string]: any;
75
- address: any;
76
- }): Promise<PaginationResult<AoGatewayDelegateWithAddress>>;
77
- getGatewayDelegateAllowList({ address, ...pageParams }: AoPaginatedAddressParams): Promise<PaginationResult<WalletAddress>>;
78
- getGateways(pageParams?: PaginationParams<AoGatewayWithAddress>): Promise<PaginationResult<AoGatewayWithAddress>>;
79
- getCurrentEpoch(): Promise<AoEpochData<AoEpochDistributionTotalsData>>;
80
- getPrescribedObservers(epoch?: EpochInput): Promise<AoWeightedObserver[]>;
81
- getPrescribedNames(epoch?: EpochInput): Promise<string[]>;
82
- getObservations(epoch?: EpochInput): Promise<AoEpochObservationData>;
83
- getDistributions(epoch?: EpochInput): Promise<AoEpochDistributionData>;
84
- getEligibleEpochRewards(epoch?: EpochInput, params?: PaginationParams<AoEligibleDistribution>): Promise<PaginationResult<AoEligibleDistribution>>;
85
- getTokenCost(params: {
86
- intent: 'Buy-Record' | 'Buy-Name';
87
- type: 'permabuy' | 'lease';
88
- years: number;
89
- name: string;
90
- }): Promise<number>;
91
- getTokenCost(params: {
92
- intent: 'Extend-Lease';
93
- years: number;
94
- name: string;
95
- }): Promise<number>;
96
- getTokenCost(params: {
97
- intent: 'Increase-Undername-Limit';
98
- quantity: number;
99
- name: string;
100
- }): Promise<number>;
101
- getTokenCost(params: {
102
- intent: 'Upgrade-Name';
103
- name: string;
104
- }): Promise<number>;
105
- getTokenCost(params: {
106
- intent: 'Primary-Name-Request';
107
- name: string;
108
- }): Promise<number>;
109
- getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }: AoGetCostDetailsParams): Promise<CostDetailsResult>;
110
- getRegistrationFees(): Promise<AoRegistrationFees>;
111
- getDemandFactor(): Promise<number>;
112
- getDemandFactorSettings(): Promise<DemandFactorSettings>;
113
- getArNSReturnedNames(params?: PaginationParams<AoReturnedName>): Promise<PaginationResult<AoReturnedName>>;
114
- getArNSReturnedName({ name, }: {
115
- name: string;
116
- }): Promise<AoReturnedName>;
117
- getDelegations(params: PaginationParams<AoDelegation> & {
118
- address: WalletAddress;
119
- }): Promise<PaginationResult<AoDelegation>>;
120
- getAllowedDelegates(params: AoPaginatedAddressParams): Promise<PaginationResult<WalletAddress>>;
121
- getGatewayVaults(params: PaginationParams<AoGatewayVault> & {
122
- address: WalletAddress;
123
- }): Promise<PaginationResult<AoGatewayVault>>;
124
- getPrimaryNameRequest(params: {
125
- initiator: WalletAddress;
126
- }): Promise<AoPrimaryNameRequest>;
127
- getPrimaryNameRequests(params?: PaginationParams<AoPrimaryNameRequest>): Promise<PaginationResult<AoPrimaryNameRequest>>;
128
- getPrimaryName(params: {
129
- address: WalletAddress;
130
- } | {
131
- name: string;
132
- }): Promise<AoPrimaryName>;
133
- getPrimaryNames(params: PaginationParams<AoPrimaryName>): Promise<PaginationResult<AoPrimaryName>>;
134
- /**
135
- * Get current redelegation fee percentage for address
136
- *
137
- * @param {Object} params - The parameters for fetching redelegation fee
138
- * @param {string} params.address - The address to fetch the fee for
139
- * @returns {Promise<AoMessageResult>} The redelegation fee result
140
- */
141
- getRedelegationFee(params: {
142
- address: WalletAddress;
143
- }): Promise<AoRedelegationFeeInfo>;
144
- getGatewayRegistrySettings(): Promise<AoGatewayRegistrySettings>;
145
- getAllDelegates(params?: PaginationParams<AoAllDelegates>): Promise<PaginationResult<AoAllDelegates>>;
146
- getAllGatewayVaults(params?: PaginationParams<AoAllGatewayVaults>): Promise<PaginationResult<AoAllGatewayVaults>>;
147
- resolveArNSName({ name, }: {
148
- name: string;
149
- }): Promise<ArNSNameResolutionData>;
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
+ import type { Address, Commitment } from '@solana/kit';
17
+ import type { SolanaRpc, SolanaRpcSubscriptions, SolanaSigner } from '../solana/types.js';
18
+ import type { ARIORead, ARIOWrite } from '../types/index.js';
19
+ /**
20
+ * Configuration for ARIO.init().
21
+ *
22
+ * Program ID overrides (`coreProgramId`, `garProgramId`, `arnsProgramId`,
23
+ * `antProgramId`) are required against any cluster other than mainnet —
24
+ * devnet, localnet, and the Surfpool harness all deploy programs at addresses
25
+ * derived from per-cluster keypair files, not the placeholder constants in
26
+ * `src/solana/constants.ts`. On localnet, source these from
27
+ * `migration/localnet/out/localnet.env`.
28
+ */
29
+ export type ARIOConfig = {
30
+ rpc: SolanaRpc;
31
+ /** Required for write operations (needed by kit's sendAndConfirm). */
32
+ rpcSubscriptions?: SolanaRpcSubscriptions;
33
+ commitment?: Commitment;
34
+ signer?: SolanaSigner;
35
+ coreProgramId?: Address;
36
+ garProgramId?: Address;
37
+ arnsProgramId?: Address;
150
38
  /**
151
- * Get all ARNS names associated with an address using the provided ANT registry address.
152
- *
153
- * By default it will use the mainnet ANT registry address.
154
- *
155
- * @param {Object} params - The parameters for fetching ARNS names
156
- * @param {string} params.address - The address to fetch the ARNS names for
157
- * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
39
+ * Override the deployed `ario-ant` program id. Required for the
40
+ * ACL-driven `getArNSRecordsForAddress` pipeline on any cluster
41
+ * other than mainnet (devnet, localnet, Surfpool).
158
42
  */
159
- getArNSRecordsForAddress(params: PaginationParams<AoArNSNameDataWithName> & {
160
- antRegistryProcessId?: string;
161
- address: WalletAddress;
162
- }): Promise<PaginationResult<AoArNSNameDataWithName>>;
163
- }
164
- export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
165
- private signer;
166
- protected paymentProvider: TurboArNSPaymentProviderAuthenticated | TurboArNSPaymentProviderUnauthenticated;
167
- constructor({ signer, paymentUrl, ...config }: ARIOConfigWithSigner);
168
- transfer({ target, qty, }: {
169
- target: string;
170
- qty: number | mARIOToken;
171
- }, options?: WriteOptions): Promise<AoMessageResult>;
172
- vaultedTransfer({ recipient, quantity, lockLengthMs, revokable, }: AoVaultedTransferParams, options?: WriteOptions): Promise<AoMessageResult>;
173
- revokeVault({ vaultId, recipient }: AoRevokeVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
174
- createVault({ lockLengthMs, quantity }: AoCreateVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
175
- extendVault({ vaultId, extendLengthMs }: AoExtendVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
176
- increaseVault({ vaultId, quantity }: AoIncreaseVaultParams, options?: WriteOptions): Promise<AoMessageResult>;
177
- joinNetwork({ operatorStake, allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }: AoJoinNetworkParams, options?: WriteOptions): Promise<AoMessageResult>;
178
- leaveNetwork(options?: WriteOptions): Promise<AoMessageResult>;
179
- updateGatewaySettings({ allowDelegatedStaking, allowedDelegates, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, port, properties, protocol, autoStake, observerAddress, services, }: AoUpdateGatewaySettingsParams, options?: WriteOptions): Promise<AoMessageResult>;
180
- delegateStake(params: {
181
- target: string;
182
- stakeQty: number | mARIOToken;
183
- }, options?: WriteOptions): Promise<AoMessageResult>;
184
- decreaseDelegateStake(params: {
185
- target: string;
186
- decreaseQty: number | mARIOToken;
187
- instant?: boolean;
188
- }, options?: WriteOptions): Promise<AoMessageResult>;
189
- /**
190
- * Initiates an instant withdrawal from a gateway.
191
- *
192
- * @param {Object} params - The parameters for initiating an instant withdrawal
193
- * @param {string} params.address - The gateway address of the withdrawal, if not provided, the signer's address will be used
194
- * @param {string} params.vaultId - The vault ID of the withdrawal
195
- * @returns {Promise<AoMessageResult>} The result of the withdrawal
196
- */
197
- instantWithdrawal(params: {
198
- gatewayAddress?: string;
199
- vaultId: string;
200
- }, options?: WriteOptions): Promise<AoMessageResult>;
201
- increaseOperatorStake(params: {
202
- increaseQty: number | mARIOToken;
203
- }, options?: WriteOptions): Promise<AoMessageResult>;
204
- decreaseOperatorStake(params: {
205
- decreaseQty: number | mARIOToken;
206
- instant?: boolean;
207
- }, options?: WriteOptions): Promise<AoMessageResult>;
208
- saveObservations(params: {
209
- reportTxId: TransactionId;
210
- failedGateways: WalletAddress[];
211
- }, options?: WriteOptions): Promise<AoMessageResult>;
212
- buyRecord(params: AoBuyRecordParams, options?: WriteOptions<keyof BuyArNSNameProgressEvents, BuyArNSNameProgressEvents[keyof BuyArNSNameProgressEvents]>): Promise<AoMessageResult>;
43
+ antProgramId?: Address;
44
+ };
45
+ export declare const DEFAULT_SOLANA_RPC_URL = "https://api.mainnet-beta.solana.com";
46
+ export declare class ARIO {
213
47
  /**
214
- * Upgrades an existing leased record to a permabuy.
48
+ * Create an ARIO client bound to a Solana RPC transport.
215
49
  *
216
- * @param {Object} params - The parameters for upgrading a record
217
- * @param {string} params.name - The name of the record to upgrade
218
- * @param {Object} [options] - The options for the upgrade
219
- * @returns {Promise<AoMessageResult>} The result of the upgrade
220
- */
221
- upgradeRecord(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult>;
222
- /**
223
- * Extends the lease of an existing leased record.
50
+ * The return type is selected by the {@link ARIOConfig} you pass:
51
+ * - **Read-write** when `signer` (a {@link SolanaSigner}) is provided. A
52
+ * {@link SolanaRpcSubscriptions} client is then also required so
53
+ * `@solana/kit`'s `sendAndConfirmTransaction` can await confirmations;
54
+ * omitting it throws. Returns {@link ARIOWrite}.
55
+ * - **Read-only** when `signer` is omitted. Returns {@link ARIORead}.
224
56
  *
225
- * @param {Object} params - The parameters for extending a lease
226
- * @param {string} params.name - The name of the record to extend
227
- * @param {number} params.years - The number of years to extend the lease
228
- * @param {Object} [options] - The options for the extension
229
- * @returns {Promise<AoMessageResult>} The result of the extension
230
- */
231
- extendLease(params: AoExtendLeaseParams, options?: WriteOptions): Promise<AoMessageResult>;
232
- increaseUndernameLimit(params: AoIncreaseUndernameLimitParams, options?: WriteOptions): Promise<AoMessageResult>;
233
- /**
234
- * Cancel a withdrawal from a gateway.
235
- *
236
- * @param {Object} params - The parameters for cancelling a withdrawal
237
- * @param {string} [params.address] - The address of the withdrawal (optional). If not provided, the signer's address will be used.
238
- * @param {string} params.vaultId - The vault ID of the withdrawal.
239
- * @param {Object} [options] - The options for the cancellation
240
- * @returns {Promise<AoMessageResult>} The result of the cancellation
241
- */
242
- cancelWithdrawal(params: {
243
- gatewayAddress?: WalletAddress;
244
- vaultId: string;
245
- }, options?: WriteOptions | undefined): Promise<AoMessageResult>;
246
- requestPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions): Promise<AoMessageResult<AoCreatePrimaryNameRequest>>;
247
- setPrimaryName(params: AoArNSPurchaseParams, options?: WriteOptions<keyof SetPrimaryNameProgressEvents, SetPrimaryNameProgressEvents[keyof SetPrimaryNameProgressEvents]>): Promise<AoMessageResult>;
248
- /**
249
- * Redelegate stake from one gateway to another gateway.
57
+ * Program-id overrides (`coreProgramId` / `garProgramId` / `arnsProgramId` /
58
+ * `antProgramId`) are required on any non-mainnet cluster (devnet, localnet,
59
+ * Surfpool); see {@link ARIOConfig}.
250
60
  *
251
- * @param {Object} params - The parameters for redelegating stake
252
- * @param {string} params.target - The target gateway address
253
- * @param {string} params.source - The source gateway address
254
- * @param {number} params.stakeQty - The quantity of stake to redelegate
255
- * @param {string} params.vaultId - An optional vault ID to redelegate from
256
- * @param {Object} [options] - The options for the redelegation
257
- * @returns {Promise<AoMessageResult>} The result of the redelegation
61
+ * @param config - RPC transport, optional signer/subscriptions, and
62
+ * per-cluster program-id overrides.
63
+ * @returns {@link ARIOWrite} when a signer is supplied, otherwise
64
+ * {@link ARIORead}.
65
+ * @throws If a signer is supplied without `rpcSubscriptions`.
258
66
  */
259
- redelegateStake(params: {
260
- target: string;
261
- source: string;
262
- stakeQty: number | mARIOToken;
263
- vaultId?: string;
264
- }, options?: WriteOptions): Promise<AoMessageResult>;
67
+ static init(config: ARIOConfig & {
68
+ signer: SolanaSigner;
69
+ rpcSubscriptions: SolanaRpcSubscriptions;
70
+ }): ARIOWrite;
71
+ static init(config: ARIOConfig & {
72
+ signer?: never;
73
+ }): ARIORead;
265
74
  }
266
- export {};
@@ -14,24 +14,17 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  export declare const ARWEAVE_TX_REGEX: RegExp;
17
+ /** ar:// protocol prefix for location-independent Arweave references */
18
+ export declare const AR_IO_PROTOCOL = "ar://";
19
+ /** Default AR.IO logo Arweave TX ID (32x32 PNG) */
20
+ export declare const ARIO_LOGO_TX_ID = "WMLnh8pQL-UIXZMpdU2NUIriHfcFB5Bc49V8jTHjsZc";
21
+ /**
22
+ * Construct an ar:// URI from an Arweave TX ID or ArNS name.
23
+ *
24
+ * - ar://{txId} — raw 43-char TX ID, resolved by wallets via arweave.net gateway
25
+ * - ar://{arnsName} — ArNS name, resolved by AR.IO gateways and Wayfinder SDK
26
+ */
27
+ export declare function arweaveUri(txIdOrName: string): string;
17
28
  /** FQDN regex that matches the one used in the ArNS contract. */
18
29
  export declare const FQDN_REGEX: RegExp;
19
- export declare const ARIO_DEVNET_PROCESS_ID = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
20
- export declare const arioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
21
- export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
22
- export declare const ARIO_MAINNET_PROCESS_ID = "qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE";
23
- export declare const ANT_REGISTRY_TESTNET_ID = "RR0vheYqtsKuJCWh6xj0beE35tjaEug5cejMw9n2aa8";
24
- export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
25
- export declare const MARKETPLACE_CONTRACT_ID = "wPh88ziUF4meLpHfffmgdA6IFtzmXHgdeg-epzBjkao";
26
30
  export declare const MARIO_PER_ARIO = 1000000;
27
- /**
28
- * @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
29
- **/
30
- export declare const AOS_MODULE_ID = "nEjlSFA_8narJlVHApbczDPkMc9znSqYtqtf1iOdoxM";
31
- /**
32
- * @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
33
- **/
34
- export declare const ANT_LUA_ID = "sOW9Sdm1yoPRrzerC5iu1nsupp4e6I-HnJyYVHzvzQo";
35
- export declare const AO_AUTHORITY = "fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY";
36
- export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
37
- export declare const DEFAULT_CU_URL = "https://cu.ardrive.io";
@@ -0,0 +1,180 @@
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 ANT (Arweave Name Token) read interface.
18
+ *
19
+ * Reads ANT state from Metaplex Core NFT + PDA accounts on Solana.
20
+ * Each ANT is a Metaplex Core NFT with extended state in PDAs:
21
+ * - AntConfig: name, ticker, logo, description, keywords, owner
22
+ * - AntControllers: list of controller pubkeys
23
+ * - AntRecord: undername records (transactionId, ttl, priority, etc.)
24
+ */
25
+ import { type Address, type Commitment } from '@solana/kit';
26
+ import { type ILogger } from '../common/logger.js';
27
+ import type { ANTHandler, ANTInfo, ANTRecord, ANTState, ANTSummary, AntReadOptions, SortedANTRecords } from '../types/ant.js';
28
+ import type { WalletAddress } from '../types/common.js';
29
+ import { SolanaANTRegistryReadable } from './ant-registry-readable.js';
30
+ import type { SolanaRpc } from './types.js';
31
+ /**
32
+ * Solana-backed read-only client for a single ANT (Arweave Name Token).
33
+ *
34
+ * Usage:
35
+ * ```ts
36
+ * import { createSolanaRpc } from '@solana/kit';
37
+ * import { SolanaANTReadable } from '@ar.io/sdk/solana';
38
+ *
39
+ * const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
40
+ * const ant = new SolanaANTReadable({
41
+ * rpc,
42
+ * processId: 'MetaplexCoreAssetAddress...',
43
+ * });
44
+ *
45
+ * const owner = await ant.getOwner();
46
+ * const record = await ant.getRecord({ undername: '@' });
47
+ * ```
48
+ */
49
+ export declare class SolanaANTReadable {
50
+ readonly processId: string;
51
+ protected readonly rpc: SolanaRpc;
52
+ protected readonly commitment: Commitment;
53
+ protected readonly logger: ILogger;
54
+ protected readonly antProgram: Address;
55
+ protected readonly mint: Address;
56
+ /**
57
+ * Composed registry instance — the source of truth for the per-user
58
+ * paginated ACL (ADR-012). Sharing one instance across the read and
59
+ * write classes keeps program id / commitment / RPC configuration
60
+ * coherent for both `accessControlList` reads and the maintenance
61
+ * planner used during writes.
62
+ */
63
+ readonly registry: SolanaANTRegistryReadable;
64
+ constructor(config: {
65
+ rpc: SolanaRpc;
66
+ processId: string;
67
+ commitment?: Commitment;
68
+ logger?: ILogger;
69
+ antProgramId?: Address;
70
+ /**
71
+ * Pre-built registry to compose. When omitted we build a readable
72
+ * registry from `rpc` / `commitment` / `antProgramId` so the simple
73
+ * "just give me an ANT" call path keeps working with a single arg.
74
+ */
75
+ registry?: SolanaANTRegistryReadable;
76
+ });
77
+ /**
78
+ * Build a `SolanaANTReadable` whose program id is read from the
79
+ * asset's `ANT Program` Attributes-plugin entry (ADR-016 / BD-100).
80
+ *
81
+ * Falls back to the canonical `ARIO_ANT_PROGRAM_ID` when the asset
82
+ * has no plugin section, no `ANT Program` trait, or any layer of the
83
+ * walk fails to decode — matching the on-chain leniency in
84
+ * `programs/ario-core/src/mpl_core.rs::read_ant_program`. This is the
85
+ * factory resolution paths should reach for: it does the asset fetch
86
+ * once, hands the resulting program id to the constructor, and
87
+ * shares one `SolanaANTRegistryReadable` instance with the new ANT.
88
+ *
89
+ * Use the plain constructor when the program id is already known
90
+ * (e.g. inside a freshly-spawned ANT flow where you've just minted
91
+ * the asset and know the program you targeted).
92
+ */
93
+ static fromAsset(config: {
94
+ rpc: SolanaRpc;
95
+ processId: string;
96
+ commitment?: Commitment;
97
+ logger?: ILogger;
98
+ }): Promise<SolanaANTReadable>;
99
+ private getAccount;
100
+ private fetchConfig;
101
+ private fetchControllers;
102
+ /**
103
+ * Fetch AntConfig + AntControllers in a single `getMultipleAccounts` round
104
+ * trip (instead of two single-account reads). Used by `getState` to shave one
105
+ * RPC per ANT — meaningful when a UI loads many ANTs.
106
+ */
107
+ private _fetchConfigAndControllers;
108
+ getOwner(_opts?: AntReadOptions): Promise<WalletAddress>;
109
+ /** Get the on-chain schema version of this ANT's config. */
110
+ getConfigVersion(): Promise<number>;
111
+ /** Check if this ANT needs a schema migration to the latest version. */
112
+ needsMigration(): Promise<boolean>;
113
+ getName(_opts?: AntReadOptions): Promise<string>;
114
+ getTicker(_opts?: AntReadOptions): Promise<string>;
115
+ getLogo(_opts?: AntReadOptions): Promise<string>;
116
+ getControllers(): Promise<WalletAddress[]>;
117
+ getRecord({ undername }: {
118
+ undername: string;
119
+ }, _opts?: AntReadOptions): Promise<ANTRecord | undefined>;
120
+ getRecords(opts?: AntReadOptions): Promise<SortedANTRecords>;
121
+ /**
122
+ * Bulk-load lightweight {@link ANTSummary} state for many ANTs in a handful
123
+ * of `getMultipleAccounts` calls instead of `N × getState`. For each mint it
124
+ * batches AntConfig + AntControllers + the apex (`@`) AntRecord — everything a
125
+ * portfolio/names table needs. Full undername records are NOT loaded here;
126
+ * fetch them lazily per-ANT via {@link getRecords}/{@link getState} when a
127
+ * name is opened.
128
+ *
129
+ * Requests: ~`ceil(3N / 100)` calls for N mints (10 → 1, 250 → 8), versus
130
+ * ~`4N` with per-ANT `getState`. Assumes every mint is deployed under this
131
+ * instance's `antProgram` (true for the standard AR.IO ANT program).
132
+ *
133
+ * Mints whose AntConfig doesn't exist are omitted from the result.
134
+ */
135
+ getANTSummaries(mints: ReadonlyArray<string>): Promise<Record<string, ANTSummary>>;
136
+ /**
137
+ * Bulk-load FULL {@link ANTState} (including all undername records) for many
138
+ * ANTs in a handful of calls instead of `N × getState`:
139
+ * - AntConfig + AntControllers for every mint via `getMultipleAccounts`
140
+ * (chunked at 100), and
141
+ * - ALL undername records via a SINGLE program-wide `getProgramAccounts`
142
+ * scan grouped by mint (offset 8), instead of one mint-filtered scan per
143
+ * ANT.
144
+ *
145
+ * Requests: ~`ceil(2N / 100) + 1` (+1 when `includeMetadata`) regardless of
146
+ * N — e.g. 10 ANTs → 2 calls, 250 → ~6 — versus ~`2N` with per-ANT
147
+ * `getState`. The records scan reads every ANT's records program-wide (cheap
148
+ * per account, one round trip); prefer per-ANT {@link getState} when you only
149
+ * need one ANT. Mints with no AntConfig are omitted.
150
+ */
151
+ getANTStates(mints: ReadonlyArray<string>, opts?: AntReadOptions): Promise<Record<string, ANTState>>;
152
+ /**
153
+ * Group every AntRecord (+ optional metadata) in the program by mint via a
154
+ * single `getProgramAccounts` scan (the mint sits at offset 8). Used by
155
+ * {@link getANTStates} to load all ANTs' undername records in one round trip
156
+ * instead of one mint-filtered scan per ANT.
157
+ */
158
+ private _recordsByMint;
159
+ getBalance({ address: queryAddress }: {
160
+ address: WalletAddress;
161
+ }, _opts?: AntReadOptions): Promise<number>;
162
+ getBalances(_opts?: AntReadOptions): Promise<Record<WalletAddress, number>>;
163
+ getState(opts?: AntReadOptions): Promise<ANTState>;
164
+ getInfo(_opts?: AntReadOptions): Promise<ANTInfo>;
165
+ getHandlers(): Promise<ANTHandler[]>;
166
+ getModuleId(_opts?: {
167
+ graphqlUrl?: string;
168
+ retries?: number;
169
+ }): Promise<string>;
170
+ getVersion(_opts?: {
171
+ antRegistryId?: string;
172
+ graphqlUrl?: string;
173
+ retries?: number;
174
+ }): Promise<string>;
175
+ isLatestVersion(_opts?: {
176
+ antRegistryId?: string;
177
+ graphqlUrl?: string;
178
+ retries?: number;
179
+ }): Promise<boolean>;
180
+ }
@@ -0,0 +1,105 @@
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
+ * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ */
25
+ /**
26
+ * Solana implementation of the ANT Registry read interface.
27
+ *
28
+ * Backed by the per-user paginated ACL (ADR-012): a head `AclConfig` PDA
29
+ * and N content-addressable `AclPage` PDAs, each holding up to
30
+ * `MAX_ACL_PAGE_ENTRIES` `(asset, role)` tuples. Frontends can fetch a
31
+ * user's ANTs in two RPC calls — one `getAccountInfo` for `AclConfig` plus
32
+ * one `getMultipleAccountsInfo` for every page — instead of a
33
+ * `getProgramAccounts` scan, a DAS provider, or a foundation-hosted
34
+ * indexer.
35
+ *
36
+ * Usage:
37
+ * ```ts
38
+ * import { createSolanaRpc } from '@solana/kit';
39
+ * import { ANTRegistry } from '@ar.io/sdk';
40
+ *
41
+ * const registry = ANTRegistry.init({
42
+ * backend: 'solana',
43
+ * rpc: createSolanaRpc('https://api.mainnet-beta.solana.com'),
44
+ * });
45
+ *
46
+ * const { Owned, Controlled } = await registry.accessControlList({
47
+ * address: 'SomeSolanaWalletAddress...',
48
+ * });
49
+ * ```
50
+ *
51
+ * When a user has no on-chain `AclConfig` (never registered / not yet
52
+ * populated), both lists return empty. The write path (SDK ANT write
53
+ * methods + migration tooling) is responsible for keeping the ACL in sync
54
+ * as owners / controllers change.
55
+ */
56
+ import { type Address, type Commitment } from '@solana/kit';
57
+ import { type ILogger } from '../common/logger.js';
58
+ import type { ANTRegistryRead } from '../types/ant-registry.js';
59
+ import type { SolanaRpc } from './types.js';
60
+ export type SolanaANTRegistryConfig = {
61
+ rpc: SolanaRpc;
62
+ commitment?: Commitment;
63
+ logger?: ILogger;
64
+ /**
65
+ * Override the ario-ant program ID. Required against any cluster other
66
+ * than mainnet — devnet, localnet, and the Surfpool harness all deploy
67
+ * programs at addresses derived from per-cluster keypair files.
68
+ */
69
+ antProgramId?: Address;
70
+ };
71
+ export declare class SolanaANTRegistryReadable implements ANTRegistryRead {
72
+ protected readonly rpc: SolanaRpc;
73
+ protected readonly commitment: Commitment;
74
+ /** Deployed `ario-ant` program id this registry talks to. */
75
+ readonly antProgram: Address;
76
+ protected readonly logger: ILogger;
77
+ constructor(config: SolanaANTRegistryConfig);
78
+ /**
79
+ * Read a user's `AclConfig` head plus every `AclPage` and return owned +
80
+ * controlled ANT mint lists. Returns empty lists if the head PDA does not
81
+ * exist yet.
82
+ *
83
+ * **Note:** This is an eventually-consistent secondary index, not a
84
+ * canonical source of truth. Marketplace transfers update NFT ownership
85
+ * on-chain immediately but the ACL is only updated when someone calls
86
+ * `record_acl_owner` / `remove_acl_owner`. For real-time accuracy on a
87
+ * specific ANT, check the Metaplex Core asset owner directly.
88
+ */
89
+ accessControlList({ address: addr, }: {
90
+ address: string;
91
+ }): Promise<{
92
+ Owned: string[];
93
+ Controlled: string[];
94
+ }>;
95
+ /**
96
+ * Cleaner alias for `accessControlList` — matches the AO backend so
97
+ * consumers can switch backends without renaming calls.
98
+ */
99
+ getAntsForAddress({ address, }: {
100
+ address: string;
101
+ }): Promise<{
102
+ Owned: string[];
103
+ Controlled: string[];
104
+ }>;
105
+ }