From d64f10b61ce638c46628a7b09e00016ec02cb201 Mon Sep 17 00:00:00 2001 From: Wil Wade Date: Wed, 4 Aug 2021 15:17:01 -0400 Subject: [PATCH] Update resolveRegistration return values in 404 case. (#40) --- README.md | 2 + contracts/IRegistry.sol | 2 +- contracts/Registry.sol | 4 +- package-lock.json | 110 ++++++++++++++++++++-------------------- package.json | 6 +-- test/Registry.test.ts | 13 +++-- 6 files changed, 69 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 8a3efe0..25d7fd5 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ The official DSNP interface and implementations. ## Overview +**Target DSNP Spec Version**: v0.9.1 + ### Installation ```console diff --git a/contracts/IRegistry.sol b/contracts/IRegistry.sol index b771324..d10ce66 100644 --- a/contracts/IRegistry.sol +++ b/contracts/IRegistry.sol @@ -106,7 +106,7 @@ interface IRegistry { * @dev Resolve a handle to a DSNP Id and contract address * @param handle The handle to resolve * - * rejects if not found + * Returns zeros if not found * @return A tuple of the DSNP Id and the Address of the contract */ function resolveRegistration(string calldata handle) external view returns (uint64, address); diff --git a/contracts/Registry.sol b/contracts/Registry.sol index 12e4469..b8235ec 100644 --- a/contracts/Registry.sol +++ b/contracts/Registry.sol @@ -260,7 +260,7 @@ contract Registry is IRegistry { * @dev Resolve a handle to a DSNP Id and contract address * @param handle The handle to resolve * - * rejects if not found + * Returns zeros if not found * @return A tuple of the DSNP Id and the Address of the contract */ function resolveRegistration(string calldata handle) @@ -271,7 +271,7 @@ contract Registry is IRegistry { { Registration memory reg = registrations[handle]; - require(reg.id != 0, "Handle does not exist"); + if (reg.id == 0) return (0, address(0)); return (reg.id, reg.identityAddress); } diff --git a/package-lock.json b/package-lock.json index f2fe7ba..ecaf359 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,16 +22,16 @@ "chai": "^4.3.4", "dotenv": "10.0.0", "ethereum-waffle": "^3.4.0", - "ethers": "^5.4.1", + "ethers": "^5.4.3", "hardhat": "^2.4.3", "hardhat-gas-reporter": "^1.0.4", "js-sha3": "^0.8.0", "prettier": "^2.3.2", - "prettier-plugin-solidity": "^1.0.0-beta.14", + "prettier-plugin-solidity": "^1.0.0-beta.17", "solhint": "^3.3.6", "solhint-plugin-prettier": "0.0.5", "ts-generator": "^0.1.1", - "ts-node": "^10.0.0", + "ts-node": "^10.1.0", "typescript": "^4.3.5" } }, @@ -682,9 +682,9 @@ } }, "node_modules/@ethersproject/abstract-signer": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.0.tgz", - "integrity": "sha512-AieQAzt05HJZS2bMofpuxMEp81AHufA5D6M4ScKwtolj041nrfIbIi8ciNW7+F59VYxXq+V4c3d568Q6l2m8ew==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.1.tgz", + "integrity": "sha512-SkkFL5HVq1k4/25dM+NWP9MILgohJCgGv5xT5AcRruGz4ILpfHeBtO/y6j+Z3UN/PAjDeb4P7E51Yh8wcGNLGA==", "dev": true, "funding": [ { @@ -767,9 +767,9 @@ } }, "node_modules/@ethersproject/bignumber": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.0.tgz", - "integrity": "sha512-OXUu9f9hO3vGRIPxU40cignXZVaYyfx6j9NNMjebKdnaCL3anCLSSy8/b8d03vY6dh7duCC0kW72GEC4tZer2w==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.1.tgz", + "integrity": "sha512-fJhdxqoQNuDOk6epfM7yD6J8Pol4NUCy1vkaGAkuujZm0+lNow//MKu1hLhRiYV4BsOHyBv5/lsTjF+7hWwhJg==", "dev": true, "funding": [ { @@ -826,9 +826,9 @@ } }, "node_modules/@ethersproject/contracts": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.0.tgz", - "integrity": "sha512-hkO3L3IhS1Z3ZtHtaAG/T87nQ7KiPV+/qnvutag35I0IkiQ8G3ZpCQ9NNOpSCzn4pWSW4CfzmtE02FcqnLI+hw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.1.tgz", + "integrity": "sha512-m+z2ZgPy4pyR15Je//dUaymRUZq5MtDajF6GwFbGAVmKz/RF+DNIPwF0k5qEcL3wPGVqUjFg2/krlCRVTU4T5w==", "dev": true, "funding": [ { @@ -1041,9 +1041,9 @@ } }, "node_modules/@ethersproject/providers": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.1.tgz", - "integrity": "sha512-p06eiFKz8nu/5Ju0kIX024gzEQIgE5pvvGrBCngpyVjpuLtUIWT3097Agw4mTn9/dEA0FMcfByzFqacBMSgCVg==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.3.tgz", + "integrity": "sha512-VURwkaWPoUj7jq9NheNDT5Iyy64Qcyf6BOFDwVdHsmLmX/5prNjFrgSX3GHPE4z1BRrVerDxe2yayvXKFm/NNg==", "dev": true, "funding": [ { @@ -3763,9 +3763,9 @@ "dev": true }, "node_modules/ethers": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.4.1.tgz", - "integrity": "sha512-SrcddMdCgP1hukDvCPd87Aipbf4NWjQvdfAbZ65XSZGbfyuYPtIrUJPDH5B1SBRsdlfiEgX3eoz28DdBDzMNFg==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.4.3.tgz", + "integrity": "sha512-esWqdrFZObpyZyhH6VLHCz5vRA/YJrEmQO77sALWSWFjFtJr5ITIRwJ448N+mxIrvnqjZGQ2Jx2zC3xt5lc64g==", "dev": true, "funding": [ { @@ -3780,14 +3780,14 @@ "dependencies": { "@ethersproject/abi": "5.4.0", "@ethersproject/abstract-provider": "5.4.0", - "@ethersproject/abstract-signer": "5.4.0", + "@ethersproject/abstract-signer": "5.4.1", "@ethersproject/address": "5.4.0", "@ethersproject/base64": "5.4.0", "@ethersproject/basex": "5.4.0", - "@ethersproject/bignumber": "5.4.0", + "@ethersproject/bignumber": "5.4.1", "@ethersproject/bytes": "5.4.0", "@ethersproject/constants": "5.4.0", - "@ethersproject/contracts": "5.4.0", + "@ethersproject/contracts": "5.4.1", "@ethersproject/hash": "5.4.0", "@ethersproject/hdnode": "5.4.0", "@ethersproject/json-wallets": "5.4.0", @@ -3796,7 +3796,7 @@ "@ethersproject/networks": "5.4.1", "@ethersproject/pbkdf2": "5.4.0", "@ethersproject/properties": "5.4.0", - "@ethersproject/providers": "5.4.1", + "@ethersproject/providers": "5.4.3", "@ethersproject/random": "5.4.0", "@ethersproject/rlp": "5.4.0", "@ethersproject/sha2": "5.4.0", @@ -15803,9 +15803,9 @@ } }, "node_modules/prettier-plugin-solidity": { - "version": "1.0.0-beta.14", - "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.14.tgz", - "integrity": "sha512-hzEYYAY66NiOE5sfgJsVJa8uSk+v8eIK2/eGMi9unLxEkhtc0jgiB8LpBnQgHM13hRCkL/wIm8lnIYHeHUSJZA==", + "version": "1.0.0-beta.17", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.17.tgz", + "integrity": "sha512-YFkxV/rHi1mphi17/XKcJ9QjZlb+L/J0yY2erix21BZfzPv2BN9dfmSRGr/poDp/FBOFSW+jteP2BCMe7HndVQ==", "dev": true, "dependencies": { "@solidity-parser/parser": "^0.13.2", @@ -17290,9 +17290,9 @@ } }, "node_modules/ts-node": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.0.0.tgz", - "integrity": "sha512-ROWeOIUvfFbPZkoDis0L/55Fk+6gFQNZwwKPLinacRl6tsxstTF1DbAcLKkovwnpKMVvOMHP1TIbnwXwtLg1gg==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.1.0.tgz", + "integrity": "sha512-6szn3+J9WyG2hE+5W8e0ruZrzyk1uFLYye6IGMBadnOzDh8aP7t8CbFpsfCiEx2+wMixAhjFt7lOZC4+l+WbEA==", "dev": true, "dependencies": { "@tsconfig/node10": "^1.0.7", @@ -17317,8 +17317,8 @@ "node": ">=12.0.0" }, "peerDependencies": { - "@swc/core": ">=1.2.45", - "@swc/wasm": ">=1.2.45", + "@swc/core": ">=1.2.50", + "@swc/wasm": ">=1.2.50", "@types/node": "*", "typescript": ">=2.7" }, @@ -18574,9 +18574,9 @@ } }, "@ethersproject/abstract-signer": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.0.tgz", - "integrity": "sha512-AieQAzt05HJZS2bMofpuxMEp81AHufA5D6M4ScKwtolj041nrfIbIi8ciNW7+F59VYxXq+V4c3d568Q6l2m8ew==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.4.1.tgz", + "integrity": "sha512-SkkFL5HVq1k4/25dM+NWP9MILgohJCgGv5xT5AcRruGz4ILpfHeBtO/y6j+Z3UN/PAjDeb4P7E51Yh8wcGNLGA==", "dev": true, "requires": { "@ethersproject/abstract-provider": "^5.4.0", @@ -18619,9 +18619,9 @@ } }, "@ethersproject/bignumber": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.0.tgz", - "integrity": "sha512-OXUu9f9hO3vGRIPxU40cignXZVaYyfx6j9NNMjebKdnaCL3anCLSSy8/b8d03vY6dh7duCC0kW72GEC4tZer2w==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.4.1.tgz", + "integrity": "sha512-fJhdxqoQNuDOk6epfM7yD6J8Pol4NUCy1vkaGAkuujZm0+lNow//MKu1hLhRiYV4BsOHyBv5/lsTjF+7hWwhJg==", "dev": true, "requires": { "@ethersproject/bytes": "^5.4.0", @@ -18648,9 +18648,9 @@ } }, "@ethersproject/contracts": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.0.tgz", - "integrity": "sha512-hkO3L3IhS1Z3ZtHtaAG/T87nQ7KiPV+/qnvutag35I0IkiQ8G3ZpCQ9NNOpSCzn4pWSW4CfzmtE02FcqnLI+hw==", + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/@ethersproject/contracts/-/contracts-5.4.1.tgz", + "integrity": "sha512-m+z2ZgPy4pyR15Je//dUaymRUZq5MtDajF6GwFbGAVmKz/RF+DNIPwF0k5qEcL3wPGVqUjFg2/krlCRVTU4T5w==", "dev": true, "requires": { "@ethersproject/abi": "^5.4.0", @@ -18775,9 +18775,9 @@ } }, "@ethersproject/providers": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.1.tgz", - "integrity": "sha512-p06eiFKz8nu/5Ju0kIX024gzEQIgE5pvvGrBCngpyVjpuLtUIWT3097Agw4mTn9/dEA0FMcfByzFqacBMSgCVg==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/@ethersproject/providers/-/providers-5.4.3.tgz", + "integrity": "sha512-VURwkaWPoUj7jq9NheNDT5Iyy64Qcyf6BOFDwVdHsmLmX/5prNjFrgSX3GHPE4z1BRrVerDxe2yayvXKFm/NNg==", "dev": true, "requires": { "@ethersproject/abstract-provider": "^5.4.0", @@ -21000,21 +21000,21 @@ } }, "ethers": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.4.1.tgz", - "integrity": "sha512-SrcddMdCgP1hukDvCPd87Aipbf4NWjQvdfAbZ65XSZGbfyuYPtIrUJPDH5B1SBRsdlfiEgX3eoz28DdBDzMNFg==", + "version": "5.4.3", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.4.3.tgz", + "integrity": "sha512-esWqdrFZObpyZyhH6VLHCz5vRA/YJrEmQO77sALWSWFjFtJr5ITIRwJ448N+mxIrvnqjZGQ2Jx2zC3xt5lc64g==", "dev": true, "requires": { "@ethersproject/abi": "5.4.0", "@ethersproject/abstract-provider": "5.4.0", - "@ethersproject/abstract-signer": "5.4.0", + "@ethersproject/abstract-signer": "5.4.1", "@ethersproject/address": "5.4.0", "@ethersproject/base64": "5.4.0", "@ethersproject/basex": "5.4.0", - "@ethersproject/bignumber": "5.4.0", + "@ethersproject/bignumber": "5.4.1", "@ethersproject/bytes": "5.4.0", "@ethersproject/constants": "5.4.0", - "@ethersproject/contracts": "5.4.0", + "@ethersproject/contracts": "5.4.1", "@ethersproject/hash": "5.4.0", "@ethersproject/hdnode": "5.4.0", "@ethersproject/json-wallets": "5.4.0", @@ -21023,7 +21023,7 @@ "@ethersproject/networks": "5.4.1", "@ethersproject/pbkdf2": "5.4.0", "@ethersproject/properties": "5.4.0", - "@ethersproject/providers": "5.4.1", + "@ethersproject/providers": "5.4.3", "@ethersproject/random": "5.4.0", "@ethersproject/rlp": "5.4.0", "@ethersproject/sha2": "5.4.0", @@ -30289,9 +30289,9 @@ } }, "prettier-plugin-solidity": { - "version": "1.0.0-beta.14", - "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.14.tgz", - "integrity": "sha512-hzEYYAY66NiOE5sfgJsVJa8uSk+v8eIK2/eGMi9unLxEkhtc0jgiB8LpBnQgHM13hRCkL/wIm8lnIYHeHUSJZA==", + "version": "1.0.0-beta.17", + "resolved": "https://registry.npmjs.org/prettier-plugin-solidity/-/prettier-plugin-solidity-1.0.0-beta.17.tgz", + "integrity": "sha512-YFkxV/rHi1mphi17/XKcJ9QjZlb+L/J0yY2erix21BZfzPv2BN9dfmSRGr/poDp/FBOFSW+jteP2BCMe7HndVQ==", "dev": true, "requires": { "@solidity-parser/parser": "^0.13.2", @@ -31462,9 +31462,9 @@ } }, "ts-node": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.0.0.tgz", - "integrity": "sha512-ROWeOIUvfFbPZkoDis0L/55Fk+6gFQNZwwKPLinacRl6tsxstTF1DbAcLKkovwnpKMVvOMHP1TIbnwXwtLg1gg==", + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.1.0.tgz", + "integrity": "sha512-6szn3+J9WyG2hE+5W8e0ruZrzyk1uFLYye6IGMBadnOzDh8aP7t8CbFpsfCiEx2+wMixAhjFt7lOZC4+l+WbEA==", "dev": true, "requires": { "@tsconfig/node10": "^1.0.7", diff --git a/package.json b/package.json index 3d7deca..e55f508 100644 --- a/package.json +++ b/package.json @@ -44,16 +44,16 @@ "chai": "^4.3.4", "dotenv": "10.0.0", "ethereum-waffle": "^3.4.0", - "ethers": "^5.4.1", + "ethers": "^5.4.3", "hardhat": "^2.4.3", "hardhat-gas-reporter": "^1.0.4", "js-sha3": "^0.8.0", "prettier": "^2.3.2", - "prettier-plugin-solidity": "^1.0.0-beta.14", + "prettier-plugin-solidity": "^1.0.0-beta.17", "solhint": "^3.3.6", "solhint-plugin-prettier": "0.0.5", "ts-generator": "^0.1.1", - "ts-node": "^10.0.0", + "ts-node": "^10.1.0", "typescript": "^4.3.5" }, "dependencies": { diff --git a/test/Registry.test.ts b/test/Registry.test.ts index b75e017..f584ae8 100644 --- a/test/Registry.test.ts +++ b/test/Registry.test.ts @@ -271,10 +271,9 @@ describe("Registry", () => { it("clears old handle and frees it for registration", async () => { await registry.connect(signer1).changeHandle(handle, newHandle); - - await expect(registry.resolveRegistration(handle)).to.be.revertedWith( - "Handle does not exist" - ); + const [id, addr] = await registry.resolveRegistration(handle); + expect(addr).to.equal("0x0000000000000000000000000000000000000000"); + expect(id).to.equal("0x00"); await expect(registry.connect(signer2).register(delegate2.address, handle)) .to.emit(registry, "DSNPRegistryUpdate") @@ -336,9 +335,9 @@ describe("Registry", () => { const { v, r, s } = await signEIP712(signer1, registryDomain, handleChangeTypes, message); await registry.connect(signer2).changeHandleByEIP712Sig(v, r, s, message); - await expect(registry.resolveRegistration(handle)).to.be.revertedWith( - "Handle does not exist" - ); + const [id, addr] = await registry.resolveRegistration(handle); + expect(addr).to.equal("0x0000000000000000000000000000000000000000"); + expect(id).to.equal("0x00"); await expect(registry.connect(signer2).register(delegate2.address, handle)) .to.emit(registry, "DSNPRegistryUpdate")