-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: sponsorships #351
Closed
Closed
feat: sponsorships #351
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Co-authored-by: Peter White <petras9789@gmail.com>
Co-authored-by: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com>
Closing in favor of #362 as I messed up the commit history and the PR was difficult to review. |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce the PoC for sponsored transactions.
Means to keeps track of sponsorship relations between a sponsor account and a beneficiary account such that sponsors can cover transaction fees for the beneficiaries.
This PoC introduces a simple pallet that maintains sponsorships in a double map
Note that the value stored is of type
Weigth
with the idea that each relation could have different limits for how much a sponsor should cover for its beneficiary. Although, that is not explored in this PoC.Implements two extrinsics to modify said state:
pub fn sponsor_account(origin: OriginFor<T>, beneficiary: T::AccountId) -> DispatchResult {}
pub fn remove_sponsorship_for(origin: OriginFor<T>, beneficiary: T::AccountId) -> DispatchResult {}
pub fn set_sponsorship_amount( origin: OriginFor<T>, beneficiary: AccountIdOf<T>, new_amount: BalanceOf<T>) -> DispatchResult {}
And the struct
Sponsored
implementsSignedExtension
and it is expected to wrap another implementer ofSignedExtension
that handles the deduction of the relevant transaction fees.Sponsored
implementation takes care of verifying the sponsorship exists and forwards to the wrapper extension the correct account to deduct fees from.In this PoC the only possible interaction that can be sponsored is a call to a contract.
This pallet is exposed to ink! contracts via pop-api. A contract is included showing how an account can be registered to be sponsor in the example contract "sponsorships":
pop-api/examples/sponsorships/lib.rs
.