mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-23 17:28:23 +00:00
## Summary - Fixed `ProxyType` enum in the Solidity Proxy precompile interface to match the runtime definition - Removed non-existent `AuthorMapping` variant - Added missing `SudoOnly` variant ## Problem The Solidity interface in `Proxy.sol` had incorrect `ProxyType` enum values that didn't match the runtime definition: | Index | Runtime (Correct) | Solidity (Was) | |-------|------------------|----------------| | 0 | Any | Any | | 1 | NonTransfer | NonTransfer | | 2 | Governance | Governance | | 3 | Staking | Staking | | 4 | CancelProxy | CancelProxy | | 5 | Balances | Balances | | 6 | **IdentityJudgement** | **AuthorMapping** ❌ | | 7 | **SudoOnly** | **IdentityJudgement** ❌ | This mismatch would cause EVM users calling the Proxy precompile with `IdentityJudgement` (index 7 in Solidity) to actually get `SudoOnly` behavior, and `AuthorMapping` (index 6) would fail to decode entirely since it doesn't exist in the runtime. ## Solution Updated the Solidity enum to match the runtime: ```solidity enum ProxyType { Any, NonTransfer, Governance, Staking, CancelProxy, Balances, IdentityJudgement, SudoOnly } ``` ## ⚠️ Breaking Changes ⚠️ - **`ProxyType.AuthorMapping` removed**: This variant never existed in the runtime and would fail to decode. - **`ProxyType.IdentityJudgement` index changed**: Moved from index 7 to index 6. Solidity code using `ProxyType.IdentityJudgement` will now work correctly (previously it mapped to `SudoOnly` in the runtime) - **`ProxyType.SudoOnly` added**: New variant at index 7 for proxies that can only execute Sudo pallet calls ## Test plan - [x] Proxy precompile tests pass (32/32) - [x] Mainnet runtime proxy tests pass (22/22) - [x] Governance proxy tests pass (6/6) - [x] Verified `InstanceFilter<RuntimeCall>` implementation handles all 8 variants correctly - [x] Verified `EvmProxyCallFilter` implementation handles all 8 variants correctly Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
76 lines
3.5 KiB
Solidity
76 lines
3.5 KiB
Solidity
// SPDX-License-Identifier: GPL-3.0-only
|
|
pragma solidity >=0.8.3;
|
|
|
|
/// @dev The Proxy contract's address.
|
|
address constant PROXY_ADDRESS = 0x000000000000000000000000000000000000080b;
|
|
|
|
/// @dev The Proxy contract's instance.
|
|
Proxy constant PROXY_CONTRACT = Proxy(PROXY_ADDRESS);
|
|
|
|
/// @author The Moonbeam Team
|
|
/// @title Pallet Proxy Interface
|
|
/// @title The interface through which solidity contracts will interact with the Proxy pallet
|
|
/// @custom:address 0x000000000000000000000000000000000000080b
|
|
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,
|
|
IdentityJudgement,
|
|
SudoOnly
|
|
}
|
|
|
|
/// @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);
|
|
}
|