@ar.io/sdk 3.21.0 → 3.22.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.
package/README.md CHANGED
@@ -2125,9 +2125,76 @@ ar.io spawn-ant --wallet-file wallet.json --module FKtQtOOtlcWCW2pXrwWFiCSlnuewM
2125
2125
 
2126
2126
  ### Versions
2127
2127
 
2128
+ #### `getModuleId({ graphqlUrl?, retries? })`
2129
+
2130
+ Gets the module ID of the current ANT process by querying its spawn transaction tags. Results are cached after the first successful fetch.
2131
+
2132
+ ```typescript
2133
+ const moduleId = await ant.getModuleId();
2134
+ console.log(`ANT was spawned with module: ${moduleId}`);
2135
+
2136
+ // With custom GraphQL URL and retries
2137
+ const moduleId = await ant.getModuleId({
2138
+ graphqlUrl: 'https://arweave.net/graphql',
2139
+ retries: 5
2140
+ });
2141
+ ```
2142
+
2143
+ <details>
2144
+ <summary>Output</summary>
2145
+
2146
+ ```json
2147
+ "FKtQtOOtlcWCW2pXrwWFiCSlnuewMZOHCzhulVkyqBE"
2148
+ ```
2149
+
2150
+ </details>
2151
+
2152
+ #### `getVersion({ antRegistryId?, graphqlUrl?, retries? })`
2153
+
2154
+ Gets the version string of the current ANT by matching its module ID with versions from the ANT registry.
2155
+
2156
+ ```typescript
2157
+ const version = await ant.getVersion();
2158
+ console.log(`ANT is running version: ${version}`);
2159
+
2160
+ // With custom ANT registry
2161
+ const version = await ant.getVersion({
2162
+ antRegistryId: 'custom-ant-registry-id'
2163
+ });
2164
+ ```
2165
+
2166
+ <details>
2167
+ <summary>Output</summary>
2168
+
2169
+ ```json
2170
+ "23"
2171
+ ```
2172
+
2173
+ </details>
2174
+
2175
+ #### `isLatestVersion({ antRegistryId?, graphqlUrl?, retries? })`
2176
+
2177
+ Checks if the current ANT version is the latest according to the ANT registry.
2178
+
2179
+ ```typescript
2180
+ const isLatest = await ant.isLatestVersion();
2181
+ if (!isLatest) {
2182
+ console.log('ANT can be upgraded to the latest version');
2183
+ }
2184
+ ```
2185
+
2186
+ <details>
2187
+ <summary>Output</summary>
2188
+
2189
+ ```json
2190
+ true
2191
+ ```
2192
+
2193
+ </details>
2194
+
2128
2195
  #### `getANTVersions`
2129
2196
 
2130
- Returns the full array of available ANT versions and the latest version from the ANT registry.
2197
+ Static method that returns the full array of available ANT versions and the latest version from the ANT registry.
2131
2198
 
2132
2199
  ```typescript
2133
2200
  import { ANT } from '@ar.io/sdk';
@@ -2155,12 +2222,17 @@ Result:
2155
2222
 
2156
2223
  #### `getLatestANTVersion()`
2157
2224
 
2158
- Returns the latest ANT version from the ANT registry.
2225
+ Static method that returns the latest ANT version from the ANT registry.
2159
2226
 
2160
2227
  ```typescript
2161
2228
  import { ANT } from '@ar.io/sdk';
2162
2229
 
2163
2230
  // Get the latest ANT version
2231
+ import { ANT } from '@ar.io/sdk';
2232
+
2233
+ // Get all available ANT versions
2234
+ const antVersions = ANT.versions;
2235
+ const versions = await antVersions.getANTVersions();
2164
2236
  const latestVersion = await antVersions.getLatestANTVersion();
2165
2237
  ```
2166
2238
 
@@ -2307,6 +2379,40 @@ const owner = await ant.getOwner();
2307
2379
 
2308
2380
  </details>
2309
2381
 
2382
+ #### `getName()`
2383
+
2384
+ Returns the name of the ANT (not the same as ArNS name).
2385
+
2386
+ ```typescript
2387
+ const name = await ant.getName();
2388
+ ```
2389
+
2390
+ <details>
2391
+ <summary>Output</summary>
2392
+
2393
+ ```json
2394
+ "ArDrive"
2395
+ ```
2396
+
2397
+ </details>
2398
+
2399
+ #### `getTicker()`
2400
+
2401
+ Returns the ticker symbol of the ANT.
2402
+
2403
+ ```typescript
2404
+ const ticker = await ant.getTicker();
2405
+ ```
2406
+
2407
+ <details>
2408
+ <summary>Output</summary>
2409
+
2410
+ ```json
2411
+ "ANT-ARDRIVE"
2412
+ ```
2413
+
2414
+ </details>
2415
+
2310
2416
  #### `getControllers()`
2311
2417
 
2312
2418
  Returns the controllers of the configured ANT process.
@@ -2363,6 +2469,72 @@ const records = await ant.getRecords();
2363
2469
 
2364
2470
  </details>
2365
2471
 
2472
+ #### `getRecord({ undername })`
2473
+
2474
+ Returns a specific record by its undername.
2475
+
2476
+ ```typescript
2477
+ const record = await ant.getRecord({ undername: 'dapp' });
2478
+ ```
2479
+
2480
+ <details>
2481
+ <summary>Output</summary>
2482
+
2483
+ ```json
2484
+ {
2485
+ "transactionId": "432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
2486
+ "ttlSeconds": 900,
2487
+ "owner": "alice-wallet-address-123...",
2488
+ "displayName": "Alice's Site",
2489
+ "logo": "avatar-tx-id-456...",
2490
+ "description": "Personal portfolio and blog",
2491
+ "keywords": ["portfolio", "personal", "blog"]
2492
+ }
2493
+ ```
2494
+
2495
+ </details>
2496
+
2497
+ ### Balances
2498
+
2499
+ #### `getBalances()`
2500
+
2501
+ Returns all token balances for the ANT.
2502
+
2503
+ ```typescript
2504
+ const balances = await ant.getBalances();
2505
+ ```
2506
+
2507
+ <details>
2508
+ <summary>Output</summary>
2509
+
2510
+ ```json
2511
+ {
2512
+ "ccp3blG__gKUvG3hsGC2u06aDmqv4CuhuDJGOIg0jw4": 1,
2513
+ "aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f": 0
2514
+ }
2515
+ ```
2516
+
2517
+ </details>
2518
+
2519
+ #### `getBalance({ address })`
2520
+
2521
+ Returns the balance of a specific address.
2522
+
2523
+ ```typescript
2524
+ const balance = await ant.getBalance({
2525
+ address: 'ccp3blG__gKUvG3hsGC2u06aDmqv4CuhuDJGOIg0jw4',
2526
+ });
2527
+ ```
2528
+
2529
+ <details>
2530
+ <summary>Output</summary>
2531
+
2532
+ ```json
2533
+ 1
2534
+ ```
2535
+
2536
+ </details>
2537
+
2366
2538
  ### Transfer
2367
2539
 
2368
2540
  #### `transfer({ target })`
@@ -2381,14 +2553,14 @@ const { id: txId } = await ant.transfer(
2381
2553
 
2382
2554
  ### Controllers
2383
2555
 
2384
- #### `setController({ controller })`
2556
+ #### `addController({ controller })`
2385
2557
 
2386
2558
  Adds a new controller to the list of approved controllers on the ANT. Controllers can set records and change the ticker and name of the ANT process.
2387
2559
 
2388
2560
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2389
2561
 
2390
2562
  ```typescript
