Commit 3d377974 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub

Merge branch 'develop' into jm/vsc-settings

parents 663b74d6 ddaa2c53
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
"pnpm": ">=8" "pnpm": ">=8"
}, },
"scripts": { "scripts": {
"clean": "npx nx run-many --target=clean", "clean": "pnpm recursive run clean; rm -rf node_modules packages/*/node_modules && echo 'Finished cleaning. Run `pnpm install && pnpm build` from root of repo to rebuild the repo.'",
"bindings": "nx bindings @eth-optimism/contracts-bedrock", "bindings": "nx bindings @eth-optimism/contracts-bedrock",
"build": "npx nx run-many --target=build", "build": "npx nx run-many --target=build",
"test": "npx nx run-many --target=test", "test": "npx nx run-many --target=test",
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
"test:coverage": "nyc hardhat test && nyc merge .nyc_output coverage.json", "test:coverage": "nyc hardhat test && nyc merge .nyc_output coverage.json",
"build": "tsc -p ./tsconfig.json", "build": "tsc -p ./tsconfig.json",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo", "clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"preinstall": "npx only-allow pnpm",
"lint": "pnpm lint:fix && pnpm lint:check", "lint": "pnpm lint:fix && pnpm lint:check",
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
"lint:fix": "pnpm lint:check --fix", "lint:fix": "pnpm lint:check --fix",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint", "all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint",
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo", "clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"preinstall": "npx only-allow pnpm",
"lint:check": "eslint . --max-warnings=0", "lint:check": "eslint . --max-warnings=0",
"lint:fix": "pnpm lint:check --fix", "lint:fix": "pnpm lint:check --fix",
"lint": "pnpm lint:fix && pnpm lint:check", "lint": "pnpm lint:fix && pnpm lint:check",
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
// A representation of an empty/uninitialized UID. // A representation of an empty/uninitialized UID.
...@@ -14,18 +13,14 @@ error InvalidLength(); ...@@ -14,18 +13,14 @@ error InvalidLength();
error InvalidSignature(); error InvalidSignature();
error NotFound(); error NotFound();
/** /// @dev A struct representing EIP712 signature data.
* @dev A struct representing EIP712 signature data.
*/
struct EIP712Signature { struct EIP712Signature {
uint8 v; // The recovery ID. uint8 v; // The recovery ID.
bytes32 r; // The x-coordinate of the nonce R. bytes32 r; // The x-coordinate of the nonce R.
bytes32 s; // The signature data. bytes32 s; // The signature data.
} }
/** /// @dev A struct representing a single attestation.
* @dev A struct representing a single attestation.
*/
struct Attestation { struct Attestation {
bytes32 uid; // A unique identifier of the attestation. bytes32 uid; // A unique identifier of the attestation.
bytes32 schema; // The unique identifier of the schema. bytes32 schema; // The unique identifier of the schema.
...@@ -42,26 +37,18 @@ struct Attestation { ...@@ -42,26 +37,18 @@ struct Attestation {
// Maximum upgrade forward-compatibility storage gap. // Maximum upgrade forward-compatibility storage gap.
uint32 constant MAX_GAP = 50; uint32 constant MAX_GAP = 50;
/** /// @dev A helper function to work with unchecked iterators in loops.
* @dev A helper function to work with unchecked iterators in loops. /// @param i The index to increment.
* /// @return j The incremented index.
* @param i The index to increment.
*
* @return j The incremented index.
*/
function uncheckedInc(uint256 i) pure returns (uint256 j) { function uncheckedInc(uint256 i) pure returns (uint256 j) {
unchecked { unchecked {
j = i + 1; j = i + 1;
} }
} }
/** /// @dev A helper function that converts a string to a bytes32.
* @dev A helper function that converts a string to a bytes32. /// @param str The string to convert.
* /// @return The converted bytes32.
* @param str The string to convert.
*
* @return The converted bytes32.
*/
function stringToBytes32(string memory str) pure returns (bytes32) { function stringToBytes32(string memory str) pure returns (bytes32) {
bytes32 result; bytes32 result;
...@@ -72,13 +59,9 @@ function stringToBytes32(string memory str) pure returns (bytes32) { ...@@ -72,13 +59,9 @@ function stringToBytes32(string memory str) pure returns (bytes32) {
return result; return result;
} }
/** /// @dev A helper function that converts a bytes32 to a string.
* @dev A helper function that converts a bytes32 to a string. /// @param data The bytes32 data to convert.
* /// @return The converted string.
* @param data The bytes32 data to convert.
*
* @return The converted string.
*/
function bytes32ToString(bytes32 data) pure returns (string memory) { function bytes32ToString(bytes32 data) pure returns (string memory) {
bytes memory byteArray = new bytes(32); bytes memory byteArray = new bytes(32);
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { ISchemaResolver } from "./resolver/ISchemaResolver.sol"; import { ISchemaResolver } from "./resolver/ISchemaResolver.sol";
/** /// @title A struct representing a record for a submitted schema.
* @title A struct representing a record for a submitted schema.
*/
struct SchemaRecord { struct SchemaRecord {
bytes32 uid; // The unique identifier of the schema. bytes32 uid; // The unique identifier of the schema.
ISchemaResolver resolver; // Optional schema resolver. ISchemaResolver resolver; // Optional schema resolver.
...@@ -17,31 +14,20 @@ struct SchemaRecord { ...@@ -17,31 +14,20 @@ struct SchemaRecord {
/// @title ISchemaRegistry /// @title ISchemaRegistry
/// @notice The interface of global attestation schemas for the Ethereum Attestation Service protocol. /// @notice The interface of global attestation schemas for the Ethereum Attestation Service protocol.
interface ISchemaRegistry { interface ISchemaRegistry {
/** /// @dev Emitted when a new schema has been registered
* @dev Emitted when a new schema has been registered /// @param uid The schema UID.
* /// @param registerer The address of the account used to register the schema.
* @param uid The schema UID.
* @param registerer The address of the account used to register the schema.
*/
event Registered(bytes32 indexed uid, address registerer); event Registered(bytes32 indexed uid, address registerer);
/** /// @dev Submits and reserves a new schema
* @dev Submits and reserves a new schema /// @param schema The schema data schema.
* /// @param resolver An optional schema resolver.
* @param schema The schema data schema. /// @param revocable Whether the schema allows revocations explicitly.
* @param resolver An optional schema resolver. /// @return The UID of the new schema.
* @param revocable Whether the schema allows revocations explicitly.
*
* @return The UID of the new schema.
*/
function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32); function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32);
/** /// @dev Returns an existing schema by UID
* @dev Returns an existing schema by UID /// @param uid The UID of the schema to retrieve.
* /// @return The schema data members.
* @param uid The UID of the schema to retrieve.
*
* @return The schema data members.
*/
function getSchema(bytes32 uid) external view returns (SchemaRecord memory); function getSchema(bytes32 uid) external view returns (SchemaRecord memory);
} }
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.19; pragma solidity 0.8.19;
import { Semver } from "../universal/Semver.sol"; import { Semver } from "../universal/Semver.sol";
...@@ -22,14 +21,10 @@ contract SchemaRegistry is ISchemaRegistry, Semver { ...@@ -22,14 +21,10 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
// Upgrade forward-compatibility storage gap // Upgrade forward-compatibility storage gap
uint256[MAX_GAP - 1] private __gap; uint256[MAX_GAP - 1] private __gap;
/** /// @dev Creates a new SchemaRegistry instance.
* @dev Creates a new SchemaRegistry instance.
*/
constructor() Semver(1, 0, 0) {} constructor() Semver(1, 0, 0) {}
/** /// @inheritdoc ISchemaRegistry
* @inheritdoc ISchemaRegistry
*/
function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32) { function register(string calldata schema, ISchemaResolver resolver, bool revocable) external returns (bytes32) {
SchemaRecord memory schemaRecord = SchemaRecord({ SchemaRecord memory schemaRecord = SchemaRecord({
uid: EMPTY_UID, uid: EMPTY_UID,
...@@ -51,20 +46,14 @@ contract SchemaRegistry is ISchemaRegistry, Semver { ...@@ -51,20 +46,14 @@ contract SchemaRegistry is ISchemaRegistry, Semver {
return uid; return uid;
} }
/** /// @inheritdoc ISchemaRegistry
* @inheritdoc ISchemaRegistry
*/
function getSchema(bytes32 uid) external view returns (SchemaRecord memory) { function getSchema(bytes32 uid) external view returns (SchemaRecord memory) {
return _registry[uid]; return _registry[uid];
} }
/** /// @dev Calculates a UID for a given schema.
* @dev Calculates a UID for a given schema. /// @param schemaRecord The input schema.
* /// @return schema UID.
* @param schemaRecord The input schema.
*
* @return schema UID.
*/
function _getUID(SchemaRecord memory schemaRecord) private pure returns (bytes32) { function _getUID(SchemaRecord memory schemaRecord) private pure returns (bytes32) {
return keccak256(abi.encodePacked(schemaRecord.schema, schemaRecord.resolver, schemaRecord.revocable)); return keccak256(abi.encodePacked(schemaRecord.schema, schemaRecord.resolver, schemaRecord.revocable));
} }
......
...@@ -36,59 +36,44 @@ abstract contract EIP712Verifier is EIP712 { ...@@ -36,59 +36,44 @@ abstract contract EIP712Verifier is EIP712 {
// Upgrade forward-compatibility storage gap // Upgrade forward-compatibility storage gap
uint256[MAX_GAP - 1] private __gap; uint256[MAX_GAP - 1] private __gap;
/** /// @dev Creates a new EIP712Verifier instance.
* @dev Creates a new EIP712Verifier instance. /// @param version The current major version of the signing domain
*
* @param version The current major version of the signing domain
*/
constructor(string memory name, string memory version) EIP712(name, version) { constructor(string memory name, string memory version) EIP712(name, version) {
_name = stringToBytes32(name); _name = stringToBytes32(name);
} }
/** /// @notice Returns the domain separator used in the encoding of the signatures for attest, and revoke.
* @dev Returns the domain separator used in the encoding of the signatures for attest, and revoke.
*/
function getDomainSeparator() external view returns (bytes32) { function getDomainSeparator() external view returns (bytes32) {
return _domainSeparatorV4(); return _domainSeparatorV4();
} }
/** /// @notice Returns the current nonce per-account.
* @dev Returns the current nonce per-account. /// @param account The requested account.
* /// @return The current nonce.
* @param account The requested account.
*
* @return The current nonce.
*/
function getNonce(address account) external view returns (uint256) { function getNonce(address account) external view returns (uint256) {
return _nonces[account]; return _nonces[account];
} }
/** /// @notice Returns the EIP712 type hash for the attest function.
* Returns the EIP712 type hash for the attest function. /// @return The EIP712 attest function type hash.
*/
function getAttestTypeHash() external pure returns (bytes32) { function getAttestTypeHash() external pure returns (bytes32) {
return ATTEST_TYPEHASH; return ATTEST_TYPEHASH;
} }
/** /// @notice Returns the EIP712 type hash for the revoke function.
* Returns the EIP712 type hash for the revoke function. /// @return hash_ The EIP712 revoke function type hash.
*/
function getRevokeTypeHash() external pure returns (bytes32) { function getRevokeTypeHash() external pure returns (bytes32) {
return REVOKE_TYPEHASH; return REVOKE_TYPEHASH;
} }
/** /// @notice Returns the EIP712 name.
* Returns the EIP712 name. /// @return The EIP712 name.
*/
function getName() external view returns (string memory) { function getName() external view returns (string memory) {
return bytes32ToString(_name); return bytes32ToString(_name);
} }
/** /// @notice Verifies delegated attestation request.
* @dev Verifies delegated attestation request. /// @param request The arguments of the delegated attestation request.
*
* @param request The arguments of the delegated attestation request.
*/
function _verifyAttest(DelegatedAttestationRequest memory request) internal { function _verifyAttest(DelegatedAttestationRequest memory request) internal {
AttestationRequestData memory data = request.data; AttestationRequestData memory data = request.data;
EIP712Signature memory signature = request.signature; EIP712Signature memory signature = request.signature;
...@@ -118,11 +103,8 @@ abstract contract EIP712Verifier is EIP712 { ...@@ -118,11 +103,8 @@ abstract contract EIP712Verifier is EIP712 {
} }
} }
/** /// @notice Verifies delegated revocation request.
* @dev Verifies delegated revocation request. /// @param request The arguments of the delegated revocation request.
*
* @param request The arguments of the delegated revocation request.
*/
function _verifyRevoke(DelegatedRevocationRequest memory request) internal { function _verifyRevoke(DelegatedRevocationRequest memory request) internal {
RevocationRequestData memory data = request.data; RevocationRequestData memory data = request.data;
EIP712Signature memory signature = request.signature; EIP712Signature memory signature = request.signature;
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import { Attestation } from "../Common.sol"; import { Attestation } from "../Common.sol";
...@@ -7,50 +6,33 @@ import { Attestation } from "../Common.sol"; ...@@ -7,50 +6,33 @@ import { Attestation } from "../Common.sol";
/// @title ISchemaResolver /// @title ISchemaResolver
/// @notice The interface of an optional schema resolver. /// @notice The interface of an optional schema resolver.
interface ISchemaResolver { interface ISchemaResolver {
/** /// @notice Checks if the resolve can be sent ETH.
* @dev Returns whether the resolver supports ETH transfers. /// @return Whether the resolver supports ETH transfers.
*/
function isPayable() external pure returns (bool); function isPayable() external pure returns (bool);
/** /// @notice Processes an attestation and verifies whether it's valid.
* @dev Processes an attestation and verifies whether it's valid. /// @param attestation The new attestation.
* /// @return Whether the attestation is valid.
* @param attestation The new attestation.
*
* @return Whether the attestation is valid.
*/
function attest(Attestation calldata attestation) external payable returns (bool); function attest(Attestation calldata attestation) external payable returns (bool);
/** /// @notice Processes multiple attestations and verifies whether they are valid.
* @dev Processes multiple attestations and verifies whether they are valid. /// @param attestations The new attestations.
* /// @param values Explicit ETH amounts which were sent with each attestation.
* @param attestations The new attestations. /// @return Whether all the attestations are valid.
* @param values Explicit ETH amounts which were sent with each attestation.
*
* @return Whether all the attestations are valid.
*/
function multiAttest( function multiAttest(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
) external payable returns (bool); ) external payable returns (bool);
/** /// @notice Processes an attestation revocation and verifies if it can be revoked.
* @dev Processes an attestation revocation and verifies if it can be revoked. /// @param attestation The existing attestation to be revoked.
* /// @return Whether the attestation can be revoked.
* @param attestation The existing attestation to be revoked.
*
* @return Whether the attestation can be revoked.
*/
function revoke(Attestation calldata attestation) external payable returns (bool); function revoke(Attestation calldata attestation) external payable returns (bool);
/** /// @notice Processes revocation of multiple attestation and verifies they can be revoked.
* @dev Processes revocation of multiple attestation and verifies they can be revoked. /// @param attestations The existing attestations to be revoked.
* /// @param values Explicit ETH amounts which were sent with each revocation.
* @param attestations The existing attestations to be revoked. /// @return Whether the attestations can be revoked.
* @param values Explicit ETH amounts which were sent with each revocation.
*
* @return Whether the attestations can be revoked.
*/
function multiRevoke( function multiRevoke(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
......
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
pragma solidity 0.8.19; pragma solidity 0.8.19;
import { Semver } from "../../universal/Semver.sol"; import { Semver } from "../../universal/Semver.sol";
...@@ -19,11 +18,8 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -19,11 +18,8 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
// The global EAS contract. // The global EAS contract.
IEAS internal immutable _eas; IEAS internal immutable _eas;
/** /// @dev Creates a new resolver.
* @dev Creates a new resolver. /// @param eas The address of the global EAS contract.
*
* @param eas The address of the global EAS contract.
*/
constructor(IEAS eas) Semver(1, 0, 0) { constructor(IEAS eas) Semver(1, 0, 0) {
if (address(eas) == address(0)) { if (address(eas) == address(0)) {
revert InvalidEAS(); revert InvalidEAS();
...@@ -32,41 +28,31 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -32,41 +28,31 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
_eas = eas; _eas = eas;
} }
/** /// @dev Ensures that only the EAS contract can make this call.
* @dev Ensures that only the EAS contract can make this call.
*/
modifier onlyEAS() { modifier onlyEAS() {
_onlyEAS(); _onlyEAS();
_; _;
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function isPayable() public pure virtual returns (bool) { function isPayable() public pure virtual returns (bool) {
return false; return false;
} }
/** /// @dev ETH callback.
* @dev ETH callback.
*/
receive() external payable virtual { receive() external payable virtual {
if (!isPayable()) { if (!isPayable()) {
revert NotPayable(); revert NotPayable();
} }
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function attest(Attestation calldata attestation) external payable onlyEAS returns (bool) { function attest(Attestation calldata attestation) external payable onlyEAS returns (bool) {
return onAttest(attestation, msg.value); return onAttest(attestation, msg.value);
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function multiAttest( function multiAttest(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
...@@ -100,16 +86,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -100,16 +86,12 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
return true; return true;
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function revoke(Attestation calldata attestation) external payable onlyEAS returns (bool) { function revoke(Attestation calldata attestation) external payable onlyEAS returns (bool) {
return onRevoke(attestation, msg.value); return onRevoke(attestation, msg.value);
} }
/** /// @inheritdoc ISchemaResolver
* @inheritdoc ISchemaResolver
*/
function multiRevoke( function multiRevoke(
Attestation[] calldata attestations, Attestation[] calldata attestations,
uint256[] calldata values uint256[] calldata values
...@@ -143,35 +125,25 @@ abstract contract SchemaResolver is ISchemaResolver, Semver { ...@@ -143,35 +125,25 @@ abstract contract SchemaResolver is ISchemaResolver, Semver {
return true; return true;
} }
/** /// @notice A resolver callback that should be implemented by child contracts.
* @dev A resolver callback that should be implemented by child contracts. /// @param attestation The new attestation.
* /// @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in
* @param attestation The new attestation. /// both attest() and multiAttest() callbacks EAS-only callbacks and that in case of multi attestations, it'll
* @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in /// usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations
* both attest() and multiAttest() callbacks EAS-only callbacks and that in case of multi attestations, it'll /// in the batch.
* usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations /// @return Whether the attestation is valid.
* in the batch.
*
* @return Whether the attestation is valid.
*/
function onAttest(Attestation calldata attestation, uint256 value) internal virtual returns (bool); function onAttest(Attestation calldata attestation, uint256 value) internal virtual returns (bool);
/** /// @notice Processes an attestation revocation and verifies if it can be revoked.
* @dev Processes an attestation revocation and verifies if it can be revoked. /// @param attestation The existing attestation to be revoked.
* /// @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in
* @param attestation The existing attestation to be revoked. /// both revoke() and multiRevoke() callbacks EAS-only callbacks and that in case of multi attestations, it'll
* @param value An explicit ETH amount that was sent to the resolver. Please note that this value is verified in /// usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations
* both revoke() and multiRevoke() callbacks EAS-only callbacks and that in case of multi attestations, it'll /// in the batch.
* usually hold that msg.value != value, since msg.value aggregated the sent ETH amounts for all the attestations /// @return Whether the attestation can be revoked.
* in the batch.
*
* @return Whether the attestation can be revoked.
*/
function onRevoke(Attestation calldata attestation, uint256 value) internal virtual returns (bool); function onRevoke(Attestation calldata attestation, uint256 value) internal virtual returns (bool);
/** /// @notice Ensures that only the EAS contract can make this call.
* @dev Ensures that only the EAS contract can make this call.
*/
function _onlyEAS() private view { function _onlyEAS() private view {
if (msg.sender != address(_eas)) { if (msg.sender != address(_eas)) {
revert AccessDenied(); revert AccessDenied();
......
...@@ -5,37 +5,26 @@ import { ERC20 } from "@rari-capital/solmate/src/tokens/ERC20.sol"; ...@@ -5,37 +5,26 @@ import { ERC20 } from "@rari-capital/solmate/src/tokens/ERC20.sol";
import { ERC721 } from "@rari-capital/solmate/src/tokens/ERC721.sol"; import { ERC721 } from "@rari-capital/solmate/src/tokens/ERC721.sol";
import { Transactor } from "./Transactor.sol"; import { Transactor } from "./Transactor.sol";
/** /// @title AssetReceiver
* @title AssetReceiver /// @notice AssetReceiver is a minimal contract for receiving funds assets in the form of either
* @notice AssetReceiver is a minimal contract for receiving funds assets in the form of either /// ETH, ERC20 tokens, or ERC721 tokens. Only the contract owner may withdraw the assets.
* ETH, ERC20 tokens, or ERC721 tokens. Only the contract owner may withdraw the assets.
*/
contract AssetReceiver is Transactor { contract AssetReceiver is Transactor {
/** /// @notice Emitted when ETH is received by this address.
* @notice Emitted when ETH is received by this address. /// @param from Address that sent ETH to this contract.
* /// @param amount Amount of ETH received.
* @param from Address that sent ETH to this contract.
* @param amount Amount of ETH received.
*/
event ReceivedETH(address indexed from, uint256 amount); event ReceivedETH(address indexed from, uint256 amount);
/** /// @notice Emitted when ETH is withdrawn from this address.
* @notice Emitted when ETH is withdrawn from this address. /// @param withdrawer Address that triggered the withdrawal.
* /// @param recipient Address that received the withdrawal.
* @param withdrawer Address that triggered the withdrawal. /// @param amount ETH amount withdrawn.
* @param recipient Address that received the withdrawal.
* @param amount ETH amount withdrawn.
*/
event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount); event WithdrewETH(address indexed withdrawer, address indexed recipient, uint256 amount);
/** /// @notice Emitted when ERC20 tokens are withdrawn from this address.
* @notice Emitted when ERC20 tokens are withdrawn from this address. /// @param withdrawer Address that triggered the withdrawal.
* /// @param recipient Address that received the withdrawal.
* @param withdrawer Address that triggered the withdrawal. /// @param asset Address of the token being withdrawn.
* @param recipient Address that received the withdrawal. /// @param amount ERC20 amount withdrawn.
* @param asset Address of the token being withdrawn.
* @param amount ERC20 amount withdrawn.
*/
event WithdrewERC20( event WithdrewERC20(
address indexed withdrawer, address indexed withdrawer,
address indexed recipient, address indexed recipient,
...@@ -43,14 +32,11 @@ contract AssetReceiver is Transactor { ...@@ -43,14 +32,11 @@ contract AssetReceiver is Transactor {
uint256 amount uint256 amount
); );
/** /// @notice Emitted when ERC20 tokens are withdrawn from this address.
* @notice Emitted when ERC20 tokens are withdrawn from this address. /// @param withdrawer Address that triggered the withdrawal.
* /// @param recipient Address that received the withdrawal.
* @param withdrawer Address that triggered the withdrawal. /// @param asset Address of the token being withdrawn.
* @param recipient Address that received the withdrawal. /// @param id Token ID being withdrawn.
* @param asset Address of the token being withdrawn.
* @param id Token ID being withdrawn.
*/
event WithdrewERC721( event WithdrewERC721(
address indexed withdrawer, address indexed withdrawer,
address indexed recipient, address indexed recipient,
...@@ -58,56 +44,40 @@ contract AssetReceiver is Transactor { ...@@ -58,56 +44,40 @@ contract AssetReceiver is Transactor {
uint256 id uint256 id
); );
/** /// @param _owner Initial contract owner.
* @param _owner Initial contract owner.
*/
constructor(address _owner) Transactor(_owner) {} constructor(address _owner) Transactor(_owner) {}
/** /// @notice Make sure we can receive ETH.
* @notice Make sure we can receive ETH.
*/
receive() external payable { receive() external payable {
emit ReceivedETH(msg.sender, msg.value); emit ReceivedETH(msg.sender, msg.value);
} }
/** /// @notice Withdraws full ETH balance to the recipient.
* @notice Withdraws full ETH balance to the recipient. /// @param _to Address to receive the ETH balance.
*
* @param _to Address to receive the ETH balance.
*/
function withdrawETH(address payable _to) external onlyOwner { function withdrawETH(address payable _to) external onlyOwner {
withdrawETH(_to, address(this).balance); withdrawETH(_to, address(this).balance);
} }
/** /// @notice Withdraws partial ETH balance to the recipient.
* @notice Withdraws partial ETH balance to the recipient. /// @param _to Address to receive the ETH balance.
* /// @param _amount Amount of ETH to withdraw.
* @param _to Address to receive the ETH balance.
* @param _amount Amount of ETH to withdraw.
*/
function withdrawETH(address payable _to, uint256 _amount) public onlyOwner { function withdrawETH(address payable _to, uint256 _amount) public onlyOwner {
// slither-disable-next-line reentrancy-unlimited-gas // slither-disable-next-line reentrancy-unlimited-gas
(bool success, ) = _to.call{ value: _amount }(""); (bool success, ) = _to.call{ value: _amount }("");
emit WithdrewETH(msg.sender, _to, _amount); emit WithdrewETH(msg.sender, _to, _amount);
} }
/** /// @notice Withdraws full ERC20 balance to the recipient.
* @notice Withdraws full ERC20 balance to the recipient. /// @param _asset ERC20 token to withdraw.
* /// @param _to Address to receive the ERC20 balance.
* @param _asset ERC20 token to withdraw.
* @param _to Address to receive the ERC20 balance.
*/
function withdrawERC20(ERC20 _asset, address _to) external onlyOwner { function withdrawERC20(ERC20 _asset, address _to) external onlyOwner {
withdrawERC20(_asset, _to, _asset.balanceOf(address(this))); withdrawERC20(_asset, _to, _asset.balanceOf(address(this)));
} }
/** /// @notice Withdraws partial ERC20 balance to the recipient.
* @notice Withdraws partial ERC20 balance to the recipient. /// @param _asset ERC20 token to withdraw.
* /// @param _to Address to receive the ERC20 balance.
* @param _asset ERC20 token to withdraw. /// @param _amount Amount of ERC20 to withdraw.
* @param _to Address to receive the ERC20 balance.
* @param _amount Amount of ERC20 to withdraw.
*/
function withdrawERC20( function withdrawERC20(
ERC20 _asset, ERC20 _asset,
address _to, address _to,
...@@ -119,13 +89,10 @@ contract AssetReceiver is Transactor { ...@@ -119,13 +89,10 @@ contract AssetReceiver is Transactor {
emit WithdrewERC20(msg.sender, _to, address(_asset), _amount); emit WithdrewERC20(msg.sender, _to, address(_asset), _amount);
} }
/** /// @notice Withdraws ERC721 token to the recipient.
* @notice Withdraws ERC721 token to the recipient. /// @param _asset ERC721 token to withdraw.
* /// @param _to Address to receive the ERC721 token.
* @param _asset ERC721 token to withdraw. /// @param _id Token ID of the ERC721 token to withdraw.
* @param _to Address to receive the ERC721 token.
* @param _id Token ID of the ERC721 token to withdraw.
*/
function withdrawERC721( function withdrawERC721(
ERC721 _asset, ERC721 _asset,
address _to, address _to,
......
...@@ -3,50 +3,38 @@ pragma solidity ^0.8.0; ...@@ -3,50 +3,38 @@ pragma solidity ^0.8.0;
import { Owned } from "@rari-capital/solmate/src/auth/Owned.sol"; import { Owned } from "@rari-capital/solmate/src/auth/Owned.sol";
/** /// @title Transactor
* @title Transactor /// @notice Transactor is a minimal contract that can send transactions.
* @notice Transactor is a minimal contract that can send transactions.
*/
contract Transactor is Owned { contract Transactor is Owned {
/** /// @param _owner Initial contract owner.
* @param _owner Initial contract owner.
*/
constructor(address _owner) Owned(_owner) {} constructor(address _owner) Owned(_owner) {}
/** /// @notice Sends a CALL to a target address.
* Sends a CALL to a target address. /// @param _target Address to call.
* /// @param _data Data to send with the call.
* @param _target Address to call. /// @param _value ETH value to send with the call.
* @param _data Data to send with the call. /// @return success_ Boolean success value.
* @param _value ETH value to send with the call. /// @return data_ Bytes data returned by the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
function CALL( function CALL(
address _target, address _target,
bytes memory _data, bytes memory _data,
uint256 _value uint256 _value
) external payable onlyOwner returns (bool, bytes memory) { ) external payable onlyOwner returns (bool success_, bytes memory data_) {
return _target.call{ value: _value }(_data); (success_, data_) = _target.call{ value: _value }(_data);
} }
/** /// @notice Sends a DELEGATECALL to a target address.
* Sends a DELEGATECALL to a target address. /// @param _target Address to call.
* /// @param _data Data to send with the call.
* @param _target Address to call. /// @return success_ Boolean success value.
* @param _data Data to send with the call. /// @return data_ Bytes data returned by the call.
*
* @return Boolean success value.
* @return Bytes data returned by the call.
*/
function DELEGATECALL(address _target, bytes memory _data) function DELEGATECALL(address _target, bytes memory _data)
external external
payable payable
onlyOwner onlyOwner
returns (bool, bytes memory) returns (bool success_, bytes memory data_)
{ {
// slither-disable-next-line controlled-delegatecall // slither-disable-next-line controlled-delegatecall
return _target.delegatecall(_data); (success_, data_) = _target.delegatecall(_data);
} }
} }
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
"slither": "./scripts/slither.sh", "slither": "./scripts/slither.sh",
"slither:triage": "TRIAGE_MODE=1 ./scripts/slither.sh", "slither:triage": "TRIAGE_MODE=1 ./scripts/slither.sh",
"clean": "rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./src/contract-artifacts.ts ./test-case-generator/fuzz", "clean": "rm -rf ./dist ./artifacts ./forge-artifacts ./cache ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo ./src/contract-artifacts.ts ./test-case-generator/fuzz",
"preinstall": "npx only-allow pnpm",
"lint:ts:check": "eslint . --max-warnings=0", "lint:ts:check": "eslint . --max-warnings=0",
"lint:forge-tests:check": "ts-node scripts/forge-test-names.ts", "lint:forge-tests:check": "ts-node scripts/forge-test-names.ts",
"lint:contracts:check": "pnpm solhint -f table 'contracts/**/!(DisputeTypes|RLPReader|EAS|SchemaRegistry|IEAS|ISchemaRegistry|SchemaResolver|EIP712Verifier|ISchemaResolver).sol' && pnpm prettier --check 'contracts/**/!(DisputeTypes|RLPReader|EAS|SchemaRegistry|IEAS|ISchemaRegistry|SchemaResolver|EIP712Verifier|ISchemaResolver).sol' && pnpm lint:forge-tests:check", "lint:contracts:check": "pnpm solhint -f table 'contracts/**/!(DisputeTypes|RLPReader|EAS|SchemaRegistry|IEAS|ISchemaRegistry|SchemaResolver|EIP712Verifier|ISchemaResolver).sol' && pnpm prettier --check 'contracts/**/!(DisputeTypes|RLPReader|EAS|SchemaRegistry|IEAS|ISchemaRegistry|SchemaResolver|EIP712Verifier|ISchemaResolver).sol' && pnpm lint:forge-tests:check",
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
], ],
"scripts": { "scripts": {
"build": "tsup", "build": "tsup",
"clean": "rm -rf ./dist",
"preinstall": "npx only-allow pnpm",
"generate": "wagmi generate && pnpm build && pnpm lint:fix", "generate": "wagmi generate && pnpm build && pnpm lint:fix",
"generate:check": "pnpm generate && git diff --exit-code ./addresses.json && git diff --exit-code ./abis.json", "generate:check": "pnpm generate && git diff --exit-code ./addresses.json && git diff --exit-code ./abis.json",
"lint": "prettier --check .", "lint": "prettier --check .",
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint", "all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint",
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo", "clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"preinstall": "npx only-allow pnpm",
"lint": "pnpm lint:fix && pnpm lint:check", "lint": "pnpm lint:fix && pnpm lint:check",
"lint:check": "eslint . --max-warnings=0", "lint:check": "eslint . --max-warnings=0",
"lint:fix": "pnpm lint:check --fix", "lint:fix": "pnpm lint:check --fix",
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
"test:coverage": "echo 'No tests defined.'", "test:coverage": "echo 'No tests defined.'",
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"clean": "rimraf ./dist ./tsconfig.tsbuildinfo", "clean": "rimraf ./dist ./tsconfig.tsbuildinfo",
"preinstall": "npx only-allow pnpm",
"lint": "pnpm run lint:fix && pnpm run lint:check", "lint": "pnpm run lint:fix && pnpm run lint:check",
"pre-commit": "lint-staged", "pre-commit": "lint-staged",
"lint:fix": "pnpm lint:check --fix", "lint:fix": "pnpm lint:check --fix",
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
"all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint", "all": "pnpm clean && pnpm build && pnpm test && pnpm lint:fix && pnpm lint",
"build": "tsc -p tsconfig.json", "build": "tsc -p tsconfig.json",
"clean": "rimraf dist/ ./tsconfig.tsbuildinfo", "clean": "rimraf dist/ ./tsconfig.tsbuildinfo",
"preinstall": "npx only-allow pnpm",
"lint": "pnpm lint:fix && pnpm lint:check", "lint": "pnpm lint:fix && pnpm lint:check",
"lint:check": "eslint . --max-warnings=0", "lint:check": "eslint . --max-warnings=0",
"lint:fix": "pnpm lint:check --fix", "lint:fix": "pnpm lint:check --fix",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment