diff --git a/.prettierignore b/.prettierignore index 900a74c2..6c05a035 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,6 +15,7 @@ imported generated */sdk/test/integration/*.test.ts !configs/src/deployments/ +!configs/src/test/unit/deployments/ # files *.env diff --git a/configs/CHANGELOG.md b/configs/CHANGELOG.md index 7110ab29..111a8864 100644 --- a/configs/CHANGELOG.md +++ b/configs/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v0.3.0 + +### Added + +- `getDaoEnsDomain` and `getPluginEnsDomain` functions. + ## v0.2.0 ### Added diff --git a/configs/package.json b/configs/package.json index 4ebf8e8a..fa92ad1b 100644 --- a/configs/package.json +++ b/configs/package.json @@ -1,7 +1,7 @@ { "name": "@aragon/osx-commons-configs", "author": "Aragon Association", - "version": "0.2.0", + "version": "0.3.0", "license": "AGPL-3.0-or-later", "typings": "dist/index.d.ts", "main": "dist/index.js", diff --git a/configs/src/deployments/ens.ts b/configs/src/deployments/ens.ts new file mode 100644 index 00000000..fa7b6dfa --- /dev/null +++ b/configs/src/deployments/ens.ts @@ -0,0 +1,14 @@ +import {SupportedNetworks} from '../networks'; +import {ENSNetworkDomain, ENSNetworkDomainsMap} from './types'; + +export const commonDomain: ENSNetworkDomain = { + daoEns: 'dao.eth', + pluginEns: 'plugin.dao.eth', +}; + +export const exceptionalDomains: ENSNetworkDomainsMap = { + [SupportedNetworks.SEPOLIA]: { + daoEns: 'aragon-dao.eth', + pluginEns: 'plugin.aragon-dao.eth', + }, +}; diff --git a/configs/src/deployments/getters.ts b/configs/src/deployments/getters.ts index 30432b52..998aaa0c 100644 --- a/configs/src/deployments/getters.ts +++ b/configs/src/deployments/getters.ts @@ -1,5 +1,6 @@ import {SupportedNetworks} from '../networks'; import {contracts} from './contracts'; +import {exceptionalDomains, commonDomain} from './ens'; import { NetworkDeployment, NetworkDeployments, @@ -50,3 +51,23 @@ export function getLatestNetworkDeployment( } return null; } + +export function getDaoEnsDomain( + networkName: SupportedNetworks +): string | undefined { + if (exceptionalDomains[networkName]) { + return exceptionalDomains[networkName]?.daoEns; + } else { + return commonDomain.daoEns; + } +} + +export function getPluginEnsDomain( + networkName: SupportedNetworks +): string | undefined { + if (exceptionalDomains[networkName]) { + return exceptionalDomains[networkName]?.pluginEns; + } else { + return commonDomain.pluginEns; + } +} diff --git a/configs/src/deployments/index.ts b/configs/src/deployments/index.ts index 98551508..d785305e 100644 --- a/configs/src/deployments/index.ts +++ b/configs/src/deployments/index.ts @@ -1,3 +1,4 @@ export * from './types'; export * from './getters'; export * from './contracts'; +export * from './ens'; diff --git a/configs/src/deployments/types.ts b/configs/src/deployments/types.ts index fae16a3d..4033916f 100644 --- a/configs/src/deployments/types.ts +++ b/configs/src/deployments/types.ts @@ -1,3 +1,5 @@ +import {SupportedNetworks} from '../networks/types'; + // the entries in this enum has to be in order from // oldest to newest so that getLatestNetworkVersion() works as expected export enum SupportedVersions { @@ -64,3 +66,12 @@ export enum ContractNames { TOKEN_VOTING_REPO_IMPLEMENTATION = 'TokenVotingRepoImplementation', ENS_REGISTRY = 'ENSRegistry', } + +export type ENSNetworkDomain = { + daoEns: string; + pluginEns: string; +}; + +export type ENSNetworkDomainsMap = { + [network in SupportedNetworks]?: ENSNetworkDomain; +}; diff --git a/configs/src/test/unit/deployments.test.ts b/configs/src/test/unit/deployments/deployments.test.ts similarity index 95% rename from configs/src/test/unit/deployments.test.ts rename to configs/src/test/unit/deployments/deployments.test.ts index 1faaa86b..6d9ad118 100644 --- a/configs/src/test/unit/deployments.test.ts +++ b/configs/src/test/unit/deployments/deployments.test.ts @@ -4,8 +4,8 @@ import { getLatestNetworkDeployment, getNetworkDeploymentForVersion, getNetworkDeployments, -} from '../../deployments'; -import {SupportedNetworks} from '../../networks'; +} from '../../../deployments'; +import {SupportedNetworks} from '../../../networks'; describe('Deployments', () => { describe('getNetworkDeployments', () => { diff --git a/configs/src/test/unit/deployments/ens.test.ts b/configs/src/test/unit/deployments/ens.test.ts new file mode 100644 index 00000000..ed1aacc0 --- /dev/null +++ b/configs/src/test/unit/deployments/ens.test.ts @@ -0,0 +1,54 @@ +import { + getDaoEnsDomain, + getPluginEnsDomain, + commonDomain, + exceptionalDomains, +} from '../../../deployments'; +import {SupportedNetworks} from '../../../networks'; + +describe('Domains', () => { + describe('getDaoEnsDomain', () => { + it('should return the correct dao ens', () => { + for (const network of Object.values(SupportedNetworks)) { + if (exceptionalDomains[network]) { + expect(getDaoEnsDomain(network)).toMatch( + exceptionalDomains[network]?.daoEns ?? '' + ); + } else { + expect(getDaoEnsDomain(network)).toMatch(commonDomain.daoEns); + } + } + }); + }); + describe('getPluginEnsDomain', () => { + it('should return the correct plugin ens', () => { + for (const network of Object.values(SupportedNetworks)) { + if (exceptionalDomains[network]) { + expect(getPluginEnsDomain(network)).toMatch( + exceptionalDomains[network]?.daoEns ?? '' + ); + } else { + expect(getPluginEnsDomain(network)).toMatch(commonDomain.pluginEns); + } + } + }); + }); + describe('add new network to exceptional domains', () => { + beforeEach(() => { + exceptionalDomains[SupportedNetworks.LOCAL] = { + daoEns: 'new-dao.eth', + pluginEns: 'plugin.new-dao.eth', + }; + }); + it('should return the new exceptional dao ens', () => { + expect(getDaoEnsDomain(SupportedNetworks.LOCAL)).toMatch( + exceptionalDomains[SupportedNetworks.LOCAL]?.daoEns ?? '' + ); + }); + it('should return the new exceptional plugin ens', () => { + expect(getPluginEnsDomain(SupportedNetworks.LOCAL)).toMatch( + exceptionalDomains[SupportedNetworks.LOCAL]?.pluginEns ?? '' + ); + }); + }); +});