Skip to content

Commit

Permalink
Merge pull request #65 from aragon/OS-1024/add-in-osx-commons-used-do…
Browse files Browse the repository at this point in the history
…mains

feat: add in osx-commons used domains in osx
  • Loading branch information
clauBv23 authored Mar 7, 2024
2 parents a6f536f + a9e1f22 commit 76e99a1
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 3 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ imported
generated
*/sdk/test/integration/*.test.ts
!configs/src/deployments/
!configs/src/test/unit/deployments/

# files
*.env
Expand Down
6 changes: 6 additions & 0 deletions configs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion configs/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
14 changes: 14 additions & 0 deletions configs/src/deployments/ens.ts
Original file line number Diff line number Diff line change
@@ -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',
},
};
21 changes: 21 additions & 0 deletions configs/src/deployments/getters.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {SupportedNetworks} from '../networks';
import {contracts} from './contracts';
import {exceptionalDomains, commonDomain} from './ens';
import {
NetworkDeployment,
NetworkDeployments,
Expand Down Expand Up @@ -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;
}
}
1 change: 1 addition & 0 deletions configs/src/deployments/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './types';
export * from './getters';
export * from './contracts';
export * from './ens';
11 changes: 11 additions & 0 deletions configs/src/deployments/types.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
getLatestNetworkDeployment,
getNetworkDeploymentForVersion,
getNetworkDeployments,
} from '../../deployments';
import {SupportedNetworks} from '../../networks';
} from '../../../deployments';
import {SupportedNetworks} from '../../../networks';

describe('Deployments', () => {
describe('getNetworkDeployments', () => {
Expand Down
54 changes: 54 additions & 0 deletions configs/src/test/unit/deployments/ens.test.ts
Original file line number Diff line number Diff line change
@@ -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 ?? ''
);
});
});
});

0 comments on commit 76e99a1

Please sign in to comment.