Skip to content
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
89 changes: 0 additions & 89 deletions precompile/allowlist/allowlisttest/bindings/AllowList.sol

This file was deleted.

57 changes: 52 additions & 5 deletions precompile/allowlist/allowlisttest/bindings/AllowListTest.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,60 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import "./IAllowList.sol";
import "./AllowList.sol";
import "precompile/allowlist/IAllowList.sol";

contract AllowListTest is AllowList {
// Precompiled Allow List Contract Address
constructor(address precompileAddr) AllowList(precompileAddr) {}
contract AllowListTest {
IAllowList private allowList;

uint256 constant STATUS_NONE = 0;
uint256 constant STATUS_ENABLED = 1;
uint256 constant STATUS_ADMIN = 2;
uint256 constant STATUS_MANAGER = 3;

constructor(address precompileAddr) {
allowList = IAllowList(precompileAddr);
}

function setAdmin(address addr) external {
allowList.setAdmin(addr);
}

function setEnabled(address addr) external {
allowList.setEnabled(addr);
}

function setManager(address addr) external {
allowList.setManager(addr);
}

function setNone(address addr) external {
allowList.setNone(addr);
}

function readAllowList(address addr) external view returns (uint256) {
return allowList.readAllowList(addr);
}

// Helper functions used by tests
function isAdmin(address addr) public view returns (bool) {
return allowList.readAllowList(addr) == STATUS_ADMIN;
}

function isManager(address addr) public view returns (bool) {
return allowList.readAllowList(addr) == STATUS_MANAGER;
}

function isEnabled(address addr) public view returns (bool) {
// Returns true if address has any role (not NONE)
return allowList.readAllowList(addr) != STATUS_NONE;
}

function revoke(address addr) public {
require(msg.sender != addr, "cannot revoke own role");
allowList.setNone(addr);
}

// Used by deployerallowlist tests to verify contract deployment permissions
function deployContract() public {
new Example();
}
Expand Down
2 changes: 1 addition & 1 deletion precompile/allowlist/allowlisttest/bindings/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package bindings

// Step 1: Compile Solidity contracts to generate ABI and bin files
//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../ --evm-version cancun AllowListTest.sol
//go:generate solc-v0.8.30 -o artifacts --overwrite --abi --bin --base-path . precompile/=../../../ --evm-version cancun AllowListTest.sol
// Step 2: Generate Go bindings from the compiled artifacts
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type IAllowList --abi artifacts/IAllowList.abi --bin artifacts/IAllowList.bin --out gen_allowlist_binding.go
//go:generate go run github.com/ava-labs/libevm/cmd/abigen --pkg bindings --type AllowListTest --abi artifacts/AllowListTest.abi --bin artifacts/AllowListTest.bin --out gen_allowlisttest_binding.go
Expand Down
Loading