Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Pallets: Treasury spends various asset kinds #14434

Open
wants to merge 43 commits into
base: master
Choose a base branch
from

Conversation

muharem
Copy link
Contributor

@muharem muharem commented Jun 21, 2023

Treasury Pallet can accept proposals for spends of various asset kinds and pay them out through the implementation of the Pay trait.

New Dispatchables:

  • spend(Config::AssetKind, AssetBalance, Config::Beneficiary, Option<ValidFrom>) - propose and approve a spend;
  • payout(SpendIndex) - payout an approved spend or retry a failed payout;
  • check_payment(SpendIndex) - check the status of a payout;
  • void_spend(SpendIndex) - void previously approved spend;

existing spend dispatchable renamed to spend_local

The parameters' types of the spend dispatchable exposed via the pallet's Config and allows to propose and accept a spend of a certain amount.

An approved spend can be claimed via the payout within the Config::SpendPeriod. Clients provide an implementation of the Pay trait which can pay an asset of the AssetKind to the Beneficiary.

The implementation of the Pay trait might not have an immediate final payment status, for example if implemented over XCM and the actual transfer happens on a remote chain.

The check_status dispatchable can be executed to update the spend's payment state and retry the payout if the payment has failed.

polkadot companion: paritytech/polkadot#7427

Closes paritytech/polkadot-sdk#92

@muharem muharem changed the title Pallets: Treasury spends processed with the Pay trait. Pallets: Treasury spends various asset kinds Jun 26, 2023
@muharem muharem added A3-in_progress Pull request is in progress. No review needed at this stage. C3-medium PR touches the given topic and has a medium impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited B1-note_worthy Changes should be noted in the release notes T1-runtime This PR/Issue is related to the topic “runtime”. labels Jul 2, 2023
@muharem muharem added the F3-breaks_API This PR changes public API; next release should be major. label Jul 3, 2023
@@ -15,53 +15,69 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//! > Made with *Substrate*, for *Polkadot*.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@muharem muharem requested a review from a team July 13, 2023 15:48
@paritytech-cicd-pr
Copy link

The CI pipeline was cancelled due to failure one of the required jobs.
Job name: cargo-check-benches
Logs: https://gitlab.parity.io/parity/mirrors/substrate/-/jobs/3276578

@muharem
Copy link
Contributor Author

muharem commented Jul 30, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

@muharem
Copy link
Contributor Author

muharem commented Aug 1, 2023

bot rebase

@paritytech-processbot
Copy link

Rebased

let native_amount = T::BalanceConverter::from_asset_balance(amount, asset_kind.clone())
.map_err(|_| Error::<T, I>::FailedToConvertBalance)?;

ensure!(native_amount <= max_amount, Error::<T, I>::InsufficientPermission);
Copy link
Member

Choose a reason for hiding this comment

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

is this not superfluous with the next block in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

now it runs with context only if dispatched via UnfilteredDispatchable::dispatch_bypass_filter

Copy link
Member

@gavofyork gavofyork left a comment

Choose a reason for hiding this comment

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

Looks good modulo the comments.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B1-note_worthy Changes should be noted in the release notes C3-medium PR touches the given topic and has a medium impact on builders. D9-needsaudit 👮 PR contains changes to fund-managing logic that should be properly reviewed and externally audited F3-breaks_API This PR changes public API; next release should be major. T1-runtime This PR/Issue is related to the topic “runtime”.
Projects
Development

Successfully merging this pull request may close these issues.

Extension to Treasury Pallet for Assets
5 participants