- core: AddressBook registry, Roles lib, ProofChainAccess base, Pauser - modules: provenance, payments/treasury, identity, reputation, finance/RWA, insurance, disputes+governance, esg/tokenization, marketplace, rewards - @proofchain/api: 33 routers + event indexer (Supabase) - web: 37 pages incl landing, explorer, finance, governance, esg, marketplace - 704 forge tests + 449 vitest tests green; 61 ABIs exported Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
1.3 KiB
Solidity
41 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.24;
|
|
|
|
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
|
|
|
/// @notice Malicious ERC20 that re-enters a target contract on `transfer` (the outbound leg of a
|
|
/// withdrawal/unstake) to prove the reputation module's `nonReentrant` guards hold.
|
|
contract ReenterERC20 is ERC20 {
|
|
address public target;
|
|
bytes public payload;
|
|
bool public armed;
|
|
|
|
constructor() ERC20("Reenter", "REEN") { }
|
|
|
|
function mint(address to, uint256 amount) external {
|
|
_mint(to, amount);
|
|
}
|
|
|
|
/// @param target_ Contract to re-enter.
|
|
/// @param payload_ ABI-encoded call to replay during the transfer.
|
|
function arm(address target_, bytes calldata payload_) external {
|
|
target = target_;
|
|
payload = payload_;
|
|
armed = true;
|
|
}
|
|
|
|
function transfer(address to, uint256 value) public override returns (bool) {
|
|
if (armed) {
|
|
armed = false; // one-shot to avoid unbounded recursion if the guard were absent
|
|
(bool ok, bytes memory ret) = target.call(payload);
|
|
// Bubble up the revert so tests can assert the reentrancy guard fired.
|
|
if (!ok) {
|
|
assembly {
|
|
revert(add(ret, 0x20), mload(ret))
|
|
}
|
|
}
|
|
}
|
|
return super.transfer(to, value);
|
|
}
|
|
}
|