diff --git a/.github/workflows/reusable-publish.yaml b/.github/workflows/reusable-publish.yaml index 8a84eda99..dcf1d7d44 100644 --- a/.github/workflows/reusable-publish.yaml +++ b/.github/workflows/reusable-publish.yaml @@ -52,6 +52,17 @@ jobs: restore-keys: | ${{ runner.os }}-turbo- + # Cache hardhat compilers + # + # This step will speed up workflow runs that use hardhat compilation + - name: Cache hardhat compilers + uses: actions/cache@v3 + with: + path: .cache/hardhat + key: ${{ runner.os }}-hardhat-${{ github.ref_name }} + restore-keys: | + ${{ runner.os }}-hardhat- + - name: Build run: yarn build env: diff --git a/.github/workflows/reusable-test.yaml b/.github/workflows/reusable-test.yaml index 2d86fbdca..1ab576350 100644 --- a/.github/workflows/reusable-test.yaml +++ b/.github/workflows/reusable-test.yaml @@ -52,6 +52,17 @@ jobs: restore-keys: | ${{ runner.os }}-turbo- + # Cache hardhat compilers + # + # This step will speed up workflow runs that use hardhat compilation + - name: Cache hardhat compilers + uses: actions/cache@v3 + with: + path: .cache/hardhat + key: ${{ runner.os }}-hardhat-${{ github.ref_name }} + restore-keys: | + ${{ runner.os }}-hardhat- + - name: Lint run: yarn lint diff --git a/.gitignore b/.gitignore index 35b175c31..43f375300 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,7 @@ node_modules/ dist # Github actions -.netrc \ No newline at end of file +.netrc + +# Cache +.cache \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index eb940dfff..76847aea3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -42,4 +42,11 @@ services: volumes: - ./node_modules/.cache/turbo:/app/node_modules/.cache/turbo - ./packages:/app/packages + # Hardhat has an issue with caching compilers inside a docker container, + # failing with EACCES -13 error, pointing to a permissions issue with the cache folder. + # + # The workaround is to provide an outside volume to work + # as a cache directory for hardhat so that the permissions + # don't clash + - ./.cache/hardhat:/root/.cache/hardhat-nodejs command: "npx turbo test $DOCKER_COMPOSE_RUN_TESTS_TURBO_ARGS" diff --git a/examples/oft/package.json b/examples/oft/package.json index f96770c66..304dd2790 100644 --- a/examples/oft/package.json +++ b/examples/oft/package.json @@ -17,6 +17,7 @@ "@layerzerolabs/lz-evm-oapp-v2": "~1.5.69", "@layerzerolabs/prettier-config-next": "^1.5.69", "@layerzerolabs/solhint-config": "^1.5.69", + "@nomicfoundation/hardhat-ethers": "^3.0.2", "@nomiclabs/hardhat-ethers": "^2.2.3", "@rushstack/eslint-patch": "^1.5.1", "ethers": "^5.7.0", diff --git a/packages/ua-utils-evm-hardhat-test/package.json b/packages/ua-utils-evm-hardhat-test/package.json index 5b72e44ae..8cee8830b 100644 --- a/packages/ua-utils-evm-hardhat-test/package.json +++ b/packages/ua-utils-evm-hardhat-test/package.json @@ -33,7 +33,7 @@ "@layerzerolabs/utils": "~0.0.1", "@layerzerolabs/utils-evm": "~0.0.1", "@layerzerolabs/utils-evm-hardhat": "~0.0.1", - "@nomiclabs/hardhat-ethers": "^2.2.3", + "@nomicfoundation/hardhat-ethers": "^3.0.2", "@types/chai-as-promised": "^7.1.7", "@types/mocha": "^10.0.6", "chai": "^4.3.10", @@ -41,7 +41,7 @@ "ethers": "^5.7.0", "hardhat": "^2.19.2", "hardhat-deploy": "^0.11.22", - "hardhat-deploy-ethers": "^0.3.0-beta.12", + "hardhat-deploy-ethers": "^0.4.1", "sinon": "^17.0.1", "ts-node": "^10.9.1", "typescript": "^5.2.2" diff --git a/packages/ua-utils-evm-hardhat/package.json b/packages/ua-utils-evm-hardhat/package.json index e34ea4a5e..6dae08069 100644 --- a/packages/ua-utils-evm-hardhat/package.json +++ b/packages/ua-utils-evm-hardhat/package.json @@ -45,7 +45,6 @@ "@layerzerolabs/ua-utils": "~0.1.0", "@layerzerolabs/utils": "~0.0.1", "@layerzerolabs/utils-evm-hardhat": "~0.0.2", - "@nomiclabs/hardhat-ethers": "^2.2.3", "@types/jest": "^29.5.10", "cli-ux": "^6.0.9", "dotenv": "^16.0.3", @@ -70,7 +69,6 @@ "@layerzerolabs/ua-utils": "~0.1.0", "@layerzerolabs/utils": "~0.0.1", "@layerzerolabs/utils-evm-hardhat": "~0.0.2", - "@nomiclabs/hardhat-ethers": "^2.2.3", "ethers": "^5.5.2", "hardhat": "^2.19.2", "hardhat-deploy": "^0.11.22" diff --git a/packages/utils-evm-test/package.json b/packages/utils-evm-test/package.json index 76b7ef2b3..0ef9e6a77 100644 --- a/packages/utils-evm-test/package.json +++ b/packages/utils-evm-test/package.json @@ -23,6 +23,7 @@ "@layerzerolabs/test-utils": "~0.0.1", "@layerzerolabs/utils": "~0.0.1", "@layerzerolabs/utils-evm": "~0.0.1", + "@nomicfoundation/hardhat-ethers": "^3.0.2", "@nomiclabs/hardhat-ethers": "^2.2.3", "@types/mocha": "^10.0.6", "chai": "^4.3.10", diff --git a/packages/utils-evm-test/test/errors/parser.test.ts b/packages/utils-evm-test/test/errors/parser.test.ts index 33a2fbec8..14c4f0a3e 100644 --- a/packages/utils-evm-test/test/errors/parser.test.ts +++ b/packages/utils-evm-test/test/errors/parser.test.ts @@ -185,8 +185,14 @@ describe('errors/parser', () => { expect(parsedError.point).to.eql(point) expect(parsedError.error).to.be.instanceOf(UnknownError) expect(parsedError.error.reason).to.be.undefined - expect(parsedError.error.message).to.eql(`Unknown error: ${error}`) - }) + expect(parsedError.error.message).to.match(/Unknown error: /) + }), + // Test case for when toString method of the error is not defined + { + seed: 223418789, + path: '40:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:1:77:77', + endOnFailure: true, + } ) }) diff --git a/packages/utils-evm/src/errors/parser.ts b/packages/utils-evm/src/errors/parser.ts index 7be417ee7..8e205dff3 100644 --- a/packages/utils-evm/src/errors/parser.ts +++ b/packages/utils-evm/src/errors/parser.ts @@ -32,12 +32,12 @@ export const createErrorParser = if (customError != null) return { point, error: customError } // If none of the decoding works, we'll send a generic error back - return { point, error: new UnknownError(`Unknown error: ${error}`) } + return { point, error: new UnknownError(`Unknown error: ${toStringSafe(error)}`) } } catch { // If we fail, we send an unknown error back return { point, - error: new UnknownError(`Unexpected error: ${error}`), + error: new UnknownError(`Unexpected error: ${toStringSafe(error)}`), } } } @@ -122,3 +122,20 @@ const getErrorDataCandidates = (error: unknown): string[] => [(error as any)?.error?.data?.data, (error as any)?.error?.data, (error as any)?.data].filter( (candidate: unknown) => typeof candidate === 'string' ) + +/** + * Solves an issue with objects that cannot be converted to primitive values + * and when stringified, they fail + * + * See https://stackoverflow.com/questions/41164750/cannot-convert-object-to-primitive-value + * + * @param {unknown} obj + * @returns {string} String representation of an object or `'[unknown]'` + */ +const toStringSafe = (obj: unknown): string => { + try { + return String(obj) + } catch { + return '[unknown]' + } +} diff --git a/yarn.lock b/yarn.lock index 63e8d7a36..a1dbf5a7a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2033,6 +2033,14 @@ mcl-wasm "^0.7.1" rustbn.js "~0.2.0" +"@nomicfoundation/hardhat-ethers@^3.0.2": + version "3.0.5" + resolved "https://registry.yarnpkg.com/@nomicfoundation/hardhat-ethers/-/hardhat-ethers-3.0.5.tgz#0422c2123dec7c42e7fb2be8e1691f1d9708db56" + integrity sha512-RNFe8OtbZK6Ila9kIlHp0+S80/0Bu/3p41HUpaRIoHLm6X3WekTd83vob3rE54Duufu1edCiBDxspBzi2rxHHw== + dependencies: + debug "^4.1.1" + lodash.isequal "^4.5.0" + "@nomicfoundation/solidity-analyzer-darwin-arm64@0.1.1": version "0.1.1" resolved "https://registry.npmjs.org/@nomicfoundation/solidity-analyzer-darwin-arm64/-/solidity-analyzer-darwin-arm64-0.1.1.tgz" @@ -2101,7 +2109,7 @@ "@nomiclabs/hardhat-ethers@^2.2.3": version "2.2.3" - resolved "https://registry.npmjs.org/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz" + resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0" integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg== "@oclif/core@^1.1.1": @@ -6804,11 +6812,6 @@ hardhat-contract-sizer@^2.10.0: cli-table3 "^0.6.0" strip-ansi "^6.0.0" -hardhat-deploy-ethers@^0.3.0-beta.12: - version "0.3.0-beta.13" - resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.3.0-beta.13.tgz#b96086ff768ddf69928984d5eb0a8d78cfca9366" - integrity sha512-PdWVcKB9coqWV1L7JTpfXRCI91Cgwsm7KLmBcwZ8f0COSm1xtABHZTyz3fvF6p42cTnz1VM0QnfDvMFlIRkSNw== - hardhat-deploy-ethers@^0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/hardhat-deploy-ethers/-/hardhat-deploy-ethers-0.4.1.tgz#dd70b0cc413ed99e98994047b383a004cf1c14f8"