Files
linea-monorepo/contracts/deploy/05_deploy_BridgedToken.ts
The Dark Jester 4405f315a9 [Chore] - standardise contract deploy logs (#460)
* standardise contract deploy logs

* apply standardization to hardhat deploy scripts

* Update contracts/common/helpers/deployments.ts

Co-authored-by: kyzooghost <73516204+kyzooghost@users.noreply.github.com>
Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>

* fix copy paste issues

* use refactored deployment logger

* add a lint space

---------

Signed-off-by: The Dark Jester <thedarkjester@users.noreply.github.com>
Co-authored-by: kyzooghost <73516204+kyzooghost@users.noreply.github.com>
2024-12-18 07:13:56 -08:00

54 lines
1.9 KiB
TypeScript

import { ethers, network, upgrades } from "hardhat";
import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { BridgedToken } from "../typechain-types";
import {
tryVerifyContract,
getDeployedContractAddress,
tryStoreAddress,
LogContractDeployment,
} from "../common/helpers";
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const { deployments } = hre;
const contractName = "BridgedToken";
const existingContractAddress = await getDeployedContractAddress(contractName, deployments);
const chainId = (await ethers.provider.getNetwork()).chainId;
console.log(`Current network's chainId is ${chainId}`);
if (existingContractAddress === undefined) {
console.log(`Deploying initial version, NB: the address will be saved if env SAVE_ADDRESS=true.`);
} else {
console.log(`Deploying new version, NB: ${existingContractAddress} will be overwritten if env SAVE_ADDRESS=true.`);
}
// Deploy beacon for bridged token
const BridgedToken = await ethers.getContractFactory(contractName);
const bridgedToken = (await upgrades.deployBeacon(BridgedToken)) as unknown as BridgedToken;
await LogContractDeployment(contractName, bridgedToken);
const bridgedTokenAddress = await bridgedToken.getAddress();
process.env.BRIDGED_TOKEN_ADDRESS = bridgedTokenAddress;
await tryStoreAddress(
hre.network.name,
contractName,
bridgedTokenAddress,
bridgedToken.deploymentTransaction()!.hash,
);
if (process.env.TOKEN_BRIDGE_L1 === "true") {
console.log(`L1 BridgedToken beacon deployed on ${network.name}, at address:`, bridgedTokenAddress);
} else {
console.log(`L2 BridgedToken beacon deployed on ${network.name}, at address:`, bridgedTokenAddress);
}
await tryVerifyContract(bridgedTokenAddress);
};
export default func;
func.tags = ["BridgedToken"];