pub trait Environment: Clone {
type AccountId: 'static + Codec + MaxEncodedLen + CodecAsType + Clone + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>;
type Balance: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + Into<U256> + FromLittleEndian;
type Hash: 'static + Codec + MaxEncodedLen + CodecAsType + Copy + Clone + Clear + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>;
type Timestamp: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian;
type BlockNumber: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian;
type EventRecord: 'static + Codec;
const NATIVE_TO_ETH_RATIO: u32;
// Provided method
fn native_to_eth(value: Self::Balance) -> U256 { ... }
}
Expand description
The environmental types usable by contracts defined with ink!.
The types and consts in this trait must be the same as the chain to which
the contract is deployed to. We have a mechanism in cargo-contract
that
attempts to check for type equality, but not everything can be compared.
Required Associated Constants§
Sourceconst NATIVE_TO_ETH_RATIO: u32
const NATIVE_TO_ETH_RATIO: u32
The ratio between the decimal representation of the native Balance
token
and the ETH token.
Required Associated Types§
Sourcetype AccountId: 'static + Codec + MaxEncodedLen + CodecAsType + Clone + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>
type AccountId: 'static + Codec + MaxEncodedLen + CodecAsType + Clone + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>
The account id type.
Sourcetype Balance: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + Into<U256> + FromLittleEndian
type Balance: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + Into<U256> + FromLittleEndian
The type of balances.
Sourcetype Hash: 'static + Codec + MaxEncodedLen + CodecAsType + Copy + Clone + Clear + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>
type Hash: 'static + Codec + MaxEncodedLen + CodecAsType + Copy + Clone + Clear + PartialEq + Eq + Ord + AsRef<[u8]> + AsMut<[u8]>
The type of hash.
Sourcetype Timestamp: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian
type Timestamp: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian
The type of a timestamp.
Sourcetype BlockNumber: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian
type BlockNumber: 'static + Codec + CodecAsType + Copy + Clone + PartialEq + Eq + AtLeast32BitUnsigned + FromLittleEndian
The type of block number.
Sourcetype EventRecord: 'static + Codec
type EventRecord: 'static + Codec
TODO comment
Provided Methods§
Sourcefn native_to_eth(value: Self::Balance) -> U256
fn native_to_eth(value: Self::Balance) -> U256
Converts from the generic Balance
type to the Ethereum native U256
.
§Developer Note
pallet-revive
uses both types, hence we have to convert in between them
for certain functions. Notice that precision loss might occur when converting
the other way (from U256
to Balance
).
See https://github.com/paritytech/polkadot-sdk/pull/9101 for more details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.