Trait pink::system::System

source ·
pub trait System: ContractEnv {
Show 42 associated items type versionOutput: ImpliesReturn<VersionTuple>; type grantAdminOutput: ImpliesReturn<Result<()>>; type isAdminOutput: ImpliesReturn<bool>; type setDriverOutput: ImpliesReturn<Result<()>>; type getDriverOutput: ImpliesReturn<Option<AccountId>>; type getDriver2Output: ImpliesReturn<Option<(BlockNumber, AccountId)>>; type deploySidevmToOutput: ImpliesReturn<Result<()>>; type stopSidevmAtOutput: ImpliesReturn<Result<()>>; type setHookOutput: ImpliesReturn<Result<()>>; type setContractWeightOutput: ImpliesReturn<Result<()>>; type totalBalanceOfOutput: ImpliesReturn<Balance>; type freeBalanceOfOutput: ImpliesReturn<Balance>; type upgradeSystemContractOutput: ImpliesReturn<Result<()>>; type doUpgradeOutput: ImpliesReturn<Result<()>>; type upgradeRuntimeOutput: ImpliesReturn<Result<()>>; type codeExistsOutput: ImpliesReturn<bool>; type codeHashOutput: ImpliesReturn<Option<Hash>>; type driverHistoryOutput: ImpliesReturn<Option<Vec<(BlockNumber, AccountId)>>>; type currentEventChainHeadOutput: ImpliesReturn<(u64, Hash)>; type deploySidevmToWorkersOutput: ImpliesReturn<Result<()>>; type setSidevmDeadlineOutput: ImpliesReturn<Result<()>>; // Required methods fn version(&self) -> Self::versionOutput; fn grant_admin(&mut self, contract_id: AccountId) -> Self::grantAdminOutput; fn is_admin(&self, contract_id: AccountId) -> Self::isAdminOutput; fn set_driver( &mut self, name: String, contract_id: AccountId ) -> Self::setDriverOutput; fn get_driver(&self, name: String) -> Self::getDriverOutput; fn get_driver2(&self, name: String) -> Self::getDriver2Output; fn deploy_sidevm_to( &self, contract_id: AccountId, code_hash: Hash ) -> Self::deploySidevmToOutput; fn stop_sidevm_at(&self, contract_id: AccountId) -> Self::stopSidevmAtOutput; fn set_hook( &mut self, hook: HookPoint, contract_id: AccountId, selector: u32, gas_limit: u64 ) -> Self::setHookOutput; fn set_contract_weight( &self, contract_id: AccountId, weight: u32 ) -> Self::setContractWeightOutput; fn total_balance_of(&self, account: AccountId) -> Self::totalBalanceOfOutput; fn free_balance_of(&self, account: AccountId) -> Self::freeBalanceOfOutput; fn upgrade_system_contract(&mut self) -> Self::upgradeSystemContractOutput; fn do_upgrade(&self, from_version: VersionTuple) -> Self::doUpgradeOutput; fn upgrade_runtime( &mut self, version: (u32, u32) ) -> Self::upgradeRuntimeOutput; fn code_exists( &self, code_hash: Hash, code_type: CodeType ) -> Self::codeExistsOutput; fn code_hash(&self, account: AccountId) -> Self::codeHashOutput; fn driver_history(&self, name: String) -> Self::driverHistoryOutput; fn current_event_chain_head(&self) -> Self::currentEventChainHeadOutput; fn deploy_sidevm_to_workers( &self, contract_id: AccountId, code_hash: Hash, workers: Vec<WorkerId>, config: SidevmConfig ) -> Self::deploySidevmToWorkersOutput; fn set_sidevm_deadline( &self, contract_id: AccountId, run_until: BlockNumber ) -> Self::setSidevmDeadlineOutput;
}
Expand description

The doc is messed up by the ink macro. See SystemForDoc for a clean version

The pink system contract interface.

The system contract, instantiated with each cluster creation, manages access permissions to the privileged chain extension functions and pink events. Some of these functions or events are exclusive to the system contract. User contracts wishing to call these functions or emit these events must first request the system contract, which then checks the permissions to either execute or reject the request.

