@ardrive/turbo-sdk 1.42.0-alpha.12 → 1.42.0-alpha.14

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.
Files changed (53) hide show
  1. package/lib/cjs/cli/cli.js +31 -0
  2. package/lib/cjs/cli/commands/arns.js +118 -0
  3. package/lib/cjs/cli/options.js +78 -1
  4. package/lib/cjs/common/folderIndex.js +394 -0
  5. package/lib/cjs/common/index.js +1 -0
  6. package/lib/cjs/common/payment.js +18 -0
  7. package/lib/cjs/common/turbo.js +8 -0
  8. package/lib/cjs/common/upload.js +267 -17
  9. package/lib/cjs/node/folderIndex.js +132 -0
  10. package/lib/cjs/node/index.js +1 -0
  11. package/lib/cjs/node/upload.js +7 -0
  12. package/lib/cjs/types.js +1 -1
  13. package/lib/cjs/utils/folderIndex.js +88 -0
  14. package/lib/esm/cli/cli.js +33 -2
  15. package/lib/esm/cli/commands/arns.js +111 -0
  16. package/lib/esm/cli/options.js +77 -0
  17. package/lib/esm/common/folderIndex.js +389 -0
  18. package/lib/esm/common/index.js +1 -0
  19. package/lib/esm/common/payment.js +18 -0
  20. package/lib/esm/common/turbo.js +8 -0
  21. package/lib/esm/common/upload.js +268 -18
  22. package/lib/esm/node/folderIndex.js +129 -0
  23. package/lib/esm/node/index.js +1 -0
  24. package/lib/esm/node/upload.js +7 -0
  25. package/lib/esm/types.js +1 -1
  26. package/lib/esm/utils/folderIndex.js +81 -0
  27. package/lib/types/cli/commands/arns.d.ts +49 -2
  28. package/lib/types/cli/commands/arns.d.ts.map +1 -1
  29. package/lib/types/cli/options.d.ts +172 -0
  30. package/lib/types/cli/options.d.ts.map +1 -1
  31. package/lib/types/cli/types.d.ts +30 -0
  32. package/lib/types/cli/types.d.ts.map +1 -1
  33. package/lib/types/common/folderIndex.d.ts +54 -0
  34. package/lib/types/common/folderIndex.d.ts.map +1 -0
  35. package/lib/types/common/index.d.ts +1 -0
  36. package/lib/types/common/index.d.ts.map +1 -1
  37. package/lib/types/common/payment.d.ts +15 -1
  38. package/lib/types/common/payment.d.ts.map +1 -1
  39. package/lib/types/common/turbo.d.ts +7 -1
  40. package/lib/types/common/turbo.d.ts.map +1 -1
  41. package/lib/types/common/upload.d.ts +41 -0
  42. package/lib/types/common/upload.d.ts.map +1 -1
  43. package/lib/types/node/folderIndex.d.ts +28 -0
  44. package/lib/types/node/folderIndex.d.ts.map +1 -0
  45. package/lib/types/node/index.d.ts +1 -0
  46. package/lib/types/node/index.d.ts.map +1 -1
  47. package/lib/types/node/upload.d.ts +1 -0
  48. package/lib/types/node/upload.d.ts.map +1 -1
  49. package/lib/types/types.d.ts +185 -1
  50. package/lib/types/types.d.ts.map +1 -1
  51. package/lib/types/utils/folderIndex.d.ts +47 -0
  52. package/lib/types/utils/folderIndex.d.ts.map +1 -0
  53. package/package.json +1 -1
@@ -147,6 +147,37 @@ const utils_js_1 = require("./utils.js");
147
147
  .description('Remove a resolution record (undername) from a Turbo-custodied ANT'), options_js_1.removeArNSRecordOptions).action(async (_commandOptions, command) => {
148
148
  await (0, utils_js_1.runCommand)(command, arns_js_1.removeArNSRecord);
149
149
  });
