@ardrive/turbo-sdk 1.42.0-alpha.2 → 1.42.0-alpha.3
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/lib/cjs/cli/cli.js +46 -0
- package/lib/cjs/cli/commands/arns.js +249 -0
- package/lib/cjs/cli/commands/index.js +1 -0
- package/lib/cjs/cli/options.js +97 -1
- package/lib/cjs/common/http.js +4 -3
- package/lib/cjs/common/index.js +3 -0
- package/lib/cjs/common/payment.js +199 -0
- package/lib/cjs/common/signer.js +11 -3
- package/lib/cjs/common/turbo.js +44 -0
- package/lib/cjs/types.js +8 -1
- package/lib/cjs/utils/errors.js +19 -1
- package/lib/cjs/utils/uuid.js +31 -0
- package/lib/cjs/web/signer.js +4 -2
- package/lib/esm/cli/cli.js +47 -1
- package/lib/esm/cli/commands/arns.js +233 -0
- package/lib/esm/cli/commands/index.js +1 -0
- package/lib/esm/cli/options.js +96 -0
- package/lib/esm/common/http.js +4 -3
- package/lib/esm/common/index.js +3 -0
- package/lib/esm/common/payment.js +199 -0
- package/lib/esm/common/signer.js +11 -3
- package/lib/esm/common/turbo.js +44 -0
- package/lib/esm/types.js +7 -0
- package/lib/esm/utils/errors.js +17 -0
- package/lib/esm/utils/uuid.js +28 -0
- package/lib/esm/web/signer.js +4 -2
- package/lib/types/cli/commands/arns.d.ts +88 -0
- package/lib/types/cli/commands/arns.d.ts.map +1 -0
- package/lib/types/cli/commands/index.d.ts +1 -0
- package/lib/types/cli/commands/index.d.ts.map +1 -1
- package/lib/types/cli/options.d.ts +201 -0
- package/lib/types/cli/options.d.ts.map +1 -1
- package/lib/types/cli/types.d.ts +27 -0
- package/lib/types/cli/types.d.ts.map +1 -1
- package/lib/types/common/http.d.ts +2 -1
- package/lib/types/common/http.d.ts.map +1 -1
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/common/index.d.ts.map +1 -1
- package/lib/types/common/payment.d.ts +64 -1
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/signer.d.ts +1 -1
- package/lib/types/common/signer.d.ts.map +1 -1
- package/lib/types/common/turbo.d.ts +53 -1
- package/lib/types/common/turbo.d.ts.map +1 -1
- package/lib/types/types.d.ts +135 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/errors.d.ts +14 -0
- package/lib/types/utils/errors.d.ts.map +1 -1
- package/lib/types/utils/uuid.d.ts +7 -0
- package/lib/types/utils/uuid.d.ts.map +1 -0
- package/lib/types/web/signer.d.ts +1 -1
- package/lib/types/web/signer.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/cli/cli.js
CHANGED
|
@@ -22,6 +22,7 @@ const arbundles_1 = require("@dha-team/arbundles");
|
|
|
22
22
|
const commander_1 = require("commander");
|
|
23
23
|
const fs_1 = require("fs");
|
|
24
24
|
const version_js_1 = require("../version.js");
|
|
25
|
+
const arns_js_1 = require("./commands/arns.js");
|
|
25
26
|
const fiatEstimate_js_1 = require("./commands/fiatEstimate.js");
|
|
26
27
|
const index_js_1 = require("./commands/index.js");
|
|
27
28
|
const listShares_js_1 = require("./commands/listShares.js");
|
|
@@ -86,6 +87,51 @@ const utils_js_1 = require("./utils.js");
|
|
|
86
87
|
.description('Lists all given or received Turbo credit share approvals for specified address or connected wallet'), options_js_1.listSharesOptions).action(async (_commandOptions, command) => {
|
|
87
88
|
await (0, utils_js_1.runCommand)(command, listShares_js_1.listShares);
|
|
88
89
|
});
|
|
90
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
91
|
+
.command('arns-price')
|
|
92
|
+
.description('Get the Turbo Credit (winc + mARIO) price to buy, extend, increase undernames, or upgrade an ArNS name'), options_js_1.arnsPriceOptions).action(async (_commandOptions, command) => {
|
|
93
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.arnsPrice);
|
|
94
|
+
});
|
|
95
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
96
|
+
.command('buy-arns-name')
|
|
97
|
+
.description('Buy an ArNS name (lease or permabuy) with Turbo Credits'), options_js_1.buyArNSNameOptions).action(async (_commandOptions, command) => {
|
|
98
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.buyArNSName);
|
|
99
|
+
});
|
|
100
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
101
|
+
.command('extend-arns-lease')
|
|
102
|
+
.description('Extend an ArNS name lease with Turbo Credits'), options_js_1.extendArNSLeaseOptions).action(async (_commandOptions, command) => {
|
|
103
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.extendArNSLease);
|
|
104
|
+
});
|
|
105
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
106
|
+
.command('increase-arns-undernames')
|
|
107
|
+
.description('Increase the undername limit of an ArNS name with Turbo Credits'), options_js_1.increaseArNSUndernamesOptions).action(async (_commandOptions, command) => {
|
|
108
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.increaseArNSUndernames);
|
|
109
|
+
});
|
|
110
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
111
|
+
.command('upgrade-arns-name')
|
|
112
|
+
.description('Upgrade an ArNS leased name to a permabuy with Turbo Credits'), options_js_1.upgradeArNSNameOptions).action(async (_commandOptions, command) => {
|
|
113
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.upgradeArNSName);
|
|
114
|
+
});
|
|
115
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
116
|
+
.command('arns-purchase-status')
|
|
117
|
+
.description('Get the status of an ArNS purchase by its nonce'), options_js_1.arnsPurchaseStatusOptions).action(async (_commandOptions, command) => {
|
|
118
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.arnsPurchaseStatus);
|
|
119
|
+
});
|
|
120
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
121
|
+
.command('transfer-arns-ant')
|
|
122
|
+
.description('Transfer a Turbo-custodied ANT to a Solana pubkey you control'), options_js_1.transferArNSAntOptions).action(async (_commandOptions, command) => {
|
|
123
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.transferArNSAnt);
|
|
124
|
+
});
|
|
125
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
126
|
+
.command('set-arns-record')
|
|
127
|
+
.description('Set a resolution record on a Turbo-custodied ANT'), options_js_1.setArNSRecordOptions).action(async (_commandOptions, command) => {
|
|
128
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.setArNSRecord);
|
|
129
|
+
});
|
|
130
|
+
(0, utils_js_1.applyOptions)(commander_1.program
|
|
131
|
+
.command('remove-arns-record')
|
|
132
|
+
.description('Remove a resolution record (undername) from a Turbo-custodied ANT'), options_js_1.removeArNSRecordOptions).action(async (_commandOptions, command) => {
|
|
133
|
+
await (0, utils_js_1.runCommand)(command, arns_js_1.removeArNSRecord);
|
|
134
|
+
});
|
|
89
135
|
(0, utils_js_1.applyOptions)(commander_1.program
|
|
90
136
|
.command('inspect-data-items')
|
|
91
137
|
.description('Lists all given or received Turbo credit share approvals for specified address or connected wallet'), [options_js_1.optionMap.folderPath]).action(async (_commandOptions, command) => {
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requiredNameFromOptions = requiredNameFromOptions;
|
|
4
|
+
exports.positiveIntFromOption = positiveIntFromOption;
|
|
5
|
+
exports.typeFromOptions = typeFromOptions;
|
|
6
|
+
exports.paidByFromArNSOptions = paidByFromArNSOptions;
|
|
7
|
+
exports.arnsPriceParamsFromOptions = arnsPriceParamsFromOptions;
|
|
8
|
+
exports.arnsPrice = arnsPrice;
|
|
9
|
+
exports.buyArNSName = buyArNSName;
|
|
10
|
+
exports.extendArNSLease = extendArNSLease;
|
|
11
|
+
exports.increaseArNSUndernames = increaseArNSUndernames;
|
|
12
|
+
exports.upgradeArNSName = upgradeArNSName;
|
|
13
|
+
exports.arnsPurchaseStatus = arnsPurchaseStatus;
|
|
14
|
+
exports.transferArNSAnt = transferArNSAnt;
|
|
15
|
+
exports.setArNSRecord = setArNSRecord;
|
|
16
|
+
exports.removeArNSRecord = removeArNSRecord;
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
|
|
19
|
+
*
|
|
20
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License.
|
|
22
|
+
* You may obtain a copy of the License at
|
|
23
|
+
*
|
|
24
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
*
|
|
26
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
* See the License for the specific language governing permissions and
|
|
30
|
+
* limitations under the License.
|
|
31
|
+
*/
|
|
32
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
33
|
+
const factory_js_1 = require("../../node/factory.js");
|
|
34
|
+
const errors_js_1 = require("../../utils/errors.js");
|
|
35
|
+
const constants_js_1 = require("../constants.js");
|
|
36
|
+
const utils_js_1 = require("../utils.js");
|
|
37
|
+
function requiredNameFromOptions(options) {
|
|
38
|
+
if (options.name === undefined || options.name.length === 0) {
|
|
39
|
+
throw new Error('Must provide an ArNS --name');
|
|
40
|
+
}
|
|
41
|
+
return options.name;
|
|
42
|
+
}
|
|
43
|
+
function positiveIntFromOption(value, flag) {
|
|
44
|
+
if (value === undefined) {
|
|
45
|
+
throw new Error(`Must provide ${flag}`);
|
|
46
|
+
}
|
|
47
|
+
const num = +value;
|
|
48
|
+
if (!Number.isFinite(num) || !Number.isInteger(num) || num <= 0) {
|
|
49
|
+
throw new Error(`${flag} must be a positive integer`);
|
|
50
|
+
}
|
|
51
|
+
return num;
|
|
52
|
+
}
|
|
53
|
+
function typeFromOptions(value) {
|
|
54
|
+
if (value !== 'lease' && value !== 'permabuy') {
|
|
55
|
+
throw new Error("Must provide --type of 'lease' or 'permabuy'");
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function paidByFromArNSOptions(paidBy) {
|
|
60
|
+
return paidBy !== undefined && paidBy.length > 0 ? paidBy : undefined;
|
|
61
|
+
}
|
|
62
|
+
// A price quote depends only on the name (length), type, and years — NOT on the
|
|
63
|
+
// ANT the name will resolve to. The service ignores `processId` for pricing, but
|
|
64
|
+
// the SDK's Buy-Name validation still requires a non-empty one, so we substitute
|
|
65
|
+
// this obvious placeholder when the user omits `--process-id` from `arns-price`.
|
|
66
|
+
// (`buy-arns-name` still requires a real `--process-id`.)
|
|
67
|
+
const PRICING_PLACEHOLDER_PROCESS_ID = 'pricing-only-no-process-id';
|
|
68
|
+
/**
|
|
69
|
+
* Infer the ArNS pricing intent from the provided flags:
|
|
70
|
+
* - `--type` present -> Buy-Name (lease needs --years; --process-id optional for pricing)
|
|
71
|
+
* - `--increase-qty` present -> Increase-Undername-Limit
|
|
72
|
+
* - `--years` present (no type) -> Extend-Lease
|
|
73
|
+
* - otherwise -> Upgrade-Name
|
|
74
|
+
*/
|
|
75
|
+
function arnsPriceParamsFromOptions(options) {
|
|
76
|
+
const name = requiredNameFromOptions(options);
|
|
77
|
+
if (options.type !== undefined) {
|
|
78
|
+
const type = typeFromOptions(options.type);
|
|
79
|
+
const processId = options.processId ?? PRICING_PLACEHOLDER_PROCESS_ID;
|
|
80
|
+
if (type === 'lease') {
|
|
81
|
+
return {
|
|
82
|
+
intent: 'Buy-Name',
|
|
83
|
+
name,
|
|
84
|
+
type: 'lease',
|
|
85
|
+
years: positiveIntFromOption(options.years, '--years'),
|
|
86
|
+
processId,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
intent: 'Buy-Name',
|
|
91
|
+
name,
|
|
92
|
+
type: 'permabuy',
|
|
93
|
+
processId,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
if (options.increaseQty !== undefined) {
|
|
97
|
+
return {
|
|
98
|
+
intent: 'Increase-Undername-Limit',
|
|
99
|
+
name,
|
|
100
|
+
increaseQty: positiveIntFromOption(options.increaseQty, '--increase-qty'),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
if (options.years !== undefined) {
|
|
104
|
+
return {
|
|
105
|
+
intent: 'Extend-Lease',
|
|
106
|
+
name,
|
|
107
|
+
years: positiveIntFromOption(options.years, '--years'),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return { intent: 'Upgrade-Name', name };
|
|
111
|
+
}
|
|
112
|
+
function creditsFromWinc(winc) {
|
|
113
|
+
return new bignumber_js_1.BigNumber(winc).dividedBy(constants_js_1.wincPerCredit).toFixed(12);
|
|
114
|
+
}
|
|
115
|
+
/** Rethrow a 402 as a clear, actionable "top up" message. */
|
|
116
|
+
async function withCreditErrorMapping(fn) {
|
|
117
|
+
try {
|
|
118
|
+
return await fn();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error instanceof errors_js_1.InsufficientCreditsError) {
|
|
122
|
+
throw new Error('Insufficient Turbo credits to complete this ArNS purchase. ' +
|
|
123
|
+
'Top up your balance (e.g. `turbo top-up` or `turbo crypto-fund`) and retry.');
|
|
124
|
+
}
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function logPurchaseResult(action, result) {
|
|
129
|
+
console.log(JSON.stringify({
|
|
130
|
+
message: `${action} submitted!`,
|
|
131
|
+
nonce: result.nonce,
|
|
132
|
+
arioWriteId: result.arioWriteResult?.id,
|
|
133
|
+
purchaseReceipt: result.purchaseReceipt,
|
|
134
|
+
}, null, 2));
|
|
135
|
+
console.log(`\nTrack this purchase with:\n turbo arns-purchase-status --nonce ${result.nonce}`);
|
|
136
|
+
}
|
|
137
|
+
async function arnsPrice(options, turbo) {
|
|
138
|
+
const params = arnsPriceParamsFromOptions(options);
|
|
139
|
+
const client = turbo ?? factory_js_1.TurboFactory.unauthenticated((0, utils_js_1.configFromOptions)(options));
|
|
140
|
+
const { winc, mARIO } = await client.getArNSPriceForName(params);
|
|
141
|
+
console.log(JSON.stringify({
|
|
142
|
+
name: params.name,
|
|
143
|
+
intent: params.intent,
|
|
144
|
+
winc,
|
|
145
|
+
credits: creditsFromWinc(winc),
|
|
146
|
+
mARIO,
|
|
147
|
+
}, null, 2));
|
|
148
|
+
}
|
|
149
|
+
async function buyArNSName(options, turbo) {
|
|
150
|
+
const name = requiredNameFromOptions(options);
|
|
151
|
+
const type = typeFromOptions(options.type);
|
|
152
|
+
const paidBy = paidByFromArNSOptions(options.paidBy);
|
|
153
|
+
// `--process-id` is OPTIONAL: omit it to have Turbo custodially provision the
|
|
154
|
+
// ANT (Turbo spawns + owns it — Model A); supply it to point the name at a
|
|
155
|
+
// user-owned ANT (Model B). When omitted, no `processId` is sent.
|
|
156
|
+
const processId = options.processId;
|
|
157
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
158
|
+
const result = await withCreditErrorMapping(() => type === 'lease'
|
|
159
|
+
? client.buyArNSName({
|
|
160
|
+
name,
|
|
161
|
+
type: 'lease',
|
|
162
|
+
years: positiveIntFromOption(options.years, '--years'),
|
|
163
|
+
processId,
|
|
164
|
+
paidBy,
|
|
165
|
+
})
|
|
166
|
+
: client.buyArNSName({ name, type: 'permabuy', processId, paidBy }));
|
|
167
|
+
logPurchaseResult('ArNS name purchase', result);
|
|
168
|
+
}
|
|
169
|
+
async function extendArNSLease(options, turbo) {
|
|
170
|
+
const name = requiredNameFromOptions(options);
|
|
171
|
+
const years = positiveIntFromOption(options.years, '--years');
|
|
172
|
+
const paidBy = paidByFromArNSOptions(options.paidBy);
|
|
173
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
174
|
+
const result = await withCreditErrorMapping(() => client.extendArNSLease({ name, years, paidBy }));
|
|
175
|
+
logPurchaseResult('ArNS lease extension', result);
|
|
176
|
+
}
|
|
177
|
+
async function increaseArNSUndernames(options, turbo) {
|
|
178
|
+
const name = requiredNameFromOptions(options);
|
|
179
|
+
const increaseQty = positiveIntFromOption(options.increaseQty, '--increase-qty');
|
|
180
|
+
const paidBy = paidByFromArNSOptions(options.paidBy);
|
|
181
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
182
|
+
const result = await withCreditErrorMapping(() => client.increaseArNSUndernameLimit({ name, increaseQty, paidBy }));
|
|
183
|
+
logPurchaseResult('ArNS undername limit increase', result);
|
|
184
|
+
}
|
|
185
|
+
async function upgradeArNSName(options, turbo) {
|
|
186
|
+
const name = requiredNameFromOptions(options);
|
|
187
|
+
const paidBy = paidByFromArNSOptions(options.paidBy);
|
|
188
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
189
|
+
const result = await withCreditErrorMapping(() => client.upgradeArNSName({ name, paidBy }));
|
|
190
|
+
logPurchaseResult('ArNS name upgrade (to permabuy)', result);
|
|
191
|
+
}
|
|
192
|
+
async function arnsPurchaseStatus(options, turbo) {
|
|
193
|
+
if (options.nonce === undefined || options.nonce.length === 0) {
|
|
194
|
+
throw new Error('Must provide a --nonce to look up purchase status');
|
|
195
|
+
}
|
|
196
|
+
const client = turbo ?? factory_js_1.TurboFactory.unauthenticated((0, utils_js_1.configFromOptions)(options));
|
|
197
|
+
const status = await client.getArNSPurchaseStatus({ nonce: options.nonce });
|
|
198
|
+
const state = status.failedDate !== undefined
|
|
199
|
+
? 'failed'
|
|
200
|
+
: status.messageId
|
|
201
|
+
? 'success'
|
|
202
|
+
: 'pending';
|
|
203
|
+
console.log(JSON.stringify({ state, ...status }, null, 2));
|
|
204
|
+
}
|
|
205
|
+
async function transferArNSAnt(options, turbo) {
|
|
206
|
+
if (options.antId === undefined) {
|
|
207
|
+
throw new Error('Must provide an --ant-id to transfer');
|
|
208
|
+
}
|
|
209
|
+
if (options.target === undefined) {
|
|
210
|
+
throw new Error('Must provide a --target address to transfer the ANT to');
|
|
211
|
+
}
|
|
212
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
213
|
+
const result = await client.transferArNSAnt({
|
|
214
|
+
antId: options.antId,
|
|
215
|
+
target: options.target,
|
|
216
|
+
});
|
|
217
|
+
console.log(JSON.stringify({ message: 'ANT transfer submitted!', ...result }, null, 2));
|
|
218
|
+
}
|
|
219
|
+
async function setArNSRecord(options, turbo) {
|
|
220
|
+
if (options.antId === undefined) {
|
|
221
|
+
throw new Error('Must provide an --ant-id to set a record on');
|
|
222
|
+
}
|
|
223
|
+
if (options.transactionId === undefined) {
|
|
224
|
+
throw new Error('Must provide a --transaction-id for the record');
|
|
225
|
+
}
|
|
226
|
+
const ttlSeconds = positiveIntFromOption(options.ttlSeconds, '--ttl-seconds');
|
|
227
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
228
|
+
const result = await client.setArNSRecord({
|
|
229
|
+
antId: options.antId,
|
|
230
|
+
undername: options.undername ?? '@',
|
|
231
|
+
transactionId: options.transactionId,
|
|
232
|
+
ttlSeconds,
|
|
233
|
+
});
|
|
234
|
+
console.log(JSON.stringify({ message: 'ArNS record set!', ...result }, null, 2));
|
|
235
|
+
}
|
|
236
|
+
async function removeArNSRecord(options, turbo) {
|
|
237
|
+
if (options.antId === undefined) {
|
|
238
|
+
throw new Error('Must provide an --ant-id to remove a record from');
|
|
239
|
+
}
|
|
240
|
+
if (options.undername === undefined || options.undername.length === 0) {
|
|
241
|
+
throw new Error('Must provide an --undername to remove');
|
|
242
|
+
}
|
|
243
|
+
const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
|
|
244
|
+
const result = await client.removeArNSRecord({
|
|
245
|
+
antId: options.antId,
|
|
246
|
+
undername: options.undername,
|
|
247
|
+
});
|
|
248
|
+
console.log(JSON.stringify({ message: 'ArNS record removed!', ...result }, null, 2));
|
|
249
|
+
}
|
|
@@ -29,6 +29,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
29
29
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
__exportStar(require("./arns.js"), exports);
|
|
32
33
|
__exportStar(require("./balance.js"), exports);
|
|
33
34
|
__exportStar(require("./cryptoFund.js"), exports);
|
|
34
35
|
__exportStar(require("./price.js"), exports);
|
package/lib/cjs/cli/options.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.listSharesOptions = exports.revokeCreditsOptions = exports.shareCreditsOptions = exports.uploadFileOptions = exports.uploadFolderOptions = exports.uploadOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
|
|
18
|
+
exports.removeArNSRecordOptions = exports.setArNSRecordOptions = exports.transferArNSAntOptions = exports.arnsPurchaseStatusOptions = exports.upgradeArNSNameOptions = exports.increaseArNSUndernamesOptions = exports.extendArNSLeaseOptions = exports.buyArNSNameOptions = exports.arnsPriceOptions = exports.listSharesOptions = exports.revokeCreditsOptions = exports.shareCreditsOptions = exports.uploadFileOptions = exports.uploadFolderOptions = exports.uploadOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
|
|
19
19
|
exports.optionMap = {
|
|
20
20
|
token: {
|
|
21
21
|
alias: '-t, --token <type>',
|
|
@@ -189,6 +189,51 @@ exports.optionMap = {
|
|
|
189
189
|
alias: '--max-crypto-top-up-value <maxCryptoTopUpValue>',
|
|
190
190
|
description: 'Maximum crypto top-up value to use for the upload. Defaults to no limit.',
|
|
191
191
|
},
|
|
192
|
+
// ---- ArNS (paid with Turbo Credits) ----
|
|
193
|
+
arnsName: {
|
|
194
|
+
alias: '--name <name>',
|
|
195
|
+
description: 'ArNS name to price, buy, or manage',
|
|
196
|
+
},
|
|
197
|
+
arnsType: {
|
|
198
|
+
alias: '--type <type>',
|
|
199
|
+
description: "ArNS purchase type for Buy-Name: 'lease' or 'permabuy'",
|
|
200
|
+
},
|
|
201
|
+
arnsYears: {
|
|
202
|
+
alias: '--years <years>',
|
|
203
|
+
description: 'Lease duration in years (Buy-Name lease / Extend-Lease)',
|
|
204
|
+
},
|
|
205
|
+
arnsIncreaseQty: {
|
|
206
|
+
alias: '--increase-qty <qty>',
|
|
207
|
+
description: 'Number of additional undernames (Increase-Undername-Limit)',
|
|
208
|
+
},
|
|
209
|
+
arnsProcessId: {
|
|
210
|
+
alias: '--process-id <processId>',
|
|
211
|
+
description: 'ANT process ID the ArNS name resolves to (Buy-Name). Optional: omit for Turbo custodial provisioning (Turbo owns the ANT); supply for a user-owned ANT',
|
|
212
|
+
},
|
|
213
|
+
arnsNonce: {
|
|
214
|
+
alias: '--nonce <nonce>',
|
|
215
|
+
description: 'ArNS purchase nonce to look up the status for',
|
|
216
|
+
},
|
|
217
|
+
arnsAntId: {
|
|
218
|
+
alias: '--ant-id <antId>',
|
|
219
|
+
description: 'ANT (Metaplex Core asset) ID to transfer or manage',
|
|
220
|
+
},
|
|
221
|
+
arnsTarget: {
|
|
222
|
+
alias: '--target <address>',
|
|
223
|
+
description: 'Target Solana pubkey to transfer the ANT to',
|
|
224
|
+
},
|
|
225
|
+
arnsUndername: {
|
|
226
|
+
alias: '--undername <undername>',
|
|
227
|
+
description: "ArNS undername record to set or remove (defaults to '@')",
|
|
228
|
+
},
|
|
229
|
+
arnsTransactionId: {
|
|
230
|
+
alias: '--transaction-id <transactionId>',
|
|
231
|
+
description: 'Arweave transaction ID the ArNS record resolves to',
|
|
232
|
+
},
|
|
233
|
+
arnsTtlSeconds: {
|
|
234
|
+
alias: '--ttl-seconds <ttlSeconds>',
|
|
235
|
+
description: 'TTL in seconds for the ArNS record',
|
|
236
|
+
},
|
|
192
237
|
};
|
|
193
238
|
exports.walletOptions = [
|
|
194
239
|
exports.optionMap.walletFile,
|
|
@@ -242,3 +287,54 @@ exports.shareCreditsOptions = [
|
|
|
242
287
|
];
|
|
243
288
|
exports.revokeCreditsOptions = [...exports.walletOptions, exports.optionMap.address];
|
|
244
289
|
exports.listSharesOptions = exports.revokeCreditsOptions;
|
|
290
|
+
// ---- ArNS command option sets (token + --payment-url come from globalOptions) ----
|
|
291
|
+
exports.arnsPriceOptions = [
|
|
292
|
+
exports.optionMap.arnsName,
|
|
293
|
+
exports.optionMap.arnsType,
|
|
294
|
+
exports.optionMap.arnsYears,
|
|
295
|
+
exports.optionMap.arnsIncreaseQty,
|
|
296
|
+
exports.optionMap.arnsProcessId,
|
|
297
|
+
];
|
|
298
|
+
exports.buyArNSNameOptions = [
|
|
299
|
+
...exports.walletOptions,
|
|
300
|
+
exports.optionMap.arnsName,
|
|
301
|
+
exports.optionMap.arnsType,
|
|
302
|
+
exports.optionMap.arnsYears,
|
|
303
|
+
exports.optionMap.arnsProcessId,
|
|
304
|
+
exports.optionMap.paidBy,
|
|
305
|
+
];
|
|
306
|
+
exports.extendArNSLeaseOptions = [
|
|
307
|
+
...exports.walletOptions,
|
|
308
|
+
exports.optionMap.arnsName,
|
|
309
|
+
exports.optionMap.arnsYears,
|
|
310
|
+
exports.optionMap.paidBy,
|
|
311
|
+
];
|
|
312
|
+
exports.increaseArNSUndernamesOptions = [
|
|
313
|
+
...exports.walletOptions,
|
|
314
|
+
exports.optionMap.arnsName,
|
|
315
|
+
exports.optionMap.arnsIncreaseQty,
|
|
316
|
+
exports.optionMap.paidBy,
|
|
317
|
+
];
|
|
318
|
+
exports.upgradeArNSNameOptions = [
|
|
319
|
+
...exports.walletOptions,
|
|
320
|
+
exports.optionMap.arnsName,
|
|
321
|
+
exports.optionMap.paidBy,
|
|
322
|
+
];
|
|
323
|
+
exports.arnsPurchaseStatusOptions = [exports.optionMap.arnsNonce];
|
|
324
|
+
exports.transferArNSAntOptions = [
|
|
325
|
+
...exports.walletOptions,
|
|
326
|
+
exports.optionMap.arnsAntId,
|
|
327
|
+
exports.optionMap.arnsTarget,
|
|
328
|
+
];
|
|
329
|
+
exports.setArNSRecordOptions = [
|
|
330
|
+
...exports.walletOptions,
|
|
331
|
+
exports.optionMap.arnsAntId,
|
|
332
|
+
exports.optionMap.arnsUndername,
|
|
333
|
+
exports.optionMap.arnsTransactionId,
|
|
334
|
+
exports.optionMap.arnsTtlSeconds,
|
|
335
|
+
];
|
|
336
|
+
exports.removeArNSRecordOptions = [
|
|
337
|
+
...exports.walletOptions,
|
|
338
|
+
exports.optionMap.arnsAntId,
|
|
339
|
+
exports.optionMap.arnsUndername,
|
|
340
|
+
];
|
package/lib/cjs/common/http.js
CHANGED
|
@@ -47,7 +47,7 @@ class TurboHTTPService {
|
|
|
47
47
|
signal,
|
|
48
48
|
}), allowedStatuses);
|
|
49
49
|
}
|
|
50
|
-
async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, x402Options, }) {
|
|
50
|
+
async post({ endpoint, signal, allowedStatuses = [200, 202], headers, data, x402Options, retry = true, }) {
|
|
51
51
|
if (x402Options !== undefined) {
|
|
52
52
|
return this.x402Post({
|
|
53
53
|
signal,
|
|
@@ -59,9 +59,10 @@ class TurboHTTPService {
|
|
|
59
59
|
}
|
|
60
60
|
// Convert all data types to fetch-compatible body
|
|
61
61
|
const { body, duplex } = await toFetchBody(data);
|
|
62
|
-
// Use retry for Buffer/Uint8Array, tryRequest for streams
|
|
62
|
+
// Use retry for Buffer/Uint8Array, tryRequest for streams. Callers can opt
|
|
63
|
+
// out of retry for non-idempotent signed writes via `retry: false`.
|
|
63
64
|
const isReusableData = data instanceof Buffer || data instanceof Uint8Array;
|
|
64
|
-
const requestFn = isReusableData
|
|
65
|
+
const requestFn = isReusableData && retry
|
|
65
66
|
? this.withRetry.bind(this)
|
|
66
67
|
: this.tryRequest.bind(this);
|
|
67
68
|
return requestFn(() => fetch(this.baseURL + endpoint, {
|
package/lib/cjs/common/index.js
CHANGED
|
@@ -34,3 +34,6 @@ __exportStar(require("./payment.js"), exports);
|
|
|
34
34
|
__exportStar(require("./turbo.js"), exports);
|
|
35
35
|
__exportStar(require("./currency.js"), exports);
|
|
36
36
|
__exportStar(require("./token/index.js"), exports);
|
|
37
|
+
// Typed errors so consumers can `catch (e) { if (e instanceof InsufficientCreditsError) ... }`
|
|
38
|
+
// e.g. to prompt a top-up on a 402 ArNS purchase.
|
|
39
|
+
__exportStar(require("../utils/errors.js"), exports);
|