Required Associated Types§

source

type versionOutput: ImpliesReturn<VersionTuple>

Output type of the respective trait message.

source

type grantAdminOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type isAdminOutput: ImpliesReturn<bool>

Output type of the respective trait message.

source

type setDriverOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type getDriverOutput: ImpliesReturn<Option<AccountId>>

Output type of the respective trait message.

source

type getDriver2Output: ImpliesReturn<Option<(BlockNumber, AccountId)>>

Output type of the respective trait message.

source

type deploySidevmToOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type stopSidevmAtOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type setHookOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type setContractWeightOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type totalBalanceOfOutput: ImpliesReturn<Balance>

Output type of the respective trait message.

source

type freeBalanceOfOutput: ImpliesReturn<Balance>

Output type of the respective trait message.

source

type upgradeSystemContractOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type doUpgradeOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type upgradeRuntimeOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type codeExistsOutput: ImpliesReturn<bool>

Output type of the respective trait message.

source

type codeHashOutput: ImpliesReturn<Option<Hash>>

Output type of the respective trait message.

source

type driverHistoryOutput: ImpliesReturn<Option<Vec<(BlockNumber, AccountId)>>>

Output type of the respective trait message.

source

type currentEventChainHeadOutput: ImpliesReturn<(u64, Hash)>

Output type of the respective trait message.

source

type deploySidevmToWorkersOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

source

type setSidevmDeadlineOutput: ImpliesReturn<Result<()>>

Output type of the respective trait message.

Required Methods§

source

fn version(&self) -> Self::versionOutput

Returns the system contract version, indicating its API capabilities.

§Example
use pink::system::SystemRef;
let (major, minor, patch) = SystemRef::instance().version();
source

fn grant_admin(&mut self, contract_id: AccountId) -> Self::grantAdminOutput

Grants the administrator role to an address. Administrator contracts can set drivers, deploy sidevm, etc.

Must be called by the cluster owner.

source

fn is_admin(&self, contract_id: AccountId) -> Self::isAdminOutput

Checks if an address is an administrator.

source

fn set_driver( &mut self, name: String, contract_id: AccountId ) -> Self::setDriverOutput

Marks a contract as a driver for a given name, retrievable via get_driver or get_driver2. The caller must be the cluster owner or an administrator. Any valid string can be a name. There are predefined names used by the Phat Contract system.

There are some predefined names that are used by the Phat Contract system:

  • PinkLogger: The contract that with a sidevm instance that collect the logs and events emitted by the ink! contracts in current cluster.
  • ContractDeposit: The contract that implements the trait ContractDeposit which talks to the pallet PhatTokenomic on Phala chain.
source

fn get_driver(&self, name: String) -> Self::getDriverOutput

Retrieves the driver contract id for a given name.

source

fn get_driver2(&self, name: String) -> Self::getDriver2Output

Retrieves the driver contract id and the set block number for a given name.

source

fn deploy_sidevm_to( &self, contract_id: AccountId, code_hash: Hash ) -> Self::deploySidevmToOutput

Deploys a sidevm instance attached to a contract. Must be called by an administrator.

source

fn stop_sidevm_at(&self, contract_id: AccountId) -> Self::stopSidevmAtOutput

Stops a sidevm instance attached to a contract. Must be called by an administrator.

source

fn set_hook( &mut self, hook: HookPoint, contract_id: AccountId, selector: u32, gas_limit: u64 ) -> Self::setHookOutput

Sets a block hook for a contract. Must be called by an administrator. Note: This feature is deprecated and will be removed in the future.

source

fn set_contract_weight( &self, contract_id: AccountId, weight: u32 ) -> Self::setContractWeightOutput

Sets the contract weight for query requests and sidevm scheduling. A higher weight allows the contract to access more resources.

source

fn total_balance_of(&self, account: AccountId) -> Self::totalBalanceOfOutput

Returns the total balance of a given account.

source

