pallet_revive_uapi/precompiles/system.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Information around the `System` pre-compile.
19
20#[cfg(feature = "precompiles-sol-interfaces")]
21use alloy_core::sol;
22
23/// Address for the System pre-compile.
24pub const SYSTEM_PRECOMPILE_ADDR: [u8; 20] =
25 hex_literal::hex!("0000000000000000000000000000000000000900");
26
27#[cfg(feature = "precompiles-sol-interfaces")]
28sol! {
29 interface ISystem {
30 /// Computes the BLAKE2 256-bit hash on the given input.
31 function hashBlake256(bytes memory input) external pure returns (bytes32 digest);
32
33 /// Computes the BLAKE2 128-bit hash on the given input.
34 function hashBlake128(bytes memory input) external pure returns (bytes32 digest);
35
36 /// Retrieve the account id for a specified `H160` address.
37 ///
38 /// Calling this function on a native `H160` chain (`type AccountId = H160`)
39 /// does not make sense, as it would just return the `address` that it was
40 /// called with.
41 ///
42 /// # Note
43 ///
44 /// If no mapping exists for `addr`, the fallback account id will be returned.
45 function toAccountId(address input) external view returns (bytes memory account_id);
46
47 /// Checks whether the caller of the contract calling this function is the origin
48 /// of the whole call stack.
49 function callerIsOrigin() external view returns (bool);
50
51 /// Checks whether the caller of the contract calling this function is root.
52 ///
53 /// Note that only the origin of the call stack can be root. Hence this
54 /// function returning `true` implies that the contract is being called by the origin.
55 ///
56 /// A return value of `true` indicates that this contract is being called by a root origin,
57 /// and `false` indicates that the caller is a signed origin.
58 function callerIsRoot() external view returns (bool);
59
60 /// Returns the minimum balance that is required for creating an account
61 /// (the existential deposit).
62 function minimumBalance() external view returns (uint);
63
64 /// Returns the code hash of the caller.
65 function ownCodeHash() external view returns (bytes32);
66
67 /// Returns the amount of `Weight` left.
68 function weightLeft() external view returns (uint64 refTime, uint64 proofSize);
69 }
70}