150
+ (0, utils_js_1.applyOptions)(commander_1.program
151
+ .command('add-arns-controller')
152
+ .description('Grant controller rights on a Turbo-custodied ANT'), options_js_1.addArNSControllerOptions).action(async (_commandOptions, command) => {
153
+ await (0, utils_js_1.runCommand)(command, arns_js_1.addArNSController);
154
+ });
155
+ (0, utils_js_1.applyOptions)(commander_1.program
156
+ .command('remove-arns-controller')
157
+ .description('Revoke controller rights on a Turbo-custodied ANT'), options_js_1.removeArNSControllerOptions).action(async (_commandOptions, command) => {
158
+ await (0, utils_js_1.runCommand)(command, arns_js_1.removeArNSController);
159
+ });
160
+ (0, utils_js_1.applyOptions)(commander_1.program
161
+ .command('transfer-arns-record')
162
+ .description('Transfer one record (undername) on a Turbo-custodied ANT to another address'), options_js_1.transferArNSRecordOptions).action(async (_commandOptions, command) => {
163
+ await (0, utils_js_1.runCommand)(command, arns_js_1.transferArNSRecord);
164
+ });
165
+ (0, utils_js_1.applyOptions)(commander_1.program
166
+ .command('set-arns-record-metadata')
167
+ .description("Set a record's display name, logo, description, or keywords on a Turbo-custodied ANT"), options_js_1.setArNSRecordMetadataOptions).action(async (_commandOptions, command) => {
168
+ await (0, utils_js_1.runCommand)(command, arns_js_1.setArNSRecordMetadata);
169
+ });
170
+ (0, utils_js_1.applyOptions)(commander_1.program
171
+ .command('remove-arns-record-metadata')
172
+ .description("Clear a record's metadata on a Turbo-custodied ANT"), options_js_1.removeArNSRecordMetadataOptions).action(async (_commandOptions, command) => {
173
+ await (0, utils_js_1.runCommand)(command, arns_js_1.removeArNSRecordMetadata);
174
+ });
175
+ (0, utils_js_1.applyOptions)(commander_1.program
176
+ .command('arns-action-price')
177
+ .description('Preview the Turbo Credit price of a non-purchase ArNS action (set-record, remove-record, ' +
178
+ 'set-record-metadata, remove-record-metadata, transfer-record, add-controller, remove-controller, transfer)'), options_js_1.arnsActionPriceOptions).action(async (_commandOptions, command) => {
179
+ await (0, utils_js_1.runCommand)(command, arns_js_1.arnsActionPrice);
180
+ });
150
181
  (0, utils_js_1.applyOptions)(commander_1.program
151
182
  .command('inspect-data-items')
152
183
  .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) => {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requiredNameFromOptions = requiredNameFromOptions;
4
4
  exports.positiveIntFromOption = positiveIntFromOption;
5
5
  exports.typeFromOptions = typeFromOptions;
6
+ exports.actionFromOptions = actionFromOptions;
6
7
  exports.paidByFromArNSOptions = paidByFromArNSOptions;
7
8
  exports.arnsPriceParamsFromOptions = arnsPriceParamsFromOptions;
8
9
  exports.arnsPrice = arnsPrice;
@@ -15,6 +16,12 @@ exports.arnsPurchaseStatus = arnsPurchaseStatus;
15
16
  exports.transferArNSAnt = transferArNSAnt;
16
17
  exports.setArNSRecord = setArNSRecord;
17
18
  exports.removeArNSRecord = removeArNSRecord;
19
+ exports.addArNSController = addArNSController;
20
+ exports.removeArNSController = removeArNSController;
21
+ exports.transferArNSRecord = transferArNSRecord;
22
+ exports.setArNSRecordMetadata = setArNSRecordMetadata;
23
+ exports.removeArNSRecordMetadata = removeArNSRecordMetadata;
24
+ exports.arnsActionPrice = arnsActionPrice;
18
25
  /**
19
26
  * Copyright (C) 2022-2024 Permanent Data Solutions, Inc.
20
27
  *
@@ -33,6 +40,7 @@ exports.removeArNSRecord = removeArNSRecord;
33
40
  const bignumber_js_1 = require("bignumber.js");
34
41
  const arnsActions_js_1 = require("../../common/arnsActions.js");
35
42
  const factory_js_1 = require("../../node/factory.js");
43
+ const types_js_1 = require("../../types.js");
36
44
  const errors_js_1 = require("../../utils/errors.js");
37
45
  const constants_js_1 = require("../constants.js");
38
46
  const utils_js_1 = require("../utils.js");
@@ -51,6 +59,13 @@ function ownerFromOptions(options) {
51
59
  }
52
60
  return (0, arnsActions_js_1.solanaOwnerSigner)(options.ownerKey);
53
61
  }
62
+ /** The four ARIO-purchase actions are priced via `arnsPrice`, not this route. */
63
+ const ARNS_PURCHASE_ACTIONS = new Set([
64
+ 'buy-name',
65
+ 'extend-lease',
66
+ 'upgrade-name',
67
+ 'increase-undername-limit',
68
+ ]);
54
69
  function requiredNameFromOptions(options) {
55
70
  if (options.name === undefined || options.name.length === 0) {
56
71
  throw new Error('Must provide an ArNS --name');
@@ -73,6 +88,25 @@ function typeFromOptions(value) {
73
88
  }
74
89
  return value;
75
90
  }
91
+ /** Parses `--action` for `arns-action-price`, rejecting the four purchase actions. */
92
+ function actionFromOptions(options) {
93
+ const { action } = options;
94
+ if (action === undefined || action.length === 0) {
95
+ throw new Error(`Must provide --action. One of: ${types_js_1.arNSActions.join(', ')}`);
96
+ }
97
+ if (!types_js_1.arNSActions.includes(action)) {
98
+ throw new Error(`Invalid --action '${action}'. One of: ${types_js_1.arNSActions.join(', ')}`);
99
+ }
100
+ if (ARNS_PURCHASE_ACTIONS.has(action)) {
101
+ throw new Error(`'${action}' is priced via \`turbo arns-price\`, not \`arns-action-price\` — ` +
102
+ 'it spends ARIO, not just the flat credits margin this route quotes.');
103
+ }
104
+ return action;
105
+ }
106
+ /** `null` clears the field (Set-Record-Metadata's tri-state), `undefined` leaves it unchanged. */
107
+ function metadataFieldFromOptions(value, clear) {
108
+ return clear ? null : value;
109
+ }
76
110
  function paidByFromArNSOptions(paidBy) {
77
111
  return paidBy !== undefined && paidBy.length > 0 ? paidBy : undefined;
78
112
  }
@@ -315,3 +349,87 @@ async function removeArNSRecord(options, turbo) {
315
349
  });
316
350
  console.log(JSON.stringify({ message: 'ArNS record removed!', ...result }, null, 2));
317
351
  }