fn free_balance_of(&self, account: AccountId) -> Self::freeBalanceOfOutput

Returns the free balance of a given account.

source

fn upgrade_system_contract(&mut self) -> Self::upgradeSystemContractOutput

Upgrades the system contract to the latest version.

source

fn do_upgrade(&self, from_version: VersionTuple) -> Self::doUpgradeOutput

Performs upgrade condition checks and state migration if necessary. Called by the system contract on the new code version during an upgrade process.

source

fn upgrade_runtime(&mut self, version: (u32, u32)) -> Self::upgradeRuntimeOutput

Upgrades the contract runtime.

source

fn code_exists( &self, code_hash: Hash, code_type: CodeType ) -> Self::codeExistsOutput

Checks if the code with a given hash is already uploaded to the cluster.

source

fn code_hash(&self, account: AccountId) -> Self::codeHashOutput

Retrieves the current code hash of a given contract.

source

fn driver_history(&self, name: String) -> Self::driverHistoryOutput

Retrieves the history of a given driver, returning a vector of (block_number, contract_id) tuples where the block number is the block number when the driver is set.

source

fn current_event_chain_head(&self) -> Self::currentEventChainHeadOutput

Get current event chain head info

Returns (next event block number, last event block hash)

source

fn deploy_sidevm_to_workers( &self, contract_id: AccountId, code_hash: Hash, workers: Vec<WorkerId>, config: SidevmConfig ) -> Self::deploySidevmToWorkersOutput

Deploys a sidevm instance attached to a contract on selected workers. Must be called by an administrator.

source

fn set_sidevm_deadline( &self, contract_id: AccountId, run_until: BlockNumber ) -> Self::setSidevmDeadlineOutput

Sets a deadline for sidevm instances attached to a contract on selected workers. Must be called by an administrator.

Implementations on Foreign Types§

source§

impl<E> System for TraitDefinitionRegistry<E>
where E: Environment,

source§

fn version(&self) -> Self::versionOutput

Returns the system contract version, indicating its API capabilities.

§Example
use pink::system::SystemRef;
let (major, minor, patch) = SystemRef::instance().version();
source§

fn grant_admin(&mut self, __ink_binding_0: AccountId) -> Self::grantAdminOutput

Grants the administrator role to an address. Administrator contracts can set drivers, deploy sidevm, etc.

Must be called by the cluster owner.

source§

fn is_admin(&self, __ink_binding_0: AccountId) -> Self::isAdminOutput

Checks if an address is an administrator.

source§

fn set_driver( &mut self, __ink_binding_0: String, __ink_binding_1: AccountId ) -> Self::setDriverOutput

Marks a contract as a driver for a given name, retrievable via get_driver or get_driver2. The caller must be the cluster owner or an administrator. Any valid string can be a name. There are predefined names used by the Phat Contract system.

There are some predefined names that are used by the Phat Contract system:

  • PinkLogger: The contract that with a sidevm instance that collect the logs and events emitted by the ink! contracts in current cluster.
  • ContractDeposit: The contract that implements the trait ContractDeposit which talks to the pallet PhatTokenomic on Phala chain.
source§

fn get_driver(&self, __ink_binding_0: String) -> Self::getDriverOutput

Retrieves the driver contract id for a given name.

source§

fn get_driver2(&self, __ink_binding_0: String) -> Self::getDriver2Output

Retrieves the driver contract id and the set block number for a given name.

source§

fn deploy_sidevm_to( &self, __ink_binding_0: AccountId, __ink_binding_1: Hash ) -> Self::deploySidevmToOutput

Deploys a sidevm instance attached to a contract. Must be called by an administrator.

source§

fn stop_sidevm_at(&self, __ink_binding_0: AccountId) -> Self::stopSidevmAtOutput

Stops a sidevm instance attached to a contract. Must be called by an administrator.

source§

fn set_hook( &mut self, __ink_binding_0: HookPoint, __ink_binding_1: AccountId, __ink_binding_2: u32, __ink_binding_3: u64 ) -> Self::setHookOutput

