@ardrive/turbo-sdk 1.42.0 → 1.43.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.
Files changed (99) hide show
  1. package/lib/cjs/cli/cli.js +97 -0
  2. package/lib/cjs/cli/commands/arns.js +475 -0
  3. package/lib/cjs/cli/commands/freeStatus.js +47 -0
  4. package/lib/cjs/cli/commands/index.js +3 -0
  5. package/lib/cjs/cli/commands/paymentHistory.js +25 -0
  6. package/lib/cjs/cli/options.js +202 -1
  7. package/lib/cjs/common/arnsActions.js +125 -0
  8. package/lib/cjs/common/chunked.js +51 -1
  9. package/lib/cjs/common/folderIndex.js +401 -0
  10. package/lib/cjs/common/http.js +40 -6
  11. package/lib/cjs/common/index.js +7 -0
  12. package/lib/cjs/common/payment.js +548 -2
  13. package/lib/cjs/common/signer.js +27 -6
  14. package/lib/cjs/common/token/index.js +0 -11
  15. package/lib/cjs/common/turbo.js +162 -0
  16. package/lib/cjs/common/upload.js +314 -31
  17. package/lib/cjs/node/folderIndex.js +132 -0
  18. package/lib/cjs/node/index.js +1 -0
  19. package/lib/cjs/node/upload.js +7 -0
  20. package/lib/cjs/types.js +53 -3
  21. package/lib/cjs/utils/common.js +0 -4
  22. package/lib/cjs/utils/errors.js +38 -1
  23. package/lib/cjs/utils/folderIndex.js +88 -0
  24. package/lib/cjs/utils/uuid.js +31 -0
  25. package/lib/cjs/web/signer.js +4 -2
  26. package/lib/esm/cli/cli.js +99 -2
  27. package/lib/esm/cli/commands/arns.js +450 -0
  28. package/lib/esm/cli/commands/freeStatus.js +44 -0
  29. package/lib/esm/cli/commands/index.js +3 -0
  30. package/lib/esm/cli/commands/paymentHistory.js +22 -0
  31. package/lib/esm/cli/options.js +201 -0
  32. package/lib/esm/common/arnsActions.js +114 -0
  33. package/lib/esm/common/chunked.js +51 -1
  34. package/lib/esm/common/folderIndex.js +396 -0
  35. package/lib/esm/common/http.js +39 -5
  36. package/lib/esm/common/index.js +7 -0
  37. package/lib/esm/common/payment.js +548 -2
  38. package/lib/esm/common/signer.js +28 -7
  39. package/lib/esm/common/token/index.js +1 -12
  40. package/lib/esm/common/turbo.js +162 -0
  41. package/lib/esm/common/upload.js +316 -33
  42. package/lib/esm/node/folderIndex.js +129 -0
  43. package/lib/esm/node/index.js +1 -0
  44. package/lib/esm/node/upload.js +7 -0
  45. package/lib/esm/types.js +52 -2
  46. package/lib/esm/utils/common.js +0 -4
  47. package/lib/esm/utils/errors.js +35 -0
  48. package/lib/esm/utils/folderIndex.js +81 -0
  49. package/lib/esm/utils/uuid.js +28 -0
  50. package/lib/esm/web/signer.js +4 -2
  51. package/lib/types/cli/commands/arns.d.ts +147 -0
  52. package/lib/types/cli/commands/arns.d.ts.map +1 -0
  53. package/lib/types/cli/commands/freeStatus.d.ts +3 -0
  54. package/lib/types/cli/commands/freeStatus.d.ts.map +1 -0
  55. package/lib/types/cli/commands/index.d.ts +3 -0
  56. package/lib/types/cli/commands/index.d.ts.map +1 -1
  57. package/lib/types/cli/commands/paymentHistory.d.ts +18 -0
  58. package/lib/types/cli/commands/paymentHistory.d.ts.map +1 -0
  59. package/lib/types/cli/options.d.ts +423 -0
  60. package/lib/types/cli/options.d.ts.map +1 -1
  61. package/lib/types/cli/types.d.ts +78 -0
  62. package/lib/types/cli/types.d.ts.map +1 -1
  63. package/lib/types/common/arnsActions.d.ts +58 -0
  64. package/lib/types/common/arnsActions.d.ts.map +1 -0
  65. package/lib/types/common/chunked.d.ts +47 -2
  66. package/lib/types/common/chunked.d.ts.map +1 -1
  67. package/lib/types/common/folderIndex.d.ts +54 -0
  68. package/lib/types/common/folderIndex.d.ts.map +1 -0
  69. package/lib/types/common/http.d.ts +25 -2
  70. package/lib/types/common/http.d.ts.map +1 -1
  71. package/lib/types/common/index.d.ts +3 -0
  72. package/lib/types/common/index.d.ts.map +1 -1
  73. package/lib/types/common/payment.d.ts +291 -1
  74. package/lib/types/common/payment.d.ts.map +1 -1
  75. package/lib/types/common/signer.d.ts +12 -6
  76. package/lib/types/common/signer.d.ts.map +1 -1
  77. package/lib/types/common/token/index.d.ts.map +1 -1
  78. package/lib/types/common/turbo.d.ts +183 -1
  79. package/lib/types/common/turbo.d.ts.map +1 -1
  80. package/lib/types/common/upload.d.ts +41 -0
  81. package/lib/types/common/upload.d.ts.map +1 -1
  82. package/lib/types/node/folderIndex.d.ts +28 -0
  83. package/lib/types/node/folderIndex.d.ts.map +1 -0
  84. package/lib/types/node/index.d.ts +1 -0
  85. package/lib/types/node/index.d.ts.map +1 -1
  86. package/lib/types/node/upload.d.ts +1 -0
  87. package/lib/types/node/upload.d.ts.map +1 -1
  88. package/lib/types/types.d.ts +694 -3
  89. package/lib/types/types.d.ts.map +1 -1
  90. package/lib/types/utils/common.d.ts.map +1 -1
  91. package/lib/types/utils/errors.d.ts +29 -0
  92. package/lib/types/utils/errors.d.ts.map +1 -1
  93. package/lib/types/utils/folderIndex.d.ts +47 -0
  94. package/lib/types/utils/folderIndex.d.ts.map +1 -0
  95. package/lib/types/utils/uuid.d.ts +7 -0
  96. package/lib/types/utils/uuid.d.ts.map +1 -0
  97. package/lib/types/web/signer.d.ts +1 -1
  98. package/lib/types/web/signer.d.ts.map +1 -1
  99. package/package.json +1 -1
