mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 06:01:02 +00:00
Contracts Add new version for marking new stable API (#3415)
Add a `ApiVersion` constant to the pallet-contracts Config to communicate with developers the current state of the host functions exposed by the pallet
This commit is contained in:
@@ -72,5 +72,6 @@ impl Config for Runtime {
|
|||||||
type RuntimeHoldReason = RuntimeHoldReason;
|
type RuntimeHoldReason = RuntimeHoldReason;
|
||||||
type Debug = ();
|
type Debug = ();
|
||||||
type Environment = ();
|
type Environment = ();
|
||||||
|
type ApiVersion = ();
|
||||||
type Xcm = pallet_xcm::Pallet<Self>;
|
type Xcm = pallet_xcm::Pallet<Self>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
title: "[pallet-contracts] Add APIVersion to the config."
|
||||||
|
|
||||||
|
doc:
|
||||||
|
- audience: Runtime Dev
|
||||||
|
description: |
|
||||||
|
Add `APIVersion` to the config to communicate the state of the Host functions exposed by the pallet.
|
||||||
|
|
||||||
|
crates:
|
||||||
|
- name: pallet-contracts
|
||||||
@@ -1367,6 +1367,7 @@ impl pallet_contracts::Config for Runtime {
|
|||||||
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
type CodeHashLockupDepositPercent = CodeHashLockupDepositPercent;
|
||||||
type Debug = ();
|
type Debug = ();
|
||||||
type Environment = ();
|
type Environment = ();
|
||||||
|
type ApiVersion = ();
|
||||||
type Xcm = ();
|
type Xcm = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,5 +94,6 @@ impl pallet_contracts::Config for Runtime {
|
|||||||
type WeightPrice = Self;
|
type WeightPrice = Self;
|
||||||
type Debug = ();
|
type Debug = ();
|
||||||
type Environment = ();
|
type Environment = ();
|
||||||
|
type ApiVersion = ();
|
||||||
type Xcm = pallet_xcm::Pallet<Self>;
|
type Xcm = pallet_xcm::Pallet<Self>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,6 +214,18 @@ pub struct Environment<T: Config> {
|
|||||||
block_number: EnvironmentType<BlockNumberFor<T>>,
|
block_number: EnvironmentType<BlockNumberFor<T>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Defines the current version of the HostFn APIs.
|
||||||
|
/// This is used to communicate the available APIs in pallet-contracts.
|
||||||
|
///
|
||||||
|
/// The version is bumped any time a new HostFn is added or stabilized.
|
||||||
|
#[derive(Encode, Decode, TypeInfo)]
|
||||||
|
pub struct ApiVersion(u16);
|
||||||
|
impl Default for ApiVersion {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[frame_support::pallet]
|
#[frame_support::pallet]
|
||||||
pub mod pallet {
|
pub mod pallet {
|
||||||
use super::*;
|
use super::*;
|
||||||
@@ -402,6 +414,12 @@ pub mod pallet {
|
|||||||
#[pallet::constant]
|
#[pallet::constant]
|
||||||
type Environment: Get<Environment<Self>>;
|
type Environment: Get<Environment<Self>>;
|
||||||
|
|
||||||
|
/// The version of the HostFn APIs that are available in the runtime.
|
||||||
|
///
|
||||||
|
/// Only valid value is `()`.
|
||||||
|
#[pallet::constant]
|
||||||
|
type ApiVersion: Get<ApiVersion>;
|
||||||
|
|
||||||
/// A type that exposes XCM APIs, allowing contracts to interact with other parachains, and
|
/// A type that exposes XCM APIs, allowing contracts to interact with other parachains, and
|
||||||
/// execute XCM programs.
|
/// execute XCM programs.
|
||||||
type Xcm: xcm_builder::Controller<
|
type Xcm: xcm_builder::Controller<
|
||||||
|
|||||||
@@ -465,6 +465,7 @@ impl Config for Test {
|
|||||||
type MaxDelegateDependencies = MaxDelegateDependencies;
|
type MaxDelegateDependencies = MaxDelegateDependencies;
|
||||||
type Debug = TestDebug;
|
type Debug = TestDebug;
|
||||||
type Environment = ();
|
type Environment = ();
|
||||||
|
type ApiVersion = ();
|
||||||
type Xcm = ();
|
type Xcm = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user