@ar.io/sdk 3.10.0-alpha.2 → 3.10.0
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 +147 -126
- package/lib/cjs/cli/commands/antCommands.js +3 -4
- package/lib/cjs/cli/commands/arnsPurchaseCommands.js +5 -6
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +11 -12
- package/lib/cjs/cli/commands/readCommands.js +21 -22
- package/lib/cjs/cli/commands/transfer.js +6 -7
- package/lib/cjs/cli/options.js +0 -12
- package/lib/cjs/cli/utils.js +52 -74
- package/lib/cjs/common/ant-versions.js +5 -5
- package/lib/cjs/common/faucet.js +2 -2
- package/lib/cjs/common/io.js +16 -52
- package/lib/cjs/types/ant.js +2 -2
- package/lib/cjs/types/io.js +5 -5
- package/lib/cjs/utils/ao.js +9 -9
- package/lib/cjs/utils/arweave.js +4 -4
- package/lib/cjs/utils/base64.js +4 -5
- package/lib/cjs/utils/json.js +1 -2
- package/lib/cjs/utils/schema.js +1 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/options.js +0 -12
- package/lib/esm/cli/utils.js +10 -31
- package/lib/esm/common/ant-versions.js +5 -5
- package/lib/esm/common/io.js +16 -52
- package/lib/esm/types/io.js +1 -1
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/commands/antCommands.d.ts +3 -3
- package/lib/types/cli/commands/arnsPurchaseCommands.d.ts +1 -1
- package/lib/types/cli/commands/gatewayWriteCommands.d.ts +9 -9
- package/lib/types/cli/commands/readCommands.d.ts +3 -4
- package/lib/types/cli/commands/transfer.d.ts +3 -3
- package/lib/types/cli/options.d.ts +0 -9
- package/lib/types/cli/types.d.ts +0 -3
- package/lib/types/cli/utils.d.ts +0 -4
- package/lib/types/common/ant-versions.d.ts +6 -3
- package/lib/types/common/http.d.ts +0 -1
- package/lib/types/common/io.d.ts +6 -9
- package/lib/types/types/common.d.ts +1 -7
- package/lib/types/types/io.d.ts +7 -8
- package/lib/types/types/token.d.ts +0 -1
- package/lib/types/utils/base64.d.ts +0 -1
- package/package.json +1 -2
- package/lib/cjs/common/turbo.js +0 -134
- package/lib/cjs/utils/url.js +0 -28
- package/lib/cjs/utils/url.test.js +0 -24
- package/lib/esm/common/turbo.js +0 -129
- package/lib/esm/utils/url.js +0 -24
- package/lib/esm/utils/url.test.js +0 -19
- package/lib/types/common/turbo.d.ts +0 -47
- package/lib/types/utils/url.d.ts +0 -19
- package/lib/types/utils/url.test.d.ts +0 -1
package/lib/cjs/cli/utils.js
CHANGED
|
@@ -3,7 +3,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultTtlSecondsCLI = void 0;
|
|
7
|
+
exports.stringifyJsonForCLIDisplay = stringifyJsonForCLIDisplay;
|
|
8
|
+
exports.runCommand = runCommand;
|
|
9
|
+
exports.applyOptions = applyOptions;
|
|
10
|
+
exports.makeCommand = makeCommand;
|
|
11
|
+
exports.arioProcessIdFromOptions = arioProcessIdFromOptions;
|
|
12
|
+
exports.requiredJwkFromOptions = requiredJwkFromOptions;
|
|
13
|
+
exports.jwkToAddress = jwkToAddress;
|
|
14
|
+
exports.getLoggerFromOptions = getLoggerFromOptions;
|
|
15
|
+
exports.readARIOFromOptions = readARIOFromOptions;
|
|
16
|
+
exports.requiredContractSignerFromOptions = requiredContractSignerFromOptions;
|
|
17
|
+
exports.requiredAoSignerFromOptions = requiredAoSignerFromOptions;
|
|
18
|
+
exports.writeARIOFromOptions = writeARIOFromOptions;
|
|
19
|
+
exports.formatARIOWithCommas = formatARIOWithCommas;
|
|
20
|
+
exports.formatMARIOToARIOWithCommas = formatMARIOToARIOWithCommas;
|
|
21
|
+
exports.addressFromOptions = addressFromOptions;
|
|
22
|
+
exports.requiredAddressFromOptions = requiredAddressFromOptions;
|
|
23
|
+
exports.paginationParamsFromOptions = paginationParamsFromOptions;
|
|
24
|
+
exports.epochInputFromOptions = epochInputFromOptions;
|
|
25
|
+
exports.requiredInitiatorFromOptions = requiredInitiatorFromOptions;
|
|
26
|
+
exports.customTagsFromOptions = customTagsFromOptions;
|
|
27
|
+
exports.gatewaySettingsFromOptions = gatewaySettingsFromOptions;
|
|
28
|
+
exports.requiredTargetAndQuantityFromOptions = requiredTargetAndQuantityFromOptions;
|
|
29
|
+
exports.redelegateParamsFromOptions = redelegateParamsFromOptions;
|
|
30
|
+
exports.recordTypeFromOptions = recordTypeFromOptions;
|
|
31
|
+
exports.requiredMARIOFromOptions = requiredMARIOFromOptions;
|
|
32
|
+
exports.assertEnoughBalanceForArNSPurchase = assertEnoughBalanceForArNSPurchase;
|
|
33
|
+
exports.assertEnoughMARIOBalance = assertEnoughMARIOBalance;
|
|
34
|
+
exports.confirmationPrompt = confirmationPrompt;
|
|
35
|
+
exports.assertConfirmationPrompt = assertConfirmationPrompt;
|
|
36
|
+
exports.requiredProcessIdFromOptions = requiredProcessIdFromOptions;
|
|
37
|
+
exports.readANTFromOptions = readANTFromOptions;
|
|
38
|
+
exports.writeANTFromOptions = writeANTFromOptions;
|
|
39
|
+
exports.booleanFromOptions = booleanFromOptions;
|
|
40
|
+
exports.requiredStringFromOptions = requiredStringFromOptions;
|
|
41
|
+
exports.requiredStringArrayFromOptions = requiredStringArrayFromOptions;
|
|
42
|
+
exports.positiveIntegerFromOptions = positiveIntegerFromOptions;
|
|
43
|
+
exports.requiredPositiveIntegerFromOptions = requiredPositiveIntegerFromOptions;
|
|
44
|
+
exports.getANTStateFromOptions = getANTStateFromOptions;
|
|
45
|
+
exports.getTokenCostParamsFromOptions = getTokenCostParamsFromOptions;
|
|
46
|
+
exports.fundFromFromOptions = fundFromFromOptions;
|
|
47
|
+
exports.assertLockLengthInRange = assertLockLengthInRange;
|
|
7
48
|
/**
|
|
8
49
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
9
50
|
*
|
|
@@ -19,7 +60,6 @@ exports.assertLockLengthInRange = exports.fundFromFromOptions = exports.getToken
|
|
|
19
60
|
* See the License for the specific language governing permissions and
|
|
20
61
|
* limitations under the License.
|
|
21
62
|
*/
|
|
22
|
-
const arbundles_1 = require("@dha-team/arbundles");
|
|
23
63
|
const aoconnect_1 = require("@permaweb/aoconnect");
|
|
24
64
|
const commander_1 = require("commander");
|
|
25
65
|
const fs_1 = require("fs");
|
|
@@ -30,7 +70,6 @@ exports.defaultTtlSecondsCLI = 3600;
|
|
|
30
70
|
function stringifyJsonForCLIDisplay(json) {
|
|
31
71
|
return JSON.stringify(json, null, 2);
|
|
32
72
|
}
|
|
33
|
-
exports.stringifyJsonForCLIDisplay = stringifyJsonForCLIDisplay;
|
|
34
73
|
function logCommandOutput(output) {
|
|
35
74
|
console.log(stringifyJsonForCLIDisplay(output));
|
|
36
75
|
}
|
|
@@ -59,14 +98,12 @@ async function runCommand(command, action) {
|
|
|
59
98
|
exitWithErrorLog(error, options.debug);
|
|
60
99
|
}
|
|
61
100
|
}
|
|
62
|
-
exports.runCommand = runCommand;
|
|
63
101
|
function applyOptions(command, options) {
|
|
64
102
|
[...options].forEach((option) => {
|
|
65
103
|
command.option(option.alias, option.description, option.default);
|
|
66
104
|
});
|
|
67
105
|
return command;
|
|
68
106
|
}
|
|
69
|
-
exports.applyOptions = applyOptions;
|
|
70
107
|
function makeCommand({ description, name, options = [], action, }) {
|
|
71
108
|
const command = commander_1.program.command(name).description(description);
|
|
72
109
|
const appliedCommand = applyOptions(command, [...options, ...options_js_1.globalOptions]);
|
|
@@ -75,7 +112,6 @@ function makeCommand({ description, name, options = [], action, }) {
|
|
|
75
112
|
}
|
|
76
113
|
return appliedCommand;
|
|
77
114
|
}
|
|
78
|
-
exports.makeCommand = makeCommand;
|
|
79
115
|
function arioProcessIdFromOptions({ arioProcessId, devnet, testnet, }) {
|
|
80
116
|
if (arioProcessId !== undefined) {
|
|
81
117
|
return arioProcessId;
|
|
@@ -88,8 +124,7 @@ function arioProcessIdFromOptions({ arioProcessId, devnet, testnet, }) {
|
|
|
88
124
|
}
|
|
89
125
|
return index_js_1.ARIO_MAINNET_PROCESS_ID;
|
|
90
126
|
}
|
|
91
|
-
|
|
92
|
-
function walletFromOptions({ privateKey, walletFile, }) {
|
|
127
|
+
function jwkFromOptions({ privateKey, walletFile, }) {
|
|
93
128
|
if (privateKey !== undefined) {
|
|
94
129
|
return JSON.parse(privateKey);
|
|
95
130
|
}
|
|
@@ -99,17 +134,15 @@ function walletFromOptions({ privateKey, walletFile, }) {
|
|
|
99
134
|
return undefined;
|
|
100
135
|
}
|
|
101
136
|
function requiredJwkFromOptions(options) {
|
|
102
|
-
const jwk =
|
|
137
|
+
const jwk = jwkFromOptions(options);
|
|
103
138
|
if (jwk === undefined) {
|
|
104
139
|
throw new Error('No JWK provided for signing!\nPlease provide a stringified JWK with `--private-key` or the file path of a jwk.json file with `--wallet-file`');
|
|
105
140
|
}
|
|
106
141
|
return jwk;
|
|
107
142
|
}
|
|
108
|
-
exports.requiredJwkFromOptions = requiredJwkFromOptions;
|
|
109
143
|
function jwkToAddress(jwk) {
|
|
110
144
|
return (0, index_js_1.sha256B64Url)((0, index_js_1.fromB64Url)(jwk.n));
|
|
111
145
|
}
|
|
112
|
-
exports.jwkToAddress = jwkToAddress;
|
|
113
146
|
function setLoggerIfDebug(options) {
|
|
114
147
|
if (options.debug) {
|
|
115
148
|
index_js_1.Logger.default.setLogLevel('debug');
|
|
@@ -119,7 +152,6 @@ function getLoggerFromOptions(options) {
|
|
|
119
152
|
setLoggerIfDebug(options);
|
|
120
153
|
return index_js_1.Logger.default;
|
|
121
154
|
}
|
|
122
|
-
exports.getLoggerFromOptions = getLoggerFromOptions;
|
|
123
155
|
function aoProcessFromOptions(options) {
|
|
124
156
|
return new index_js_1.AOProcess({
|
|
125
157
|
processId: arioProcessIdFromOptions(options),
|
|
@@ -132,38 +164,17 @@ function readARIOFromOptions(options) {
|
|
|
132
164
|
setLoggerIfDebug(options);
|
|
133
165
|
return index_js_1.ARIO.init({
|
|
134
166
|
process: aoProcessFromOptions(options),
|
|
135
|
-
paymentUrl: options.paymentUrl,
|
|
136
167
|
});
|
|
137
168
|
}
|
|
138
|
-
exports.readARIOFromOptions = readARIOFromOptions;
|
|
139
|
-
function contractSignerFromOptions(options) {
|
|
140
|
-
const wallet = walletFromOptions(options);
|
|
141
|
-
if (wallet === undefined) {
|
|
142
|
-
return undefined;
|
|
143
|
-
}
|
|
144
|
-
const token = options.token ?? 'arweave';
|
|
145
|
-
if (token === 'ethereum') {
|
|
146
|
-
const signer = new arbundles_1.EthereumSigner(wallet);
|
|
147
|
-
// For EthereumSigner, we need to convert the JWK to a string
|
|
148
|
-
return { signer, signerAddress: signer.publicKey.toString('hex') };
|
|
149
|
-
}
|
|
150
|
-
// TODO: Support other wallet types
|
|
151
|
-
const signer = new index_js_1.ArweaveSigner(wallet);
|
|
152
|
-
return { signer, signerAddress: jwkToAddress(wallet) };
|
|
153
|
-
}
|
|
154
|
-
exports.contractSignerFromOptions = contractSignerFromOptions;
|
|
155
169
|
function requiredContractSignerFromOptions(options) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
return contractSigner;
|
|
170
|
+
// TODO: Support other wallet types
|
|
171
|
+
const jwk = requiredJwkFromOptions(options);
|
|
172
|
+
const signer = new index_js_1.ArweaveSigner(jwk);
|
|
173
|
+
return { signer, signerAddress: jwkToAddress(jwk) };
|
|
161
174
|
}
|
|
162
|
-
exports.requiredContractSignerFromOptions = requiredContractSignerFromOptions;
|
|
163
175
|
function requiredAoSignerFromOptions(options) {
|
|
164
176
|
return (0, index_js_1.createAoSigner)(requiredContractSignerFromOptions(options).signer);
|
|
165
177
|
}
|
|
166
|
-
exports.requiredAoSignerFromOptions = requiredAoSignerFromOptions;
|
|
167
178
|
function writeARIOFromOptions(options) {
|
|
168
179
|
const { signer, signerAddress } = requiredContractSignerFromOptions(options);
|
|
169
180
|
setLoggerIfDebug(options);
|
|
@@ -171,12 +182,10 @@ function writeARIOFromOptions(options) {
|
|
|
171
182
|
ario: index_js_1.ARIO.init({
|
|
172
183
|
process: aoProcessFromOptions(options),
|
|
173
184
|
signer,
|
|
174
|
-
paymentUrl: options.paymentUrl,
|
|
175
185
|
}),
|
|
176
186
|
signerAddress,
|
|
177
187
|
};
|
|
178
188
|
}
|
|
179
|
-
exports.writeARIOFromOptions = writeARIOFromOptions;
|
|
180
189
|
function formatARIOWithCommas(value) {
|
|
181
190
|
const [integerPart, decimalPart] = value.toString().split('.');
|
|
182
191
|
const integerWithCommas = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
@@ -185,23 +194,21 @@ function formatARIOWithCommas(value) {
|
|
|
185
194
|
}
|
|
186
195
|
return integerWithCommas + '.' + decimalPart;
|
|
187
196
|
}
|
|
188
|
-
exports.formatARIOWithCommas = formatARIOWithCommas;
|
|
189
197
|
function formatMARIOToARIOWithCommas(value) {
|
|
190
198
|
return formatARIOWithCommas(value.toARIO());
|
|
191
199
|
}
|
|
192
|
-
exports.formatMARIOToARIOWithCommas = formatMARIOToARIOWithCommas;
|
|
193
200
|
/** helper to get address from --address option first, then check wallet options */
|
|
194
201
|
function addressFromOptions(options) {
|
|
195
202
|
if (options.address !== undefined) {
|
|
196
203
|
return options.address;
|
|
197
204
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
205
|
+
// TODO: Support other wallet types
|
|
206
|
+
const jwk = jwkFromOptions(options);
|
|
207
|
+
if (jwk !== undefined) {
|
|
208
|
+
return jwkToAddress(jwk);
|
|
201
209
|
}
|
|
202
210
|
return undefined;
|
|
203
211
|
}
|
|
204
|
-
exports.addressFromOptions = addressFromOptions;
|
|
205
212
|
function requiredAddressFromOptions(options) {
|
|
206
213
|
const address = addressFromOptions(options);
|
|
207
214
|
if (address !== undefined) {
|
|
@@ -209,7 +216,6 @@ function requiredAddressFromOptions(options) {
|
|
|
209
216
|
}
|
|
210
217
|
throw new Error('No address provided. Use --address or --wallet-file');
|
|
211
218
|
}
|
|
212
|
-
exports.requiredAddressFromOptions = requiredAddressFromOptions;
|
|
213
219
|
const defaultCliPaginationLimit = 10; // more friendly UX than 100
|
|
214
220
|
function paginationParamsFromOptions(options) {
|
|
215
221
|
const { cursor, limit, sortBy, sortOrder } = options;
|
|
@@ -227,7 +233,6 @@ function paginationParamsFromOptions(options) {
|
|
|
227
233
|
sortOrder,
|
|
228
234
|
};
|
|
229
235
|
}
|
|
230
|
-
exports.paginationParamsFromOptions = paginationParamsFromOptions;
|
|
231
236
|
function epochInputFromOptions(options) {
|
|
232
237
|
if (options.epochIndex !== undefined) {
|
|
233
238
|
return { epochIndex: +options.epochIndex };
|
|
@@ -237,14 +242,12 @@ function epochInputFromOptions(options) {
|
|
|
237
242
|
}
|
|
238
243
|
return undefined;
|
|
239
244
|
}
|
|
240
|
-
exports.epochInputFromOptions = epochInputFromOptions;
|
|
241
245
|
function requiredInitiatorFromOptions(options) {
|
|
242
246
|
if (options.initiator !== undefined) {
|
|
243
247
|
return options.initiator;
|
|
244
248
|
}
|
|
245
249
|
return requiredAddressFromOptions(options);
|
|
246
250
|
}
|
|
247
|
-
exports.requiredInitiatorFromOptions = requiredInitiatorFromOptions;
|
|
248
251
|
function customTagsFromOptions(options) {
|
|
249
252
|
if (options.tags === undefined) {
|
|
250
253
|
return {};
|
|
@@ -269,7 +272,6 @@ function customTagsFromOptions(options) {
|
|
|
269
272
|
tags,
|
|
270
273
|
};
|
|
271
274
|
}
|
|
272
|
-
exports.customTagsFromOptions = customTagsFromOptions;
|
|
273
275
|
function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegateRewardShareRatio, fqdn, label, minDelegatedStake, note, observerAddress, port, properties, allowedDelegates, }) {
|
|
274
276
|
return {
|
|
275
277
|
observerAddress,
|
|
@@ -287,7 +289,6 @@ function gatewaySettingsFromOptions({ allowDelegatedStaking, autoStake, delegate
|
|
|
287
289
|
properties,
|
|
288
290
|
};
|
|
289
291
|
}
|
|
290
|
-
exports.gatewaySettingsFromOptions = gatewaySettingsFromOptions;
|
|
291
292
|
function requiredTargetAndQuantityFromOptions(options) {
|
|
292
293
|
if (options.target === undefined) {
|
|
293
294
|
throw new Error('No target provided. Use --target');
|
|
@@ -300,7 +301,6 @@ function requiredTargetAndQuantityFromOptions(options) {
|
|
|
300
301
|
arioQuantity: new index_js_1.ARIOToken(+options.quantity),
|
|
301
302
|
};
|
|
302
303
|
}
|
|
303
|
-
exports.requiredTargetAndQuantityFromOptions = requiredTargetAndQuantityFromOptions;
|
|
304
304
|
function redelegateParamsFromOptions(options) {
|
|
305
305
|
const { target, arioQuantity: aRIOQuantity } = requiredTargetAndQuantityFromOptions(options);
|
|
306
306
|
const source = options.source;
|
|
@@ -314,7 +314,6 @@ function redelegateParamsFromOptions(options) {
|
|
|
314
314
|
stakeQty: aRIOQuantity.toMARIO(),
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
exports.redelegateParamsFromOptions = redelegateParamsFromOptions;
|
|
318
317
|
function recordTypeFromOptions(options) {
|
|
319
318
|
options.type ??= 'lease';
|
|
320
319
|
if (options.type !== 'lease' && options.type !== 'permabuy') {
|
|
@@ -322,18 +321,13 @@ function recordTypeFromOptions(options) {
|
|
|
322
321
|
}
|
|
323
322
|
return options.type;
|
|
324
323
|
}
|
|
325
|
-
exports.recordTypeFromOptions = recordTypeFromOptions;
|
|
326
324
|
function requiredMARIOFromOptions(options, key) {
|
|
327
325
|
if (options[key] === undefined) {
|
|
328
326
|
throw new Error(`No ${key} provided. Use --${key} denominated in ARIO`);
|
|
329
327
|
}
|
|
330
328
|
return new index_js_1.ARIOToken(+options[key]).toMARIO();
|
|
331
329
|
}
|
|
332
|
-
exports.requiredMARIOFromOptions = requiredMARIOFromOptions;
|
|
333
330
|
async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsParams, }) {
|
|
334
|
-
if (costDetailsParams.fundFrom === 'turbo') {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
331
|
const costDetails = await ario.getCostDetails(costDetailsParams);
|
|
338
332
|
if (costDetails.fundingPlan) {
|
|
339
333
|
if (costDetails.fundingPlan.shortfall > 0) {
|
|
@@ -348,7 +342,6 @@ async function assertEnoughBalanceForArNSPurchase({ ario, address, costDetailsPa
|
|
|
348
342
|
});
|
|
349
343
|
}
|
|
350
344
|
}
|
|
351
|
-
exports.assertEnoughBalanceForArNSPurchase = assertEnoughBalanceForArNSPurchase;
|
|
352
345
|
async function assertEnoughMARIOBalance({ address, ario, mARIOQuantity, }) {
|
|
353
346
|
if (typeof mARIOQuantity === 'number') {
|
|
354
347
|
mARIOQuantity = new index_js_1.mARIOToken(mARIOQuantity);
|
|
@@ -358,7 +351,6 @@ async function assertEnoughMARIOBalance({ address, ario, mARIOQuantity, }) {
|
|
|
358
351
|
throw new Error(`Insufficient ARIO balance for action. Balance available: ${formatMARIOToARIOWithCommas(new index_js_1.mARIOToken(balance))} ARIO`);
|
|
359
352
|
}
|
|
360
353
|
}
|
|
361
|
-
exports.assertEnoughMARIOBalance = assertEnoughMARIOBalance;
|
|
362
354
|
async function confirmationPrompt(message) {
|
|
363
355
|
const { confirm } = await (0, prompts_1.default)({
|
|
364
356
|
type: 'confirm',
|
|
@@ -367,21 +359,18 @@ async function confirmationPrompt(message) {
|
|
|
367
359
|
});
|
|
368
360
|
return confirm;
|
|
369
361
|
}
|
|
370
|
-
exports.confirmationPrompt = confirmationPrompt;
|
|
371
362
|
async function assertConfirmationPrompt(message, options) {
|
|
372
363
|
if (options.skipConfirmation) {
|
|
373
364
|
return true;
|
|
374
365
|
}
|
|
375
366
|
return confirmationPrompt(message);
|
|
376
367
|
}
|
|
377
|
-
exports.assertConfirmationPrompt = assertConfirmationPrompt;
|
|
378
368
|
function requiredProcessIdFromOptions(o) {
|
|
379
369
|
if (o.processId === undefined) {
|
|
380
370
|
throw new Error('--process-id is required');
|
|
381
371
|
}
|
|
382
372
|
return o.processId;
|
|
383
373
|
}
|
|
384
|
-
exports.requiredProcessIdFromOptions = requiredProcessIdFromOptions;
|
|
385
374
|
function ANTProcessFromOptions(options) {
|
|
386
375
|
return new index_js_1.AOProcess({
|
|
387
376
|
processId: requiredProcessIdFromOptions(options),
|
|
@@ -395,7 +384,6 @@ function readANTFromOptions(options) {
|
|
|
395
384
|
process: ANTProcessFromOptions(options),
|
|
396
385
|
});
|
|
397
386
|
}
|
|
398
|
-
exports.readANTFromOptions = readANTFromOptions;
|
|
399
387
|
function writeANTFromOptions(options, signer) {
|
|
400
388
|
signer ??= requiredContractSignerFromOptions(options).signer;
|
|
401
389
|
return index_js_1.ANT.init({
|
|
@@ -403,11 +391,9 @@ function writeANTFromOptions(options, signer) {
|
|
|
403
391
|
signer,
|
|
404
392
|
});
|
|
405
393
|
}
|
|
406
|
-
exports.writeANTFromOptions = writeANTFromOptions;
|
|
407
394
|
function booleanFromOptions(options, key) {
|
|
408
395
|
return !!options[key];
|
|
409
396
|
}
|
|
410
|
-
exports.booleanFromOptions = booleanFromOptions;
|
|
411
397
|
function requiredStringFromOptions(options, key) {
|
|
412
398
|
const value = options[key];
|
|
413
399
|
if (value === undefined) {
|
|
@@ -415,7 +401,6 @@ function requiredStringFromOptions(options, key) {
|
|
|
415
401
|
}
|
|
416
402
|
return value;
|
|
417
403
|
}
|
|
418
|
-
exports.requiredStringFromOptions = requiredStringFromOptions;
|
|
419
404
|
function requiredStringArrayFromOptions(options, key) {
|
|
420
405
|
const value = options[key];
|
|
421
406
|
if (value === undefined) {
|
|
@@ -426,7 +411,6 @@ function requiredStringArrayFromOptions(options, key) {
|
|
|
426
411
|
}
|
|
427
412
|
return value;
|
|
428
413
|
}
|
|
429
|
-
exports.requiredStringArrayFromOptions = requiredStringArrayFromOptions;
|
|
430
414
|
function positiveIntegerFromOptions(options, key) {
|
|
431
415
|
const value = options[key];
|
|
432
416
|
if (value === undefined) {
|
|
@@ -438,7 +422,6 @@ function positiveIntegerFromOptions(options, key) {
|
|
|
438
422
|
}
|
|
439
423
|
return numberValue;
|
|
440
424
|
}
|
|
441
|
-
exports.positiveIntegerFromOptions = positiveIntegerFromOptions;
|
|
442
425
|
function requiredPositiveIntegerFromOptions(options, key) {
|
|
443
426
|
const value = positiveIntegerFromOptions(options, key);
|
|
444
427
|
if (value === undefined) {
|
|
@@ -446,7 +429,6 @@ function requiredPositiveIntegerFromOptions(options, key) {
|
|
|
446
429
|
}
|
|
447
430
|
return value;
|
|
448
431
|
}
|
|
449
|
-
exports.requiredPositiveIntegerFromOptions = requiredPositiveIntegerFromOptions;
|
|
450
432
|
function getANTStateFromOptions(options) {
|
|
451
433
|
return (0, index_js_1.initANTStateForAddress)({
|
|
452
434
|
owner: requiredAddressFromOptions(options),
|
|
@@ -462,7 +444,6 @@ function getANTStateFromOptions(options) {
|
|
|
462
444
|
: exports.defaultTtlSecondsCLI,
|
|
463
445
|
});
|
|
464
446
|
}
|
|
465
|
-
exports.getANTStateFromOptions = getANTStateFromOptions;
|
|
466
447
|
function getTokenCostParamsFromOptions(o) {
|
|
467
448
|
o.intent ??= 'Buy-Name';
|
|
468
449
|
o.type ??= 'lease';
|
|
@@ -482,7 +463,6 @@ function getTokenCostParamsFromOptions(o) {
|
|
|
482
463
|
fromAddress: addressFromOptions(o),
|
|
483
464
|
};
|
|
484
465
|
}
|
|
485
|
-
exports.getTokenCostParamsFromOptions = getTokenCostParamsFromOptions;
|
|
486
466
|
function fundFromFromOptions(o) {
|
|
487
467
|
if (o.fundFrom !== undefined) {
|
|
488
468
|
if (!(0, index_js_1.isValidFundFrom)(o.fundFrom)) {
|
|
@@ -491,7 +471,6 @@ function fundFromFromOptions(o) {
|
|
|
491
471
|
}
|
|
492
472
|
return o.fundFrom ?? 'balance';
|
|
493
473
|
}
|
|
494
|
-
exports.fundFromFromOptions = fundFromFromOptions;
|
|
495
474
|
function assertLockLengthInRange(lockLengthMs, assertMin = true) {
|
|
496
475
|
const minLockLengthMs = 1209600000; // 14 days
|
|
497
476
|
const maxLockLengthMs = 378432000000; // ~12 years
|
|
@@ -505,4 +484,3 @@ function assertLockLengthInRange(lockLengthMs, assertMin = true) {
|
|
|
505
484
|
throw new Error(`Lock length must be at least 14 days (1209600000 ms). Provided lock length: ${lockLengthMs} ms`);
|
|
506
485
|
}
|
|
507
486
|
}
|
|
508
|
-
exports.assertLockLengthInRange = assertLockLengthInRange;
|
|
@@ -75,14 +75,14 @@ class ANTVersionsWritable extends ANTVersionsReadable {
|
|
|
75
75
|
super(config);
|
|
76
76
|
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
77
77
|
}
|
|
78
|
-
async addVersion(
|
|
78
|
+
async addVersion(params, { tags }) {
|
|
79
79
|
return this.process.send({
|
|
80
80
|
tags: (0, arweave_js_1.pruneTags)([
|
|
81
81
|
{ name: 'Action', value: 'Add-Version' },
|
|
82
|
-
{ name: 'Version', value: version },
|
|
83
|
-
{ name: 'Module-Id', value: moduleId },
|
|
84
|
-
{ name: 'Lua-Source-Id', value: luaSourceId },
|
|
85
|
-
{ name: 'Notes', value: notes },
|
|
82
|
+
{ name: 'Version', value: params.version },
|
|
83
|
+
{ name: 'Module-Id', value: params.moduleId },
|
|
84
|
+
{ name: 'Lua-Source-Id', value: params.luaSourceId },
|
|
85
|
+
{ name: 'Notes', value: params.notes },
|
|
86
86
|
...(tags ?? []),
|
|
87
87
|
]),
|
|
88
88
|
signer: this.signer,
|
package/lib/cjs/common/faucet.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ARIOTokenFaucet =
|
|
3
|
+
exports.ARIOTokenFaucet = void 0;
|
|
4
|
+
exports.createFaucet = createFaucet;
|
|
4
5
|
const DEFAULT_FAUCET_API_URL = 'https://faucet.ario.permaweb.services';
|
|
5
6
|
/**
|
|
6
7
|
* Creates a proxy object that implements the TokenFaucet interface. It wraps the ARIOReadable instance and adds methods for claiming tokens from the faucet API.
|
|
@@ -30,7 +31,6 @@ function createFaucet({ arioInstance, faucetApiUrl = DEFAULT_FAUCET_API_URL, })
|
|
|
30
31
|
});
|
|
31
32
|
return proxy;
|
|
32
33
|
}
|
|
33
|
-
exports.createFaucet = createFaucet;
|
|
34
34
|
class ARIOTokenFaucet {
|
|
35
35
|
faucetUrl;
|
|
36
36
|
processId;
|
package/lib/cjs/common/io.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ARIOWriteable = exports.ARIOReadable = exports.ARIO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License.
|
|
9
|
+
* You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
4
19
|
const aoconnect_1 = require("@permaweb/aoconnect");
|
|
5
20
|
const constants_js_1 = require("../constants.js");
|
|
6
21
|
const index_js_1 = require("../types/index.js");
|
|
@@ -10,7 +25,6 @@ const arweave_js_2 = require("./arweave.js");
|
|
|
10
25
|
const ao_process_js_1 = require("./contracts/ao-process.js");
|
|
11
26
|
const error_js_1 = require("./error.js");
|
|
12
27
|
const faucet_js_1 = require("./faucet.js");
|
|
13
|
-
const turbo_js_1 = require("./turbo.js");
|
|
14
28
|
class ARIO {
|
|
15
29
|
// Implementation
|
|
16
30
|
static init(config) {
|
|
@@ -75,7 +89,6 @@ class ARIOReadable {
|
|
|
75
89
|
process;
|
|
76
90
|
epochSettings;
|
|
77
91
|
arweave;
|
|
78
|
-
paymentProvider; // TODO: this could be an array/map of payment providers
|
|
79
92
|
constructor(config) {
|
|
80
93
|
this.arweave = config?.arweave ?? arweave_js_2.defaultArweave;
|
|
81
94
|
if (config === undefined || Object.keys(config).length === 0) {
|
|
@@ -94,9 +107,6 @@ class ARIOReadable {
|
|
|
94
107
|
else {
|
|
95
108
|
throw new error_js_1.InvalidContractConfigurationError();
|
|
96
109
|
}
|
|
97
|
-
this.paymentProvider = new turbo_js_1.TurboArNSPaymentProvider({
|
|
98
|
-
paymentUrl: config?.paymentUrl,
|
|
99
|
-
});
|
|
100
110
|
}
|
|
101
111
|
async getInfo() {
|
|
102
112
|
return this.process.read({
|
|
@@ -428,20 +438,6 @@ class ARIOReadable {
|
|
|
428
438
|
// TODO: Can overload this function to refine different types of cost details params
|
|
429
439
|
async getCostDetails({ intent, type, years, name, quantity, fromAddress, fundFrom, }) {
|
|
430
440
|
const replacedBuyRecordWithBuyName = intent === 'Buy-Record' ? 'Buy-Name' : intent;
|
|
431
|
-
if (fundFrom === 'turbo') {
|
|
432
|
-
const { mARIO, winc } = await this.paymentProvider.getArNSPriceDetails({
|
|
433
|
-
intent: replacedBuyRecordWithBuyName,
|
|
434
|
-
name,
|
|
435
|
-
quantity,
|
|
436
|
-
type,
|
|
437
|
-
years,
|
|
438
|
-
});
|
|
439
|
-
return {
|
|
440
|
-
tokenCost: +mARIO,
|
|
441
|
-
wincQty: winc,
|
|
442
|
-
discounts: [],
|
|
443
|
-
};
|
|
444
|
-
}
|
|
445
441
|
const allTags = [
|
|
446
442
|
{ name: 'Action', value: 'Cost-Details' },
|
|
447
443
|
{
|
|
@@ -609,8 +605,7 @@ class ARIOReadable {
|
|
|
609
605
|
exports.ARIOReadable = ARIOReadable;
|
|
610
606
|
class ARIOWriteable extends ARIOReadable {
|
|
611
607
|
signer;
|
|
612
|
-
|
|
613
|
-
constructor({ signer, paymentUrl, ...config }) {
|
|
608
|
+
constructor({ signer, ...config }) {
|
|
614
609
|
if (config === undefined) {
|
|
615
610
|
super({
|
|
616
611
|
process: new ao_process_js_1.AOProcess({
|
|
@@ -622,10 +617,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
622
617
|
super(config);
|
|
623
618
|
}
|
|
624
619
|
this.signer = (0, ao_js_1.createAoSigner)(signer);
|
|
625
|
-
this.paymentProvider = new turbo_js_1.TurboArNSPaymentProvider({
|
|
626
|
-
signer: signer,
|
|
627
|
-
paymentUrl,
|
|
628
|
-
});
|
|
629
620
|
}
|
|
630
621
|
async transfer({ target, qty, }, options) {
|
|
631
622
|
const { tags = [] } = options || {};
|
|
@@ -900,12 +891,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
900
891
|
});
|
|
901
892
|
}
|
|
902
893
|
async buyRecord(params, options) {
|
|
903
|
-
if (params.fundFrom === 'turbo') {
|
|
904
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
905
|
-
intent: 'Buy-Name',
|
|
906
|
-
...params,
|
|
907
|
-
});
|
|
908
|
-
}
|
|
909
894
|
const { tags = [] } = options || {};
|
|
910
895
|
const allTags = [
|
|
911
896
|
...tags,
|
|
@@ -930,12 +915,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
930
915
|
* @returns {Promise<AoMessageResult>} The result of the upgrade
|
|
931
916
|
*/
|
|
932
917
|
async upgradeRecord(params, options) {
|
|
933
|
-
if (params.fundFrom === 'turbo') {
|
|
934
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
935
|
-
intent: 'Upgrade-Name',
|
|
936
|
-
name: params.name,
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
918
|
const { tags = [] } = options || {};
|
|
940
919
|
const allTags = [
|
|
941
920
|
...tags,
|
|
@@ -958,12 +937,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
958
937
|
* @returns {Promise<AoMessageResult>} The result of the extension
|
|
959
938
|
*/
|
|
960
939
|
async extendLease(params, options) {
|
|
961
|
-
if (params.fundFrom === 'turbo') {
|
|
962
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
963
|
-
intent: 'Extend-Lease',
|
|
964
|
-
...params,
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
940
|
const { tags = [] } = options || {};
|
|
968
941
|
const allTags = [
|
|
969
942
|
...tags,
|
|
@@ -978,12 +951,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
978
951
|
});
|
|
979
952
|
}
|
|
980
953
|
async increaseUndernameLimit(params, options) {
|
|
981
|
-
if (params.fundFrom === 'turbo') {
|
|
982
|
-
return this.paymentProvider.initiateArNSPurchase({
|
|
983
|
-
intent: 'Increase-Undername-Limit',
|
|
984
|
-
...params,
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
954
|
const { tags = [] } = options || {};
|
|
988
955
|
const allTags = [
|
|
989
956
|
...tags,
|
|
@@ -1020,9 +987,6 @@ class ARIOWriteable extends ARIOReadable {
|
|
|
1020
987
|
});
|
|
1021
988
|
}
|
|
1022
989
|
async requestPrimaryName(params, options) {
|
|
1023
|
-
if (params.fundFrom === 'turbo') {
|
|
1024
|
-
throw new Error('Turbo funding is not yet supported for primary name requests');
|
|
1025
|
-
}
|
|
1026
990
|
const { tags = [] } = options || {};
|
|
1027
991
|
const allTags = [
|
|
1028
992
|
...tags,
|
package/lib/cjs/types/ant.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AntInfoSchema = exports.AntHandlersSchema = exports.AntHandlerNames = exports.AntWriteHandlers = exports.AntReadHandlers = exports.AntStateSchema = exports.AntBalancesSchema = exports.AntControllersSchema = exports.AntRecordsSchema = exports.AntRecordSchema = exports.AntKeywordsSchema = exports.AntDescriptionSchema = exports.IntegerStringSchema = exports.AOAddressSchema = exports.ArweaveTxIdSchema = void 0;
|
|
4
|
+
exports.isAoANTState = isAoANTState;
|
|
4
5
|
/**
|
|
5
6
|
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
6
7
|
*
|
|
@@ -136,4 +137,3 @@ exports.AntInfoSchema = zod_1.z.object({
|
|
|
136
137
|
function isAoANTState(state) {
|
|
137
138
|
return exports.AntStateSchema.safeParse(state).success;
|
|
138
139
|
}
|
|
139
|
-
exports.isAoANTState = isAoANTState;
|
package/lib/cjs/types/io.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isValidFundFrom = exports.fundFromOptions = exports.isValidIntent = exports.intentsUsingYears = exports.validIntents = exports.isDistributedEpoch = exports.isDistributedEpochData = void 0;
|
|
4
|
+
exports.isProcessConfiguration = isProcessConfiguration;
|
|
5
|
+
exports.isProcessIdConfiguration = isProcessIdConfiguration;
|
|
6
|
+
exports.isLeasedArNSRecord = isLeasedArNSRecord;
|
|
4
7
|
const arweave_js_1 = require("../utils/arweave.js");
|
|
5
8
|
const isDistributedEpochData = (data) => {
|
|
6
9
|
return data.distributedTimestamp !== undefined;
|
|
@@ -28,7 +31,7 @@ const isValidIntent = (intent) => {
|
|
|
28
31
|
return exports.validIntents.indexOf(intent) !== -1;
|
|
29
32
|
};
|
|
30
33
|
exports.isValidIntent = isValidIntent;
|
|
31
|
-
exports.fundFromOptions = ['balance', 'stakes', 'any'
|
|
34
|
+
exports.fundFromOptions = ['balance', 'stakes', 'any'];
|
|
32
35
|
const isValidFundFrom = (fundFrom) => {
|
|
33
36
|
return exports.fundFromOptions.indexOf(fundFrom) !== -1;
|
|
34
37
|
};
|
|
@@ -37,15 +40,12 @@ exports.isValidFundFrom = isValidFundFrom;
|
|
|
37
40
|
function isProcessConfiguration(config) {
|
|
38
41
|
return config !== undefined && 'process' in config;
|
|
39
42
|
}
|
|
40
|
-
exports.isProcessConfiguration = isProcessConfiguration;
|
|
41
43
|
function isProcessIdConfiguration(config) {
|
|
42
44
|
return (config !== undefined &&
|
|
43
45
|
'processId' in config &&
|
|
44
46
|
typeof config.processId === 'string' &&
|
|
45
47
|
(0, arweave_js_1.validateArweaveId)(config.processId) === true);
|
|
46
48
|
}
|
|
47
|
-
exports.isProcessIdConfiguration = isProcessIdConfiguration;
|
|
48
49
|
function isLeasedArNSRecord(record) {
|
|
49
50
|
return record.type === 'lease';
|
|
50
51
|
}
|
|
51
|
-
exports.isLeasedArNSRecord = isLeasedArNSRecord;
|