Skip to content

Commit

Permalink
Refactor setName/Text
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflau committed Nov 8, 2023
1 parent d25e521 commit 5ed5fa9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
27 changes: 16 additions & 11 deletions contracts/reverseRegistrar/L2ReverseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ contract L2ReverseRegistrar is
revert InvalidSignature();
}

_setName(node, name);
_setLastUpdated(node, inceptionDate);
_setName(node, name, inceptionDate);
return node;
}

Expand Down Expand Up @@ -127,7 +126,7 @@ contract L2ReverseRegistrar is
inceptionDate >= lastUpdated[node] &&
inceptionDate < block.timestamp
) {
_setName(node, name);
_setName(node, name, inceptionDate);
return node;
}

Expand All @@ -147,6 +146,7 @@ contract L2ReverseRegistrar is
/**
* @dev Sets the `name()` record for the reverse ENS record associated with
* the addr provided account.
* Can be used if the addr is a contract that is owned by a SCW.
* @param name The name to set for this address.
* @return The ENS node hash of the reverse record.
*/
Expand All @@ -156,7 +156,7 @@ contract L2ReverseRegistrar is
string memory name
) public authorised(addr) returns (bytes32) {
bytes32 node = _getNamehash(addr);
_setName(node, name);
_setName(node, name, block.timestamp);
return node;
}

Expand Down Expand Up @@ -198,8 +198,7 @@ contract L2ReverseRegistrar is
revert InvalidSignature();
}

_setText(node, key, value);
_setLastUpdated(node, inceptionDate);
_setText(node, key, value, inceptionDate);
return node;
}

Expand Down Expand Up @@ -248,7 +247,7 @@ contract L2ReverseRegistrar is
inceptionDate > lastUpdated[node] &&
inceptionDate < block.timestamp
) {
_setText(node, key, value);
_setText(node, key, value, inceptionDate);
return node;
}

Expand Down Expand Up @@ -283,17 +282,18 @@ contract L2ReverseRegistrar is
string calldata value
) public override authorised(addr) returns (bytes32) {
bytes32 node = _getNamehash(addr);
_setText(node, key, value);
_setLastUpdated(node, block.timestamp);
_setText(node, key, value, block.timestamp);
return node;
}

function _setText(
bytes32 node,
string calldata key,
string calldata value
string calldata value,
uint256 inceptionDate
) internal {
versionable_texts[recordVersions[node]][node][key] = value;
_setLastUpdated(node, inceptionDate);
emit TextChanged(node, key, key, value);
}

Expand All @@ -316,8 +316,13 @@ contract L2ReverseRegistrar is
* @param node The node to update.
* @param newName name record
*/
function _setName(bytes32 node, string memory newName) internal virtual {
function _setName(
bytes32 node,
string memory newName,
uint256 inceptionDate
) internal virtual {
versionable_names[recordVersions[node]][node] = newName;
_setLastUpdated(node, inceptionDate);
emit NameChanged(node, newName);
}

Expand Down
7 changes: 1 addition & 6 deletions test/reverseRegistrar/TestL2ReverseRegistrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,7 @@ describe('L2ReverseRegistrar', function () {
),
]

const tx = await L2ReverseRegistrar.multicall(calls)

console.log(tx.blockNumber)

const block2 = await ethers.provider.getBlock(tx.blockNumber)
console.log(block2.timestamp)
await L2ReverseRegistrar.multicall(calls)

assert.equal(
await L2ReverseRegistrar.text(node, 'url'),
Expand Down

0 comments on commit 5ed5fa9

Please sign in to comment.