Sets a block hook for a contract. Must be called by an administrator. Note: This feature is deprecated and will be removed in the future.

source§

fn set_contract_weight( &self, __ink_binding_0: AccountId, __ink_binding_1: u32 ) -> Self::setContractWeightOutput

Sets the contract weight for query requests and sidevm scheduling. A higher weight allows the contract to access more resources.

source§

fn total_balance_of( &self, __ink_binding_0: AccountId ) -> Self::totalBalanceOfOutput

Returns the total balance of a given account.

source§

fn free_balance_of( &self, __ink_binding_0: AccountId ) -> Self::freeBalanceOfOutput

Returns the free balance of a given account.

source§

fn upgrade_system_contract(&mut self) -> Self::upgradeSystemContractOutput

Upgrades the system contract to the latest version.

source§

fn do_upgrade(&self, __ink_binding_0: VersionTuple) -> Self::doUpgradeOutput

Performs upgrade condition checks and state migration if necessary. Called by the system contract on the new code version during an upgrade process.

source§

fn upgrade_runtime( &mut self, __ink_binding_0: (u32, u32) ) -> Self::upgradeRuntimeOutput

Upgrades the contract runtime.

source§

fn code_exists( &self, __ink_binding_0: Hash, __ink_binding_1: CodeType ) -> Self::codeExistsOutput

Checks if the code with a given hash is already uploaded to the cluster.

source§

fn code_hash(&self, __ink_binding_0: AccountId) -> Self::codeHashOutput

Retrieves the current code hash of a given contract.

source§

fn driver_history(&self, __ink_binding_0: String) -> Self::driverHistoryOutput

Retrieves the history of a given driver, returning a vector of (block_number, contract_id) tuples where the block number is the block number when the driver is set.

source§

fn current_event_chain_head(&self) -> Self::currentEventChainHeadOutput

Get current event chain head info

Returns (next event block number, last event block hash)

source§

fn deploy_sidevm_to_workers( &self, __ink_binding_0: AccountId, __ink_binding_1: Hash, __ink_binding_2: Vec<WorkerId>, __ink_binding_3: SidevmConfig ) -> Self::deploySidevmToWorkersOutput

Deploys a sidevm instance attached to a contract on selected workers. Must be called by an administrator.

source§

fn set_sidevm_deadline( &self, __ink_binding_0: AccountId, __ink_binding_1: BlockNumber ) -> Self::setSidevmDeadlineOutput

Sets a deadline for sidevm instances attached to a contract on selected workers. Must be called by an administrator.

§

type versionOutput = (u16, u16, u16)

§

type grantAdminOutput = Result<(), Error>

§

type isAdminOutput = bool

§

type setDriverOutput = Result<(), Error>

§

type getDriverOutput = Option<<PinkEnvironment as Environment>::AccountId>

§

type getDriver2Output = Option<(<PinkEnvironment as Environment>::BlockNumber, <PinkEnvironment as Environment>::AccountId)>

§

type deploySidevmToOutput = Result<(), Error>

§

type stopSidevmAtOutput = Result<(), Error>

§

type setHookOutput = Result<(), Error>

§

type setContractWeightOutput = Result<(), Error>

§

type totalBalanceOfOutput = <PinkEnvironment as Environment>::Balance

§

type freeBalanceOfOutput = <PinkEnvironment as Environment>::Balance

§

type upgradeSystemContractOutput = Result<(), Error>

§

type doUpgradeOutput = Result<(), Error>

§

type upgradeRuntimeOutput = Result<(), Error>

§

type codeExistsOutput = bool

§

type codeHashOutput = Option<Hash>

§

type driverHistoryOutput = Option<Vec<(<PinkEnvironment as Environment>::BlockNumber, <PinkEnvironment as Environment>::AccountId)>>

§

type currentEventChainHeadOutput = (u64, [u8; 32])

§

type deploySidevmToWorkersOutput = Result<(), Error>

§

type setSidevmDeadlineOutput = Result<(), Error>

Implementors§