diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 299cd9e..8212748 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,7 +1,7 @@ name: Test concurrency: - group: ${{ github.workflow }} + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true on: @@ -11,46 +11,9 @@ on: - main jobs: + lint: + uses: bgd-labs/github-workflows/.github/workflows/foundry-lint-prettier.yml@main test: - name: Foundry build n test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - uses: bgd-labs/action-rpc-env@main - with: - ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - - # we simply use foundry zk for all jobs in this repo - - name: Run Foundry setup - uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main - with: - ZKSYNC: 'true' - - - name: Run Forge tests - id: test - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - - - name: Run ZK tests - id: zktest - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - with: - ZKSYNC: true - - - name: Run Gas report - uses: bgd-labs/github-workflows/.github/actions/foundry-gas-report@main - - - name: Run Lcov report - uses: bgd-labs/github-workflows/.github/actions/foundry-lcov-report@main - - - name: Run Forge tests - uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main - - # we let failing tests pass so we can log them in the comment, still we want the ci to fail - - name: Post test - if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} - run: | - echo "tests failed" - exit 1 + uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main + test-zk: + uses: bgd-labs/github-workflows/.github/workflows/foundry-test-zk.yml@main diff --git a/.gitignore b/.gitignore index 99075ec..1791c78 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ out/ .env broadcast node_modules -package-lock.json +yarn.lock zkout/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..7dc4a54 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +lib +broadcast +cache +out +node_modules +zkout diff --git a/CHANGELOG.md b/CHANGELOG.md index 13e5d33..cc18710 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,33 +4,31 @@ All notable changes to this project will be documented in this file. See [standa ## 1.1.0 (2022-11-15) - ### Features -* add ierc20 with permit ([1093eaa](https://github.com/bgd-labs/solidity-utils/commit/1093eaa8c7ee3a605d1935da3b115e97960a61aa)) -* added emergency consumer logic ([23a0c85](https://github.com/bgd-labs/solidity-utils/commit/23a0c855ac8a599b0bc3ea34fcebb134994b6aa2)) -* added IERC20 and SafeERC20 oz contracts ([ba4d85f](https://github.com/bgd-labs/solidity-utils/commit/ba4d85f14cc2cf94e403c56395cda5e705877b38)) -* added IERC20Metadata interface ([3afcba2](https://github.com/bgd-labs/solidity-utils/commit/3afcba2a81dc916f18c3411eb0329ee40d6b5f41)) -* added test workflow ([03028a7](https://github.com/bgd-labs/solidity-utils/commit/03028a7b6fc1b94eeafbb828bbcff23b9266542d)) -* deploy on npm ([#11](https://github.com/bgd-labs/solidity-utils/issues/11)) ([0bece64](https://github.com/bgd-labs/solidity-utils/commit/0bece649ec134950634b80b255772a0eacab7746)) - +- add ierc20 with permit ([1093eaa](https://github.com/bgd-labs/solidity-utils/commit/1093eaa8c7ee3a605d1935da3b115e97960a61aa)) +- added emergency consumer logic ([23a0c85](https://github.com/bgd-labs/solidity-utils/commit/23a0c855ac8a599b0bc3ea34fcebb134994b6aa2)) +- added IERC20 and SafeERC20 oz contracts ([ba4d85f](https://github.com/bgd-labs/solidity-utils/commit/ba4d85f14cc2cf94e403c56395cda5e705877b38)) +- added IERC20Metadata interface ([3afcba2](https://github.com/bgd-labs/solidity-utils/commit/3afcba2a81dc916f18c3411eb0329ee40d6b5f41)) +- added test workflow ([03028a7](https://github.com/bgd-labs/solidity-utils/commit/03028a7b6fc1b94eeafbb828bbcff23b9266542d)) +- deploy on npm ([#11](https://github.com/bgd-labs/solidity-utils/issues/11)) ([0bece64](https://github.com/bgd-labs/solidity-utils/commit/0bece649ec134950634b80b255772a0eacab7746)) ### Bug Fixes -* add 20 to filename to be consistent ([0c5a8b8](https://github.com/bgd-labs/solidity-utils/commit/0c5a8b894b6bd9e434c9e8b5b355469c6c306228)) -* add indexed to few fields on events ([7a6fd00](https://github.com/bgd-labs/solidity-utils/commit/7a6fd00a06def5fdbc33cb0759efd18f5865500a)) -* add lockfile ([6d07157](https://github.com/bgd-labs/solidity-utils/commit/6d071575f3085c4f45d084429a6bced227a155c6)) -* add natspec for cl oracle interface ([ee1fcfd](https://github.com/bgd-labs/solidity-utils/commit/ee1fcfde4b47426e2370bbc54ce3e365b1cae7bb)) -* added deterministic method to create proxy, also creating admin and transfering ownership of deployed admin to specified address ([37a0f96](https://github.com/bgd-labs/solidity-utils/commit/37a0f967166bbe893a810c7b2014c939e1ad72ac)) -* added deterministic proxy admin ([23892f3](https://github.com/bgd-labs/solidity-utils/commit/23892f362de15e1cad1166fd881b159fa463bd15)) -* added predictive proxy admin deployment ([b18f754](https://github.com/bgd-labs/solidity-utils/commit/b18f754af61d65ab6951dfb4f5418ff67e0f740e)) -* added solved event ([82832ba](https://github.com/bgd-labs/solidity-utils/commit/82832baf8cc3d289a69dba57039a7f7fc38902c4)) -* **ci:** better triggers ([c097977](https://github.com/bgd-labs/solidity-utils/commit/c09797758e76103f41840c8ecc7acb5e142bfa18)) -* fixed imports ([f3bbb92](https://github.com/bgd-labs/solidity-utils/commit/f3bbb92d2420ebadcfbc9bf68ec239849f52e0ac)) -* removed comments ([eca9e94](https://github.com/bgd-labs/solidity-utils/commit/eca9e94ba34c53743ab650255787bddf1cb27316)) -* removed highly recomended ([394dbce](https://github.com/bgd-labs/solidity-utils/commit/394dbce5f078bb363deb6617469a285f090a2e31)) -* removed highly recomended from all comments ([3a5bdf3](https://github.com/bgd-labs/solidity-utils/commit/3a5bdf34dc764136f2154993482877574dd26805)) -* removed mock contract ([e266d70](https://github.com/bgd-labs/solidity-utils/commit/e266d708c969f59ebff052156692ce058819c0e3)) -* updated docs ([d07d705](https://github.com/bgd-labs/solidity-utils/commit/d07d705d83d7bae0511b53b46fa1b1bbca0c22cb)) -* updated tests ([8570de9](https://github.com/bgd-labs/solidity-utils/commit/8570de9e6aa7868ea277dc1627da745c3add4e10)) -* updated with virtual update method, and moved solve emergency to modifier ([1a86eb3](https://github.com/bgd-labs/solidity-utils/commit/1a86eb3fcc65e267ff67bb72888eb65a35f83542)) +- add 20 to filename to be consistent ([0c5a8b8](https://github.com/bgd-labs/solidity-utils/commit/0c5a8b894b6bd9e434c9e8b5b355469c6c306228)) +- add indexed to few fields on events ([7a6fd00](https://github.com/bgd-labs/solidity-utils/commit/7a6fd00a06def5fdbc33cb0759efd18f5865500a)) +- add lockfile ([6d07157](https://github.com/bgd-labs/solidity-utils/commit/6d071575f3085c4f45d084429a6bced227a155c6)) +- add natspec for cl oracle interface ([ee1fcfd](https://github.com/bgd-labs/solidity-utils/commit/ee1fcfde4b47426e2370bbc54ce3e365b1cae7bb)) +- added deterministic method to create proxy, also creating admin and transfering ownership of deployed admin to specified address ([37a0f96](https://github.com/bgd-labs/solidity-utils/commit/37a0f967166bbe893a810c7b2014c939e1ad72ac)) +- added deterministic proxy admin ([23892f3](https://github.com/bgd-labs/solidity-utils/commit/23892f362de15e1cad1166fd881b159fa463bd15)) +- added predictive proxy admin deployment ([b18f754](https://github.com/bgd-labs/solidity-utils/commit/b18f754af61d65ab6951dfb4f5418ff67e0f740e)) +- added solved event ([82832ba](https://github.com/bgd-labs/solidity-utils/commit/82832baf8cc3d289a69dba57039a7f7fc38902c4)) +- **ci:** better triggers ([c097977](https://github.com/bgd-labs/solidity-utils/commit/c09797758e76103f41840c8ecc7acb5e142bfa18)) +- fixed imports ([f3bbb92](https://github.com/bgd-labs/solidity-utils/commit/f3bbb92d2420ebadcfbc9bf68ec239849f52e0ac)) +- removed comments ([eca9e94](https://github.com/bgd-labs/solidity-utils/commit/eca9e94ba34c53743ab650255787bddf1cb27316)) +- removed highly recomended ([394dbce](https://github.com/bgd-labs/solidity-utils/commit/394dbce5f078bb363deb6617469a285f090a2e31)) +- removed highly recomended from all comments ([3a5bdf3](https://github.com/bgd-labs/solidity-utils/commit/3a5bdf34dc764136f2154993482877574dd26805)) +- removed mock contract ([e266d70](https://github.com/bgd-labs/solidity-utils/commit/e266d708c969f59ebff052156692ce058819c0e3)) +- updated docs ([d07d705](https://github.com/bgd-labs/solidity-utils/commit/d07d705d83d7bae0511b53b46fa1b1bbca0c22cb)) +- updated tests ([8570de9](https://github.com/bgd-labs/solidity-utils/commit/8570de9e6aa7868ea277dc1627da745c3add4e10)) +- updated with virtual update method, and moved solve emergency to modifier ([1a86eb3](https://github.com/bgd-labs/solidity-utils/commit/1a86eb3fcc65e267ff67bb72888eb65a35f83542)) diff --git a/README.md b/README.md index 2831f7b..d936a5e 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,20 @@ Common contracts we use almost everywhere - ## Create3 + Contracts to deploy a Create3 Factory which so that contract addresses can be predicted without influence from constructor arguments. These contracts where modified from: + - Create3 lib: -Modified from https://github.com/0xsequence/create3/blob/5a4a152e6be4e0ecfbbbe546992a5aaa43a4c1b0/contracts/Create3.sol by Agustin Aguilar + Modified from https://github.com/0xsequence/create3/blob/5a4a152e6be4e0ecfbbbe546992a5aaa43a4c1b0/contracts/Create3.sol by Agustin Aguilar - Modifications consist on: - removal of named returns - moved logic of addressOf method to addressOfWithPreDeployedFactory so that factory address can be abstracted - Create3Factory: -Modified from https://github.com/lifinance/create3-factory/blob/main/src/CREATE3Factory.sol + Modified from https://github.com/lifinance/create3-factory/blob/main/src/CREATE3Factory.sol - Modifications consist on: - removal of named returns - changed name of getDeployed for predictAddress @@ -29,7 +30,9 @@ as expected. - Tests specific for ZkSync network can be found [here](test-zksync) To build and test the contracts use `FOUNDRY_PROFILE=zksync` and the flag `--zksync` + - Example: + ```solidity FOUNDRY_PROFILE=zksync forge test -vvv --zksync ``` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e145843 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,66 @@ +{ + "name": "@bgd-labs/solidity-utils", + "version": "1.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@bgd-labs/solidity-utils", + "version": "1.1.0", + "license": "ISC", + "devDependencies": { + "prettier": "^2.8.3", + "prettier-plugin-solidity": "^1.1.1" + } + }, + "node_modules/@solidity-parser/parser": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.18.0.tgz", + "integrity": "sha512-yfORGUIPgLck41qyN7nbwJRAx17/jAIXCTanHOJZhB6PJ1iAk/84b/xlsVKFSyNyLXIj0dhppoE0+CRws7wlzA==", + "dev": true + }, + "node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-solidity": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.4.1.tgz", + "integrity": "sha512-Mq8EtfacVZ/0+uDKTtHZGW3Aa7vEbX/BNx63hmVg6YTiTXSiuKP0amj0G6pGwjmLaOfymWh3QgXEZkjQbU8QRg==", + "dev": true, + "dependencies": { + "@solidity-parser/parser": "^0.18.0", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "prettier": ">=2.3.0" + } + }, + "node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + } + } +} diff --git a/package.json b/package.json index f70a056..97ca287 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "test": "tests" }, "scripts": { - "lint": "prettier ./", - "lint:fix": "npm run lint -- --write", + "lint": "prettier . --check", + "lint:fix": "prettier . --write", "ci:publish": "npm publish --access=public" }, "repository": { diff --git a/script/DeployCreate3Factory.s.sol b/script/DeployCreate3Factory.s.sol index 8d39fc6..cf3c25a 100644 --- a/script/DeployCreate3Factory.s.sol +++ b/script/DeployCreate3Factory.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import {Script} from 'forge-std/Script.sol'; import {TransparentProxyFactory} from '../src/contracts/transparent-proxy/TransparentProxyFactory.sol'; -import {Create3Factory} from "../src/contracts/create3/Create3Factory.sol"; +import {Create3Factory} from '../src/contracts/create3/Create3Factory.sol'; contract DeployCreate3Factory is Script { bytes32 public constant CREATE3_FACTORY_SALT = keccak256(bytes('Create3 Factory')); diff --git a/src/contracts/create3/Create3.sol b/src/contracts/create3/Create3.sol index e483ab4..defe6c1 100644 --- a/src/contracts/create3/Create3.sol +++ b/src/contracts/create3/Create3.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; /** * @title A library for deploying contracts EIP-3171 style. * @author BGD Labs -*/ + */ library Create3 { error ErrorCreatingProxy(); error ErrorCreatingContract(); @@ -59,10 +59,7 @@ library Create3 { * @param creationCode Creation code (constructor) of the contract to be deployed, this value doesn't affect the resulting address * @return address of the deployed contract, reverts on error */ - function create3( - bytes32 salt, - bytes memory creationCode - ) internal returns (address) { + function create3(bytes32 salt, bytes memory creationCode) internal returns (address) { return create3(salt, creationCode, 0); } @@ -88,12 +85,7 @@ library Create3 { // Create CREATE2 proxy address proxy; assembly { - proxy := create2( - value, - add(proxyCreationCode, 32), - mload(proxyCreationCode), - salt - ) + proxy := create2(value, add(proxyCreationCode, 32), mload(proxyCreationCode), salt) } if (proxy == address(0)) revert ErrorCreatingProxy(); @@ -128,22 +120,12 @@ library Create3 { uint160( uint256( keccak256( - abi.encodePacked( - hex'ff', - preDeployedFactory, - salt, - KECCAK256_PROXY_CHILD_BYTECODE - ) + abi.encodePacked(hex'ff', preDeployedFactory, salt, KECCAK256_PROXY_CHILD_BYTECODE) ) ) ) ); - return - address( - uint160( - uint256(keccak256(abi.encodePacked(hex'd6_94', proxy, hex'01'))) - ) - ); + return address(uint160(uint256(keccak256(abi.encodePacked(hex'd6_94', proxy, hex'01'))))); } } diff --git a/src/contracts/create3/Create3Factory.sol b/src/contracts/create3/Create3Factory.sol index 1f37623..9a48949 100644 --- a/src/contracts/create3/Create3Factory.sol +++ b/src/contracts/create3/Create3Factory.sol @@ -6,26 +6,20 @@ import {Create3} from './Create3.sol'; import {ICreate3Factory} from './interfaces/ICreate3Factory.sol'; /** - * @title Factory for deploying contracts to deterministic addresses via Create3 - * @author BGD Labs - * @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has its own namespace for deployed addresses. - */ + * @title Factory for deploying contracts to deterministic addresses via Create3 + * @author BGD Labs + * @notice Enables deploying contracts using CREATE3. Each deployer (msg.sender) has its own namespace for deployed addresses. + */ contract Create3Factory is ICreate3Factory { /// @inheritdoc ICreate3Factory - function create( - bytes32 salt, - bytes memory creationCode - ) external payable returns (address) { + function create(bytes32 salt, bytes memory creationCode) external payable returns (address) { // hash salt with the deployer address to give each deployer its own namespace salt = keccak256(abi.encodePacked(msg.sender, salt)); return Create3.create3(salt, creationCode, msg.value); } /// @inheritdoc ICreate3Factory - function predictAddress( - address deployer, - bytes32 salt - ) external view returns (address) { + function predictAddress(address deployer, bytes32 salt) external view returns (address) { // hash salt with the deployer address to give each deployer its own namespace salt = keccak256(abi.encodePacked(deployer, salt)); return Create3.addressOf(salt); diff --git a/src/contracts/create3/interfaces/ICreate3Factory.sol b/src/contracts/create3/interfaces/ICreate3Factory.sol index a84105b..9118408 100644 --- a/src/contracts/create3/interfaces/ICreate3Factory.sol +++ b/src/contracts/create3/interfaces/ICreate3Factory.sol @@ -15,10 +15,7 @@ interface ICreate3Factory { * @param creationCode The creation code of the contract to deploy * @return The address of the deployed contract */ - function create( - bytes32 salt, - bytes memory creationCode - ) external payable returns (address); + function create(bytes32 salt, bytes memory creationCode) external payable returns (address); /** * @notice Predicts the address of a deployed contract @@ -27,8 +24,5 @@ interface ICreate3Factory { * @param salt The deployer-specific salt for determining the deployed contract's address * @return The address of the contract that will be deployed */ - function predictAddress( - address deployer, - bytes32 salt - ) external view returns (address); + function predictAddress(address deployer, bytes32 salt) external view returns (address); } diff --git a/src/contracts/utils/Rescuable721.sol b/src/contracts/utils/Rescuable721.sol index df59a71..d1f9303 100644 --- a/src/contracts/utils/Rescuable721.sol +++ b/src/contracts/utils/Rescuable721.sol @@ -10,7 +10,6 @@ import {Rescuable} from './Rescuable.sol'; * @notice abstract contract that extend Rescuable with the methods to rescue ERC721 tokens from a contract */ abstract contract Rescuable721 is Rescuable, IRescuable721 { - /// @inheritdoc IRescuable721 function emergency721TokenTransfer( address erc721Token, diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index ade56c3..0000000 --- a/yarn.lock +++ /dev/null @@ -1,53 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@solidity-parser/parser@^0.14.5": - version "0.14.5" - resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.14.5.tgz#87bc3cc7b068e08195c219c91cd8ddff5ef1a804" - integrity sha512-6dKnHZn7fg/iQATVEzqyUOyEidbn05q7YA2mQ9hC0MMXhhV3/JrsxmFSYZAcr7j1yUP700LLhTruvJ3MiQmjJg== - dependencies: - antlr4ts "^0.5.0-alpha.4" - -antlr4ts@^0.5.0-alpha.4: - version "0.5.0-alpha.4" - resolved "https://registry.yarnpkg.com/antlr4ts/-/antlr4ts-0.5.0-alpha.4.tgz#71702865a87478ed0b40c0709f422cf14d51652a" - integrity sha512-WPQDt1B74OfPv/IMS2ekXAKkTZIHl88uMetg6q3OTqgFxZ/dxDXI0EWLyZid/1Pe6hTftyg5N7gel5wNAGxXyQ== - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -prettier-plugin-solidity@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.1.1.tgz#4d3375b85f97812ffcbe48d5a8b3fe914d69c91f" - integrity sha512-uD24KO26tAHF+zMN2nt1OUzfknzza5AgxjogQQrMLZc7j8xiQrDoNWNeOlfFC0YLTwo12CLD10b9niLyP6AqXg== - dependencies: - "@solidity-parser/parser" "^0.14.5" - semver "^7.3.8" - solidity-comments-extractor "^0.0.7" - -prettier@^2.8.3: - version "2.8.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.3.tgz#ab697b1d3dd46fb4626fbe2f543afe0cc98d8632" - integrity sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw== - -semver@^7.3.8: - version "7.3.8" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" - integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== - dependencies: - lru-cache "^6.0.0" - -solidity-comments-extractor@^0.0.7: - version "0.0.7" - resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.7.tgz#99d8f1361438f84019795d928b931f4e5c39ca19" - integrity sha512-wciNMLg/Irp8OKGrh3S2tfvZiZ0NEyILfcRCXCD4mp7SgK/i9gzLfhY2hY7VMCQJ3kH9UB9BzNdibIVMchzyYw== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== diff --git a/zksync/src/contracts/utils/ScriptUtilsZkSync.sol b/zksync/src/contracts/utils/ScriptUtilsZkSync.sol index b531ccf..2af8591 100644 --- a/zksync/src/contracts/utils/ScriptUtilsZkSync.sol +++ b/zksync/src/contracts/utils/ScriptUtilsZkSync.sol @@ -8,7 +8,11 @@ library Create2UtilsZkSync { address public constant CREATE2_FACTORY = 0x0000000000000000000000000000000000010000; // @dev the bytecodeHash is the unsanitized input we get via `type(Contract).creationCode` - function create2Deploy(bytes32 salt, bytes memory bytecodeHash, bytes memory arguments) internal returns (address) { + function create2Deploy( + bytes32 salt, + bytes memory bytecodeHash, + bytes memory arguments + ) internal returns (address) { return create2Deploy(salt, bytes32(sliceBytes(bytecodeHash, 36, 32)), arguments); } @@ -30,11 +34,7 @@ library Create2UtilsZkSync { if (isContractDeployed(computed)) { return computed; } else { - address deployedAt = ICreate2Factory(CREATE2_FACTORY).create2( - salt, - bytecodeHash, - arguments - ); + address deployedAt = ICreate2Factory(CREATE2_FACTORY).create2(salt, bytecodeHash, arguments); require(deployedAt == computed, 'failure at create2 address derivation'); return deployedAt; @@ -50,11 +50,7 @@ library Create2UtilsZkSync { if (isContractDeployed(computed)) { return computed; } else { - address deployedAt = ICreate2Factory(CREATE2_FACTORY).create2( - salt, - bytecodeHash, - '' - ); + address deployedAt = ICreate2Factory(CREATE2_FACTORY).create2(salt, bytecodeHash, ''); require(deployedAt == computed, 'failure at create2 address derivation'); return deployedAt; @@ -90,7 +86,11 @@ library Create2UtilsZkSync { return (_addr.code.length > 0); } - function sliceBytes(bytes memory data, uint256 start, uint256 length) internal pure returns (bytes memory) { + function sliceBytes( + bytes memory data, + uint256 start, + uint256 length + ) internal pure returns (bytes memory) { require(start + length <= data.length, 'Slice out of bounds'); bytes memory result = new bytes(length); @@ -102,7 +102,11 @@ library Create2UtilsZkSync { let words := div(add(length, 31), 32) let srcPtr := add(dataPtr, start) - for { let i := 0 } lt(i, words) { i := add(i, 1) } { + for { + let i := 0 + } lt(i, words) { + i := add(i, 1) + } { mstore(add(resultPtr, mul(i, 32)), mload(add(srcPtr, mul(i, 32)))) }