Skip to content

Commit

Permalink
feat: support Base resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
sammyluo committed Sep 24, 2024
1 parent 3c10dce commit 64f0c7c
Show file tree
Hide file tree
Showing 7 changed files with 742 additions and 220 deletions.
39 changes: 36 additions & 3 deletions src/Resolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class Resolution {

constructor(config: {sourceConfig?: SourceConfig; apiKey?: string} = {}) {
const uns = this.getUnsConfig(config);
const unsBase = this.getUnsBaseConfig(config);
const zns = this.getZnsConfig(config);
const ens = this.getEnsConfig(config);

Expand All @@ -86,6 +87,10 @@ export default class Resolution {
usedServices: [uns],
native: uns instanceof Uns ? uns : new Uns(),
},
[NamingServiceName.UNS_BASE]: {
usedServices: [unsBase],
native: unsBase instanceof Uns ? unsBase : new Uns(),
},
[NamingServiceName.ZNS]: {
usedServices: equalUdApiProviders ? [uns] : [uns, zns],
native: zns instanceof Zns ? zns : new Zns(),
Expand Down Expand Up @@ -1202,13 +1207,36 @@ export default class Resolution {
: new Uns(config.sourceConfig?.uns);
}

getZnsConfig(config: ResolutionConfig): Zns | UdApi {
private getUnsBaseConfig(config: ResolutionConfig): Uns | UdApi {
if (config.apiKey) {
return new Uns({
locations: {
Layer1: {
url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/eth/rpc`,
network: 'mainnet',
proxyServiceApiKey: config.apiKey,
},
Layer2: {
url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/base/rpc`,
network: 'base-mainnet',
proxyServiceApiKey: config.apiKey,
},
},
});
}

return isApi(config.sourceConfig?.uns)
? new UdApi(config.sourceConfig?.uns)
: new Uns(config.sourceConfig?.uns);
}

private getZnsConfig(config: ResolutionConfig): Zns | UdApi {
return isApi(config.sourceConfig?.zns)
? new UdApi(config.sourceConfig?.zns)
: new Zns(config.sourceConfig?.zns);
}

getEnsConfig(config: ResolutionConfig): Ens | UdApi {
private getEnsConfig(config: ResolutionConfig): Ens | UdApi {
if (config.apiKey) {
return new Ens({
url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/eth/rpc`,
Expand All @@ -1231,5 +1259,10 @@ type ServicesEntry = {
};

function isApi(obj: any): obj is Api {
return obj && obj.api;
return (
typeof obj === 'object' &&
obj !== null &&
'api' in obj &&
typeof obj.api === 'boolean'
);
}
173 changes: 114 additions & 59 deletions src/config/ens-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.1.8",
"version": "0.2.6",
"networks": {
"1": {
"contracts": {
Expand Down Expand Up @@ -33,6 +33,7 @@
},
"PublicResolver": {
"address": "0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63",
"legacyAddresses": ["0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"],
"deploymentBlock": "0x10243b3"
},
"ProxyAdmin": {
Expand All @@ -52,114 +53,168 @@
"LegacyETHRegistrarController": {
"address": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"deploymentBlock": "0x8f2277"
},
"DNSRegistrar": {
"address": "0x58774Bb8acD458A640aF0B88238369A167546ef2",
"deploymentBlock": "0xc6faf4"
},
"DNSSECImpl": {
"address": "0x46c6F79952d3046Bf673a28132ff2a81F306959c",
"deploymentBlock": "0xc6fa9e"
},
"Root": {
"address": "0xaB528d626EC275E3faD363fF1393A41F581c5897",
"deploymentBlock": "0x8F22BC"
}
}
},
"5": {
"1337": {
"contracts": {
"ENSRegistry": {
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"deploymentBlock": "0x1fd6d3"
"address": "0x50eBEc0b0EAfc732324C1A28963C1FcB7889DA39",
"deploymentBlock": "0x5e",
"legacyAddresses": []
},
"BaseRegistrarImplementation": {
"address": "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
"deploymentBlock": "0x1fd6dd"
"address": "0xc86965b7720a64c86263030f7B2902c752084F46",
"deploymentBlock": "0x5f",
"legacyAddresses": []
},
"ReverseRegistrar": {
"address": "0x4f7A657451358a22dc397d5eE7981FfC526cd856",
"deploymentBlock": "0x830309"
"address": "0xdb787398b6595b4F0a8d6072A8AF69774D967f5F",
"deploymentBlock": "0x60",
"legacyAddresses": []
},
"NameWrapper": {
"address": "0x114D4603199df73e7D157787f8778E21fCd13066",
"deploymentBlock": "0x83f9a2"
"address": "0xd70Ab4F5767a8fa0e1e261A2f51189316a7C0d86",
"deploymentBlock": "0x63",
"legacyAddresses": []
},
"DummyOracle": {
"address": "0x0000000000000000000000000000000000000000",
"deploymentBlock": "0x0"
"address": "0x6D264795bBa755974bBBB84Ea5E66eA893BbF606",
"deploymentBlock": "0x65",
"legacyAddresses": []
},
"StablePriceOracle": {
"address": "0x0000000000000000000000000000000000000000",
"deploymentBlock": "0x0"
"address": "0x25D0359804421aDF8E28c3629f611bfD4F04F4fD",
"deploymentBlock": "0x66",
"legacyAddresses": []
},
"ETHRegistrarController": {
"address": "0xCc5e7dB10E65EED1BBD105359e7268aa660f6734",
"deploymentBlock": "0x83fa46"
"address": "0x51A944e573DdcA58500583A997F2E46616A15770",
"deploymentBlock": "0x67",
"legacyAddresses": []
},
"PublicResolver": {
"address": "0xd7a4F6473f32aC2Af804B3686AE8F1932bC35750",
"deploymentBlock": "0x83fa9e"
"address": "0xcA8C131DC1f9f62EE54012b10BCA2DA71B8d42e7",
"deploymentBlock": "0x70",
"legacyAddresses": ["0xb9025e16A304BA1604e4b93e0A5d6cc4C699a772"]
},
"ProxyAdmin": {
"address": "0xf4906E210523F9dA79E33811A44EE000441F4E04",
"deploymentBlock": "0x5b57e8"
"address": "0x4e44E79e0cEc05D9e62e952B2088c02A3C450aeC",
"deploymentBlock": "0x36",
"legacyAddresses": []
},
"ENSCustody": {
"address": "0x74d1fA29295028e58573b894A4bF2cE8541036d4",
"deploymentBlock": "0x8b85b3",
"implementation": "0x223350B4892300EA6E8adEF48C955dcf1C544D02",
"forwarder": "0x74d1fA29295028e58573b894A4bF2cE8541036d4"
"address": "0x57b1b0EABC6d5004a227A707625BdCD2257Acd63",
"deploymentBlock": "0x87",
"implementation": "0x97e711b69fa03aA2859153FCA5656F213A7b51c3",
"forwarder": "0x57b1b0EABC6d5004a227A707625BdCD2257Acd63",
"legacyAddresses": []
},
"LegacyENSRegistry": {
"address": "0x112234455C3a32FD11230C42E7Bccd4A84e02010",
"deploymentBlock": "0xa890"
"address": "0xDF1eCDd1d075d212f62d77e33f152c2FF8F26D69",
"deploymentBlock": "0x73",
"legacyAddresses": []
},
"LegacyETHRegistrarController": {
"address": "0x283Af0B28c62C092C9727F1Ee09c02CA627EB7F5",
"deploymentBlock": "0x1fd6f0"
"address": "0x942518378eb0f32aAaB57B9c8176432AcCCdA331",
"deploymentBlock": "0x68",
"legacyAddresses": []
},
"DNSSECImpl": {
"address": "0x87d45031F0507132474f7b913ba7e1B8A9B222a6",
"deploymentBlock": "0x7a"
},
"DNSRegistrar": {
"address": "0x15f5427fbbE5e4c3aA2137C176B7558F5B53265D",
"deploymentBlock": "0x81"
},
"Root": {
"address": "0x99127fc7FB6d6ef5eE2d59b9e0F30c8451A0d9ce",
"deploymentBlock": "0x82"
},
"LegacyPublicResolver": {
"address": "0x4fbf7B2f171336958BE5D15FF762a5CfF5363568",
"deploymentBlock": "0x3b"
}
}
},
"1337": {
"11155111": {
"contracts": {
"ENSRegistry": {
"address": "0x24F45688D421f46cca60734BdC648ad192dB0f2E",
"deploymentBlock": "0x28"
"address": "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",
"deploymentBlock": "0x387fc8"
},
"BaseRegistrarImplementation": {
"address": "0x7e76aE49D6F4c6158757693b050BF88f039DeA21",
"deploymentBlock": "0x29"
"address": "0x57f1887a8BF19b14fC0dF6Fd9B2acc9Af147eA85",
"deploymentBlock": "0x387fcb"
},
"ReverseRegistrar": {
"address": "0xEE9A59532B50514d4Cb2440b19E9539b6380CEcf",
"deploymentBlock": "0x2a"
"address": "0xA0a1AbcDAe1a2a4A2EF8e9113Ff0e02DD81DC0C6",
"deploymentBlock": "0x39d263"
},
"NameWrapper": {
"address": "0xf6b7c221342BC966f4396790895530bF4E9799eB",
"deploymentBlock": "0x2d"
"address": "0x0635513f179D50A207757E05759CbD106d7dFcE8",
"deploymentBlock": "0x39d549"
},
"DummyOracle": {
"address": "0x38Dae41aEed12884D39dabD8F8a81Bb5B4562756",
"deploymentBlock": "0x2f"
"address": "0x10E7e7D64d7dA687f7DcF8443Df58A0415329b15",
"deploymentBlock": "0x39d560"
},
"StablePriceOracle": {
"address": "0xf7c9FD8E37863CF3f2da6A3ea0B1D1E3FaadeAD4",
"deploymentBlock": "0x30"
"address": "0x0000000000000000000000000000000000000000",
"deploymentBlock": "0x0"
},
"ETHRegistrarController": {
"address": "0x4Eb9dE1Fc0d800e941F326d6699E9E11969557ea",
"deploymentBlock": "0x31"
"address": "0xFED6a969AaA60E4961FCD3EBF1A2e8913ac65B72",
"deploymentBlock": "0x39d5a4"
},
"PublicResolver": {
"address": "0xeC71E4E674fe0f432693DC2b935C34bd2774C003",
"deploymentBlock": "0x3a"
},
"ProxyAdmin": {
"address": "0x4e44E79e0cEc05D9e62e952B2088c02A3C450aeC",
"deploymentBlock": "0x36"
},
"ENSCustody": {
"address": "0xf7313E5a57432B8A90233F7158D6dDE03572Dd9f",
"deploymentBlock": "0x3f",
"implementation": "0x38b83990077ac5DA78Aa9e72f5747D3A0b2374D9",
"forwarder": "0xf7313E5a57432B8A90233F7158D6dDE03572Dd9f"
"address": "0x8FADE66B79cC9f707aB26799354482EB93a5B7dD",
"legacyAddresses": ["0x0CeEC524b2807841739D3B5E161F5bf1430FFA48"],
"deploymentBlock": "0x39d5ab"
},
"LegacyENSRegistry": {
"address": "0xB17aAe5B3A7815433fC82Cfd67Ea245767894f03",
"deploymentBlock": "0x3c"
"address": "0x94f523b8261B815b87EFfCf4d18E6aBeF18d6e4b",
"deploymentBlock": "0x387fc1"
},
"LegacyETHRegistrarController": {
"address": "0x3F1194B9019002863Ad0DBBE295294547c0d36A9",
"deploymentBlock": "0x32"
"address": "0x7e02892cfc2Bfd53a75275451d73cF620e793fc0",
"deploymentBlock": "0x39d575"
},
"DNSRegistrar": {
"address": "0x5a07C75Ae469Bf3ee2657B588e8E6ABAC6741b4f",
"deploymentBlock": "0x4c7608"
},
"DNSSECImpl": {
"address": "0xe62E4b6cE018Ad6e916fcC24545e20a33b9d8653",
"deploymentBlock": "0x3f3236"
},
"Root": {
"address": "0xDaaF96c344f63131acadD0Ea35170E7892d3dfBA",
"deploymentBlock": "0x387fc9"
},
"ProxyAdmin": {
"address": "0xCbF16B0E2A06916F0Ca4892F704349d13E11cF66",
"legacyAddresses": [],
"deploymentBlock": "0x5588B8"
},
"ENSCustody": {
"address": "0xd2Bf816C7b23fF6e7d141ECC4c1e41DcC857aD45",
"deploymentBlock": "0x5588b9",
"implementation": "0x49Ac063337cF2fB26dD421Ab650b893CD54b900F",
"forwarder": "0xd2Bf816C7b23fF6e7d141ECC4c1e41DcC857aD45"
}
}
}
Expand Down
Loading

0 comments on commit 64f0c7c

Please sign in to comment.