@ar.io/sdk 3.19.0-alpha.1 → 3.19.0-alpha.11
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 +155 -7
- package/bundles/web.bundle.min.js +88 -72
- package/lib/cjs/cli/cli.js +14 -1
- package/lib/cjs/cli/commands/antCommands.js +82 -16
- package/lib/cjs/cli/options.js +36 -1
- package/lib/cjs/cli/utils.js +25 -11
- package/lib/cjs/common/ant.js +452 -12
- package/lib/cjs/common/io.js +2 -2
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/types/ant.js +18 -0
- package/lib/cjs/utils/ant.js +4 -0
- package/lib/cjs/utils/ao.js +3 -1
- package/lib/cjs/utils/processes.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +16 -3
- package/lib/esm/cli/commands/antCommands.js +81 -17
- package/lib/esm/cli/options.js +35 -0
- package/lib/esm/cli/utils.js +24 -11
- package/lib/esm/common/ant.js +453 -13
- package/lib/esm/common/io.js +2 -2
- package/lib/esm/constants.js +1 -0
- package/lib/esm/types/ant.js +18 -0
- package/lib/esm/utils/ant.js +4 -0
- package/lib/esm/utils/ao.js +3 -1
- package/lib/esm/utils/processes.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +12 -0
- package/lib/types/cli/options.d.ts +25 -0
- package/lib/types/cli/types.d.ts +1 -0
- package/lib/types/cli/utils.d.ts +15 -2
- package/lib/types/common/ant.d.ts +167 -6
- package/lib/types/common/io.d.ts +1 -1
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/types/ant.d.ts +131 -9
- package/lib/types/types/common.d.ts +31 -0
- package/lib/types/utils/ant.d.ts +4 -0
- package/lib/types/utils/ao.d.ts +2 -1
- package/lib/types/utils/processes.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2086,6 +2086,27 @@ const processId = await ANT.spawn({
|
|
|
2086
2086
|
description: 'My custom ANT token',
|
|
2087
2087
|
},
|
|
2088
2088
|
});
|
|
2089
|
+
|
|
2090
|
+
// Using a custom module ID
|
|
2091
|
+
const processId = await ANT.spawn({
|
|
2092
|
+
signer: new ArweaveSigner(jwk),
|
|
2093
|
+
module: 'FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE', // Custom module ID
|
|
2094
|
+
state: {
|
|
2095
|
+
name: 'My Custom Module ANT',
|
|
2096
|
+
ticker: 'CUSTOM',
|
|
2097
|
+
description: 'ANT using a specific module version',
|
|
2098
|
+
},
|
|
2099
|
+
});
|
|
2100
|
+
```
|
|
2101
|
+
|
|
2102
|
+
**CLI Usage:**
|
|
2103
|
+
|
|
2104
|
+
```bash
|
|
2105
|
+
# Spawn ANT with default (latest) module
|
|
2106
|
+
ar.io spawn-ant --wallet-file wallet.json --name "My ANT" --ticker "MYANT"
|
|
2107
|
+
|
|
2108
|
+
# Spawn ANT with custom module ID
|
|
2109
|
+
ar.io spawn-ant --wallet-file wallet.json --module FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE --name "My Custom ANT" --ticker "CUSTOM"
|
|
2089
2110
|
```
|
|
2090
2111
|
|
|
2091
2112
|
**Parameters:**
|
|
@@ -2204,6 +2225,15 @@ const state = await ant.getState();
|
|
|
2204
2225
|
"transactionId": "2rMLb2uHAyEt7jSu6bXtKx8e-jOfIf7E-DOgQnm8EtU",
|
|
2205
2226
|
"ttlSeconds": 3600
|
|
2206
2227
|
},
|
|
2228
|
+
"alice": {
|
|
2229
|
+
"transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
|
|
2230
|
+
"ttlSeconds": 900,
|
|
2231
|
+
"owner": "alice-wallet-address-123...",
|
|
2232
|
+
"displayName": "Alice's Portfolio",
|
|
2233
|
+
"logo": "avatar-tx-id-456...",
|
|
2234
|
+
"description": "Personal portfolio and blog",
|
|
2235
|
+
"keywords": ["portfolio", "personal", "blog"]
|
|
2236
|
+
},
|
|
2207
2237
|
"whitepaper": {
|
|
2208
2238
|
"transactionId": "lNjWn3LpyhKC95Kqe-x8X2qgju0j98MhucdDKK85vc4",
|
|
2209
2239
|
"ttlSeconds": 900
|
|
@@ -2273,11 +2303,19 @@ const records = await ant.getRecords();
|
|
|
2273
2303
|
"transactionId": "UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk",
|
|
2274
2304
|
"ttlSeconds": 3600
|
|
2275
2305
|
},
|
|
2306
|
+
"alice": {
|
|
2307
|
+
"transactionId": "kMk95k_3R8x_7d3wB9tEOiL5v6n8QhR_VnFCh3aeE3f",
|
|
2308
|
+
"ttlSeconds": 900,
|
|
2309
|
+
"owner": "alice-wallet-address-123...",
|
|
2310
|
+
"displayName": "Alice's Portfolio",
|
|
2311
|
+
"logo": "avatar-tx-id-456...",
|
|
2312
|
+
"description": "Personal portfolio and blog",
|
|
2313
|
+
"keywords": ["portfolio", "personal", "blog"]
|
|
2314
|
+
},
|
|
2276
2315
|
"zed": {
|
|
2277
2316
|
"transactionId": "-k7t8xMoB8hW482609Z9F4bTFMC3MnuW8bTvTyT8pFI",
|
|
2278
2317
|
"ttlSeconds": 900
|
|
2279
2318
|
},
|
|
2280
|
-
|
|
2281
2319
|
"ardrive": {
|
|
2282
2320
|
"transactionId": "-cucucachoodwedwedoiwepodiwpodiwpoidpwoiedp",
|
|
2283
2321
|
"ttlSeconds": 900
|
|
@@ -2329,9 +2367,9 @@ const { id: txId } = await ant.removeController(
|
|
|
2329
2367
|
);
|
|
2330
2368
|
```
|
|
2331
2369
|
|
|
2332
|
-
#### `setBaseNameRecord({ transactionId, ttlSeconds })`
|
|
2370
|
+
#### `setBaseNameRecord({ transactionId, ttlSeconds, owner?, displayName?, logo?, description?, keywords? })`
|
|
2333
2371
|
|
|
2334
|
-
Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io)
|
|
2372
|
+
Adds or updates the base name record for the ANT. This is the top level name of the ANT (e.g. ardrive.ar.io). Supports undername ownership delegation and metadata.
|
|
2335
2373
|
|
|
2336
2374
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2337
2375
|
|
|
@@ -2339,17 +2377,30 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2339
2377
|
// get the ant for the base name
|
|
2340
2378
|
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
|
|
2341
2379
|
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2380
|
+
|
|
2381
|
+
// Basic usage
|
|
2342
2382
|
const { id: txId } = await ant.setBaseNameRecord({
|
|
2343
2383
|
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
2344
2384
|
ttlSeconds: 3600,
|
|
2345
2385
|
});
|
|
2346
2386
|
|
|
2347
|
-
//
|
|
2387
|
+
// With ownership delegation and metadata
|
|
2388
|
+
const { id: txId } = await ant.setBaseNameRecord({
|
|
2389
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
2390
|
+
ttlSeconds: 3600,
|
|
2391
|
+
owner: 'user-wallet-address-123...', // delegate ownership to another address
|
|
2392
|
+
displayName: 'ArDrive', // display name
|
|
2393
|
+
logo: 'logo-tx-id-123...', // logo transaction ID
|
|
2394
|
+
description: 'Decentralized storage application',
|
|
2395
|
+
keywords: ['storage', 'decentralized', 'web3'],
|
|
2396
|
+
});
|
|
2397
|
+
|
|
2398
|
+
// ardrive.ar.io will now resolve to the provided transaction id and include metadata
|
|
2348
2399
|
```
|
|
2349
2400
|
|
|
2350
|
-
#### `setUndernameRecord({ undername, transactionId, ttlSeconds })`
|
|
2401
|
+
#### `setUndernameRecord({ undername, transactionId, ttlSeconds, owner?, displayName?, logo?, description?, keywords? })`
|
|
2351
2402
|
|
|
2352
|
-
Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io)
|
|
2403
|
+
Adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io). Supports undername ownership delegation and metadata.
|
|
2353
2404
|
|
|
2354
2405
|
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2355
2406
|
|
|
@@ -2358,6 +2409,8 @@ _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
|
2358
2409
|
```typescript
|
|
2359
2410
|
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
|
|
2360
2411
|
const ant = await ANT.init({ processId: arnsName.processId });
|
|
2412
|
+
|
|
2413
|
+
// Basic usage
|
|
2361
2414
|
const { id: txId } = await ant.setUndernameRecord(
|
|
2362
2415
|
{
|
|
2363
2416
|
undername: 'dapp',
|
|
@@ -2368,7 +2421,23 @@ const { id: txId } = await ant.setUndernameRecord(
|
|
|
2368
2421
|
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
2369
2422
|
);
|
|
2370
2423
|
|
|
2371
|
-
//
|
|
2424
|
+
// With ownership delegation and metadata
|
|
2425
|
+
const { id: txId } = await ant.setUndernameRecord(
|
|
2426
|
+
{
|
|
2427
|
+
undername: 'alice',
|
|
2428
|
+
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
|
|
2429
|
+
ttlSeconds: 900,
|
|
2430
|
+
owner: 'alice-wallet-address-123...', // delegate ownership to Alice
|
|
2431
|
+
displayName: "Alice's Site", // display name
|
|
2432
|
+
logo: 'avatar-tx-id-123...', // avatar/logo transaction ID
|
|
2433
|
+
description: 'Personal portfolio and blog',
|
|
2434
|
+
keywords: ['portfolio', 'personal', 'blog'],
|
|
2435
|
+
},
|
|
2436
|
+
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
|
|
2437
|
+
);
|
|
2438
|
+
|
|
2439
|
+
// dapp_ardrive.ar.io will now resolve to the provided transaction id
|
|
2440
|
+
// alice_ardrive.ar.io will be owned by Alice and include metadata
|
|
2372
2441
|
```
|
|
2373
2442
|
|
|
2374
2443
|
#### `removeUndernameRecord({ undername })`
|
|
@@ -2564,6 +2633,85 @@ const { id: txId } = await ant.removePrimaryNames({
|
|
|
2564
2633
|
});
|
|
2565
2634
|
```
|
|
2566
2635
|
|
|
2636
|
+
#### `upgrade({ reassignAffiliatedNames?, names?, arioProcessId?, antRegistryId?, skipVersionCheck?, onSigningProgress? })`
|
|
2637
|
+
|
|
2638
|
+
Upgrades an ANT by forking it to the latest version from the ANT registry and optionally reassigning ArNS names to the new process. This function first checks the version of the existing ANT, creates a new ANT using `.fork()` to the latest version, and then reassigns the ArNS names affiliated with this process to the new process.
|
|
2639
|
+
|
|
2640
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2641
|
+
|
|
2642
|
+
```typescript
|
|
2643
|
+
// Upgrade ANT and reassign all affiliated ArNS names to the new process
|
|
2644
|
+
const result = await ant.upgrade();
|
|
2645
|
+
|
|
2646
|
+
// Upgrade ANT and reassign specific ArNS names to the new process
|
|
2647
|
+
const result = await ant.upgrade({
|
|
2648
|
+
names: ['ardrive', 'example'],
|
|
2649
|
+
});
|
|
2650
|
+
|
|
2651
|
+
// with callbacks
|
|
2652
|
+
const result = await ant.upgrade({
|
|
2653
|
+
names: ['ardrive', 'example'],
|
|
2654
|
+
onSigningProgress: (event, payload) => {
|
|
2655
|
+
console.log(`${event}:`, payload);
|
|
2656
|
+
if (event === 'checking-version') {
|
|
2657
|
+
console.log(`Checking version: ${payload.antProcessId}`);
|
|
2658
|
+
}
|
|
2659
|
+
if (event === 'fetching-affiliated-names') {
|
|
2660
|
+
console.log(`Fetching affiliated names: ${payload.arioProcessId}`);
|
|
2661
|
+
}
|
|
2662
|
+
if (event === 'reassigning-name') {
|
|
2663
|
+
console.log(`Reassigning name: ${payload.name}`);
|
|
2664
|
+
}
|
|
2665
|
+
if (event === 'validating-names') {
|
|
2666
|
+
console.log(`Validating names: ${payload.names}`);
|
|
2667
|
+
}
|
|
2668
|
+
// other callback events...
|
|
2669
|
+
},
|
|
2670
|
+
});
|
|
2671
|
+
|
|
2672
|
+
console.log(`Upgraded to process: ${result.forkedProcessId}`);
|
|
2673
|
+
console.log(`Successfully reassigned names: ${result.reassignedNames}`);
|
|
2674
|
+
console.log(`Failed to reassign names: ${result.failedReassignedNames}`);
|
|
2675
|
+
```
|
|
2676
|
+
|
|
2677
|
+
**Parameters:**
|
|
2678
|
+
|
|
2679
|
+
- `reassignAffiliatedNames?: boolean` - If true, reassigns all names associated with this process to the new forked process (defaults to true when names is empty)
|
|
2680
|
+
- `names?: string[]` - Optional array of specific names to reassign (cannot be used with `reassignAffiliatedNames: true`). These names must be affiliated with this ANT on the provided ARIO process.
|
|
2681
|
+
- `arioProcessId?: string` - Optional ARIO process ID (defaults to mainnet)
|
|
2682
|
+
- `antRegistryId?: string` - Optional ANT registry process ID used to resolve the latest version (defaults to mainnet registry)
|
|
2683
|
+
- `skipVersionCheck?: boolean` - Skip checking if ANT is already latest version (defaults to false)
|
|
2684
|
+
- `onSigningProgress?: Function` - Optional progress callback for tracking upgrade steps
|
|
2685
|
+
|
|
2686
|
+
**Returns:** `Promise<{ forkedProcessId: string, reassignedNames: Record<string, AoMessageResult>, failedReassignedNames: Record<string, { id?: string; error: Error }> }>`
|
|
2687
|
+
|
|
2688
|
+
#### `transferRecord({ undername, recipient })`
|
|
2689
|
+
|
|
2690
|
+
Transfers ownership of a specific record (undername) to another address. This enables delegation of control for individual records within an ANT while maintaining the ANT owner's ultimate authority. The current record owner or ANT owner/controllers can transfer ownership.
|
|
2691
|
+
|
|
2692
|
+
_Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
|
|
2693
|
+
|
|
2694
|
+
```typescript
|
|
2695
|
+
const { id: txId } = await ant.transferRecord({
|
|
2696
|
+
undername: 'alice', // the subdomain/record to transfer
|
|
2697
|
+
recipient: 'new-owner-address-123...', // address of the new owner
|
|
2698
|
+
});
|
|
2699
|
+
|
|
2700
|
+
// alice_ardrive.ar.io is now owned by the new owner address
|
|
2701
|
+
// The new owner can update the record but not other records in the ANT
|
|
2702
|
+
```
|
|
2703
|
+
|
|
2704
|
+
**CLI Usage:**
|
|
2705
|
+
|
|
2706
|
+
```bash
|
|
2707
|
+
# Transfer ownership of a record using the CLI
|
|
2708
|
+
ar.io transfer-record \
|
|
2709
|
+
--process-id "ANT_PROCESS_ID" \
|
|
2710
|
+
--undername "alice" \
|
|
2711
|
+
--recipient "new-owner-address-123..." \
|
|
2712
|
+
--wallet-file "path/to/wallet.json"
|
|
2713
|
+
```
|
|
2714
|
+
|
|
2567
2715
|
### Configuration
|
|
2568
2716
|
|
|
2569
2717
|
ANT clients can be configured to use custom AO process. Refer to [AO Connect] for more information on how to configure the AO process to use specific AO infrastructure.
|