@ar.io/sdk 3.15.1 → 3.16.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/README.md +72 -1
- package/bundles/web.bundle.min.js +93 -93
- package/lib/cjs/cli/cli.js +1 -0
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +23 -5
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +2 -3
- package/lib/cjs/common/ant.js +12 -1
- package/lib/cjs/common/io.js +20 -0
- package/lib/cjs/constants.js +6 -0
- package/lib/cjs/utils/ao.js +155 -40
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/cli.js +1 -0
- package/lib/esm/cli/commands/arnsPurchaseCommands.js +23 -5
- package/lib/esm/cli/commands/gatewayWriteCommands.js +2 -3
- package/lib/esm/common/ant.js +13 -2
- package/lib/esm/common/io.js +20 -0
- package/lib/esm/constants.js +6 -0
- package/lib/esm/utils/ao.js +156 -41
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +0 -15
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +1 -1
- package/lib/types/common/ant.d.ts +12 -2
- package/lib/types/common/io.d.ts +4 -2
- package/lib/types/constants.d.ts +6 -0
- package/lib/types/types/common.d.ts +21 -1
- package/lib/types/types/io.d.ts +1 -1
- package/lib/types/utils/ao.d.ts +11 -2
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/esm/utils/ao.js
CHANGED
|
@@ -16,17 +16,45 @@
|
|
|
16
16
|
import { ArconnectSigner, DataItem, createData } from '@dha-team/arbundles';
|
|
17
17
|
import { connect, createDataItemSigner } from '@permaweb/aoconnect';
|
|
18
18
|
import { z } from 'zod';
|
|
19
|
+
import { ANTRegistry } from '../common/ant-registry.js';
|
|
20
|
+
import { ANTVersions } from '../common/ant-versions.js';
|
|
19
21
|
import { defaultArweave } from '../common/arweave.js';
|
|
20
22
|
import { AOProcess, Logger } from '../common/index.js';
|
|
21
|
-
import { ANT_LUA_ID, ANT_REGISTRY_ID,
|
|
23
|
+
import { ANT_LUA_ID, ANT_REGISTRY_ID, AO_AUTHORITY, DEFAULT_SCHEDULER_ID, } from '../constants.js';
|
|
22
24
|
import { SpawnANTStateSchema } from '../types/ant.js';
|
|
23
25
|
import { parseSchemaResult } from './schema.js';
|
|
24
|
-
export async function spawnANT({ signer, module
|
|
26
|
+
export async function spawnANT({ signer, module, ao = connect({
|
|
25
27
|
MODE: 'legacy',
|
|
26
|
-
}), scheduler = DEFAULT_SCHEDULER_ID, state, antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY,
|
|
28
|
+
}), scheduler = DEFAULT_SCHEDULER_ID, state, antRegistryId = ANT_REGISTRY_ID, logger = Logger.default, authority = AO_AUTHORITY, onSigningProgress = (name, payload) => {
|
|
29
|
+
logger.debug('Signing progress', { name, payload });
|
|
30
|
+
}, }) {
|
|
27
31
|
if (state) {
|
|
28
32
|
parseSchemaResult(SpawnANTStateSchema, state);
|
|
29
33
|
}
|
|
34
|
+
let version;
|
|
35
|
+
if (module === undefined) {
|
|
36
|
+
const antRegistry = ANTVersions.init({
|
|
37
|
+
process: new AOProcess({
|
|
38
|
+
processId: antRegistryId,
|
|
39
|
+
ao,
|
|
40
|
+
logger,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
const { moduleId: latestAntModule, version: latestVersion } = await antRegistry.getLatestANTVersion();
|
|
44
|
+
logger.debug('Spawning new ANT with latest module from ANT registry', {
|
|
45
|
+
moduleId: latestAntModule,
|
|
46
|
+
version,
|
|
47
|
+
antRegistryId,
|
|
48
|
+
});
|
|
49
|
+
module = latestAntModule;
|
|
50
|
+
version = latestVersion;
|
|
51
|
+
}
|
|
52
|
+
onSigningProgress?.('spawning-ant', {
|
|
53
|
+
moduleId: module,
|
|
54
|
+
antRegistryId,
|
|
55
|
+
version,
|
|
56
|
+
state,
|
|
57
|
+
});
|
|
30
58
|
const processId = await ao.spawn({
|
|
31
59
|
module,
|
|
32
60
|
scheduler,
|
|
@@ -44,64 +72,150 @@ export async function spawnANT({ signer, module = AOS_MODULE_ID, ao = connect({
|
|
|
44
72
|
},
|
|
45
73
|
],
|
|
46
74
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Note: if we are given a state, ensure the ANT was initialized with it
|
|
77
|
+
* there is a bug in the ANT source where we try to parse the empty default
|
|
78
|
+
* 'Data' string as JSON that causes the Invalid-Boot-Notice error, even though
|
|
79
|
+
* the ANT was initialized with the default state set by the ANT source code.
|
|
80
|
+
*
|
|
81
|
+
* Reference: https://github.com/ar-io/ar-io-ant-process/blob/b89018ffcce079add2e90e7ab82d0bbc9b671346/src/common/main.lua#L355-L358
|
|
82
|
+
*/
|
|
83
|
+
if (state !== undefined) {
|
|
84
|
+
let bootRes;
|
|
85
|
+
let attempts = 0;
|
|
86
|
+
while (attempts < 5 && bootRes === undefined) {
|
|
87
|
+
try {
|
|
88
|
+
// TODO: could add a progress event here to show the boot progress and number of attempts
|
|
89
|
+
if (bootRes === undefined) {
|
|
90
|
+
bootRes = await ao.result({
|
|
91
|
+
process: processId,
|
|
92
|
+
message: processId,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
logger.debug('Retrying ANT boot result fetch', {
|
|
99
|
+
processId,
|
|
100
|
+
module,
|
|
101
|
+
scheduler,
|
|
102
|
+
attempts,
|
|
103
|
+
error,
|
|
55
104
|
});
|
|
105
|
+
attempts++;
|
|
106
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * attempts ** 2));
|
|
56
107
|
}
|
|
57
|
-
break;
|
|
58
108
|
}
|
|
59
|
-
|
|
60
|
-
|
|
109
|
+
if (bootRes === undefined ||
|
|
110
|
+
bootRes.Messages?.some((m) => m?.Tags?.some((t) => t.value === 'Invalid-Boot-Notice'))) {
|
|
111
|
+
if (bootRes === undefined) {
|
|
112
|
+
throw new Error('Failed to get boot result');
|
|
113
|
+
}
|
|
114
|
+
const bootError = errorMessageFromOutput(bootRes);
|
|
115
|
+
logger.error('ANT failed to boot correctly', {
|
|
61
116
|
processId,
|
|
62
117
|
module,
|
|
63
118
|
scheduler,
|
|
64
|
-
|
|
65
|
-
|
|
119
|
+
bootRes,
|
|
120
|
+
bootError,
|
|
66
121
|
});
|
|
67
|
-
|
|
68
|
-
await new Promise((resolve) => setTimeout(resolve, 1000 * attempts ** 2));
|
|
122
|
+
throw new Error(`ANT failed to boot correctly: ${bootError}`);
|
|
69
123
|
}
|
|
70
124
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
125
|
+
onSigningProgress?.('verifying-state', {
|
|
126
|
+
processId,
|
|
127
|
+
moduleId: module,
|
|
128
|
+
antRegistryId,
|
|
129
|
+
});
|
|
130
|
+
// Note: for hyperbeam caching, due to a SU issue, we need to send a second message to the ANT to cache the state
|
|
131
|
+
// We wait for the first message to be processed before sending the second one to ensure this is the second message
|
|
132
|
+
// We use the resulting state to check the owner of the ANT is set in the registry. Should this be patched on MUs,
|
|
133
|
+
// we can convert to just a simple dry-run to avoid sending/signing another message.
|
|
134
|
+
let owner;
|
|
135
|
+
try {
|
|
136
|
+
const processApi = new AOProcess({
|
|
137
|
+
processId,
|
|
138
|
+
ao,
|
|
139
|
+
logger,
|
|
140
|
+
});
|
|
141
|
+
const { id } = await processApi.send({
|
|
142
|
+
tags: [{ name: 'Action', value: 'State' }],
|
|
143
|
+
signer,
|
|
144
|
+
});
|
|
145
|
+
const stateResult = await ao.result({
|
|
146
|
+
process: processId,
|
|
147
|
+
message: id,
|
|
148
|
+
});
|
|
149
|
+
if (stateResult === undefined) {
|
|
150
|
+
throw new Error('Failed to get state result');
|
|
76
151
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
152
|
+
const { Owner } = JSON.parse(stateResult.Messages?.[0]?.Data ?? '{}');
|
|
153
|
+
owner = Owner;
|
|
154
|
+
logger.debug(`Successfully spawned new ANT and validated owner`, {
|
|
79
155
|
processId,
|
|
80
156
|
module,
|
|
81
|
-
|
|
82
|
-
bootRes,
|
|
83
|
-
bootError,
|
|
157
|
+
owner,
|
|
84
158
|
});
|
|
85
|
-
throw new Error(`ANT failed to boot correctly: ${bootError}`);
|
|
86
159
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
160
|
+
catch (error) {
|
|
161
|
+
logger.error('Failed to validate owner of spawned ANT', {
|
|
162
|
+
processId,
|
|
163
|
+
module,
|
|
164
|
+
error,
|
|
165
|
+
});
|
|
166
|
+
throw error;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Now confirm the owner of the ANT is set in the registry
|
|
170
|
+
* This is to ensure the ANT is available via the ANT registry
|
|
171
|
+
* for the owner to find and use the ANT.
|
|
172
|
+
*/
|
|
173
|
+
if (owner === undefined) {
|
|
174
|
+
throw new Error(`Spawning ANT (${processId}) failed to set owner`);
|
|
175
|
+
}
|
|
176
|
+
onSigningProgress?.('registering-ant', {
|
|
90
177
|
processId,
|
|
91
|
-
|
|
92
|
-
|
|
178
|
+
antRegistryId,
|
|
179
|
+
owner,
|
|
93
180
|
});
|
|
94
|
-
|
|
95
|
-
|
|
181
|
+
// check the ACL for the owner
|
|
182
|
+
const antRegistry = ANTRegistry.init({
|
|
96
183
|
signer,
|
|
184
|
+
processId: antRegistryId,
|
|
97
185
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
186
|
+
let attempts = 0;
|
|
187
|
+
const maxAttempts = 5;
|
|
188
|
+
while (attempts < maxAttempts) {
|
|
189
|
+
try {
|
|
190
|
+
const acl = await antRegistry.accessControlList({ address: owner });
|
|
191
|
+
if (acl === undefined) {
|
|
192
|
+
throw new Error('ACL not found for owner');
|
|
193
|
+
}
|
|
194
|
+
const { Owned } = acl;
|
|
195
|
+
if (!Owned.includes(processId)) {
|
|
196
|
+
throw new Error(`Spawned ANT (${processId}) not found in registry for owner ${owner}`);
|
|
197
|
+
}
|
|
198
|
+
return processId;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
logger.debug('Retrying ANT registry access control list fetch', {
|
|
202
|
+
owner,
|
|
203
|
+
antRegistryId,
|
|
204
|
+
attempts,
|
|
205
|
+
error,
|
|
206
|
+
});
|
|
207
|
+
attempts++;
|
|
208
|
+
await new Promise((resolve) => setTimeout(resolve, 1000 * attempts ** 2));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
103
211
|
return processId;
|
|
104
212
|
}
|
|
213
|
+
// TODO: add a utility for forking an ANT to the latest module that leverages getState and spawnANT
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated
|
|
216
|
+
* Direct Evals are not encouraged when dealing with ANTs.
|
|
217
|
+
* Instead, use spawnANT to fork an ANT to new module source code
|
|
218
|
+
*/
|
|
105
219
|
export async function evolveANT({ signer, processId, luaCodeTxId = ANT_LUA_ID, ao = connect({
|
|
106
220
|
MODE: 'legacy',
|
|
107
221
|
}), logger = Logger.default, arweave = defaultArweave, }) {
|
|
@@ -110,6 +224,7 @@ export async function evolveANT({ signer, processId, luaCodeTxId = ANT_LUA_ID, a
|
|
|
110
224
|
ao,
|
|
111
225
|
logger,
|
|
112
226
|
});
|
|
227
|
+
logger.warn('Directly running an Eval on a process is not encouraged.');
|
|
113
228
|
//TODO: cache locally and only fetch if not cached
|
|
114
229
|
// We do not use arweave to get the data because it may throw on l2 tx data
|
|
115
230
|
const { api: { host, port, protocol }, } = arweave.getConfig();
|
package/lib/esm/version.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
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
1
|
import { AoArNSPurchaseParams, AoBuyRecordParams, AoExtendLeaseParams, AoIncreaseUndernameLimitParams } from '../../types/io.js';
|
|
17
2
|
import { CLIWriteOptionsFromAoParams } from '../types.js';
|
|
18
3
|
export declare function buyRecordCLICommand(o: CLIWriteOptionsFromAoParams<AoBuyRecordParams>): Promise<import("../../types/common.js").AoMessageResult>;
|
|
@@ -14,7 +14,7 @@ export declare function saveObservations(o: WriteActionCLIOptions & {
|
|
|
14
14
|
failedGateways?: string[];
|
|
15
15
|
transactionId?: string;
|
|
16
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").
|
|
17
|
+
export declare function increaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
18
18
|
export declare function decreaseOperatorStake(o: OperatorStakeCLIOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
19
19
|
export declare function instantWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
20
20
|
export declare function cancelWithdrawal(o: AddressAndVaultIdCLIWriteOptions): Promise<import("../../types/common.js").AoMessageResult<Record<string, string | number | boolean | null>>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState,
|
|
1
|
+
import { AntReadOptions, AoANTHandler, AoANTInfo, AoANTRead, AoANTRecord, AoANTSetBaseNameRecordParams, AoANTSetUndernameRecordParams, AoANTState, AoANTWrite, SortedANTRecords } from '../types/ant.js';
|
|
2
2
|
import { AoMessageResult, ProcessConfiguration, WalletAddress, WithSigner, WriteOptions } from '../types/index.js';
|
|
3
|
+
import { spawnANT } from '../utils/ao.js';
|
|
3
4
|
import { AOProcess } from './index.js';
|
|
4
5
|
type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
5
6
|
strict?: boolean;
|
|
@@ -8,7 +9,16 @@ type ANTConfigOptionalStrict = Required<ProcessConfiguration> & {
|
|
|
8
9
|
type ANTConfigNoSigner = ANTConfigOptionalStrict;
|
|
9
10
|
type ANTConfigWithSigner = WithSigner<ANTConfigOptionalStrict>;
|
|
10
11
|
export declare class ANT {
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Versions of ANTs according to the ANT registry.
|
|
14
|
+
*
|
|
15
|
+
* Needs to be wrapped in a getter to avoid circular dependency issues.
|
|
16
|
+
*/
|
|
17
|
+
static get versions(): import("../types/ant.js").AoANTVersionsRead;
|
|
18
|
+
/**
|
|
19
|
+
* Spawn a new ANT.
|
|
20
|
+
*/
|
|
21
|
+
static spawn: typeof spawnANT;
|
|
12
22
|
static init(config: ANTConfigNoSigner): AoANTRead;
|
|
13
23
|
static init(config: ANTConfigWithSigner): AoANTWrite;
|
|
14
24
|
}
|
package/lib/types/common/io.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
|
-
import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, ArNSNameResolutionData, ArNSNameResolver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
|
|
2
|
+
import { ARIOWithFaucet, AoARIORead, AoARIOWrite, AoAllDelegates, AoAllGatewayVaults, AoArNSNameData, AoArNSNameDataWithName, AoArNSPurchaseParams, AoArNSReservedNameData, AoArNSReservedNameDataWithName, AoBalanceWithAddress, AoBuyRecordParams, AoCreateVaultParams, AoDelegation, AoEligibleDistribution, AoEpochData, AoEpochDistributed, AoEpochDistributionData, AoEpochDistributionTotalsData, AoEpochObservationData, AoEpochSettings, AoExtendLeaseParams, AoExtendVaultParams, AoGateway, AoGatewayDelegateWithAddress, AoGatewayRegistrySettings, AoGatewayVault, AoGatewayWithAddress, AoGetCostDetailsParams, AoIncreaseUndernameLimitParams, AoIncreaseVaultParams, AoJoinNetworkParams, AoMessageResult, AoPaginatedAddressParams, AoPrimaryName, AoPrimaryNameRequest, AoRedelegationFeeInfo, AoRegistrationFees, AoReturnedName, AoRevokeVaultParams, AoTokenSupplyData, AoUpdateGatewaySettingsParams, AoVaultData, AoVaultedTransferParams, AoWalletVault, AoWeightedObserver, ArNSNameResolutionData, ArNSNameResolver, CostDetailsResult, DemandFactorSettings, EpochInput, OptionalArweave, OptionalPaymentUrl, PaginationParams, PaginationResult, ProcessConfiguration, SpawnAntProgressEvent, TransactionId, WalletAddress, WithSigner, WriteOptions, mARIOToken } from '../types/index.js';
|
|
3
3
|
import { AOProcess } from './contracts/ao-process.js';
|
|
4
|
+
import { Logger } from './logger.js';
|
|
4
5
|
import { TurboArNSPaymentProviderAuthenticated, TurboArNSPaymentProviderUnauthenticated } from './turbo.js';
|
|
5
6
|
type ARIOConfigNoSigner = OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>;
|
|
6
7
|
type ARIOConfigWithSigner = WithSigner<OptionalPaymentUrl<OptionalArweave<ProcessConfiguration>>>;
|
|
@@ -24,6 +25,7 @@ export declare class ARIOReadable implements AoARIORead, ArNSNameResolver {
|
|
|
24
25
|
protected epochSettings: AoEpochSettings | undefined;
|
|
25
26
|
protected arweave: Arweave;
|
|
26
27
|
protected paymentProvider: TurboArNSPaymentProviderUnauthenticated;
|
|
28
|
+
protected logger: Logger;
|
|
27
29
|
constructor(config?: ARIOConfigNoSigner);
|
|
28
30
|
getInfo(): Promise<{
|
|
29
31
|
Name: string;
|
|
@@ -187,7 +189,7 @@ export declare class ARIOWriteable extends ARIOReadable implements AoARIOWrite {
|
|
|
187
189
|
reportTxId: TransactionId;
|
|
188
190
|
failedGateways: WalletAddress[];
|
|
189
191
|
}, options?: WriteOptions): Promise<AoMessageResult>;
|
|
190
|
-
buyRecord(params: AoBuyRecordParams, options?: WriteOptions): Promise<AoMessageResult>;
|
|
192
|
+
buyRecord(params: AoBuyRecordParams, options?: WriteOptions<keyof SpawnAntProgressEvent, SpawnAntProgressEvent[keyof SpawnAntProgressEvent]>): Promise<AoMessageResult>;
|
|
191
193
|
/**
|
|
192
194
|
* Upgrades an existing leased record to a permabuy.
|
|
193
195
|
*
|
package/lib/types/constants.d.ts
CHANGED
|
@@ -25,7 +25,13 @@ export declare const ARIO_TESTNET_PROCESS_ID = "agYcCFJtrMG6cqMuZfskIkFTGvUPddIC
|
|
|
25
25
|
export declare const ARIO_MAINNET_PROCESS_ID = "qNvAoz0TgcH7DMg8BCVn8jF32QH5L6T29VjHxhHqqGE";
|
|
26
26
|
export declare const ANT_REGISTRY_ID = "i_le_yKKPVstLTDSmkHRqf-wYphMnwB9OhleiTgMkWc";
|
|
27
27
|
export declare const MARIO_PER_ARIO = 1000000;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
|
|
30
|
+
**/
|
|
28
31
|
export declare const AOS_MODULE_ID = "nEjlSFA_8narJlVHApbczDPkMc9znSqYtqtf1iOdoxM";
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated - use ANT.versions.getLatestANTVersion() to get latest ANT module
|
|
34
|
+
**/
|
|
29
35
|
export declare const ANT_LUA_ID = "sOW9Sdm1yoPRrzerC5iu1nsupp4e6I-HnJyYVHzvzQo";
|
|
30
36
|
export declare const AO_AUTHORITY = "fcoN_xJeisVsPXA-trzVAuIiqO3ydLQxM-L4XbrQKzY";
|
|
31
37
|
export declare const DEFAULT_SCHEDULER_ID = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import { ArconnectSigner, ArweaveSigner, EthereumSigner, InjectedEthereumSigner, Signer } from '@dha-team/arbundles';
|
|
17
17
|
import { dryrun, message, monitor, result, results, spawn, unmonitor } from '@permaweb/aoconnect';
|
|
18
18
|
import Arweave from 'arweave';
|
|
19
|
+
import { SpawnANTState } from './ant.js';
|
|
19
20
|
import { AoSigner } from './token.js';
|
|
20
21
|
export type BlockHeight = number;
|
|
21
22
|
export type SortKey = string;
|
|
@@ -41,11 +42,12 @@ export type ReadParameters<Input> = {
|
|
|
41
42
|
functionName: string;
|
|
42
43
|
inputs?: Input;
|
|
43
44
|
};
|
|
44
|
-
export type WriteOptions = {
|
|
45
|
+
export type WriteOptions<K extends string = string, T = unknown> = {
|
|
45
46
|
tags?: {
|
|
46
47
|
name: string;
|
|
47
48
|
value: string;
|
|
48
49
|
}[];
|
|
50
|
+
onSigningProgress?: (name: K, payload: T) => void;
|
|
49
51
|
};
|
|
50
52
|
export type WriteParameters<Input> = WithSigner<Required<ReadParameters<Input>>>;
|
|
51
53
|
export type AoMessageResult<T = Record<string, string | number | boolean | null>> = {
|
|
@@ -95,6 +97,24 @@ export interface AoClient {
|
|
|
95
97
|
unmonitor: typeof unmonitor;
|
|
96
98
|
dryrun: typeof dryrun;
|
|
97
99
|
}
|
|
100
|
+
export type SpawnAntProgressEvent = {
|
|
101
|
+
'spawning-ant': {
|
|
102
|
+
moduleId: string;
|
|
103
|
+
antRegistryId: string;
|
|
104
|
+
version: string | undefined;
|
|
105
|
+
state: SpawnANTState | undefined;
|
|
106
|
+
};
|
|
107
|
+
'verifying-state': {
|
|
108
|
+
processId: ProcessId;
|
|
109
|
+
moduleId: string;
|
|
110
|
+
antRegistryId: string;
|
|
111
|
+
};
|
|
112
|
+
'registering-ant': {
|
|
113
|
+
antRegistryId: string;
|
|
114
|
+
processId: ProcessId;
|
|
115
|
+
owner: WalletAddress;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
98
118
|
export interface AOContract {
|
|
99
119
|
read<K>({ tags, retries, }: {
|
|
100
120
|
tags?: {
|
package/lib/types/types/io.d.ts
CHANGED
|
@@ -353,7 +353,7 @@ export type AoArNSPurchaseParams = AoArNSNameParams & {
|
|
|
353
353
|
export type AoBuyRecordParams = AoArNSPurchaseParams & {
|
|
354
354
|
years?: number;
|
|
355
355
|
type: 'lease' | 'permabuy';
|
|
356
|
-
processId
|
|
356
|
+
processId?: string;
|
|
357
357
|
};
|
|
358
358
|
export type AoExtendLeaseParams = AoArNSPurchaseParams & {
|
|
359
359
|
years: number;
|
package/lib/types/utils/ao.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Arweave from 'arweave';
|
|
2
2
|
import { Logger } from '../common/index.js';
|
|
3
3
|
import { SpawnANTState } from '../types/ant.js';
|
|
4
|
-
import { AoClient, AoEpochData, AoEpochDistributed, AoSigner, ContractSigner, WalletAddress } from '../types/index.js';
|
|
4
|
+
import { AoClient, AoEpochData, AoEpochDistributed, AoSigner, ContractSigner, ProcessId, SpawnAntProgressEvent, WalletAddress } from '../types/index.js';
|
|
5
5
|
export type SpawnANTParams = {
|
|
6
6
|
signer: AoSigner;
|
|
7
7
|
module?: string;
|
|
@@ -20,8 +20,17 @@ export type SpawnANTParams = {
|
|
|
20
20
|
* @deprecated no longer in use due to compiled modules being preferred
|
|
21
21
|
*/
|
|
22
22
|
arweave?: Arweave;
|
|
23
|
+
/**
|
|
24
|
+
* Callback function to be called when signing progress is made
|
|
25
|
+
*/
|
|
26
|
+
onSigningProgress?: (name: keyof SpawnAntProgressEvent, payload: SpawnAntProgressEvent[keyof SpawnAntProgressEvent]) => void;
|
|
23
27
|
};
|
|
24
|
-
export declare function spawnANT({ signer, module, ao, scheduler, state, antRegistryId, logger, authority, }: SpawnANTParams): Promise<
|
|
28
|
+
export declare function spawnANT({ signer, module, ao, scheduler, state, antRegistryId, logger, authority, onSigningProgress, }: SpawnANTParams): Promise<ProcessId>;
|
|
29
|
+
/**
|
|
30
|
+
* @deprecated
|
|
31
|
+
* Direct Evals are not encouraged when dealing with ANTs.
|
|
32
|
+
* Instead, use spawnANT to fork an ANT to new module source code
|
|
33
|
+
*/
|
|
25
34
|
export declare function evolveANT({ signer, processId, luaCodeTxId, ao, logger, arweave, }: {
|
|
26
35
|
signer: AoSigner;
|
|
27
36
|
processId: string;
|
package/lib/types/version.d.ts
CHANGED