352
+ async function addArNSController(options, turbo) {
353
+ if (options.antId === undefined) {
354
+ throw new Error('Must provide an --ant-id to add a controller to');
355
+ }
356
+ const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
357
+ const result = await client.addArNSController({
358
+ antId: options.antId,
359
+ owner: ownerFromOptions(options),
360
+ target: options.target,
361
+ });
362
+ console.log(JSON.stringify({ message: 'ArNS controller added!', ...result }, null, 2));
363
+ }
364
+ async function removeArNSController(options, turbo) {
365
+ if (options.antId === undefined) {
366
+ throw new Error('Must provide an --ant-id to remove a controller from');
367
+ }
368
+ const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
369
+ const result = await client.removeArNSController({
370
+ antId: options.antId,
371
+ owner: ownerFromOptions(options),
372
+ target: options.target,
373
+ });
374
+ console.log(JSON.stringify({ message: 'ArNS controller removed!', ...result }, null, 2));
375
+ }
376
+ async function transferArNSRecord(options, turbo) {
377
+ if (options.antId === undefined) {
378
+ throw new Error('Must provide an --ant-id whose record to transfer');
379
+ }
380
+ if (options.undername === undefined || options.undername.length === 0) {
381
+ throw new Error('Must provide an --undername to transfer');
382
+ }
383
+ if (options.target === undefined) {
384
+ throw new Error('Must provide a --target address to transfer the record to');
385
+ }
386
+ const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
387
+ const result = await client.transferArNSRecord({
388
+ antId: options.antId,
389
+ owner: ownerFromOptions(options),
390
+ undername: options.undername,
391
+ target: options.target,
392
+ });
393
+ console.log(JSON.stringify({ message: 'ArNS record transferred!', ...result }, null, 2));
394
+ }
395
+ async function setArNSRecordMetadata(options, turbo) {
396
+ if (options.antId === undefined) {
397
+ throw new Error('Must provide an --ant-id to set record metadata on');
398
+ }
399
+ const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
400
+ const result = await client.setArNSRecordMetadata({
401
+ antId: options.antId,
402
+ owner: ownerFromOptions(options),
403
+ undername: options.undername ?? '@',
404
+ displayName: metadataFieldFromOptions(options.displayName, options.clearDisplayName),
405
+ recordLogo: metadataFieldFromOptions(options.recordLogo, options.clearRecordLogo),
406
+ recordDescription: metadataFieldFromOptions(options.recordDescription, options.clearRecordDescription),
407
+ recordKeywords: metadataFieldFromOptions(options.recordKeywords, options.clearRecordKeywords),
408
+ });
409
+ console.log(JSON.stringify({ message: 'ArNS record metadata set!', ...result }, null, 2));
410
+ }
411
+ async function removeArNSRecordMetadata(options, turbo) {
412
+ if (options.antId === undefined) {
413
+ throw new Error('Must provide an --ant-id to remove record metadata from');
414
+ }
415
+ if (options.undername === undefined || options.undername.length === 0) {
416
+ throw new Error('Must provide an --undername');
417
+ }
418
+ const client = turbo ?? (await (0, utils_js_1.turboFromOptions)(options));
419
+ const result = await client.removeArNSRecordMetadata({
420
+ antId: options.antId,
421
+ owner: ownerFromOptions(options),
422
+ undername: options.undername,
423
+ });
424
+ console.log(JSON.stringify({ message: 'ArNS record metadata removed!', ...result }, null, 2));
425
+ }
426
+ /**
427
+ * Preview what one of the eight non-purchase actions will debit, without
428
+ * creating it.
429
+ */
430
+ async function arnsActionPrice(options, turbo) {
431
+ const action = actionFromOptions(options);
432
+ const client = turbo ?? factory_js_1.TurboFactory.unauthenticated((0, utils_js_1.configFromOptions)(options));
433
+ const { wincQty } = await client.getArNSActionPrice(action);
434
+ console.log(JSON.stringify({ action, wincQty, credits: creditsFromWinc(wincQty) }, null, 2));
435
+ }
@@ -15,7 +15,7 @@
15
15
  * limitations under the License.
