@ar.io/sdk 3.18.3 → 3.19.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.
- package/bundles/web.bundle.min.js +89 -73
- package/lib/cjs/cli/cli.js +6 -0
- package/lib/cjs/cli/commands/antCommands.js +33 -0
- package/lib/cjs/cli/options.js +2 -1
- package/lib/cjs/cli/utils.js +11 -11
- package/lib/cjs/common/ant.js +315 -1
- package/lib/cjs/common/io.js +2 -2
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/utils/ant.js +4 -0
- package/lib/cjs/utils/ao.js +35 -1
- package/lib/cjs/utils/processes.js +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +8 -2
- package/lib/esm/cli/commands/antCommands.js +33 -1
- package/lib/esm/cli/options.js +1 -0
- package/lib/esm/cli/utils.js +11 -11
- package/lib/esm/common/ant.js +317 -3
- package/lib/esm/common/io.js +2 -2
- package/lib/esm/constants.js +1 -0
- package/lib/esm/utils/ant.js +4 -0
- package/lib/esm/utils/ao.js +35 -2
- package/lib/esm/utils/processes.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +5 -0
- package/lib/types/cli/options.d.ts +4 -0
- package/lib/types/cli/utils.d.ts +2 -2
- package/lib/types/common/ant.d.ts +133 -3
- package/lib/types/common/io.d.ts +1 -1
- package/lib/types/constants.d.ts +1 -0
- package/lib/types/types/ant.d.ts +26 -1
- package/lib/types/types/common.d.ts +15 -0
- package/lib/types/utils/ant.d.ts +4 -0
- package/lib/types/utils/ao.d.ts +8 -0
- package/lib/types/utils/processes.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -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';
|
|
3
|
-
import { spawnANT } from '../utils/ao.js';
|
|
4
|
-
import { AOProcess } from './index.js';
|
|
2
|
+
import { AoClient, AoMessageResult, AoSigner, ProcessConfiguration, UpgradeAntProgressEvent, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
3
|
+
import { forkANT, spawnANT } from '../utils/ao.js';
|
|
4
|
+
import { AOProcess, Logger } from './index.js';
|
|
5
5
|
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
6
6
|
strict?: boolean;
|
|
7
7
|
hyperbeamUrl?: string;
|
|
@@ -19,6 +19,42 @@ export declare class ANT {
|
|
|
19
19
|
* Spawn a new ANT.
|
|
20
20
|
*/
|
|
21
21
|
static spawn: typeof spawnANT;
|
|
22
|
+
/**
|
|
23
|
+
* Fork an ANT to a new process.
|
|
24
|
+
*
|
|
25
|
+
* @param config
|
|
26
|
+
*/
|
|
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, // if true, will reassign all affiliated names, otherwise will use the names parameter
|
|
36
|
+
names, arioProcessId, antRegistryId, ao, logger, skipVersionCheck, onSigningProgress, hyperbeamUrl, }: {
|
|
37
|
+
signer: AoSigner;
|
|
38
|
+
antProcessId: string;
|
|
39
|
+
names?: string[];
|
|
40
|
+
reassignAffiliatedNames?: boolean;
|
|
41
|
+
arioProcessId?: string;
|
|
42
|
+
skipVersionCheck?: boolean;
|
|
43
|
+
ao?: AoClient;
|
|
44
|
+
logger?: Logger;
|
|
45
|
+
antRegistryId?: string;
|
|
46
|
+
hyperbeamUrl?: string;
|
|
47
|
+
onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
forkedProcessId: string;
|
|
50
|
+
reassignedNames: string[];
|
|
51
|
+
failedReassignedNames: string[];
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* Initialize overloads.
|
|
55
|
+
*
|
|
56
|
+
* @param config
|
|
57
|
+
*/
|
|
22
58
|
static init(config: ANTConfigNoSigner): AoANTRead;
|
|
23
59
|
static init(config: ANTConfigWithSigner): AoANTWrite;
|
|
24
60
|
}
|
|
@@ -28,6 +64,8 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
28
64
|
private strict;
|
|
29
65
|
private hyperbeamUrl;
|
|
30
66
|
private checkHyperBeamPromise;
|
|
67
|
+
private moduleId;
|
|
68
|
+
private moduleIdPromise;
|
|
31
69
|
private logger;
|
|
32
70
|
constructor(config: ANTConfigOptionalStrict);
|
|
33
71
|
/**
|
|
@@ -42,6 +80,63 @@ export declare class AoANTReadable implements AoANTRead {
|
|
|
42
80
|
* Returns the TX ID of the logo set for the ANT.
|
|
43
81
|
*/
|
|
44
82
|
getLogo(): Promise<string>;
|
|
83
|
+
/**
|
|
84
|
+
* Gets the module ID of the current ANT process by querying its spawn transaction tags.
|
|
85
|
+
* Results are cached after the first successful fetch.
|
|
86
|
+
*
|
|
87
|
+
* @param graphqlUrl The GraphQL endpoint URL (defaults to Arweave's GraphQL endpoint)
|
|
88
|
+
* @param retries Number of retry attempts (defaults to 3)
|
|
89
|
+
* @returns Promise<string> The module ID used to spawn this ANT process
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* const moduleId = await ant.getModuleId();
|
|
93
|
+
* console.log(`ANT was spawned with module: ${moduleId}`);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
getModuleId({ graphqlUrl, retries, }?: {
|
|
97
|
+
graphqlUrl?: string;
|
|
98
|
+
retries?: number;
|
|
99
|
+
}): Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Internal method to fetch the module ID from GraphQL.
|
|
102
|
+
*
|
|
103
|
+
* TODO: this could be more like get process headers/metadata and fetch additional details.
|
|
104
|
+
*
|
|
105
|
+
* It seems like module is the only relevant one, but scheduler and authority are also available.
|
|
106
|
+
*/
|
|
107
|
+
private fetchModuleId;
|
|
108
|
+
/**
|
|
109
|
+
* Gets the version string of the current ANT by matching its module ID
|
|
110
|
+
* with versions from the ANT registry.
|
|
111
|
+
*
|
|
112
|
+
* @param antRegistryId The ANT registry process ID (defaults to mainnet registry)
|
|
113
|
+
* @param graphqlUrl The GraphQL endpoint URL for getModuleId (defaults to Arweave's GraphQL endpoint)
|
|
114
|
+
* @param retries Number of retry attempts for getModuleId (defaults to 3)
|
|
115
|
+
* @returns Promise<string> The version string (e.g., "1.0.15") or "unknown" if not found
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const version = await ant.getVersion();
|
|
119
|
+
* console.log(`ANT is running version: ${version}`);
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
getVersion({ antRegistryId, graphqlUrl, retries, }?: {
|
|
123
|
+
antRegistryId?: string;
|
|
124
|
+
graphqlUrl?: string;
|
|
125
|
+
retries?: number;
|
|
126
|
+
}): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Checks if the current ANT version is the latest according to the ANT registry.
|
|
129
|
+
*
|
|
130
|
+
* @param antRegistryId Optional ANT registry process ID. Defaults to mainnet ANT registry.
|
|
131
|
+
* @param graphqlUrl Optional GraphQL endpoint. Defaults to https://arweave.net/graphql.
|
|
132
|
+
* @param retries Optional number of retries for fetching module ID. Defaults to 3.
|
|
133
|
+
* @returns {Promise<boolean>} True if current ANT version is the latest, false otherwise.
|
|
134
|
+
*/
|
|
135
|
+
isLatestVersion({ antRegistryId, graphqlUrl, retries, }?: {
|
|
136
|
+
antRegistryId?: string;
|
|
137
|
+
graphqlUrl?: string;
|
|
138
|
+
retries?: number;
|
|
139
|
+
}): Promise<boolean>;
|
|
45
140
|
/**
|
|
46
141
|
* @param undername @type {string} The domain name.
|
|
47
142
|
* @returns {Promise<ANTRecord>} The record of the undername domain.
|
|
@@ -362,5 +457,40 @@ export declare class AoANTWriteable extends AoANTReadable implements AoANTWrite
|
|
|
362
457
|
arioProcessId: string;
|
|
363
458
|
notifyOwners?: boolean;
|
|
364
459
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
460
|
+
/**
|
|
461
|
+
* Upgrade this ANT by forking it to the latest version and reassigning names.
|
|
462
|
+
*
|
|
463
|
+
* This is a convenience method that calls the static ANT.upgrade() method
|
|
464
|
+
* using this instance's process ID and signer.
|
|
465
|
+
*
|
|
466
|
+
* TODO: Add version checking by implementing a getVersion API on ANTs to compare
|
|
467
|
+
* current version with latest ANT registry version and skip if already up to date.
|
|
468
|
+
*
|
|
469
|
+
* @param names @type {string[]} The ArNS names to reassign to the upgraded ANT.
|
|
470
|
+
* @param arioProcessId @type {string} The processId of the ARIO contract.
|
|
471
|
+
* @param antRegistryId @type {string} Optional ANT registry ID.
|
|
472
|
+
* @param onSigningProgress Progress callback function.
|
|
473
|
+
* @returns {Promise} The upgrade results.
|
|
474
|
+
* @example
|
|
475
|
+
* ```ts
|
|
476
|
+
* const result = await ant.upgrade({
|
|
477
|
+
* names: ["example", "test"],
|
|
478
|
+
* arioProcessId: ARIO_MAINNET_PROCESS_ID
|
|
479
|
+
* });
|
|
480
|
+
* console.log(`Upgraded to process: ${result.forkedProcessId}`);
|
|
481
|
+
* ```
|
|
482
|
+
*/
|
|
483
|
+
upgrade({ names, reassignAffiliatedNames, arioProcessId, antRegistryId, onSigningProgress, skipVersionCheck, }: {
|
|
484
|
+
names?: string[];
|
|
485
|
+
arioProcessId?: string;
|
|
486
|
+
antRegistryId?: string;
|
|
487
|
+
skipVersionCheck?: boolean;
|
|
488
|
+
reassignAffiliatedNames?: boolean;
|
|
489
|
+
onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
|
|
490
|
+
}): Promise<{
|
|
491
|
+
forkedProcessId: string;
|
|
492
|
+
reassignedNames: string[];
|
|
493
|
+
failedReassignedNames: string[];
|
|
494
|
+
}>;
|
|
365
495
|
}
|
|
366
496
|
export {};
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -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
|
-
|
|
158
|
+
antRegistryId?: string;
|
|
159
159
|
address: WalletAddress;
|
|
160
160
|
}): Promise<PaginationResult<AoArNSNameDataWithName>>;
|
|
161
161
|
}
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -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
|
/**
|
package/lib/types/types/ant.d.ts
CHANGED
|
@@ -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 { 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,17 @@ export interface AoANTWrite extends AoANTRead {
|
|
|
320
334
|
arioProcessId: string;
|
|
321
335
|
notifyOwners?: boolean;
|
|
322
336
|
}>;
|
|
337
|
+
upgrade(params: {
|
|
338
|
+
names?: string[];
|
|
339
|
+
reassignAffiliatedNames?: boolean;
|
|
340
|
+
arioProcessId?: string;
|
|
341
|
+
antRegistryId?: string;
|
|
342
|
+
onSigningProgress?: (name: keyof UpgradeAntProgressEvent, payload: UpgradeAntProgressEvent[keyof UpgradeAntProgressEvent]) => void;
|
|
343
|
+
}): Promise<{
|
|
344
|
+
forkedProcessId: string;
|
|
345
|
+
reassignedNames: string[];
|
|
346
|
+
failedReassignedNames: string[];
|
|
347
|
+
}>;
|
|
323
348
|
}
|
|
324
349
|
export type AoANTSetBaseNameRecordParams = {
|
|
325
350
|
transactionId: string;
|
|
@@ -126,6 +126,21 @@ 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
|
+
};
|
|
129
144
|
export type BuyArNSNameProgressEvents = SpawnAntProgressEvent & {
|
|
130
145
|
'buying-name': AoBuyRecordParams;
|
|
131
146
|
};
|
package/lib/types/utils/ant.d.ts
CHANGED
|
@@ -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;
|
package/lib/types/utils/ao.d.ts
CHANGED
|
@@ -30,6 +30,14 @@ 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, }: {
|
|
34
|
+
signer: AoSigner;
|
|
35
|
+
antProcessId: string;
|
|
36
|
+
logger?: Logger;
|
|
37
|
+
ao?: AoClient;
|
|
38
|
+
antRegistryId?: string;
|
|
39
|
+
onSigningProgress?: (name: keyof SpawnAntProgressEvent, payload: SpawnAntProgressEvent[keyof SpawnAntProgressEvent]) => void;
|
|
40
|
+
}): Promise<string>;
|
|
33
41
|
/**
|
|
34
42
|
* @deprecated
|
|
35
43
|
* Direct Evals are not encouraged when dealing with ANTs.
|
|
@@ -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
|
-
* @
|
|
6
|
+
* @beta This API is in beta and may change in the future.
|
|
7
7
|
*/
|
|
8
8
|
export declare const getANTProcessesOwnedByWallet: ({ address, registry, }: {
|
|
9
9
|
address: WalletAddress;
|
package/lib/types/version.d.ts
CHANGED