@ardrive/turbo-sdk 1.31.1 → 1.32.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 (77) hide show
  1. package/README.md +28 -0
  2. package/bundles/web.bundle.min.js +437 -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/token/ario.js +1 -1
  10. package/lib/cjs/common/token/arweave.js +1 -1
  11. package/lib/cjs/common/token/baseEth.js +17 -1
  12. package/lib/cjs/common/token/ethereum.js +13 -4
  13. package/lib/cjs/common/token/kyve.js +1 -1
  14. package/lib/cjs/common/token/solana.js +1 -1
  15. package/lib/cjs/common/turbo.js +3 -1
  16. package/lib/cjs/common/upload.js +124 -6
  17. package/lib/cjs/node/upload.js +2 -1
  18. package/lib/cjs/types.js +20 -1
  19. package/lib/cjs/version.js +1 -1
  20. package/lib/cjs/web/upload.js +2 -2
  21. package/lib/esm/cli/commands/uploadFile.js +2 -1
  22. package/lib/esm/cli/commands/uploadFolder.js +2 -1
  23. package/lib/esm/cli/options.js +19 -0
  24. package/lib/esm/cli/utils.js +25 -1
  25. package/lib/esm/common/factory.js +1 -0
  26. package/lib/esm/common/payment.js +1 -1
  27. package/lib/esm/common/token/ario.js +1 -1
  28. package/lib/esm/common/token/arweave.js +1 -1
  29. package/lib/esm/common/token/baseEth.js +17 -1
  30. package/lib/esm/common/token/ethereum.js +13 -4
  31. package/lib/esm/common/token/kyve.js +1 -1
  32. package/lib/esm/common/token/solana.js +1 -1
  33. package/lib/esm/common/turbo.js +3 -1
  34. package/lib/esm/common/upload.js +124 -6
  35. package/lib/esm/node/upload.js +2 -1
  36. package/lib/esm/types.js +17 -0
  37. package/lib/esm/version.js +1 -1
  38. package/lib/esm/web/upload.js +2 -2
  39. package/lib/types/cli/commands/uploadFile.d.ts.map +1 -1
  40. package/lib/types/cli/commands/uploadFolder.d.ts.map +1 -1
  41. package/lib/types/cli/options.d.ts +43 -0
  42. package/lib/types/cli/options.d.ts.map +1 -1
  43. package/lib/types/cli/types.d.ts +4 -0
  44. package/lib/types/cli/types.d.ts.map +1 -1
  45. package/lib/types/cli/utils.d.ts +4 -1
  46. package/lib/types/cli/utils.d.ts.map +1 -1
  47. package/lib/types/common/factory.d.ts +4 -1
  48. package/lib/types/common/factory.d.ts.map +1 -1
  49. package/lib/types/common/token/ario.d.ts +1 -1
  50. package/lib/types/common/token/ario.d.ts.map +1 -1
  51. package/lib/types/common/token/arweave.d.ts +1 -1
  52. package/lib/types/common/token/arweave.d.ts.map +1 -1
  53. package/lib/types/common/token/baseEth.d.ts +1 -0
  54. package/lib/types/common/token/baseEth.d.ts.map +1 -1
  55. package/lib/types/common/token/ethereum.d.ts +2 -1
  56. package/lib/types/common/token/ethereum.d.ts.map +1 -1
  57. package/lib/types/common/token/kyve.d.ts +1 -1
  58. package/lib/types/common/token/kyve.d.ts.map +1 -1
  59. package/lib/types/common/token/solana.d.ts +1 -1
  60. package/lib/types/common/token/solana.d.ts.map +1 -1
  61. package/lib/types/common/turbo.d.ts +2 -2
  62. package/lib/types/common/turbo.d.ts.map +1 -1
  63. package/lib/types/common/upload.d.ts +16 -3
  64. package/lib/types/common/upload.d.ts.map +1 -1
  65. package/lib/types/node/factory.d.ts +4 -1
  66. package/lib/types/node/factory.d.ts.map +1 -1
  67. package/lib/types/node/upload.d.ts +4 -1
  68. package/lib/types/node/upload.d.ts.map +1 -1
  69. package/lib/types/types.d.ts +19 -4
  70. package/lib/types/types.d.ts.map +1 -1
  71. package/lib/types/version.d.ts +1 -1
  72. package/lib/types/version.d.ts.map +1 -1
  73. package/lib/types/web/factory.d.ts +4 -1
  74. package/lib/types/web/factory.d.ts.map +1 -1
  75. package/lib/types/web/upload.d.ts +4 -1
  76. package/lib/types/web/upload.d.ts.map +1 -1
  77. package/package.json +1 -1
package/README.md CHANGED
@@ -659,6 +659,28 @@ await turbo.upload({
659
659
  });
660
660
  ```
661
661
 
662
+ #### On Demand Uploads
663
+
664
+ 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.
665
+
666
+ 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.
667
+
668
+ Note: On demand API currently only available for $ARIO (`ario`), $SOL (`solana`), and $ETH on Base Network (`base-eth`) token types.
669
+
670
+ ```typescript
671
+ const turbo = TurboFactory.authenticated({
672
+ signer: arweaveSignerWithARIO,
673
+ token: 'ario',
674
+ });
675
+ await turbo.upload({
676
+ ...params,
677
+ fundingMode: new OnDemandFunding({
678
+ maxTokenAmount: ARIOToTokenAmount(500), // Max 500 $ARIO
679
+ topUpBufferMultiplier: 1.1, // 10% buffer to avoid underpayment
680
+ }),
681
+ });
682
+ ```
683
+
662
684
  #### `uploadFolder({ folderPath, files, dataItemOpts, signal, maxConcurrentUploads, throwOnFailure, manifestOptions })`
663
685
 
664
686
  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 +1067,9 @@ Command Options:
1045
1067
  - `--fallback-file <fallbackFile>` - File to use for the "fallback" path in the resulting manifest
1046
1068
  - `--no-manifest` - Disable manifest creation
1047
1069
  - `--max-concurrency <maxConcurrency>` - Maximum number of concurrent uploads
1070
+ - `--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)
1071
+ - `--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
1072
+ - `--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
1073
 
1049
1074
  e.g:
1050
1075
 
@@ -1059,6 +1084,9 @@ Upload a file to the Turbo Upload Service.
1059
1084
  Command Options:
1060
1085
 
1061
1086
  - `-f, --file-path <filePath>` - Path to the file to upload
1087
+ - `--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)
1088
+ - `--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
1089
+ - `--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
1090
 
1063
1091
  e.g:
1064
1092