Skip to content
Unverified Commit 7725890d authored by davidk-pt's avatar davidk-pt Committed by GitHub
Browse files

[Deprecation] deprecate treasury `spend_local` call and related items (#6169)



Resolves https://github.com/paritytech/polkadot-sdk/issues/5930

`spend_local` from `treasury` pallet and associated types are
deprecated. `spend_local` was being used before with native currency in
the treasury.

This PR provides a documentation on how to migrate to the `spend` call
instead.

### Migration

#### For users who were using only `spend_local` before

To replace `spend_local` functionality configure `Paymaster` pallet
configuration to be `PayFromAccount` and configure `AssetKind` to be
`()` and use `spend` call instead.
This way `spend` call will function as deprecated `spend_local`.

Example:
```
impl pallet_treasury::Config for Runtime {
    ..
    type AssetKind = ();
    type Paymaster = PayFromAccount<Self::Currency, TreasuryAccount>;
    // convert balance 1:1 ratio with native currency
    type BalanceConverter = UnityAssetBalanceConversion;
    ..
}
```

#### For users who were already using `spend` with all other assets,
except the native asset

Use `NativeOrWithId` type for `AssetKind` and have a `UnionOf` for
native and non-native assets, then use that with `PayAssetFromAccount`.

Example from `kitchensink-runtime`:
```
// Union of native currency and assets
pub type NativeAndAssets =
    UnionOf<Balances, Assets, NativeFromLeft, NativeOrWithId<u32>, AccountId>;

impl pallet_treasury::Config for Runtime {
    ..
    type AssetKind = NativeOrWithId<u32>;
    type Paymaster = PayAssetFromAccount<NativeAndAssets, TreasuryAccount>;
    type BalanceConverter = AssetRate;
    ..
}

// AssetRate pallet configuration
impl pallet_asset_rate::Config for Runtime {
    ..
    type Currency = Balances;
    type AssetKind = NativeOrWithId<u32>;
    ..
}
```

---------

Co-authored-by: default avatarDavidK <[email protected]>
Co-authored-by: default avatarMuharem <[email protected]>
parent 74ec1ee2
Pipeline #504292 waiting for manual action with stages
in 23 minutes and 53 seconds