@ar.io/sdk 3.19.0-alpha.1 → 3.19.0-alpha.10

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.
@@ -296,6 +296,11 @@ export declare const optionMap: {
296
296
  alias: string;
297
297
  description: string;
298
298
  };
299
+ reassignAffiliatedNames: {
300
+ alias: string;
301
+ description: string;
302
+ type: string;
303
+ };
299
304
  };
300
305
  export declare const walletOptions: {
301
306
  alias: string;
@@ -390,3 +395,7 @@ export declare const setAntUndernameOptions: {
390
395
  alias: string;
391
396
  description: string;
392
397
  }[];
398
+ export declare const upgradeAntOptions: {
399
+ alias: string;
400
+ description: string;
401
+ }[];
@@ -1,6 +1,6 @@
1
1
  import { JWKInterface } from 'arweave/node/lib/wallet.js';
2
2
  import { Command, OptionValues } from 'commander';
3
- import { AOProcess, ARIOToken, AoANTRead, AoANTRegistryRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
3
+ import { ARIOToken, AoANTRead, AoANTRegistryRead, AoANTWrite, AoARIORead, AoARIOWrite, AoGetCostDetailsParams, AoRedelegateStakeParams, AoSigner, AoUpdateGatewaySettingsParams, ContractSigner, EpochInput, FundFrom, Logger, PaginationParams, SpawnANTState, WriteOptions, mARIOToken } from '../node/index.js';
4
4
  import { ANTStateCLIOptions, AddressCLIOptions, EpochCLIOptions, GetTokenCostCLIOptions, GlobalCLIOptions, InitiatorCLIOptions, JsonSerializable, PaginationCLIOptions, ProcessIdCLIOptions, RedelegateStakeCLIOptions, TransferCLIOptions, UpdateGatewaySettingsCLIOptions, WalletCLIOptions, WriteActionCLIOptions } from './types.js';
5
5
  export declare const defaultTtlSecondsCLI = 3600;
6
6
  export declare function stringifyJsonForCLIDisplay(json: JsonSerializable | unknown): string;
@@ -18,11 +18,11 @@ export declare function makeCommand<O extends OptionValues = GlobalCLIOptions>({
18
18
  options?: CommanderOption[];
19
19
  }): Command;
20
20
  export declare function arioProcessIdFromOptions({ arioProcessId, devnet, testnet, }: GlobalCLIOptions): string;
21
+ export declare function antRegistryIdFromOptions({ antRegistryProcessId, testnet, }: GlobalCLIOptions): string;
21
22
  export declare function requiredJwkFromOptions(options: WalletCLIOptions): JWKInterface;
22
23
  export declare function jwkToAddress(jwk: JWKInterface): string;
23
24
  export declare function getLoggerFromOptions(options: GlobalCLIOptions): Logger;
24
25
  export declare function readARIOFromOptions(options: GlobalCLIOptions): AoARIORead;
25
- export declare function ANTRegistryProcessFromOptions(options: ProcessIdCLIOptions): AOProcess;
26
26
  export declare function readANTRegistryFromOptions(options: ProcessIdCLIOptions): AoANTRegistryRead;
27
27
  export declare function contractSignerFromOptions(options: WalletCLIOptions): {
28
28
  signer: ContractSigner;
@@ -1,7 +1,7 @@
1
1
  import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTWrite, SortedANTRecords } from '../types/ant.js';
2
- import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
2
+ import { AoClient, AoMessageResult, AoSigner, ProcessConfiguration, UpgradeAntProgressEvent, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
3
3
  import { forkANT, spawnANT } from '../utils/ao.js';
4
- import { AOProcess } from './index.js';
4
+ import { AOProcess, Logger } from './index.js';
5
5
  type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
6
6
  strict?: boolean;
7
7
  hyperbeamUrl?: string;
@@ -25,6 +25,37 @@ export declare class ANT {
25
25
  * @param config
26
26
  */
27
27
  static fork: typeof forkANT;
28
+ /**
29
+ * Upgrade an ANT by forking it to the latest version and reassigning names.
30
+ *
31
+ *
32
+ * @param config Configuration object for the upgrade process
33
+ * @returns Promise resolving to the forked process ID and successfully reassigned names
34
+ */
35
+ static upgrade({ signer, antProcessId, reassignAffiliatedNames, names, arioProcessId, antRegistryId, ao, logger, skipVersionCheck, onSigningProgress, hyperbeamUrl, }: {
36
+ signer: AoSigner;
37
+ antProcessId: string;
38
+ arioProcessId?: string;
39
+ skipVersionCheck?: boolean;
40
+ ao?: AoClient;
41
+ logger?: Logger;
42
+ antRegistryId?: string;
43
+ hyperbeamUrl?: string;
44
+ onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
45
+ } & ({
46
+ names: string[];
47
+ reassignAffiliatedNames?: false;
48
+ } | {
49
+ names?: never;
50
+ reassignAffiliatedNames: true;
51
+ })): Promise<{
52
+ forkedProcessId: string;
53
+ reassignedNames: Record<string, AoMessageResult>;
54
+ failedReassignedNames: Record<string, {
55
+ id?: string;
56
+ error: Error;
57
+ }>;
58
+ }>;
28
59
  /**
29
60
  * Initialize overloads.
30
61
  *
@@ -36,9 +67,11 @@ export declare class ANT {
36
67
  export declare class AoANTReadable implements AoANTRead {
37
68
  protected process: AOProcess;
38
69
  readonly processId: string;
70
+ readonly hyperbeamUrl: URL | undefined;
39
71
  private strict;
40
- private hyperbeamUrl;
41
72
  private checkHyperBeamPromise;
73
+ private moduleId;
74
+ private moduleIdPromise;
42
75
  private logger;
43
76
  constructor(config: ANTConfigOptionalStrict);
44
77
  /**
@@ -53,6 +86,63 @@ export declare class AoANTReadable implements AoANTRead {
53
86
  * Returns the TX ID of the logo set for the ANT.
54
87
  */
55
88
  getLogo(): Promise<string>;
89
+ /**
90
+ * Gets the module ID of the current ANT process by querying its spawn transaction tags.
91
+ * Results are cached after the first successful fetch.
92
+ *
93
+ * @param graphqlUrl The GraphQL endpoint URL (defaults to Arweave's GraphQL endpoint)
94
+ * @param retries Number of retry attempts (defaults to 3)
95
+ * @returns Promise<string> The module ID used to spawn this ANT process
96
+ * @example
97
+ * ```ts
98
+ * const moduleId = await ant.getModuleId();
99
+ * console.log(`ANT was spawned with module: ${moduleId}`);
100
+ * ```
101
+ */
102
+ getModuleId({ graphqlUrl, retries, }?: {
103
+ graphqlUrl?: string;
104
+ retries?: number;
105
+ }): Promise<string>;
106
+ /**
107
+ * Internal method to fetch the module ID from GraphQL.
108
+ *
109
+ * TODO: this could be more like get process headers/metadata and fetch additional details.
110
+ *
111
+ * It seems like module is the only relevant one, but scheduler and authority are also available.
112
+ */
113
+ private fetchModuleId;
114
+ /**
115
+ * Gets the version string of the current ANT by matching its module ID
116
+ * with versions from the ANT registry.
117
+ *
118
+ * @param antRegistryId The ANT registry process ID (defaults to mainnet registry)
119
+ * @param graphqlUrl The GraphQL endpoint URL for getModuleId (defaults to Arweave's GraphQL endpoint)
120
+ * @param retries Number of retry attempts for getModuleId (defaults to 3)
121
+ * @returns Promise<string> The version string (e.g., "1.0.15") or "unknown" if not found
122
+ * @example
123
+ * ```ts
124
+ * const version = await ant.getVersion();
125
+ * console.log(`ANT is running version: ${version}`);
126
+ * ```
127
+ */
128
+ getVersion({ antRegistryId, graphqlUrl, retries, }?: {
129
+ antRegistryId?: string;
130
+ graphqlUrl?: string;
131
+ retries?: number;
132
+ }): Promise<string>;
133
+ /**
134
+ * Checks if the current ANT version is the latest according to the ANT registry.
135
+ *
136
+ * @param antRegistryId Optional ANT registry process ID. Defaults to mainnet ANT registry.
137
+ * @param graphqlUrl Optional GraphQL endpoint. Defaults to https://arweave.net/graphql.
138
+ * @param retries Optional number of retries for fetching module ID. Defaults to 3.
139
+ * @returns {Promise<boolean>} True if current ANT version is the latest, false otherwise.
140
+ */
141
+ isLatestVersion({ antRegistryId, graphqlUrl, retries, }?: {
142
+ antRegistryId?: string;
143
+ graphqlUrl?: string;
144
+ retries?: number;
145
+ }): Promise<boolean>;
56
146
  /**
57
147
  * @param undername @type {string} The domain name.
58
148
  * @returns {Promise<ANTRecord>} The record of the undername domain.
@@ -373,5 +463,46 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
373
463
  arioProcessId: string;
374
464
  notifyOwners?: boolean;
375
465
  }, options?: WriteOptions): Promise<AoMessageResult>;
466
+ /**
467
+ * Upgrade this ANT by forking it to the latest version and reassigning names.
468
+ *
469
+ * This is a convenience method that calls the static ANT.upgrade() method
470
+ * using this instance's process ID and signer.
471
+ *
472
+ * current version with latest ANT registry version and skip if already up to date.
473
+ *
474
+ * @param names @type {string[]} The ArNS names to reassign to the upgraded ANT.
475
+ * @param arioProcessId @type {string} The processId of the ARIO contract.
476
+ * @param antRegistryId @type {string} Optional ANT registry ID.
477
+ * @param onSigningProgress Progress callback function.
478
+ * @returns {Promise} The upgrade results.
479
+ * @example
480
+ * ```ts
481
+ * const result = await ant.upgrade({
482
+ * names: ["example", "test"],
483
+ * arioProcessId: ARIO_MAINNET_PROCESS_ID
484
+ * });
485
+ * console.log(`Upgraded to process: ${result.forkedProcessId}`);
486
+ * ```
487
+ */
488
+ upgrade(params?: {
489
+ arioProcessId?: string;
490
+ antRegistryId?: string;
491
+ skipVersionCheck?: boolean;
492
+ onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
493
+ } & ({
494
+ names: string[];
495
+ reassignAffiliatedNames?: false;
496
+ } | {
497
+ names?: never;
498
+ reassignAffiliatedNames?: true;
499
+ })): Promise<{
500
+ forkedProcessId: string;
501
+ reassignedNames: Record<string, AoMessageResult>;
502
+ failedReassignedNames: Record<string, {
503
+ id?: string;
504
+ error: Error;
505
+ }>;
506
+ }>;
376
507
  }
377
508
  export {};
@@ -155,7 +155,7 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
155
155
  * @returns {Promise<AoArNSNameData[]>} The ARNS names associated with the address
156
156
  */
157
157
  getArNSRecordsForAddress(params: PaginationParams<AoArNSNameDataWithName> & {
158
- antRegistryId?: string;
158
+ antRegistryProcessId?: string;
159
159
  address: WalletAddress;
160
160
  }): Promise<PaginationResult<AoArNSNameDataWithName>>;
161
161
  }
@@ -20,6 +20,7 @@ export declare const ARIO_DEVNET_PROCESS_ID = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelV
20
20
  export declare const arioDevnetProcessId = "GaQrvEMKBpkjofgnBi_B3IgIDmY_XYelVLB6GcRGrHc";
21
21
  export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddICmtQSBIoPdiA";
22
22
  export declare const ARIO_MAINNET_PROCESS_ID = "qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE";
23
+ export declare const ANT_REGISTRY_TESTNET_ID = "RR0vheYqtsKuJCWh6xj0beE35tjaEug5cejMw9n2aa8";
23
24
  export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
24
25
  export declare const MARIO_PER_ARIO = 1000000;
25
26
  /**
@@ -14,7 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import { z } from 'zod';
17
- import { AoWriteAction, WalletAddress } from './common.js';
17
+ import { AoMessageResult, AoWriteAction, UpgradeAntProgressEvent, WalletAddress } from './common.js';
18
18
  /**
19
19
  * example error:
20
20
  * {
@@ -264,6 +264,20 @@ export interface AoANTRead {
264
264
  }, opts?: AntReadOptions): Promise<number>;
265
265
  getBalances(opts?: AntReadOptions): Promise<Record<WalletAddress, number>>;
266
266
  getHandlers(): Promise<AoANTHandler[]>;
267
+ getModuleId(opts?: {
268
+ graphqlUrl?: string;
269
+ retries?: number;
270
+ }): Promise<string>;
271
+ getVersion(opts?: {
272
+ antRegistryId?: string;
273
+ graphqlUrl?: string;
274
+ retries?: number;
275
+ }): Promise<string>;
276
+ isLatestVersion(opts?: {
277
+ antRegistryId?: string;
278
+ graphqlUrl?: string;
279
+ retries?: number;
280
+ }): Promise<boolean>;
267
281
  }
268
282
  export interface AoANTWrite extends AoANTRead {
269
283
  transfer: AoWriteAction<{
@@ -320,6 +334,25 @@ export interface AoANTWrite extends AoANTRead {
320
334
  arioProcessId: string;
321
335
  notifyOwners?: boolean;
322
336
  }>;
337
+ upgrade(params?: {
338
+ arioProcessId?: string;
339
+ antRegistryId?: string;
340
+ skipVersionCheck?: boolean;
341
+ onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
342
+ } & ({
343
+ names: string[];
344
+ reassignAffiliatedNames?: false;
345
+ } | {
346
+ names?: never;
347
+ reassignAffiliatedNames?: true;
348
+ })): Promise<{
349
+ forkedProcessId: string;
350
+ reassignedNames: Record<string, AoMessageResult>;
351
+ failedReassignedNames: Record<string, {
352
+ id?: string;
353
+ error: Error;
354
+ }>;
355
+ }>;
323
356
  }
324
357
  export type AoANTSetBaseNameRecordParams = {
325
358
  transactionId: string;
@@ -126,6 +126,37 @@ export type SpawnAntProgressEvent = {
126
126
  owner: WalletAddress;
127
127
  };
128
128
  };
129
+ export type UpgradeAntProgressEvent = SpawnAntProgressEvent & {
130
+ 'checking-version': {
131
+ antProcessId: string;
132
+ antRegistryId: string;
133
+ };
134
+ 'fetching-affiliated-names': {
135
+ arioProcessId: string;
136
+ antProcessId: string;
137
+ };
138
+ 'reassigning-name': {
139
+ name: string;
140
+ arioProcessId: string;
141
+ antProcessId: string;
142
+ };
143
+ 'validating-names': {
144
+ arioProcessId: string;
145
+ antProcessId: string;
146
+ names: string[];
147
+ };
148
+ 'failed-to-reassign-name': {
149
+ name: string;
150
+ arioProcessId: string;
151
+ antProcessId: string;
152
+ error?: Error;
153
+ };
154
+ 'successfully-reassigned-name': {
155
+ name: string;
156
+ arioProcessId: string;
157
+ antProcessId: string;
158
+ };
159
+ };
129
160
  export type BuyArNSNameProgressEvents = SpawnAntProgressEvent & {
130
161
  'buying-name': AoBuyRecordParams;
131
162
  };
@@ -24,10 +24,14 @@ import { ANTRecords, AoANTState, HyperBeamANTState, SortedANTRecords } from '../
24
24
  * @param antRecords - The ANT records to sort.
25
25
  */
26
26
  export declare const sortANTRecords: (antRecords: ANTRecords) => SortedANTRecords;
27
+ /**
28
+ * @deprecated - this is no longer necessary because HyperBeam now uses the AoANTState type
29
+ */
27
30
  export declare const isHyperBeamANTState: (state: any) => state is HyperBeamANTState;
28
31
  /**
29
32
  * Convert HyperBeam serialized ANT state to backwards compatible format.
30
33
  *
34
+ * @deprecated - this is no longer necessary because HyperBeam now uses the AOANTState type
31
35
  * @param state - The HyperBeam serialized ANT state.
32
36
  */
33
37
  export declare const convertHyperBeamStateToAoANTState: (initialState: HyperBeamANTState) => AoANTState;
@@ -30,9 +30,10 @@ export type SpawnANTParams = {
30
30
  onSigningProgress?: (name: keyof SpawnAntProgressEvent, payload: SpawnAntProgressEvent[keyof SpawnAntProgressEvent]) => void;
31
31
  };
32
32
  export declare function spawnANT({ signer, module, ao, scheduler, state, tags, antRegistryId, logger, authority, onSigningProgress, }: SpawnANTParams): Promise<ProcessId>;
33
- export declare function forkANT({ signer, antProcessId, logger, ao, antRegistryId, onSigningProgress, }: {
33
+ export declare function forkANT({ signer, antProcessId, logger, ao, moduleId, antRegistryId, onSigningProgress, }: {
34
34
  signer: AoSigner;
35
35
  antProcessId: string;
36
+ moduleId?: string;
36
37
  logger?: Logger;
37
38
  ao?: AoClient;
38
39
  antRegistryId?: string;
@@ -3,7 +3,7 @@ import { ILogger } from '../common/logger.js';
3
3
  import { AoANTRegistryRead } from '../types/ant-registry.js';
4
4
  import { AoARIORead, AoArNSNameData, AoClient, ProcessId, WalletAddress } from '../types/index.js';
5
5
  /**
6
- * @beta This API is in beta and may change in the future.
6
+ * @deprecated Use getArNSRecordsForAddress instead
7
7
  */
8
8
  export declare const getANTProcessesOwnedByWallet: ({ address, registry, }: {
9
9
  address: WalletAddress;
@@ -13,4 +13,4 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const version = "3.18.2";
16
+ export declare const version = "3.19.0-alpha.9";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ar.io/sdk",
3
- "version": "3.19.0-alpha.1",
3
+ "version": "3.19.0-alpha.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ar-io/ar-io-sdk.git"