2391
- const { id: txId } = await ant.setController(
2563
+ const { id: txId } = await ant.addController(
2392
2564
  { controller: 'aGzM_yjralacHIUo8_nQXMbh9l1cy0aksiL_x9M359f' },
2393
2565
  // optional additional tags
2394
2566
  { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
@@ -2595,7 +2767,7 @@ Sets the keywords of the ANT process.
2595
2767
  _Note: Requires `signer` to be provided on `ANT.init` to sign the transaction._
2596
2768
 
2597
2769
  ```typescript
2598
- const { id: txId } = await ant.setDescription(
2770
+ const { id: txId } = await ant.setKeywords(
2599
2771
  { keywords: ['Game', 'FPS', 'AO'] },
2600
2772
  // optional tags
2601
2773
  { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
@@ -2841,6 +3013,53 @@ const recordAfter = await ant.getRecord({ undername: 'alice' });
2841
3013
  console.log(recordAfter.owner); // undefined (controlled by ANT owner again)
2842
3014
  ```
2843
3015
 
3016
+ ### Static Methods
3017
+
3018
+ #### `ANT.fork({ signer, antProcessId, module?, scheduler?, state?, ao?, antRegistryId?, onSigningProgress? })`
3019
+
3020
+ Forks an existing ANT process to create a new one with the same state but potentially a different module. This is used for upgrading ANTs to new versions.
3021
+
3022
+ ```typescript
3023
+ const newProcessId = await ANT.fork({
3024
+ signer: new ArweaveSigner(jwk),
3025
+ antProcessId: 'existing-ant-process-id',
3026
+ // Optional: specify a specific module ID, defaults to latest from registry
3027
+ module: 'new-module-id',
3028
+ onSigningProgress: (event, payload) => {
3029
+ console.log(`Fork progress: ${event}`);
3030
+ },
3031
+ });
3032
+
3033
+ console.log(`Forked ANT to new process: ${newProcessId}`);
3034
+ ```
3035
+
3036
+ #### `ANT.upgrade({ signer, antProcessId, reassignAffiliatedNames?, names?, arioProcessId?, antRegistryId?, ao?, logger?, skipVersionCheck?, onSigningProgress?, hyperbeamUrl? })`
3037
+
3038
+ Static method to upgrade an ANT by forking it to the latest version and reassigning names.
3039
+
3040
+ ```typescript
3041
+ // Upgrade and reassign all affiliated names
3042
+ const result = await ANT.upgrade({
3043
+ signer: new ArweaveSigner(jwk),
3044
+ antProcessId: 'existing-ant-process-id',
3045
+ reassignAffiliatedNames: true,
3046
+ arioProcessId: ARIO_MAINNET_PROCESS_ID
3047
+ });
3048
+
3049
+ // Upgrade and reassign specific names
3050
+ const result = await ANT.upgrade({
3051
+ signer: new ArweaveSigner(jwk),
3052
+ antProcessId: 'existing-ant-process-id',
3053
+ names: ['ardrive', 'example'],
3054
+ reassignAffiliatedNames: false,
3055
+ arioProcessId: ARIO_MAINNET_PROCESS_ID
3056
+ });
3057
+
3058
+ console.log(`Upgraded to process: ${result.forkedProcessId}`);
3059
+ console.log(`Successfully reassigned names: ${Object.keys(result.reassignedNames)}`);
3060
+ console.log(`Failed reassignments: ${Object.keys(result.failedReassignedNames)}`);
3061
+ ```
3062
+
2844
3063
  ## Token Conversion
2845
3064
 
2846
3065
  The ARIO process stores all values as mARIO (milli-ARIO) to avoid floating-point arithmetic issues. The SDK provides an `ARIOToken` and `mARIOToken` classes to handle the conversion between ARIO and mARIO, along with rounding logic for precision.