Skip to content

Commit d64f10b

Browse files
authored
Update resolveRegistration return values in 404 case. (#40)
1 parent 5c945f0 commit d64f10b

File tree

6 files changed

+69
-68
lines changed

6 files changed

+69
-68
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ The official DSNP interface and implementations.
44

55
## Overview
66

7+
**Target DSNP Spec Version**: v0.9.1
8+
79
### Installation
810

911
```console

contracts/IRegistry.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ interface IRegistry {
106106
* @dev Resolve a handle to a DSNP Id and contract address
107107
* @param handle The handle to resolve
108108
*
109-
* rejects if not found
109+
* Returns zeros if not found
110110
* @return A tuple of the DSNP Id and the Address of the contract
111111
*/
112112
function resolveRegistration(string calldata handle) external view returns (uint64, address);

contracts/Registry.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ contract Registry is IRegistry {
260260
* @dev Resolve a handle to a DSNP Id and contract address
261261
* @param handle The handle to resolve
262262
*
263-
* rejects if not found
263+
* Returns zeros if not found
264264
* @return A tuple of the DSNP Id and the Address of the contract
265265
*/
266266
function resolveRegistration(string calldata handle)
@@ -271,7 +271,7 @@ contract Registry is IRegistry {
271271
{
272272
Registration memory reg = registrations[handle];
273273

274-
require(reg.id != 0, "Handle does not exist");
274+
if (reg.id == 0) return (0, address(0));
275275

276276
return (reg.id, reg.identityAddress);
277277
}

package-lock.json

Lines changed: 55 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@
4444
"chai": "^4.3.4",
4545
"dotenv": "10.0.0",
4646
"ethereum-waffle": "^3.4.0",
47-
"ethers": "^5.4.1",
47+
"ethers": "^5.4.3",
4848
"hardhat": "^2.4.3",
4949
"hardhat-gas-reporter": "^1.0.4",
5050
"js-sha3": "^0.8.0",
5151
"prettier": "^2.3.2",
52-
"prettier-plugin-solidity": "^1.0.0-beta.14",
52+
"prettier-plugin-solidity": "^1.0.0-beta.17",
5353
"solhint": "^3.3.6",
5454
"solhint-plugin-prettier": "0.0.5",
5555
"ts-generator": "^0.1.1",
56-
"ts-node": "^10.0.0",
56+
"ts-node": "^10.1.0",
5757
"typescript": "^4.3.5"
5858
},
5959
"dependencies": {

test/Registry.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,9 @@ describe("Registry", () => {
271271

272272
it("clears old handle and frees it for registration", async () => {
273273
await registry.connect(signer1).changeHandle(handle, newHandle);
274-
275-
await expect(registry.resolveRegistration(handle)).to.be.revertedWith(
276-
"Handle does not exist"
277-
);
274+
const [id, addr] = await registry.resolveRegistration(handle);
275+
expect(addr).to.equal("0x0000000000000000000000000000000000000000");
276+
expect(id).to.equal("0x00");
278277

279278
await expect(registry.connect(signer2).register(delegate2.address, handle))
280279
.to.emit(registry, "DSNPRegistryUpdate")
@@ -336,9 +335,9 @@ describe("Registry", () => {
336335
const { v, r, s } = await signEIP712(signer1, registryDomain, handleChangeTypes, message);
337336
await registry.connect(signer2).changeHandleByEIP712Sig(v, r, s, message);
338337

339-
await expect(registry.resolveRegistration(handle)).to.be.revertedWith(
340-
"Handle does not exist"
341-
);
338+
const [id, addr] = await registry.resolveRegistration(handle);
339+
expect(addr).to.equal("0x0000000000000000000000000000000000000000");
340+
expect(id).to.equal("0x00");
342341

343342
await expect(registry.connect(signer2).register(delegate2.address, handle))
344343
.to.emit(registry, "DSNPRegistryUpdate")

0 commit comments

Comments
 (0)