( artifactsFolderPath: string, address: string, chain: SameOrCrossChain )
| 66 | * @param address |
| 67 | */ |
| 68 | export const writeAddressToDeploymentsFile = ( |
| 69 | artifactsFolderPath: string, |
| 70 | address: string, |
| 71 | chain: SameOrCrossChain |
| 72 | ) => { |
| 73 | // Make sure the deployments folder exist |
| 74 | const deploymentsPath = join(__dirname, '../deployments'); |
| 75 | if (!existsSync(deploymentsPath)) mkdirSync(deploymentsPath); |
| 76 | |
| 77 | // Try to load the existing deployments file for this network - we want to preserve deployments of other contracts |
| 78 | const network = |
| 79 | chain === SameOrCrossChain.cross ? readIntegrationInfo().crossChainNetwork! : readIntegrationInfo().network; |
| 80 | const deploymentPath = join(deploymentsPath, network + '.json'); |
| 81 | let deployment: any = {}; |
| 82 | if (existsSync(deploymentPath)) deployment = JSON.parse(readFileSync(deploymentPath).toString()); |
| 83 | |
| 84 | // The key name for this contract is the path of the artifact without the '.sol' extension |
| 85 | const deploymentName = removeExtension(artifactsFolderPath); |
| 86 | // Write down the address of deployed contract |
| 87 | writeFileSync(deploymentPath, JSON.stringify({ ...deployment, [deploymentName]: address }, null, 2)); |
| 88 | }; |
| 89 | |
| 90 | /** |
| 91 | * Deploys the contract specified by the path to the artifact and constructor arguments and writes the |
no test coverage detected