16
16
  */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.removeArNSRecordOptions = exports.setArNSRecordOptions = exports.transferArNSAntOptions = exports.arnsPurchaseStatusOptions = exports.upgradeArNSNameOptions = exports.increaseArNSUndernamesOptions = exports.extendArNSLeaseOptions = exports.buyArNSNameOptions = exports.arnsFiatQuoteOptions = exports.arnsPriceOptions = exports.listSharesOptions = exports.revokeCreditsOptions = exports.shareCreditsOptions = exports.uploadFileOptions = exports.uploadFolderOptions = exports.uploadOptions = exports.globalOptions = exports.walletOptions = exports.optionMap = void 0;
18
+ exports.arnsActionPriceOptions = exports.removeArNSRecordMetadataOptions = exports.setArNSRecordMetadataOptions = exports.transferArNSRecordOptions = exports.removeArNSControllerOptions = exports.addArNSControllerOptions = exports.removeArNSRecordOptions = exports.setArNSRecordOptions = exports.transferArNSAntOptions = exports.arnsPurchaseStatusOptions = exports.upgradeArNSNameOptions = exports.increaseArNSUndernamesOptions = exports.extendArNSLeaseOptions = exports.buyArNSNameOptions = exports.arnsFiatQuoteOptions = 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>',
@@ -234,6 +234,48 @@ exports.optionMap = {
234
234
  alias: '--ttl-seconds <ttlSeconds>',
235
235
  description: 'TTL in seconds for the ArNS record',
236
236
  },
