forked from Moonsong-Labs/moonkit
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Port proxy precompile from Moonbeam (Moonsong-Labs#47)
* Port proxy precompile from Moonbeam * cleanup * cleanup * copyright * Fix mock * asserts * warn
- Loading branch information
Showing
7 changed files
with
1,799 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
[package] | ||
name = "pallet-evm-precompile-proxy" | ||
authors = { workspace = true } | ||
description = "A Precompile to make proxy calls encoding accessible to pallet-evm" | ||
edition = "2021" | ||
version = "0.1.0" | ||
|
||
[dependencies] | ||
log = { workspace = true } | ||
num_enum = { workspace = true } | ||
|
||
# Substrate | ||
frame-support = { workspace = true } | ||
frame-system = { workspace = true } | ||
pallet-balances = { workspace = true } | ||
pallet-proxy = { workspace = true } | ||
parity-scale-codec = { workspace = true, features = [ "derive" ] } | ||
sp-core = { workspace = true } | ||
sp-runtime = { workspace = true } | ||
sp-std = { workspace = true } | ||
|
||
# Frontier | ||
evm = { workspace = true, features = [ "with-codec" ] } | ||
fp-evm = { workspace = true } | ||
pallet-evm = { workspace = true, features = [ "forbid-evm-reentrancy" ] } | ||
precompile-utils = { workspace = true } | ||
|
||
[dev-dependencies] | ||
derive_more = { workspace = true } | ||
hex-literal = { workspace = true } | ||
serde = { workspace = true } | ||
sha3 = { workspace = true } | ||
|
||
# Frontier | ||
precompile-utils = { workspace = true, features = [ "std", "testing" ] } | ||
|
||
# Substrate | ||
pallet-balances = { workspace = true, features = [ "std" ] } | ||
pallet-timestamp = { workspace = true, features = [ "std" ] } | ||
scale-info = { workspace = true, features = [ "derive", "std" ] } | ||
sp-io = { workspace = true, features = [ "std" ] } | ||
|
||
[features] | ||
default = [ "std" ] | ||
std = [ | ||
"fp-evm/std", | ||
"frame-support/std", | ||
"frame-system/std", | ||
"pallet-balances/std", | ||
"pallet-evm/std", | ||
"pallet-proxy/std", | ||
"parity-scale-codec/std", | ||
"precompile-utils/std", | ||
"sp-core/std", | ||
"sp-runtime/std", | ||
"sp-std/std", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
pragma solidity >=0.8.3; | ||
|
||
/// @author The Moonsong Labs Team | ||
/// @title Pallet Proxy Interface | ||
/// @title The interface through which solidity contracts will interact with the Proxy pallet | ||
interface Proxy { | ||
/// @dev Defines the proxy permission types. | ||
/// The values start at `0` (most permissive) and are represented as `uint8` | ||
enum ProxyType { | ||
Any, | ||
NonTransfer, | ||
Governance, | ||
Staking, | ||
CancelProxy, | ||
Balances, | ||
AuthorMapping, | ||
IdentityJudgement | ||
} | ||
|
||
/// @dev Register a proxy account for the sender that is able to make calls on its behalf | ||
/// @custom:selector 74a34dd3 | ||
/// @param delegate The account that the caller would like to make a proxy | ||
/// @param proxyType The permissions allowed for this proxy account | ||
/// @param delay The announcement period required of the initial proxy, will generally be zero | ||
function addProxy( | ||
address delegate, | ||
ProxyType proxyType, | ||
uint32 delay | ||
) external; | ||
|
||
/// @dev Removes a proxy account from the sender | ||
/// @custom:selector fef3f708 | ||
/// @param delegate The account that the caller would like to remove as a proxy | ||
/// @param proxyType The permissions currently enabled for the removed proxy account | ||
/// @param delay The announcement period required of the initial proxy, will generally be zero | ||
function removeProxy( | ||
address delegate, | ||
ProxyType proxyType, | ||
uint32 delay | ||
) external; | ||
|
||
/// @dev Unregister all proxy accounts for the sender | ||
/// @custom:selector 14a5b5fa | ||
function removeProxies() external; | ||
|
||
/// @dev Dispatch the given subcall (`callTo`, `callData`) from an account that the sender | ||
/// is authorised for through `addProxy` | ||
/// @custom:selector 0d3cff86 | ||
/// @param real The account that the proxy will make a call on behalf of | ||
/// @param callTo Recipient of the call to be made by the `real` account | ||
/// @param callData Data of the call to be made by the `real` account | ||
function proxy( | ||
address real, | ||
address callTo, | ||
bytes memory callData | ||
) external payable; | ||
|
||
/// @dev Dispatch the given subcall (`callTo`, `callData`) from an account that the sender | ||
/// is authorised for through `addProxy` | ||
/// @custom:selector 685b9d2f | ||
/// @param real The account that the proxy will make a call on behalf of | ||
/// @param forceProxyType Specify the exact proxy type to be used and checked for this call | ||
/// @param callTo Recipient of the call to be made by the `real` account | ||
/// @param callData Data of the call to be made by the `real` account | ||
function proxyForceType( | ||
address real, | ||
ProxyType forceProxyType, | ||
address callTo, | ||
bytes memory callData | ||
) external payable; | ||
|
||
/// @dev Checks if the caller has an account proxied with a given proxy type | ||
/// @custom:selector e26d38ed | ||
/// @param real The real account that maybe has a proxy | ||
/// @param delegate The account that the caller has maybe proxied | ||
/// @param proxyType The permissions allowed for the proxy | ||
/// @param delay The announcement period required of the initial proxy, will generally be zero | ||
/// @return exists True if a proxy exists, False otherwise | ||
function isProxy( | ||
address real, | ||
address delegate, | ||
ProxyType proxyType, | ||
uint32 delay | ||
) external view returns (bool exists); | ||
} |
Oops, something went wrong.