@ardrive/turbo-sdk 1.31.1 → 1.32.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 (80) hide show
  1. package/README.md +37 -0
  2. package/bundles/web.bundle.min.js +466 -258
  3. package/lib/cjs/cli/commands/uploadFile.js +1 -0
  4. package/lib/cjs/cli/commands/uploadFolder.js +1 -0
  5. package/lib/cjs/cli/options.js +19 -0
  6. package/lib/cjs/cli/utils.js +25 -0
  7. package/lib/cjs/common/factory.js +1 -0
  8. package/lib/cjs/common/payment.js +1 -1
  9. package/lib/cjs/common/signer.js +21 -0
  10. package/lib/cjs/common/token/ario.js +1 -1
  11. package/lib/cjs/common/token/arweave.js +1 -1
  12. package/lib/cjs/common/token/baseEth.js +17 -1
  13. package/lib/cjs/common/token/ethereum.js +13 -4
  14. package/lib/cjs/common/token/kyve.js +1 -1
  15. package/lib/cjs/common/token/solana.js +10 -1
  16. package/lib/cjs/common/turbo.js +3 -1
  17. package/lib/cjs/common/upload.js +124 -6
  18. package/lib/cjs/node/upload.js +2 -1
  19. package/lib/cjs/types.js +20 -1
  20. package/lib/cjs/version.js +1 -1
  21. package/lib/cjs/web/upload.js +2 -2
  22. package/lib/esm/cli/commands/uploadFile.js +2 -1
  23. package/lib/esm/cli/commands/uploadFolder.js +2 -1
  24. package/lib/esm/cli/options.js +19 -0
  25. package/lib/esm/cli/utils.js +25 -1
  26. package/lib/esm/common/factory.js +1 -0
  27. package/lib/esm/common/payment.js +1 -1
  28. package/lib/esm/common/signer.js +22 -1
  29. package/lib/esm/common/token/ario.js +1 -1
  30. package/lib/esm/common/token/arweave.js +1 -1
  31. package/lib/esm/common/token/baseEth.js +17 -1
  32. package/lib/esm/common/token/ethereum.js +13 -4
  33. package/lib/esm/common/token/kyve.js +1 -1
  34. package/lib/esm/common/token/solana.js +10 -1
  35. package/lib/esm/common/turbo.js +3 -1
  36. package/lib/esm/common/upload.js +124 -6
  37. package/lib/esm/node/upload.js +2 -1
  38. package/lib/esm/types.js +17 -0
  39. package/lib/esm/version.js +1 -1
  40. package/lib/esm/web/upload.js +2 -2
  41. package/lib/types/cli/commands/uploadFile.d.ts.map +1 -1
  42. package/lib/types/cli/commands/uploadFolder.d.ts.map +1 -1
  43. package/lib/types/cli/options.d.ts +43 -0
  44. package/lib/types/cli/options.d.ts.map +1 -1
  45. package/lib/types/cli/types.d.ts +4 -0
  46. package/lib/types/cli/types.d.ts.map +1 -1
  47. package/lib/types/cli/utils.d.ts +4 -1
  48. package/lib/types/cli/utils.d.ts.map +1 -1
  49. package/lib/types/common/factory.d.ts +4 -1
  50. package/lib/types/common/factory.d.ts.map +1 -1
  51. package/lib/types/common/signer.d.ts.map +1 -1
  52. package/lib/types/common/token/ario.d.ts +1 -1
  53. package/lib/types/common/token/ario.d.ts.map +1 -1
  54. package/lib/types/common/token/arweave.d.ts +1 -1
  55. package/lib/types/common/token/arweave.d.ts.map +1 -1
  56. package/lib/types/common/token/baseEth.d.ts +1 -0
  57. package/lib/types/common/token/baseEth.d.ts.map +1 -1
  58. package/lib/types/common/token/ethereum.d.ts +2 -1
  59. package/lib/types/common/token/ethereum.d.ts.map +1 -1
  60. package/lib/types/common/token/kyve.d.ts +1 -1
  61. package/lib/types/common/token/kyve.d.ts.map +1 -1
  62. package/lib/types/common/token/solana.d.ts +1 -16
  63. package/lib/types/common/token/solana.d.ts.map +1 -1
  64. package/lib/types/common/turbo.d.ts +2 -2
  65. package/lib/types/common/turbo.d.ts.map +1 -1
  66. package/lib/types/common/upload.d.ts +16 -3
  67. package/lib/types/common/upload.d.ts.map +1 -1
  68. package/lib/types/node/factory.d.ts +4 -1
  69. package/lib/types/node/factory.d.ts.map +1 -1
  70. package/lib/types/node/upload.d.ts +4 -1
  71. package/lib/types/node/upload.d.ts.map +1 -1
  72. package/lib/types/types.d.ts +26 -6
  73. package/lib/types/types.d.ts.map +1 -1
  74. package/lib/types/version.d.ts +1 -1
  75. package/lib/types/version.d.ts.map +1 -1
  76. package/lib/types/web/factory.d.ts +4 -1
  77. package/lib/types/web/factory.d.ts.map +1 -1
  78. package/lib/types/web/upload.d.ts +4 -1
  79. package/lib/types/web/upload.d.ts.map +1 -1
  80. package/package.json +1 -1
