@ar.io/sdk 3.24.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +682 -600
  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 +221 -0
  6. package/lib/esm/cli/commands/gatewayWriteCommands.js +142 -23
  7. package/lib/esm/cli/commands/pruneCommands.js +150 -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 +280 -174
  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 +11 -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 +51 -263
  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
@@ -0,0 +1,224 @@
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.spawn`.
18
+ *
19
+ * Mints a fresh Metaplex Core asset (the ANT NFT) AND initializes the
20
+ * `ario-ant` extended state PDAs (`AntConfig`, `AntControllers`, root `@`
21
+ * record) in a single atomic transaction.
22
+ *
23
+ * This is the Solana counterpart to the legacy AO `spawnANT` flow:
24
+ * - AO: `ao.spawn({ module, scheduler, ... })` → returns AO process id.
25
+ * - Solana: mint MPL Core asset + initialize ario-ant PDAs → returns the
26
+ * asset's pubkey (which serves as the SDK's stable `processId`).
27
+ *
28
+ * For the bulk-import flow used by `migration/import` we use a separate
29
+ * code path that mints to the migration authority and uses the gated
30
+ * `import_account` instruction — that's intentional and not what this SDK
31
+ * helper is for.
32
+ */
33
+ import { addSignersToTransactionMessage, appendTransactionMessageInstructions, createTransactionMessage, generateKeyPairSigner, getSignatureFromTransaction, pipe, sendAndConfirmTransactionFactory, setTransactionMessageFeePayerSigner, setTransactionMessageLifetimeUsingBlockhash, signTransactionMessageWithSigners, } from '@solana/kit';
34
+ import { getInitializeInstructionAsync } from '@ar.io/solana-contracts/ant';
35
+ import { DataState, getCreateV1Instruction, } from '@ar.io/solana-contracts/mpl-core';
36
+ import { getSetComputeUnitLimitInstruction, getSetComputeUnitPriceInstruction, } from '@solana-program/compute-budget';
37
+ import { SolanaANTRegistryWriteable } from './ant-registry-writeable.js';
38
+ import { ARIO_ANT_PROGRAM_ID } from './constants.js';
39
+ import { getAntRecordPDA } from './pda.js';
40
+ /** AR.IO logo Arweave TX — matches the Rust default in `ario_ant::initialize`. */
41
+ export const ARIO_LOGO_TX_ID = 'AnYvLJTWcG9lr2Ll5MwYWZR2o5uTE39WbpYB0zCxwKM';
42
+ /**
43
+ * Default Arweave transaction id used when an ANT is spawned without an
44
+ * explicit `transactionId`. Empty string would fail the on-chain
45
+ * `is_valid_arweave_id` check, so we fall back to the AR.IO logo TX (which is
46
+ * a real Arweave id and won't trip validation).
47
+ */
48
+ export const DEFAULT_ANT_TRANSACTION_ID = ARIO_LOGO_TX_ID;
49
+ /**
50
+ * Public, low-level builder for the `CreateV1` MPL Core instruction with the
51
+ * AR.IO-standard ANT shape (Attributes plugin pre-installed, Owner authority).
52
+ *
53
+ * Delegates to the Codama-generated `getCreateV1Instruction`, but accepts
54
+ * plain `Address`es (rather than full `TransactionSigner`s) so test fixtures
55
+ * and devnet validation scripts can byte-pin the wire format without
56
+ * standing up real keypairs. The signer roles still flow through correctly
57
+ * because we re-cast under `unknown`.
58
+ *
59
+ * Most callers should use `ANT.spawn` / `spawnSolanaANT` instead — that path
60
+ * also wires up `ario_ant::initialize` so the ANT is fully usable end to end.
61
+ * Use this raw builder when you need fine-grained control over signing, or
62
+ * are bundling the mint into a larger compound transaction.
63
+ *
64
+ * **Why we always emit an Attributes plugin (even with an empty list):**
65
+ * `ario_arns::buy_record` and friends CPI into `UpdatePluginV1` to populate
66
+ * traits at purchase time. If the asset has no Attributes plugin, that CPI
67
+ * fails. Emitting an empty plugin here keeps every spawned ANT
68
+ * `purchase`-ready and matches what `migration/import` mints — see ADR-012
69
+ * and BD-096. Authority is `Owner` so the ANT NFT holder (= asset owner)
70
+ * can sign their own trait updates.
71
+ */
72
+ export function buildCreateAntInstruction({ mint, authority, payer, name, uri, attributes = [], }) {
73
+ // Codama wants TransactionSigners for asset/authority/payer because the
74
+ // resulting account meta is marked SIGNER. The byte-pinning surface we're
75
+ // exposing only cares about pubkeys + wire bytes, so we adapt by feeding
76
+ // it minimal signer-shaped objects.
77
+ const asSigner = (a) => ({ address: a, signTransactions: () => Promise.resolve([]) });
78
+ return getCreateV1Instruction({
79
+ asset: asSigner(mint),
80
+ authority: asSigner(authority),
81
+ payer: asSigner(payer),
82
+ dataState: DataState.AccountState,
83
+ name,
84
+ uri,
85
+ plugins: [
86
+ {
87
+ plugin: {
88
+ __kind: 'Attributes',
89
+ fields: [{ attributeList: attributes }],
90
+ },
91
+ authority: { __kind: 'Owner' },
92
+ },
93
+ ],
94
+ });
95
+ }
96
+ /**
97
+ * Build the `ario_ant::initialize` instruction for a freshly minted asset.
98
+ */
99
+ async function buildInitializeAntIx({ programId, mint, signer, state, }) {
100
+ // Codama auto-resolves antConfig + antControllers PDAs. rootRecord uses a
101
+ // hashed-undername seed Codama can't infer from args, so we derive it here.
102
+ const [rootRecordPda] = await getAntRecordPDA(mint, '@', programId);
103
+ return getInitializeInstructionAsync({
104
+ asset: mint,
105
+ rootRecord: rootRecordPda,
106
+ owner: signer,
107
+ name: state.name,
108
+ ticker: state.ticker ?? null,
109
+ target: state.transactionId ?? DEFAULT_ANT_TRANSACTION_ID,
110
+ targetProtocol: state.targetProtocol ?? null,
111
+ logo: state.logo ?? '',
112
+ description: state.description ?? '',
113
+ keywords: state.keywords ?? [],
114
+ }, { programAddress: programId });
115
+ }
116
+ /**
117
+ * Spawn a brand-new ANT on Solana. Returns the asset address, which is the
118
+ * SDK's stable `processId` for that ANT.
119
+ */
120
+ export async function spawnSolanaANT(params) {
121
+ if (!params.state?.name || params.state.name.length === 0) {
122
+ throw new Error('spawnSolanaANT: state.name is required');
123
+ }
124
+ const { rpc, rpcSubscriptions, signer, state, antProgramId = ARIO_ANT_PROGRAM_ID, commitment = 'confirmed', computeUnitLimit = 400_000, } = params;
125
+ const mintSigner = params.mintSigner ?? (await generateKeyPairSigner());
126
+ const owner = signer.address;
127
+ const mint = mintSigner.address;
128
+ const uri = state.uri ??
129
+ `ar://${state.logo && state.logo.length > 0 ? state.logo : ARIO_LOGO_TX_ID}`;
130
+ // Emit the Attributes plugin (Owner authority) at mint time with the
131
+ // asset-side `ANT Program` entry pre-installed. Two reasons to always
132
+ // include it:
133
+ //
134
+ // 1. ADR-016 / BD-100 — the program managing this asset's per-mint
135
+ // state PDAs is named on the asset itself. Writing it here means
136
+ // every fresh ANT carries an explicit, queryable program id from
137
+ // the moment it's minted; resolvers can read it without a lookup
138
+ // against any external registry.
139
+ // 2. The Attributes plugin must already exist before
140
+ // `ario_arns::buy_name` CPIs into `UpdatePluginV1` to populate
141
+ // ARNS Name / Type / Undername Limit. Skipping this returns
142
+ // MPL Core 0x4 ("Plugin not found") at ArNS purchase time.
143
+ //
144
+ // Default value is the canonical `ARIO_ANT_PROGRAM_ID`; passing
145
+ // `antProgramId` opts into the BYO-ANT (third-party) path.
146
+ const createIx = getCreateV1Instruction({
147
+ asset: mintSigner,
148
+ payer: signer,
149
+ authority: signer,
150
+ dataState: DataState.AccountState,
151
+ name: state.name,
152
+ uri,
153
+ plugins: [
154
+ {
155
+ plugin: {
156
+ __kind: 'Attributes',
157
+ fields: [
158
+ {
159
+ attributeList: [
160
+ { key: 'ANT Program', value: antProgramId },
161
+ ],
162
+ },
163
+ ],
164
+ },
165
+ authority: { __kind: 'Owner' },
166
+ },
167
+ ],
168
+ });
169
+ const initIx = await buildInitializeAntIx({
170
+ programId: antProgramId,
171
+ mint,
172
+ signer,
173
+ state,
174
+ });
175
+ // ADR-012 (ACL): bootstrap the new owner's paginated ACL. The
176
+ // contract's `initialize` handler seeds `ant_controllers = vec![owner]`
177
+ // (matches the Lua source), so the owner needs entries under both
178
+ // `Owner` (for "ANTs I own" lookups) and `Controller` (for "ANTs I
179
+ // can manage" lookups). Bundling here keeps the ACL atomic with the
180
+ // spawn — by the time the tx confirms, frontends can resolve the
181
+ // owner's ANT list via the head config + paged accounts.
182
+ const registry = new SolanaANTRegistryWriteable({
183
+ rpc,
184
+ signer,
185
+ commitment,
186
+ antProgramId,
187
+ });
188
+ const aclIxs = await registry.bootstrapOwnerOnSpawn({
189
+ owner,
190
+ asset: mint,
191
+ });
192
+ // The create instruction has two signers (mint + authority+payer). Kit picks
193
+ // them up from the account metadata roles: accounts marked as SIGNER roles
194
+ // must have a matching `TransactionSigner` attached. We do that by placing
195
+ // the mint signer on the message alongside the fee payer signer.
196
+ const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
197
+ const message = pipe(createTransactionMessage({ version: 0 }), (tx) => setTransactionMessageFeePayerSigner(signer, tx), (tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx), (tx) => appendTransactionMessageInstructions([
198
+ getSetComputeUnitLimitInstruction({ units: computeUnitLimit }),
199
+ // Pin the priority fee (at 0) so wallets like Phantom don't
200
+ // silently append their own compute-budget instructions and
201
+ // invalidate the paired mint keypair signer's signature. See
202
+ // `sendAndConfirm` in `./send.js` for the full rationale.
203
+ getSetComputeUnitPriceInstruction({ microLamports: 0n }),
204
+ createIx,
205
+ initIx,
206
+ ...aclIxs,
207
+ ], tx));
208
+ // Attach the mint signer so kit can satisfy the WRITABLE_SIGNER role on the
209
+ // mint account. `addSignersToTransactionMessage` walks the message's account
210
+ // metas and registers each matching signer by address, which is what
211
+ // `signTransactionMessageWithSigners` then looks up to produce signatures.
212
+ const withMintSigner = addSignersToTransactionMessage([mintSigner], message);
213
+ const signedTx = await signTransactionMessageWithSigners(withMintSigner);
214
+ const sendAndConfirmFactory = sendAndConfirmTransactionFactory({
215
+ rpc,
216
+ rpcSubscriptions,
217
+ });
218
+ await sendAndConfirmFactory(signedTx, { commitment });
219
+ return {
220
+ processId: mint,
221
+ mint,
222
+ signature: getSignatureFromTransaction(signedTx),
223
+ };
224
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -34,8 +34,8 @@ export const ArweaveTxIdSchema = z
34
34
  .refine((val) => ARWEAVE_TX_REGEX.test(val), {
35
35
  message: 'Must be an Arweave Transaction ID',
36
36
  });
