Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard Writing based on IWriteDeferral w/ view call #239

Open
wants to merge 10 commits into
base: 241-l2-support-writeparams
Choose a base branch
from
276 changes: 231 additions & 45 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint . --ext .ts --fix"
},
"devDependencies": {
"@apollo/server": "^4.11.0",
"@apollo/server": "^4.11.2",
"@blockful/ccip-server": "*",
"@blockful/gateway": "*",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
Expand All @@ -22,12 +22,12 @@
"aes-js": "^3.1.2",
"chai": "^4.2.0",
"dotenv": "^16.4.5",
"hardhat": "^2.22.12",
"hardhat": "^2.22.15",
"npm-run-all": "^4.1.5",
"reflect-metadata": "^0.2.2",
"solidity-coverage": "^0.8.12",
"typeorm": "^0.3.20",
"viem": "^2.21.19"
"viem": "^2.21.42"
},
"peerDependencies": {
"@blockful/tsconfig": "*"
Expand Down
39 changes: 23 additions & 16 deletions packages/client/src/write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ const _ = (async () => {
functionName: 'register',
abi: scAbi,
args: [
encodedName,
signer.address, // owner
duration,
zeroHash,
resolver,
data, // records calldata
false, // reverseRecord
0, // fuses
zeroHash,
{
name: encodedName,
owner: signer.address,
duration,
secret: zeroHash,
resolver,
data,
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
account: signer,
}
Expand Down Expand Up @@ -154,13 +156,18 @@ const _ = (async () => {

let value = 0n
try {
const [_value /* commitTime */ /* extraData */, ,] =
(await client.readContract({
address: contractAddress,
abi: scAbi,
functionName: 'registerParams',
args: [encodedName, duration],
})) as [bigint, bigint, Hex]
const { price: _value } = (await client.readContract({
address: contractAddress,
abi: scAbi,
functionName: 'registerParams',
args: [encodedName, duration],
})) as {
price: bigint
commitTime: bigint
extraData: Hex
available: boolean
token: Hex
}
value = _value
} catch {
// interface not implemented by the resolver
Expand Down
100 changes: 55 additions & 45 deletions packages/client/test/db.e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,17 @@ describe('DatabaseResolver', async () => {
functionName: 'register',
abi: abiOffchainRegister,
args: [
encodedName,
owner.address,
300n,
zeroHash,
resolver,
[],
false,
0,
zeroHash,
{
name: encodedName,
owner: owner.address,
duration: 300n,
secret: zeroHash,
resolver,
data: [],
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
universalResolverAddress,
signer: owner,
Expand Down Expand Up @@ -236,15 +238,17 @@ describe('DatabaseResolver', async () => {
functionName: 'register',
abi: abiOffchainRegister,
args: [
encodedName,
owner.address,
300n,
zeroHash,
resolver,
calldata,
false,
0,
zeroHash,
{
name: encodedName,
owner: owner.address,
duration: 300n,
secret: zeroHash,
resolver,
data: calldata,
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
universalResolverAddress,
signer: owner,
Expand Down Expand Up @@ -287,15 +291,17 @@ describe('DatabaseResolver', async () => {
functionName: 'register',
abi: abiOffchainRegister,
args: [
encodedName,
owner.address,
300n,
zeroHash,
resolver,
[],
false,
0,
zeroHash,
{
name: encodedName,
owner: owner.address,
duration: 300n,
secret: zeroHash,
resolver,
data: [],
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
universalResolverAddress,
signer: owner,
Expand All @@ -319,15 +325,17 @@ describe('DatabaseResolver', async () => {
functionName: 'register',
abi: abiOffchainRegister,
args: [
encodedName,
newOwner.address,
300n,
zeroHash,
resolver,
[],
false,
0,
zeroHash,
{
name: encodedName,
owner: newOwner.address,
duration: 300n,
secret: zeroHash,
resolver,
data: [],
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
universalResolverAddress,
signer: newOwner,
Expand Down Expand Up @@ -360,15 +368,17 @@ describe('DatabaseResolver', async () => {
functionName: 'register',
abi: abiOffchainRegister,
args: [
encodedName,
newOwner,
300n,
zeroHash,
resolver,
[],
false,
0,
zeroHash,
{
name: encodedName,
owner: newOwner,
duration: 300n,
secret: zeroHash,
resolver,
data: [],
reverseRecord: false,
fuses: 0,
extraData: zeroHash,
},
],
universalResolverAddress,
signer: owner,
Expand Down
6 changes: 2 additions & 4 deletions packages/contracts/script/deploy/SubdomainController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ contract SubdomainControllerScript is DeployHelper, ENSHelper {
vm.startBroadcast();

uint256 subdomainPrice = 0.001 ether;
uint256 commitTime = 0;
SubdomainController subdomainController = new SubdomainController(
address(nameWrapper), subdomainPrice, commitTime
);
SubdomainController subdomainController =
new SubdomainController(address(nameWrapper), subdomainPrice);
nameWrapper.setApprovalForAll(address(subdomainController), true);

vm.stopBroadcast();
Expand Down
31 changes: 18 additions & 13 deletions packages/contracts/script/local/L2ArbitrumResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import {NameEncoder} from "@ens-contracts/utils/NameEncoder.sol";

import {ENSHelper} from "../ENSHelper.sol";
import {SubdomainController} from "../../src/SubdomainController.sol";
import {
OffchainRegister,
RegisterRequest
} from "../../src/interfaces/WildcardWriting.sol";

contract L2ArbitrumResolver is Script, ENSHelper {

Expand Down Expand Up @@ -80,10 +84,8 @@ contract L2ArbitrumResolver is Script, ENSHelper {
nameWrapper.setController(msg.sender, true);

uint256 subdomainPrice = 0.001 ether;
uint256 commitTime = 0;
SubdomainController subdomainController = new SubdomainController(
address(nameWrapper), subdomainPrice, commitTime
);
SubdomainController subdomainController =
new SubdomainController(address(nameWrapper), subdomainPrice);
nameWrapper.setApprovalForAll(address(subdomainController), true);

PublicResolver arbResolver = new PublicResolver(
Expand All @@ -109,21 +111,24 @@ contract L2ArbitrumResolver is Script, ENSHelper {
);

subdomainController.register{value: subdomainController.price()}(
name,
msg.sender,
31556952000,
keccak256("secret"),
address(arbResolver),
data,
false,
0,
bytes("")
RegisterRequest(
name,
msg.sender,
31556952000,
keccak256(abi.encode("secret")),
address(arbResolver),
data,
false,
0,
bytes("")
)
);

vm.stopBroadcast();

console.log("Registry deployed at", address(registry));
console.log("NameWrapper deployed at", address(nameWrapper));
console.log("BaseRegistrar deployed at", address(baseRegistrar));
console.log(
"SubdomainController deployed at", address(subdomainController)
);
Expand Down
45 changes: 24 additions & 21 deletions packages/contracts/src/DatabaseResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {IExtendedResolver} from
import {AddrResolver} from "@ens-contracts/resolvers/profiles/AddrResolver.sol";
import {NameResolver} from "@ens-contracts/resolvers/profiles/NameResolver.sol";
import {ABIResolver} from "@ens-contracts/resolvers/profiles/ABIResolver.sol";
import {IMulticallable} from "@ens-contracts/resolvers/IMulticallable.sol";
import {PubkeyResolver} from
"@ens-contracts/resolvers/profiles/PubkeyResolver.sol";
import {TextResolver} from "@ens-contracts/resolvers/profiles/TextResolver.sol";
Expand Down Expand Up @@ -391,6 +392,29 @@ contract DatabaseResolver is
return result;
}

//////// MULTICALL ////////

function multicall(bytes[] calldata /* data */ )
external
view
override
returns (bytes[] memory)
{
_offChainStorage(msg.data);
}

function multicallWithNodeCheck(
bytes32, /* node */
bytes[] calldata /* data */
)
external
view
override
returns (bytes[] memory)
{
_offChainStorage(msg.data);
}

//////// ENS WRITE DEFERRAL RESOLVER (EIP-5559) ////////

/**
Expand Down Expand Up @@ -550,25 +574,4 @@ contract DatabaseResolver is
|| super.supportsInterface(interfaceID);
}

function multicall(bytes[] calldata /* data */ )
external
view
override
returns (bytes[] memory)
{
_offChainStorage(msg.data);
}

function multicallWithNodeCheck(
bytes32,
bytes[] calldata /* data */
)
external
view
override
returns (bytes[] memory)
{
_offChainStorage(msg.data);
}

}
3 changes: 1 addition & 2 deletions packages/contracts/src/L1Resolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {IAddrResolver} from
"@ens-contracts/resolvers/profiles/IAddrResolver.sol";
import {IAddressResolver} from
"@ens-contracts/resolvers/profiles/IAddressResolver.sol";
import {IMulticallable} from "@ens-contracts/resolvers/IMulticallable.sol";
import {AddrResolver} from "@ens-contracts/resolvers/profiles/AddrResolver.sol";
import {TextResolver} from "@ens-contracts/resolvers/profiles/TextResolver.sol";
import {ContentHashResolver} from
Expand Down Expand Up @@ -61,8 +62,6 @@ contract L1Resolver is
uint256 constant VERSIONABLE_HASHES_SLOT = 3;
uint256 constant VERSIONABLE_TEXTS_SLOT = 10;
uint256 constant PRICE_SLOT = 0;
uint256 constant COMMIT_SLOT = 1;
uint256 constant EXTRA_DATA_SLOT = 2;

/// Contract targets
bytes32 public constant TARGET_RESOLVER = keccak256("resolver");
Expand Down
Loading
Loading