MCPcopy Create free account
hub / github.com/api3dao/airnode / writeAddressToDeploymentsFile

Function writeAddressToDeploymentsFile

packages/airnode-examples/src/evm.ts:68–88  ·  view source on GitHub ↗
(
  artifactsFolderPath: string,
  address: string,
  chain: SameOrCrossChain
)

Source from the content-addressed store, hash-verified

66 * @param address
67 */
68export 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

Callers 2

deployContractFunction · 0.85
mainFunction · 0.85

Calls 2

readIntegrationInfoFunction · 0.90
removeExtensionFunction · 0.90

Tested by

no test coverage detected