@@ -17,17 +17,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.tokenToBaseMap = exports.exponentMap = exports.defaultTokenMap = void 0;
18
18
  exports.isTokenType = isTokenType;
19
19
  const types_js_1 = require("../../types.js");
20
- const common_js_1 = require("../../utils/common.js");
21
20
  const ario_js_1 = require("./ario.js");
22
21
  const arweave_js_1 = require("./arweave.js");
23
22
  const baseEth_js_1 = require("./baseEth.js");
24
- const erc20_js_1 = require("./erc20.js");
25
23
  const ethereum_js_1 = require("./ethereum.js");
26
24
  const kyve_js_1 = require("./kyve.js");
27
25
  const polygon_js_1 = require("./polygon.js");
28
26
  const solana_js_1 = require("./solana.js");
29
27
  const usdc_js_1 = require("./usdc.js");
30
- const baseARIOContractAddress = '0x138746adfA52909E5920def027f5a8dc1C7EfFb6';
31
28
  exports.defaultTokenMap = {
32
29
  arweave: (config) => new arweave_js_1.ArweaveToken(config),
33
30
  ario: (config) => new ario_js_1.ARIOToken(config),
@@ -40,12 +37,6 @@ exports.defaultTokenMap = {
40
37
  usdc: (config) => new usdc_js_1.USDCToken({ network: 'ethereum', ...config }),
41
38
  'base-usdc': (config) => new usdc_js_1.USDCToken({ network: 'base', ...config }),
42
39
  'polygon-usdc': (config) => new usdc_js_1.USDCToken({ network: 'polygon', ...config }),
43
- 'base-ario': (config) => new erc20_js_1.ERC20Token({
44
- ...config,
45
- pollingOptions: config.pollingOptions ?? baseEth_js_1.defaultBaseNetworkPollingOptions,
46
- tokenContractAddress: baseARIOContractAddress,
47
- gatewayUrl: config.gatewayUrl ?? common_js_1.defaultProdGatewayUrls['base-ario'],
48
- }),
49
40
  };
50
41
  const ethExponent = 18;
51
42
  const usdcExponent = 6;
@@ -53,7 +44,6 @@ const arioExponent = 6;
53
44
  exports.exponentMap = {
54
45
  arweave: 12,
55
46
  ario: arioExponent,
56
- 'base-ario': arioExponent,
57
47
  solana: 9,
58
48
  ethereum: ethExponent,
59
49
  'base-eth': ethExponent,
@@ -67,7 +57,6 @@ exports.exponentMap = {
67
57
  exports.tokenToBaseMap = {
68
58
  arweave: (a) => (0, arweave_js_1.ARToTokenAmount)(a),
69
59
  ario: (a) => (0, ario_js_1.ARIOToTokenAmount)(a),
70
- 'base-ario': (a) => (0, usdc_js_1.USDCToTokenAmount)(a),
71
60
  solana: (a) => (0, solana_js_1.SOLToTokenAmount)(a),
72
61
  ethereum: (a) => (0, ethereum_js_1.ETHToTokenAmount)(a),
73
62
  'base-eth': (a) => (0, ethereum_js_1.ETHToTokenAmount)(a),
@@ -54,6 +54,53 @@ class TurboUnauthenticatedClient {
54
54
  getBalance(address) {
55
55
  return this.paymentService.getBalance(address);
56
56
  }
57
+ getFreeStatus(address) {
58
+ return this.paymentService.getFreeStatus(address);
59
+ }
60
+ /**
61
+ * Returns the price in 'winc' (and mARIO) to buy/extend/upgrade an ArNS name.
62
+ */
63
+ getArNSPriceForName(params) {
64
+ return this.paymentService.getArNSPriceForName(params);
65
+ }
66
+ /**
67
+ * Previews what one of the eight non-purchase ArNS actions will debit,
68
+ * without creating it. Use {@link getArNSPriceForName} for the four
69
+ * ARIO-purchase actions instead.
70
+ */
71
+ getArNSActionPrice(action) {
72
+ return this.paymentService.getArNSActionPrice(action);
73
+ }
74
+ /**
75
+ * Returns the status of an ArNS purchase by its nonce.
76
+ */
77
+ getArNSPurchaseStatus(p) {
78
+ return this.paymentService.getArNSPurchaseStatus(p);
79
+ }
80
+ /**
81
+ * Returns the ArNS names a wallet owns or controls via Turbo's custodial
82
+ * ArNS-with-credits feature. `custodial: true` on a returned name means
83
+ * Turbo still holds/manages its ANT (transfer/manage routes apply);
84
+ * `custodial: false` means self-custody (or an already-completed exit) and
85
+ * is informational only.
86
+ *
87
+ * To read a name's current records or lease/expiration state, use
88
+ * `@ar.io/sdk` directly against the returned `antId`.
89
+ */
90
+ getArNSNames(address) {
91
+ return this.paymentService.getArNSNames(address);
92
+ }
93
+ /**
94
+ * Quote a fiat (Stripe) ArNS purchase — buy a name with a credit card in one
95
+ * step, no Turbo Credits top-up in between. Complete the returned
96
+ * `paymentSession` with Stripe, then poll {@link getArNSPurchaseStatus} using
97
+ * `purchaseQuote.nonce`.
98
+ *
99
+ * Throws `FiatPaymentsDisabledError` when the service has Stripe switched off.
100
+ */
101
+ getArNSFiatPurchaseQuote(params) {
102
+ return this.paymentService.getArNSFiatPurchaseQuote(params);
103
+ }
57
104
  /**
58
105
  * Returns a list of all supported fiat currencies.
59
106
  */
@@ -159,6 +206,121 @@ class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
159
206
  getBalance(userAddress) {
160
207
  return this.paymentService.getBalance(userAddress);
161
208
  }
209
+ /**
210
+ * Returns how many free-tier bytes the wallet can still upload for free
211
+ * (`bytesRemaining`), or `null` for an unlimited (exempt/partner) wallet.
212
+ */
213
+ getFreeStatus(userAddress) {
214
+ return this.paymentService.getFreeStatus(userAddress);
215
+ }
216
+ /**
217
+ * Returns the signer's OWN completed top-up history (crypto + fiat), newest
218
+ * first and keyset-paginated. Signature-required and self-scoped: it only ever
219
+ * returns the signing wallet's rows. Pass `cursor` from a prior response's
220
+ * `cursor` field (with `hasMore === true`) to fetch the next page.
221
+ */
222
+ getPaymentHistory(params) {
223
+ return this.paymentService.getPaymentHistory(params);
224
+ }
225
+ // ===== ArNS actions (sponsored) =====
226
+ //
227
+ // Thin delegations. The two-shape branch and the owner-proof construction
228
+ // live in the payment service; see its comments for why callers must branch
229
+ // on `status` rather than on which action they asked for.
230
+ /** Create an action. Debits credits HERE — capture the nonce before signing. */
231
+ createArNSAction(action, params, ownerProof) {
232
+ return this.paymentService.createArNSAction(action, params, ownerProof);
233
+ }
234
+ /** Submit the owner-signed transaction (FULL serialized tx, base64). */
235
+ signArNSAction(nonce, signedTransaction) {
236
+ return this.paymentService.signArNSAction(nonce, signedTransaction);
237
+ }
238
+ /** Status by nonce — open, needs no signature. Use it to resume. */
239
+ getArNSActionStatus(nonce) {
240
+ return this.paymentService.getArNSActionStatus(nonce);
241
+ }
242
+ /**
243
+ * Quote a fiat (Stripe) ArNS purchase for this signer's wallet — a credit-card
244
+ * buy in one step, with no Turbo Credits top-up in between. `address` defaults
245
+ * to the signer's native address; pass one to buy on another wallet's behalf.
246
+ *
247
+ * Complete the returned `paymentSession` with Stripe, then poll
248
+ * {@link getArNSPurchaseStatus} using `purchaseQuote.nonce`. Throws
249
+ * `FiatPaymentsDisabledError` when the service has Stripe switched off.
250
+ */
251
+ getArNSFiatPurchaseQuote(params) {
252
+ return this.paymentService.getArNSFiatPurchaseQuote(params);
253
+ }
254
+ /**
255
+ * Buy a name. The ANT is minted straight to `owner`; Turbo never holds it.
256
+ * The only action that always needs the owner's signature — once, ever.
257
+ */
258
+ buyArNSName(params) {
259
+ return this.paymentService.buyArNSName(params);
260
+ }
261
+ /** Extend a lease. No owner signature needed. */
262
+ extendArNSLease(params) {
263
+ return this.paymentService.extendArNSLease(params);
264
+ }
265
+ /** Raise the undername limit. No owner signature needed. */
266
+ increaseArNSUndernameLimit(params) {
267
+ return this.paymentService.increaseArNSUndernameLimit(params);
268
+ }
269
+ /** Upgrade a lease to a permanent name. No owner signature needed. */
270
+ upgradeArNSName(params) {
271
+ return this.paymentService.upgradeArNSName(params);
272
+ }
273
+ /**
274
+ * Point a name (or undername) at data. Debits a flat credits margin (Turbo
275
+ * pays the SOL); preview it with `getArNSActionPrice`. Handles both shapes.
276
+ */
277
+ setArNSRecord(params) {
278
+ return this.paymentService.setArNSRecord(params);
279
+ }
280
+ /**
281
+ * Remove a record. Debits a flat credits margin (Turbo pays the SOL);
282
+ * preview it with `getArNSActionPrice`. Handles both shapes.
283
+ */
284
+ removeArNSRecord(params) {
285
+ return this.paymentService.removeArNSRecord(params);
286
+ }
287
+ /** Grant controller rights — omit `target` for Turbo itself. Costs credits. */
288
+ addArNSController(params) {
289
+ return this.paymentService.addArNSController(params);
290
+ }
291
+ /** Revoke controller rights. Always available; costs credits, never SOL. */
292
+ removeArNSController(params) {
293
+ return this.paymentService.removeArNSController(params);
294
+ }
295
+ /**
296
+ * Edit a RECORD's metadata (display name, logo, description, keywords).
297
+ * Debits a flat credits margin (Turbo pays the SOL); preview it with
298
+ * `getArNSActionPrice`. Handles both shapes. Fields are tri-state — omit to
299
+ * leave unchanged, pass `null` to clear.
300
+ */
301
+ setArNSRecordMetadata(params) {
302
+ return this.paymentService.setArNSRecordMetadata(params);
303
+ }
304
+ /** Clear a record's metadata. Costs credits, never SOL; handles both shapes. */
305
+ removeArNSRecordMetadata(params) {
306
+ return this.paymentService.removeArNSRecordMetadata(params);
307
+ }
308
+ /** Hand ONE record over — not the whole ANT. Costs credits, never SOL. */
309
+ transferArNSRecord(params) {
310
+ return this.paymentService.transferArNSRecord(params);
311
+ }
312
+ /** Hand the ANT to a new owner. Irreversible. Costs credits, never SOL. */
313
+ transferArNSAnt(params) {
314
+ return this.paymentService.transferArNSAnt(params);
315
+ }
316
+ /**
317
+ * Returns the ArNS names owned or controlled by the connected signer's
318
+ * wallet (or the given `userAddress`) via Turbo's custodial
319
+ * ArNS-with-credits feature.
320
+ */
321
+ getArNSNames(userAddress) {
322
+ return this.paymentService.getArNSNames(userAddress);
323
+ }
162
324
  /**
163
325
  * Returns a list of all credit share approvals for the user.
164
326
  */