-
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 #362
feat: sponsorships #362
Conversation
Co-authored-by: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com>
…-node into al3mart/sub0/feat-sponsored
beneficiary: AccountIdOf<T>, | ||
) -> DispatchResult { | ||
let who = ensure_signed(origin)?; | ||
if <Sponsorships<T>>::take(&who, &beneficiary).is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original comment at: #351 (comment)
What would happen to the weight here? Is it just lost?
fn is_contracts_call( | ||
call: &<T as frame_system::Config>::RuntimeCall, | ||
) -> Option<AccountIdOf<T>> { | ||
match call.is_sub_type() { | ||
Some(pallet_revive::Call::<T>::call { dest, .. }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original comment from #351 (comment)
Ideally this would be passed in via a generic type parameter which resolves a runtime call to an account id so no tight coupling to revive and configured at runtime level.
No changes required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I tested both sponsorship and incentives, and is looking good!
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
.