Skip to content

Commit

Permalink
Change from coinType to chainId
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Mar 7, 2024
1 parent 3e8036c commit 5706812
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
10 changes: 5 additions & 5 deletions contracts/reverseRegistrar/L2ReverseRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ contract L2ReverseRegistrar is

/*
* @dev Constructor
* @param _L2ReverseNode The namespace to set. The converntion is '${cointype}.reverse'
* @param _coinType The cointype converted from the chainId of the chain this contract is deployed to.
* @param _L2ReverseNode The namespace to set. The converntion is '${chainId}.reverse'
* @param _chainId The chainId converted from the chainId of the chain this contract is deployed to.
*/
constructor(
bytes32 _L2ReverseNode,
uint256 _coinType
) SignatureReverseResolver(_L2ReverseNode, _coinType) {
uint256 _chainId
) SignatureReverseResolver(_L2ReverseNode, _chainId) {
L2ReverseNode = _L2ReverseNode;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ contract L2ReverseRegistrar is
bytes memory signature
) internal view returns (bool) {
bytes32 message = keccak256(
abi.encodePacked(hash, addr, owner, inceptionDate, coinType)
abi.encodePacked(hash, addr, owner, inceptionDate, chainId)
).toEthSignedMessageHash();
bytes32 node = _getNamehash(addr);

Expand Down
10 changes: 5 additions & 5 deletions contracts/reverseRegistrar/SignatureReverseResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ contract SignatureReverseResolver is Ownable, ISignatureReverseResolver {
mapping(bytes32 => uint64) internal recordVersions;

bytes32 public immutable parentNode;
uint256 public immutable coinType;
uint256 public immutable chainId;

/*
* @dev Constructor
* @param parentNode The namespace to set.
* @param _coinType The cointype converted from the chainId of the chain this contract is deployed to.
* @param _chainId The chainId converted from the chainId of the chain this contract is deployed to.
*/
constructor(bytes32 _parentNode, uint256 _coinType) {
constructor(bytes32 _parentNode, uint256 _chainId) {
parentNode = _parentNode;
coinType = _coinType;
chainId = _chainId;
}

modifier authorised(address addr) {
Expand Down Expand Up @@ -58,7 +58,7 @@ contract SignatureReverseResolver is Ownable, ISignatureReverseResolver {
bytes memory signature
) internal view returns (bool) {
bytes32 message = keccak256(
abi.encodePacked(hash, addr, inceptionDate, coinType)
abi.encodePacked(hash, addr, inceptionDate, chainId)
).toEthSignedMessageHash();
bytes32 node = _getNamehash(addr);

Expand Down
28 changes: 14 additions & 14 deletions test/reverseRegistrar/TestL2ReverseRegistrar.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('L2ReverseRegistrar', function () {
'setTextForAddrWithSignature(address,string,string,uint256,bytes)'
let setTextForAddrWithSignatureAndOwnableFuncSig =
'setTextForAddrWithSignatureAndOwnable(address,address,string,string,uint256,bytes)'
let coinType = 123
let chainId = 123

before(async function () {
signers = await ethers.getSigners()
Expand All @@ -32,7 +32,7 @@ describe('L2ReverseRegistrar', function () {
)
L2ReverseRegistrar = await L2ReverseRegistrarFactory.deploy(
namehash('optimism.reverse'),
coinType,
chainId,
)

const MockSmartContractWalletFactory = await ethers.getContractFactory(
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('L2ReverseRegistrar', function () {
keccak256(['bytes4', 'string'], [funcId, name]),
account,
inceptionDate,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -184,7 +184,7 @@ describe('L2ReverseRegistrar', function () {
keccak256(['bytes4', 'string'], [funcId, 'hello.eth']),
account,
inceptionDate,
coinType,
chainId,
],
),
),
Expand All @@ -209,7 +209,7 @@ describe('L2ReverseRegistrar', function () {
keccak256(['bytes4', 'string'], [funcId, 'hello.eth']),
account,
inceptionDate2,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -250,7 +250,7 @@ describe('L2ReverseRegistrar', function () {
MockOwnable.address,
MockSmartContractWallet.address,
inceptionDate,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -319,7 +319,7 @@ describe('L2ReverseRegistrar', function () {
),
account,
inceptionDate,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('L2ReverseRegistrar', function () {
),
account,
inceptionDate,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -424,7 +424,7 @@ describe('L2ReverseRegistrar', function () {
),
account,
inceptionDate2,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -464,7 +464,7 @@ describe('L2ReverseRegistrar', function () {
MockOwnable.address,
MockSmartContractWallet.address,
inceptionDate,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -537,7 +537,7 @@ describe('L2ReverseRegistrar', function () {
),
account,
inceptionDate,
coinType,
chainId,
],
),
),
Expand All @@ -551,7 +551,7 @@ describe('L2ReverseRegistrar', function () {
keccak256(['bytes4', 'string'], [funcId2, 'hello.eth']),
account,
inceptionDate + 1,
coinType,
chainId,
],
),
),
Expand Down Expand Up @@ -613,7 +613,7 @@ describe('L2ReverseRegistrar', function () {
ethers.utils.arrayify(
keccak256(
['bytes32', 'address', 'uint256', 'uint256'],
[keccak256(['bytes4'], [funcId]), account, inceptionDate, coinType],
[keccak256(['bytes4'], [funcId]), account, inceptionDate, chainId],
),
),
)
Expand Down Expand Up @@ -647,7 +647,7 @@ describe('L2ReverseRegistrar', function () {
ethers.utils.arrayify(
keccak256(
['bytes32', 'address', 'uint256', 'uint256'],
[keccak256(['bytes4'], [funcId]), account, inceptionDate, coinType],
[keccak256(['bytes4'], [funcId]), account, inceptionDate, chainId],
),
),
)
Expand Down

0 comments on commit 5706812

Please sign in to comment.