From 9cc62efb8ae28f13ad87c73ad9704a2c2574480f Mon Sep 17 00:00:00 2001 From: arthur Date: Fri, 29 May 2026 20:09:12 +0000 Subject: [PATCH] fix_lint (#11) Co-authored-by: Arthur Abeilice Reviewed-on: https://git.p2pix.co/doiim/p2pix-smart-contracts/pulls/11 Co-authored-by: arthur Co-committed-by: arthur --- .eslintignore | 27 - .eslintrc.yaml | 21 - .prettierignore | 4 +- .prettierrc.yaml | 6 +- .solhint.json | 11 +- contracts/core/BaseUtils.sol | 5 +- contracts/core/Constants.sol | 33 +- contracts/core/DataTypes.sol | 1 - contracts/lib/metatx/ERC2771Context.sol | 9 +- contracts/lib/utils/Multicall.sol | 23 +- contracts/p2pix.sol | 185 ++-- eslint.config.js | 55 ++ hardhat.config.ts | 15 +- package.json | 5 +- scripts/setDefaultBlocks.ts | 20 +- test/Reputation.test.ts | 6 +- test/_.test.ts | 2 - test/p2pix.test.ts | 1085 +++++++++++------------ test/utils/fixtures.ts | 36 +- test/utils/interfaces.ts | 19 +- yarn.lock | 376 ++++++-- 21 files changed, 1086 insertions(+), 858 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.yaml create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 817d491..0000000 --- a/.eslintignore +++ /dev/null @@ -1,27 +0,0 @@ -# directories -.yarn/ -**/.coverage_artifacts -**/.coverage_cache -**/.coverage_contracts -**/artifacts -**/build -**/cache -**/coverage -**/dist -**/node_modules -**/types - -# deploy artifacts -deploys/old/ - -# auto-generated docs -docs/ - -# files -*.env -*.log -.pnp.* -coverage.json -npm-debug.log* -yarn-debug.log* -yarn-error.log* \ No newline at end of file diff --git a/.eslintrc.yaml b/.eslintrc.yaml deleted file mode 100644 index dbafe1e..0000000 --- a/.eslintrc.yaml +++ /dev/null @@ -1,21 +0,0 @@ -extends: - - "eslint:recommended" - - "plugin:@typescript-eslint/eslint-recommended" - - "plugin:@typescript-eslint/recommended" - - "prettier" -parser: "@typescript-eslint/parser" -parserOptions: - project: "./tsconfig.json" -plugins: - - "@typescript-eslint" -root: true -rules: - "@typescript-eslint/no-floating-promises": - - error - - ignoreIIFE: true - ignoreVoid: true - "@typescript-eslint/no-inferrable-types": "off" - "@typescript-eslint/no-unused-vars": - - error - - argsIgnorePattern: "_" - varsIgnorePattern: "_" diff --git a/.prettierignore b/.prettierignore index 679f05d..817d491 100644 --- a/.prettierignore +++ b/.prettierignore @@ -24,6 +24,4 @@ docs/ coverage.json npm-debug.log* yarn-debug.log* -yarn-error.log* - -contracts/p2pix.sol \ No newline at end of file +yarn-error.log* \ No newline at end of file diff --git a/.prettierrc.yaml b/.prettierrc.yaml index 0ced30f..1feb774 100644 --- a/.prettierrc.yaml +++ b/.prettierrc.yaml @@ -1,10 +1,8 @@ +plugins: + - prettier-plugin-solidity arrowParens: avoid bracketSpacing: true endOfLine: auto -importOrder: ["", "^[./]"] -importOrderParserPlugins: ["typescript"] -importOrderSeparation: true -importOrderSortSpecifiers: true printWidth: 62 singleQuote: false tabWidth: 2 diff --git a/.solhint.json b/.solhint.json index 7d30633..5450161 100644 --- a/.solhint.json +++ b/.solhint.json @@ -3,6 +3,7 @@ "plugins": ["prettier"], "rules": { "code-complexity": ["error", 8], + "avoid-low-level-calls": "off", "compiler-version": ["error", ">=0.8.4"], "const-name-snakecase": "off", "constructor-syntax": "error", @@ -10,7 +11,14 @@ "error", { "ignoreConstructors": true } ], + "function-max-lines": "off", + "gas-calldata-parameters": "off", + "gas-indexed-events": "off", + "gas-strict-inequalities": "off", + "gas-struct-packing": "off", + "interface-starts-with-i": "off", "max-line-length": ["error", 120], + "no-inline-assembly": "off", "not-rely-on-time": "off", "prettier/prettier": [ "error", @@ -18,6 +26,7 @@ "endOfLine": "auto" } ], - "reason-string": ["warn", { "maxLength": 64 }] + "reason-string": ["warn", { "maxLength": 64 }], + "use-natspec": "off" } } diff --git a/contracts/core/BaseUtils.sol b/contracts/core/BaseUtils.sol index 672ccf3..cf930c5 100644 --- a/contracts/core/BaseUtils.sol +++ b/contracts/core/BaseUtils.sol @@ -45,9 +45,8 @@ abstract contract BaseUtils is !validBacenSigners( _castAddrToKey( ECDSA.recover( - MessageHashUtils.toEthSignedMessageHash( - _message - ), + MessageHashUtils + .toEthSignedMessageHash(_message), _signature ) ) diff --git a/contracts/core/Constants.sol b/contracts/core/Constants.sol index 21e2449..470c587 100644 --- a/contracts/core/Constants.sol +++ b/contracts/core/Constants.sol @@ -4,19 +4,23 @@ pragma solidity ^0.8.19; abstract contract Constants { /// ███ Constants ██████████████████████████████████████████████████████████ - uint256 constant _ROOT_UPDATED_EVENT_SIGNATURE = + uint256 internal constant _ROOT_UPDATED_EVENT_SIGNATURE = 0x0b294da292f26e55fd442b5c0164fbb9013036ff00c5cfdde0efd01c1baaf632; - uint256 constant _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE = + uint256 + internal constant _ALLOWED_ERC20_UPDATED_EVENT_SIGNATURE = 0x5d6e86e5341d57a92c49934296c51542a25015c9b1782a1c2722a940131c3d9a; - uint256 constant _TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE = + uint256 + internal constant _TRUSTED_FORWARDER_UPDATED_EVENT_SIGNATURE = 0xbee55516e29d3969d3cb8eb01351eb3c52d06f9e2435bd5a8bfe3647e185df92; /// @dev Seller casted to key => Seller's allowlist merkleroot. /// mapping(uint256 => bytes32) public sellerAllowList; - uint256 constant _SELLER_ALLOWLIST_SLOT_SEED = 0x74dfee70; + uint256 internal constant _SELLER_ALLOWLIST_SLOT_SEED = + 0x74dfee70; /// @dev Tokens allowed to serve as the underlying amount of a deposit. /// mapping(ERC20 => bool) public allowedERC20s; - uint256 constant _ALLOWED_ERC20_SLOT_SEED = 0xcbc9d1c4; + uint256 internal constant _ALLOWED_ERC20_SLOT_SEED = + 0xcbc9d1c4; /// @dev `balance` max. value = 10**26. /// @dev `pixTarget` keys are restricted to 160 bits. @@ -32,16 +36,21 @@ abstract contract Constants { /// mstore(0x0c, _SELLER_BALANCE_SLOT_SEED) /// mstore(0x00, seller) /// let value := sload(keccak256(0x0c, 0x34)). - uint256 constant _SELLER_BALANCE_SLOT_SEED = 0x739094b1; + uint256 internal constant _SELLER_BALANCE_SLOT_SEED = + 0x739094b1; /// @dev The bitmask of `sellerBalance` entry. - uint256 constant BITMASK_SB_ENTRY = (1 << 94) - 1; + uint256 internal constant BITMASK_SB_ENTRY = + (1 << 94) - 1; /// @dev The bit position of `valid` in `sellerBalance`. - uint256 constant BITPOS_VALID = 95; + uint256 internal constant BITPOS_VALID = 95; /// @dev The scalar of BRZ token. - uint256 constant WAD = 1e18; - uint256 constant MAXBALANCE_UPPERBOUND = 1e8 ether; - uint256 constant REPUTATION_LOWERBOUND = 1e2 ether; - uint256 constant LOCKAMOUNT_UPPERBOUND = 1e6 ether; + uint256 internal constant WAD = 1e18; + uint256 internal constant MAXBALANCE_UPPERBOUND = + 1e8 ether; + uint256 internal constant REPUTATION_LOWERBOUND = + 1e2 ether; + uint256 internal constant LOCKAMOUNT_UPPERBOUND = + 1e6 ether; } diff --git a/contracts/core/DataTypes.sol b/contracts/core/DataTypes.sol index eb784e0..7178e61 100644 --- a/contracts/core/DataTypes.sol +++ b/contracts/core/DataTypes.sol @@ -4,7 +4,6 @@ pragma solidity ^0.8.19; import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol"; library DataTypes { - struct Lock { uint256 counter; uint256 expirationBlock; diff --git a/contracts/lib/metatx/ERC2771Context.sol b/contracts/lib/metatx/ERC2771Context.sol index a6d45cf..4001dbc 100644 --- a/contracts/lib/metatx/ERC2771Context.sol +++ b/contracts/lib/metatx/ERC2771Context.sol @@ -6,9 +6,10 @@ import { ERC2771Context } from "@openzeppelin/contracts/metatx/ERC2771Context.so abstract contract ERC2771 is ERC2771Context(address(0)) { mapping(address => bool) public trustedForwarders; - - function isTrustedForwarder(address forwarder) public view override returns (bool) { - return trustedForwarders[forwarder]; - } + function isTrustedForwarder( + address forwarder + ) public view override returns (bool) { + return trustedForwarders[forwarder]; + } } diff --git a/contracts/lib/utils/Multicall.sol b/contracts/lib/utils/Multicall.sol index 2f98220..c19aad8 100644 --- a/contracts/lib/utils/Multicall.sol +++ b/contracts/lib/utils/Multicall.sol @@ -19,12 +19,12 @@ contract Multicall { } //prettier-ignore + //solhint-disable-next-line no-empty-blocks constructor(/* */) payable {/* */} - function mtc1(Call[] calldata calls) - external - returns (uint256, bytes[] memory) - { + function mtc1( + Call[] calldata calls + ) external returns (uint256, bytes[] memory) { uint256 bn = block.number; uint256 len = calls.length; bytes[] memory res = new bytes[](len); @@ -49,21 +49,14 @@ contract Multicall { return (bn, res); } - function mtc2(Call[] calldata calls) - external - returns ( - uint256, - bytes32, - Result[] memory - ) - { + function mtc2( + Call[] calldata calls + ) external returns (uint256, bytes32, Result[] memory) { uint256 bn = block.number; // µ 0 s [0] ≡ P(IHp , µs [0], 0) ∴ P is the hash of a block of a particular number, up to a maximum age. // 0 is left on the stack if the looked for `block.number` is >= to the current `block.number` or more than 256 // blocks behind the current block (Yellow Paper, p. 33, https://ethereum.github.io/yellowpaper/paper.pdf). - bytes32 bh = blockhash( - bn /* - 1 */ - ); + bytes32 bh = blockhash(bn /* - 1 */); uint256 len = calls.length; Result[] memory res = new Result[](len); uint256 i; diff --git a/contracts/p2pix.sol b/contracts/p2pix.sol index 641da79..bb6d19b 100644 --- a/contracts/p2pix.sol +++ b/contracts/p2pix.sol @@ -12,7 +12,6 @@ import { OwnerSettings, ERC20, SafeTransferLib } from "contracts/core/OwnerSetti import { BaseUtils } from "contracts/core/BaseUtils.sol"; import { DataTypes as DT } from "contracts/core/DataTypes.sol"; - contract P2PIX is BaseUtils { // solhint-disable use-forbidden-name // solhint-disable no-inline-assembly @@ -34,15 +33,18 @@ contract P2PIX is BaseUtils { address _reputation, ERC20[] memory tokens, bool[] memory tokenStates - ) + ) + payable OwnerSettings( - defaultBlocks, - validSigners, - _reputation, - tokens, + defaultBlocks, + validSigners, + _reputation, + tokens, tokenStates - ) - payable {/* */} + ) + { + /* */ + } /// @notice Creates a deposit order based on a seller's /// offer of an amount of ERC20 tokens. @@ -58,13 +60,16 @@ contract P2PIX is BaseUtils { uint96 amount, bool valid ) public nonReentrant { - - if (bytes(pixTarget).length == 0) revert EmptyPixTarget(); + if (bytes(pixTarget).length == 0) + revert EmptyPixTarget(); if (!allowedERC20s(token)) revert TokenDenied(); - uint256 _sellerBalance = __sellerBalance(msg.sender, token); + uint256 _sellerBalance = __sellerBalance( + msg.sender, + token + ); uint256 currBal = _sellerBalance & BITMASK_SB_ENTRY; - uint256 _newBal = uint256(currBal + amount); + uint256 _newBal = uint256(currBal + amount); if (_newBal > MAXBALANCE_UPPERBOUND) revert MaxBalExceeded(); @@ -76,8 +81,8 @@ contract P2PIX is BaseUtils { uint256 validCasted = _castBool(valid); _setSellerBalance( - msg.sender, - token, + msg.sender, + token, (_newBal | (validCasted << BITPOS_VALID)), pixTargetCasted ); @@ -97,7 +102,10 @@ contract P2PIX is BaseUtils { /// @notice This function does not affect any ongoing active locks. /// @dev Function sighash: 0x6d82d9e0 function setValidState(ERC20 token, bool state) public { - uint256 _sellerBalance = __sellerBalance(msg.sender, token); + uint256 _sellerBalance = __sellerBalance( + msg.sender, + token + ); if (_sellerBalance != 0) { uint256 _valid = _castBool(state); @@ -115,7 +123,7 @@ contract P2PIX is BaseUtils { /// @notice Public method designed to lock an remaining amount of /// the deposit order of a seller. /// @notice Transaction forwarding must leave `merkleProof` empty; - /// otherwise, the trustedForwarder must be previously added + /// otherwise, the trustedForwarder must be previously added /// to a seller whitelist. /// @notice This method can be performed either by: /// - An user allowed via the seller's allowlist; @@ -144,30 +152,36 @@ contract P2PIX is BaseUtils { uint256 bal = getBalance(seller, token); if (bal < amount) revert NotEnoughTokens(); - unchecked { + unchecked { lockID = ++lockCounter; } - if ( - mapLocks[lockID].expirationBlock >= block.number - ) revert NotExpired(); + if (mapLocks[lockID].expirationBlock >= block.number) + revert NotExpired(); bytes32 _pixTarget = getPixTarget(seller, token); // transaction forwarding must leave `merkleProof` empty; - // otherwise, the trustedForwarder must be previously added + // otherwise, the trustedForwarder must be previously added // to a seller whitelist. if (merkleProof.length != 0) { - _merkleVerify( merkleProof, sellerAllowList(seller), _msgSender()); - - } else if ( amount > REPUTATION_LOWERBOUND && msg.sender == _msgSender() ) { - - uint256 spendLimit; uint256 userCredit = - userRecord[_castAddrToKey(_msgSender())]; + _merkleVerify( + merkleProof, + sellerAllowList(seller), + _msgSender() + ); + } else if ( + amount > REPUTATION_LOWERBOUND && + msg.sender == _msgSender() + ) { + uint256 spendLimit; + uint256 userCredit = userRecord[ + _castAddrToKey(_msgSender()) + ]; (spendLimit) = _limiter(userCredit / WAD); - if ( - amount > (spendLimit * WAD) || - amount > LOCKAMOUNT_UPPERBOUND + if ( + amount > (spendLimit * WAD) || + amount > LOCKAMOUNT_UPPERBOUND ) revert AmountNotAllowed(); } @@ -225,14 +239,21 @@ contract P2PIX is BaseUtils { l.amount = 0; l.expirationBlock = 0; _setUsedTransactions(message); - - if (_msgSender() == msg.sender) { - if (msg.sender != l.buyerAddress) { - userRecord[_castAddrToKey(msg.sender)] += (lockAmount >> 1); - userRecord[_castAddrToKey(l.buyerAddress)] += (lockAmount >> 1); - } else { - userRecord[_castAddrToKey(msg.sender)] += lockAmount; - }} + + if (_msgSender() == msg.sender) { + if (msg.sender != l.buyerAddress) { + userRecord[ + _castAddrToKey(msg.sender) + ] += (lockAmount >> 1); + userRecord[ + _castAddrToKey(l.buyerAddress) + ] += (lockAmount >> 1); + } else { + userRecord[ + _castAddrToKey(msg.sender) + ] += lockAmount; + } + } SafeTransferLib.safeTransfer( t, @@ -249,9 +270,9 @@ contract P2PIX is BaseUtils { /// @notice For each successfull unexpired lock recovered, /// `userRecord[_castAddrToKey(l.relayerAddress)]` is decreased by half of its value. /// @dev Function sighash: 0xb0983d39 - function unlockExpired(uint256[] calldata lockIDs) - public - { + function unlockExpired( + uint256[] calldata lockIDs + ) public { uint256 i; uint256 locksSize = lockIDs.length; @@ -260,19 +281,21 @@ contract P2PIX is BaseUtils { _notExpired(l); - uint256 _sellerBalance = - __sellerBalance(l.seller, l.token) & BITMASK_SB_ENTRY; + uint256 _sellerBalance = __sellerBalance( + l.seller, + l.token + ) & BITMASK_SB_ENTRY; - if ((_sellerBalance + l.amount) > MAXBALANCE_UPPERBOUND) - revert MaxBalExceeded(); + if ( + (_sellerBalance + l.amount) > + MAXBALANCE_UPPERBOUND + ) revert MaxBalExceeded(); _addSellerBalance(l.seller, l.token, l.amount); l.amount = 0; - uint256 userKey = _castAddrToKey( - l.buyerAddress - ); + uint256 userKey = _castAddrToKey(l.buyerAddress); uint256 _newUserRecord = (userRecord[userKey] >> 1); @@ -312,7 +335,8 @@ contract P2PIX is BaseUtils { setValidState(token, false); _decBal( - (__sellerBalance(msg.sender, token) & BITMASK_SB_ENTRY), + (__sellerBalance(msg.sender, token) & + BITMASK_SB_ENTRY), amount, token, msg.sender @@ -325,18 +349,15 @@ contract P2PIX is BaseUtils { amount ); - emit DepositWithdrawn( - msg.sender, - token, - amount - ); + emit DepositWithdrawn(msg.sender, token, amount); } - function setRoot(address addr, bytes32 merkleroot) - public - { + function setRoot( + address addr, + bytes32 merkleroot + ) public { assembly ("memory-safe") { - // if (addr != msg.sender) + // if (addr != msg.sender) if iszero(eq(addr, caller())) { // revert OnlySeller() mstore(0x00, 0x85d1f726) @@ -349,8 +370,8 @@ contract P2PIX is BaseUtils { // emit RootUpdated(addr, merkleroot); log3( - 0, - 0, + 0, + 0, _ROOT_UPDATED_EVENT_SIGNATURE, addr, merkleroot @@ -408,14 +429,13 @@ contract P2PIX is BaseUtils { } // we can directly dec from packed uint entry value - _decSellerBalance(_k,_t, _amount); + _decSellerBalance(_k, _t, _amount); } - function getBalance(address seller, ERC20 token) - public - view - returns (uint256 bal) - { + function getBalance( + address seller, + ERC20 token + ) public view returns (uint256 bal) { assembly ("memory-safe") { for { /* */ @@ -434,11 +454,10 @@ contract P2PIX is BaseUtils { } } - function getValid(address seller, ERC20 token) - public - view - returns (bool valid) - { + function getValid( + address seller, + ERC20 token + ) public view returns (bool valid) { assembly ("memory-safe") { for { /* */ @@ -452,7 +471,9 @@ contract P2PIX is BaseUtils { BITMASK_SB_ENTRY, shr( BITPOS_VALID, - sload(add(keccak256(0x0c, 0x34), 0x01)) + sload( + add(keccak256(0x0c, 0x34), 0x01) + ) ) ) break @@ -460,11 +481,10 @@ contract P2PIX is BaseUtils { } } - function getPixTarget(address seller, ERC20 token) - public - view - returns (bytes32 pixTarget) - { + function getPixTarget( + address seller, + ERC20 token + ) public view returns (bytes32 pixTarget) { assembly ("memory-safe") { for { /* */ @@ -480,9 +500,12 @@ contract P2PIX is BaseUtils { } } - function getPixTargetString(address seller, ERC20 token) public view returns (string memory pixTarget) { + function getPixTargetString( + address seller, + ERC20 token + ) public view returns (string memory pixTarget) { bytes32 _pixEnc = getPixTarget(seller, token); - pixTarget = string(abi.encodePacked(_pixEnc)); + pixTarget = string(abi.encodePacked(_pixEnc)); } function getBalances( @@ -506,7 +529,9 @@ contract P2PIX is BaseUtils { /// @notice External getter that returns the status of a lockIDs array. /// @notice Call will not revert if provided with an empty array as parameter. /// @dev Function sighash: 0x49ef8448 - function getLocksStatus(uint256[] memory ids) + function getLocksStatus( + uint256[] memory ids + ) external view returns (uint256[] memory, DT.LockStatus[] memory) diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..7c14ea9 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,55 @@ +const tseslint = require("typescript-eslint"); +const js = require("@eslint/js"); +const eslintConfigPrettier = require("eslint-config-prettier"); + +module.exports = tseslint.config( + { + ignores: [ + ".yarn/", + "**/.coverage_artifacts", + "**/.coverage_cache", + "**/.coverage_contracts", + "**/artifacts", + "**/build", + "**/cache", + "**/coverage", + "**/dist", + "**/node_modules", + "**/types", + "deploys/old/", + "docs/", + "*.env", + "*.log", + ".pnp.*", + "coverage.json", + "npm-debug.log*", + "yarn-debug.log*", + "yarn-error.log*", + ".solcover.js", + "eslint.config.js", + ], + }, + js.configs.recommended, + ...tseslint.configs.recommended, + eslintConfigPrettier, + { + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: __dirname, + }, + }, + rules: { + "@typescript-eslint/no-floating-promises": [ + "error", + { ignoreIIFE: true, ignoreVoid: true }, + ], + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { argsIgnorePattern: "_", varsIgnorePattern: "_" }, + ], + "@typescript-eslint/no-unused-expressions": "off", + }, + }, +); diff --git a/hardhat.config.ts b/hardhat.config.ts index 6a96164..80b961d 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -15,8 +15,10 @@ dotenvConfig({ path: resolve(__dirname, "./.env") }); const DEFAULT_MNEMONIC = "test test test test test test test test test test test junk"; -const mnemonic: string = process.env.MNEMONIC ?? DEFAULT_MNEMONIC; -const alchemyApiKey: string | undefined = process.env.ALCHEMY_API_KEY; +const mnemonic: string = + process.env.MNEMONIC ?? DEFAULT_MNEMONIC; +const alchemyApiKey: string | undefined = + process.env.ALCHEMY_API_KEY; const chainIds = { // "{INSERT_NAME}": {INSERT_ID}, @@ -33,7 +35,12 @@ const chainIds = { function getChainConfig( chain: keyof typeof chainIds, ): NetworkUserConfig { - let jsonRpcUrl = + if (!alchemyApiKey) { + throw new Error( + `Please set ALCHEMY_API_KEY in a .env file before targeting ${chain}`, + ); + } + const jsonRpcUrl = "https://" + chain + ".g.alchemy.com/v2/" + alchemyApiKey; return { accounts: { @@ -136,7 +143,7 @@ const config: HardhatUserConfig = { }, docgen: { pages: "files", - } + }, }; export default config; diff --git a/package.json b/package.json index f3dd9e9..5e715ab 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "coverage": "hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"test/**/*.ts\" && yarn typechain", "lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check", "lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"", - "lint:ts": "eslint --config ./.eslintrc.yaml --ignore-path ./.eslintignore --ext .js,.ts .", + "lint:ts": "eslint .", "prettier": "prettier --config ./.prettierrc.yaml --write \"**/*.{js,json,md,sol,ts,yaml,yml}\"", "prettier:check": "prettier --check --config ./.prettierrc.yaml \"**/*.{js,json,md,sol,ts,yaml,yml}\"" }, @@ -54,13 +54,14 @@ "mocha": "^10.8.2", "prettier": "^3.0.0", "prettier-plugin-solidity": "^1.0.0", - "solhint": "^5.0.0", + "solhint": "^6.2.1", "solhint-plugin-prettier": "^0.1.0", "solidity-coverage": "^0.8.16", "solidity-docgen": "^0.6.0-beta.36", "ts-node": "^10.9.2", "typechain": "^8.3.2", "typescript": "^5.8.3", + "typescript-eslint": "^8.60.0", "viem": "^2.33.1" }, "files": [ diff --git a/scripts/setDefaultBlocks.ts b/scripts/setDefaultBlocks.ts index 7d45330..c4defa5 100644 --- a/scripts/setDefaultBlocks.ts +++ b/scripts/setDefaultBlocks.ts @@ -20,12 +20,22 @@ const main = async () => { } const [deployer] = await ethers.getSigners(); - console.log(`Signing transactions with ${deployer.address}`); + console.log( + `Signing transactions with ${deployer.address}`, + ); - const iface = new ethers.utils.Interface(P2PIX__factory.abi); - const calldata = iface.encodeFunctionData("setDefaultLockBlocks", ["10000"]); - - const tx = await deployer.sendTransaction({to:deploysJson.p2pix, data: calldata}); + const iface = new ethers.utils.Interface( + P2PIX__factory.abi, + ); + const calldata = iface.encodeFunctionData( + "setDefaultLockBlocks", + ["10000"], + ); + + const tx = await deployer.sendTransaction({ + to: deploysJson.p2pix, + data: calldata, + }); const done = await tx.wait(); console.log(done.transactionHash); }; diff --git a/test/Reputation.test.ts b/test/Reputation.test.ts index 339bbd0..fc4c88e 100644 --- a/test/Reputation.test.ts +++ b/test/Reputation.test.ts @@ -1,6 +1,5 @@ import "@nomicfoundation/hardhat-chai-matchers"; import { loadFixture } from "@nomicfoundation/hardhat-network-helpers"; -import { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers"; import { expect } from "chai"; import { ethers, network } from "hardhat"; @@ -8,14 +7,11 @@ import { Reputation } from "../src/types"; import { curve, repFixture } from "./utils/fixtures"; describe("Reputation", () => { - // contract deployer/admin - let owner: SignerWithAddress; // Reputation Interface instance; let reputation: Reputation; before("Set signers and reset network", async () => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [owner] = await ethers.getSigners(); + await ethers.getSigners(); await network.provider.send("hardhat_reset"); }); diff --git a/test/_.test.ts b/test/_.test.ts index df06161..ee28331 100644 --- a/test/_.test.ts +++ b/test/_.test.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-useless-escape */ - describe("_", () => { console.log( "/// ______ __\r\n/// .-----.|__ |.-----.|__|.--.--.\r\n/// | _ || __|| _ || ||_ _|\r\n/// | __||______|| __||__||__.__|\r\n/// |__| |__|\r\n///", diff --git a/test/p2pix.test.ts b/test/p2pix.test.ts index 912d994..104a6f3 100644 --- a/test/p2pix.test.ts +++ b/test/p2pix.test.ts @@ -22,12 +22,12 @@ import { Reputation, } from "../src/types"; import { P2PixErrors } from "./utils/errors"; -import { - // LockArgs, +import { + // LockArgs, // DepositArgs, - Call, - Lock, - Result + Call, + Lock, + Result, } from "./utils/interfaces"; import { getBnFrom, @@ -36,10 +36,7 @@ import { p2pixFixture, randomSigners, } from "./utils/fixtures"; -import { - parseEther, - stringToHex, -} from "viem"; +import { parseEther, stringToHex } from "viem"; describe("P2PIX", () => { type WalletWithAddress = Wallet & SignerWithAddress; @@ -62,10 +59,10 @@ describe("P2PIX", () => { let merkleRoot: string; // MerkleRoot from seller's allowlist let proof: string[]; // Owner's proof as whitelisted address - const fundAmount: BigInt = parseEther("10000"); - const price: BigInt = parseEther("100"); + const fundAmount: bigint = parseEther("10000"); + const price: bigint = parseEther("100"); - const zero = '0x0000000000000000000000000000000000000000'; + const zero = "0x0000000000000000000000000000000000000000"; before("Set signers and reset network", async () => { [owner, acc01, acc02, acc03] = @@ -90,15 +87,19 @@ describe("P2PIX", () => { expect(p2pix).to.be.ok; expect(erc20).to.be.ok; expect(reputation).to.be.ok; - const ownerKey = await p2pix._castAddrToKey(owner.address); - const acc01Key = await p2pix._castAddrToKey(acc01.address); + const ownerKey = await p2pix._castAddrToKey( + owner.address, + ); + const acc01Key = await p2pix._castAddrToKey( + acc01.address, + ); // storage checks expect( await p2pix.defaultLockBlocks.staticCall(), ).to.eq(10); expect(await p2pix.reputation.staticCall()).to.eq( - reputation.target + reputation.target, ); expect(await p2pix.lockCounter.staticCall()).to.eq(0); expect( @@ -165,17 +166,20 @@ describe("P2PIX", () => { expect(newBal).to.eq(price); const tx = p2pix.withdrawBalance(); + await expect(tx).to.changeEtherBalances( + [owner.address, p2pix.target], + [price, price * -1n], + ); await expect(tx) - .to.changeEtherBalances( - [owner.address, p2pix.target], - [price, price * -1n], - ); - await expect(tx).to.emit(p2pix, "FundsWithdrawn") + .to.emit(p2pix, "FundsWithdrawn") .withArgs(owner.address, price); await expect( p2pix.connect(acc01).withdrawBalance(), - ).to.be.revertedWithCustomError(p2pix, P2PixErrors.Unauthorized); + ).to.be.revertedWithCustomError( + p2pix, + P2PixErrors.Unauthorized, + ); }); it("should allow owner to change reputation instance", async () => { const tx = await p2pix.setReputation(acc03.address); @@ -285,11 +289,10 @@ describe("P2PIX", () => { p2pix, P2PixErrors.LengthMismatch, ); - await expect(mtcFail) - .to.be.revertedWithCustomError( - multicall, - P2PixErrors.CallFailed, - ); + await expect(mtcFail).to.be.revertedWithCustomError( + multicall, + P2PixErrors.CallFailed, + ); }); }); describe("Deposit", async () => { @@ -304,9 +307,15 @@ describe("P2PIX", () => { // token: owner.address, // amount: BigInt(1), // valid: true, - // }; + // }; - const tx = p2pix.deposit(pTarget, root, owner.address, BigInt(1), true); + const tx = p2pix.deposit( + pTarget, + root, + owner.address, + BigInt(1), + true, + ); await expect(tx).to.be.revertedWithCustomError( p2pix, @@ -318,7 +327,13 @@ describe("P2PIX", () => { ethers.toUtf8Bytes("root"), ); - const tx = p2pix.deposit("", root, erc20.target, BigInt(1), true); + const tx = p2pix.deposit( + "", + root, + erc20.target, + BigInt(1), + true, + ); await expect(tx).to.be.revertedWithCustomError( p2pix, @@ -330,7 +345,13 @@ describe("P2PIX", () => { const root = ethers.keccak256( ethers.toUtf8Bytes("root"), ); - const tx = p2pix.deposit(pTarget, root, erc20.target, parseEther("100000001"), true); + const tx = p2pix.deposit( + pTarget, + root, + erc20.target, + parseEther("100000001"), + true, + ); await expect(tx).to.be.revertedWithCustomError( p2pix, @@ -342,7 +363,7 @@ describe("P2PIX", () => { // we use `hashZero` to avoid updating seller's allowlist settings const root = ethers.ZeroHash; await erc20.approve(p2pix.target, price); - + const tx = await p2pix.deposit( pTarget, root, @@ -363,13 +384,14 @@ describe("P2PIX", () => { erc20.target, ); - const allowList = await p2pix.sellerAllowList(owner.address); + const allowList = await p2pix.sellerAllowList( + owner.address, + ); const balances = await p2pix.getBalances.staticCall( [owner.address, acc01.address], erc20.target, ); - expect(tx).to.be.ok; await expect(tx) .to.emit(p2pix, "DepositAdded") @@ -380,7 +402,9 @@ describe("P2PIX", () => { [price * -1n, price], ); expect(storage).to.eq(price); - expect(pixTarget).to.eq(stringToHex(pTarget,{size:32})); + expect(pixTarget).to.eq( + stringToHex(pTarget, { size: 32 }), + ); expect(valid).to.eq(true); expect(allowList).to.eq(root); expect(balances[0]).to.eq(price); @@ -388,7 +412,6 @@ describe("P2PIX", () => { }); // edge case test it("should create multiple deposits", async () => { - // const acc01Key = await p2pix._castAddrToKey.staticCall( // acc01.address, // ); @@ -411,7 +434,7 @@ describe("P2PIX", () => { const price2 = price * 2n; const price3 = price * 3n; const price4 = price * 4n; - const prices: BigInt[] = [ + const prices: bigint[] = [ price, price2, price3, @@ -421,9 +444,7 @@ describe("P2PIX", () => { getSignerAddrs(4, await ethers.getSigners()), price4, ); - await erc20 - .connect(owner) - .approve(p2pix.target, price); + await erc20.connect(owner).approve(p2pix.target, price); await erc20 .connect(acc01) .approve(p2pix.target, price2); @@ -440,29 +461,23 @@ describe("P2PIX", () => { const tx2 = await p2pix .connect(acc01) .deposit( - pTarget2, - nullRoot, - erc20.target, - price2, - false, + pTarget2, + nullRoot, + erc20.target, + price2, + false, ); const tx3 = await p2pix .connect(acc02) - .deposit( - pTarget3, - root, - erc20.target, - price3, - true, - ); + .deposit(pTarget3, root, erc20.target, price3, true); const tx4 = await p2pix .connect(acc03) .deposit( - pTarget, - nullRoot, - erc20.target, - price4, - false, + pTarget, + nullRoot, + erc20.target, + price4, + false, ); const balances = await p2pix.getBalances.staticCall( @@ -557,7 +572,8 @@ describe("P2PIX", () => { const tx = transactions[i]; const addr = addresses[i]; const depositPrice = depositPrices[i]; - const amount = parseEther("100") * BigInt(i+1) * -1n; + const amount = + parseEther("100") * BigInt(i + 1) * -1n; await expect(tx) .to.emit(p2pix, "DepositAdded") @@ -575,22 +591,30 @@ describe("P2PIX", () => { expect(prices[3]).to.eq(balances[3]); expect(storage1).to.eq(price); - expect(pixTarget1).to.eq(stringToHex(pTarget,{size:32})); + expect(pixTarget1).to.eq( + stringToHex(pTarget, { size: 32 }), + ); expect(valid1).to.eq(true); expect(allowList1).to.eq(root); expect(storage2).to.eq(price2); - expect(pixTarget2).to.eq(stringToHex(pTarget2,{size:32})); + expect(pixTarget2).to.eq( + stringToHex(pTarget2, { size: 32 }), + ); expect(valid2).to.eq(false); expect(allowList2).to.eq(nullRoot); expect(storage3).to.eq(price3); - expect(pixTarget3).to.eq(stringToHex(pTarget3,{size:32})); + expect(pixTarget3).to.eq( + stringToHex(pTarget3, { size: 32 }), + ); expect(valid3).to.eq(true); expect(allowList3).to.eq(root); expect(storage4).to.eq(price4); - expect(pixTarget4).to.eq(stringToHex(pTarget,{size:32})); + expect(pixTarget4).to.eq( + stringToHex(pTarget, { size: 32 }), + ); expect(valid4).to.eq(false); expect(allowList4).to.eq(nullRoot); }); @@ -600,35 +624,23 @@ describe("P2PIX", () => { const pTarget = "7ce3339x4133301u8f63pn71a5333118"; await erc20.approve(p2pix.target, price); await p2pix.deposit( - pTarget, - ethers.ZeroHash, - erc20.target, - price, - true, + pTarget, + ethers.ZeroHash, + erc20.target, + price, + true, ); await p2pix.setValidState(erc20.target, false); const fail = p2pix .connect(acc03) - .lock( - owner.address, - erc20.target, - price, - [], - [], - ); - const fail2 = p2pix.lock( - zero, - zero, - price, - [], - [], - ); + .lock(owner.address, erc20.target, price, [], []); + const fail2 = p2pix.lock(zero, zero, price, [], []); - expect(fail).to.be.revertedWithCustomError( + await expect(fail).to.be.revertedWithCustomError( p2pix, P2PixErrors.InvalidDeposit, ); - expect(fail2).to.be.revertedWithCustomError( + await expect(fail2).to.be.revertedWithCustomError( p2pix, P2PixErrors.InvalidDeposit, ); @@ -637,20 +649,20 @@ describe("P2PIX", () => { await erc20.approve(p2pix.target, price); const pTarget = "7ce3339x4133301u8f63pn71a5333118"; await p2pix.deposit( - pTarget, - ethers.ZeroHash, - erc20.target, - price, - true, + pTarget, + ethers.ZeroHash, + erc20.target, + price, + true, ); const fail = p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - price * 2n, - [], - [], + owner.address, + erc20.target, + price * 2n, + [], + [], ); await expect(fail).to.be.revertedWithCustomError( @@ -662,20 +674,20 @@ describe("P2PIX", () => { it("should revert if an invalid allowlist merkleproof is provided", async () => { await erc20.approve(p2pix.target, price); await p2pix.deposit( - "7ce3339x4133301u8f63pn71a5333118", - merkleRoot, - erc20.target, - price, - true, + "7ce3339x4133301u8f63pn71a5333118", + merkleRoot, + erc20.target, + price, + true, ); const fail = p2pix .connect(acc02) .lock( - owner.address, - erc20.target, - 1000n, - [ethers.keccak256(ethers.toUtf8Bytes("wrong"))], - [], + owner.address, + erc20.target, + 1000n, + [ethers.keccak256(ethers.toUtf8Bytes("wrong"))], + [], ); await expect(fail).to.be.revertedWithCustomError( @@ -684,25 +696,22 @@ describe("P2PIX", () => { ); }); it("should revert if msg.sender does not have enough credit in his spend limit", async () => { - await erc20.approve( - p2pix.target, - price * 3n, - ); + await erc20.approve(p2pix.target, price * 3n); await p2pix.deposit( - "1", - merkleRoot, - erc20.target, - price * 3n, - true, + "1", + merkleRoot, + erc20.target, + price * 3n, + true, ); const fail = p2pix .connect(acc02) .lock( - owner.address, - erc20.target, - price * 2n, - [], - [], + owner.address, + erc20.target, + price * 2n, + [], + [], ); await expect(fail).to.be.revertedWithCustomError( @@ -714,24 +723,17 @@ describe("P2PIX", () => { const target = "333"; await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); const tx = await p2pix .connect(acc01) - .lock( - owner.address, - erc20.target, - price, - proof, - [], - ); - const storage: Lock = await p2pix.mapLocks.staticCall( - 1, - ); + .lock(owner.address, erc20.target, price, proof, []); + const storage: Lock = + await p2pix.mapLocks.staticCall(1); const rc: ContractTransactionReceipt = await tx.wait(); const expiration = rc.blockNumber + 10; @@ -749,7 +751,9 @@ describe("P2PIX", () => { expect(storage.counter).to.eq(1); expect(storage.amount).to.eq(price); expect(storage.expirationBlock).to.eq(expiration); - expect(storage.pixTarget).to.eq(stringToHex(target,{size:32})); + expect(storage.pixTarget).to.eq( + stringToHex(target, { size: 32 }), + ); expect(storage.buyerAddress).to.eq(acc01.address); expect(storage.token).to.eq(erc20.target); }); @@ -758,33 +762,25 @@ describe("P2PIX", () => { const target = "101"; await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - root, - erc20.target, - price, - true, + target, + root, + erc20.target, + price, + true, ); const tx = await p2pix .connect(acc01) - .lock( - owner.address, - erc20.target, - price, - [], - [], - ); - const storage: Lock = await p2pix.mapLocks.staticCall( - 1, - ); + .lock(owner.address, erc20.target, price, [], []); + const storage: Lock = + await p2pix.mapLocks.staticCall(1); const rc: ContractTransactionReceipt = await tx.wait(); const expiration = rc.blockNumber + 10; const key = await p2pix._castAddrToKey.staticCall( owner.address, ); - const castBack = await p2pix._castKeyToAddr.staticCall( - key, - ); + const castBack = + await p2pix._castKeyToAddr.staticCall(key); expect(tx).to.be.ok; expect(castBack).to.eq(owner.address); @@ -792,13 +788,20 @@ describe("P2PIX", () => { expect(storage.counter).to.eq(1); expect(storage.amount).to.eq(price); expect(storage.expirationBlock).to.eq(expiration); - expect(storage.pixTarget).to.eq(stringToHex(target,{size:32})); + expect(storage.pixTarget).to.eq( + stringToHex(target, { size: 32 }), + ); expect(storage.buyerAddress).to.eq(acc01.address); expect(storage.token).to.eq(erc20.target); await expect(tx) .to.emit(p2pix, "LockAdded") - .withArgs(acc01.address, 1, owner.address, storage.amount); + .withArgs( + acc01.address, + 1, + owner.address, + storage.amount, + ); }); it("should create a lock, update storage and emit events via the reputation path 2", async () => { const root = ethers.ZeroHash; @@ -807,75 +810,71 @@ describe("P2PIX", () => { const target = "101"; const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(target, { size: 32 }), price, endtoendID], + [ + stringToHex(target, { size: 32 }), + price, + endtoendID, + ], ); - const messageHashBytes = - ethers.getBytes(messageToSign); + const messageHashBytes = ethers.getBytes(messageToSign); const flatSig = await acc01.signMessage( messageHashBytes, ); // const sig = ethers.utils.splitSignature(flatSig); await erc20.approve(p2pix.target, newPrice); await p2pix.deposit( - target, - root, - erc20.target, - newPrice, - true, + target, + root, + erc20.target, + newPrice, + true, ); await p2pix .connect(acc01) - .lock( - owner.address, - erc20.target, - price, - [], - [], - ); + .lock(owner.address, erc20.target, price, [], []); await p2pix .connect(acc01) - .release( - BigInt(1), - endtoendID, - flatSig - ); + .release(BigInt(1), endtoendID, flatSig); const tx = await p2pix .connect(acc01) .lock( - owner.address, - erc20.target, - price + 1n, - [], - [], + owner.address, + erc20.target, + price + 1n, + [], + [], ); - const storage: Lock = await p2pix.mapLocks.staticCall( - 2, - ); + const storage: Lock = + await p2pix.mapLocks.staticCall(2); const rc: ContractTransactionReceipt = await tx.wait(); const expiration = rc.blockNumber + 10; const key = await p2pix._castAddrToKey.staticCall( owner.address, ); - const castBack = await p2pix._castKeyToAddr.staticCall( - key, - ); + const castBack = + await p2pix._castKeyToAddr.staticCall(key); expect(tx).to.be.ok; expect(castBack).to.eq(owner.address); expect(storage.seller).to.eq(owner.address); expect(storage.counter).to.eq(2); - expect(storage.amount).to.eq( - price+1n, - ); + expect(storage.amount).to.eq(price + 1n); expect(storage.expirationBlock).to.eq(expiration); - expect(storage.pixTarget).to.eq(stringToHex(target,{size:32})); + expect(storage.pixTarget).to.eq( + stringToHex(target, { size: 32 }), + ); expect(storage.buyerAddress).to.eq(acc01.address); expect(storage.token).to.eq(erc20.target); await expect(tx) .to.emit(p2pix, "LockAdded") - .withArgs(acc01.address, 2, owner.address, storage.amount); + .withArgs( + acc01.address, + 2, + owner.address, + storage.amount, + ); }); // edge case test it("should create multiple locks", async () => { @@ -883,58 +882,58 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); const tx1 = await p2pix .connect(acc01) .lock( - owner.address, - erc20.target, - newPrice, - proof, - [], + owner.address, + erc20.target, + newPrice, + proof, + [], ); - const storage1: Lock = await p2pix.mapLocks.staticCall( - 1, - ); + const storage1: Lock = + await p2pix.mapLocks.staticCall(1); - const rc1: ContractTransactionReceipt = await tx1.wait(); + const rc1: ContractTransactionReceipt = + await tx1.wait(); const expiration1 = rc1.blockNumber + 10; const tx2 = await p2pix .connect(acc01) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); - const storage2: Lock = await p2pix.mapLocks.staticCall( - 2, - ); + const storage2: Lock = + await p2pix.mapLocks.staticCall(2); - const rc2: ContractTransactionReceipt = await tx2.wait(); + const rc2: ContractTransactionReceipt = + await tx2.wait(); const expiration2 = rc2.blockNumber + 10; const tx3 = await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); - const storage3: Lock = await p2pix.mapLocks.staticCall( - 3, - ); + const storage3: Lock = + await p2pix.mapLocks.staticCall(3); - const rc3: ContractTransactionReceipt = await tx3.wait(); + const rc3: ContractTransactionReceipt = + await tx3.wait(); const expiration3 = rc3.blockNumber + 10; // const key = await p2pix._castAddrToKey.staticCall( @@ -947,24 +946,24 @@ describe("P2PIX", () => { // const lockStatus4 = await p2pix.getLocksStatus.staticCall([]); // All getLocksStatus calls were batched via the Multicall contract. - const ls1: [BigInt[], BigInt[]] = [ + const ls1: [bigint[], bigint[]] = [ getBnFrom([1, 7, 7, 2, 3, 4, 5, 5, 2, 3]), getBnFrom([1, 0, 0, 1, 1, 0, 0, 0, 1, 1]), ]; - const ls2: [BigInt[], BigInt[]] = [ + const ls2: [bigint[], bigint[]] = [ getBnFrom([0, 1, 2, 3]), getBnFrom([0, 1, 1, 1]), ]; - const ls3: [BigInt[], BigInt[]] = [ + const ls3: [bigint[], bigint[]] = [ getBnFrom([7, 7, 333, 14, 777]), getBnFrom([0, 0, 0, 0, 0]), ]; const ls4 = [[], []]; - const batchedLocks: Array = [ + const batchedLocks: Array = [ ls1, ls2, ls3, @@ -976,15 +975,11 @@ describe("P2PIX", () => { batchedLocks, ); - const batchCall = await multicall.mtc1.staticCall( - cData, - ); + const batchCall = + await multicall.mtc1.staticCall(cData); const blockNumber = batchCall[0]; - const result: Array = batchCall[1].slice( - 0, - 4, - ); + const result: Array = batchCall[1].slice(0, 4); const decodedData = result.map(r => ethers.AbiCoder.defaultAbiCoder().decode( @@ -1023,7 +1018,7 @@ describe("P2PIX", () => { expect(storage2.expirationBlock).to.eq(expiration2); expect(storage3.expirationBlock).to.eq(expiration3); - expect(stringToHex(target,{size:32})) + expect(stringToHex(target, { size: 32 })) .to.eq(storage1.pixTarget) .and.to.eq(storage2.pixTarget) .and.to.eq(storage3.pixTarget); @@ -1040,13 +1035,28 @@ describe("P2PIX", () => { await expect(tx1) .to.emit(p2pix, "LockAdded") - .withArgs(acc01.address, 1, owner.address, storage1.amount); + .withArgs( + acc01.address, + 1, + owner.address, + storage1.amount, + ); await expect(tx2) .to.emit(p2pix, "LockAdded") - .withArgs(acc01.address, 2, owner.address, storage2.amount); + .withArgs( + acc01.address, + 2, + owner.address, + storage2.amount, + ); await expect(tx3) .to.emit(p2pix, "LockAdded") - .withArgs(acc03.address, 3, owner.address, storage3.amount); + .withArgs( + acc03.address, + 3, + owner.address, + storage3.amount, + ); }); }); describe("Set sellerBalance Valid State", async () => { @@ -1061,11 +1071,11 @@ describe("P2PIX", () => { it("should setValidState, update storage and emit events", async () => { await erc20.approve(p2pix.target, price); await p2pix.deposit( - BigInt(10101).toString(), - merkleRoot, - erc20.target, - price, - true, + BigInt(10101).toString(), + merkleRoot, + erc20.target, + price, + true, ); const state1 = await p2pix.getValid.staticCall( owner.address, @@ -1093,15 +1103,13 @@ describe("P2PIX", () => { const target = BigInt(1).toString(); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - hashZero, - erc20.target, - price, - true, + target, + hashZero, + erc20.target, + price, + true, ); - await erc20 - .connect(acc01) - .approve(p2pix.target, price); + await erc20.connect(acc01).approve(p2pix.target, price); await p2pix .connect(acc01) .deposit( @@ -1111,18 +1119,10 @@ describe("P2PIX", () => { price, false, ); - await erc20 - .connect(acc02) - .approve(p2pix.target, price); + await erc20.connect(acc02).approve(p2pix.target, price); await p2pix .connect(acc02) - .deposit( - target, - hashZero, - erc20.target, - price, - true, - ); + .deposit(target, hashZero, erc20.target, price, true); const oldState1 = await p2pix.getValid.staticCall( owner.address, erc20.target, @@ -1191,28 +1191,28 @@ describe("P2PIX", () => { // const sig = ethers.utils.splitSignature(flatSig); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); const lockID = BigInt(1); await mine(13); const fail = p2pix.release( - lockID, - ethers.ZeroHash, - flatSig, - ); + lockID, + ethers.ZeroHash, + flatSig, + ); await expect(fail).to.be.revertedWithCustomError( p2pix, @@ -1224,7 +1224,7 @@ describe("P2PIX", () => { const hashZero = ethers.ZeroHash; const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(target,{size:32}), 100, hashZero], + [stringToHex(target, { size: 32 }), 100, hashZero], ); const flatSig = await acc01.signMessage( ethers.getBytes(messageToSign), @@ -1232,31 +1232,27 @@ describe("P2PIX", () => { // const sig = ethers.utils.splitSignature(flatSig); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); const lockID = BigInt(1); - await p2pix.release( - lockID, - ethers.ZeroHash, - flatSig - ); + await p2pix.release(lockID, ethers.ZeroHash, flatSig); const fail = p2pix.release( - lockID, - ethers.ZeroHash, - flatSig, + lockID, + ethers.ZeroHash, + flatSig, ); await expect(fail).to.be.revertedWithCustomError( @@ -1268,7 +1264,11 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(target,{size:32}), 100, ethers.ZeroHash], + [ + stringToHex(target, { size: 32 }), + 100, + ethers.ZeroHash, + ], ); const flatSig = await owner.signMessage( ethers.getBytes(messageToSign), @@ -1276,45 +1276,37 @@ describe("P2PIX", () => { // const sig = ethers.utils.splitSignature(flatSig); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - ethers.ZeroHash, - erc20.target, - price, - true, + target, + ethers.ZeroHash, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); await p2pix .connect(acc01) - .release( - BigInt(1), - ethers.ZeroHash, - flatSig, - ); + .release(BigInt(1), ethers.ZeroHash, flatSig); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); const fail = p2pix .connect(acc01) - .release( - BigInt(2), - ethers.ZeroHash, - flatSig, - ); + .release(BigInt(2), ethers.ZeroHash, flatSig); await expect(fail).to.be.revertedWithCustomError( p2pix, @@ -1325,7 +1317,11 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(target,{size:32}), 100, ethers.ZeroHash], + [ + stringToHex(target, { size: 32 }), + 100, + ethers.ZeroHash, + ], ); const flatSig = await acc03.signMessage( ethers.getBytes(messageToSign), @@ -1334,28 +1330,24 @@ describe("P2PIX", () => { await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - ethers.ZeroHash, - erc20.target, - price, - true, + target, + ethers.ZeroHash, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); const fail = p2pix .connect(acc01) - .release( - BigInt(1), - ethers.ZeroHash, - flatSig, - ); + .release(BigInt(1), ethers.ZeroHash, flatSig); await expect(fail).to.be.revertedWithCustomError( p2pix, @@ -1368,7 +1360,11 @@ describe("P2PIX", () => { const pixTarget = BigInt(101).toString(); const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(pixTarget,{size:32}), 100, endtoendID], + [ + stringToHex(pixTarget, { size: 32 }), + 100, + endtoendID, + ], ); // Note: messageToSign is a string, that is 66-bytes long, to sign the // binary value, we must convert it to the 32 byte Array that @@ -1380,8 +1376,7 @@ describe("P2PIX", () => { // ... vs ... // 32 entry Uint8Array // [ 89, 47, 167, 67, 136, 159, ... 103, 7, 186] - const messageHashBytes = - ethers.getBytes(messageToSign); + const messageHashBytes = ethers.getBytes(messageToSign); const flatSig = await acc01.signMessage( messageHashBytes, ); @@ -1390,20 +1385,20 @@ describe("P2PIX", () => { await erc20.approve(p2pix.target, price); await p2pix.deposit( - pixTarget, - root, - erc20.target, - price, - true, + pixTarget, + root, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); const acc01Key = await p2pix._castAddrToKey.staticCall( acc01.address, @@ -1411,44 +1406,36 @@ describe("P2PIX", () => { const acc03Key = await p2pix._castAddrToKey.staticCall( acc03.address, ); - const userRecordA = await p2pix.userRecord.staticCall( - acc01Key, - ); - const userRecord1 = await p2pix.userRecord.staticCall( - acc03Key, - ); + const userRecordA = + await p2pix.userRecord.staticCall(acc01Key); + const userRecord1 = + await p2pix.userRecord.staticCall(acc03Key); const storage1: Lock = await p2pix.mapLocks.staticCall( BigInt(1), ); const tx = await p2pix .connect(acc01) - .release( - BigInt(1), - endtoendID, - flatSig, - ); + .release(BigInt(1), endtoendID, flatSig); const lockStatus1 = await p2pix.getLocksStatus.staticCall([1]); - const ls1: [BigInt[], number[]] = [ - [BigInt(1)], - [3], - ]; + const ls1: [bigint[], number[]] = [[BigInt(1)], [3]]; const funcSig = "0xd6e8b973"; const args = ethers.AbiCoder.defaultAbiCoder().encode( ["address[]", "bool[]"], [[acc01.address], [false]], ); const cd1 = funcSig + args.substring(2); - const cd2: Call[] = getLockData(p2pix.target as string, [ - ls1[0], - ]); + const cd2: Call[] = getLockData( + p2pix.target as string, + [ls1[0]], + ); const mtcCalls = [ { target: p2pix.target, callData: cd1 }, ]; mtcCalls.push(cd2[0]); const mtc2 = await multicall.mtc2.staticCall(mtcCalls); - const blockNumber: BigInt = mtc2[0]; + const blockNumber: bigint = mtc2[0]; const blockhash: Bytes = mtc2[1]; const result = mtc2.slice(2).flat(1) as Result[]; const res1: Bytes[] = [result[1].returnData]; @@ -1459,32 +1446,21 @@ describe("P2PIX", () => { ), ); - const storage2: Lock = await p2pix.mapLocks.staticCall( - 1, - ); - const userRecordB = await p2pix.userRecord.staticCall( - acc01Key, - ); - const userRecord2 = await p2pix.userRecord.staticCall( - acc03Key, - ); + const storage2: Lock = + await p2pix.mapLocks.staticCall(1); + const userRecordB = + await p2pix.userRecord.staticCall(acc01Key); + const userRecord2 = + await p2pix.userRecord.staticCall(acc03Key); const used = await p2pix.usedTransactions.staticCall( messageHashBytes, ); expect(tx).to.be.ok; await expect(tx) .to.emit(p2pix, "LockReleased") - .withArgs( - acc03.address, - BigInt(1), - storage1.amount, - ); - expect(storage1.expirationBlock).to.eq( - BigInt(17), - ); - expect(storage1.amount).to.eq( - BigInt(100), - ); + .withArgs(acc03.address, BigInt(1), storage1.amount); + expect(storage1.expirationBlock).to.eq(BigInt(17)); + expect(storage1.amount).to.eq(BigInt(100)); expect(lockStatus1[0].toString()).to.equal( ls1[0].toString(), ); @@ -1492,9 +1468,7 @@ describe("P2PIX", () => { ls1[1].toString(), ); expect(blockNumber).to.eq(8); - expect(blockhash).to.deep.equal( - ethers.ZeroHash, - ); + expect(blockhash).to.deep.equal(ethers.ZeroHash); expect(result[0].success).to.eq(false); expect(result[1].success).to.eq(true); expect(decodedLockData.flat(1)).to.deep.eq(ls1); @@ -1507,7 +1481,7 @@ describe("P2PIX", () => { expect(userRecord2).to.eq(BigInt(50)); await expect(tx).to.changeTokenBalances( erc20, - [acc03.address, acc01.address, acc02.address ], + [acc03.address, acc01.address, acc02.address], [100, 0, 0], ); }); @@ -1522,15 +1496,17 @@ describe("P2PIX", () => { const acc03Key = await p2pix._castAddrToKey.staticCall( acc03.address, ); - const acc01Record1 = await p2pix.userRecord.staticCall( - acc01Key, - ); - const acc03Record1 = await p2pix.userRecord.staticCall( - acc03Key, - ); + const acc01Record1 = + await p2pix.userRecord.staticCall(acc01Key); + const acc03Record1 = + await p2pix.userRecord.staticCall(acc03Key); const messageToSign1 = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(pixTarget,{size:32}), 100, endtoendID], + [ + stringToHex(pixTarget, { size: 32 }), + 100, + endtoendID, + ], ); const flatSig1 = await owner.signMessage( ethers.getBytes(messageToSign1), @@ -1538,7 +1514,11 @@ describe("P2PIX", () => { // const sig1 = ethers.utils.splitSignature(flatSig1); const messageToSign2 = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(pixTarget,{size:32}), 50, endtoendID], + [ + stringToHex(pixTarget, { size: 32 }), + 50, + endtoendID, + ], ); const flatSig2 = await owner.signMessage( ethers.getBytes(messageToSign2), @@ -1546,7 +1526,11 @@ describe("P2PIX", () => { // const sig2 = ethers.utils.splitSignature(flatSig2); const messageToSign3 = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(pixTarget,{size:32}), 25, endtoendID], + [ + stringToHex(pixTarget, { size: 32 }), + 25, + endtoendID, + ], ); const flatSig3 = await owner.signMessage( ethers.getBytes(messageToSign3), @@ -1554,90 +1538,70 @@ describe("P2PIX", () => { // const sig3 = ethers.utils.splitSignature(flatSig3); await erc20.approve(p2pix.target, price); await p2pix.deposit( - pixTarget, - root, - erc20.target, - price, - true, + pixTarget, + root, + erc20.target, + price, + true, ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(100), - [], - [], + owner.address, + erc20.target, + BigInt(100), + [], + [], ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(50), - [], - [], + owner.address, + erc20.target, + BigInt(50), + [], + [], ); await p2pix .connect(acc03) .lock( - owner.address, - erc20.target, - BigInt(25), - [], - [], + owner.address, + erc20.target, + BigInt(25), + [], + [], ); const lockStatus1 = await p2pix.getLocksStatus.staticCall([1, 2, 3, 44]); - const ls1: [BigInt[], BigInt[]] = [ - [ - BigInt(1), - BigInt(2), - BigInt(3), - BigInt(44), - ], + const ls1: [bigint[], bigint[]] = [ + [BigInt(1), BigInt(2), BigInt(3), BigInt(44)], getBnFrom([1, 1, 1, 0]), ]; const lockID = BigInt(1); const lockID2 = BigInt(2); const lockID3 = BigInt(3); - const storage1: Lock = await p2pix.mapLocks.staticCall( - lockID, - ); - const storage2: Lock = await p2pix.mapLocks.staticCall( - lockID2, - ); - const storage3: Lock = await p2pix.mapLocks.staticCall( - lockID3, - ); + const storage1: Lock = + await p2pix.mapLocks.staticCall(lockID); + const storage2: Lock = + await p2pix.mapLocks.staticCall(lockID2); + const storage3: Lock = + await p2pix.mapLocks.staticCall(lockID3); // relayerPremium == 0 const tx = await p2pix .connect(acc01) - .release( - lockID, - endtoendID, - flatSig1, - ); + .release(lockID, endtoendID, flatSig1); // relayerPremium != 0 && // lock's msg.sender != release's msg.sender const tx1 = await p2pix .connect(acc01) - .release( - lockID2, - endtoendID, - flatSig2, - ); + .release(lockID2, endtoendID, flatSig2); // relayerPremium != 0 && // lock's msg.sender == release's msg.sender const tx2 = await p2pix .connect(acc03) - .release( - lockID3, - endtoendID, - flatSig3, - ); + .release(lockID3, endtoendID, flatSig3); const used1 = await p2pix.usedTransactions.staticCall( ethers.getBytes(messageToSign1), ); @@ -1647,26 +1611,19 @@ describe("P2PIX", () => { const used3 = await p2pix.usedTransactions.staticCall( ethers.getBytes(messageToSign3), ); - const acc01Record2 = await p2pix.userRecord.staticCall( - acc01Key, - ); - const acc03Record2 = await p2pix.userRecord.staticCall( - acc03Key, - ); + const acc01Record2 = + await p2pix.userRecord.staticCall(acc01Key); + const acc03Record2 = + await p2pix.userRecord.staticCall(acc03Key); const lockStatus2 = await p2pix.getLocksStatus.staticCall([1, 2, 3, 44]); - const ls2: [BigInt[], BigInt[]] = [ - [ - BigInt(1), - BigInt(2), - BigInt(3), - BigInt(44), - ], + const ls2: [bigint[], bigint[]] = [ + [BigInt(1), BigInt(2), BigInt(3), BigInt(44)], getBnFrom([3, 3, 3, 0]), ]; - const batchedLocks: Array = [ + const batchedLocks: Array = [ ls1.slice(0, 1)[0], ls2.slice(0, 1)[0], ]; @@ -1741,21 +1698,15 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); await p2pix .connect(acc02) - .lock( - owner.address, - erc20.target, - BigInt(1), - [], - [], - ); + .lock(owner.address, erc20.target, BigInt(1), [], []); const lockID = BigInt(1); const fail = p2pix.unlockExpired([lockID]); @@ -1769,38 +1720,27 @@ describe("P2PIX", () => { const pixTarget = BigInt(101).toString(); const messageToSign = ethers.solidityPackedKeccak256( ["bytes32", "uint80", "bytes32"], - [stringToHex(pixTarget,{size:32}), 1, endtoendID], + [stringToHex(pixTarget, { size: 32 }), 1, endtoendID], ); - const messageHashBytes = - ethers.getBytes(messageToSign); + const messageHashBytes = ethers.getBytes(messageToSign); const flatSig = await acc01.signMessage( messageHashBytes, ); // const sig = ethers.utils.splitSignature(flatSig); await erc20.approve(p2pix.target, price); await p2pix.deposit( - pixTarget, - merkleRoot, - erc20.target, - price, - true, + pixTarget, + merkleRoot, + erc20.target, + price, + true, ); await p2pix .connect(acc02) - .lock( - owner.address, - erc20.target, - BigInt(1), - [], - [], - ); + .lock(owner.address, erc20.target, BigInt(1), [], []); const lockID = BigInt(1); // await mine(10); - await p2pix.release( - lockID, - endtoendID, - flatSig, - ); + await p2pix.release(lockID, endtoendID, flatSig); const fail = p2pix.unlockExpired([lockID]); await expect(fail).to.be.revertedWithCustomError( @@ -1812,51 +1752,37 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); await p2pix .connect(acc02) - .lock( - owner.address, - erc20.target, - BigInt(1), - [], - [], - ); + .lock(owner.address, erc20.target, BigInt(1), [], []); const lockID = BigInt(1); await mine(11); const lockStatus1 = await p2pix.getLocksStatus.staticCall([11, 1, 777]); - const ls1: [BigInt[], BigInt[]] = [ - [ - BigInt(11), - BigInt(1), - BigInt(777), - ], + const ls1: [bigint[], bigint[]] = [ + [BigInt(11), BigInt(1), BigInt(777)], getBnFrom([0, 2, 0]), ]; - const storage: Lock = await p2pix.mapLocks.staticCall( - lockID, - ); + const storage: Lock = + await p2pix.mapLocks.staticCall(lockID); const userKey = await p2pix._castAddrToKey.staticCall( acc02.address, ); - const record1 = await p2pix.userRecord.staticCall( - userKey, - ); + const record1 = + await p2pix.userRecord.staticCall(userKey); const tx = await p2pix.unlockExpired([lockID]); - const storage2: Lock = await p2pix.mapLocks.staticCall( - lockID, - ); - const record2 = await p2pix.userRecord.staticCall( - userKey, - ); + const storage2: Lock = + await p2pix.mapLocks.staticCall(lockID); + const record2 = + await p2pix.userRecord.staticCall(userKey); expect(tx).to.be.ok; await expect(tx) @@ -1875,28 +1801,23 @@ describe("P2PIX", () => { // test method through lock fx await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); const lock1: ContractTransactionResponse = await p2pix .connect(acc01) - .lock( - owner.address, - erc20.target, - price, - proof, - [], - ); + .lock(owner.address, erc20.target, price, proof, []); // as return values of non view functions can't be accessed // outside the evm, we fetch the lockID from the emitted event. - const rc: ContractTransactionReceipt = await lock1.wait() as ContractTransactionReceipt; + const rc: ContractTransactionReceipt = + (await lock1.wait()) as ContractTransactionReceipt; const event = rc.logs?.find( log => log.fragment.name === "LockAdded", ); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const emittedLockID = event?.args!["lockID"]; const lockID = BigInt(1); @@ -1923,11 +1844,11 @@ describe("P2PIX", () => { // create another lock by freeing the price value // back to `l.remamining` and lock 100 again. const tx1 = await p2pix.lock( - owner.address, - erc20.target, - BigInt(100), - [], - [lockID], + owner.address, + erc20.target, + BigInt(100), + [], + [lockID], ); const remaining = await p2pix.getBalance.staticCall( owner.address, @@ -1938,9 +1859,7 @@ describe("P2PIX", () => { await expect(tx1) .to.emit(p2pix, "LockReturned") .withArgs(acc01.address, lockID); - expect(remaining).to.eq( - price - 100n, - ); + expect(remaining).to.eq(price - 100n); }); it("should unlock expired through withdraw function", async () => { const target = "1"; @@ -1955,13 +1874,7 @@ describe("P2PIX", () => { ); await p2pix .connect(acc01) - .lock( - owner.address, - erc20.target, - price, - proof, - [], - ); + .lock(owner.address, erc20.target, price, proof, []); const lockID = BigInt(1); // mine blocks to expire lock await mine(11); @@ -1986,19 +1899,15 @@ describe("P2PIX", () => { const target = BigInt(101).toString(); await erc20.approve(p2pix.target, price); await p2pix.deposit( - target, - merkleRoot, - erc20.target, - price, - true, + target, + merkleRoot, + erc20.target, + price, + true, ); const fail = p2pix .connect(acc02) - .withdraw( - erc20.target, - price * 2n, - [], - ); + .withdraw(erc20.target, price * 2n, []); await expect(fail).to.be.revertedWithCustomError( p2pix, @@ -2009,11 +1918,11 @@ describe("P2PIX", () => { const newPrice = price / 2n; await erc20.approve(p2pix.target, price); const dep = await p2pix.deposit( - BigInt(101).toString(), - merkleRoot, - erc20.target, - price, - true, + BigInt(101).toString(), + merkleRoot, + erc20.target, + price, + true, ); const tx = await p2pix.withdraw( erc20.target, @@ -2022,25 +1931,26 @@ describe("P2PIX", () => { ); expect(tx).to.be.ok; - await expect(dep) - .to.changeTokenBalance( - erc20, - owner.address, - price * -1n, - ); await expect(dep).to.changeTokenBalance( - erc20, - p2pix.target, - price, - ); - await expect(tx) - .to.changeTokenBalance(erc20, owner.address, newPrice); - await expect(tx) - .to.changeTokenBalance( - erc20, - p2pix.target, - (price/2n) * -1n, - ); + erc20, + owner.address, + price * -1n, + ); + await expect(dep).to.changeTokenBalance( + erc20, + p2pix.target, + price, + ); + await expect(tx).to.changeTokenBalance( + erc20, + owner.address, + newPrice, + ); + await expect(tx).to.changeTokenBalance( + erc20, + p2pix.target, + (price / 2n) * -1n, + ); await expect(tx) .to.emit(p2pix, "DepositWithdrawn") @@ -2063,7 +1973,6 @@ describe("P2PIX", () => { ); }); it("should set root of seller's allowlist, update storage and emit event", async () => { - const oldState = await p2pix.sellerAllowList.staticCall( owner.address, ); diff --git a/test/utils/fixtures.ts b/test/utils/fixtures.ts index 8fb483a..d5e5a19 100644 --- a/test/utils/fixtures.ts +++ b/test/utils/fixtures.ts @@ -4,15 +4,13 @@ import { ethers } from "hardhat"; import keccak256 from "keccak256"; import { MerkleTree } from "merkletreejs"; -import { - MockToken, - Multicall, - P2PIX, - P2PIX__factory, - Reputation, -} from "../../src/types"; +import { MockToken, P2PIX__factory } from "../../src/types"; -import { Call, RepFixture, P2PixAndReputation, DepositArgs, LockArgs, ReleaseArgs } from "./interfaces"; +import { + Call, + RepFixture, + P2PixAndReputation, +} from "./interfaces"; // exported constants export const getSignerAddrs = ( @@ -22,18 +20,16 @@ export const getSignerAddrs = ( return addrs.slice(0, amount).map(({ address }) => address); }; -export const getBnFrom = (nums: number[]): BigInt[] => { +export const getBnFrom = (nums: number[]): bigint[] => { const bns = nums.map(num => BigInt(num)); return bns; }; export const getLockData = ( addr: string, - locks: BigInt[][], + locks: bigint[][], ): Call[] => { - const iface = new ethers.Interface( - P2PIX__factory.abi, - ); + const iface = new ethers.Interface(P2PIX__factory.abi); return locks.map(lock => ({ target: addr, callData: iface.encodeFunctionData("getLocksStatus", [ @@ -71,8 +67,9 @@ export const curve = (x: number): number => { // exported async functions export async function repFixture(): Promise { - const reputation = await ethers.deployContract("Reputation"); - return { reputation: await reputation.waitForDeployment() }; + const reputation = + await ethers.deployContract("Reputation"); + return { reputation: await reputation.waitForDeployment() }; } export async function p2pixFixture(): Promise { @@ -81,11 +78,12 @@ export async function p2pixFixture(): Promise { await ethers.getSigners(), ); - const reputation = await ethers.deployContract("Reputation"); + const reputation = + await ethers.deployContract("Reputation"); - const erc20 = await ethers.deployContract("MockToken", [ - ethers.parseEther("20000000") // 20M - ]) as MockToken; + const erc20 = (await ethers.deployContract("MockToken", [ + ethers.parseEther("20000000"), // 20M + ])) as MockToken; const p2pix = await ethers.deployContract("P2PIX", [ 10, diff --git a/test/utils/interfaces.ts b/test/utils/interfaces.ts index 95906a0..9bfa0e9 100644 --- a/test/utils/interfaces.ts +++ b/test/utils/interfaces.ts @@ -5,7 +5,6 @@ import { Reputation, } from "../../src/types"; - // exported interfaces export interface Deploys { signers: string[]; @@ -17,29 +16,29 @@ export interface DepositArgs { pixTarget: string; allowlistRoot: string; token: string; - amount: BigInt; + amount: bigint; valid: boolean; -} +} export interface LockArgs { seller: string; token: string; - amount: BigInt; + amount: bigint; merkleProof: string[]; - expiredLocks: BigInt[]; + expiredLocks: bigint[]; } export interface ReleaseArgs { - lockID: BigInt; + lockID: bigint; pixTimestamp: string; signature: string; } export interface Lock { - counter: BigInt; - expirationBlock: BigInt; + counter: bigint; + expirationBlock: bigint; pixTarget: string; - amount: BigInt; + amount: bigint; token: string; buyerAddress: string; seller: string; @@ -72,4 +71,4 @@ export interface MtcFixture { export type P2PixAndReputation = P2pixFixture & RepFixture & - MtcFixture; \ No newline at end of file + MtcFixture; diff --git a/yarn.lock b/yarn.lock index 1cc3313..8de8931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -64,6 +64,17 @@ __metadata: languageName: node linkType: hard +"@eslint-community/eslint-utils@npm:^4.9.1": + version: 4.9.1 + resolution: "@eslint-community/eslint-utils@npm:4.9.1" + dependencies: + eslint-visitor-keys: "npm:^3.4.3" + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + checksum: 10/863b5467868551c9ae34d03eefe634633d08f623fc7b19d860f8f26eb6f303c1a5934253124163bee96181e45ed22bf27473dccc295937c3078493a4a8c9eddd + languageName: node + linkType: hard + "@eslint-community/regexpp@npm:^4.12.1": version: 4.12.1 resolution: "@eslint-community/regexpp@npm:4.12.1" @@ -71,6 +82,13 @@ __metadata: languageName: node linkType: hard +"@eslint-community/regexpp@npm:^4.12.2": + version: 4.12.2 + resolution: "@eslint-community/regexpp@npm:4.12.2" + checksum: 10/049b280fddf71dd325514e0a520024969431dc3a8b02fa77476e6820e9122f28ab4c9168c11821f91a27982d2453bcd7a66193356ea84e84fb7c8d793be1ba0c + languageName: node + linkType: hard + "@eslint/config-array@npm:^0.21.0": version: 0.21.0 resolution: "@eslint/config-array@npm:0.21.0" @@ -1229,7 +1247,7 @@ __metadata: languageName: node linkType: hard -"@solidity-parser/parser@npm:^0.20.0, @solidity-parser/parser@npm:^0.20.1": +"@solidity-parser/parser@npm:^0.20.1, @solidity-parser/parser@npm:^0.20.2": version: 0.20.2 resolution: "@solidity-parser/parser@npm:0.20.2" checksum: 10/405009cd712cc410df60e45510ddd2ca615d208b152903be71cef4b9440720287ffd3792f88a92eb0de375c2ea66b442e84c843cb810612d6b6e45fd51a2b49b @@ -1439,6 +1457,141 @@ __metadata: languageName: node linkType: hard +"@typescript-eslint/eslint-plugin@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/eslint-plugin@npm:8.60.0" + dependencies: + "@eslint-community/regexpp": "npm:^4.12.2" + "@typescript-eslint/scope-manager": "npm:8.60.0" + "@typescript-eslint/type-utils": "npm:8.60.0" + "@typescript-eslint/utils": "npm:8.60.0" + "@typescript-eslint/visitor-keys": "npm:8.60.0" + ignore: "npm:^7.0.5" + natural-compare: "npm:^1.4.0" + ts-api-utils: "npm:^2.5.0" + peerDependencies: + "@typescript-eslint/parser": ^8.60.0 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: ">=4.8.4 <6.1.0" + checksum: 10/aec6f08be04ad0014c80e5cf3bd8ec83d59c44244c9ca357c4cf182b6f0debdd690e64daa88215e937183e97c4bdee6749dbf4162191c5851ae9c648439c8a96 + languageName: node + linkType: hard + +"@typescript-eslint/parser@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/parser@npm:8.60.0" + dependencies: + "@typescript-eslint/scope-manager": "npm:8.60.0" + "@typescript-eslint/types": "npm:8.60.0" + "@typescript-eslint/typescript-estree": "npm:8.60.0" + "@typescript-eslint/visitor-keys": "npm:8.60.0" + debug: "npm:^4.4.3" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: ">=4.8.4 <6.1.0" + checksum: 10/f55fa3547e3d0a0ec88bcb886b9bf6cef9b425c016dfa47e2ad7fbcbaa854640ba3f501cc0115824b58f33be4bf8bdf544505847988688906d11c154b600c54d + languageName: node + linkType: hard + +"@typescript-eslint/project-service@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/project-service@npm:8.60.0" + dependencies: + "@typescript-eslint/tsconfig-utils": "npm:^8.60.0" + "@typescript-eslint/types": "npm:^8.60.0" + debug: "npm:^4.4.3" + peerDependencies: + typescript: ">=4.8.4 <6.1.0" + checksum: 10/21e233d1292775753861aad32b30448f9fb5508f53d5a12c8ce7e75613df236757377fa877c738cc858ac863f2f8259a1f63bfb15a32ee9c5476fe9b2d12fbb0 + languageName: node + linkType: hard + +"@typescript-eslint/scope-manager@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/scope-manager@npm:8.60.0" + dependencies: + "@typescript-eslint/types": "npm:8.60.0" + "@typescript-eslint/visitor-keys": "npm:8.60.0" + checksum: 10/c08274fdb38be51d2d655ee32bed271cfedf5f5775709da98b3d6cf5f7eb419e98228fb087b48f4a591f4dd71ebcb27a8bd716fa831442c7cad708288625e454 + languageName: node + linkType: hard + +"@typescript-eslint/tsconfig-utils@npm:8.60.0, @typescript-eslint/tsconfig-utils@npm:^8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/tsconfig-utils@npm:8.60.0" + peerDependencies: + typescript: ">=4.8.4 <6.1.0" + checksum: 10/d82cac7dec0366c0e680d002b4d20bc2564a198a2d9a80099f4fa7ee2b2f394dd2d47df03f1c4b276c4de6c7b8684a50e7bad0ddd5b33907188e90cc203a9593 + languageName: node + linkType: hard + +"@typescript-eslint/type-utils@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/type-utils@npm:8.60.0" + dependencies: + "@typescript-eslint/types": "npm:8.60.0" + "@typescript-eslint/typescript-estree": "npm:8.60.0" + "@typescript-eslint/utils": "npm:8.60.0" + debug: "npm:^4.4.3" + ts-api-utils: "npm:^2.5.0" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: ">=4.8.4 <6.1.0" + checksum: 10/4b29dcc1ee7a006b2df8a50700b43701bedd4f8380e94311a8988102d98fdd89244c233a8063a800cbdee86278bdc98874bfa6a8a3c71f1b278be1be6698961b + languageName: node + linkType: hard + +"@typescript-eslint/types@npm:8.60.0, @typescript-eslint/types@npm:^8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/types@npm:8.60.0" + checksum: 10/8c6967503b3a370af10fea7bfec9adc7a4152e0e8aaa72ee790f105f08721683f6e8829acf610de82bfcdeb56bdf07f6795ccec394edbdac222fd3a1d76fe9cd + languageName: node + linkType: hard + +"@typescript-eslint/typescript-estree@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/typescript-estree@npm:8.60.0" + dependencies: + "@typescript-eslint/project-service": "npm:8.60.0" + "@typescript-eslint/tsconfig-utils": "npm:8.60.0" + "@typescript-eslint/types": "npm:8.60.0" + "@typescript-eslint/visitor-keys": "npm:8.60.0" + debug: "npm:^4.4.3" + minimatch: "npm:^10.2.2" + semver: "npm:^7.7.3" + tinyglobby: "npm:^0.2.15" + ts-api-utils: "npm:^2.5.0" + peerDependencies: + typescript: ">=4.8.4 <6.1.0" + checksum: 10/ad02384fd48152a7d9bb5db1aa5d6cbda1cfa9e549a2d529d801ec1401d1d7d011c5e071f5b4d99c5ed656c95e5e97c46a783b45dcc7c016df7fee37ab5bdc0a + languageName: node + linkType: hard + +"@typescript-eslint/utils@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/utils@npm:8.60.0" + dependencies: + "@eslint-community/eslint-utils": "npm:^4.9.1" + "@typescript-eslint/scope-manager": "npm:8.60.0" + "@typescript-eslint/types": "npm:8.60.0" + "@typescript-eslint/typescript-estree": "npm:8.60.0" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: ">=4.8.4 <6.1.0" + checksum: 10/9fc8bc7a62deacd3823d957de8e8ca2012ffa90715734cd89d0e3a62c2c9e2775d3ba9da80e419339893a44af8674d690488cb195c981e8de9fd9dfa4948956d + languageName: node + linkType: hard + +"@typescript-eslint/visitor-keys@npm:8.60.0": + version: 8.60.0 + resolution: "@typescript-eslint/visitor-keys@npm:8.60.0" + dependencies: + "@typescript-eslint/types": "npm:8.60.0" + eslint-visitor-keys: "npm:^5.0.0" + checksum: 10/4854d08416e2c97837cc1ecf8dacb50b3337ebb34bd6d703ad40b6585fdf78243074e56994ddc90650586146cebd6ad7390b6fa3ddda4e3532be4b872dd8f541 + languageName: node + linkType: hard + "abbrev@npm:1, abbrev@npm:1.0.x": version: 1.0.9 resolution: "abbrev@npm:1.0.9" @@ -1550,12 +1703,12 @@ __metadata: languageName: node linkType: hard -"ajv-errors@npm:^1.0.1": - version: 1.0.1 - resolution: "ajv-errors@npm:1.0.1" +"ajv-errors@npm:^3.0.0": + version: 3.0.0 + resolution: "ajv-errors@npm:3.0.0" peerDependencies: - ajv: ">=5.0.0" - checksum: 10/7d8907f7ff3df7cb5b224ddd95c43ebd3d8bac3fd74fe942d644adc68ed3f67d5bb971b897ab8d21607a1ecf6071a987024b96439e040c9fd45625a9b87da1bb + ajv: ^8.0.1 + checksum: 10/bd3403f8547dc12f7417c40b6a003f6d891c0123e365b4b3cd9fffb0edd29100ae682b92ef47dcb3a3b4642a702a246873d3758c3fb92e24dfa3443f97476421 languageName: node linkType: hard @@ -1571,18 +1724,6 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.12.6": - version: 6.15.0 - resolution: "ajv@npm:6.15.0" - dependencies: - fast-deep-equal: "npm:^3.1.1" - fast-json-stable-stringify: "npm:^2.0.0" - json-schema-traverse: "npm:^0.4.1" - uri-js: "npm:^4.2.2" - checksum: 10/0916dda09c152fb5857bc1cc7ce61718e9cec5b7faeff44a74f5e324eed8a556e1a84856724ea322a067b436ecad9f74ac8295fd395449788cca52f0c25bd5fb - languageName: node - linkType: hard - "ajv@npm:^8.0.1": version: 8.17.1 resolution: "ajv@npm:8.17.1" @@ -1595,6 +1736,18 @@ __metadata: languageName: node linkType: hard +"ajv@npm:^8.18.0": + version: 8.20.0 + resolution: "ajv@npm:8.20.0" + dependencies: + fast-deep-equal: "npm:^3.1.3" + fast-uri: "npm:^3.0.1" + json-schema-traverse: "npm:^1.0.0" + require-from-string: "npm:^2.0.2" + checksum: 10/5ce59c0537f4c2aca9a758b412659ec70acb4d5dde971c10ecf21d2e3d799f99acdb4a08e1f5fb2e067c8542930398aae793bb996bb07d3feb81dae22fe2ada9 + languageName: node + linkType: hard + "amdefine@npm:>=0.0.4": version: 1.0.1 resolution: "amdefine@npm:1.0.1" @@ -1666,13 +1819,6 @@ __metadata: languageName: node linkType: hard -"antlr4@npm:^4.13.1-patch-1": - version: 4.13.2 - resolution: "antlr4@npm:4.13.2" - checksum: 10/23ab4742ec937adaaf20d13228c8cca58638e1aafeb28919bdeb4860776a403d0c7eb85a3f07fadc27fc03f773eed6bcc82bd8369b9d0e258e6502ba514cf87e - languageName: node - linkType: hard - "anymatch@npm:~3.1.2": version: 3.1.3 resolution: "anymatch@npm:3.1.3" @@ -1787,6 +1933,13 @@ __metadata: languageName: node linkType: hard +"balanced-match@npm:^4.0.2": + version: 4.0.4 + resolution: "balanced-match@npm:4.0.4" + checksum: 10/fb07bb66a0959c2843fc055838047e2a95ccebb837c519614afb067ebfdf2fa967ca8d712c35ced07f2cd26fc6f07964230b094891315ad74f11eba3d53178a0 + languageName: node + linkType: hard + "base-x@npm:^3.0.2": version: 3.0.11 resolution: "base-x@npm:3.0.11" @@ -1895,6 +2048,15 @@ __metadata: languageName: node linkType: hard +"brace-expansion@npm:^5.0.5": + version: 5.0.6 + resolution: "brace-expansion@npm:5.0.6" + dependencies: + balanced-match: "npm:^4.0.2" + checksum: 10/a7acf120fefa79e9d7c9c92898114f57c07596a3920197f3c5917e6a628b04220a5f7f9618c30bdd973a6576a32113b99f9c3f1c8245ccc399dd2a9a718d81d8 + languageName: node + linkType: hard + "braces@npm:^3.0.3, braces@npm:~3.0.2": version: 3.0.3 resolution: "braces@npm:3.0.3" @@ -2439,6 +2601,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.4.3": + version: 4.4.3 + resolution: "debug@npm:4.4.3" + dependencies: + ms: "npm:^2.1.3" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10/9ada3434ea2993800bd9a1e320bd4aa7af69659fb51cca685d390949434bc0a8873c21ed7c9b852af6f2455a55c6d050aa3937d52b3c69f796dab666f762acad + languageName: node + linkType: hard + "decamelize@npm:^4.0.0": version: 4.0.0 resolution: "decamelize@npm:4.0.0" @@ -2737,6 +2911,13 @@ __metadata: languageName: node linkType: hard +"eslint-visitor-keys@npm:^5.0.0": + version: 5.0.1 + resolution: "eslint-visitor-keys@npm:5.0.1" + checksum: 10/f9cc1a57b75e0ef949545cac33d01e8367e302de4c1483266ed4d8646ee5c306376660196bbb38b004e767b7043d1e661cb4336b49eff634a1bbe75c1db709ec + languageName: node + linkType: hard + "eslint@npm:^9.32.0": version: 9.32.0 resolution: "eslint@npm:9.32.0" @@ -3045,6 +3226,18 @@ __metadata: languageName: node linkType: hard +"fdir@npm:^6.5.0": + version: 6.5.0 + resolution: "fdir@npm:6.5.0" + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + checksum: 10/14ca1c9f0a0e8f4f2e9bf4e8551065a164a09545dae548c12a18d238b72e51e5a7b39bd8e5494b56463a0877672d0a6c1ef62c6fa0677db1b0c847773be939b1 + languageName: node + linkType: hard + "file-entry-cache@npm:^8.0.0": version: 8.0.0 resolution: "file-entry-cache@npm:8.0.0" @@ -3166,17 +3359,6 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:^11.1.0": - version: 11.3.5 - resolution: "fs-extra@npm:11.3.5" - dependencies: - graceful-fs: "npm:^4.2.0" - jsonfile: "npm:^6.0.1" - universalify: "npm:^2.0.0" - checksum: 10/dc8408818eec8b03efad8742d079ecab749a2f7bc9f208e429b447fcac7632fae52e09312d6d42218efe7e2efa97f03ff232d639ade4aa7fcd8c00ebe9ad0c0c - languageName: node - linkType: hard - "fs-extra@npm:^7.0.0, fs-extra@npm:^7.0.1": version: 7.0.1 resolution: "fs-extra@npm:7.0.1" @@ -3362,6 +3544,17 @@ __metadata: languageName: node linkType: hard +"glob@npm:^13.0.6": + version: 13.0.6 + resolution: "glob@npm:13.0.6" + dependencies: + minimatch: "npm:^10.2.2" + minipass: "npm:^7.1.3" + path-scurry: "npm:^2.0.2" + checksum: 10/201ad69e5f0aa74e1d8c00a481581f8b8c804b6a4fbfabeeb8541f5d756932800331daeba99b58fb9e4cd67e12ba5a7eba5b82fb476691588418060b84353214 + languageName: node + linkType: hard + "glob@npm:^5.0.15": version: 5.0.15 resolution: "glob@npm:5.0.15" @@ -3389,7 +3582,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^8.0.3, glob@npm:^8.1.0": +"glob@npm:^8.1.0": version: 8.1.0 resolution: "glob@npm:8.1.0" dependencies: @@ -3784,6 +3977,13 @@ __metadata: languageName: node linkType: hard +"ignore@npm:^7.0.5": + version: 7.0.5 + resolution: "ignore@npm:7.0.5" + checksum: 10/f134b96a4de0af419196f52c529d5c6120c4456ff8a6b5a14ceaaa399f883e15d58d2ce651c9b69b9388491d4669dda47285d307e827de9304a53a1824801bc6 + languageName: node + linkType: hard + "immer@npm:10.0.2": version: 10.0.2 resolution: "immer@npm:10.0.2" @@ -4296,6 +4496,13 @@ __metadata: languageName: node linkType: hard +"lru-cache@npm:^11.0.0": + version: 11.5.1 + resolution: "lru-cache@npm:11.5.1" + checksum: 10/02c4f73967d91fb101f4accf8ebac9e0541e08e16d987bdb9e9737f13e5f2c4bc33c593b98ec30e4486bf899bc97edb36fbd133684b36087336559e41edafdea + languageName: node + linkType: hard + "lru-cache@npm:^6.0.0": version: 6.0.0 resolution: "lru-cache@npm:6.0.0" @@ -4480,6 +4687,15 @@ __metadata: languageName: node linkType: hard +"minimatch@npm:^10.2.2": + version: 10.2.5 + resolution: "minimatch@npm:10.2.5" + dependencies: + brace-expansion: "npm:^5.0.5" + checksum: 10/19e87a931aff60ee7b9d80f39f817b8bfc54f61f8356ee3549fbf636dbccacacfec8d803eac73293955c4527cd085247dfc064bce4a5e349f8f3b85e2bf5da0f + languageName: node + linkType: hard + "minimatch@npm:^5.0.1, minimatch@npm:^5.1.6": version: 5.1.6 resolution: "minimatch@npm:5.1.6" @@ -4572,6 +4788,13 @@ __metadata: languageName: node linkType: hard +"minipass@npm:^7.1.3": + version: 7.1.3 + resolution: "minipass@npm:7.1.3" + checksum: 10/175e4d5e20980c3cd316ae82d2c031c42f6c746467d8b1905b51060a0ba4461441a0c25bb67c025fd9617f9a3873e152c7b543c6b5ac83a1846be8ade80dffd6 + languageName: node + linkType: hard + "minizlib@npm:^3.0.1": version: 3.0.2 resolution: "minizlib@npm:3.0.2" @@ -4959,13 +5182,14 @@ __metadata: mocha: "npm:^10.8.2" prettier: "npm:^3.0.0" prettier-plugin-solidity: "npm:^1.0.0" - solhint: "npm:^5.0.0" + solhint: "npm:^6.2.1" solhint-plugin-prettier: "npm:^0.1.0" solidity-coverage: "npm:^0.8.16" solidity-docgen: "npm:^0.6.0-beta.36" ts-node: "npm:^10.9.2" typechain: "npm:^8.3.2" typescript: "npm:^5.8.3" + typescript-eslint: "npm:^8.60.0" viem: "npm:^2.33.1" languageName: unknown linkType: soft @@ -5048,6 +5272,16 @@ __metadata: languageName: node linkType: hard +"path-scurry@npm:^2.0.2": + version: 2.0.2 + resolution: "path-scurry@npm:2.0.2" + dependencies: + lru-cache: "npm:^11.0.0" + minipass: "npm:^7.1.2" + checksum: 10/2b4257422bcb870a4c2d205b3acdbb213a72f5e2250f61c80f79c9d014d010f82bdf8584441612c8e1fa4eb098678f5704a66fa8377d72646bad4be38e57a2c3 + languageName: node + linkType: hard + "path-type@npm:^4.0.0": version: 4.0.0 resolution: "path-type@npm:4.0.0" @@ -5096,6 +5330,13 @@ __metadata: languageName: node linkType: hard +"picomatch@npm:^4.0.4": + version: 4.0.4 + resolution: "picomatch@npm:4.0.4" + checksum: 10/f6ef80a3590827ce20378ae110ac78209cc4f74d39236370f1780f957b7ee41c12acde0e4651b90f39983506fd2f5e449994716f516db2e9752924aff8de93ce + languageName: node + linkType: hard + "pify@npm:^4.0.1": version: 4.0.1 resolution: "pify@npm:4.0.1" @@ -5145,7 +5386,7 @@ __metadata: languageName: node linkType: hard -"prettier@npm:^2.3.1, prettier@npm:^2.8.3": +"prettier@npm:^2.3.1": version: 2.8.8 resolution: "prettier@npm:2.8.8" bin: @@ -5545,7 +5786,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.7.1": +"semver@npm:^7.3.7, semver@npm:^7.5.2, semver@npm:^7.7.1, semver@npm:^7.7.3": version: 7.8.1 resolution: "semver@npm:7.8.1" bin: @@ -5718,30 +5959,27 @@ __metadata: languageName: node linkType: hard -"solhint@npm:^5.0.0": - version: 5.2.0 - resolution: "solhint@npm:5.2.0" +"solhint@npm:^6.2.1": + version: 6.2.1 + resolution: "solhint@npm:6.2.1" dependencies: - "@solidity-parser/parser": "npm:^0.20.0" - ajv: "npm:^6.12.6" - ajv-errors: "npm:^1.0.1" - antlr4: "npm:^4.13.1-patch-1" + "@solidity-parser/parser": "npm:^0.20.2" + ajv: "npm:^8.18.0" + ajv-errors: "npm:^3.0.0" ast-parents: "npm:^0.0.1" better-ajv-errors: "npm:^2.0.2" chalk: "npm:^4.1.2" commander: "npm:^10.0.0" cosmiconfig: "npm:^8.0.0" fast-diff: "npm:^1.2.0" - fs-extra: "npm:^11.1.0" - glob: "npm:^8.0.3" + glob: "npm:^13.0.6" ignore: "npm:^5.2.4" js-yaml: "npm:^4.1.0" latest-version: "npm:^7.0.0" lodash: "npm:^4.17.21" pluralize: "npm:^8.0.0" - prettier: "npm:^2.8.3" + prettier: "npm:^3.0.0" semver: "npm:^7.5.2" - strip-ansi: "npm:^6.0.1" table: "npm:^6.8.1" text-table: "npm:^0.2.0" dependenciesMeta: @@ -5749,7 +5987,7 @@ __metadata: optional: true bin: solhint: solhint.js - checksum: 10/ccccfe72390989fe4e4827e9635ef41605f966a1efb835bb9c231b5e4b9edcd0ccd60602668aba3365c385e89f8ca383e32570cf1148f7a81e8bb44d69b5ddf7 + checksum: 10/b8edac2ee072034cbb2200a4146ce50bdb20839ed4772a72718f341766006753780c48a5292b6911b4f8398e046a905ae4ab0dd21101041449b8ada1f7c93b2f languageName: node linkType: hard @@ -6057,6 +6295,16 @@ __metadata: languageName: node linkType: hard +"tinyglobby@npm:^0.2.15": + version: 0.2.16 + resolution: "tinyglobby@npm:0.2.16" + dependencies: + fdir: "npm:^6.5.0" + picomatch: "npm:^4.0.4" + checksum: 10/5c2c41b572ada38449e7c86a5fe034f204a1dbba577225a761a14f29f48dc3f2fc0d81a6c56fcc67c5a742cc3aa9fb5e2ca18dbf22b610b0bc0e549b34d5a0f8 + languageName: node + linkType: hard + "tmp@npm:0.0.33": version: 0.0.33 resolution: "tmp@npm:0.0.33" @@ -6089,6 +6337,15 @@ __metadata: languageName: node linkType: hard +"ts-api-utils@npm:^2.5.0": + version: 2.5.0 + resolution: "ts-api-utils@npm:2.5.0" + peerDependencies: + typescript: ">=4.8.4" + checksum: 10/d5f1936f5618c6ab6942a97b78802217540ced00e7501862ae1f578d9a3aa189fc06050e64cb8951d21f7088e5fd35f53d2bf0d0370a883861c7b05e993ebc44 + languageName: node + linkType: hard + "ts-command-line-args@npm:^2.2.0": version: 2.5.1 resolution: "ts-command-line-args@npm:2.5.1" @@ -6239,6 +6496,21 @@ __metadata: languageName: node linkType: hard +"typescript-eslint@npm:^8.60.0": + version: 8.60.0 + resolution: "typescript-eslint@npm:8.60.0" + dependencies: + "@typescript-eslint/eslint-plugin": "npm:8.60.0" + "@typescript-eslint/parser": "npm:8.60.0" + "@typescript-eslint/typescript-estree": "npm:8.60.0" + "@typescript-eslint/utils": "npm:8.60.0" + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: ">=4.8.4 <6.1.0" + checksum: 10/625e49e6d06e32adcfe903087d1fb2adc3be925adafe1f4e57f690bb196b35e2aac01760a3d5e17a53ea2feb6fef3a13da4b8faa214f628ec56e64f99f20e4ad + languageName: node + linkType: hard + "typescript@npm:^5.8.3": version: 5.8.3 resolution: "typescript@npm:5.8.3"