@ardrive/turbo-sdk 1.4.2 → 1.5.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 (56) hide show
  1. package/README.md +27 -1
  2. package/bundles/web.bundle.min.js +7491 -1388
  3. package/lib/cjs/common/http.js +6 -2
  4. package/lib/cjs/common/index.js +1 -0
  5. package/lib/cjs/common/payment.js +106 -3
  6. package/lib/cjs/common/signer.js +45 -0
  7. package/lib/cjs/common/token.js +132 -0
  8. package/lib/cjs/common/turbo.js +13 -0
  9. package/lib/cjs/node/factory.js +2 -1
  10. package/lib/cjs/node/signer.js +4 -17
  11. package/lib/cjs/types.js +2 -0
  12. package/lib/cjs/utils/common.js +23 -0
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/cjs/web/factory.js +3 -1
  15. package/lib/cjs/web/signer.js +22 -26
  16. package/lib/esm/common/http.js +6 -2
  17. package/lib/esm/common/index.js +1 -0
  18. package/lib/esm/common/payment.js +106 -3
  19. package/lib/esm/common/signer.js +41 -0
  20. package/lib/esm/common/token.js +123 -0
  21. package/lib/esm/common/turbo.js +13 -0
  22. package/lib/esm/node/factory.js +2 -1
  23. package/lib/esm/node/signer.js +5 -18
  24. package/lib/esm/types.js +1 -1
  25. package/lib/esm/utils/common.js +19 -0
  26. package/lib/esm/version.js +1 -1
  27. package/lib/esm/web/factory.js +3 -1
  28. package/lib/esm/web/signer.js +22 -26
  29. package/lib/types/common/http.d.ts.map +1 -1
  30. package/lib/types/common/index.d.ts +1 -0
  31. package/lib/types/common/index.d.ts.map +1 -1
  32. package/lib/types/common/logger.d.ts +4 -4
  33. package/lib/types/common/logger.d.ts.map +1 -1
  34. package/lib/types/common/payment.d.ts +10 -19
  35. package/lib/types/common/payment.d.ts.map +1 -1
  36. package/lib/types/common/signer.d.ts +16 -0
  37. package/lib/types/common/signer.d.ts.map +1 -0
  38. package/lib/types/common/token.d.ts +47 -0
  39. package/lib/types/common/token.d.ts.map +1 -0
  40. package/lib/types/common/turbo.d.ts +12 -1
  41. package/lib/types/common/turbo.d.ts.map +1 -1
  42. package/lib/types/node/factory.d.ts +1 -1
  43. package/lib/types/node/factory.d.ts.map +1 -1
  44. package/lib/types/node/signer.d.ts +4 -15
  45. package/lib/types/node/signer.d.ts.map +1 -1
  46. package/lib/types/types.d.ts +105 -5
  47. package/lib/types/types.d.ts.map +1 -1
  48. package/lib/types/utils/common.d.ts +18 -0
  49. package/lib/types/utils/common.d.ts.map +1 -0
  50. package/lib/types/version.d.ts +1 -1
  51. package/lib/types/version.d.ts.map +1 -1
  52. package/lib/types/web/factory.d.ts +1 -1
  53. package/lib/types/web/factory.d.ts.map +1 -1
  54. package/lib/types/web/signer.d.ts +8 -15
  55. package/lib/types/web/signer.d.ts.map +1 -1
  56. package/package.json +10 -5
package/README.md CHANGED
@@ -258,6 +258,17 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
258
258
  }
259
259
  ```
260
260
 
261
+ - `submitFundTransaction({ txId })` - 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.
262
+
263
+ - Note: Use this API if you've already executed your token transfer to the Turbo wallet. Otherwise, consider using `topUpWithTokens` to execute a new token transfer to the Turbo wallet and submit its resulting transaction ID for top up processing all in one go
264
+
265
+ ```typescript
266
+ const turbo = TurboFactory.unauthenticated(); // defaults to arweave token type
267
+ const { status, id, ...fundResult } = await turbo.submitFundTransaction({
268
+ txId: 'my-valid-arweave-fund-transaction-id',
269
+ });
270
+ ```
271
+
261
272
  ### TurboAuthenticatedClient
262
273
 
263
274
  - `getBalance()` - Issues a signed request to get the credit balance of a wallet measured in AR (measured in Winston Credits, or winc).
@@ -324,6 +335,20 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
324
335
  });
325
336
  ```
326
337
 
338
+ - `topUpWithTokens({ tokenAmount, feeMultiplier })` - Tops up the connected wallet with Credits by submitting a payment transaction for the token amount to the Turbo wallet and then submitting that transaction id to Turbo Payment Service for top up processing.
339
+
340
+ - 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.
341
+ - 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.
342
+
343
+ ```typescript
344
+ const turbo = TurboFactory.authenticated({ signer, token: 'arweave' });
345
+
346
+ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
347
+ tokenAmount: WinstonToTokenAmount(100_000_000), // 0.0001 AR
348
+ feeMultiplier: 1.1, // 10% increase in reward for improved mining chances
349
+ });
350
+ ```
351
+
327
352
  ## Developers
328
353
 
329
354
  ### Requirements
@@ -339,7 +364,8 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
339
364
 
340
365
  ### Testing
341
366
 
342
- - `yarn test` - runs integration tests
367
+ - `yarn test` - runs integration tests against dev environment (e.g. `https://payment.ardrive.dev` and `https://upload.ardrive.dev`)
368
+ - `yarn test:docker` - runs integration tests against locally running docker containers (recommended)
343
369
  - `yarn example:web` - opens up the example web page
344
370
  - `yarn example:cjs` - runs example CJS node script
345
371
  - `yarn example:esm` - runs example ESM node script