@ardrive/turbo-sdk 1.20.2 → 1.21.0

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 (44) hide show
  1. package/README.md +29 -0
  2. package/bundles/web.bundle.min.js +312 -277
  3. package/lib/cjs/cli/cli.js +6 -0
  4. package/lib/cjs/cli/commands/shareCredits.js +1 -1
  5. package/lib/cjs/cli/commands/tokenPrice.js +45 -0
  6. package/lib/cjs/cli/options.js +4 -0
  7. package/lib/cjs/common/payment.js +15 -0
  8. package/lib/cjs/common/signer.js +3 -3
  9. package/lib/cjs/common/token/index.js +9 -1
  10. package/lib/cjs/common/turbo.js +6 -0
  11. package/lib/cjs/utils/base64.js +2 -2
  12. package/lib/cjs/utils/common.js +1 -0
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/esm/cli/cli.js +6 -0
  15. package/lib/esm/cli/commands/shareCredits.js +1 -1
  16. package/lib/esm/cli/commands/tokenPrice.js +42 -0
  17. package/lib/esm/cli/options.js +4 -0
  18. package/lib/esm/common/payment.js +15 -0
  19. package/lib/esm/common/signer.js +3 -3
  20. package/lib/esm/common/token/index.js +8 -0
  21. package/lib/esm/common/turbo.js +6 -0
  22. package/lib/esm/utils/base64.js +2 -2
  23. package/lib/esm/utils/common.js +1 -0
  24. package/lib/esm/version.js +1 -1
  25. package/lib/types/cli/commands/shareCredits.d.ts.map +1 -1
  26. package/lib/types/cli/commands/tokenPrice.d.ts +3 -0
  27. package/lib/types/cli/commands/tokenPrice.d.ts.map +1 -0
  28. package/lib/types/cli/options.d.ts +4 -0
  29. package/lib/types/cli/options.d.ts.map +1 -1
  30. package/lib/types/cli/types.d.ts +6 -3
  31. package/lib/types/cli/types.d.ts.map +1 -1
  32. package/lib/types/common/payment.d.ts +4 -1
  33. package/lib/types/common/payment.d.ts.map +1 -1
  34. package/lib/types/common/signer.d.ts.map +1 -1
  35. package/lib/types/common/token/index.d.ts +1 -0
  36. package/lib/types/common/token/index.d.ts.map +1 -1
  37. package/lib/types/common/turbo.d.ts +7 -1
  38. package/lib/types/common/turbo.d.ts.map +1 -1
  39. package/lib/types/types.d.ts +8 -0
  40. package/lib/types/types.d.ts.map +1 -1
  41. package/lib/types/utils/common.d.ts.map +1 -1
  42. package/lib/types/version.d.ts +1 -1
  43. package/lib/types/version.d.ts.map +1 -1
  44. package/package.json +1 -1
package/README.md CHANGED
@@ -42,6 +42,7 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
42
42
  - [`getFiatRates()`](#getfiatrates)
43
43
  - [`getWincForFiat({ amount })`](#getwincforfiat-amount-)
44
44
  - [`getWincForToken({ tokenAmount })`](#getwincfortoken-tokenamount-)
45
+ - [`getTokenPriceForBytes({ byteCount })`](#gettokenpriceforbytes-bytecount-)
45
46
  - [`getUploadCosts({ bytes })`](#getuploadcosts-bytes-)
46
47
  - [`uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal })`](#uploadsigneddataitem-dataitemstreamfactory-dataitemsizefactory-signal-)
47
48
  - [`createCheckoutSession({ amount, owner })`](#createcheckoutsession-amount-owner-)
@@ -80,6 +81,7 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
80
81
  - [`upload-folder`](#upload-folder)
81
82
  - [`upload-file`](#upload-file)
82
83
  - [`price`](#price)
84
+ - [`token-price`](#token-price)
83
85
  - [`share-credits`](#share-credits)
84
86
  - [`revoke-credits`](#revoke-credits)
85
87
  - [`list-shares`](#list-shares)
@@ -390,6 +392,19 @@ const { winc, actualTokenAmount, equivalentWincTokenAmount } =
390
392
  });
391
393
  ```
392
394
 
395
+ #### `getTokenPriceForBytes({ byteCount })`
396
+
397
+ Get the current price from the Turbo Payment Service, denominated in the specified token, for uploading a specified number of bytes to Turbo.
398
+
399
+ ```typescript
400
+ const turbo = TurboFactory.unauthenticated({ token: 'solana' });
401
+ const { tokenPrice } = await turbo.getTokenPriceForBytes({
402
+ byteCount: 1024 * 1024 * 100,
403
+ });
404
+
405
+ console.log(tokenPrice); // Estimated SOL Price for 100 MiB
406
+ ```
407
+
393
408
  #### `getUploadCosts({ bytes })`
394
409
 
395
410
  Returns the estimated cost in Winston Credits for the provided file sizes, including all upload adjustments and fees.
@@ -905,6 +920,20 @@ turbo price --value 1024 --type bytes
905
920
  turbo price --value 1.1 --type arweave
906
921
  ```
907
922
 
923
+ ##### `token-price`
924
+
925
+ Get the current price from the Turbo Payment Service, denominated in the specified token, for uploading a specified number of bytes to Turbo.
926
+
927
+ Command Options:
928
+
929
+ - `--byte-count <byteCount>` - Byte value to get the token price for
930
+
931
+ e.g:
932
+
933
+ ```shell
934
+ turbo token-price --byte-count 102400 --token solana
935
+ ```
936
+
908
937
  ##### `share-credits`
909
938
 
910
939
  Shares credits from the connected wallet to the provided native address and approved winc amount.