package/README.md CHANGED
@@ -267,6 +267,15 @@ const signer = new HexSolanaSigner(bs58.encode(secretKey));
267
267
  const turbo = TurboFactory.authenticated({ signer });
268
268
  ```
269
269
 
270
+ ##### Solana Web Wallet Adapter
271
+
272
+ ```typescript
273
+ const turbo = TurboFactory.authenticated({
274
+ walletAdapter: window.solana,
275
+ token: 'solana',
276
+ });
277
+ ```
278
+
270
279
  ##### Solana Secret Key
271
280
 
272
281
  ```typescript
@@ -659,6 +668,28 @@ await turbo.upload({
659
668
  });
660
669
  ```
661
670
 
671
+ #### On Demand Uploads
672
+
673
+ With the upload methods, you can choose to Top Up with selected crypto token on demand if the connected wallet does not have enough credits to complete the upload.
674
+
675
+ This is done by providing the `OnDemandFunding` class to the `fundingMode` parameter on upload methods. The `maxTokenAmount` (optional) is the maximum amount of tokens in the token type's smallest unit value (e.g: Winston for arweave token type) to fund the wallet with. The `topUpBufferMultiplier` (optional) is the multiplier to apply to the estimated top-up amount to avoid underpayment during on-demand top-ups due to price fluctuations on longer uploads. Defaults to 1.1, meaning a 10% buffer.
676
+
677
+ Note: On demand API currently only available for $ARIO (`ario`), $SOL (`solana`), and $ETH on Base Network (`base-eth`) token types.
678
+
679
+ ```typescript
680
+ const turbo = TurboFactory.authenticated({
681
+ signer: arweaveSignerWithARIO,
682
+ token: 'ario',
683
+ });
684
+ await turbo.upload({
685
+ ...params,
686
+ fundingMode: new OnDemandFunding({
687
+ maxTokenAmount: ARIOToTokenAmount(500), // Max 500 $ARIO
688
+ topUpBufferMultiplier: 1.1, // 10% buffer to avoid underpayment
689
+ }),
690
+ });
691
+ ```
692
+
662
693
  #### `uploadFolder({ folderPath, files, dataItemOpts, signal, maxConcurrentUploads, throwOnFailure, manifestOptions })`
663
694
 
664
695
  Signs and uploads a folder of files. For NodeJS, the `folderPath` of the folder to upload is required. For the browser, an array of `files` is required. The `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. The `maxConcurrentUploads` is an optional number that can be used to limit the number of concurrent uploads. The `throwOnFailure` is an optional boolean that can be used to throw an error if any upload fails. The `manifestOptions` is an optional object that can be used to configure the manifest file, including a custom index file, fallback file, or whether to disable manifests altogether. Manifests are enabled by default.
@@ -1045,6 +1076,9 @@ Command Options:
1045
1076
  - `--fallback-file <fallbackFile>` - File to use for the "fallback" path in the resulting manifest
1046
1077
  - `--no-manifest` - Disable manifest creation
1047
1078
  - `--max-concurrency <maxConcurrency>` - Maximum number of concurrent uploads
1079
+ - `--on-demand` - Enable on-demand top up if the connected wallet does not have enough credits to complete the upload (only available for $ARIO, $SOL, and $ETH on Base Network token types)
1080
+ - `--max-crypto-top-up-value <maxCryptoTopUpValue>` - Maximum value of crypto token for on-demand top up. e.g: 100 for 100 $ARIO. NOTE: This is a value in the token's standard crypto unit, not the smallest unit. e.g: 100 for 100 $ARIO, NOT 100000000 for 100 $ARIO
1081
+ - `--top-up-buffer-multiplier <topUpBufferMultiplier>` - Multiplier to apply to the estimated top-up amount to avoid underpayment during on-demand top-ups due to price fluctuations. Default: 1.1 (10% buffer)
1048
1082
 
1049
1083
  e.g:
1050
1084
 
@@ -1059,6 +1093,9 @@ Upload a file to the Turbo Upload Service.
1059
1093
  Command Options:
1060
1094
 
1061
1095
  - `-f, --file-path <filePath>` - Path to the file to upload
1096
+ - `--on-demand` - Enable on-demand top up if the connected wallet does not have enough credits to complete the upload (only available for $ARIO, $SOL, and $ETH on Base Network token types)
1097
+ - `--max-crypto-top-up-value <maxCryptoTopUpValue>` - Maximum value of crypto token for on-demand top up. e.g: 100 for 100 $ARIO. NOTE: This is a value in the token's standard crypto unit, not the smallest unit. e.g: 100 for 100 $ARIO, NOT 100000000 for 100 $ARIO
1098
+ - `--top-up-buffer-multiplier <topUpBufferMultiplier>` - Multiplier to apply to the estimated top-up amount to avoid underpayment during on-demand top-ups due to price fluctuations. Default: 1.1 (10% buffer)
1062
1099
 
1063
1100
  e.g:
1064
1101