From 64f0c7c0af3d97f6e7cdedd6b333a7d13063557c Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 24 Sep 2024 16:11:41 -0400 Subject: [PATCH 1/8] feat: support Base resolution --- src/Resolution.ts | 39 +- src/config/ens-config.json | 173 +++++---- src/config/resolver-keys.json | 59 +++- src/config/uns-config.json | 648 +++++++++++++++++++++++++++------- src/types/index.ts | 6 +- src/types/publicTypes.ts | 2 + src/utils/index.ts | 35 +- 7 files changed, 742 insertions(+), 220 deletions(-) diff --git a/src/Resolution.ts b/src/Resolution.ts index 76c7ad25..7a8ad573 100644 --- a/src/Resolution.ts +++ b/src/Resolution.ts @@ -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); @@ -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(), @@ -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`, @@ -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' + ); } diff --git a/src/config/ens-config.json b/src/config/ens-config.json index ae045a1e..9ac2956d 100644 --- a/src/config/ens-config.json +++ b/src/config/ens-config.json @@ -1,5 +1,5 @@ { - "version": "0.1.8", + "version": "0.2.6", "networks": { "1": { "contracts": { @@ -33,6 +33,7 @@ }, "PublicResolver": { "address": "0x231b0Ee14048e9dCcD1d247744d114a4EB5E8E63", + "legacyAddresses": ["0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41"], "deploymentBlock": "0x10243b3" }, "ProxyAdmin": { @@ -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" } } } diff --git a/src/config/resolver-keys.json b/src/config/resolver-keys.json index 1903157d..f045ef0e 100644 --- a/src/config/resolver-keys.json +++ b/src/config/resolver-keys.json @@ -1,5 +1,5 @@ { - "version": "2.1.27", + "version": "2.1.33", "information": { "description": "This file describes all resolver keys with a defined meaning and related metadata used by Unstoppable Domains UNS Registry", "documentation": "https://docs.unstoppabledomains.com/developer-toolkit/records-reference/", @@ -56,6 +56,11 @@ "deprecated": false, "validationRegex": "^0x[a-fA-F0-9]{40}$" }, + "crypto.FARMS.version.MATIC.address": { + "deprecatedKeyName": "FARMS_MATIC", + "deprecated": false, + "validationRegex": "^0x[a-fA-F0-9]{40}$" + }, "crypto.USDC.address": { "deprecatedKeyName": "USDC", "deprecated": true, @@ -154,12 +159,12 @@ "crypto.ADA.address": { "deprecatedKeyName": "ADA", "deprecated": false, - "validationRegex": "^[1-9a-km-zA-HJ-NP-Z]{104}$|^A[1-9A-HJ-NP-Za-km-z]{58}$|^addr[0-9a-zA-Z]{99}$" + "validationRegex": "^[1-9a-km-zA-HJ-NP-Z]{104}$|^A[1-9A-HJ-NP-Za-km-z]{58}$|^addr([0-9a-zA-Z]{99}|[0-9a-zA-Z]{54})$" }, "crypto.EOS.address": { "deprecatedKeyName": "EOS", "deprecated": false, - "validationRegex": "^[a-z][a-z1-5.]{10}[a-z1-5]$" + "validationRegex": "^[1-5a-z]{12}$|^EOS[a-zA-Z0-9]{50}$|^PUB_K[0-9]_[a-zA-Z0-9]{50}$" }, "crypto.XLM.address": { "deprecatedKeyName": "XLM", @@ -319,7 +324,7 @@ "crypto.BSV.address": { "deprecatedKeyName": "BSV", "deprecated": false, - "validationRegex": "^bitcoincash:[a-zA-Z0-9]{42}$" + "validationRegex": "^[a-zA-Z0-9]{33,34}$" }, "crypto.GAS.address": { "deprecatedKeyName": "GAS", @@ -458,7 +463,7 @@ }, "crypto.TLOS.address": { "deprecatedKeyName": "TLOS", - "validationRegex": "^[a-z][a-z1-5.]{10}[a-z1-5]$", + "validationRegex": "^[1-5a-z]{12}$", "deprecated": false }, "crypto.XDC.address": { @@ -511,11 +516,31 @@ "validationRegex": "^0x[a-fA-F0-9]{40}$", "deprecated": false }, + "crypto.WETH.version.ERC20.address": { + "deprecatedKeyName": "WETH_ERC20", + "validationRegex": "^0x[a-fA-F0-9]{40}$", + "deprecated": false + }, + "crypto.WETH.version.MATIC.address": { + "deprecatedKeyName": "WETH_MATIC", + "deprecated": false, + "validationRegex": "^0x[a-fA-F0-9]{40}$" + }, + "crypto.WETH.version.BEP20.address": { + "deprecatedKeyName": "WETH_BEP20", + "validationRegex": "^0x[a-fA-F0-9]{40}$", + "deprecated": false + }, "crypto.USDT.version.ERC20.address": { "deprecatedKeyName": "USDT_ERC20", "validationRegex": "^0x[a-fA-F0-9]{40}$", "deprecated": false }, + "crypto.USDT.version.MATIC.address": { + "deprecatedKeyName": "USDT_MATIC", + "validationRegex": "^0x[a-fA-F0-9]{40}$", + "deprecated": false + }, "crypto.USDT.version.TRON.address": { "deprecatedKeyName": "USDT_TRON", "validationRegex": "^[T][a-zA-HJ-NP-Z0-9]{33}$", @@ -523,7 +548,7 @@ }, "crypto.USDT.version.EOS.address": { "deprecatedKeyName": "USDT_EOS", - "validationRegex": "^[a-z][a-z1-5.]{10}[a-z1-5]$", + "validationRegex": "^[1-5a-z]{12}$|^EOS[a-zA-Z0-9]{50}$|^PUB_K[0-9]_[a-zA-Z0-9]{50}$", "deprecated": false }, "crypto.USDT.version.OMNI.address": { @@ -531,10 +556,15 @@ "validationRegex": "^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$", "deprecated": false }, + "crypto.USDT.version.OKB.address": { + "deprecatedKeyName": "USDT_OKB", + "validationRegex": "^0x[a-fA-F0-9]{40}$", + "deprecated": false + }, "crypto.USDT.version.OKC.address": { "deprecatedKeyName": "USDT_OKC", "validationRegex": "^0x[a-fA-F0-9]{40}$|^ex[a-zA-HJ-NP-Z0-9]{6,90}$", - "deprecated": false + "deprecated": true }, "crypto.FTM.version.ERC20.address": { "deprecatedKeyName": "FTM_ERC20", @@ -1373,7 +1403,7 @@ }, "crypto.RUNE.address": { "deprecatedKeyName": "RUNE", - "validationRegex": "^(bnb|tbnb)[a-zA-HJ-NP-Z0-9]{39}$", + "validationRegex": "^thor[a-zA-HJ-NP-Z0-9]{39}$", "deprecated": false }, "crypto.HBAR.address": { @@ -1423,7 +1453,7 @@ }, "crypto.EGLD.address": { "deprecatedKeyName": "EGLD", - "validationRegex": "^0x[a-zA-Z0-9]*$", + "validationRegex": "^erd[a-zA-Z0-9]{59}$", "deprecated": false }, "crypto.TUSD.version.ERC20.address": { @@ -1528,7 +1558,7 @@ }, "crypto.STX.address": { "deprecatedKeyName": "STX", - "validationRegex": "^[a-zA-Z0-9]*$", + "validationRegex": "^SP[A-Z0-9]{38,39}$", "deprecated": false }, "crypto.MANA.version.ERC20.address": { @@ -1853,7 +1883,7 @@ }, "crypto.ERG.address": { "deprecatedKeyName": "ERG", - "validationRegex": "^0x[a-zA-Z0-9]*$", + "validationRegex": "^[a-zA-Z0-9]{51}$", "deprecated": false }, "crypto.WIN.address": { @@ -2593,7 +2623,7 @@ }, "crypto.SUI.address": { "deprecatedKeyName": "SUI", - "validationRegex": "^0x[a-fA-F0-9]{40}$", + "validationRegex": "^0x([0-9a-fA-F]{64}|[a-fA-F0-9]{40})$", "deprecated": false }, "crypto.MOON.address": { @@ -2650,6 +2680,11 @@ "deprecatedKeyName": "VERSE", "validationRegex": "^0x[a-fA-F0-9]{40}$", "deprecated": false + }, + "crypto.NIBI.address": { + "deprecatedKeyName": "NIBI", + "validationRegex": "^nibi1[a-z0-9]{38}$", + "deprecated": false } } } diff --git a/src/config/uns-config.json b/src/config/uns-config.json index 574b1590..7d28688b 100644 --- a/src/config/uns-config.json +++ b/src/config/uns-config.json @@ -1,5 +1,5 @@ { - "version": "0.8.3", + "version": "0.9.11", "networks": { "1": { "contracts": { @@ -111,113 +111,30 @@ "address": "0x65c6abdf52aD08A53A77488D1Acc5c666ada840F", "legacyAddresses": [], "deploymentBlock": "0xf335e0" - } - } - }, - "5": { - "contracts": { - "UNSRegistry": { - "address": "0x070e83FCed225184E67c86302493ffFCDB953f71", - "implementation": "0x2ab164829617D51cD8c29848b8DcE163bFAF70aa", - "legacyAddresses": [], - "deploymentBlock": "0x5b57ea", - "forwarder": "0x070e83FCed225184E67c86302493ffFCDB953f71" - }, - "CNSRegistry": { - "address": "0x801452cFAC27e79a11c6b185986fdE09e8637589", - "legacyAddresses": [], - "deploymentBlock": "0x5b57d7", - "forwarder": "0x00443017FFaa4C840Caf5Dc7d3CB59147f363080" - }, - "MintingManager": { - "address": "0x9ee42D3EB042e06F8Cd241890C4fA0d51e4DA345", - "implementation": "0xe72E170CeA8F6665DcF6B8c350511F9771f21800", - "legacyAddresses": [], - "deploymentBlock": "0x5b57ec", - "forwarder": "0x7F9F48cF94C69ce91D4b442DA186F31118ac0185" }, - "UNSOperator": { - "address": "0xd484eF427E87462F8ee816B0eA219c841f802eF6", - "legacyAddresses": [], - "deploymentBlock": "0x7ff335", - "implementation": "0x7DB4481290635743721FbDB9f96b1b0Cdf5CaE69" - }, - "ProxyAdmin": { - "address": "0xf4906E210523F9dA79E33811A44EE000441F4E04", - "legacyAddresses": [], - "deploymentBlock": "0x5b57e8" - }, - "SignatureController": { - "address": "0x5199dAE4B24B987ba18FcE1b64664D1B798d372B", - "legacyAddresses": [], - "deploymentBlock": "0x5b57d8" - }, - "MintingController": { - "address": "0xCEC41677be322049cC885c0DAe2fE0D52CA195ca", - "legacyAddresses": [], - "deploymentBlock": "0x5b57d9", - "deprecated": true - }, - "WhitelistedMinter": { + "ZilliqaRecover": { "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], - "deploymentBlock": "0x0", - "deprecated": true + "deploymentBlock": "0x0" }, - "URIPrefixController": { - "address": "0x29465e3d2daA588E62375977bCe9b3f51406a794", - "legacyAddresses": [], - "deploymentBlock": "0x5b57da", - "deprecated": true + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0" }, - "DomainZoneController": { + "SeaportProxyBuyer": { "address": "0x0000000000000000000000000000000000000000", - "legacyAddresses": [], "deploymentBlock": "0x0", - "deprecated": true - }, - "Resolver": { - "address": "0x0555344A5F440Bd1d8cb6B42db46c5e5D4070437", - "legacyAddresses": [], - "deploymentBlock": "0x5b57dc", - "forwarder": "0xFCc1A95B7287Ae7a8B7cA813F12991dF5714d4C7" - }, - "ProxyReader": { - "address": "0x76007c52C73972A441aFA1A0E1016B140ffdE689", - "implementation": "0xAa61dBf197646Bd01747f0AFf4Fa24135B4568Fb", - "legacyAddresses": [ - "0x77cb0e7503Ea82315421BcF0eE9603451cd285F6", - "0xE3b961856C417d081a02cBa0161a051268F52677", - "0x9A70ff906D422C2FD0F7B94244D6b36DB62Ee982", - "0xFc5f608149f4D9e2Ed0733efFe9DD57ee24BCF68" - ], - "deploymentBlock": "0x78b972" + "implementation": "0x0000000000000000000000000000000000000000", + "forwarder": "0x0000000000000000000000000000000000000000" }, - "TwitterValidationOperator": { - "address": "0x0000000000000000000000000000000000000000", - "legacyAddresses": [], + "USDC": { + "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", "deploymentBlock": "0x0" }, - "FreeMinter": { + "L1GasPriceOracle": { "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], - "deploymentBlock": "0x0", - "deprecated": true - }, - "MintableERC721Predicate": { - "address": "0x56E14C4C1748a818a5564D33cF774c59EB3eDF59", - "legacyAddresses": [], - "deploymentBlock": "0x2fc240" - }, - "RootChainManager": { - "address": "0xBbD7cBFA79faee899Eaf900F13C9065bF03B1A74", - "legacyAddresses": [], - "deploymentBlock": "0x2dc9b9" - }, - "DotCoinBurner": { - "address": "0x65c6abdf52aD08A53A77488D1Acc5c666ada840F", - "legacyAddresses": [], - "deploymentBlock": "0x78f5ac" + "deploymentBlock": "0x0" } } }, @@ -225,7 +142,7 @@ "contracts": { "UNSRegistry": { "address": "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f", - "implementation": "0xC4999E1daef4ecBd4E0F71A00B4a78B53e617922", + "implementation": "0x11227E54F19934164A81d5aDd1ce5825D46B2271", "legacyAddresses": [], "deploymentBlock": "0x01272eb5", "forwarder": "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f" @@ -238,7 +155,7 @@ }, "MintingManager": { "address": "0x7be83293BeeDc9Eba1bd76c66A65F10F3efaeC26", - "implementation": "0xfd27d20F8eABAE006Dae997460344b3C0CB81bD9", + "implementation": "0x8Efbe119357753c5d12f078AC081E37a5AFACf33", "legacyAddresses": [], "deploymentBlock": "0x01272f41", "forwarder": "0xC37d3c4326ab0E1D2b9D8b916bBdf5715f780fcF" @@ -325,6 +242,32 @@ "address": "0x65c6abdf52aD08A53A77488D1Acc5c666ada840F", "legacyAddresses": [], "deploymentBlock": "0x021cac00" + }, + "ZilliqaRecover": { + "address": "0x07B58C81f160257BCb3a2d549ea02D36E3e70461", + "legacyAddresses": [], + "deploymentBlock": "0x032b35a6", + "implementation": "0x50752EcBedBb07543C4191E2492e2e888a7D04bD", + "forwarder": "0x07B58C81f160257BCb3a2d549ea02D36E3e70461" + }, + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0" + }, + "SeaportProxyBuyer": { + "address": "0x8b031F472F7f90ac1fAE1616Ddf1283CDDe084bF", + "deploymentBlock": "0x037b22db", + "implementation": "0x53B01e32807127D3c2Fb6eA1A3b268753183Ed68", + "forwarder": "0x8b031F472F7f90ac1fAE1616Ddf1283CDDe084bF" + }, + "USDC": { + "address": "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359", + "deploymentBlock": "0x0" + }, + "L1GasPriceOracle": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" } } }, @@ -397,10 +340,10 @@ "forwarder": "0x11dD97b7Ca847DfB6504e61B7B9Eb30F55E554a0" }, "ProxyReader": { - "address": "0x5CC819C9915eADfcEBd76952B8C1BC36CADd7376", - "implementation": "0xBDeFCF6429D0AC68236A6BEb321cBD2Ce66B463C", + "address": "0xcd12F3f3faae97679a844aA184c0589ea8176656", + "implementation": "0x0930ffb2c192B0C9A9dd2372Cf7f2845ef39CBb6", "legacyAddresses": [], - "deploymentBlock": "0x1f" + "deploymentBlock": "0x23" }, "TwitterValidationOperator": { "address": "0x0000000000000000000000000000000000000000", @@ -424,44 +367,176 @@ "deploymentBlock": "0x0f" }, "DotCoinBurner": { - "address": "0x54563a9e1cD2dCBD0BCA90D3CFA4A647e02C404a", + "address": "0x951c830a0471C04DCB60Ce244DEe38eE4b0609ec", "legacyAddresses": [], - "deploymentBlock": "0x27" + "deploymentBlock": "0x5c" + }, + "ZilliqaRecover": { + "address": "0xDD622cF8306F18d736705e4Cc03f7FF83A899FD0", + "deploymentBlock": "0x2e", + "implementation": "0xf6b7c221342BC966f4396790895530bF4E9799eB", + "legacyAddresses": [], + "forwarder": "0xDD622cF8306F18d736705e4Cc03f7FF83A899FD0" + }, + "Seaport": { + "address": "0x5CC819C9915eADfcEBd76952B8C1BC36CADd7376", + "deploymentBlock": "0x1f" + }, + "SeaportProxyBuyer": { + "address": "0x7e76aE49D6F4c6158757693b050BF88f039DeA21", + "deploymentBlock": "0x29", + "implementation": "0x24F45688D421f46cca60734BdC648ad192dB0f2E", + "forwarder": "0x7e76aE49D6F4c6158757693b050BF88f039DeA21" + }, + "USDC": { + "address": "0xbE92182CAB5b84Fd18b34881A0c32771e84f5b8B", + "deploymentBlock": "0x21", + "implementation": "0xDa9E1b3e395bFb0A45F03C7F615146B9d896c959", + "forwarder": "0xbE92182CAB5b84Fd18b34881A0c32771e84f5b8B" + }, + "L1GasPriceOracle": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" } } }, - "80001": { + "8453": { "contracts": { - "UNSRegistry": { - "address": "0x2a93C52E7B6E7054870758e15A1446E769EdfB93", - "implementation": "0x010aEA2d9a25B0E0f05C27946e6FFFE0b88ad721", + "CNSRegistry": { + "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], - "deploymentBlock": "0x01213f43", - "forwarder": "0x2a93C52E7B6E7054870758e15A1446E769EdfB93" + "deploymentBlock": "0x0", + "forwarder": "0x0000000000000000000000000000000000000000" }, - "CNSRegistry": { + "SignatureController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "MintingController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "WhitelistedMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "URIPrefixController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "DomainZoneController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "Resolver": { "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], "deploymentBlock": "0x0", "forwarder": "0x0000000000000000000000000000000000000000" }, - "MintingManager": { - "address": "0x428189346bb3CC52f031A1092fd47C919AC30A9f", - "implementation": "0x78DB6F11a5bA8Ee61D1e5Ee25880212747ffB46F", + "TwitterValidationOperator": { + "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], - "deploymentBlock": "0x01213f4a", - "forwarder": "0xEf3a491A8750BEC2Dff5339CF6Df94436d432C4d" + "deploymentBlock": "0x0" }, - "UNSOperator": { - "address": "0x576a376832181ddD19d17CD4505F6BF8FEdb428E", + "FreeMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "MintableERC721Predicate": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "RootChainManager": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0", + "legacyAddresses": [] + }, + "DotCoinBurner": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "ZilliqaRecover": { + "address": "0x0000000000000000000000000000000000000000", "legacyAddresses": [], - "deploymentBlock": "0x01e03592", - "implementation": "0xaBB7934fFD76282dc9d5126A5549C2695C9b52A2" + "deploymentBlock": "0x0" + }, + "USDC": { + "address": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913", + "deploymentBlock": "0x0", + "legacyAddresses": [] }, "ProxyAdmin": { - "address": "0x460d63117c7Ab1624b7474C45BF46eC6702f57ce", + "address": "0x03EBd257caDe479638c9f1Dc69d1ECbbF98e301C", + "deploymentBlock": "0x1215A51", + "legacyAddresses": [] + }, + "UNSRegistry": { + "address": "0xF6c1b83977DE3dEffC476f5048A0a84d3375d498", + "deploymentBlock": "0x01215a53", + "implementation": "0xE0F063F1e63E8Ac83118B08b03603d7826C718bb", + "forwarder": "0xF6c1b83977DE3dEffC476f5048A0a84d3375d498", + "legacyAddresses": [] + }, + "MintingManager": { + "address": "0xe56D6aa367B7a16385Ea867F556339bbC361F983", + "deploymentBlock": "0x01215a5c", + "implementation": "0xd30b3cB992777134E2a338BcF422a311339E75b1", + "forwarder": "0xd57f8F7be4BaE8f2bf24792Fec2Ca06513c83c1D", + "legacyAddresses": [] + }, + "UNSOperator": { + "address": "0x1E2A1f502fbe0018ED1a019D9c874e21d0a66Cb3", + "deploymentBlock": "0x01215a62", + "implementation": "0x9fd7AF306e76DCf7CF41D5c9bFbc55BA33C962B1", + "legacyAddresses": [] + }, + "ProxyReader": { + "address": "0x78c4b414e1abdf0de267deda01dffd4cd0817a16", + "deploymentBlock": "0x1219245", + "implementation": "0x6B5F9068Aa94eFf728585665244cb5AB8735E71A", + "legacyAddresses": [] + }, + "SeaportProxyBuyer": { + "address": "0x19d40e8b3338669BfC40747F5D5bDb8a14422Fdb", + "deploymentBlock": "0x01215b4f", + "implementation": "0x99d55A02f5d9c76d31C6Ff57cc36A7862D5E1029", + "forwarder": "0x19d40e8b3338669BfC40747F5D5bDb8a14422Fdb", + "legacyAddresses": [] + }, + "L1GasPriceOracle": { + "address": "0x420000000000000000000000000000000000000F", "legacyAddresses": [], - "deploymentBlock": "0x01213b22" + "deploymentBlock": "0x0" + } + } + }, + "80002": { + "contracts": { + "CNSRegistry": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "forwarder": "0x0000000000000000000000000000000000000000" }, "SignatureController": { "address": "0x0000000000000000000000000000000000000000", @@ -498,16 +573,135 @@ "deploymentBlock": "0x0", "forwarder": "0x0000000000000000000000000000000000000000" }, + "TwitterValidationOperator": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "FreeMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "MintableERC721Predicate": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "RootChainManager": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "ProxyAdmin": { + "address": "0xCbF16B0E2A06916F0Ca4892F704349d13E11cF66", + "legacyAddresses": [], + "deploymentBlock": "0x53f24d" + }, + "UNSOperator": { + "address": "0x89D35aABc8427a32ee7032e73975271e1480fd4E", + "legacyAddresses": [], + "deploymentBlock": "0x53f775", + "implementation": "0x49Ac063337cF2fB26dD421Ab650b893CD54b900F" + }, + "UNSRegistry": { + "address": "0xAb005176D74900A9c25fDA144e2f9f329A409166", + "legacyAddresses": [], + "deploymentBlock": "0x53f76a", + "implementation": "0x223350B4892300EA6E8adEF48C955dcf1C544D02", + "forwarder": "0xAb005176D74900A9c25fDA144e2f9f329A409166" + }, + "MintingManager": { + "address": "0xabec3fF0F0b6375F65CB9aEB01e8347bf697082F", + "legacyAddresses": [], + "deploymentBlock": "0x53f770", + "implementation": "0x5e6f02BA94648Fb25Ca98C6a577c04A0Db34c724", + "forwarder": "0xC738bD0E31CF0f7a777D815F8cA965f3c064C012" + }, "ProxyReader": { - "address": "0xBD4674F11d512120dFc8BAe5f84963d7419A5db2", - "implementation": "0x952e0E876ad3a47F503Fb53eB04dD89aA1e6B8Da", - "legacyAddresses": [ - "0x71f7C0A978A541aB13Bd5783470f38b0dd71Cf78", - "0x6fe7c857C1B0E54492C8762f27e0a45CA7ff264B", - "0xbd9e01F6513E7C05f71Bf21d419a3bDF1EA9104b", - "0x332A8191905fA8E6eeA7350B5799F225B8ed30a9" - ], - "deploymentBlock": "0x01bb07d3" + "address": "0x109e7315189E476AB21166955a0fB9BE9b531BEc", + "legacyAddresses": [], + "deploymentBlock": "0x53fff5", + "implementation": "0xA35F199591bD4F0Cb301ff85b6109Bda146dfb09" + }, + "DotCoinBurner": { + "address": "0xFc86844dE82FA7906C9789ca3161004F18Ca8ff4", + "legacyAddresses": [], + "deploymentBlock": "0x540d0d" + }, + "ZilliqaRecover": { + "address": "0x002380ccAFf852dEF50a176873d50f8019e36FBc", + "legacyAddresses": [], + "deploymentBlock": "0x540d6a", + "implementation": "0xBf101Ad6226024D1d26180136311d77387353c71", + "forwarder": "0x002380ccAFf852dEF50a176873d50f8019e36FBc" + }, + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0" + }, + "SeaportProxyBuyer": { + "address": "0x4FF860525ccb6E992E0A4579860465f7EF581aed", + "deploymentBlock": "0x7c4d06", + "implementation": "0xf02a5fA08b86aC35EC3D6Df6878832334696788E", + "forwarder": "0x4FF860525ccb6E992E0A4579860465f7EF581aed" + }, + "USDC": { + "address": "0x9E85b0F8a298Eb0ACc175cFFEd0674718d552C11", + "deploymentBlock": "0xb7c92b", + "implementation": "0xf66A05D55F6a71E74e131b9870B9131EE56ef12E", + "forwarder": "0x9E85b0F8a298Eb0ACc175cFFEd0674718d552C11" + }, + "L1GasPriceOracle": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + } + } + }, + "84532": { + "contracts": { + "CNSRegistry": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "forwarder": "0x0000000000000000000000000000000000000000" + }, + "SignatureController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "MintingController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "WhitelistedMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "URIPrefixController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "DomainZoneController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "Resolver": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "forwarder": "0x0000000000000000000000000000000000000000" }, "TwitterValidationOperator": { "address": "0x0000000000000000000000000000000000000000", @@ -530,10 +724,200 @@ "legacyAddresses": [], "deploymentBlock": "0x0" }, + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0", + "legacyAddresses": [] + }, + "ProxyAdmin": { + "address": "0xd57f8F7be4BaE8f2bf24792Fec2Ca06513c83c1D", + "legacyAddresses": [], + "deploymentBlock": "0xcbf182" + }, + "UNSRegistry": { + "address": "0xEc353DCE22C2B97814608A6b2e44889506A4Aabf", + "deploymentBlock": "0xcbf184", + "implementation": "0xD0AB7f2490736c60575123aF2Ce0D2D6b13D5490", + "forwarder": "0xEc353DCE22C2B97814608A6b2e44889506A4Aabf", + "legacyAddresses": [] + }, + "MintingManager": { + "address": "0x050Ceb85167D510558E793a483b479f2917B4b9b", + "deploymentBlock": "0xcbf18d", + "implementation": "0x6B5F9068Aa94eFf728585665244cb5AB8735E71A", + "forwarder": "0xEa5AE30C714ccd63Fca6D791Eea1E26CB1be0c1d", + "legacyAddresses": [] + }, + "UNSOperator": { + "address": "0x99d55A02f5d9c76d31C6Ff57cc36A7862D5E1029", + "deploymentBlock": "0xcbf193", + "implementation": "0x3a2Ad968667a8214BEAe6AfA45192DD24109a3e7", + "legacyAddresses": [] + }, + "ProxyReader": { + "address": "0x8Fc4DBA4A6F5AE8992E8f9B64D6d995BD3AfE2c4", + "deploymentBlock": "0xcbf1a9", + "implementation": "0x37e22Fd398B8c95128f5235e991682cF6e9F5d9c", + "legacyAddresses": [] + }, + "SeaportProxyBuyer": { + "address": "0x78c4B414e1AbdF0dE267deDa01DFFd4cd0817A16", + "deploymentBlock": "0xcbf1b5", + "implementation": "0x6C95A12CcEA79971C51b16f707D8CdDd7d1b5033", + "forwarder": "0x78c4B414e1AbdF0dE267deDa01DFFd4cd0817A16", + "legacyAddresses": [] + }, "DotCoinBurner": { - "address": "0x65c6abdf52aD08A53A77488D1Acc5c666ada840F", + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "ZilliqaRecover": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "USDC": { + "address": "0x5dEaC602762362FE5f135FA5904351916053cF70", + "deploymentBlock": "0x0" + }, + "L1GasPriceOracle": { + "address": "0x420000000000000000000000000000000000000F", + "legacyAddresses": [], + "deploymentBlock": "0x0" + } + } + }, + "11155111": { + "contracts": { + "ProxyAdmin": { + "address": "0xCbF16B0E2A06916F0Ca4892F704349d13E11cF66", + "legacyAddresses": [], + "deploymentBlock": "0x5588B8" + }, + "ENSCustody": { + "address": "0xd2Bf816C7b23fF6e7d141ECC4c1e41DcC857aD45", + "legacyAddresses": [], + "deploymentBlock": "0x5588b9", + "implementation": "0x49Ac063337cF2fB26dD421Ab650b893CD54b900F", + "forwarder": "0xd2Bf816C7b23fF6e7d141ECC4c1e41DcC857aD45" + }, + "CNSRegistry": { + "address": "0xAb005176D74900A9c25fDA144e2f9f329A409166", + "legacyAddresses": [], + "deploymentBlock": "0x558be7", + "forwarder": "0xD3146C740c0Fa128ab1aEA90e4E75194AC0Bbc9B" + }, + "SignatureController": { + "address": "0x5e6f02BA94648Fb25Ca98C6a577c04A0Db34c724", + "legacyAddresses": [], + "deploymentBlock": "0x558bee" + }, + "MintingController": { + "address": "0xabec3fF0F0b6375F65CB9aEB01e8347bf697082F", + "legacyAddresses": [], + "deploymentBlock": "0x558bef", + "deprecated": true + }, + "URIPrefixController": { + "address": "0x89D35aABc8427a32ee7032e73975271e1480fd4E", + "legacyAddresses": [], + "deploymentBlock": "0x558bf6", + "deprecated": true + }, + "Resolver": { + "address": "0xf8F0622A88eC688140890153191Db1713442618D", + "legacyAddresses": [], + "deploymentBlock": "0x558bfc", + "forwarder": "0xA35F199591bD4F0Cb301ff85b6109Bda146dfb09" + }, + "WhitelistedMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "DomainZoneController": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "TwitterValidationOperator": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "FreeMinter": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0", + "deprecated": true + }, + "MintableERC721Predicate": { + "address": "0xf8D2ecCA43F50F04922A13c417aEd05C34F1EF52", + "legacyAddresses": [], + "deploymentBlock": "0x486873" + }, + "RootChainManager": { + "address": "0x34F5A25B627f50Bb3f5cAb72807c4D4F405a9232", + "legacyAddresses": [], + "deploymentBlock": "0x486867" + }, + "UNSRegistry": { + "address": "0xDD907B4d80B4a979fd77eE502580c55F2700292c", + "deploymentBlock": "0x55a711", + "legacyAddresses": [], + "implementation": "0x7f21bA760352326c55FD6A83D218c2FCd294Dd1c", + "forwarder": "0xDD907B4d80B4a979fd77eE502580c55F2700292c" + }, + "MintingManager": { + "address": "0x1620637c0ce88cccfa919ef562b4398e3187189d", + "deploymentBlock": "0x55a715", "legacyAddresses": [], - "deploymentBlock": "0x01bbafc7" + "implementation": "0x63B6F3F80d12A70eA26a57cdFDc16F33e6fD319A", + "forwarder": "0x38F532B32E0b42E747483A37Dfaf05460b1F4Fa3" + }, + "UNSOperator": { + "address": "0x41fD65E5a1cbdcCdD69F8C11DA4c829F7d3565A6", + "deploymentBlock": "0x55A717", + "legacyAddresses": [], + "implementation": "0xf9A7A6516Ee73E4Bd3FA9fbABdA3C8DeA40c89FA" + }, + "ProxyReader": { + "address": "0x880F7D37E9E4EB6868F92F4bB9C8C0995178fdA9", + "deploymentBlock": "0x55a857", + "legacyAddresses": [], + "implementation": "0xdA0E8ec8f801593161e689275Ab1394e7791ee18" + }, + "DotCoinBurner": { + "address": "0x64E3ecF931610d2503247b7c7A885688de54241A", + "legacyAddresses": [], + "deploymentBlock": "0x55f932" + }, + "ZilliqaRecover": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" + }, + "Seaport": { + "address": "0x0000000000000068F116a894984e2DB1123eB395", + "deploymentBlock": "0x0" + }, + "SeaportProxyBuyer": { + "address": "0x0000000000000000000000000000000000000000", + "deploymentBlock": "0x0", + "implementation": "0x0000000000000000000000000000000000000000", + "forwarder": "0x0000000000000000000000000000000000000000" + }, + "USDC": { + "address": "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238", + "deploymentBlock": "0x0" + }, + "L1GasPriceOracle": { + "address": "0x0000000000000000000000000000000000000000", + "legacyAddresses": [], + "deploymentBlock": "0x0" } } } diff --git a/src/types/index.ts b/src/types/index.ts index 91fe80d4..4d1631d0 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -121,9 +121,11 @@ const StringUnion = (...values: UnionType[]) => { export const UnsSupportedNetwork = StringUnion( 'mainnet', - 'goerli', + 'sepolia', 'polygon-mainnet', - 'polygon-mumbai', + 'polygon-amoy', + 'base-mainnet', + 'base-sepolia', ); export type UnsSupportedNetwork = typeof UnsSupportedNetwork.type; diff --git a/src/types/publicTypes.ts b/src/types/publicTypes.ts index 2d26c3da..3d2cfa48 100644 --- a/src/types/publicTypes.ts +++ b/src/types/publicTypes.ts @@ -48,6 +48,7 @@ export enum UnsLocation { export enum NamingServiceName { UNS = 'UNS', + UNS_BASE = 'UNS_BASE', ENS = 'ENS', ZNS = 'ZNS', } @@ -280,6 +281,7 @@ export enum BlockchainType { ETH = 'ETH', MATIC = 'MATIC', ZIL = 'ZIL', + BASE = 'BASE', } export type DomainLocation = { diff --git a/src/utils/index.ts b/src/utils/index.ts index 381ef436..0e5ce080 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -7,15 +7,19 @@ type NetworkSignedLinkURLs = Record; const ProviderURLMap: Record = { infura: { mainnet: 'https://mainnet.infura.io/v3/', - goerli: 'https://goerli.infura.io/v3/', + sepolia: 'https://sepolia.infura.io/v3/', 'polygon-mainnet': 'https://polygon-mainnet.infura.io/v3/', - 'polygon-mumbai': 'https://polygon-mumbai.infura.io/v3/', + 'polygon-amoy': 'https://polygon-amoy.infura.io/v3/', + 'base-mainnet': 'https://base-mainnet.infura.io/v3/', + 'base-sepolia': 'https://base-sepolia.infura.io/v3/', }, alchemy: { mainnet: 'https://eth-mainnet.alchemyapi.io/v2/', - goerli: 'https://eth-goerli.alchemyapi.io/v2/', + sepolia: 'https://eth-sepolia.alchemyapi.io/v2/', 'polygon-mainnet': 'https://polygon-mainnet.g.alchemy.com/v2/', - 'polygon-mumbai': 'https://polygon-mumbai.g.alchemy.com/v2/', + 'polygon-amoy': 'https://polygon-amoy.g.alchemy.com/v2/', + 'base-mainnet': 'https://base-mainnet.g.alchemy.com/v2/', + 'base-sepolia': 'https://base-sepolia.g.alchemy.com/v2/', }, }; @@ -76,6 +80,7 @@ export function constructRecords( return records; } +// TODO: Replace this with supported_tlds calls export const domainExtensionToNamingServiceName = { crypto: NamingServiceName.UNS, zil: NamingServiceName.ZNS, @@ -84,6 +89,7 @@ export const domainExtensionToNamingServiceName = { xyz: NamingServiceName.ENS, kred: NamingServiceName.ENS, reverse: NamingServiceName.ENS, + udtest: NamingServiceName.UNS_BASE, }; export const findNamingServiceName = ( @@ -102,17 +108,22 @@ export const findNamingServiceName = ( export const EthereumNetworks = { mainnet: 1, - goerli: 5, + sepolia: 11155111, 'polygon-mainnet': 137, - 'polygon-mumbai': 80001, + 'polygon-amoy': 80002, + 'base-mainnet': 8453, + 'base-sepolia': 84532, } as const; -export const EthereumNetworksInverted = { - 1: 'mainnet', - 5: 'goerli', - 137: 'polygon-mainnet', - 80001: 'polygon-mumbai', -} as const; +export const EthereumNetworksInverted = Object.entries(EthereumNetworks).reduce< + Record +>( + (acc, [originalKey, originalValue]) => ({ + ...acc, + [originalValue]: originalKey, + }), + {}, +); export const wrapResult = (func: () => T): Promise> => { let callResult; From 75b9498b74dba8e74d585fed394b4c8c9e572434 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 24 Sep 2024 16:23:51 -0400 Subject: [PATCH 2/8] feat: add reverse resolution priority --- src/Resolution.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Resolution.ts b/src/Resolution.ts index 7a8ad573..c479f7d6 100644 --- a/src/Resolution.ts +++ b/src/Resolution.ts @@ -1178,10 +1178,18 @@ export default class Resolution { private async reverseGetTokenId( address: string, location?: UnsLocation, - ): Promise { - const service = this.serviceMap['UNS'].native; - const tokenId = await service.reverseOf(address, location); - return tokenId as string; + ): Promise { + let tokenId: string | null = null; + + const unsService = this.serviceMap['UNS'].native; + tokenId = await unsService.reverseOf(address, location); + + if (!tokenId) { + const baseUnsService = this.serviceMap['UNS_BASE'].native; + tokenId = await baseUnsService.reverseOf(address, location); + } + + return tokenId; } private getUnsConfig(config: ResolutionConfig): Uns | UdApi { From 1affbeca291a3788d1a8726fef5055271bab61db Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 30 Sep 2024 14:53:34 -0400 Subject: [PATCH 3/8] feat: load tld naming service from /supported_tlds API --- .env.example | 8 +- src/Ens.ts | 18 -- src/Resolution.ts | 8 +- src/UdApi.ts | 8 +- src/Uns.ts | 4 +- src/tests/Ens.test.ts | 4 +- src/tests/Resolution.test.ts | 276 ++++++++++++++++--------------- src/tests/Uns.test.ts | 30 ++-- src/tests/UnsInternal.test.ts | 17 +- src/tests/Zns.test.ts | 51 +++--- src/tests/testData/mockData.json | 2 +- src/types/index.ts | 2 +- src/types/publicTypes.ts | 3 +- src/utils/Networking.ts | 6 +- src/utils/Tlds.ts | 42 +++++ src/utils/index.ts | 73 +++++--- 16 files changed, 311 insertions(+), 241 deletions(-) create mode 100644 src/utils/Tlds.ts diff --git a/.env.example b/.env.example index 52800290..5094b85e 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -L1_TEST_NET_RPC_URL=https://goerli.infura.io/v3/ -L1_TEST_NET_RPC_WSS_URL=wss://goerli.infura.io/ws/v3/ -L2_TEST_NET_RPC_URL=https://polygon-mumbai.infura.io/v3/ -L2_TEST_NET_RPC_WSS_URL=wss://polygon-mumbai.g.alchemy.com/v2/ +L1_TEST_NET_RPC_URL=https://sepolia.infura.io/v3/ +L1_TEST_NET_RPC_WSS_URL=wss://sepolia.infura.io/ws/v3/ +L2_TEST_NET_RPC_URL=https://polygon-amoy.infura.io/v3/ +L2_TEST_NET_RPC_WSS_URL=wss://polygon-amoy.g.alchemy.com/v2/ diff --git a/src/Ens.ts b/src/Ens.ts index d1e67ee9..31fdd22d 100644 --- a/src/Ens.ts +++ b/src/Ens.ts @@ -15,7 +15,6 @@ import { Locations, NamingServiceName, Provider, - TokenUriMetadata, BlockchainType, DnsRecordType, DnsRecord, @@ -289,7 +288,6 @@ export default class Ens extends NamingService { let domainName = ''; const nameWrapperMetadataResponse = await Networking.fetch( `https://metadata.ens.domains/${this.networkName}/${this.nameWrapperContract.address}/${hash}`, - {}, ); if (nameWrapperMetadataResponse.status === 200) { const jsonResponse = await nameWrapperMetadataResponse.json(); @@ -299,7 +297,6 @@ export default class Ens extends NamingService { const baseRegistrarMetadataResponse = await Networking.fetch( `https://metadata.ens.domains/${this.networkName}/${this.baseRegistrarContract.address}/${hash}`, - {}, ); if (baseRegistrarMetadataResponse.status === 200) { @@ -614,19 +611,4 @@ export default class Ens extends NamingService { this.namehash(domain), ]); } - - private async getMetadataFromTokenURI( - tokenUri: string, - ): Promise { - const resp = await Networking.fetch(tokenUri, {}); - if (resp.ok) { - return resp.json(); - } - - throw new ResolutionError(ResolutionErrorCode.ServiceProviderError, { - providerMessage: await resp.text(), - method: 'UDAPI', - methodName: 'tokenURIMetadata', - }); - } } diff --git a/src/Resolution.ts b/src/Resolution.ts index c479f7d6..4b34714a 100644 --- a/src/Resolution.ts +++ b/src/Resolution.ts @@ -662,7 +662,7 @@ export default class Resolution { async email(domain: string): Promise { domain = prepareAndValidateDomain(domain); let key = 'whois.email.value'; - const serviceName = findNamingServiceName(domain); + const serviceName = await findNamingServiceName(domain); if (serviceName === 'ENS') { key = 'email'; } @@ -1062,7 +1062,7 @@ export default class Resolution { private async getMetadataFromTokenURI( tokenUri: string, ): Promise { - const resp = await Networking.fetch(tokenUri, {}); + const resp = await Networking.fetch(tokenUri); if (resp.ok) { return resp.json(); } @@ -1102,7 +1102,7 @@ export default class Resolution { domain: string, func: (service: NamingService) => T, ): Promise> { - const serviceName = findNamingServiceName(domain); + const serviceName = await findNamingServiceName(domain); if (!serviceName) { throw new ResolutionError(ResolutionErrorCode.UnsupportedDomain, { domain, @@ -1141,7 +1141,7 @@ export default class Resolution { func: (service: NamingService) => Promise, options: {throwIfUnsupportedDomain: boolean; expectedValue: boolean}, ): Promise { - const serviceName = findNamingServiceName(domain); + const serviceName = await findNamingServiceName(domain); if (!serviceName) { if (!options.throwIfUnsupportedDomain) { return !options.expectedValue; diff --git a/src/UdApi.ts b/src/UdApi.ts index 142e55da..81b8a0b3 100644 --- a/src/UdApi.ts +++ b/src/UdApi.ts @@ -31,9 +31,9 @@ export default class UdApi extends NamingService { constructor(api?: Api) { super(); - this.url = api?.url || 'https://unstoppabledomains.com/api/v1'; + this.url = api?.url || 'https://unstoppabledomains.com/api/v1'; // TODO: this is about to be deprecated const DefaultUserAgent = - 'cross-fetch/3.1.4 (+https://github.com/lquixada/cross-fetch)'; + 'cross-fetch/4.0.0 (+https://github.com/lquixada/cross-fetch)'; const CustomUserAgent = `${DefaultUserAgent} Resolution`; this.headers = {'X-user-agent': CustomUserAgent}; } @@ -77,7 +77,7 @@ export default class UdApi extends NamingService { } async twitter(domain: string): Promise { - const serviceName = findNamingServiceName(domain); + const serviceName = await findNamingServiceName(domain); if (serviceName !== NamingServiceName.UNS) { throw new ResolutionError(ResolutionErrorCode.UnsupportedMethod, { domain, @@ -150,7 +150,7 @@ export default class UdApi extends NamingService { private async getMetadata(tokenId: string): Promise { const tokenUri = `${this.url}/${tokenId}`; - const resp = await Networking.fetch(tokenUri, {}).catch((err) => { + const resp = await Networking.fetch(tokenUri).catch((err) => { throw new ResolutionError(ResolutionErrorCode.MetadataEndpointError, { tokenUri: tokenUri || 'undefined', errorMessage: err.message, diff --git a/src/Uns.ts b/src/Uns.ts index 66b35dd5..f0459606 100644 --- a/src/Uns.ts +++ b/src/Uns.ts @@ -99,7 +99,7 @@ export default class Uns extends NamingService { this.unsl2 = new UnsInternal( UnsLocation.Layer2, source.locations.Layer2, - BlockchainType.MATIC, + BlockchainType.POL, ); } @@ -447,7 +447,7 @@ export default class Uns extends NamingService { private async getMetadata(tokenId: string): Promise { const tokenUri = await this.getTokenUri(tokenId); - const resp = await Networking.fetch(tokenUri, {}).catch((err) => { + const resp = await Networking.fetch(tokenUri).catch((err) => { throw new ResolutionError(ResolutionErrorCode.MetadataEndpointError, { tokenUri: tokenUri || 'undefined', errorMessage: err.message, diff --git a/src/tests/Ens.test.ts b/src/tests/Ens.test.ts index 1cf6f9c1..4d006b72 100644 --- a/src/tests/Ens.test.ts +++ b/src/tests/Ens.test.ts @@ -11,6 +11,8 @@ import { } from './helpers'; import Ens from '../Ens'; +const ETH_L1_TESTNET_NAME = 'sepolia'; + let resolution: Resolution; let ens: Ens; @@ -24,7 +26,7 @@ beforeEach(() => { ProviderProtocol.http, NamingServiceName.ENS, ), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, }, }); diff --git a/src/tests/Resolution.test.ts b/src/tests/Resolution.test.ts index 65bcde74..0b1a9339 100644 --- a/src/tests/Resolution.test.ts +++ b/src/tests/Resolution.test.ts @@ -55,6 +55,9 @@ let uns: Uns; let zns: Zns; let ens: Ens; +const ETH_L1_TESTNET_NAME = 'sepolia'; +const POL_L2_TESTNET_NAME = 'polygon-amoy'; + beforeEach(() => { nock.cleanAll(); jest.restoreAllMocks(); @@ -64,11 +67,11 @@ beforeEach(() => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -77,7 +80,7 @@ beforeEach(() => { ProviderProtocol.http, NamingServiceName.ENS, ), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, zns: {network: 'testnet'}, }, @@ -102,8 +105,8 @@ describe('Resolution', () => { describe('.Basic setup', () => { it('should work with autonetwork url configuration', async () => { - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); // mocking getNetworkConfigs because no access to inner provider.request const UnsGetNetworkOriginal = Uns.autoNetwork; const EnsGetNetworkOriginal = Ens.autoNetwork; @@ -112,29 +115,29 @@ describe('Resolution', () => { new Uns({ locations: { Layer1: { - network: 'goerli', - provider: new FetchProvider(UnsLocation.Layer1, goerliUrl), + network: ETH_L1_TESTNET_NAME, + provider: new FetchProvider(UnsLocation.Layer1, l1Url), }, Layer2: { - network: 'polygon-mumbai', - provider: new FetchProvider(UnsLocation.Layer2, polygonUrl), + network: POL_L2_TESTNET_NAME, + provider: new FetchProvider(UnsLocation.Layer2, l2Url), }, }, }), ); Ens.autoNetwork = jest.fn().mockReturnValue( new Ens({ - url: goerliUrl, - network: 'goerli', - provider: new FetchProvider(NamingServiceName.ENS, goerliUrl), + url: l1Url, + network: ETH_L1_TESTNET_NAME, + provider: new FetchProvider(NamingServiceName.ENS, l1Url), }), ); } const resolution = await Resolution.autoNetwork({ uns: { - locations: {Layer1: {url: goerliUrl}, Layer2: {url: polygonUrl}}, + locations: {Layer1: {url: l1Url}, Layer2: {url: l2Url}}, }, - ens: {url: goerliUrl}, + ens: {url: l1Url}, }); // We need to manually restore the function as jest.restoreAllMocks and simillar works only with spyOn Uns.autoNetwork = UnsGetNetworkOriginal; @@ -142,52 +145,53 @@ describe('Resolution', () => { expect( (resolution.serviceMap[NamingServiceName.UNS].native as Uns).unsl1 .network, - ).toBe('goerli'); + ).toBe(ETH_L1_TESTNET_NAME); expect( (resolution.serviceMap[NamingServiceName.UNS].native as Uns).unsl2 .network, - ).toBe('polygon-mumbai'); + ).toBe(POL_L2_TESTNET_NAME); expect( (resolution.serviceMap[NamingServiceName.ENS].native as Ens).network, ).toBe(5); }); it('should not work with invalid proxyReader configuration #1', async () => { - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); - const customNetwork = 'goerli'; - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + await expectConfigurationErrorCode(() => { new Uns({ locations: { Layer1: { - network: customNetwork, - url: goerliUrl, + network: ETH_L1_TESTNET_NAME, + url: l1Url, proxyReaderAddress: '0x012312931293', }, Layer2: { - network: 'polygon-mumbai', - url: polygonUrl, + network: POL_L2_TESTNET_NAME, + url: l2Url, proxyReaderAddress: '0x012312931293', }, }, }); }, ConfigurationErrorCode.InvalidConfigurationField); }); + it('should not work with invalid proxyReader configuration #2', async () => { - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); - const customNetwork = 'goerli'; - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + await expect(() => { new Uns({ locations: { Layer1: { - network: customNetwork, - url: goerliUrl, + network: ETH_L1_TESTNET_NAME, + url: l1Url, proxyReaderAddress: '0xe7474D07fD2FA286e7e0aa23cd107F8379025037', }, Layer2: { - network: 'polygon-mumbai', - url: polygonUrl, + network: POL_L2_TESTNET_NAME, + url: l2Url, proxyReaderAddress: '0x012312931293', }, }, @@ -204,22 +208,22 @@ describe('Resolution', () => { }); it('should not work with invalid proxyReader configuration #3', async () => { - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); - const provider = new FetchProvider(NamingServiceName.UNS, goerliUrl); - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const polygonProvider = new FetchProvider(UnsLocation.Layer2, polygonUrl); - const customNetwork = 'goerli'; + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l1Provider = new FetchProvider(NamingServiceName.UNS, l1Url); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l2Provider = new FetchProvider(UnsLocation.Layer2, l2Url); + await expectConfigurationErrorCode(() => { new Uns({ locations: { Layer1: { - network: customNetwork, - provider, + network: ETH_L1_TESTNET_NAME, + provider: l1Provider, proxyReaderAddress: '0xe7474D07fD2FA286e7e0aa23cd107F8379025037', }, Layer2: { - network: 'polygon-mumbai', - provider: polygonProvider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider, proxyReaderAddress: '0x332a8191905fa8e6eea7350b5799f225b8ed', }, }, @@ -228,20 +232,19 @@ describe('Resolution', () => { }); it('should work with proxyReader configuration', async () => { - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const customNetwork = 'goerli'; + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); const uns = new Uns({ locations: { Layer1: { - network: customNetwork, - url: goerliUrl, + network: ETH_L1_TESTNET_NAME, + url: l1Url, proxyReaderAddress: '0xe7474D07fD2FA286e7e0aa23cd107F8379025037', }, Layer2: { - network: 'polygon-mumbai', - url: polygonUrl, + network: POL_L2_TESTNET_NAME, + url: l2Url, proxyReaderAddress: '0x332a8191905fa8e6eea7350b5799f225b8ed30a9', }, }, @@ -250,21 +253,21 @@ describe('Resolution', () => { }); it('should work with custom network configuration with provider', async () => { - const goerliUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); - const provider = new FetchProvider(NamingServiceName.UNS, goerliUrl); - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const polygonProvider = new FetchProvider(UnsLocation.Layer2, polygonUrl); - const customNetwork = 'goerli'; + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l1Provider = new FetchProvider(NamingServiceName.UNS, l1Url); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l2Provider = new FetchProvider(UnsLocation.Layer2, l2Url); + const uns = new Uns({ locations: { Layer1: { - network: customNetwork, - provider, + network: ETH_L1_TESTNET_NAME, + provider: l1Provider, proxyReaderAddress: '0xe7447Fdd52FA286e7e0aa23cd107F83790250897', }, Layer2: { - network: 'polygon-mumbai', - provider: polygonProvider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider, proxyReaderAddress: '0x332a8191905fa8e6eea7350b5799f225b8ed30a9', }, }, @@ -278,13 +281,13 @@ describe('Resolution', () => { getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), ); - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const polygonProvider = new FetchProvider(UnsLocation.Layer2, polygonUrl); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const l2Provider = new FetchProvider(UnsLocation.Layer2, l2Url); const spy = mockAsyncMethod(provider, 'request', '1'); - const spyTwo = mockAsyncMethod(polygonProvider, 'request', '80001'); + const spyTwo = mockAsyncMethod(l2Provider, 'request', '80001'); const resolution = await Resolution.autoNetwork({ uns: { - locations: {Layer1: {provider}, Layer2: {provider: polygonProvider}}, + locations: {Layer1: {provider}, Layer2: {provider: l2Provider}}, }, ens: {provider}, }); @@ -297,7 +300,7 @@ describe('Resolution', () => { expect( (resolution.serviceMap[NamingServiceName.UNS].native as Uns).unsl2 .network, - ).toBe('polygon-mumbai'); + ).toBe(POL_L2_TESTNET_NAME); expect( (resolution.serviceMap[NamingServiceName.ENS].native as Ens).network, ).toBe(1); @@ -367,15 +370,9 @@ describe('Resolution', () => { }); it('should fail because of unsupported test network for uns', async () => { - const blockchainUrl = getProtocolLinkFromEnv( - ProviderProtocol.http, - 'UNSL1', - ); - const polygonUrl = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); - const mockedProvider = new FetchProvider( - NamingServiceName.UNS, - blockchainUrl, - ); + const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); + const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); + const mockedProvider = new FetchProvider(NamingServiceName.UNS, l1Url); mockAsyncMethod(mockedProvider, 'request', () => '3'); mockAsyncMethod(FetchProvider, 'factory', () => mockedProvider); @@ -383,8 +380,8 @@ describe('Resolution', () => { Resolution.autoNetwork({ uns: { locations: { - Layer1: {url: blockchainUrl}, - Layer2: {url: polygonUrl}, + Layer1: {url: l1Url}, + Layer2: {url: l2Url}, }, }, }), @@ -407,32 +404,40 @@ describe('Resolution', () => { const resolution = Resolution.infura('api-key', { uns: { locations: { - Layer1: {network: 'goerli'}, - Layer2: {network: 'polygon-mumbai'}, + Layer1: {network: ETH_L1_TESTNET_NAME}, + Layer2: {network: POL_L2_TESTNET_NAME}, }, }, - ens: {network: 'goerli'}, + ens: {network: ETH_L1_TESTNET_NAME}, }); uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; ens = resolution.serviceMap[NamingServiceName.ENS].native as Ens; - expect(uns.unsl1.url).toBe(`https://goerli.infura.io/v3/api-key`); - expect(uns.unsl2.url).toBe(`https://polygon-mumbai.infura.io/v3/api-key`); - expect(ens.url).toBe(`https://goerli.infura.io/v3/api-key`); + expect(uns.unsl1.url).toBe( + `https://${ETH_L1_TESTNET_NAME}.infura.io/v3/api-key`, + ); + expect(uns.unsl2.url).toBe( + `https://${POL_L2_TESTNET_NAME}.infura.io/v3/api-key`, + ); + expect(ens.url).toBe( + `https://${ETH_L1_TESTNET_NAME}.infura.io/v3/api-key`, + ); }); it('should get a valid resolution instance with .alchemy', async () => { const resolution = Resolution.alchemy('api-key', { uns: { locations: { - Layer1: {network: 'goerli'}, - Layer2: {network: 'polygon-mumbai'}, + Layer1: {network: ETH_L1_TESTNET_NAME}, + Layer2: {network: POL_L2_TESTNET_NAME}, }, }, }); uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; - expect(uns.unsl1.url).toBe(`https://eth-goerli.alchemyapi.io/v2/api-key`); + expect(uns.unsl1.url).toBe( + `https://eth-${ETH_L1_TESTNET_NAME}.g.alchemy.com/v2/api-key`, + ); expect(uns.unsl2.url).toBe( - `https://polygon-mumbai.g.alchemy.com/v2/api-key`, + `https://${POL_L2_TESTNET_NAME}.g.alchemy.com/v2/api-key`, ); }); @@ -615,6 +620,7 @@ describe('Resolution', () => { ); expectSpyToBeCalled([unsSpy, znsSpy]); }); + it('checks Resolution#addr error #2', async () => { const resolution = new Resolution({ sourceConfig: { @@ -622,11 +628,11 @@ describe('Resolution', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -775,6 +781,7 @@ describe('Resolution', () => { expectSpyToBeCalled(eyes, 2); expect(capital).toStrictEqual(lower); }); + describe('.multichain', () => { it('should work with usdt on different erc20', async () => { const erc20Spy = mockAsyncMethod(uns, 'get', { @@ -852,15 +859,15 @@ describe('Resolution', () => { describe('.Providers', () => { it('should work with web3HttpProvider', async () => { // web3-providers-http has problems with type definitions - const provider = new (Web3HttpProvider as any)( + const l1Provider = new (Web3HttpProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), ); - const polygonProvider = new (Web3HttpProvider as any)( + const l2Provider = new (Web3HttpProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), ); // mock the send function with different implementations (each should call callback right away with different answers) const eye = mockAsyncMethod( - provider, + l1Provider, 'send', (payload: JsonRpcPayload, callback) => { const result = caseMock( @@ -879,13 +886,12 @@ describe('Resolution', () => { uns: { locations: { Layer1: { - network: 'goerli', - provider: provider as unknown as Web3Version1Provider, + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as Web3Version1Provider, }, Layer2: { - network: 'polygon-mumbai', - provider: - polygonProvider as unknown as Web3Version1Provider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider as Web3Version1Provider, }, }, }, @@ -905,14 +911,14 @@ describe('Resolution', () => { it('should work with webSocketProvider', async () => { // web3-providers-ws has problems with type definitions - const provider = new (Web3WsProvider as any)( + const l1Provider = new (Web3WsProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.wss, 'UNSL1'), ); - const polygonProvider = new (Web3WsProvider as any)( + const l2Provider = new (Web3WsProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.wss, 'UNSL2'), ); const eye = mockAsyncMethod( - provider, + l1Provider, 'send', (payload, callback) => { const result = caseMock( @@ -930,13 +936,12 @@ describe('Resolution', () => { uns: { locations: { Layer1: { - network: 'goerli', - provider: provider as unknown as Web3Version1Provider, + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as Web3Version1Provider, }, Layer2: { - network: 'polygon-mumbai', - provider: - polygonProvider as unknown as Web3Version1Provider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider as Web3Version1Provider, }, }, }, @@ -946,7 +951,7 @@ describe('Resolution', () => { Promise.resolve([NullAddress, NullAddress, {}]), ); const ethAddress = await resolution.addr('brad.crypto', 'ETH'); - provider.disconnect(1000, 'end of test'); + l1Provider.disconnect(1000, 'end of test'); expectSpyToBeCalled([eye]); expect(ethAddress).toBe( '0x8aaD44321A86b170879d7A244c1e8d360c99DdA8', @@ -954,21 +959,21 @@ describe('Resolution', () => { }); it('should work for ethers jsonrpc provider', async () => { - const provider = new JsonRpcProvider( + const l1Provider = new JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - 'goerli', + ETH_L1_TESTNET_NAME, ); - const polygonProvider = new JsonRpcProvider( + const l2Provider = new JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - 'maticmum', + POL_L2_TESTNET_NAME, ); const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: 'goerli', provider}, + Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, Layer2: { - network: 'polygon-mumbai', - provider: polygonProvider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider, }, }, }, @@ -977,7 +982,7 @@ describe('Resolution', () => { mockAsyncMethod(uns.unsl2.readerContract, 'call', (params) => Promise.resolve([NullAddress, NullAddress, {}]), ); - const eye = mockAsyncMethod(provider, 'call', (params) => + const eye = mockAsyncMethod(l1Provider, 'call', (params) => Promise.resolve(caseMock(params, RpcProviderTestCases)), ); const ethAddress = await resolution.addr('brad.crypto', 'ETH'); @@ -989,14 +994,14 @@ describe('Resolution', () => { it('should work with webSocketProvider', async () => { // web3-providers-ws has problems with type definitions - const provider = new (Web3WsProvider as any)( + const l1Provider = new (Web3WsProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.wss, 'UNSL1'), ); - const polygonProvider = new (Web3WsProvider as any)( + const l2Provider = new (Web3WsProvider as any)( getProtocolLinkFromEnv(ProviderProtocol.wss, 'UNSL2'), ); const eye = mockAsyncMethod( - provider, + l1Provider, 'send', (payload, callback) => { const result = caseMock( @@ -1015,13 +1020,12 @@ describe('Resolution', () => { uns: { locations: { Layer1: { - network: 'goerli', - provider: provider as unknown as Web3Version1Provider, + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as Web3Version1Provider, }, Layer2: { - network: 'polygon-mumbai', - provider: - polygonProvider as unknown as Web3Version1Provider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider as Web3Version1Provider, }, }, }, @@ -1031,7 +1035,7 @@ describe('Resolution', () => { Promise.resolve([NullAddress, NullAddress, {}]), ); const ethAddress = await resolution.addr('brad.crypto', 'ETH'); - provider.disconnect(1000, 'end of test'); + l1Provider.disconnect(1000, 'end of test'); expectSpyToBeCalled([eye]); expect(ethAddress).toBe( '0x8aaD44321A86b170879d7A244c1e8d360c99DdA8', @@ -1039,21 +1043,21 @@ describe('Resolution', () => { }); it('should work for ethers jsonrpc provider', async () => { - const provider = new JsonRpcProvider( + const l1Provider = new JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - 'goerli', + ETH_L1_TESTNET_NAME, ); - const polygonProvider = new JsonRpcProvider( + const l2Provider = new JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - 'maticmum', + POL_L2_TESTNET_NAME, ); const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: 'goerli', provider}, + Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, Layer2: { - network: 'polygon-mumbai', - provider: polygonProvider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider, }, }, }, @@ -1062,7 +1066,7 @@ describe('Resolution', () => { mockAsyncMethod(uns.unsl2.readerContract, 'call', (params) => Promise.resolve([NullAddress, NullAddress, {}]), ); - const eye = mockAsyncMethod(provider, 'call', (params) => + const eye = mockAsyncMethod(l1Provider, 'call', (params) => Promise.resolve(caseMock(params, RpcProviderTestCases)), ); const ethAddress = await resolution.addr('brad.crypto', 'ETH'); @@ -1073,25 +1077,25 @@ describe('Resolution', () => { }); it('should work with ethers default provider', async () => { - const provider = new InfuraProvider( - 'goerli', + const l1Provider = new InfuraProvider( + ETH_L1_TESTNET_NAME, '213fff28936343858ca9c5115eff1419', ); - const polygonProvider = new InfuraProvider( - 'maticmum', + const l2Provider = new InfuraProvider( + POL_L2_TESTNET_NAME, 'a32aa2ace9704ee9a1a9906418bcabe5', ); - const eye = mockAsyncMethod(provider, 'call', (params) => + const eye = mockAsyncMethod(l1Provider, 'call', (params) => Promise.resolve(caseMock(params, RpcProviderTestCases)), ); const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: 'goerli', provider}, + Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, Layer2: { - network: 'polygon-mumbai', - provider: polygonProvider, + network: POL_L2_TESTNET_NAME, + provider: l2Provider, }, }, }, @@ -1789,7 +1793,7 @@ describe('Resolution', () => { registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', networkId: 80001, - blockchain: BlockchainType.MATIC, + blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( ProviderProtocol.http, @@ -1802,7 +1806,7 @@ describe('Resolution', () => { registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', networkId: 80001, - blockchain: BlockchainType.MATIC, + blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( ProviderProtocol.http, @@ -1817,7 +1821,7 @@ describe('Resolution', () => { registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', networkId: 80001, - blockchain: BlockchainType.MATIC, + blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( ProviderProtocol.http, diff --git a/src/tests/Uns.test.ts b/src/tests/Uns.test.ts index 88c21b93..7ea9c85e 100644 --- a/src/tests/Uns.test.ts +++ b/src/tests/Uns.test.ts @@ -30,6 +30,9 @@ import UnsConfig from '../config/uns-config.json'; import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash'; import Zns from '../Zns'; +const ETH_L1_TESTNET_NAME = 'sepolia'; +const POL_L2_TESTNET_NAME = 'polygon-amoy'; + describe('UNS', () => { describe('constructor', () => { it('should define the default uns contract', () => { @@ -37,20 +40,20 @@ describe('UNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }); expect(uns).toBeDefined(); - expect(uns.unsl1.network).toBe('goerli'); + expect(uns.unsl1.network).toBe(ETH_L1_TESTNET_NAME); expect(uns.unsl1.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), ); - expect(uns.unsl2.network).toBe('polygon-mumbai'); + expect(uns.unsl2.network).toBe(POL_L2_TESTNET_NAME); expect(uns.unsl2.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), ); @@ -101,9 +104,9 @@ describe('UNS', () => { sourceConfig: { uns: { locations: { - Layer1: {network: 'goerli'}, + Layer1: {network: ETH_L1_TESTNET_NAME}, Layer2: { - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, url: 'https://someurl.com', }, }, @@ -121,9 +124,12 @@ describe('UNS', () => { sourceConfig: { uns: { locations: { - Layer1: {network: 'goerli', url: 'https://someurl.com'}, + Layer1: { + network: ETH_L1_TESTNET_NAME, + url: 'https://someurl.com', + }, Layer2: { - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -146,11 +152,11 @@ describe('UNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -1534,9 +1540,9 @@ describe('UNS', () => { sourceConfig: { uns: { locations: { - Layer1: {url, provider, network: 'goerli'}, + Layer1: {url, provider, network: ETH_L1_TESTNET_NAME}, Layer2: { - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, provider: polygonProvider, }, }, diff --git a/src/tests/UnsInternal.test.ts b/src/tests/UnsInternal.test.ts index a9319325..2e5173d5 100644 --- a/src/tests/UnsInternal.test.ts +++ b/src/tests/UnsInternal.test.ts @@ -20,6 +20,9 @@ import {ResolutionError, ResolutionErrorCode} from '../errors/resolutionError'; import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash'; import Networking from '../utils/Networking'; +const ETH_L1_TESTNET_NAME = 'sepolia'; +const POL_L2_TESTNET_NAME = 'polygon-amoy'; + let unsInternalL1: UnsInternal; let unsInternalL2: UnsInternal; @@ -29,7 +32,7 @@ beforeEach(async () => { UnsLocation.Layer1, { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, BlockchainType.ETH, ); @@ -37,9 +40,9 @@ beforeEach(async () => { UnsLocation.Layer2, { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, - BlockchainType.MATIC, + BlockchainType.POL, ); }); @@ -131,7 +134,7 @@ describe('UnsInternal', () => { UnsLocation.Layer1, { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, proxyServiceApiKey: 'some key', }, BlockchainType.ETH, @@ -399,7 +402,7 @@ describe('UnsInternal', () => { registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', networkId: 80001, - blockchain: BlockchainType.MATIC, + blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( ProviderProtocol.http, @@ -423,7 +426,7 @@ describe('UnsInternal', () => { registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', networkId: 80001, - blockchain: BlockchainType.MATIC, + blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( ProviderProtocol.http, @@ -439,7 +442,7 @@ describe('UnsInternal', () => { UnsLocation.Layer1, { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, proxyServiceApiKey: 'some key', }, BlockchainType.ETH, diff --git a/src/tests/Zns.test.ts b/src/tests/Zns.test.ts index a1a154e1..0aa6e0e3 100644 --- a/src/tests/Zns.test.ts +++ b/src/tests/Zns.test.ts @@ -15,6 +15,9 @@ import {ConfigurationErrorCode} from '../errors/configurationError'; import Uns from '../Uns'; import ResolutionError from '../errors/resolutionError'; +const ETH_L1_TESTNET_NAME = 'sepolia'; +const POL_L2_TESTNET_NAME = 'polygon-amoy'; + let resolution: Resolution; let zns: Zns; let uns: Uns; @@ -28,11 +31,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -63,11 +66,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -86,11 +89,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -109,11 +112,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -134,11 +137,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -159,11 +162,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -185,11 +188,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -212,11 +215,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -239,11 +242,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -265,11 +268,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -288,11 +291,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, @@ -317,11 +320,11 @@ describe('ZNS', () => { locations: { Layer1: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: 'goerli', + network: ETH_L1_TESTNET_NAME, }, Layer2: { url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: 'polygon-mumbai', + network: POL_L2_TESTNET_NAME, }, }, }, diff --git a/src/tests/testData/mockData.json b/src/tests/testData/mockData.json index baa3a175..15b7c26a 100644 --- a/src/tests/testData/mockData.json +++ b/src/tests/testData/mockData.json @@ -602,7 +602,7 @@ "METHOD": "POST", "REQUEST": { "method": "POST", - "url": "https://goerli.infura.io/v3/a32aa2ace9704ee9a1a9906418bcabe5", + "url": "https://sepolia.infura.io/v3/a32aa2ace9704ee9a1a9906418bcabe5", "headers": { "content-type": ["application/json"], "accept": ["*/*"], diff --git a/src/types/index.ts b/src/types/index.ts index 4d1631d0..972b7d02 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -130,7 +130,7 @@ export const UnsSupportedNetwork = StringUnion( export type UnsSupportedNetwork = typeof UnsSupportedNetwork.type; -export const EnsSupportedNetwork = StringUnion('mainnet', 'goerli'); +export const EnsSupportedNetwork = StringUnion('mainnet', 'sepolia'); export const ZnsSupportedNetwork = StringUnion('mainnet', 'testnet'); diff --git a/src/types/publicTypes.ts b/src/types/publicTypes.ts index 3d2cfa48..8fe924f3 100644 --- a/src/types/publicTypes.ts +++ b/src/types/publicTypes.ts @@ -156,7 +156,6 @@ export interface EthersProvider { getLogs(filter: EventFilter): Promise; } -export const UDApiDefaultUrl = 'https://unstoppabledomains.com/api/v1'; export type NamehashOptions = { readonly format?: 'dec' | 'hex'; readonly prefix?: boolean; @@ -279,7 +278,7 @@ export interface DomainMetadata extends Erc721Metadata { export enum BlockchainType { ETH = 'ETH', - MATIC = 'MATIC', + POL = 'POL', ZIL = 'ZIL', BASE = 'BASE', } diff --git a/src/utils/Networking.ts b/src/utils/Networking.ts index 3ebd5d3b..1822b89f 100644 --- a/src/utils/Networking.ts +++ b/src/utils/Networking.ts @@ -3,7 +3,11 @@ import crossFetch from 'cross-fetch'; export default class Networking { static async fetch( url: string, - options: {body?: string; headers?: Record; method?: string}, + options?: { + body?: string; + headers?: Record; + method?: string; + }, ): Promise { return crossFetch(url, options); } diff --git a/src/utils/Tlds.ts b/src/utils/Tlds.ts new file mode 100644 index 00000000..ecf51c66 --- /dev/null +++ b/src/utils/Tlds.ts @@ -0,0 +1,42 @@ +import type {BlockchainType} from '../types/publicTypes'; +import Networking from './Networking'; + +type TldsMeta = Record< + string, + { + namingService: 'UNS' | 'ENS' | 'ZNS' | 'DNS'; + registrationBlockchain: BlockchainType; + } +>; + +export default class Tlds { + private static supportedTlds: string[]; + private static tldsMeta: TldsMeta; + + private static async loadSupportedTldsData() { + try { + const res = await Networking.fetch( + 'https://api.unstoppabledomains.com/resolve/supported_tlds', + ); + const data: {tlds: string[]; meta: TldsMeta} = await res.json(); + Tlds.supportedTlds = data.tlds; + Tlds.tldsMeta = data.meta; + } catch (error) { + throw new Error(`Failed to load supported TLDs data: ${error}`); + } + } + + public static async getSupportedTlds(): Promise> { + if (!Tlds.supportedTlds) { + await Tlds.loadSupportedTldsData(); + } + return Tlds.supportedTlds; + } + + public static async getTldsMeta(): Promise> { + if (!Tlds.tldsMeta) { + await Tlds.loadSupportedTldsData(); + } + return Tlds.tldsMeta; + } +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 0e5ce080..4cf06b52 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,6 +1,12 @@ -import {CryptoRecords, NamingServiceName} from '../types/publicTypes'; +import { + BlockchainType, + CryptoRecords, + NamingServiceName, +} from '../types/publicTypes'; import {NullAddresses} from '../types'; import {UnsSupportedNetwork} from '../types'; +import Tlds from './Tlds'; +import ResolutionError, {ResolutionErrorCode} from '../errors/resolutionError'; type Providers = 'infura' | 'alchemy'; type NetworkSignedLinkURLs = Record; @@ -14,8 +20,8 @@ const ProviderURLMap: Record = { 'base-sepolia': 'https://base-sepolia.infura.io/v3/', }, alchemy: { - mainnet: 'https://eth-mainnet.alchemyapi.io/v2/', - sepolia: 'https://eth-sepolia.alchemyapi.io/v2/', + mainnet: 'https://eth-mainnet.g.alchemy.com/v2/', + sepolia: 'https://eth-sepolia.g.alchemy.com/v2/', 'polygon-mainnet': 'https://polygon-mainnet.g.alchemy.com/v2/', 'polygon-amoy': 'https://polygon-amoy.g.alchemy.com/v2/', 'base-mainnet': 'https://base-mainnet.g.alchemy.com/v2/', @@ -80,30 +86,49 @@ export function constructRecords( return records; } -// TODO: Replace this with supported_tlds calls -export const domainExtensionToNamingServiceName = { - crypto: NamingServiceName.UNS, - zil: NamingServiceName.ZNS, - eth: NamingServiceName.ENS, - luxe: NamingServiceName.ENS, - xyz: NamingServiceName.ENS, - kred: NamingServiceName.ENS, - reverse: NamingServiceName.ENS, - udtest: NamingServiceName.UNS_BASE, -}; +const EnsTlds = ['eth', 'luxe', 'xyz', 'kred', 'reverse']; -export const findNamingServiceName = ( +export const findNamingServiceName = async ( domain: string, -): NamingServiceName | '' => { - const extension = domain.split('.').pop(); - - if (!extension) { - return ''; - } else if (extension in domainExtensionToNamingServiceName) { - return domainExtensionToNamingServiceName[extension]; - } else { - return domainExtensionToNamingServiceName.crypto; +): Promise => { + const tld = domain.split('.').pop(); + + if (!tld) { + return null; + } + + if (EnsTlds.includes(tld)) { + return NamingServiceName.ENS; } + + const tldsMeta = await Tlds.getTldsMeta(); + + if (!tldsMeta) { + throw new ResolutionError(ResolutionErrorCode.ServiceProviderError, { + providerMessage: + 'TLD meta is not available. Possibly failed to load supported TLDs data', + }); + } + + if (tld in tldsMeta) { + const {namingService, registrationBlockchain} = tldsMeta[tld]; + switch (namingService) { + case 'UNS': { + switch (registrationBlockchain) { + case BlockchainType.BASE: + return NamingServiceName.UNS_BASE; + default: + return NamingServiceName.UNS; + } + } + case 'ENS': + return NamingServiceName.ENS; + case 'ZNS': + return NamingServiceName.ZNS; + } + } + + return null; }; export const EthereumNetworks = { From d3705756af88a3c9d0b6533fee915f4843a433f5 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 2 Oct 2024 11:20:44 -0400 Subject: [PATCH 4/8] test: fix test --- src/tests/Ens.test.ts | 10 +- src/tests/Resolution.test.ts | 114 ++++++++------- src/tests/UdApi.test.ts | 30 ++-- src/tests/Uns.test.ts | 25 ++-- src/tests/UnsInternal.test.ts | 9 +- src/tests/Zns.test.ts | 11 +- src/tests/helpers.ts | 5 + src/tests/providerMockData.ts | 10 +- src/tests/testData/mockData.json | 232 +++++++++++++++++++++++++++++++ 9 files changed, 362 insertions(+), 84 deletions(-) diff --git a/src/tests/Ens.test.ts b/src/tests/Ens.test.ts index 4d006b72..d033f518 100644 --- a/src/tests/Ens.test.ts +++ b/src/tests/Ens.test.ts @@ -8,10 +8,10 @@ import { getProtocolLinkFromEnv, ProviderProtocol, skipItInLive, + ETH_L1_TESTNET_NAME, } from './helpers'; import Ens from '../Ens'; - -const ETH_L1_TESTNET_NAME = 'sepolia'; +import {EthereumNetworks} from '../utils'; let resolution: Resolution; let ens: Ens; @@ -38,14 +38,14 @@ describe('ENS', () => { expect(ens.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, NamingServiceName.ENS), ); - expect(ens.network).toEqual(5); + expect(ens.network).toEqual(EthereumNetworks[ETH_L1_TESTNET_NAME]); }); it('resolves .eth name using blockchain', async () => { expect(ens.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, NamingServiceName.ENS), ); - expect(ens.network).toEqual(5); + expect(ens.network).toEqual(EthereumNetworks[ETH_L1_TESTNET_NAME]); const eyes = mockAsyncMethods(ens, { resolver: '0x5FfC014343cd971B7eb70732021E26C35B744cc4', @@ -148,7 +148,7 @@ describe('ENS', () => { }); it('checks normalizeSource ens (object)', async () => { - expect(ens.network).toBe(5); + expect(ens.network).toBe(EthereumNetworks[ETH_L1_TESTNET_NAME]); expect(ens.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, NamingServiceName.ENS), ); diff --git a/src/tests/Resolution.test.ts b/src/tests/Resolution.test.ts index 0b1a9339..d907c059 100644 --- a/src/tests/Resolution.test.ts +++ b/src/tests/Resolution.test.ts @@ -32,6 +32,10 @@ import { WalletDomainLayerTwoWithAllRecords, WalletDomainOnBothLayers, SubdomainLayerTwo, + ETH_L1_TESTNET_NAME, + POL_L2_TESTNET_NAME, + mockAPICalls, + RESOLUTION_SERVICE_BASE_URL, } from './helpers'; import {RpcProviderTestCases} from './providerMockData'; import fetch, {FetchError} from 'node-fetch'; @@ -48,49 +52,51 @@ import {Eip1993Factories as Eip1193Factories} from '../utils/Eip1993Factories'; import UnsConfig from '../config/uns-config.json'; import {NullAddress} from '../types'; import Networking from '../utils/Networking'; -import {findNamingServiceName} from '../utils'; +import {EthereumNetworks, findNamingServiceName} from '../utils'; let resolution: Resolution; let uns: Uns; let zns: Zns; let ens: Ens; -const ETH_L1_TESTNET_NAME = 'sepolia'; -const POL_L2_TESTNET_NAME = 'polygon-amoy'; - -beforeEach(() => { - nock.cleanAll(); - jest.restoreAllMocks(); - resolution = new Resolution({ - sourceConfig: { - uns: { - locations: { - Layer1: { - url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - network: ETH_L1_TESTNET_NAME, - }, - Layer2: { - url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - network: POL_L2_TESTNET_NAME, +describe('Resolution', () => { + beforeEach(() => { + nock.cleanAll(); + jest.restoreAllMocks(); + resolution = new Resolution({ + sourceConfig: { + uns: { + locations: { + Layer1: { + url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), + network: ETH_L1_TESTNET_NAME, + }, + Layer2: { + url: getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), + network: POL_L2_TESTNET_NAME, + }, }, }, + ens: { + url: getProtocolLinkFromEnv( + ProviderProtocol.http, + NamingServiceName.ENS, + ), + network: ETH_L1_TESTNET_NAME, + }, + zns: {network: 'testnet'}, }, - ens: { - url: getProtocolLinkFromEnv( - ProviderProtocol.http, - NamingServiceName.ENS, - ), - network: ETH_L1_TESTNET_NAME, - }, - zns: {network: 'testnet'}, - }, + }); + uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; + zns = resolution.serviceMap[NamingServiceName.ZNS].native as Zns; + ens = resolution.serviceMap[NamingServiceName.ENS].native as Ens; + + mockAPICalls( + 'resolution_service_supported_tlds', + RESOLUTION_SERVICE_BASE_URL, + ); }); - uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; - zns = resolution.serviceMap[NamingServiceName.ZNS].native as Zns; - ens = resolution.serviceMap[NamingServiceName.ENS].native as Ens; -}); -describe('Resolution', () => { describe('constructor', () => { it(`should allow to configure with api key`, () => { const resolution = new Resolution({ @@ -105,6 +111,7 @@ describe('Resolution', () => { describe('.Basic setup', () => { it('should work with autonetwork url configuration', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); const l1Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'); // mocking getNetworkConfigs because no access to inner provider.request @@ -152,7 +159,7 @@ describe('Resolution', () => { ).toBe(POL_L2_TESTNET_NAME); expect( (resolution.serviceMap[NamingServiceName.ENS].native as Ens).network, - ).toBe(5); + ).toBe(l1NetworkId); }); it('should not work with invalid proxyReader configuration #1', async () => { @@ -1251,40 +1258,44 @@ describe('Resolution', () => { }); it('should return cns mainnet registry address #1', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; const spies = mockAsyncMethods(uns, { registryAddress: - UnsConfig.networks[5].contracts.CNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.CNSRegistry.address, }); const registryAddress = await resolution.registryAddress( 'udtestdev-crewe.crypto', ); expectSpyToBeCalled(spies); expect(registryAddress).toBe( - UnsConfig.networks[5].contracts.CNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.CNSRegistry.address, ); }); it('should return uns mainnet registry address', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; const spies = mockAsyncMethods(uns, { registryAddress: - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, }); const registryAddress = await resolution.registryAddress( 'udtestdev-check.wallet', ); expectSpyToBeCalled(spies); expect(registryAddress).toBe( - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, ); }); it('should return uns l2 mainnet registry address if domain exists on both', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; + const l2NetworkId = EthereumNetworks[POL_L2_TESTNET_NAME]; const spies = mockAsyncMethods(uns.unsl1, { registryAddress: - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, }); const spies2 = mockAsyncMethods(uns.unsl2, { registryAddress: - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[l2NetworkId].contracts.UNSRegistry.address, }); const registryAddress = await resolution.registryAddress( WalletDomainOnBothLayers, @@ -1292,7 +1303,7 @@ describe('Resolution', () => { expectSpyToBeCalled(spies); expectSpyToBeCalled(spies2); expect(registryAddress).toBe( - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[l2NetworkId].contracts.UNSRegistry.address, ); }); }); @@ -1335,26 +1346,29 @@ describe('Resolution', () => { }); it('should return uns mainnet registry address', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; const spies = mockAsyncMethods(uns, { registryAddress: - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, }); const registryAddress = await resolution.registryAddress( 'udtestdev-check.wallet', ); expectSpyToBeCalled(spies); expect(registryAddress).toBe( - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, ); }); it('should return uns l2 mainnet registry address if domain exists on both', async () => { + const l1NetworkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; + const l2NetworkId = EthereumNetworks[POL_L2_TESTNET_NAME]; const spies = mockAsyncMethods(uns.unsl1, { registryAddress: - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[l1NetworkId].contracts.UNSRegistry.address, }); const spies2 = mockAsyncMethods(uns.unsl2, { registryAddress: - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[l2NetworkId].contracts.UNSRegistry.address, }); const registryAddress = await resolution.registryAddress( WalletDomainOnBothLayers, @@ -1362,7 +1376,7 @@ describe('Resolution', () => { expectSpyToBeCalled(spies); expectSpyToBeCalled(spies2); expect(registryAddress).toBe( - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[l2NetworkId].contracts.UNSRegistry.address, ); }); }); @@ -1770,7 +1784,7 @@ describe('Resolution', () => { expect(location['udtestdev-check.wallet']).toEqual({ registryAddress: '0x7fb83000B8eD59D3eAD22f0D584Df3a85fBC0086', resolverAddress: '0x7fb83000B8eD59D3eAD22f0D584Df3a85fBC0086', - networkId: 5, + networkId: EthereumNetworks[ETH_L1_TESTNET_NAME], blockchain: BlockchainType.ETH, ownerAddress: '0x0e43F36e4B986dfbE1a75cacfA60cA2bD44Ae962', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -1781,7 +1795,7 @@ describe('Resolution', () => { expect(location['brad.crypto']).toEqual({ registryAddress: '0xAad76bea7CFEc82927239415BB18D2e93518ecBB', resolverAddress: '0x95AE1515367aa64C462c71e87157771165B1287A', - networkId: 5, + networkId: EthereumNetworks[ETH_L1_TESTNET_NAME], blockchain: BlockchainType.ETH, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -1792,7 +1806,7 @@ describe('Resolution', () => { expect(location['udtestdev-test-l2-domain-784391.wallet']).toEqual({ registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', - networkId: 80001, + networkId: EthereumNetworks[POL_L2_TESTNET_NAME], blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -1805,7 +1819,7 @@ describe('Resolution', () => { ).toEqual({ registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', - networkId: 80001, + networkId: EthereumNetworks[POL_L2_TESTNET_NAME], blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -1820,7 +1834,7 @@ describe('Resolution', () => { expect(location['uns-devtest-testnet-domain.zil']).toEqual({ registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', - networkId: 80001, + networkId: EthereumNetworks[POL_L2_TESTNET_NAME], blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( diff --git a/src/tests/UdApi.test.ts b/src/tests/UdApi.test.ts index 19ce7967..711a22dd 100644 --- a/src/tests/UdApi.test.ts +++ b/src/tests/UdApi.test.ts @@ -9,6 +9,7 @@ import { expectSpyToBeCalled, CryptoDomainWithTwitterVerification, expectResolutionErrorCode, + RESOLUTION_SERVICE_BASE_URL, } from './helpers'; import {NamingServiceName} from '../types/publicTypes'; import {ResolutionErrorCode} from '../errors/resolutionError'; @@ -16,20 +17,25 @@ import {ResolutionErrorCode} from '../errors/resolutionError'; let resolution: Resolution; let udApi: UdApi; -beforeEach(() => { - nock.cleanAll(); - jest.restoreAllMocks(); - resolution = new Resolution({ - sourceConfig: { - zns: {api: true}, - uns: {api: true}, - ens: {api: true}, - }, +describe('Unstoppable API', () => { + beforeEach(() => { + nock.cleanAll(); + jest.restoreAllMocks(); + resolution = new Resolution({ + sourceConfig: { + zns: {api: true}, + uns: {api: true}, + ens: {api: true}, + }, + }); + udApi = resolution.serviceMap[NamingServiceName.UNS] + .usedServices[0] as UdApi; + mockAPICalls( + 'resolution_service_supported_tlds', + RESOLUTION_SERVICE_BASE_URL, + ); }); - udApi = resolution.serviceMap[NamingServiceName.UNS].usedServices[0] as UdApi; -}); -describe('Unstoppable API', () => { it('should throw error for registryAddress', async () => { await expectResolutionErrorCode( () => resolution.registryAddress('test.crypto'), diff --git a/src/tests/Uns.test.ts b/src/tests/Uns.test.ts index 7ea9c85e..693426dd 100644 --- a/src/tests/Uns.test.ts +++ b/src/tests/Uns.test.ts @@ -18,6 +18,9 @@ import { mockAsyncMethod, ZilDomainWithAllRecords, ZilDomainWithNoResolver, + RESOLUTION_SERVICE_BASE_URL, + ETH_L1_TESTNET_NAME, + POL_L2_TESTNET_NAME, } from './helpers'; import FetchProvider from '../FetchProvider'; import {NamingServiceName, UnsLocation} from '../types/publicTypes'; @@ -29,9 +32,7 @@ import liveData from './testData/liveData.json'; import UnsConfig from '../config/uns-config.json'; import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash'; import Zns from '../Zns'; - -const ETH_L1_TESTNET_NAME = 'sepolia'; -const POL_L2_TESTNET_NAME = 'polygon-amoy'; +import {EthereumNetworks} from '../utils'; describe('UNS', () => { describe('constructor', () => { @@ -164,6 +165,10 @@ describe('UNS', () => { }); uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; zns = resolution.serviceMap[NamingServiceName.ZNS].native as Zns; + mockAPICalls( + 'resolution_service_supported_tlds', + RESOLUTION_SERVICE_BASE_URL, + ); }); afterEach(() => { @@ -1231,38 +1236,40 @@ describe('UNS', () => { }); it('should return uns l2 registry address', async () => { - mockAsyncMethod(uns.unsl1.readerContract, 'call', (params) => + const networkId = EthereumNetworks[POL_L2_TESTNET_NAME]; + mockAsyncMethod(uns.unsl1.readerContract, 'call', () => Promise.resolve(), ); - mockAsyncMethod(uns.unsl2.readerContract, 'call', (params) => + mockAsyncMethod(uns.unsl2.readerContract, 'call', () => Promise.resolve([ - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[networkId].contracts.UNSRegistry.address, ]), ); const registryAddress = await uns.registryAddress( WalletDomainLayerTwoWithAllRecords, ); expect(registryAddress).toBe( - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[networkId].contracts.UNSRegistry.address, ); }); skipItInLive( 'should return uns l2 registry address for a .zil domain', async () => { + const networkId = EthereumNetworks[POL_L2_TESTNET_NAME]; const l1Spy = mockAsyncMethod( uns.unsl1.readerContract, 'call', undefined, ); const l2Spy = mockAsyncMethod(uns.unsl2.readerContract, 'call', [ - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[networkId].contracts.UNSRegistry.address, ]); const registryAddress = await resolution.registryAddress( WalletDomainLayerTwoWithAllRecords, ); expect(registryAddress).toBe( - UnsConfig.networks[80001].contracts.UNSRegistry.address, + UnsConfig.networks[networkId].contracts.UNSRegistry.address, ); expectSpyToBeCalled([l1Spy, l2Spy]); }, diff --git a/src/tests/UnsInternal.test.ts b/src/tests/UnsInternal.test.ts index 2e5173d5..a3438cf6 100644 --- a/src/tests/UnsInternal.test.ts +++ b/src/tests/UnsInternal.test.ts @@ -10,6 +10,8 @@ import { ProviderProtocol, WalletDomainOnBothLayers, skipItInLive, + ETH_L1_TESTNET_NAME, + POL_L2_TESTNET_NAME, } from './helpers'; import {BlockchainType, UnsLocation} from '../types/publicTypes'; import { @@ -20,9 +22,6 @@ import {ResolutionError, ResolutionErrorCode} from '../errors/resolutionError'; import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash'; import Networking from '../utils/Networking'; -const ETH_L1_TESTNET_NAME = 'sepolia'; -const POL_L2_TESTNET_NAME = 'polygon-amoy'; - let unsInternalL1: UnsInternal; let unsInternalL2: UnsInternal; @@ -314,6 +313,10 @@ describe('UnsInternal', () => { }); it('should return true for tld exists', async () => { + console.log( + 'heyhey', + getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), + ); mockAPICalls( 'uns_domain_exists_test', getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), diff --git a/src/tests/Zns.test.ts b/src/tests/Zns.test.ts index 0aa6e0e3..aef87601 100644 --- a/src/tests/Zns.test.ts +++ b/src/tests/Zns.test.ts @@ -7,6 +7,10 @@ import { expectResolutionErrorCode, mockAsyncMethods, expectConfigurationErrorCode, + mockAPICalls, + RESOLUTION_SERVICE_BASE_URL, + ETH_L1_TESTNET_NAME, + POL_L2_TESTNET_NAME, } from './helpers'; import {NullAddress} from '../types'; import {NamingServiceName} from '../types/publicTypes'; @@ -15,9 +19,6 @@ import {ConfigurationErrorCode} from '../errors/configurationError'; import Uns from '../Uns'; import ResolutionError from '../errors/resolutionError'; -const ETH_L1_TESTNET_NAME = 'sepolia'; -const POL_L2_TESTNET_NAME = 'polygon-amoy'; - let resolution: Resolution; let zns: Zns; let uns: Uns; @@ -46,6 +47,10 @@ describe('ZNS', () => { }); zns = resolution.serviceMap[NamingServiceName.ZNS].native as Zns; uns = resolution.serviceMap[NamingServiceName.UNS].native as Uns; + mockAPICalls( + 'resolution_service_supported_tlds', + RESOLUTION_SERVICE_BASE_URL, + ); }); describe('.NormalizeSource', () => { diff --git a/src/tests/helpers.ts b/src/tests/helpers.ts index 72654fe2..3e501e8a 100644 --- a/src/tests/helpers.ts +++ b/src/tests/helpers.ts @@ -11,6 +11,11 @@ import {NamingServiceName} from '../types/publicTypes'; export const ZilliqaUrl = 'https://api.zilliqa.com'; export const DefaultUrl = 'https://unstoppabledomains.com/api/v1'; +export const RESOLUTION_SERVICE_BASE_URL = + 'https://api.unstoppabledomains.com/resolve'; + +export const ETH_L1_TESTNET_NAME = 'sepolia'; +export const POL_L2_TESTNET_NAME = 'polygon-amoy'; export const CryptoDomainWithTwitterVerification = 'reseller-test-udtesting-052523593694.crypto'; diff --git a/src/tests/providerMockData.ts b/src/tests/providerMockData.ts index c902972f..c3b45fbe 100644 --- a/src/tests/providerMockData.ts +++ b/src/tests/providerMockData.ts @@ -1,8 +1,14 @@ import {RpcProviderTestCase} from '../types'; import UnsConfig from '../config/uns-config.json'; +import {EthereumNetworks} from '../utils'; +import {ETH_L1_TESTNET_NAME} from './helpers'; + +const networkId = EthereumNetworks[ETH_L1_TESTNET_NAME]; + const ProxyReaderAddress = - UnsConfig.networks[5].contracts.ProxyReader.address.toLowerCase(); -const ResolverAddress = UnsConfig.networks[5].contracts.Resolver.address; + UnsConfig.networks[networkId].contracts.ProxyReader.address.toLowerCase(); +const ResolverAddress = + UnsConfig.networks[networkId].contracts.Resolver.address; export const RpcProviderTestCases: RpcProviderTestCase = [ { diff --git a/src/tests/testData/mockData.json b/src/tests/testData/mockData.json index 15b7c26a..d185179d 100644 --- a/src/tests/testData/mockData.json +++ b/src/tests/testData/mockData.json @@ -632,5 +632,237 @@ "result": "0x0000000000000000000000000000000000000000000000000000000000000001" } } + ], + "resolution_service_supported_tlds": [ + { + "METHOD": "GET", + "REQUEST": "/supported_tlds", + "RESPONSE": { + "tlds": [ + "888", + "altimist", + "anime", + "austin", + "benji", + "binanceus", + "bitcoin", + "bitget", + "blockchain", + "ca", + "clay", + "com", + "crypto", + "dao", + "dfz", + "dream", + "eth", + "farms", + "go", + "hi", + "klever", + "kresus", + "kryptic", + "lfg", + "manga", + "metropolis", + "mumu", + "nft", + "pog", + "polygon", + "pudgy", + "pw", + "raiin", + "secret", + "smobler", + "stepn", + "tball", + "ubu", + "unstoppable", + "wallet", + "witg", + "wrkx", + "x", + "zil" + ], + "meta": { + "888": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "altimist": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "anime": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "austin": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "binanceus": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "bitcoin": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "bitget": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "blockchain": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "clay": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "crypto": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "dao": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "dfz": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "dream": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "farms": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "go": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "hi": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "klever": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "kresus": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "kryptic": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "lfg": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "manga": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "metropolis": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "mumu": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "nft": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "pog": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "polygon": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "pudgy": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "raiin": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "secret": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "stepn": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "tball": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "ubu": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "unstoppable": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "wallet": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "witg": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "wrkx": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "x": { + "namingService": "UNS", + "registrationBlockchain": "POL" + }, + "benji": { + "namingService": "UNS", + "registrationBlockchain": "BASE" + }, + "smobler": { + "namingService": "UNS", + "registrationBlockchain": "BASE" + }, + "zil": { + "namingService": "ZNS", + "registrationBlockchain": "POL" + }, + "ca": { + "namingService": "DNS", + "registrationBlockchain": "POL" + }, + "com": { + "namingService": "DNS", + "registrationBlockchain": "POL" + }, + "pw": { + "namingService": "DNS", + "registrationBlockchain": "POL" + }, + "eth": { + "namingService": "ENS", + "registrationBlockchain": "ETH" + } + } + } + } ] } From d8665a49a6f5d8295d5af988f3392b9723e8519f Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 15 Oct 2024 17:16:31 -0400 Subject: [PATCH 5/8] fix: test --- package.json | 3 +- src/Ens.ts | 4 +-- src/tests/Ens.test.ts | 37 +++++++++++------------ src/tests/Resolution.test.ts | 55 ++++++++++++++++++++++------------- src/tests/UnsInternal.test.ts | 4 --- 5 files changed, 56 insertions(+), 47 deletions(-) diff --git a/package.json b/package.json index 74e16067..9d2631f6 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,6 @@ }, "homepage": "https://github.com/unstoppabledomains/resolution.git#readme", "devDependencies": { - "@ethersproject/providers": "^5.4.5", "@types/bn.js": "^4.11.6", "@types/crypto-js": "^4.1.1", "@types/elliptic": "^6.4.13", @@ -76,6 +75,7 @@ "eslint": "^7.7.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-jest": "^24.1.0", + "ethers": "^6.13.4", "husky": "^6.0.0", "jest": "^27.0.4", "lint-staged": "11.0.0", @@ -104,7 +104,6 @@ "cross-fetch": "4.0.0", "crypto-js": "^4.1.1", "elliptic": "^6.5.4", - "ethereum-ens-network-map": "^1.0.2", "js-sha256": "^0.9.0", "js-sha3": "^0.8.0" }, diff --git a/src/Ens.ts b/src/Ens.ts index 31fdd22d..e4fbe164 100644 --- a/src/Ens.ts +++ b/src/Ens.ts @@ -1,7 +1,6 @@ import * as contentHash from 'content-hash'; import bip44Constants from 'bip44-constants'; import {formatsByCoinType} from '@ensdomains/address-encoder'; -import EnsNetworkMap from 'ethereum-ens-network-map'; import {default as ensInterface} from './contracts/ens/ens'; import {default as resolverInterface} from './contracts/ens/resolver'; import {default as nameWrapperInterface} from './contracts/ens/nameWrapper'; @@ -59,7 +58,8 @@ export default class Ens extends NamingService { this.proxyServiceApiKey = finalSource['proxyServiceApiKey']; const registryAddress = - finalSource['registryAddress'] || EnsNetworkMap[this.network]; + finalSource['registryAddress'] || + ensConfig.networks[this.network].contracts.ENSRegistry.address; this.registryContract = new EthereumContract( ensInterface, registryAddress, diff --git a/src/tests/Ens.test.ts b/src/tests/Ens.test.ts index d033f518..9de492a2 100644 --- a/src/tests/Ens.test.ts +++ b/src/tests/Ens.test.ts @@ -13,27 +13,28 @@ import { import Ens from '../Ens'; import {EthereumNetworks} from '../utils'; -let resolution: Resolution; -let ens: Ens; - -beforeEach(() => { - nock.cleanAll(); - jest.restoreAllMocks(); - resolution = new Resolution({ - sourceConfig: { - ens: { - url: getProtocolLinkFromEnv( - ProviderProtocol.http, - NamingServiceName.ENS, - ), - network: ETH_L1_TESTNET_NAME, +describe('ENS', () => { + let resolution: Resolution; + let ens: Ens; + + beforeEach(() => { + nock.cleanAll(); + jest.restoreAllMocks(); + + resolution = new Resolution({ + sourceConfig: { + ens: { + url: getProtocolLinkFromEnv( + ProviderProtocol.http, + NamingServiceName.ENS, + ), + network: ETH_L1_TESTNET_NAME, + }, }, - }, + }); + ens = resolution.serviceMap[NamingServiceName.ENS].native as Ens; }); - ens = resolution.serviceMap[NamingServiceName.ENS].native as Ens; -}); -describe('ENS', () => { it('allows ens network specified as string', async () => { expect(ens.url).toBe( getProtocolLinkFromEnv(ProviderProtocol.http, NamingServiceName.ENS), diff --git a/src/tests/Resolution.test.ts b/src/tests/Resolution.test.ts index d907c059..e3aedb47 100644 --- a/src/tests/Resolution.test.ts +++ b/src/tests/Resolution.test.ts @@ -12,7 +12,7 @@ import { NamingServiceName, Web3Version1Provider, } from '../types/publicTypes'; -import {JsonRpcProvider, InfuraProvider} from '@ethersproject/providers'; +import {ethers} from 'ethers'; import Web3HttpProvider from 'web3-providers-http'; import Web3WsProvider from 'web3-providers-ws'; import { @@ -291,7 +291,11 @@ describe('Resolution', () => { const l2Url = getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'); const l2Provider = new FetchProvider(UnsLocation.Layer2, l2Url); const spy = mockAsyncMethod(provider, 'request', '1'); - const spyTwo = mockAsyncMethod(l2Provider, 'request', '80001'); + const spyTwo = mockAsyncMethod( + l2Provider, + 'request', + EthereumNetworks[POL_L2_TESTNET_NAME], + ); const resolution = await Resolution.autoNetwork({ uns: { locations: {Layer1: {provider}, Layer2: {provider: l2Provider}}, @@ -533,9 +537,9 @@ describe('Resolution', () => { }); describe('.ServiceName', () => { - it('checks ens service name', () => { - const serviceName = findNamingServiceName('domain.eth'); - expect(serviceName).toBe('ENS'); + it('checks ens service name', async () => { + const serviceName = await findNamingServiceName('domain.eth'); + expect(serviceName).toBe(NamingServiceName.ENS); }); it('should resolve gundb chat id', async () => { @@ -966,21 +970,24 @@ describe('Resolution', () => { }); it('should work for ethers jsonrpc provider', async () => { - const l1Provider = new JsonRpcProvider( + const l1Provider = new ethers.JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), ETH_L1_TESTNET_NAME, ); - const l2Provider = new JsonRpcProvider( + const l2Provider = new ethers.JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - POL_L2_TESTNET_NAME, + 'matic-amoy', ); const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, + Layer1: { + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as any, + }, Layer2: { network: POL_L2_TESTNET_NAME, - provider: l2Provider, + provider: l2Provider as any, }, }, }, @@ -1050,21 +1057,24 @@ describe('Resolution', () => { }); it('should work for ethers jsonrpc provider', async () => { - const l1Provider = new JsonRpcProvider( + const l1Provider = new ethers.JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), ETH_L1_TESTNET_NAME, ); - const l2Provider = new JsonRpcProvider( + const l2Provider = new ethers.JsonRpcProvider( getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL2'), - POL_L2_TESTNET_NAME, + 'matic-amoy', ); const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, + Layer1: { + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as any, + }, Layer2: { network: POL_L2_TESTNET_NAME, - provider: l2Provider, + provider: l2Provider as any, }, }, }, @@ -1084,12 +1094,12 @@ describe('Resolution', () => { }); it('should work with ethers default provider', async () => { - const l1Provider = new InfuraProvider( - ETH_L1_TESTNET_NAME, + const l1Provider = new ethers.InfuraProvider( + 'matic-amoy', '213fff28936343858ca9c5115eff1419', ); - const l2Provider = new InfuraProvider( - POL_L2_TESTNET_NAME, + const l2Provider = new ethers.InfuraProvider( + 'matic-amoy', 'a32aa2ace9704ee9a1a9906418bcabe5', ); @@ -1099,10 +1109,13 @@ describe('Resolution', () => { const resolution = Resolution.fromEthersProvider({ uns: { locations: { - Layer1: {network: ETH_L1_TESTNET_NAME, provider: l1Provider}, + Layer1: { + network: ETH_L1_TESTNET_NAME, + provider: l1Provider as any, + }, Layer2: { network: POL_L2_TESTNET_NAME, - provider: l2Provider, + provider: l2Provider as any, }, }, }, diff --git a/src/tests/UnsInternal.test.ts b/src/tests/UnsInternal.test.ts index a3438cf6..01b3749a 100644 --- a/src/tests/UnsInternal.test.ts +++ b/src/tests/UnsInternal.test.ts @@ -313,10 +313,6 @@ describe('UnsInternal', () => { }); it('should return true for tld exists', async () => { - console.log( - 'heyhey', - getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), - ); mockAPICalls( 'uns_domain_exists_test', getProtocolLinkFromEnv(ProviderProtocol.http, 'UNSL1'), From abd3c7220dd59a9d96c58b7092d85d0a42119f78 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 16 Oct 2024 02:06:05 -0400 Subject: [PATCH 6/8] fix: test --- src/tests/Uns.test.ts | 12 +++++-- src/tests/UnsInternal.test.ts | 9 ++--- src/tests/testData/mockData.json | 61 +++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/src/tests/Uns.test.ts b/src/tests/Uns.test.ts index 693426dd..01c95a00 100644 --- a/src/tests/Uns.test.ts +++ b/src/tests/Uns.test.ts @@ -1,3 +1,4 @@ +import nock from 'nock'; import Resolution from '../index'; import ResolutionError, {ResolutionErrorCode} from '../errors/resolutionError'; import {NullAddress} from '../types'; @@ -35,6 +36,11 @@ import Zns from '../Zns'; import {EthereumNetworks} from '../utils'; describe('UNS', () => { + beforeEach(() => { + nock.cleanAll(); + jest.restoreAllMocks(); + }); + describe('constructor', () => { it('should define the default uns contract', () => { const uns = new Uns({ @@ -1215,7 +1221,8 @@ describe('UNS', () => { 'udtestdev-265f8f.crypto', ); expect(registryAddress).toBe( - UnsConfig.networks[5].contracts.CNSRegistry.address, + UnsConfig.networks[EthereumNetworks[ETH_L1_TESTNET_NAME]].contracts + .CNSRegistry.address, ); }); @@ -1231,7 +1238,8 @@ describe('UNS', () => { ); const registryAddress = await uns.registryAddress('some-domain.888'); expect(registryAddress).toBe( - UnsConfig.networks[5].contracts.UNSRegistry.address, + UnsConfig.networks[EthereumNetworks[ETH_L1_TESTNET_NAME]].contracts + .UNSRegistry.address, ); }); diff --git a/src/tests/UnsInternal.test.ts b/src/tests/UnsInternal.test.ts index 01b3749a..1c61a200 100644 --- a/src/tests/UnsInternal.test.ts +++ b/src/tests/UnsInternal.test.ts @@ -21,6 +21,7 @@ import { import {ResolutionError, ResolutionErrorCode} from '../errors/resolutionError'; import {eip137Namehash, fromHexStringToDecimals} from '../utils/namehash'; import Networking from '../utils/Networking'; +import {EthereumNetworks} from '../utils'; let unsInternalL1: UnsInternal; let unsInternalL2: UnsInternal; @@ -364,7 +365,7 @@ describe('UnsInternal', () => { expect(location['udtestdev-check.wallet']).toEqual({ registryAddress: '0x070e83FCed225184E67c86302493ffFCDB953f71', resolverAddress: '0x070e83FCed225184E67c86302493ffFCDB953f71', - networkId: 5, + networkId: EthereumNetworks[ETH_L1_TESTNET_NAME], blockchain: BlockchainType.ETH, ownerAddress: '0x0e43F36e4B986dfbE1a75cacfA60cA2bD44Ae962', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -375,7 +376,7 @@ describe('UnsInternal', () => { expect(location['brad.crypto']).toEqual({ registryAddress: '0x801452cFAC27e79a11c6b185986fdE09e8637589', resolverAddress: '0x95AE1515367aa64C462c71e87157771165B1287A', - networkId: 5, + networkId: EthereumNetworks[ETH_L1_TESTNET_NAME], blockchain: BlockchainType.ETH, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -400,7 +401,7 @@ describe('UnsInternal', () => { expect(location['udtestdev-test-l2-domain-784391.wallet']).toEqual({ registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', - networkId: 80001, + networkId: EthereumNetworks[POL_L2_TESTNET_NAME], blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( @@ -424,7 +425,7 @@ describe('UnsInternal', () => { expect(location['0xtestdomain-dev-test.wallet']).toEqual({ registryAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', resolverAddress: '0x2a93C52E7B6E7054870758e15A1446E769EdfB93', - networkId: 80001, + networkId: EthereumNetworks[POL_L2_TESTNET_NAME], blockchain: BlockchainType.POL, ownerAddress: '0x499dD6D875787869670900a2130223D85d4F6Aa7', blockchainProviderUrl: getProtocolLinkFromEnv( diff --git a/src/tests/testData/mockData.json b/src/tests/testData/mockData.json index d185179d..f121362e 100644 --- a/src/tests/testData/mockData.json +++ b/src/tests/testData/mockData.json @@ -81,7 +81,7 @@ "params": [ { "data": "0x4f558e7940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -101,7 +101,7 @@ "params": [ { "data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -142,7 +142,7 @@ "params": [ { "data": "0x4f558e79644d751c0e0112006e6d5d5d9234c9d3fae5a4646ff88a754d7fa1ed09794e94", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -164,7 +164,7 @@ "params": [ { "data": "0x4f558e794118ebbd893ecbb9f5d7a817c7d8039c1bd991b56ea243e2ae84d0a1b2c950a7", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -184,7 +184,7 @@ "params": [ { "data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -204,7 +204,7 @@ "params": [ { "data": "0x4f558e795c828ec285c0bf152a30a325b3963661a80cb87641d60920344caf04d4a0f31e", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -224,7 +224,7 @@ "params": [ { "data": "0x4f558e791e3f482b3363eb4710dae2cb2183128e272eafbe137f686851c1caea32502230", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -246,7 +246,7 @@ "params": [ { "data": "0x4f558e790f4a10a4f46c288cea365fcf45cccf0e9d901b945b9829ccdb54c10dc3cb7a6f", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -265,7 +265,8 @@ "method": "eth_call", "params": [ { - "data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000" + "data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334", + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -273,7 +274,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x0000000000000000000000000000000000000000000000000000000000000001" + "result": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, { @@ -323,7 +324,7 @@ "params": [ { "data": "0x4f558e79ed0afd72b0ca62d74b891a3c8a70d90f88b8c386f188fd455bc53f58f0079334", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -364,7 +365,7 @@ "params": [ { "data": "0xa81ce6f970702ccf2d95c2c8ff666f5e4dde0ed0e83d7d7407fff6f593d4e277aac0a40c", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -372,7 +373,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x000000000000000000000000801452cFAC27e79a11c6b185986fdE09e8637589" + "result": "0x000000000000000000000000Ab005176D74900A9c25fDA144e2f9f329A409166" } }, { @@ -384,7 +385,7 @@ "params": [ { "data": "0xa81ce6f98e3f4a48d9806259e049ea529c5be0c6433ff147ad781caf8014d196c388e1df", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -392,7 +393,7 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x000000000000000000000000070e83FCed225184E67c86302493ffFCDB953f71" + "result": "0x000000000000000000000000DD907B4d80B4a979fd77eE502580c55F2700292c" } }, { @@ -411,7 +412,27 @@ "RESPONSE": { "jsonrpc": "2.0", "id": 1, - "result": "0x000000000000000000000000070e83FCed225184E67c86302493ffFCDB953f71" + "result": "0x000000000000000000000000DD907B4d80B4a979fd77eE502580c55F2700292c" + } + }, + { + "METHOD": "POST", + "REQUEST": { + "jsonrpc": "2.0", + "id": "1", + "method": "eth_call", + "params": [ + { + "data": "0xa81ce6f98e3f4a48d9806259e049ea529c5be0c6433ff147ad781caf8014d196c388e1df", + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" + }, + "latest" + ] + }, + "RESPONSE": { + "jsonrpc": "2.0", + "id": 1, + "result": "0x0000000000000000000000000000000000000000000000000000000000000000" } }, { @@ -423,7 +444,7 @@ "params": [ { "data": "0xa81ce6f99319b0a972ee595115c81afa667fc78253ff07a82fc635b39d528c759c979ebc", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -445,7 +466,7 @@ "params": [ { "data": "0xac9650d800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000001a00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026000000000000000000000000000000000000000000000000000000000000000e4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000377b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f977b84a993689f621bf64877f62cf52f43fca88607c03d5d7bd72ca9a814446cf000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9756e4e998dbffd803c21d23b06cd855cdc7a4b57706c95964a37e24b47c10fc9000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000", - "to": "0x76007c52c73972a441afa1a0e1016b140ffde689" + "to": "0x880f7d37e9e4eb6868f92f4bb9c8c0995178fda9" }, "latest" ] @@ -467,7 +488,7 @@ "params": [ { "data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000060000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000c4933c051d000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000240920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b82ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f940920d1d24c83454d9d64e6666927f3abb97b3fd67c7e1bf43de5c2f4297f3b8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f92ebdfc3a84caa7244ea6c94a45ab1b8ffa60959949b72e435f172e03447784e500000000000000000000000000000000000000000000000000000000", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] @@ -489,7 +510,7 @@ "params": [ { "data": "0xac9650d8000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000a4933c051d0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab047314000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024a81ce6f9610f26481d76ff830345933bfa36b33bc6b18b795a5f2c6cffbe77d2ab04731400000000000000000000000000000000000000000000000000000000", - "to": "0xbd4674f11d512120dfc8bae5f84963d7419a5db2" + "to": "0x109e7315189e476ab21166955a0fb9be9b531bec" }, "latest" ] From 3ace94012e6f80e58d41c6f6f97bdcbc3b382638 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 22 Oct 2024 15:35:13 -0400 Subject: [PATCH 7/8] chore: optional blockchain type for uns source config --- src/Resolution.ts | 5 +++++ src/Uns.ts | 4 ++-- src/types/publicTypes.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Resolution.ts b/src/Resolution.ts index 4b34714a..57c85c43 100644 --- a/src/Resolution.ts +++ b/src/Resolution.ts @@ -22,6 +22,7 @@ import { Web3Version1Provider, ReverseResolutionOptions, UnsLocation, + BlockchainType, } from './types/publicTypes'; import ResolutionError, {ResolutionErrorCode} from './errors/resolutionError'; import DnsUtils from './utils/DnsUtils'; @@ -1200,11 +1201,13 @@ export default class Resolution { url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/eth/rpc`, network: 'mainnet', proxyServiceApiKey: config.apiKey, + blockchain: BlockchainType.ETH, }, Layer2: { url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/matic/rpc`, network: 'polygon-mainnet', proxyServiceApiKey: config.apiKey, + blockchain: BlockchainType.POL, }, }, }); @@ -1223,11 +1226,13 @@ export default class Resolution { url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/eth/rpc`, network: 'mainnet', proxyServiceApiKey: config.apiKey, + blockchain: BlockchainType.ETH, }, Layer2: { url: `${DEFAULT_UNS_PROXY_SERVICE_URL}/chains/base/rpc`, network: 'base-mainnet', proxyServiceApiKey: config.apiKey, + blockchain: BlockchainType.BASE, }, }, }); diff --git a/src/Uns.ts b/src/Uns.ts index f0459606..5ae8a16d 100644 --- a/src/Uns.ts +++ b/src/Uns.ts @@ -94,12 +94,12 @@ export default class Uns extends NamingService { this.unsl1 = new UnsInternal( UnsLocation.Layer1, source.locations.Layer1, - BlockchainType.ETH, + source.locations.Layer1.blockchain ?? BlockchainType.ETH, ); this.unsl2 = new UnsInternal( UnsLocation.Layer2, source.locations.Layer2, - BlockchainType.POL, + source.locations.Layer2.blockchain ?? BlockchainType.POL, ); } diff --git a/src/types/publicTypes.ts b/src/types/publicTypes.ts index 8fe924f3..714982d7 100644 --- a/src/types/publicTypes.ts +++ b/src/types/publicTypes.ts @@ -13,6 +13,7 @@ export type UnsLayerSource = NamingServiceSource & { network: string; proxyServiceApiKey?: string; proxyReaderAddress?: string; + blockchain?: BlockchainType; }; export type UnsSource = { From d495e81972cdd7dfc3fcefb8b5c9de13254c86ba Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 22 Oct 2024 15:44:43 -0400 Subject: [PATCH 8/8] chore: changelog update --- CHANGELOG.md | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 665d5d22..b2a9cf0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.3.0 + +- Support Base blockchain UNS domains resolution + ## 9.2.2 - Changed devDependencies to dependencies diff --git a/package.json b/package.json index 9d2631f6..f3b3d89a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "files": [ "build" ], - "author": "JohnnyJumper , Bogdan Gusiev , Braden Pezeshki , Matthew Gould ", + "author": "Unstoppable Domains", "repository": { "type": "git", "url": "https://github.com/unstoppabledomains/resolution.git"