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