Skip to content

Commit

Permalink
Add resolveDeferral
Browse files Browse the repository at this point in the history
  • Loading branch information
makoto committed Apr 3, 2024
1 parent bd686a7 commit fbbc60c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions crosschain-resolver/contracts/IAddrSetter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ pragma solidity ^0.8.17;

interface IAddrSetter{
function setAddr(bytes32 node, address addr) external view;
function resolveDeferral(bytes calldata name, bytes calldata data) external view returns (bytes memory result);
}

12 changes: 12 additions & 0 deletions crosschain-resolver/contracts/L1Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ contract L1Resolver is EVMFetchTarget, ITargetResolver, IMetadataResolver, IExte
(bytes32 node) = abi.decode(data[4:], (bytes32));
return _contenthash(node, target);
}
}

/**
* @dev Resolve and throws an EIP 3559 compliant error
* @param name DNS encoded ENS name to query
* @param data The actual calldata
* @return result result of the call
*/
function resolveDeferral(bytes calldata name, bytes calldata data) external view returns (bytes memory result) {
(, address target) = _getTarget(name, 0);
bytes4 selector = bytes4(data);

if (selector == IAddrSetter.setAddr.selector) {
_writeDeferral(target);
}
Expand Down
3 changes: 2 additions & 1 deletion crosschain-resolver/test/testResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,15 @@ describe('Crosschain Resolver', () => {
expect(await target.supportsInterface('0x9061b923')).to.equal(true) // IExtendedResolver
expect(await target.supportsInterface('0x8a596ebe')).to.equal(true) // IMetadataResolver
expect(await target.supportsInterface('0x01ffc9a7')).to.equal(true) // ERC-165 support
expect(await target.supportsInterface('0x41d40572')).to.equal(true) // IAddrSetter support
})

describe('EIP 5559', () => {
it('throws StorageHandledByL2 error', async () => {
await target.setTarget(encodedname, resolverAddress)
const i = new ethers.Interface(["function setAddr(bytes32 node, address addr)"])
const calldata = i.encodeFunctionData("setAddr", [node, EMPTY_ADDRESS])
await expect(target.resolve(encodedname, calldata)).to.be
await expect(target.resolveDeferral(encodedname, calldata)).to.be
.revertedWithCustomError(target, 'StorageHandledByL2')
.withArgs(l2ResolverChainId, resolverAddress)
});
Expand Down

0 comments on commit fbbc60c

Please sign in to comment.