-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(configs): adds helper function for networks and deployments (#44)
* fix(configs): changes to be commonjs package feat(configs): improves typings for networks feat(configs): adds helper function for networks and deployments * chore(configs): applies formatting * deploy(configs): bumps version to 0.1.0 * fix(configs): typo in SupportedVerions * fix(configs): typo in NetworkDeploymnets docs(configs): adds more clarifying comments * fix(configs): corrects SupportedVersions enum keys * Add tests Add missing sepolia contract Add NetworksAliases enum Add CHANGELOG Add ContractNames enum Add exported `contracts` object Add `getNetworkAlias` function * fix comments * fix prettier * fix changelog * add generic tests * fix lint + * update contract names enum * update type with enum value * fix networkDeployment type --------- Co-authored-by: Jose Manuel Mariñas Bascoy <[email protected]>
- Loading branch information
1 parent
2de5fd2
commit 1b8ca59
Showing
14 changed files
with
2,795 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,4 @@ ignorePatterns: | |
- '.DS_Store' | ||
- .pnp.* | ||
- 'node_modules' | ||
- '*.config.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Aragon OSx Commons Configs | ||
|
||
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.1.0 | ||
|
||
### Added | ||
|
||
- Types for Deployments | ||
- `SupportedNetworks` enum | ||
- `SupportedAliases` enum | ||
- `SupportedVersions` enum | ||
- Typed deployments | ||
- `contracts` object with all contracts | ||
- `getNetworkAlias` function | ||
- `getNetworkNameFromAlias` function | ||
- `getNetworkDeployments` function | ||
- `getNetworkDeploymentForVersion` function | ||
- `getLatestNetworkDeployment` function | ||
- `getNetwork` function | ||
- `getNetworkByNameOrAlias` function | ||
- `getNetworkByAlias` function | ||
- `getNetworkNameByAlias` function | ||
- `getNetworkAlias` function | ||
|
||
## v0.0.2 | ||
|
||
### Added | ||
|
||
- Deployment JSON files for: | ||
- Mainnet | ||
- Goerli | ||
- Sepolia | ||
- Polygon | ||
- Mumbai | ||
- Base Mainnet | ||
- Base Goerli | ||
- Base Sepolia | ||
- Arbitrum | ||
- Arbitrum Sepolia | ||
- JSON file with the supported networks and the default rpcs, chainIds, and aliases on other services. | ||
- Typing for the Network Configs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['<rootDir>/dist/'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { | ||
NetworkDeployment, | ||
NetworkDeployments, | ||
SupportedNetworks, | ||
SupportedVersions, | ||
} from '../types'; | ||
import * as arbitrum from './arbitrum.json'; | ||
import * as arbitrumSepolia from './arbitrumSepolia.json'; | ||
import * as baseGoerli from './baseGoerli.json'; | ||
import * as baseMainnet from './baseMainnet.json'; | ||
import * as baseSepolia from './baseSepolia.json'; | ||
import * as goerli from './goerli.json'; | ||
import * as mainnet from './mainnet.json'; | ||
import * as mumbai from './mumbai.json'; | ||
import * as polygon from './polygon.json'; | ||
import * as sepolia from './sepolia.json'; | ||
|
||
const contracts: { | ||
[network in SupportedNetworks]: { | ||
[version in SupportedVersions]?: NetworkDeployment; | ||
}; | ||
} = { | ||
mainnet, | ||
goerli, | ||
sepolia, | ||
polygon, | ||
mumbai, | ||
baseMainnet, | ||
baseGoerli, | ||
baseSepolia, | ||
arbitrum, | ||
arbitrumSepolia, | ||
}; | ||
|
||
/** | ||
* Retrieves the network deployments based on the specified network. | ||
* | ||
* @param {SupportedNetworks} network - The network to retrieve the deployments for. | ||
* @return {NetworkDeployments} The network deployments for the specified network. | ||
*/ | ||
export function getNetworkDeployments( | ||
network: SupportedNetworks | ||
): NetworkDeployments { | ||
return contracts[network]; | ||
} | ||
|
||
/** | ||
* Retrieves the network deployment for a specific version. | ||
* | ||
* @param {SupportedNetworks} network - The network to retrieve the deployment for. | ||
* @param {SupportedVersions} version - The version of the deployment. | ||
* @return {NetworkDeployment | null} The network deployment for the specified version, or null if not found. | ||
*/ | ||
export function getNetworkDeploymentForVersion( | ||
network: SupportedNetworks, | ||
version: SupportedVersions | ||
): NetworkDeployment | null { | ||
return getNetworkDeployments(network)[version] || null; | ||
} | ||
|
||
/** | ||
* Retrieves the latest network deployment for the specified network. | ||
* | ||
* @param {SupportedNetworks} network - The network to retrieve the deployment for. | ||
* @return {NetworkDeployment | null} The latest network deployment, or null if not found. | ||
*/ | ||
export function getLatestNetworkDeployment( | ||
network: SupportedNetworks | ||
): NetworkDeployment | null { | ||
const versions = Object.values(SupportedVersions).reverse(); | ||
for (const version of versions) { | ||
const deployment = getNetworkDeploymentForVersion(network, version); | ||
if (deployment) { | ||
return deployment; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
export { | ||
contracts, | ||
mainnet, | ||
goerli, | ||
sepolia, | ||
polygon, | ||
mumbai, | ||
baseMainnet, | ||
baseGoerli, | ||
baseSepolia, | ||
arbitrum, | ||
arbitrumSepolia, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,3 @@ | ||
import * as arbitrum from './deployments/arbitrum.json'; | ||
import * as arbitrumSepolia from './deployments/arbitrumSepolia.json'; | ||
import * as baseGoerli from './deployments/baseGoerli.json'; | ||
import * as baseMainnet from './deployments/baseMainnet.json'; | ||
import * as baseSepolia from './deployments/baseSepolia.json'; | ||
import * as goerli from './deployments/goerli.json'; | ||
import * as mainnet from './deployments/mainnet.json'; | ||
import * as mumbai from './deployments/mumbai.json'; | ||
import * as polygon from './deployments/polygon.json'; | ||
import * as sepolia from './deployments/sepolia.json'; | ||
import * as networks from './networks.json'; | ||
import {NetworkConfigs} from './types'; | ||
|
||
export * from './networks'; | ||
export * from './types'; | ||
|
||
const networksTyped: NetworkConfigs = networks; | ||
|
||
export { | ||
networksTyped as networks, | ||
arbitrum, | ||
arbitrumSepolia, | ||
baseGoerli, | ||
baseMainnet, | ||
baseSepolia, | ||
goerli, | ||
mainnet, | ||
mumbai, | ||
polygon, | ||
sepolia, | ||
}; | ||
export * from './deployments/index'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.