Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use credit sharing in commands/methods/docs PE-6754 #198

Merged
merged 8 commits into from
Nov 1, 2024

Conversation

fedellen
Copy link
Collaborator

@fedellen fedellen commented Nov 1, 2024

No description provided.

@fedellen fedellen requested a review from a team as a code owner November 1, 2024 17:28
@fedellen fedellen self-assigned this Nov 1, 2024
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.60%. Comparing base (d7a6f5e) to head (b2acf6a).
Report is 20 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha     #198      +/-   ##
==========================================
- Coverage   93.61%   93.60%   -0.02%     
==========================================
  Files          25       25              
  Lines        3491     3485       -6     
  Branches      159      159              
==========================================
- Hits         3268     3262       -6     
  Misses        223      223              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fedellen fedellen merged commit 84216ef into alpha Nov 1, 2024
9 checks passed
@fedellen fedellen deleted the PE-6754-credit-sharing branch November 1, 2024 20:35
@dtfiedler
Copy link
Collaborator

🎉 This PR is included in version 1.20.0-alpha.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

```

## Turbo Credit Sharing

Users can share their purchased Credits with other user's wallets by creating Credit Share Approvals. These approvals are created by uploading a signed data item with tags indicating the recipient's wallet address, the amount of Credits to share, and an optional amount of seconds that the approval will expire in. The recipient can then use the shared Credits to pay for their own uploads to Turbo.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other user's wallets -> other users' wallets


Users can share their purchased Credits with other user's wallets by creating Credit Share Approvals. These approvals are created by uploading a signed data item with tags indicating the recipient's wallet address, the amount of Credits to share, and an optional amount of seconds that the approval will expire in. The recipient can then use the shared Credits to pay for their own uploads to Turbo.

Shared Credits cannot be re-shared by the recipient to other recipients. Only the owner of the Credits can share or revoke Credit Share Approvals. Credits that are shared to other wallets may not be used by the original owner of the Credits for sharing or uploading unless the Credit Share Approval is revoked or expired.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the owner -> Only the original owner


To use the shared Credits, recipient users must provide the wallet address of the user who shared the Credits with them in the `x-paid-by` HTTP header when uploading data. This tells Turbo services to look for and use Credit Share Approvals to pay for the upload before using the signer's balance.

For user convenience, during upload the Turbo CLI will use any available Credit Share Approvals found for the connected wallet before using the signing wallet's balance. To instead ignore all Credit shares and only use the signer's balance, use the `--ignore-approvals` flag. To use the signer's balance first before using Credit shares, use the `--use-signer-balance-first` flag. The Turbo SDK layer does not provide this functionality and will always use the signer's balance unless `paidBy` is provided.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Turbo SDK layer does not provide this functionality and will always use the signer's balance unless paidBy is provided.
This is a little confusing... are you saying it can do it (and what is "it" specifically?") or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifically it does not provide any convenience of fetching approvals. it only uses the paidBy. I'll change up the wording

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-> In contrast, the Turbo SDK layer does not provide this functionality and and will only use approvals when paidBy is provided.


- `shareCredits`: Creates a Credit Share Approval for the specified wallet address and amount of Credits.
- `revokeCredits`: Revokes all Credit Share Approvals for the specified wallet address.
- `listShares`: Lists all Credit Share Approvals for the specified wallet address or connected wallet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have no APIs that can list ALL of the credit share approvals provided by the original credit holder?

Copy link
Collaborator Author

@fedellen fedellen Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you mean approvals from single payer to a single signer, no not on the SDK level. the payment API does provide this for compatibility with the getApproval from ARx tooling. but this can be achieved by using the SDK and a simple filter: listShares(signerAddress).receivedApprovals.filter(a => a === payerAddress)

- `shareCredits`: Creates a Credit Share Approval for the specified wallet address and amount of Credits.
- `revokeCredits`: Revokes all Credit Share Approvals for the specified wallet address.
- `listShares`: Lists all Credit Share Approvals for the specified wallet address or connected wallet.
- `dataItemOpts: { ...opts, paidBy: string[] }`: Upload methods now accept an array of wallet addresses to pay for the upload.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upload methods now accept an array of wallet addresses to pay for the upload. -> Upload methods now accept 'paidBy', an array of wallet addresses that have provided credit share approvals to the user from which to pay, in the order provided and as necessary, for the upload.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of a mouthful, but perhaps GPT can clean it up

@dtfiedler
Copy link
Collaborator

🎉 This PR is included in version 1.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants