Skip to content

Commit d2f9e64

Browse files
authored
feat: add view function for mint precompile allowlist (#67)
1 parent 2abaac7 commit d2f9e64

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

crates/ev-precompiles/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface INativeToken {
2626
function burn(address from, uint256 amount) external;
2727
function addToAllowList(address account) external;
2828
function removeFromAllowList(address account) external;
29+
function allowlist(address account) external view returns (bool);
2930
}
3031
```
3132

crates/ev-precompiles/src/mint.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Mint precompile
22

3-
use alloy::{sol, sol_types::SolInterface};
3+
use alloy::{
4+
sol,
5+
sol_types::{SolInterface, SolValue},
6+
};
47
use alloy_evm::{
58
precompiles::{Precompile, PrecompileInput},
69
revm::precompile::{PrecompileError, PrecompileId, PrecompileResult},
@@ -16,6 +19,7 @@ sol! {
1619
function burn(address from, uint256 amount) external;
1720
function addToAllowList(address account) external;
1821
function removeFromAllowList(address account) external;
22+
function allowlist(address account) external view returns (bool);
1923
}
2024
}
2125

@@ -232,6 +236,11 @@ impl Precompile for MintPrecompile {
232236
Self::set_allowlisted(internals, call.account, false)?;
233237
Ok(PrecompileOutput::new(0, Bytes::new()))
234238
}
239+
INativeToken::INativeTokenCalls::allowlist(call) => {
240+
let is_allowed = Self::is_allowlisted(internals, call.account)?;
241+
let result = is_allowed.abi_encode();
242+
Ok(PrecompileOutput::new(0, result.into()))
243+
}
235244
}
236245
}
237246

docs/adr/ADR-0002-native-minting-precompile.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ interface INativeToken {
4949
function burn(address from, uint256 amount) external;
5050
function addToAllowList(address account) external;
5151
function removeFromAllowList(address account) external;
52+
function allowlist(address account) external view returns (bool);
5253
}
5354
```
5455

0 commit comments

Comments
 (0)