precompile_utils/lib.rs
1// This file is part of Frontier.
2
3// Copyright (c) Moonsong Labs.
4// Copyright (C) Parity Technologies (UK) Ltd.
5// SPDX-License-Identifier: Apache-2.0
6
7// Licensed under the Apache License, Version 2.0 (the "License");
8// you may not use this file except in compliance with the License.
9// You may obtain a copy of the License at
10//
11// http://www.apache.org/licenses/LICENSE-2.0
12//
13// Unless required by applicable law or agreed to in writing, software
14// distributed under the License is distributed on an "AS IS" BASIS,
15// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16// See the License for the specific language governing permissions and
17// limitations under the License.
18
19#![cfg_attr(not(feature = "std"), no_std)]
20
21extern crate alloc;
22
23// Allows to use inside this crate `solidity::Codec` derive macro,which depends on
24// `precompile_utils` being in the list of imported crates.
25extern crate self as precompile_utils;
26
27#[doc(hidden)]
28pub mod __alloc {
29 pub use ::alloc::*;
30}
31
32pub mod evm;
33pub mod precompile_set;
34pub mod substrate;
35
36pub mod solidity;
37
38#[cfg(feature = "testing")]
39pub mod testing;
40
41pub use fp_evm::Precompile;
42use fp_evm::PrecompileFailure;
43pub use precompile_utils_macro::{keccak256, precompile, precompile_name_from_address};
44
45/// Alias for Result returning an EVM precompile error.
46pub type EvmResult<T = ()> = Result<T, PrecompileFailure>;
47
48pub mod prelude {
49 pub use {
50 crate::{
51 evm::{
52 handle::PrecompileHandleExt,
53 logs::{log0, log1, log2, log3, log4, LogExt},
54 },
55 precompile_set::DiscriminantResult,
56 solidity::{
57 // We export solidity itself to encourage using `solidity::Codec` to avoid confusion
58 // with parity_scale_codec,
59 self,
60 codec::{
61 Address,
62 BoundedBytes,
63 BoundedString,
64 BoundedVec,
65 // Allow usage of Codec methods while not exporting the name directly.
66 Codec as _,
67 Convert,
68 UnboundedBytes,
69 UnboundedString,
70 },
71 revert::{
72 revert, BacktraceExt, InjectBacktrace, MayRevert, Revert, RevertExt,
73 RevertReason,
74 },
75 },
76 substrate::{RuntimeHelper, TryDispatchError},
77 EvmResult,
78 },
79 alloc::string::String,
80 pallet_evm::{PrecompileHandle, PrecompileOutput},
81 precompile_utils_macro::{keccak256, precompile},
82 };
83}