Skip to content

Commit

Permalink
WIP inceptionDate
Browse files Browse the repository at this point in the history
  • Loading branch information
jefflau committed Nov 6, 2023
1 parent 569f07a commit 2b4cf91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
3 changes: 2 additions & 1 deletion contracts/reverseRegistrar/L2ReverseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ contract L2ReverseRegistrar is
if (
!SignatureChecker.isValidSignatureNow(addr, message, signature) ||
inceptionDate <= lastUpdated[node] ||
inceptionDate < block.timestamp
inceptionDate > block.timestamp
) {
revert InvalidSignature();
}

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

Expand Down
33 changes: 18 additions & 15 deletions test/reverseRegistrar/TestL2ReverseRegistrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ describe('L2ReverseRegistrar', function () {
.substring(0, 10)

const block = await ethers.provider.getBlock('latest')
const signatureExpiry = block.timestamp + 3600
const inceptionDate = block.timestamp
const signature = await signers[0].signMessage(
ethers.utils.arrayify(
ethers.utils.solidityKeccak256(
['bytes4', 'address', 'string', 'string', 'uint256'],
[funcId, account, 'url', 'http://ens.domains', signatureExpiry],
[funcId, account, 'url', 'http://ens.domains', inceptionDate],
),
),
)
Expand All @@ -204,7 +204,7 @@ describe('L2ReverseRegistrar', function () {
account,
'url',
'http://ens.domains',
signatureExpiry,
inceptionDate,
signature,
)

Expand All @@ -221,12 +221,12 @@ describe('L2ReverseRegistrar', function () {
.substring(0, 10)

const block = await ethers.provider.getBlock('latest')
const signatureExpiry = block.timestamp + 3600
const inceptionDate = block.timestamp
const signature = await signers[0].signMessage(
ethers.utils.arrayify(
ethers.utils.solidityKeccak256(
['bytes4', 'address', 'string', 'string', 'uint256'],
[funcId, account, 'url', 'http://ens.domains', signatureExpiry],
[funcId, account, 'url', 'http://ens.domains', inceptionDate],
),
),
)
Expand All @@ -236,7 +236,7 @@ describe('L2ReverseRegistrar', function () {
account,
'url',
'http://some.other.url.com',
signatureExpiry,
inceptionDate,
signature,
),
).to.be.revertedWith(`InvalidSignature()`)
Expand Down Expand Up @@ -323,14 +323,14 @@ describe('L2ReverseRegistrar', function () {
.substring(0, 10)

const block = await ethers.provider.getBlock('latest')
const signatureExpiry = block.timestamp + 3600
const inceptionDate = block.timestamp

console.log('signatureExpiry', signatureExpiry)
console.log('inceptionDate', inceptionDate)
const signature1 = await signers[0].signMessage(
ethers.utils.arrayify(
ethers.utils.solidityKeccak256(
['bytes4', 'address', 'string', 'string', 'uint256'],
[funcId1, account, 'url', 'http://ens.domains', signatureExpiry],
[funcId1, account, 'url', 'http://ens.domains', inceptionDate],
),
),
)
Expand All @@ -339,26 +339,29 @@ describe('L2ReverseRegistrar', function () {
ethers.utils.arrayify(
ethers.utils.solidityKeccak256(
['bytes4', 'address', 'string', 'uint256'],
[funcId2, account, 'hello.eth', signatureExpiry],
[funcId2, account, 'hello.eth', inceptionDate],
),
),
)

const calls = [
L2ReverseRegistrar.interface.encodeFunctionData(
'setTextForAddrWithSignature',
[account, 'url', 'http://ens.domains', signatureExpiry, signature1],
),
L2ReverseRegistrar.interface.encodeFunctionData(
'setNameForAddrWithSignature',
[account, 'hello.eth', signatureExpiry, signature2],
[account, 'url', 'http://ens.domains', inceptionDate, signature1],
),
// L2ReverseRegistrar.interface.encodeFunctionData(
// 'setNameForAddrWithSignature',
// [account, 'hello.eth', inceptionDate, signature2],
// ),
]

const tx = await L2ReverseRegistrar.multicall(calls)

console.log(tx.blockNumber)

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

assert.equal(
await L2ReverseRegistrar.text(node, 'url'),
'http://ens.domains',
Expand Down

0 comments on commit 2b4cf91

Please sign in to comment.