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
32 changes: 0 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@ permissions:
contents: read

jobs:
solhint:
name: Run solhint
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.1
- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # pin@v6.3.0
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Install dependencies
run: yarn install --frozen-lockfile --network-concurrency 1
- name: Run solhint
run: yarn run lint

forge-test:
name: Run Forge Tests
runs-on: ubuntu-latest
Expand Down Expand Up @@ -85,22 +69,6 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.1
- run: sh readmecheck.sh

hardhat-legacy:
name: Run Hardhat Tests
runs-on: ubuntu-latest
steps:
- run: |
echo "Hardhat was removed in SDK v3. See README and MIGRATION.md."
echo "This job exists only to satisfy legacy branch protection on PRs targeting main."

eslint-legacy:
name: Run eslint
runs-on: ubuntu-latest
steps:
- run: |
echo "ESLint is not part of the v3 toolchain (solhint covers Solidity)."
echo "This job exists only to satisfy legacy branch protection on PRs targeting main."

slither:
name: Run slither
runs-on: ubuntu-latest
Expand Down
53 changes: 0 additions & 53 deletions .solhint.json

This file was deleted.

1 change: 0 additions & 1 deletion .solhintignore

This file was deleted.

12 changes: 3 additions & 9 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@ forge install
sudo pip3 install slither-analyzer
```

## Build and Test
## Build, Test, and Lint

To build and test the contracts:
To build, test, and lint the contracts:

```
forge test -vvv
```

## Solidity Linter

To execute solhint:

```
yarn run solhint contracts/**/*.sol
```
## Solidity Formatter

To format Solidity (same as CI):

Expand Down
1 change: 0 additions & 1 deletion contracts/access/IERC173.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//SPDX-License-Identifier: Apache 2.0
// solhint-disable compiler-version
pragma solidity ^0.8.0;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/access/IMintingAccessControl.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <0.8.29;

Expand Down
3 changes: 2 additions & 1 deletion contracts/access/MintingAccessControl.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <0.8.29;

import {AccessControlEnumerable} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

abstract contract MintingAccessControl is AccessControlEnumerable {
/// @notice Role to mint tokens
// forge-lint: disable-next-line(unsafe-typecast)
bytes32 public constant MINTER_ROLE = bytes32("MINTER_ROLE");

/**
Expand Down
2 changes: 1 addition & 1 deletion contracts/allowlist/IOperatorAllowlist.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <0.8.29;

Expand Down
3 changes: 1 addition & 2 deletions contracts/allowlist/IWalletProxy.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <0.8.29;

// Interface to retrieve the implementation stored inside the Proxy contract
/// Interface for Passport Wallet's proxy contract.
interface IWalletProxy {
// Returns the current implementation address used by the proxy contract
// solhint-disable-next-line func-name-mixedcase
function PROXY_getImplementation() external view returns (address);
}
41 changes: 15 additions & 26 deletions contracts/allowlist/OperatorAllowlistEnforced.sol
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
// Copyright Immutable Pty Ltd 2018 - 2023
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
// slither-disable-start calls-loop
pragma solidity >=0.8.19 <0.8.29;

// Allowlist Registry
import {IOperatorAllowlist} from "./IOperatorAllowlist.sol";

// Interface
import {IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

// Errors
import {OperatorAllowlistEnforcementErrors} from "../errors/Errors.sol";

/*
OperatorAllowlistEnforced is an abstract contract that token contracts can inherit in order to set the
address of the OperatorAllowlist registry that it will interface with, so that the token contract may
enable the restriction of approvals and transfers to allowlisted users.
OperatorAllowlistEnforced is not designed to be upgradeable or extended.
*/

abstract contract OperatorAllowlistEnforced is OperatorAllowlistEnforcementErrors {
/// ===== State Variables =====

/// @notice Interface that implements the `IOperatorAllowlist` interface
IOperatorAllowlist public operatorAllowlist;
// Disable this code size warning as there is no plan to change this logic.
// forge-lint: disable-start(unwrapped-modifier-logic)

/// ===== Events =====
/**
* @notice OperatorAllowlistEnforced is an abstract contract that token contracts can inherit in order to set the
* address of the OperatorAllowlist registry that it will interface with, so that the token contract may
* enable the restriction of approvals and transfers to allowlisted users.
* OperatorAllowlistEnforced is not designed to be upgradeable or extended.
*/

abstract contract OperatorAllowlistEnforced is OperatorAllowlistEnforcementErrors {
/// @notice Emitted whenever the transfer Allowlist registry is updated
event OperatorAllowlistRegistryUpdated(address oldRegistry, address newRegistry);

/// ===== Modifiers =====

/**
* @notice Internal function to validate an approval, according to whether the target is an EOA or Allowlisted
* @param targetApproval the address of the approval target to be validated
Expand Down Expand Up @@ -63,10 +52,7 @@ abstract contract OperatorAllowlistEnforced is OperatorAllowlistEnforcementError
// Check for:
// 1. caller is an EOA
// 2. caller is Allowlisted or is the calling address bytecode is Allowlisted
if (
msg.sender != tx.origin && // solhint-disable-line avoid-tx-origin
!operatorAllowlist.isAllowlisted(msg.sender)
) {
if (msg.sender != tx.origin && !operatorAllowlist.isAllowlisted(msg.sender)) {
revert CallerNotInAllowlist(msg.sender);
}

Expand All @@ -86,7 +72,8 @@ abstract contract OperatorAllowlistEnforced is OperatorAllowlistEnforcementError
_;
}

/// ===== External functions =====
/// @notice Interface that implements the `IOperatorAllowlist` interface
IOperatorAllowlist public operatorAllowlist;

/**
* @notice Internal function to set the operator allowlist the calling contract will interface with
Expand All @@ -101,4 +88,6 @@ abstract contract OperatorAllowlistEnforced is OperatorAllowlistEnforcementError
operatorAllowlist = IOperatorAllowlist(_operatorAllowlist);
}
}

// forge-lint: disable-end(unwrapped-modifier-logic)
// slither-disable-end calls-loop
30 changes: 16 additions & 14 deletions contracts/allowlist/OperatorAllowlistUpgradeable.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// Copyright Immutable Pty Ltd 2018 - 2024
// Copyright Immutable Pty Ltd 2018 - 2026
// SPDX-License-Identifier: Apache 2.0
pragma solidity >=0.8.19 <0.8.29;

import {UUPSUpgradeable} from "openzeppelin-contracts-upgradeable-4.9.3/proxy/utils/UUPSUpgradeable.sol";
import {AccessControlEnumerableUpgradeable} from "openzeppelin-contracts-upgradeable-4.9.3/access/AccessControlEnumerableUpgradeable.sol";
import {
AccessControlEnumerableUpgradeable
} from "openzeppelin-contracts-upgradeable-4.9.3/access/AccessControlEnumerableUpgradeable.sol";

// Introspection
import {ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";
Expand All @@ -25,7 +27,6 @@ contract OperatorAllowlistUpgradeable is
IOperatorAllowlist
{
/// ===== Events =====

/// @notice Emitted when a target address is added or removed from the Allowlist
event AddressAllowlistChanged(address indexed target, bool added);

Expand All @@ -34,9 +35,11 @@ contract OperatorAllowlistUpgradeable is
/// ===== State Variables =====

/// @notice Only REGISTRAR_ROLE can invoke white listing registration and removal
// forge-lint: disable-next-line(unsafe-typecast)
bytes32 public constant REGISTRAR_ROLE = bytes32("REGISTRAR_ROLE");

/// @notice Only UPGRADE_ROLE can upgrade the contract
// forge-lint: disable-next-line(unsafe-typecast)
bytes32 public constant UPGRADE_ROLE = bytes32("UPGRADE_ROLE");

/// @notice Mapping of Allowlisted addresses
Expand Down Expand Up @@ -99,8 +102,7 @@ contract OperatorAllowlistUpgradeable is
function addWalletToAllowlist(address walletAddr) external onlyRole(REGISTRAR_ROLE) {
// get bytecode of wallet
bytes32 codeHash;
// solhint-disable-next-line no-inline-assembly
assembly {
assembly ("memory-safe") {
codeHash := extcodehash(walletAddr)
}
bytecodeAllowlist[codeHash] = true;
Expand All @@ -119,8 +121,7 @@ contract OperatorAllowlistUpgradeable is
function removeWalletFromAllowlist(address walletAddr) external onlyRole(REGISTRAR_ROLE) {
// get bytecode of wallet
bytes32 codeHash;
// solhint-disable-next-line no-inline-assembly
assembly {
assembly ("memory-safe") {
codeHash := extcodehash(walletAddr)
}
delete bytecodeAllowlist[codeHash];
Expand All @@ -144,8 +145,7 @@ contract OperatorAllowlistUpgradeable is

// Check if caller is a Allowlisted smart contract wallet
bytes32 codeHash;
// solhint-disable-next-line no-inline-assembly
assembly {
assembly ("memory-safe") {
codeHash := extcodehash(target)
}
if (bytecodeAllowlist[codeHash]) {
Expand All @@ -162,19 +162,21 @@ contract OperatorAllowlistUpgradeable is
* @notice ERC-165 interface support
* @param interfaceId The interface identifier, which is a 4-byte selector.
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC165, AccessControlEnumerableUpgradeable) returns (bool) {
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165, AccessControlEnumerableUpgradeable)
returns (bool)
{
return interfaceId == type(IOperatorAllowlist).interfaceId || super.supportsInterface(interfaceId);
}

// Override the _authorizeUpgrade function
// solhint-disable-next-line no-empty-blocks
function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADE_ROLE) {}

/// @notice storage gap for additional variables for upgrades
// slither-disable-start unused-state
// solhint-disable-next-line var-name-mixedcase
uint256[20] private __OperatorAllowlistUpgradeableGap;
// slither-disable-end unused-state
}
Loading