237
+ arnsDisplayName: {
238
+ alias: '--display-name <displayName>',
239
+ description: 'Display name for the record (Set-Record-Metadata)',
240
+ },
241
+ arnsClearDisplayName: {
242
+ alias: '--clear-display-name',
243
+ description: 'Clear the record display name (Set-Record-Metadata)',
244
+ default: false,
245
+ },
246
+ arnsRecordLogo: {
247
+ alias: '--record-logo <transactionId>',
248
+ description: 'Arweave transaction ID for the record logo (Set-Record-Metadata)',
249
+ },
250
+ arnsClearRecordLogo: {
251
+ alias: '--clear-record-logo',
252
+ description: 'Clear the record logo (Set-Record-Metadata)',
253
+ default: false,
254
+ },
255
+ arnsRecordDescription: {
256
+ alias: '--record-description <description>',
257
+ description: 'Description for the record (Set-Record-Metadata)',
258
+ },
259
+ arnsClearRecordDescription: {
260
+ alias: '--clear-record-description',
261
+ description: 'Clear the record description (Set-Record-Metadata)',
262
+ default: false,
263
+ },
264
+ arnsRecordKeywords: {
265
+ alias: '--record-keywords <keywords...>',
266
+ description: 'Keywords for the record (Set-Record-Metadata)',
267
+ type: 'array',
268
+ },
269
+ arnsClearRecordKeywords: {
270
+ alias: '--clear-record-keywords',
271
+ description: 'Clear the record keywords (Set-Record-Metadata)',
272
+ default: false,
273
+ },
274
+ arnsAction: {
275
+ alias: '--action <action>',
276
+ description: 'ArNS action to price: set-record, remove-record, set-record-metadata, ' +
277
+ 'remove-record-metadata, transfer-record, add-controller, remove-controller, or transfer',
278
+ },
237
279
  // ---- Payment history ----
238
280
  limit: {
239
281
  alias: '--limit <limit>',
@@ -365,3 +407,38 @@ exports.removeArNSRecordOptions = [
365
407
  exports.optionMap.arnsAntId,
366
408
  exports.optionMap.arnsUndername,
367
409
  ];
410
+ exports.addArNSControllerOptions = [
411
+ ...exports.walletOptions,
412
+ exports.optionMap.arnsOwnerKey,
413
+ exports.optionMap.arnsAntId,
414
+ exports.optionMap.arnsTarget,
415
+ ];
416
+ exports.removeArNSControllerOptions = exports.addArNSControllerOptions;
417
+ exports.transferArNSRecordOptions = [
418
+ ...exports.walletOptions,
419
+ exports.optionMap.arnsOwnerKey,
420
+ exports.optionMap.arnsAntId,
421
+ exports.optionMap.arnsUndername,
422
+ exports.optionMap.arnsTarget,
423
+ ];
424
+ exports.setArNSRecordMetadataOptions = [
425
+ ...exports.walletOptions,
426
+ exports.optionMap.arnsOwnerKey,
427
+ exports.optionMap.arnsAntId,
428
+ exports.optionMap.arnsUndername,
429
+ exports.optionMap.arnsDisplayName,
430
+ exports.optionMap.arnsClearDisplayName,
431
+ exports.optionMap.arnsRecordLogo,
432
+ exports.optionMap.arnsClearRecordLogo,
433
+ exports.optionMap.arnsRecordDescription,
434
+ exports.optionMap.arnsClearRecordDescription,
435
+ exports.optionMap.arnsRecordKeywords,
436
+ exports.optionMap.arnsClearRecordKeywords,
437
+ ];
438
+ exports.removeArNSRecordMetadataOptions = [
439
+ ...exports.walletOptions,
440
+ exports.optionMap.arnsOwnerKey,
441
+ exports.optionMap.arnsAntId,
442
+ exports.optionMap.arnsUndername,
443
+ ];
444
+ exports.arnsActionPriceOptions = [exports.optionMap.arnsAction];