diff --git a/contracts/import.sol b/contracts/import.sol index 00d8ee96..2f921473 100644 --- a/contracts/import.sol +++ b/contracts/import.sol @@ -15,6 +15,8 @@ import '@rsksmart/rif-relay-contracts/contracts/verifier/DeployVerifier.sol'; import '@rsksmart/rif-relay-contracts/contracts/verifier/RelayVerifier.sol'; import '@rsksmart/rif-relay-contracts/contracts/verifier/BoltzRelayVerifier.sol'; import '@rsksmart/rif-relay-contracts/contracts/verifier/BoltzDeployVerifier.sol'; +import '@rsksmart/rif-relay-contracts/contracts/verifier/MinimalBoltzRelayVerifier.sol'; +import '@rsksmart/rif-relay-contracts/contracts/verifier/MinimalBoltzDeployVerifier.sol'; import '@rsksmart/rif-relay-contracts/contracts/Penalizer.sol'; import '@rsksmart/rif-relay-contracts/contracts/utils/UtilToken.sol'; import '@rsksmart/rif-relay-contracts/contracts/interfaces/IForwarder.sol'; diff --git a/package-lock.json b/package-lock.json index e721e8aa..f7a26810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2432,7 +2432,7 @@ }, "node_modules/@rsksmart/rif-relay-client": { "version": "2.1.0", - "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-client.git#70adad7b92b72b7aa6363c6042fff4541174760b", + "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-client.git#987434ae5a4932ac1aecd66f15c261f0af733a57", "license": "MIT", "dependencies": { "bignumber.js": "^9.1.1", @@ -2447,7 +2447,7 @@ }, "node_modules/@rsksmart/rif-relay-contracts": { "version": "2.0.0-beta.1", - "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-contracts.git#60184e7a95f02b05d251cfdd778eaa90f4d322e3", + "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-contracts.git#5f164560512301319f5a41aa80a8dfb3ab3d4ad2", "license": "MIT", "dependencies": { "@metamask/eth-sig-util": "^4.0.1", @@ -2584,7 +2584,7 @@ }, "node_modules/@rsksmart/rif-relay-server": { "version": "2.2.2", - "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-server.git#403423f79bcca76064ea3592a04cf05d91e63daf", + "resolved": "git+ssh://git@github.com/rsksmart/rif-relay-server.git#e6760c1c0929d280215860a1f2d5c138bd61e580", "license": "MIT", "dependencies": { "@rsksmart/rif-relay-client": "github:rsksmart/rif-relay-client#PP-885/explore-solution-b2", @@ -3129,9 +3129,9 @@ "peer": true }, "node_modules/@types/node": { - "version": "18.19.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.14.tgz", - "integrity": "sha512-EnQ4Us2rmOS64nHDWr0XqAD8DsO6f3XR6lf9UIIrZQpUzPVdN/oPuEzfDWNHSyXLvoGgjuEm/sPwFGSSs35Wtg==", + "version": "18.19.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.15.tgz", + "integrity": "sha512-AMZ2UWx+woHNfM11PyAEQmfSxi05jm9OlkxczuHeEqmvwPkYj6MWv44gbzDPefYOLysTOFyI3ziiy2ONmUZfpA==", "dependencies": { "undici-types": "~5.26.4" } @@ -3188,9 +3188,9 @@ } }, "node_modules/@types/semver": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", - "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==" + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.7.tgz", + "integrity": "sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==" }, "node_modules/@types/send": { "version": "0.17.4", @@ -3700,15 +3700,6 @@ "node": ">=0.4.0" } }, - "node_modules/address": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/address/-/address-1.2.2.tgz", - "integrity": "sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==", - "peer": true, - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/adm-zip": { "version": "0.4.16", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", @@ -4346,9 +4337,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001585", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001585.tgz", - "integrity": "sha512-yr2BWR1yLXQ8fMpdS/4ZZXpseBgE7o4g41x3a6AJOqZuOi+iE/WdJYAuZ6Y95i4Ohd2Y+9MzIWRR+uGABH4s3Q==", + "version": "1.0.30001587", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz", + "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==", "funding": [ { "type": "opencollective", @@ -5244,17 +5235,20 @@ "peer": true }, "node_modules/define-data-property": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", - "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.3.tgz", + "integrity": "sha512-h3GBouC+RPtNX2N0hHVLo2ZwPYurq8mLmXpOLTsw71gr7lHt5VaI4vVkDUNOfiWmm48JEXe3VM7PmLX45AMmmg==", "dependencies": { "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" }, "engines": { "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, "node_modules/delayed-stream": { @@ -5282,20 +5276,6 @@ "npm": "1.2.8000 || >= 1.4.16" } }, - "node_modules/detect-port": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/detect-port/-/detect-port-1.5.1.tgz", - "integrity": "sha512-aBzdj76lueB6uUst5iAs7+0H/oOjqI5D16XUWxlWMIMROhcM0rfsNVk93zTngq1dDNpoXRr++Sus7ETAExppAQ==", - "peer": true, - "dependencies": { - "address": "^1.0.1", - "debug": "4" - }, - "bin": { - "detect": "bin/detect-port.js", - "detect-port": "bin/detect-port.js" - } - }, "node_modules/dezalgo": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", @@ -5437,9 +5417,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "node_modules/electron-to-chromium": { - "version": "1.4.659", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.659.tgz", - "integrity": "sha512-sRJ3nV3HowrYpBtPF9bASQV7OW49IgZC01Xiq43WfSE3RTCkK0/JidoCmR73Hyc1mN+l/H4Yqx0eNiomvExFZg==" + "version": "1.4.667", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.667.tgz", + "integrity": "sha512-66L3pLlWhTNVUhnmSA5+qDM3fwnXsM6KAqE36e2w4KN0g6pkEtlT5bs41FQtQwVwKnfhNBXiWRLPs30HSxd7Kw==" }, "node_modules/elliptic": { "version": "6.5.4", @@ -7631,9 +7611,9 @@ } }, "node_modules/hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", "dependencies": { "function-bind": "^1.1.2" }, @@ -9231,9 +9211,9 @@ } }, "node_modules/mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.3.0.tgz", + "integrity": "sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg==", "dependencies": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", @@ -9242,13 +9222,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -9263,10 +9242,6 @@ }, "engines": { "node": ">= 14.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/mochajs" } }, "node_modules/mocha/node_modules/ansi-colors": { @@ -9321,6 +9296,24 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/mocha/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha/node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -9401,9 +9394,15 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==", + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], "bin": { "nanoid": "bin/nanoid.cjs" }, @@ -9967,9 +9966,9 @@ } }, "node_modules/postcss": { - "version": "8.4.34", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.34.tgz", - "integrity": "sha512-4eLTO36woPSocqZ1zIrFD2K1v6wH7pY1uBh0JIM2KKfrVtGvPFiAku6aNOP0W1Wr9qwnaCsF0Z+CrVnryB2A8Q==", + "version": "8.4.35", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", + "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==", "funding": [ { "type": "opencollective", @@ -10065,23 +10064,6 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, - "node_modules/postcss/node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.cjs" - }, - "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -11109,9 +11091,9 @@ } }, "node_modules/sinon/node_modules/diff": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", - "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true, "engines": { "node": ">=0.3.1" @@ -11218,16 +11200,15 @@ } }, "node_modules/solidity-coverage": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.8.6.tgz", - "integrity": "sha512-vV03mA/0nNMskOdVwNarUcqk0N/aYdelxAbf6RZ5l84FcYHbqDTr2JXyeYMp4bT48qHtAQjnKrygW1FrECyWNw==", + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.8.7.tgz", + "integrity": "sha512-RzcPuNsIqVGq5F8rjQZPdI2EVdsRU7w2f1Uk1UY567n9eNcg5LSEQ3Q1WFoy9bi/2AD5SYbYK9SS/Nwh2oYbNw==", "peer": true, "dependencies": { "@ethersproject/abi": "^5.0.9", "@solidity-parser/parser": "^0.18.0", "chalk": "^2.4.2", "death": "^1.1.0", - "detect-port": "^1.3.0", "difflib": "^0.2.4", "fs-extra": "^8.1.0", "ghost-testrpc": "^0.0.2", @@ -11428,9 +11409,9 @@ } }, "node_modules/spdx-license-ids": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.16.tgz", - "integrity": "sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==" + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.17.tgz", + "integrity": "sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==" }, "node_modules/split2": { "version": "3.2.2", @@ -11676,9 +11657,9 @@ } }, "node_modules/swagger-ui-dist": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.11.2.tgz", - "integrity": "sha512-jQG0cRgJNMZ7aCoiFofnoojeSaa/+KgWaDlfgs8QN+BXoGMpxeMVY5OEnjq4OlNvF3yjftO8c9GRAgcHlO+u7A==" + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.11.3.tgz", + "integrity": "sha512-vQ+Pe73xt7vMVbX40L6nHu4sDmNCM6A+eMVJPGvKrifHQ4LO3smH0jCiiefKzsVl7OlOcVEnrZ9IFzYwElfMkA==" }, "node_modules/swagger-ui-express": { "version": "4.6.3", @@ -14467,7 +14448,7 @@ "integrity": "sha512-z0zMCjyhhp4y7XKAcDAi3Vgms4T2PstwBdahiO0+9NaGICQKjynK3wduSRplTgk4LXmoO1yfDGO5RbjKYxtuxA==" }, "@rsksmart/rif-relay-client": { - "version": "git+ssh://git@github.com/rsksmart/rif-relay-client.git#70adad7b92b72b7aa6363c6042fff4541174760b", + "version": "git+ssh://git@github.com/rsksmart/rif-relay-client.git#987434ae5a4932ac1aecd66f15c261f0af733a57", "from": "@rsksmart/rif-relay-client@github:rsksmart/rif-relay-client#PP-885/explore-solution-b2", "requires": { "bignumber.js": "^9.1.1", @@ -14477,7 +14458,7 @@ } }, "@rsksmart/rif-relay-contracts": { - "version": "git+ssh://git@github.com/rsksmart/rif-relay-contracts.git#60184e7a95f02b05d251cfdd778eaa90f4d322e3", + "version": "git+ssh://git@github.com/rsksmart/rif-relay-contracts.git#5f164560512301319f5a41aa80a8dfb3ab3d4ad2", "from": "@rsksmart/rif-relay-contracts@github:rsksmart/rif-relay-contracts#PP-885/explore-solution-b2", "requires": { "@metamask/eth-sig-util": "^4.0.1", @@ -14605,7 +14586,7 @@ } }, "@rsksmart/rif-relay-server": { - "version": "git+ssh://git@github.com/rsksmart/rif-relay-server.git#403423f79bcca76064ea3592a04cf05d91e63daf", + "version": "git+ssh://git@github.com/rsksmart/rif-relay-server.git#e6760c1c0929d280215860a1f2d5c138bd61e580", "from": "@rsksmart/rif-relay-server@github:rsksmart/rif-relay-server#PP-885/explore-solution-b2", "requires": { "@rsksmart/rif-relay-client": "github:rsksmart/rif-relay-client#PP-885/explore-solution-b2", @@ -15106,9 +15087,9 @@ "peer": true }, "@types/node": { - "version": "18.19.14", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.14.tgz", - "integrity": "sha512-EnQ4Us2rmOS64nHDWr0XqAD8DsO6f3XR6lf9UIIrZQpUzPVdN/oPuEzfDWNHSyXLvoGgjuEm/sPwFGSSs35Wtg==", + "version": "18.19.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.15.tgz", + "integrity": "sha512-AMZ2UWx+woHNfM11PyAEQmfSxi05jm9OlkxczuHeEqmvwPkYj6MWv44gbzDPefYOLysTOFyI3ziiy2ONmUZfpA==", "requires": { "undici-types": "~5.26.4" } @@ -15167,9 +15148,9 @@ } }, "@types/semver": { - "version": "7.5.6", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.6.tgz", - "integrity": "sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A==" + "version": "7.5.7", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.7.tgz", + "integrity": "sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==" }, "@types/send": { "version": "0.17.4", @@ -15562,12 +15543,6 @@ "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==" }, - "address": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/address/-/address-1.2.2.tgz", - "integrity": "sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==", - "peer": true - }, "adm-zip": { "version": "0.4.16", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.16.tgz", @@ -16047,9 +16022,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001585", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001585.tgz", - "integrity": "sha512-yr2BWR1yLXQ8fMpdS/4ZZXpseBgE7o4g41x3a6AJOqZuOi+iE/WdJYAuZ6Y95i4Ohd2Y+9MzIWRR+uGABH4s3Q==" + "version": "1.0.30001587", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001587.tgz", + "integrity": "sha512-HMFNotUmLXn71BQxg8cijvqxnIAofforZOwGsxyXJ0qugTdspUF4sPSJ2vhgprHCB996tIDzEq1ubumPDV8ULA==" }, "case": { "version": "1.6.3", @@ -16695,12 +16670,12 @@ "peer": true }, "define-data-property": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", - "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.3.tgz", + "integrity": "sha512-h3GBouC+RPtNX2N0hHVLo2ZwPYurq8mLmXpOLTsw71gr7lHt5VaI4vVkDUNOfiWmm48JEXe3VM7PmLX45AMmmg==", "requires": { "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.2", + "get-intrinsic": "^1.2.4", "gopd": "^1.0.1", "has-property-descriptors": "^1.0.1" } @@ -16720,16 +16695,6 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, - "detect-port": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/detect-port/-/detect-port-1.5.1.tgz", - "integrity": "sha512-aBzdj76lueB6uUst5iAs7+0H/oOjqI5D16XUWxlWMIMROhcM0rfsNVk93zTngq1dDNpoXRr++Sus7ETAExppAQ==", - "peer": true, - "requires": { - "address": "^1.0.1", - "debug": "4" - } - }, "dezalgo": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", @@ -16838,9 +16803,9 @@ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, "electron-to-chromium": { - "version": "1.4.659", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.659.tgz", - "integrity": "sha512-sRJ3nV3HowrYpBtPF9bASQV7OW49IgZC01Xiq43WfSE3RTCkK0/JidoCmR73Hyc1mN+l/H4Yqx0eNiomvExFZg==" + "version": "1.4.667", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.667.tgz", + "integrity": "sha512-66L3pLlWhTNVUhnmSA5+qDM3fwnXsM6KAqE36e2w4KN0g6pkEtlT5bs41FQtQwVwKnfhNBXiWRLPs30HSxd7Kw==" }, "elliptic": { "version": "6.5.4", @@ -18516,9 +18481,9 @@ } }, "hasown": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", - "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz", + "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==", "requires": { "function-bind": "^1.1.2" } @@ -19643,9 +19608,9 @@ } }, "mocha": { - "version": "10.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz", - "integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-10.3.0.tgz", + "integrity": "sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg==", "requires": { "ansi-colors": "4.1.1", "browser-stdout": "1.3.1", @@ -19654,13 +19619,12 @@ "diff": "5.0.0", "escape-string-regexp": "4.0.0", "find-up": "5.0.0", - "glob": "7.2.0", + "glob": "8.1.0", "he": "1.2.0", "js-yaml": "4.1.0", "log-symbols": "4.1.0", "minimatch": "5.0.1", "ms": "2.1.3", - "nanoid": "3.3.3", "serialize-javascript": "6.0.0", "strip-json-comments": "3.1.1", "supports-color": "8.1.1", @@ -19708,6 +19672,18 @@ "wrap-ansi": "^7.0.0" } }, + "glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + } + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -19769,9 +19745,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nanoid": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz", - "integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==" + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==" }, "napi-macros": { "version": "2.2.2", @@ -20194,20 +20170,13 @@ "peer": true }, "postcss": { - "version": "8.4.34", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.34.tgz", - "integrity": "sha512-4eLTO36woPSocqZ1zIrFD2K1v6wH7pY1uBh0JIM2KKfrVtGvPFiAku6aNOP0W1Wr9qwnaCsF0Z+CrVnryB2A8Q==", + "version": "8.4.35", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.35.tgz", + "integrity": "sha512-u5U8qYpBCpN13BsiEB0CbR1Hhh4Gc0zLFuedrHJKMctHCHAGrMdG0PRM/KErzAL3CU6/eckEtmHNB3x6e3c0vA==", "requires": { "nanoid": "^3.3.7", "picocolors": "^1.0.0", "source-map-js": "^1.0.2" - }, - "dependencies": { - "nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==" - } } }, "postcss-modules-extract-imports": { @@ -21005,9 +20974,9 @@ }, "dependencies": { "diff": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.1.0.tgz", - "integrity": "sha512-D+mk+qE8VC/PAUrlAU34N+VfXev0ghe5ywmpqrawphmVZc1bEfn56uo9qpyGp1p4xpzOHkSW4ztBd6L7Xx4ACw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", "dev": true } } @@ -21097,16 +21066,15 @@ } }, "solidity-coverage": { - "version": "0.8.6", - "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.8.6.tgz", - "integrity": "sha512-vV03mA/0nNMskOdVwNarUcqk0N/aYdelxAbf6RZ5l84FcYHbqDTr2JXyeYMp4bT48qHtAQjnKrygW1FrECyWNw==", + "version": "0.8.7", + "resolved": "https://registry.npmjs.org/solidity-coverage/-/solidity-coverage-0.8.7.tgz", + "integrity": "sha512-RzcPuNsIqVGq5F8rjQZPdI2EVdsRU7w2f1Uk1UY567n9eNcg5LSEQ3Q1WFoy9bi/2AD5SYbYK9SS/Nwh2oYbNw==", "peer": true, "requires": { "@ethersproject/abi": "^5.0.9", "@solidity-parser/parser": "^0.18.0", "chalk": "^2.4.2", "death": "^1.1.0", - "detect-port": "^1.3.0", "difflib": "^0.2.4", "fs-extra": "^8.1.0", "ghost-testrpc": "^0.0.2", @@ -21273,9 +21241,9 @@ } }, "spdx-license-ids": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.16.tgz", - "integrity": "sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==" + "version": "3.0.17", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.17.tgz", + "integrity": "sha512-sh8PWc/ftMqAAdFiBu6Fy6JUOYjqDJBJvIhpfDMyHrr0Rbp5liZqd4TjtQ/RgfLjKFZb+LMx5hpml5qOWy0qvg==" }, "split2": { "version": "3.2.2", @@ -21459,9 +21427,9 @@ } }, "swagger-ui-dist": { - "version": "5.11.2", - "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.11.2.tgz", - "integrity": "sha512-jQG0cRgJNMZ7aCoiFofnoojeSaa/+KgWaDlfgs8QN+BXoGMpxeMVY5OEnjq4OlNvF3yjftO8c9GRAgcHlO+u7A==" + "version": "5.11.3", + "resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-5.11.3.tgz", + "integrity": "sha512-vQ+Pe73xt7vMVbX40L6nHu4sDmNCM6A+eMVJPGvKrifHQ4LO3smH0jCiiefKzsVl7OlOcVEnrZ9IFzYwElfMkA==" }, "swagger-ui-express": { "version": "4.6.3", diff --git a/scripts/GasEstimation.ts b/scripts/GasEstimation.ts index f6092578..05c8fc83 100644 --- a/scripts/GasEstimation.ts +++ b/scripts/GasEstimation.ts @@ -26,15 +26,10 @@ import { SupportedType, SupportedSmartWallet, SupportedSmartWalletName, - SupportedSmartWalletFactory, getSmartWalletAddress, } from '../test/utils/TestUtils'; import { TestSwap, TestVerifierEverythingAccepted } from 'typechain-types'; -import { - Penalizer, - RelayHub, - SmartWallet, -} from '@rsksmart/rif-relay-contracts'; +import { Penalizer, RelayHub } from '@rsksmart/rif-relay-contracts'; import { expect } from 'chai'; const GAS_PRICE = '60000000'; @@ -123,11 +118,11 @@ async function deployAndSetup(payment: Payment = 'erc20') { erc20: 'Default', }; - const factory = (await createSmartWalletFactory( + const factory = await createSmartWalletFactory( template, supportedTypes[payment], owner - )) as SupportedSmartWalletFactory; + ); const tokenContracts: Record = { native: constants.AddressZero, @@ -288,7 +283,7 @@ async function getDestinationContractCallParams( transferReceiver: string, balanceToTransfer: string, token: UtilToken, - forwarder: SmartWallet, + forwarder: SupportedSmartWallet, native: boolean, swap: TestSwap ): Promise { @@ -334,13 +329,13 @@ async function estimateRelayCost(fees = NO_FEES, payment: Payment = 'erc20') { const isNative = isNativePayment(payment); - const smartWallet = (await createSupportedSmartWallet({ + const smartWallet: SupportedSmartWallet = await createSupportedSmartWallet({ relayHub: relayHubSigner.address, factory, owner, sender: relayHubSigner, type, - })) as SmartWallet; + }); // provide the SW with some tokens await token.mint( @@ -544,7 +539,6 @@ async function prepareDeployRequest( tokenContract: tokenContractAddress, tokenGas: tokenGas.toString(), value: '0', - gas: '0', validUntilTime: 0, index: SMART_WALLET_INDEX, recoverer: constants.AddressZero, @@ -580,14 +574,13 @@ async function estimateDeployCost( ...deployRequest, }; if (withExecution) { - const { to, data, gas } = await getExecutionParameters(swap, swAddress); + const { to, data } = await getExecutionParameters(swap, swAddress); updatedDeployRequest = { request: { ...deployRequest.request, to, data, - gas, }, relayData: { ...deployRequest.relayData, diff --git a/test/RelayHub.test.ts b/test/RelayHub.test.ts index 5e43edb7..4844a765 100644 --- a/test/RelayHub.test.ts +++ b/test/RelayHub.test.ts @@ -9,6 +9,8 @@ import { SmartWallet, BoltzSmartWalletFactory, BoltzSmartWallet, + MinimalBoltzSmartWalletFactory, + MinimalBoltzSmartWallet, } from '@rsksmart/rif-relay-contracts'; import { CommonEnvelopingRequestBody, @@ -109,11 +111,11 @@ describe('RelayHub', function () { value: ethers.utils.parseEther('1'), }); - factory = (await createSmartWalletFactory( + factory = await createSmartWalletFactory( smartWalletTemplate, 'Default', owner - )) as SmartWalletFactory; + ); }); describe('#add/disable relay workers', function () { const expectRelayWorkersAddedEvent = ( @@ -363,12 +365,12 @@ describe('RelayHub', function () { let forwarder: SmartWallet; beforeEach(async function () { - forwarder = (await createSupportedSmartWallet({ + forwarder = await createSupportedSmartWallet({ relayHub: relayHubSigner.address, factory, owner, sender: relayHubSigner, - })) as SmartWallet; + }); await token.mint('1000', forwarder.address); @@ -837,7 +839,6 @@ describe('RelayHub', function () { recoverer: ethers.constants.AddressZero, index: '0', validUntilTime: '0', - gas: '30000', }, relayData: { gasPrice, @@ -991,11 +992,11 @@ describe('RelayHub', function () { const smartWalletTemplate = await deployContract( 'BoltzSmartWallet' ); - boltzFactory = (await createSmartWalletFactory( + boltzFactory = await createSmartWalletFactory( smartWalletTemplate, 'Boltz', owner - )) as BoltzSmartWalletFactory; + ); swap = await deployContract('TestSwap'); await fundedAccount.sendTransaction({ to: swap.address, @@ -1046,13 +1047,14 @@ describe('RelayHub', function () { ); }); - it('should fail if not enough gas', async function () { + it('should fail if not enough native token to pay', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), to: swap.address, data, - gas: 0, + tokenAmount: claimedValue.add(ethers.utils.parseEther('0.5')), + tokenContract: constants.AddressZero, }, relayData: { callForwarder: boltzFactory.address, @@ -1070,17 +1072,45 @@ describe('RelayHub', function () { .connect(relayWorker) .deployCall(deployRequest, signature, { gasLimit }); - await expect(deployCall).to.be.rejectedWith('Unable to execute'); + await expect(deployCall).to.be.rejectedWith( + 'Unable to pay for deployment' + ); }); - it('should fail if not enough native token to pay', async function () { + it('should succeed paying with native token', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), to: swap.address, data, - tokenAmount: claimedValue.add(ethers.utils.parseEther('0.5')), tokenContract: constants.AddressZero, + tokenAmount: ethers.utils.parseEther('0.01'), + }, + relayData: { + callForwarder: boltzFactory.address, + }, + }); + + const { signature } = await signEnvelopingRequest( + deployRequest, + owner + ); + + nextWalletIndex++; + + const deployCall = relayHub + .connect(relayWorker) + .deployCall(deployRequest, signature, { gasLimit }); + + await expect(deployCall).not.to.be.rejected; + }); + + it('should fail if not enough token to pay', async function () { + const deployRequest = cloneDeployRequest({ + request: { + index: nextWalletIndex.toString(), + to: swap.address, + data, }, relayData: { callForwarder: boltzFactory.address, @@ -1103,14 +1133,13 @@ describe('RelayHub', function () { ); }); - it('should succeed paying with native token', async function () { + it('should fail if not enough gas to pay for token transfer', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), to: swap.address, data, - tokenContract: constants.AddressZero, - tokenAmount: ethers.utils.parseEther('0.01'), + tokenGas: 0, }, relayData: { callForwarder: boltzFactory.address, @@ -1128,10 +1157,12 @@ describe('RelayHub', function () { .connect(relayWorker) .deployCall(deployRequest, signature, { gasLimit }); - await expect(deployCall).not.to.be.rejected; + await expect(deployCall).to.be.rejectedWith( + 'Unable to pay for deployment' + ); }); - it('should fail if not enough token to pay', async function () { + it('should succeed paying with token', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), @@ -1143,6 +1174,80 @@ describe('RelayHub', function () { }, }); + const calculatedAddr = await boltzFactory.getSmartWalletAddress( + owner.address, + constants.AddressZero, + deployRequest.request.index + ); + + await token.mint('1', calculatedAddr); + + const { signature } = await signEnvelopingRequest( + deployRequest, + owner + ); + + nextWalletIndex++; + + const deployCall = relayHub + .connect(relayWorker) + .deployCall(deployRequest, signature, { gasLimit }); + + await expect(deployCall).not.to.be.rejected; + }); + }); + + context('with minimal boltz', function () { + let data: string; + let swap: TestSwap; + let minimalBoltzFactory: MinimalBoltzSmartWalletFactory; + let claimedValue: BigNumber; + + beforeEach(async function () { + const smartWalletTemplate = + await deployContract( + 'MinimalBoltzSmartWallet' + ); + minimalBoltzFactory = await createSmartWalletFactory( + smartWalletTemplate, + 'MinimalBoltz', + owner + ); + swap = await deployContract('TestSwap'); + await fundedAccount.sendTransaction({ + to: swap.address, + value: ethers.utils.parseEther('1'), + }); + + claimedValue = ethers.utils.parseEther('0.5'); + data = swap.interface.encodeFunctionData('claim', [ + constants.HashZero, + claimedValue, + constants.AddressZero, + 500, + ]); + }); + + it('should fail if revert from destination contract', async function () { + data = swap.interface.encodeFunctionData('claim', [ + constants.HashZero, + ethers.utils.parseEther('2'), + constants.AddressZero, + 500, + ]); + + const deployRequest = cloneDeployRequest({ + request: { + index: nextWalletIndex.toString(), + to: swap.address, + data, + tokenContract: constants.AddressZero, + }, + relayData: { + callForwarder: minimalBoltzFactory.address, + }, + }); + const { signature } = await signEnvelopingRequest( deployRequest, owner @@ -1155,20 +1260,21 @@ describe('RelayHub', function () { .deployCall(deployRequest, signature, { gasLimit }); await expect(deployCall).to.be.rejectedWith( - 'Unable to pay for deployment' + 'Could not transfer Ether' ); }); - it('should fail if not enough gas to pay for token transfer', async function () { + it('should fail if not enough native token to pay', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), to: swap.address, data, - tokenGas: 0, + tokenAmount: claimedValue.add(ethers.utils.parseEther('0.5')), + tokenContract: constants.AddressZero, }, relayData: { - callForwarder: boltzFactory.address, + callForwarder: minimalBoltzFactory.address, }, }); @@ -1188,25 +1294,47 @@ describe('RelayHub', function () { ); }); - it('should succeed paying with token', async function () { + it('should succeed paying with native token', async function () { const deployRequest = cloneDeployRequest({ request: { index: nextWalletIndex.toString(), to: swap.address, data, + tokenContract: constants.AddressZero, + tokenAmount: ethers.utils.parseEther('0.01'), }, relayData: { - callForwarder: boltzFactory.address, + callForwarder: minimalBoltzFactory.address, }, }); - const calculatedAddr = await boltzFactory.getSmartWalletAddress( - owner.address, - constants.AddressZero, - deployRequest.request.index + const { signature } = await signEnvelopingRequest( + deployRequest, + owner ); - await token.mint('1', calculatedAddr); + nextWalletIndex++; + + const deployCall = relayHub + .connect(relayWorker) + .deployCall(deployRequest, signature, { gasLimit }); + + await expect(deployCall).not.to.be.rejected; + }); + + it.skip('should fail if not enough gas to pay for native transfer', async function () { + const deployRequest = cloneDeployRequest({ + request: { + index: nextWalletIndex.toString(), + to: swap.address, + data, + tokenGas: 0, + tokenContract: constants.AddressZero, + }, + relayData: { + callForwarder: minimalBoltzFactory.address, + }, + }); const { signature } = await signEnvelopingRequest( deployRequest, @@ -1219,7 +1347,9 @@ describe('RelayHub', function () { .connect(relayWorker) .deployCall(deployRequest, signature, { gasLimit }); - await expect(deployCall).not.to.be.rejected; + await expect(deployCall).to.be.rejectedWith( + 'Unable to pay for deployment' + ); }); }); diff --git a/test/relayclient/RelayClient.test.ts b/test/relayclient/RelayClient.test.ts index c448a45d..018fe522 100644 --- a/test/relayclient/RelayClient.test.ts +++ b/test/relayclient/RelayClient.test.ts @@ -6,7 +6,6 @@ import { deployRelayHub, RSK_URL, SupportedSmartWallet, - SupportedSmartWalletFactory, } from '../utils/TestUtils'; import { RelayHub, @@ -183,11 +182,11 @@ describe('RelayClient', function () { const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - smartWalletFactory = (await createSmartWalletFactory( + smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; + ); }); describe('should relay transaction', function () { @@ -569,7 +568,7 @@ describe('RelayClient', function () { expect(to).to.be.equal(relayHub.address); }); - describe('with boltz', function () { + describe('with contract execution during deploy', function () { let data: string; let swap: TestSwap; let boltzFactory: BoltzSmartWalletFactory; @@ -579,11 +578,11 @@ describe('RelayClient', function () { const smartWalletTemplate = await deployContract( 'BoltzSmartWallet' ); - boltzFactory = (await createSmartWalletFactory( + boltzFactory = await createSmartWalletFactory( smartWalletTemplate, 'Boltz', fundedAccount - )) as BoltzSmartWalletFactory; + ); loadConfiguration({ app: { ...basicAppConfig, @@ -598,7 +597,7 @@ describe('RelayClient', function () { ]); }); - it('without gas - tokenGas', async function () { + it('without tokenGas', async function () { await fundedAccount.sendTransaction({ to: swap.address, value: ethers.utils.parseEther('1'), @@ -659,11 +658,11 @@ describe('RelayClient', function () { const smartWalletTemplate = await deployContract( 'SmartWallet' ); - const smartWalletFactory = (await createSmartWalletFactory( + const smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SupportedSmartWalletFactory; + ); smartWallet = await createSupportedSmartWallet({ relayHub: relayWorker.address, sender: relayWorker, @@ -751,11 +750,11 @@ describe('RelayClient', function () { const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - const smartWalletFactory = (await createSmartWalletFactory( + const smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; + ); smartWallet = await createSupportedSmartWallet({ relayHub: relayWorker.address, sender: relayWorker, @@ -796,11 +795,11 @@ describe('RelayClient', function () { const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - const smartWalletFactory = (await createSmartWalletFactory( + const smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; + ); const mockServer = express(); mockServer.use(bodyParser.urlencoded({ extended: false })); diff --git a/test/relayserver/RelayServer.test.ts b/test/relayserver/RelayServer.test.ts index 488c2b6f..8038b94b 100644 --- a/test/relayserver/RelayServer.test.ts +++ b/test/relayserver/RelayServer.test.ts @@ -14,7 +14,8 @@ import { SmartWalletFactory, BoltzDeployVerifier, BoltzSmartWalletFactory, - BoltzSmartWallet, + MinimalBoltzDeployVerifier, + MinimalBoltzSmartWalletFactory, } from '@rsksmart/rif-relay-contracts'; import { createSupportedSmartWallet, @@ -26,6 +27,9 @@ import { generateRandomAddress, createUserDefinedRequest, deployContract, + SupportedType, + SupportedSmartWalletFactory, + SupportedDeployVerifier, } from '../utils/TestUtils'; import config from 'config'; import { @@ -414,6 +418,31 @@ describe('RelayServer', function () { let smartWalletFactory: SmartWalletFactory; let boltzVerifier: BoltzDeployVerifier; let boltzFactory: BoltzSmartWalletFactory; + let minimalBoltzVerifier: MinimalBoltzDeployVerifier; + let minimalBoltzFactory: MinimalBoltzSmartWalletFactory; + + async function prepareVerifier< + F extends SupportedSmartWalletFactory, + V extends SupportedDeployVerifier + >( + fundedAccount: SignerWithAddress, + type: SupportedType + ): Promise<{ factory: F; verifier: V }> { + const smartWalletTemplate: SupportedSmartWallet = await deployContract( + `${type === 'Default' ? '' : type}SmartWallet` + ); + const factory = await createSmartWalletFactory( + smartWalletTemplate, + 'Boltz', + fundedAccount + ); + const verifierFactory = await ethers.getContractFactory( + 'BoltzDeployVerifier' + ); + const verifier = (await verifierFactory.deploy(factory.address)) as V; + + return { factory, verifier }; + } beforeEach(async function () { const [worker, fundedAccount, relayOwner] = @@ -426,26 +455,27 @@ describe('RelayServer', function () { const fakeRelayVerifierAddress = generateRandomAddress(); relayHub = await deployRelayHub(); recipient = await deployContract('TestRecipient'); + const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - smartWalletFactory = (await createSmartWalletFactory( + smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; - const boltzSmartWalletTemplate: BoltzSmartWallet = await deployContract( - 'BoltzSmartWallet' ); - boltzFactory = (await createSmartWalletFactory( - boltzSmartWalletTemplate, - 'Boltz', - fundedAccount - )) as BoltzSmartWalletFactory; - const boltzVerifierFactory = await ethers.getContractFactory( - 'BoltzDeployVerifier' - ); - boltzVerifier = await boltzVerifierFactory.deploy(boltzFactory.address); + + ({ factory: boltzFactory, verifier: boltzVerifier } = + await prepareVerifier( + fundedAccount, + 'Boltz' + )); + ({ factory: minimalBoltzFactory, verifier: minimalBoltzVerifier } = + await prepareVerifier< + MinimalBoltzSmartWalletFactory, + MinimalBoltzDeployVerifier + >(fundedAccount, 'Boltz')); + loadConfiguration({ app: { ...basicAppConfig, @@ -457,6 +487,7 @@ describe('RelayServer', function () { fakeDeployVerifierAddress, fakeRelayVerifierAddress, boltzVerifier.address, + minimalBoltzVerifier.address, ], }, }); @@ -811,6 +842,93 @@ describe('RelayServer', function () { ).to.be.rejectedWith('Could not transfer Ether'); }); }); + + describe('with minimal boltz verifier', function () { + let swap: TestSwap; + let index = 1; + + beforeEach(async function () { + swap = await deployContract('TestSwap'); + encodedData = swap.interface.encodeFunctionData('claim', [ + constants.HashZero, + ethers.utils.parseEther('0.5'), + constants.AddressZero, + 500, + ]); + loadConfiguration({ + app: { + ...basicAppConfig, + allowedDestinations: [swap.address], + }, + }); + index++; + }); + + it('should relay deploy transaction with contract execution', async function () { + const [fundedAccount] = (await ethers.getSigners()) as [ + SignerWithAddress + ]; + await fundedAccount.sendTransaction({ + to: swap.address, + value: ethers.utils.parseEther('1'), + }); + const userDefinedRelayRequest = createUserDefinedRequest( + true, + { + from: owner.address, + to: swap.address, + data: encodedData, + index, + }, + { + callForwarder: minimalBoltzFactory.address, + callVerifier: minimalBoltzVerifier.address, + } + ); + + const envelopingTxRequest = await createEnvelopingTxRequest( + userDefinedRelayRequest, + relayClient, + hubInfo + ); + + await expect( + relayServer.createRelayTransaction( + stringifyEnvelopingTx(envelopingTxRequest) + ) + ).to.be.fulfilled; + }); + + it('should fail if verifier throws error', async function () { + const userDefinedRelayRequest = createUserDefinedRequest( + true, + { + from: owner.address, + to: swap.address, + data: encodedData, + tokenGas: 5000, + tokenAmount: ethers.utils.parseEther('5'), + index, + }, + { + callForwarder: minimalBoltzFactory.address, + callVerifier: minimalBoltzVerifier.address, + } + ); + + const envelopingTxRequest = await createEnvelopingTxRequest( + userDefinedRelayRequest, + relayClient, + hubInfo + ); + + await expect( + relayServer.createRelayTransaction( + stringifyEnvelopingTx(envelopingTxRequest) + ) + ).to.be.rejectedWith('Native balance too low'); + }); + }); }); }); @@ -1099,11 +1217,11 @@ describe('RelayServer', function () { const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - const smartWalletFactory = (await createSmartWalletFactory( + const smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; + ); smartWallet = await createSupportedSmartWallet({ relayHub: worker.address, sender: worker, @@ -1268,11 +1386,11 @@ describe('RelayServer', function () { const smartWalletTemplate: SmartWallet = await deployContract( 'SmartWallet' ); - const smartWalletFactory = (await createSmartWalletFactory( + const smartWalletFactory = await createSmartWalletFactory( smartWalletTemplate, 'Default', fundedAccount - )) as SmartWalletFactory; + ); ({ deployVerifier, relayVerifier } = await deployVerifiers< DeployVerifier, RelayVerifier diff --git a/test/relayserver/ServerTestUtils.ts b/test/relayserver/ServerTestUtils.ts index 92dc815c..4b0a7add 100644 --- a/test/relayserver/ServerTestUtils.ts +++ b/test/relayserver/ServerTestUtils.ts @@ -109,7 +109,7 @@ const stringifyEnvelopingTx = ( nonce: nonce.toString(), value: value.toString(), tokenAmount: tokenAmount.toString(), - gas: gas?.toString(), + ...(gas && { gas: gas.toString() }), }, relayData: { ...envelopingTx.relayRequest.relayData, diff --git a/test/smartwallet/CustomSmartWallet.test.ts b/test/smartwallet/CustomSmartWallet.test.ts index d3f5ac7a..96330a08 100644 --- a/test/smartwallet/CustomSmartWallet.test.ts +++ b/test/smartwallet/CustomSmartWallet.test.ts @@ -148,23 +148,19 @@ describe('Custom Smart Wallet using TestToken', function () { value: ethers.utils.parseEther('1'), }); - factory = (await createSmartWalletFactory( - template, - 'Custom', - owner - )) as CustomSmartWalletFactory; + factory = await createSmartWalletFactory(template, 'Custom', owner); token = await utilTokenFactory.deploy(); }); async function createCustomSmartWallet(customLogic: IWalletCustomLogic) { - const smartWallet = (await createSupportedSmartWallet({ + const smartWallet: CustomSmartWallet = await createSupportedSmartWallet({ relayHub: relayHub.address, owner, sender: relayHub, factory, logicAddr: customLogic.address, type: 'Custom', - })) as CustomSmartWallet; + }); await fillTokens(token, smartWallet.address, '1000'); diff --git a/test/smartwallet/baseSmartWallet.test.ts b/test/smartwallet/baseSmartWallet.test.ts index 749fa77c..ff4c46ce 100644 --- a/test/smartwallet/baseSmartWallet.test.ts +++ b/test/smartwallet/baseSmartWallet.test.ts @@ -1,8 +1,4 @@ import { BaseProvider } from '@ethersproject/providers'; -import { - CustomSmartWallet__factory, - SmartWallet__factory, -} from '@rsksmart/rif-relay-contracts'; import chai, { expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import { ethers as hardhat } from 'hardhat'; @@ -28,7 +24,6 @@ import { getSuffixData, SupportedSmartWallet, RSK_URL, - SupportedSmartWalletFactory, } from '../utils/TestUtils'; import { RelayRequest, @@ -69,17 +64,17 @@ TYPES_OF_WALLETS.forEach((typeOfWallet) => { switch (typeOfWallet) { case 'Default': { - const smartWalletFactory = (await hardhat.getContractFactory( + const smartWalletFactory = await hardhat.getContractFactory( 'SmartWallet' - )) as SmartWallet__factory; + ); supportedSmartWalletTemplate = await smartWalletFactory.deploy(); } break; case 'Custom': { - const customSmartWalletFactory = (await hardhat.getContractFactory( + const customSmartWalletFactory = await hardhat.getContractFactory( 'CustomSmartWallet' - )) as CustomSmartWallet__factory; + ); supportedSmartWalletTemplate = await customSmartWalletFactory.deploy(); } @@ -101,11 +96,11 @@ TYPES_OF_WALLETS.forEach((typeOfWallet) => { value: hardhat.utils.parseEther('10'), }); - const supportedSmartWalletFactory = (await createSmartWalletFactory( + const supportedSmartWalletFactory = await createSmartWalletFactory( supportedSmartWalletTemplate, typeOfWallet, owner - )) as SupportedSmartWalletFactory; + ); supportedSmartWallet = await createSupportedSmartWallet({ type: typeOfWallet, diff --git a/test/utils/TestUtils.ts b/test/utils/TestUtils.ts index 2f583e2f..b76466bb 100644 --- a/test/utils/TestUtils.ts +++ b/test/utils/TestUtils.ts @@ -12,7 +12,6 @@ import { RelayHub, SmartWalletFactory, CustomSmartWalletFactory, - IForwarder, SmartWallet, BoltzSmartWalletFactory, DeployVerifier, @@ -20,8 +19,12 @@ import { BoltzDeployVerifier, RelayVerifier, BoltzRelayVerifier, - MinimalBoltzSmartWallet, MinimalBoltzSmartWalletFactory, + BoltzSmartWallet, + CustomSmartWallet, + MinimalBoltzDeployVerifier, + MinimalBoltzRelayVerifier, + MinimalBoltzSmartWallet, } from '@rsksmart/rif-relay-contracts'; import { defaultEnvironment, @@ -46,7 +49,6 @@ import { } from '@rsksmart/rif-relay-client'; import { ethers } from 'hardhat'; import { keccak256, _TypedDataEncoder } from 'ethers/lib/utils'; -import { BoltzSmartWallet, CustomSmartWallet } from 'typechain-types'; import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { SignTypedDataVersion, TypedDataUtils } from '@metamask/eth-sig-util'; import { @@ -71,17 +73,18 @@ type SupportedSmartWalletName = | 'SmartWallet' | 'BoltzSmartWallet' | 'MinimalBoltzSmartWallet'; -type SupportedSmartWallet = - | CustomSmartWallet - | SmartWallet - | BoltzSmartWallet - | MinimalBoltzSmartWallet; +type SupportedSmartWallet = CustomSmartWallet | SmartWallet | BoltzSmartWallet; type SupportedSmartWalletFactory = | CustomSmartWalletFactory | SmartWalletFactory | BoltzSmartWalletFactory | MinimalBoltzSmartWalletFactory; type SupportedType = 'Custom' | 'Boltz' | 'MinimalBoltz' | 'Default'; +type SupportedDeployVerifier = + | DeployVerifier + | CustomSmartWalletDeployVerifier + | BoltzDeployVerifier + | MinimalBoltzDeployVerifier; type CreateSmartWalletParams = { relayHub: string; @@ -196,11 +199,8 @@ const deployRelayHub = async ( }; const deployVerifiers = async < - C1 extends - | DeployVerifier - | CustomSmartWalletDeployVerifier - | BoltzDeployVerifier, - C2 extends RelayVerifier | BoltzRelayVerifier + C1 extends SupportedDeployVerifier, + C2 extends RelayVerifier | BoltzRelayVerifier | MinimalBoltzRelayVerifier >( smartWalletFactory: SupportedSmartWalletFactory, type: SupportedType = 'Default' @@ -228,19 +228,21 @@ const deployVerifiers = async < }; }; -const createSmartWalletFactory = async ( - template: IForwarder, +const createSmartWalletFactory = async ( + template: SupportedSmartWallet | MinimalBoltzSmartWallet, type: SupportedType = 'Default', owner: Wallet | SignerWithAddress -) => { +): Promise => { const factory = await ethers.getContractFactory( `${type === 'Default' ? '' : type}SmartWalletFactory` ); - return factory.connect(owner).deploy(template.address); + return (await factory.connect(owner).deploy(template.address)) as T; }; -const createSupportedSmartWallet = async ({ +const createSupportedSmartWallet = async < + T extends SupportedSmartWallet | MinimalBoltzSmartWallet +>({ relayHub, sender, owner, @@ -255,7 +257,7 @@ const createSupportedSmartWallet = async ({ initParams = SHA3_NULL_S, type = 'Default', logGas = false, -}: CreateSmartWalletParams): Promise => { +}: CreateSmartWalletParams): Promise => { const envelopingRequest = createEnvelopingRequest( true, { @@ -314,7 +316,7 @@ const createSupportedSmartWallet = async ({ MinimalBoltz: MinimalBoltzSmartWalletJson.abi, }; - return new Contract(swAddress, abis[type], owner) as SupportedSmartWallet; + return new Contract(swAddress, abis[type], owner) as T; }; const prepareRelayTransaction = async ({ @@ -466,7 +468,6 @@ const baseDeployRequest: DeployRequestBody = { validUntilTime: '0', index: '0', data: '0x00', - gas: '0', }; const baseRelayRequest: RelayRequestBody = { @@ -625,4 +626,5 @@ export type { SupportedSmartWallet, SupportedSmartWalletFactory, SupportedType, + SupportedDeployVerifier, }; diff --git a/test/verifier/verifiers.test.ts b/test/verifier/verifiers.test.ts index efa2ce6a..44555287 100644 --- a/test/verifier/verifiers.test.ts +++ b/test/verifier/verifiers.test.ts @@ -2,6 +2,9 @@ import { BaseProvider } from '@ethersproject/providers'; import { BoltzSmartWalletFactory, DeployVerifier, + MinimalBoltzDeployVerifier, + MinimalBoltzRelayVerifier, + MinimalBoltzSmartWalletFactory, RelayVerifier, } from '@rsksmart/rif-relay-contracts'; import chai, { expect } from 'chai'; @@ -19,6 +22,7 @@ import { import { RelayRequest, DeployRequest } from '@rsksmart/rif-relay-client'; import { BoltzDeployVerifier, + MinimalBoltzSmartWallet, SmartWallet, SmartWalletFactory, TestSwap, @@ -233,14 +237,14 @@ describe('Verifiers tests', function () { smartWalletTemplate.address ); - smartWallet = (await createSupportedSmartWallet({ + smartWallet = await createSupportedSmartWallet({ relayHub: relayHub.address, sender: relayHub, owner, factory: smartWalletFactory, tokenContract: testToken.address, type: 'Default', - })) as SmartWallet; + }); await testToken.mint(TOKEN_AMOUNT_TO_TRANSFER + 10, smartWallet.address); @@ -616,4 +620,304 @@ describe('Verifiers tests', function () { }); }); }); + + describe('Minimal boltz deploy verifier', function () { + let swap: TestSwap; + let data: string; + let owner: Wallet; + let relayHub: SignerWithAddress; + let deployVerifier: MinimalBoltzDeployVerifier; + let smartWalletFactory: MinimalBoltzSmartWalletFactory; + + beforeEach(async function () { + swap = await deployContract('TestSwap'); + data = swap.interface.encodeFunctionData('claim', [ + constants.HashZero, + 2, + constants.AddressZero, + 500, + ]); + + const [, localRelayHub] = await hardhat.getSigners(); + relayHub = localRelayHub as SignerWithAddress; + + owner = Wallet.createRandom().connect(rskProvider); + + const hardHatSmartWalletFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWallet' + ); + const smartWalletTemplate = await hardHatSmartWalletFactory.deploy(); + + const hardHatWalletFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWalletFactory' + ); + + smartWalletFactory = await hardHatWalletFactory.deploy( + smartWalletTemplate.address + ); + + const deployVerifierFactory = await hardhat.getContractFactory( + 'MinimalBoltzDeployVerifier' + ); + deployVerifier = await deployVerifierFactory.deploy( + smartWalletFactory.address + ); + }); + + it('Should fail if there is a smartWallet already deployed at that address', async function () { + await createSupportedSmartWallet({ + relayHub: relayHub.address, + sender: relayHub, + owner, + factory: smartWalletFactory, + type: 'Default', + }); + + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + }, + { + callForwarder: smartWalletFactory.address, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect( + deployVerifier.verifyRelayedCall(deployRequest, signature) + ).to.be.rejectedWith('Address already created'); + }); + + it('Should fail if the factory is incorrect', async function () { + const wrongFactory = constants.AddressZero; + + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + }, + { + callForwarder: wrongFactory, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect( + deployVerifier.verifyRelayedCall(deployRequest, signature) + ).to.be.rejectedWith('Invalid factory'); + }); + + it('Should fail if payment is with ERC20 token', async function () { + const fakeToken = Wallet.createRandom(); + + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + tokenContract: fakeToken.address, + tokenAmount: 10000, + }, + { + callForwarder: smartWalletFactory.address, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect( + deployVerifier.verifyRelayedCall(deployRequest, signature) + ).to.be.rejectedWith('RBTC necessary for payment'); + }); + + it('Should fail if not enough native token for payment', async function () { + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + tokenAmount: 3, + }, + { + callForwarder: smartWalletFactory.address, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect( + deployVerifier.verifyRelayedCall(deployRequest, signature) + ).to.be.rejectedWith('Native balance too low'); + }); + + it('Should succeed in sponsored transactions', async function () { + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + }, + { + callForwarder: smartWalletFactory.address, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect(deployVerifier.verifyRelayedCall(deployRequest, signature)) + .not.to.be.rejected; + }); + + it('Should succeed destination contract provide enough balance', async function () { + const deployRequest = createEnvelopingRequest( + true, + { + relayHub: relayHub.address, + from: owner.address, + to: swap.address, + data, + tokenAmount: 1, + }, + { + callForwarder: smartWalletFactory.address, + callVerifier: deployVerifier.address, + } + ) as DeployRequest; + + const signature = '0x00'; + + await expect(deployVerifier.verifyRelayedCall(deployRequest, signature)) + .not.to.be.rejected; + }); + }); + + describe('Minimal boltz relay verifier', function () { + let owner: Wallet; + let relayHub: SignerWithAddress; + let relayVerifier: MinimalBoltzRelayVerifier; + let smartWalletFactory: MinimalBoltzSmartWalletFactory; + let smartWallet: MinimalBoltzSmartWallet; + + async function prepareSmartWallet() { + const hardHatSmartWalletFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWallet' + ); + const smartWalletTemplate = await hardHatSmartWalletFactory.deploy(); + + const hardHatSmartWalletFactoryFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWalletFactory' + ); + smartWalletFactory = await hardHatSmartWalletFactoryFactory.deploy( + smartWalletTemplate.address + ); + + const smartWallet = await createSupportedSmartWallet({ + relayHub: relayHub.address, + sender: relayHub, + owner, + factory: smartWalletFactory, + type: 'Default', + }); + + return smartWallet; + } + + beforeEach(async function () { + const [, localRelayHub] = await hardhat.getSigners(); + relayHub = localRelayHub as SignerWithAddress; + + owner = Wallet.createRandom().connect(rskProvider); + + const hardHatSmartWalletFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWallet' + ); + const smartWalletTemplate = await hardHatSmartWalletFactory.deploy(); + + const hardHatWalletFactory = await hardhat.getContractFactory( + 'MinimalBoltzSmartWalletFactory' + ); + + smartWalletFactory = await hardHatWalletFactory.deploy( + smartWalletTemplate.address + ); + + const relayVerifierFactory = await hardhat.getContractFactory( + 'MinimalBoltzRelayVerifier' + ); + + relayVerifier = await relayVerifierFactory.deploy( + smartWalletFactory.address + ); + + smartWallet = await createSupportedSmartWallet({ + relayHub: relayHub.address, + sender: relayHub, + owner, + factory: smartWalletFactory, + type: 'Default', + }); + }); + + it('Should fail if the factory is incorrect', async function () { + const wrongSmartWallet = await prepareSmartWallet(); + + const relayRequest = createEnvelopingRequest( + false, + { + relayHub: relayHub.address, + from: owner.address, + }, + { + callForwarder: wrongSmartWallet.address, + callVerifier: relayVerifier.address, + } + ) as RelayRequest; + + const signature = '0x00'; + + await expect( + relayVerifier.verifyRelayedCall(relayRequest, signature) + ).to.be.rejectedWith('SW different to template'); + }); + + it('Should always fail', async function () { + const relayRequest = createEnvelopingRequest( + false, + { + relayHub: relayHub.address, + from: owner.address, + }, + { + callForwarder: smartWallet.address, + callVerifier: relayVerifier.address, + } + ) as RelayRequest; + + const signature = '0x00'; + + await expect( + relayVerifier.verifyRelayedCall(relayRequest, signature) + ).to.be.rejectedWith('Deploy request accepted only'); + }); + }); });