forked from aragon/osx-plugin-template-hardhat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from aragon/develop
Compare to audit branch for new changes
- Loading branch information
Showing
31 changed files
with
6,046 additions
and
368 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
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 |
---|---|---|
|
@@ -25,3 +25,5 @@ package-lock.json | |
pnpm-lock.yaml | ||
yarn.lock | ||
extended-schema.ts | ||
|
||
deployments-zk |
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
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,31 @@ | ||
import {isLocal} from '../utils/helpers'; | ||
import { | ||
getLatestNetworkDeployment, | ||
getNetworkByNameOrAlias, | ||
} from '@aragon/osx-commons-configs'; | ||
import {HardhatRuntimeEnvironment} from 'hardhat/types'; | ||
|
||
export function getLatestContractAddress( | ||
contractName: string, | ||
hre: HardhatRuntimeEnvironment | ||
): string { | ||
const networkName = hre.network.name; | ||
|
||
const osxNetworkName = getNetworkByNameOrAlias(networkName); | ||
if (!osxNetworkName) { | ||
if (isLocal(hre)) { | ||
return ''; | ||
} | ||
throw new Error(`Failed to find network ${networkName}`); | ||
} | ||
|
||
const latestNetworkDeployment = getLatestNetworkDeployment( | ||
osxNetworkName.name | ||
); | ||
if (latestNetworkDeployment && contractName in latestNetworkDeployment) { | ||
// safe cast due to conditional above, but we return the fallback string anyhow | ||
const key = contractName as keyof typeof latestNetworkDeployment; | ||
return latestNetworkDeployment[key]?.address ?? ''; | ||
} | ||
return ''; | ||
} |
Oops, something went wrong.