Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port proxy precompile from Moonbeam #47

Merged
merged 8 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ evm = { version = "0.41.1", default-features = false }
pallet-evm-precompile-balances-erc20 = { path = "precompiles/balances-erc20", default-features = false }
pallet-evm-precompile-batch = { path = "precompiles/batch", default-features = false }
pallet-evm-precompile-call-permit = { path = "precompiles/call-permit", default-features = false }
pallet-evm-precompile-proxy = { path = "precompiles/proxy", default-features = false }
pallet-evm-precompile-xcm-utils = { path = "precompiles/xcm-utils", default-features = false }
async-backing-primitives = { path = "primitives/async-backing", default-features = false }
pallet-author-inherent = { path = "pallets/author-inherent", default-features = false }
Expand Down
57 changes: 57 additions & 0 deletions precompiles/proxy/Cargo.toml
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",
]
86 changes: 86 additions & 0 deletions precompiles/proxy/Proxy.sol
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);
}
Loading
Loading