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§
sourcetype versionOutput: ImpliesReturn<VersionTuple>
type versionOutput: ImpliesReturn<VersionTuple>
Output type of the respective trait message.
sourcetype grantAdminOutput: ImpliesReturn<Result<()>>
type grantAdminOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype isAdminOutput: ImpliesReturn<bool>
type isAdminOutput: ImpliesReturn<bool>
Output type of the respective trait message.
sourcetype setDriverOutput: ImpliesReturn<Result<()>>
type setDriverOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype getDriverOutput: ImpliesReturn<Option<AccountId>>
type getDriverOutput: ImpliesReturn<Option<AccountId>>
Output type of the respective trait message.
sourcetype getDriver2Output: ImpliesReturn<Option<(BlockNumber, AccountId)>>
type getDriver2Output: ImpliesReturn<Option<(BlockNumber, AccountId)>>
Output type of the respective trait message.
sourcetype deploySidevmToOutput: ImpliesReturn<Result<()>>
type deploySidevmToOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype stopSidevmAtOutput: ImpliesReturn<Result<()>>
type stopSidevmAtOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype setHookOutput: ImpliesReturn<Result<()>>
type setHookOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype setContractWeightOutput: ImpliesReturn<Result<()>>
type setContractWeightOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype totalBalanceOfOutput: ImpliesReturn<Balance>
type totalBalanceOfOutput: ImpliesReturn<Balance>
Output type of the respective trait message.
sourcetype freeBalanceOfOutput: ImpliesReturn<Balance>
type freeBalanceOfOutput: ImpliesReturn<Balance>
Output type of the respective trait message.
sourcetype upgradeSystemContractOutput: ImpliesReturn<Result<()>>
type upgradeSystemContractOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype doUpgradeOutput: ImpliesReturn<Result<()>>
type doUpgradeOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype upgradeRuntimeOutput: ImpliesReturn<Result<()>>
type upgradeRuntimeOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype codeExistsOutput: ImpliesReturn<bool>
type codeExistsOutput: ImpliesReturn<bool>
Output type of the respective trait message.
sourcetype codeHashOutput: ImpliesReturn<Option<Hash>>
type codeHashOutput: ImpliesReturn<Option<Hash>>
Output type of the respective trait message.
sourcetype driverHistoryOutput: ImpliesReturn<Option<Vec<(BlockNumber, AccountId)>>>
type driverHistoryOutput: ImpliesReturn<Option<Vec<(BlockNumber, AccountId)>>>
Output type of the respective trait message.
sourcetype currentEventChainHeadOutput: ImpliesReturn<(u64, Hash)>
type currentEventChainHeadOutput: ImpliesReturn<(u64, Hash)>
Output type of the respective trait message.
sourcetype deploySidevmToWorkersOutput: ImpliesReturn<Result<()>>
type deploySidevmToWorkersOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
sourcetype setSidevmDeadlineOutput: ImpliesReturn<Result<()>>
type setSidevmDeadlineOutput: ImpliesReturn<Result<()>>
Output type of the respective trait message.
Required Methods§
sourcefn version(&self) -> Self::versionOutput
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();
sourcefn grant_admin(&mut self, contract_id: AccountId) -> Self::grantAdminOutput
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.
sourcefn is_admin(&self, contract_id: AccountId) -> Self::isAdminOutput
fn is_admin(&self, contract_id: AccountId) -> Self::isAdminOutput
Checks if an address is an administrator.
sourcefn set_driver(
&mut self,
name: String,
contract_id: AccountId
) -> Self::setDriverOutput
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 thetrait ContractDeposit
which talks to the pallet PhatTokenomic on Phala chain.
sourcefn get_driver(&self, name: String) -> Self::getDriverOutput
fn get_driver(&self, name: String) -> Self::getDriverOutput
Retrieves the driver contract id for a given name.
sourcefn get_driver2(&self, name: String) -> Self::getDriver2Output
fn get_driver2(&self, name: String) -> Self::getDriver2Output
Retrieves the driver contract id and the set block number for a given name.
sourcefn deploy_sidevm_to(
&self,
contract_id: AccountId,
code_hash: Hash
) -> Self::deploySidevmToOutput
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.
sourcefn stop_sidevm_at(&self, contract_id: AccountId) -> Self::stopSidevmAtOutput
fn stop_sidevm_at(&self, contract_id: AccountId) -> Self::stopSidevmAtOutput
Stops a sidevm instance attached to a contract. Must be called by an administrator.
sourcefn set_hook(
&mut self,
hook: HookPoint,
contract_id: AccountId,
selector: u32,
gas_limit: u64
) -> Self::setHookOutput
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.
sourcefn set_contract_weight(
&self,
contract_id: AccountId,
weight: u32
) -> Self::setContractWeightOutput
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.
sourcefn total_balance_of(&self, account: AccountId) -> Self::totalBalanceOfOutput
fn total_balance_of(&self, account: AccountId) -> Self::totalBalanceOfOutput
Returns the total balance of a given account.
sourcefn free_balance_of(&self, account: AccountId) -> Self::freeBalanceOfOutput
fn free_balance_of(&self, account: AccountId) -> Self::freeBalanceOfOutput
Returns the free balance of a given account.
sourcefn upgrade_system_contract(&mut self) -> Self::upgradeSystemContractOutput
fn upgrade_system_contract(&mut self) -> Self::upgradeSystemContractOutput
Upgrades the system contract to the latest version.
sourcefn do_upgrade(&self, from_version: VersionTuple) -> Self::doUpgradeOutput
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.
sourcefn upgrade_runtime(&mut self, version: (u32, u32)) -> Self::upgradeRuntimeOutput
fn upgrade_runtime(&mut self, version: (u32, u32)) -> Self::upgradeRuntimeOutput
Upgrades the contract runtime.
sourcefn code_exists(
&self,
code_hash: Hash,
code_type: CodeType
) -> Self::codeExistsOutput
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.
sourcefn code_hash(&self, account: AccountId) -> Self::codeHashOutput
fn code_hash(&self, account: AccountId) -> Self::codeHashOutput
Retrieves the current code hash of a given contract.
sourcefn driver_history(&self, name: String) -> Self::driverHistoryOutput
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.
sourcefn current_event_chain_head(&self) -> Self::currentEventChainHeadOutput
fn current_event_chain_head(&self) -> Self::currentEventChainHeadOutput
Get current event chain head info
Returns (next event block number, last event block hash)
sourcefn deploy_sidevm_to_workers(
&self,
contract_id: AccountId,
code_hash: Hash,
workers: Vec<WorkerId>,
config: SidevmConfig
) -> Self::deploySidevmToWorkersOutput
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.
sourcefn set_sidevm_deadline(
&self,
contract_id: AccountId,
run_until: BlockNumber
) -> Self::setSidevmDeadlineOutput
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,
impl<E> System for TraitDefinitionRegistry<E>where
E: Environment,
source§fn version(&self) -> Self::versionOutput
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
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
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
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 thetrait ContractDeposit
which talks to the pallet PhatTokenomic on Phala chain.
source§fn get_driver(&self, __ink_binding_0: String) -> Self::getDriverOutput
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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.