mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 04:01:10 +00:00
contracts: Allow runtime authors to define a chain extension (#7548)
* Make host functions return TrapReason This avoids the need to manually store any trap reasons to the `Runtime` from the host function. This adds the following benefits: * It properly composes with the upcoming chain extensions * Missing to set a trap value is now a compile error * Add chain extension The chain extension is a way for the contract author to add new host functions for contracts to call. * Add tests for chain extensions * Fix regression in set_rent.wat fixture Not all offsets where properly updated when changing the fixtures for the new salt on instantiate. * Pre-charge a weight amount based off the specified length * Improve fn write docs * Renamed state to phantom * Fix typo
This commit is contained in:
committed by
GitHub
parent
e3e651f72c
commit
51c37ecc15
@@ -89,6 +89,8 @@ mod wasm;
|
||||
mod rent;
|
||||
mod benchmarking;
|
||||
mod schedule;
|
||||
|
||||
pub mod chain_extension;
|
||||
pub mod weights;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -320,6 +322,9 @@ pub trait Config: frame_system::Config {
|
||||
/// Describes the weights of the dispatchables of this module and is also used to
|
||||
/// construct a default cost schedule.
|
||||
type WeightInfo: WeightInfo;
|
||||
|
||||
/// Type that allows the runtime authors to add new host functions for a contract to call.
|
||||
type ChainExtension: chain_extension::ChainExtension;
|
||||
}
|
||||
|
||||
decl_error! {
|
||||
@@ -387,6 +392,10 @@ decl_error! {
|
||||
TooManyTopics,
|
||||
/// The topics passed to `seal_deposit_events` contains at least one duplicate.
|
||||
DuplicateTopics,
|
||||
/// The chain does not provide a chain extension. Calling the chain extension results
|
||||
/// in this error. Note that this usually shouldn't happen as deploying such contracts
|
||||
/// is rejected.
|
||||
NoChainExtension,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user