37
- export const AOAddressSchema = z.string({
38
- description: 'AO Address',
37
+ export const WalletAddressSchema = z.string({
38
+ description: 'Wallet address (Solana base58 pubkey)',
39
39
  });
40
40
  export const IntegerStringSchema = z
41
41
  .string({
@@ -45,13 +45,25 @@ export const IntegerStringSchema = z
45
45
  const num = parseInt(val);
46
46
  return Number.isInteger(num) && num >= 0;
47
47
  }, { message: 'Must be a non negative integer string' });
48
- export const AntDescriptionSchema = z.string(); // TODO: add specific limits for description ie max length
49
- export const AntKeywordsSchema = z.array(z.string()); // TODO: add specific limits for keywords ie max amount and max length
48
+ export const AntDescriptionSchema = z.string().max(256, {
49
+ message: 'ANT description must be at most 256 characters',
50
+ });
51
+ export const AntKeywordsSchema = z
52
+ .array(z.string().max(32, {
53
+ message: 'Each keyword must be at most 32 characters',
54
+ }))
55
+ .max(8, { message: 'ANT can have at most 8 keywords' });
50
56
  export const AntRecordSchema = z.object({
51
- transactionId: ArweaveTxIdSchema.describe('The Target ID of the undername'),
57
+ transactionId: z
58
+ .string()
59
+ .describe('Content target (Arweave TX ID, IPFS CID, etc.)'),
52
60
  ttlSeconds: z.number(),
61
+ targetProtocol: z
62
+ .number()
63
+ .describe('Storage protocol: 0 = Arweave, 1 = IPFS')
64
+ .default(0),
53
65
  priority: z.number().optional(),
54
- owner: AOAddressSchema.describe('The owner address of the record').optional(),
66
+ owner: WalletAddressSchema.describe('The owner address of the record').optional(),
55
67
  displayName: z
56
68
  .string()
57
69
  .max(61)
@@ -60,18 +72,18 @@ export const AntRecordSchema = z.object({
60
72
  logo: ArweaveTxIdSchema.describe('Logo transaction ID for the record').optional(),
61
73
  description: z
62
74
  .string()
63
- .max(512)
64
- .describe('Description of the record (max 512 chars)')
75
+ .max(256)
76
+ .describe('Description of the record (max 256 chars)')
65
77
  .optional(),
66
78
  keywords: z
67
79
  .array(z.string().max(32))
68
- .max(16)
69
- .describe('Keywords array (max 16, each max 32 chars)')
80
+ .max(8)
81
+ .describe('Keywords array (max 8, each max 32 chars)')
70
82
  .optional(),
71
83
  });
72
84
  export const AntRecordsSchema = z.record(z.string(), AntRecordSchema);
73
- export const AntControllersSchema = z.array(AOAddressSchema.describe('Controller address'));
74
- export const AntBalancesSchema = z.record(AOAddressSchema.describe('Holder address'), z.number());
85
+ export const AntControllersSchema = z.array(WalletAddressSchema.describe('Controller address'));
86
+ export const AntBalancesSchema = z.record(WalletAddressSchema.describe('Holder address'), z.number());
75
87
  export const AntStateSchema = z.object({
76
88
  Name: z.string().describe('The name of the ANT.'),
77
89
  Ticker: z.string().describe('The ticker symbol for the ANT.'),
@@ -81,7 +93,7 @@ export const AntStateSchema = z.object({
81
93
  .number()
82
94
  .describe('The number of decimal places to use for the ANT. Defaults to 0 if not set representing whole numbers.')
83
95
  .min(0, { message: 'Denomination must be a non-negative number' }),
84
- Owner: AOAddressSchema.describe('The Owners address.'),
96
+ Owner: WalletAddressSchema.describe('The Owners address.'),
85
97
  Controllers: AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
86
98
  Records: AntRecordsSchema.describe('Records associated with the ANT.'),
87
99
  Balances: AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
@@ -99,7 +111,7 @@ export const SpawnANTStateSchema = z.object({
99
111
  ticker: z.string().describe('The ticker symbol for the ANT.'),
100
112
  description: z.string().describe('The description for the ANT.'),
101
113
  keywords: AntKeywordsSchema.describe('The keywords for the ANT.'),
102
- owner: AOAddressSchema.describe('The Owners address.'),
114
+ owner: WalletAddressSchema.describe('The Owners address.'),
103
115
  controllers: AntControllersSchema.describe('Controllers of the ANT who have administrative privileges.'),
104
116
  records: AntRecordsSchema.describe('Records associated with the ANT.'),
105
117
  balances: AntBalancesSchema.describe('Balance details for each address holding the ANT.'),
@@ -159,6 +171,6 @@ export const AntInfoSchema = z.object({
159
171
  * @param state {object}
160
172
  * @returns {boolean}
161
173
  */
162
- export function isAoANTState(state) {
174
+ export function isANTState(state) {
163
175
  return AntStateSchema.safeParse(state).success;
164
176
  }
@@ -1,4 +1,3 @@
1
- import { validateArweaveId } from '../utils/arweave.js';
2
1
  export const isDistributedEpochData = (data) => {
3
2
  return data.distributedTimestamp !== undefined;
4
3
  };
@@ -22,20 +21,18 @@ export const intentsUsingYears = [
22
21
  export const isValidIntent = (intent) => {
23
22
  return validIntents.indexOf(intent) !== -1;
24
23
  };
25
- export const fundFromOptions = ['balance', 'stakes', 'any', 'turbo'];
24
+ export const fundFromOptions = [
25
+ 'balance',
26
+ 'stakes',
27
+ 'withdrawal',
28
+ 'plan',
29
+ 'any',
30
+ 'turbo',
31
+ ];
26
32
  export const isValidFundFrom = (fundFrom) => {
27
33
  return fundFromOptions.indexOf(fundFrom) !== -1;
28
34
  };
29
35
  // Type-guard functions
30
- export function isProcessConfiguration(config) {
31
- return config !== undefined && 'process' in config;
32
- }
33
- export function isProcessIdConfiguration(config) {
34
- return (config !== undefined &&
35
- 'processId' in config &&
36
- typeof config.processId === 'string' &&
37
- validateArweaveId(config.processId) === true);
38
- }
39
36
  export function isLeasedArNSRecord(record) {
40
37
  return record.type === 'lease';
41
38
  }
@@ -37,66 +37,3 @@ export const sortANTRecords = (antRecords) => {
37
37
  // now that they are sorted, add the index to each record - this is their position in the sorted list and is used to enforce undername limits
38
38
  return Object.fromEntries(sortedEntries.map(([a, aRecord], index) => [a, { ...aRecord, index }]));
39
39
  };
40
- /**
41
- * @deprecated - this is no longer necessary because HyperBeam now uses the AoANTState type
42
- */
43
- export const isHyperBeamANTState = (state) => {
44
- return ('name' in state &&
45
- 'ticker' in state &&
46
- 'description' in state &&
47
- 'keywords' in state &&
48
- 'denomination' in state &&
49
- 'owner' in state &&
50
- 'controllers' in state &&
51
- 'records' in state &&
52
- 'balances' in state &&
53
- 'logo' in state &&
54
- 'totalsupply' in state &&
55
- 'initialized' in state);
56
- };
57
- /**
58
- * Convert HyperBeam serialized ANT state to backwards compatible format.
59
- *
60
- * @deprecated - this is no longer necessary because HyperBeam now uses the AOANTState type
61
- * @param state - The HyperBeam serialized ANT state.
62
- */
63
- export const convertHyperBeamStateToAoANTState = (initialState) => {
64
- function lowerCaseKeys(obj) {
65
- return Object.fromEntries(Object.entries(obj).map(([key, value]) => {
66
- if (key.toLowerCase().includes('balances')) {
67
- return [key.toLowerCase(), value];
68
- }
69
- if (typeof value === 'object' &&
70
- !Array.isArray(value) &&
71
- value !== null) {
72
- return [key.toLowerCase(), lowerCaseKeys(value)];
73
- }
74
- return [key.toLowerCase(), value];
75
- }));
76
- }
77
- // we need to ensure keys are lower cased because hyperbeam json serializes keys to lowercase inconsistently
78
- const state = lowerCaseKeys(initialState);
79
- return {
80
- Name: state.name,
81
- Ticker: state.ticker,
82
- Description: state.description,
83
- Keywords: state.keywords,
84
- Denomination: parseInt(state.denomination),
85
- Owner: state.owner,
86
- Controllers: state.controllers,
87
- Records: Object.entries(state.records).reduce((acc, [key, record]) => {
88
- acc[key] = {
89
- transactionId: record.transactionid,
90
- ttlSeconds: record.ttlseconds,
91
- ...(record.priority !== undefined
92
- ? { priority: record.priority }
93
- : {}),
94
- };
95
- return acc;
96
- }, {}),
97
- Balances: state.balances,
98
- Logo: state.logo,
99
- TotalSupply: state.totalsupply || 1,
100
- Initialized: state.initialized,
101
- };
102
- };
@@ -13,10 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export * from './ao.js';
17
- export * from './arweave.js';
18
16
  export * from './base64.js';
19
17
  export * from './json.js';
20
- export * from './processes.js';
21
18
  export * from './schema.js';
22
19
  export * from './ant.js';
@@ -14,4 +14,4 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
17
- export const version = '3.24.0';
17
+ export const version = '4.0.0-alpha.1';
@@ -13,21 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams } from '../../types/ant.js';
16
+ import { ANTSetBaseNameRecordParams, ANTSetUndernameRecordParams } from '../../types/ant.js';
17
17
  import { CLIWriteOptionsFromAoAntParams } from '../types.js';
18
18
  /** @deprecated -- use set-ant-base-name and set-ant-undername */
19
- export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
20
- export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
21
- export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<AoANTSetUndernameRecordParams>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
19
+ export declare function setAntRecordCLICommand(o: CLIWriteOptionsFromAoAntParams<ANTSetUndernameRecordParams>): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
20
+ export declare function setAntBaseNameCLICommand(o: CLIWriteOptionsFromAoAntParams<ANTSetBaseNameRecordParams>): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
21
+ export declare function setAntUndernameCLICommand(o: CLIWriteOptionsFromAoAntParams<ANTSetUndernameRecordParams>): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
22
22
  export declare function transferRecordOwnershipCLICommand(o: CLIWriteOptionsFromAoAntParams<{
23
23
  undername: string;
24
24
  recipient: string;
25
- }>): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
26
- export declare function upgradeAntCLICommand(o: CLIWriteOptionsFromAoAntParams<Record<string, unknown>>): Promise<{
27
- forkedProcessId: string;
28
- reassignedNames: Record<string, import("../../types/common.js").AoMessageResult>;
29
- failedReassignedNames: Record<string, {
30
- id?: string;
31
- error: string;
32
- }>;
33
- }>;
25
+ }>): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
@@ -1,10 +1,36 @@
1
- import { AoArNSPurchaseParams, AoBuyRecordParams, AoExtendLeaseParams, AoIncreaseUndernameLimitParams } from '../../types/io.js';
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 { ArNSPurchaseParams, BuyRecordParams, ExtendLeaseParams, IncreaseUndernameLimitParams } from '../../types/io.js';
2
17
  import { CLIWriteOptionsFromAoParams } from '../types.js';
3
- export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuyRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
4
- export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
5
- export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<AoExtendLeaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
6
- export declare function increaseUndernameLimitCLICommand(o: CLIWriteOptionsFromAoParams<AoIncreaseUndernameLimitParams>): Promise<import("../../types/common.js").AoMessageResult>;
7
- export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<Omit<import("../../types/common.js").AoPrimaryNameRequest, "initiator"> & {
18
+ export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<BuyRecordParams>): Promise<import("../../types/common.js").MessageResult>;
19
+ export declare function upgradeRecordCLICommand(o: CLIWriteOptionsFromAoParams<ArNSPurchaseParams>): Promise<import("../../types/common.js").MessageResult>;
20
+ export declare function extendLeaseCLICommand(o: CLIWriteOptionsFromAoParams<ExtendLeaseParams>): Promise<import("../../types/common.js").MessageResult>;
21
+ export declare function increaseUndernameLimitCLICommand(o: CLIWriteOptionsFromAoParams<IncreaseUndernameLimitParams>): Promise<import("../../types/common.js").MessageResult>;
22
+ export declare function requestPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<ArNSPurchaseParams>): Promise<Omit<import("../../types/common.js").PrimaryNameRequest, "initiator"> & {
8
23
  initiator: import("../../types/common.js").WalletAddress;
9
24
  }>;
10
- export declare function setPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<AoArNSPurchaseParams>): Promise<import("../../types/common.js").AoMessageResult>;
25
+ export declare function setPrimaryNameCLICommand(o: CLIWriteOptionsFromAoParams<ArNSPurchaseParams>): Promise<import("../../types/common.js").MessageResult>;
26
+ /**
27
+ * Reconcile the on-chain ANT Attributes plugin (`ArNS Name`, `Type`,
28
+ * `Undername Limit`) with the current `ArnsRecord` state. Permissionless.
29
+ *
30
+ * Use after a `buy-record` where the buyer was not the ANT NFT holder
31
+ * (the ANT-side trait CPI gets skipped at runtime in that case so the
32
+ * plugin stays empty until the actual holder reconciles).
33
+ */
34
+ export declare function syncAttributesCLICommand(o: CLIWriteOptionsFromAoParams<{
35
+ name: string;
36
+ }>): Promise<import("../../types/common.js").MessageResult>;
@@ -0,0 +1,68 @@
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
+ * CLI commands for `ario-ant-escrow` — trustless multi-protocol ANT custody.
18
+ *
19
+ * Each command instantiates an {@link ANTEscrow} with options-driven RPC +
20
+ * signer wiring (mirrors the rest of the Solana CLI surface — see
21
+ * `arnsPurchaseCommands.ts`). All read commands work without a signer; all
22
+ * write commands require `--wallet-file` or `--private-key`.
23
+ *
24
+ * Recipient pubkey loading:
25
+ * - Arweave: `--recipient-arweave <jwk-file>` reads the JWK JSON, decodes
26
+ * the base64url `n` field to 512 raw bytes (RSA-4096 modulus).
27
+ * - Ethereum: `--recipient-ethereum 0x...` parses the 20-byte hex address.
28
+ */
29
+ import type { JsonSerializable } from '../types.js';
30
+ interface EscrowGlobalOptions {
31
+ rpcUrl?: string;
32
+ walletFile?: string;
33
+ privateKey?: string;
34
+ escrowProgramId?: string;
35
+ }
36
+ interface AntMintOptions extends EscrowGlobalOptions {
37
+ ant?: string;
38
+ }
39
+ interface DepositOptions extends AntMintOptions {
40
+ recipientArweave?: string;
41
+ recipientEthereum?: string;
42
+ }
43
+ interface UpdateRecipientOptions extends AntMintOptions {
44
+ newRecipientArweave?: string;
45
+ newRecipientEthereum?: string;
46
+ }
47
+ interface ClaimArweaveOptions extends AntMintOptions {
48
+ signatureFile?: string;
49
+ saltLen?: string;
50
+ claimant?: string;
51
+ }
52
+ interface ClaimEthereumOptions extends AntMintOptions {
53
+ signatureFile?: string;
54
+ claimant?: string;
55
+ }
56
+ /** `ar.io escrow status --ant <mint>` */
57
+ export declare function escrowStatusCLICommand(o: AntMintOptions): Promise<JsonSerializable>;
58
+ /** `ar.io escrow deposit --ant <mint> --recipient-{arweave|ethereum} ...` */
59
+ export declare function escrowDepositCLICommand(o: DepositOptions): Promise<JsonSerializable>;
60
+ /** `ar.io escrow cancel --ant <mint>` */
61
+ export declare function escrowCancelCLICommand(o: AntMintOptions): Promise<JsonSerializable>;
62
+ /** `ar.io escrow update-recipient --ant <mint> --new-recipient-{arweave|ethereum} ...` */
63
+ export declare function escrowUpdateRecipientCLICommand(o: UpdateRecipientOptions): Promise<JsonSerializable>;
64
+ /** `ar.io escrow claim-arweave --ant <mint> --signature-file <bin> --claimant <pubkey> [--salt-len 32]` */
65
+ export declare function escrowClaimArweaveCLICommand(o: ClaimArweaveOptions): Promise<JsonSerializable>;
66
+ /** `ar.io escrow claim-ethereum --ant <mint> --signature-file <bin> --claimant <pubkey>` */
67
+ export declare function escrowClaimEthereumCLICommand(o: ClaimEthereumOptions): Promise<JsonSerializable>;
68
+ export {};
@@ -1,38 +1,39 @@
1
1
  import { AddressAndVaultIdCLIWriteOptions, DecreaseDelegateStakeCLIOptions, JoinNetworkCLIOptions, OperatorStakeCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WriteActionCLIOptions } from '../types.js';
2
2
  export declare function joinNetwork(options: JoinNetworkCLIOptions): Promise<{
3
- joinNetworkResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
3
+ joinNetworkResult: import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>;
4
4
  joinedAddress: string;
5
5
  message: string;
6
6
  }>;
7
7
  export declare function updateGatewaySettings(options: UpdateGatewaySettingsCLIOptions): Promise<{
8
- updateGatewaySettingsResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
8
+ updateGatewaySettingsResult: import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>;
9
9
  updatedGatewayAddress: string;
10
10
  message: string;
11
11
  }>;
12
- export declare function leaveNetwork(options: WriteActionCLIOptions): Promise<import("../../types/common.js").AoMessageResult>;
12
+ export declare function leaveNetwork(options: WriteActionCLIOptions): Promise<import("../../types/common.js").MessageResult>;
13
13
  export declare function saveObservations(o: WriteActionCLIOptions & {
14
14
  failedGateways?: string[];
15
15
  transactionId?: string;
16
- }): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
17
- export declare function increaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
18
- export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
19
- export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
20
- export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
16
+ }): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
17
+ export declare function increaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
18
+ export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
19
+ export declare function claimWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").MessageResult>;
20
+ export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
21
+ export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>>;
21
22
  export declare function delegateStake(options: TransferCLIOptions): Promise<{
22
23
  senderAddress: string;
23
- transferResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
24
+ transferResult: import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>;
24
25
  message: string;
25
26
  } | {
26
27
  message: string;
27
28
  }>;
28
29
  export declare function decreaseDelegateStake(options: DecreaseDelegateStakeCLIOptions): Promise<{
29
30
  targetGateway: string;
30
- decreaseDelegateStakeResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
31
+ decreaseDelegateStakeResult: import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>;
31
32
  message: string;
32
33
  }>;
33
34
  export declare function redelegateStake(options: RedelegateStakeCLIOptions): Promise<{
34
35
  sourceGateway: string;
35
36
  targetGateway: string;
36
- redelegateStakeResult: import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>;
37
+ redelegateStakeResult: import("../../types/common.js").MessageResult<Record<string, string | number | boolean | null>>;
37
38
  message: string;
38
39
  }>;