@ardrive/turbo-sdk 1.11.0-alpha.2 → 1.11.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/README.md CHANGED
@@ -31,6 +31,8 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
31
31
  - [Ethereum Private Key](#ethereum-private-key)
32
32
  - [HexSolanaSigner](#hexsolanasigner)
33
33
  - [Solana Secret Key](#solana-secret-key)
34
+ - [KYVE Private Key](#kyve-private-key)
35
+ - [KYVE Mnemonic](#kyve-mnemonic)
34
36
  - [TurboUnauthenticatedClient](#turbounauthenticatedclient)
35
37
  - [`getSupportedCurrencies()`](#getsupportedcurrencies)
36
38
  - [`getSupportedCountries()`](#getsupportedcountries)
@@ -40,9 +42,10 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
40
42
  - [`getUploadCosts({ bytes })`](#getuploadcosts-bytes-)
41
43
  - [`uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal })`](#uploadsigneddataitem-dataitemstreamfactory-dataitemsizefactory-signal-)
42
44
  - [`createCheckoutSession({ amount, owner })`](#createcheckoutsession-amount-owner-)
43
- - [Arweave (AR)](#arweave-ar)
44
- - [Ethereum (ETH)](#ethereum-eth)
45
- - [Solana (SOL)](#solana-sol)
45
+ - [Arweave (AR) Fiat Top Up](#arweave-ar-fiat-top-up)
46
+ - [Ethereum (ETH) Fiat Top Up](#ethereum-eth-fiat-top-up)
47
+ - [Solana (SOL) Fiat Top Up](#solana-sol-fiat-top-up)
48
+ - [KYVE Fiat Top Up](#kyve-fiat-top-up)
46
49
  - [`submitFundTransaction({ txId })`](#submitfundtransaction-txid-)
47
50
  - [TurboAuthenticatedClient](#turboauthenticatedclient)
48
51
  - [`getBalance()`](#getbalance)
@@ -53,8 +56,16 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
53
56
  - [NodeJS Upload Folder](#nodejs-upload-folder)
54
57
  - [Browser Upload Folder](#browser-upload-folder)
55
58
  - [`topUpWithTokens({ tokenAmount, feeMultiplier })`](#topupwithtokens-tokenamount-feemultiplier-)
56
- - [Ethereum (ETH)](#ethereum-eth-1)
57
- - [Solana (SOL)](#solana-sol-1)
59
+ - [Arweave (AR) Crypto Top Up](#arweave-ar-crypto-top-up)
60
+ - [Ethereum (ETH) Crypto Top Up](#ethereum-eth-crypto-top-up)
61
+ - [Solana (SOL) Crypto Top Up](#solana-sol-crypto-top-up)
62
+ - [KYVE Crypto Top Up](#kyve-crypto-top-up)
63
+ - [CLI](#cli)
64
+ - [Install CLI](#install-cli)
65
+ - [CLI Usage](#cli-usage)
66
+ - [Options](#options)
67
+ - [Commands](#commands)
68
+ - [`crypto-fund`](#crypto-fund)
58
69
  - [Developers](#developers)
59
70
  - [Requirements](#requirements)
60
71
  - [Setup & Build](#setup--build)
@@ -268,6 +279,26 @@ const turbo = TurboFactory.authenticated({
268
279
  });
269
280
  ```
270
281
 
282
+ ##### KYVE Private Key
283
+
284
+ ```typescript
285
+ const turbo = TurboFactory.authenticated({
286
+ privateKey: kyveHexadecimalPrivateKey,
287
+ token: 'kyve',
288
+ });
289
+ ```
290
+
291
+ ##### KYVE Mnemonic
292
+
293
+ ```typescript
294
+ import { privateKeyFromKyveMnemonic } from '@ardrive/turbo-sdk';
295
+
296
+ const turbo = TurboFactory.authenticated({
297
+ privateKey: privateKeyFromKyveMnemonic(mnemonic),
298
+ token: 'kyve',
299
+ });
300
+ ```
301
+
271
302
  ### TurboUnauthenticatedClient
272
303
 
273
304
  #### `getSupportedCurrencies()`
@@ -341,7 +372,7 @@ const uploadResponse = await turbo.uploadSignedDataItem({
341
372
 
342
373
  Creates a Stripe checkout session for a Turbo Top Up with the provided amount, currency, owner. The returned URL can be opened in the browser, all payments are processed by Stripe. To leverage promo codes, see [TurboAuthenticatedClient].
343
374
 
344
- ##### Arweave (AR)
375
+ ##### Arweave (AR) Fiat Top Up
345
376
 
346
377
  ```typescript
347
378
  const { url, winc, paymentAmount, quotedPaymentAmount, adjustments } =
@@ -364,7 +395,7 @@ if (process.platform === 'darwin') {
364
395
  }
365
396
  ```
366
397
 
367
- ##### Ethereum (ETH)
398
+ ##### Ethereum (ETH) Fiat Top Up
368
399
 
369
400
  ```ts
370
401
  const turbo = TurboFactory.unauthenticated({ token: 'ethereum' });
@@ -375,7 +406,7 @@ const { url, winc, paymentAmount } = await turbo.createCheckoutSession({
375
406
  });
376
407
  ```
377
408
 
378
- ##### Solana (SOL)
409
+ ##### Solana (SOL) Fiat Top Up
379
410
 
380
411
  ```ts
381
412
  const turbo = TurboFactory.unauthenticated({ token: 'solana' });
@@ -386,6 +417,17 @@ const { url, winc, paymentAmount } = await turbo.createCheckoutSession({
386
417
  });
387
418
  ```
388
419
 
420
+ ##### KYVE Fiat Top Up
421
+
422
+ ```ts
423
+ const turbo = TurboFactory.unauthenticated({ token: 'kyve' });
424
+
425
+ const { url, winc, paymentAmount } = await turbo.createCheckoutSession({
426
+ amount: USD(10.0), // $10.00 USD
427
+ owner: publicKyveAddress,
428
+ });
429
+ ```
430
+
389
431
  #### `submitFundTransaction({ txId })`
390
432
 
391
433
  Submits the transaction ID of a funding transaction to Turbo Payment Service for top up processing. The `txId` is the transaction ID of the transaction to be submitted.
@@ -536,6 +578,8 @@ Tops up the connected wallet with Credits by submitting a payment transaction fo
536
578
  - The `tokenAmount` is the amount of tokens in the token type's smallest unit value (e.g: Winston for arweave token type) to fund the wallet with.
537
579
  - The `feeMultiplier` (optional) is the multiplier to apply to the reward for the transaction to modify its chances of being mined. Credits will be added to the wallet balance after the transaction is confirmed on the given blockchain. Defaults to 1.0, meaning no multiplier.
538
580
 
581
+ ##### Arweave (AR) Crypto Top Up
582
+
539
583
  ```typescript
540
584
  const turbo = TurboFactory.authenticated({ signer, token: 'arweave' });
541
585
 
@@ -545,7 +589,7 @@ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
545
589
  });
546
590
  ```
547
591
 
548
- ##### Ethereum (ETH)
592
+ ##### Ethereum (ETH) Crypto Top Up
549
593
 
550
594
  ```ts
551
595
  const turbo = TurboFactory.authenticated({ signer, token: 'ethereum' });
@@ -555,7 +599,7 @@ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
555
599
  });
556
600
  ```
557
601
 
558
- ##### Solana (SOL)
602
+ ##### Solana (SOL) Crypto Top Up
559
603
 
560
604
  ```ts
561
605
  const turbo = TurboFactory.authenticated({ signer, token: 'solana' });
@@ -565,6 +609,88 @@ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
565
609
  });
566
610
  ```
567
611
 
612
+ ##### KYVE Crypto Top Up
613
+
614
+ ```ts
615
+ const turbo = TurboFactory.authenticated({ signer, token: 'kyve' });
616
+
617
+ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
618
+ tokenAmount: KYVEToTokenAmount(0.00001), // 0.00001 KYVE
619
+ });
620
+ ```
621
+
622
+ ## CLI
623
+
624
+ ### Install CLI
625
+
626
+ Global installation:
627
+
628
+ ```shell
629
+ npm install -g @ardrive/turbo-sdk
630
+ ```
631
+
632
+ or
633
+
634
+ ```shell
635
+ yarn global add @ardrive/turbo-sdk
636
+ ```
637
+
638
+ or install locally as a dev dependency:
639
+
640
+ ```shell
641
+ npm install --save-dev @ardrive/turbo-sdk
642
+ ```
643
+
644
+ or
645
+
646
+ ```shell
647
+ yarn add -D @ardrive/turbo-sdk
648
+ ```
649
+
650
+ ### CLI Usage
651
+
652
+ ```shell
653
+ turbo --help
654
+ ```
655
+
656
+ or from local installation:
657
+
658
+ ```shell
659
+ yarn turbo --help
660
+ ```
661
+
662
+ ```shell
663
+ npx turbo --help
664
+ ```
665
+
666
+ #### Options
667
+
668
+ - `-V, --version` - output the version number
669
+ - `-h, --help` - display help for command
670
+ - `--dev` - Enable development endpoints (default: false)
671
+ - `-g, --gateway <url>` - Set a custom crypto gateway URL
672
+ - `-t, --token <token>` - Token type for the command or connected wallet (default: "arweave")
673
+
674
+ - `-w, --wallet-file <filePath>` - Wallet file to use with the action. Formats accepted: JWK.json, KYVE or ETH private key as a string, or SOL Secret Key as a Uint8Array
675
+ - `-m, --mnemonic <phrase>` - Mnemonic to use with the action (KYVE only)
676
+ - `-p, --private-key <key>` - Private key to use with the action
677
+
678
+ #### Commands
679
+
680
+ ##### `crypto-fund`
681
+
682
+ Fund a wallet with Turbo Credits by submitting a payment transaction for the crypto amount to the Turbo wallet and then submitting that transaction id to Turbo Payment Service for top up processing.
683
+
684
+ Command Options:
685
+
686
+ - `-v, --value <value>` - Amount of tokens in the token type's smallest unit value to fund the wallet with
687
+
688
+ e.g:
689
+
690
+ ```shell
691
+ turbo crypto-fund --value 0.0001 --token kyve --private-key 'b27...45c'
692
+ ```
693
+
568
694
  ## Developers
569
695
 
570
696
  ### Requirements
@@ -312251,7 +312251,7 @@ var import_winston = __toESM(require_winston(), 1);
312251
312251
  init_dirname();
312252
312252
  init_buffer2();
312253
312253
  init_process2();
312254
- var version16 = "1.11.0-alpha.1";
312254
+ var version16 = "1.11.0-alpha.2";
312255
312255
 
312256
312256
  // src/common/logger.ts
312257
312257
  var TurboWinstonLogger = class _TurboWinstonLogger {
@@ -33,7 +33,7 @@ const utils_js_1 = require("./utils.js");
33
33
  (0, utils_js_1.applyOptions)(commander_1.program.command('top-up').description('Top up a Turbo address with Fiat'), [utils_js_1.optionMap.address, utils_js_1.optionMap.value, utils_js_1.optionMap.token]).action((options) => {
34
34
  console.log('TODO: fiat top-up', options.address, options.token, options.value);
35
35
  });
36
- (0, utils_js_1.applyOptions)(commander_1.program.command('crypto-fund').description('Top up a wallet with crypto'), [...utils_js_1.walletOptions, utils_js_1.optionMap.token, utils_js_1.optionMap.value]).action(async (_commandOptions, command) => {
36
+ (0, utils_js_1.applyOptions)(commander_1.program.command('crypto-fund').description('Top up a wallet with crypto'), [...utils_js_1.walletOptions, utils_js_1.optionMap.value]).action(async (_commandOptions, command) => {
37
37
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
38
  const options = command.optsWithGlobals();
39
39
  const token = (0, utils_js_1.tokenFromOptions)(options);
@@ -48,7 +48,7 @@ const utils_js_1 = require("./utils.js");
48
48
  .argument('<folderPath>', 'Directory to upload'), [...utils_js_1.walletOptions, utils_js_1.optionMap.token]).action((directory, options) => {
49
49
  console.log('upload-folder TODO', directory, options);
50
50
  });
51
- if (process.argv[1].includes('.bin/turbo') || // Running from global .bin
51
+ if (process.argv[1].includes('bin/turbo') || // Running from global .bin
52
52
  process.argv[1].includes('cli/cli') // Running from source
53
53
  ) {
54
54
  commander_1.program.parse(process.argv);
@@ -92,6 +92,7 @@ exports.globalOptions = [
92
92
  exports.optionMap.gateway,
93
93
  exports.optionMap.debug,
94
94
  exports.optionMap.quiet,
95
+ exports.optionMap.token,
95
96
  ];
96
97
  function applyOptions(command, options) {
97
98
  [...options].forEach((option) => {
@@ -122,6 +123,7 @@ async function privateKeyFromOptions({ mnemonic, privateKey, walletFile, }, toke
122
123
  return (0, index_js_1.privateKeyFromKyveMnemonic)(mnemonic);
123
124
  }
124
125
  else {
126
+ // TODO: Implement other token types mnemonic to wallet
125
127
  throw new Error('mnemonic provided but this token type mnemonic to wallet is not supported');
126
128
  }
127
129
  }
@@ -132,7 +134,9 @@ async function privateKeyFromOptions({ mnemonic, privateKey, walletFile, }, toke
132
134
  else if (privateKey !== undefined) {
133
135
  return privateKey;
134
136
  }
135
- throw new Error('mnemonic or wallet file required');
137
+ // TODO: Get TURBO_WALLET_FILE, TURBO_MNEMONIC, TURBO_PRIVATE_KEY or similar from ENV variables
138
+ // TODO: Add prompts for selecting wallet type and secure input
139
+ throw new Error('mnemonic or wallet file or private key is required');
136
140
  }
137
141
  const tokenToDevGatewayMap = {
138
142
  arweave: 'https://arweave.net', // No arweave test net
@@ -18,4 +18,4 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.version = void 0;
20
20
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
21
- exports.version = '1.11.0-alpha.2';
21
+ exports.version = '1.11.0-alpha.3';
@@ -31,7 +31,7 @@ applyOptions(program.command('get-balance').description('Get balance of a Turbo
31
31
  applyOptions(program.command('top-up').description('Top up a Turbo address with Fiat'), [optionMap.address, optionMap.value, optionMap.token]).action((options) => {
32
32
  console.log('TODO: fiat top-up', options.address, options.token, options.value);
33
33
  });
34
- applyOptions(program.command('crypto-fund').description('Top up a wallet with crypto'), [...walletOptions, optionMap.token, optionMap.value]).action(async (_commandOptions, command) => {
34
+ applyOptions(program.command('crypto-fund').description('Top up a wallet with crypto'), [...walletOptions, optionMap.value]).action(async (_commandOptions, command) => {
35
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
36
  const options = command.optsWithGlobals();
37
37
  const token = tokenFromOptions(options);
@@ -46,7 +46,7 @@ applyOptions(program
46
46
  .argument('<folderPath>', 'Directory to upload'), [...walletOptions, optionMap.token]).action((directory, options) => {
47
47
  console.log('upload-folder TODO', directory, options);
48
48
  });
49
- if (process.argv[1].includes('.bin/turbo') || // Running from global .bin
49
+ if (process.argv[1].includes('bin/turbo') || // Running from global .bin
50
50
  process.argv[1].includes('cli/cli') // Running from source
51
51
  ) {
52
52
  program.parse(process.argv);
@@ -81,6 +81,7 @@ export const globalOptions = [
81
81
  optionMap.gateway,
82
82
  optionMap.debug,
83
83
  optionMap.quiet,
84
+ optionMap.token,
84
85
  ];
85
86
  export function applyOptions(command, options) {
86
87
  [...options].forEach((option) => {
@@ -111,6 +112,7 @@ export async function privateKeyFromOptions({ mnemonic, privateKey, walletFile,
111
112
  return privateKeyFromKyveMnemonic(mnemonic);
112
113
  }
113
114
  else {
115
+ // TODO: Implement other token types mnemonic to wallet
114
116
  throw new Error('mnemonic provided but this token type mnemonic to wallet is not supported');
115
117
  }
116
118
  }
@@ -121,7 +123,9 @@ export async function privateKeyFromOptions({ mnemonic, privateKey, walletFile,
121
123
  else if (privateKey !== undefined) {
122
124
  return privateKey;
123
125
  }
124
- throw new Error('mnemonic or wallet file required');
126
+ // TODO: Get TURBO_WALLET_FILE, TURBO_MNEMONIC, TURBO_PRIVATE_KEY or similar from ENV variables
127
+ // TODO: Add prompts for selecting wallet type and secure input
128
+ throw new Error('mnemonic or wallet file or private key is required');
125
129
  }
126
130
  const tokenToDevGatewayMap = {
127
131
  arweave: 'https://arweave.net', // No arweave test net
@@ -15,4 +15,4 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
18
- export const version = '1.11.0-alpha.2';
18
+ export const version = '1.11.0-alpha.3';
@@ -68,6 +68,10 @@ export declare const walletOptions: ({
68
68
  readonly description: "Private key to use with the action";
69
69
  })[];
70
70
  export declare const globalOptions: ({
71
+ readonly alias: "-t, --token <type>";
72
+ readonly description: "Token type for wallet or action";
73
+ readonly default: "arweave";
74
+ } | {
71
75
  readonly alias: "-g, --gateway <url>";
72
76
  readonly description: "Set a custom crypto gateway URL";
73
77
  readonly default: undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/cli/utils.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,SAAS,EACT,iCAAiC,EAKlC,MAAM,kBAAkB,CAAC;AAE1B,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AAED,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDZ,CAAC;AAEX,eAAO,MAAM,aAAa;;;;;;;;;IAIzB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;IAKzB,CAAC;AAEF,wBAAgB,YAAY,CAC1B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,eAAe,EAAE,GACzB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zB,OAAO,CAKT;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAU5D;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAMzD;AAED,wBAAsB,qBAAqB,CACzC,EACE,QAAQ,EACR,UAAU,EACV,UAAU,GACX,EAAE;IACD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,EACD,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,MAAM,CAAC,CAqBjB;AASD,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,GAAG,EACH,KAAK,GACN,EAAE;IACD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;CAClB,GAAG,iCAAiC,CAgBpC"}
@@ -14,5 +14,5 @@
14
14
  * You should have received a copy of the GNU Affero General Public License
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
- export declare const version = "1.11.0-alpha.1";
17
+ export declare const version = "1.11.0-alpha.2";
18
18
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.11.0-alpha.2",
3
+ "version": "1.11.0-alpha.3",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",