Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to testnet env (8/26/24) #357

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
204 changes: 102 additions & 102 deletions deploy/999_faucet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,108 +22,108 @@ import { Environment, getEnvironment } from '@holographxyz/environment';
const FIVE_MILLION_TOKENS = '5000000000000000000000000'; // 5 million tokens denominated in wei

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
console.log(`Starting deploy script: ${path.basename(__filename)} 👇`);
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const deployer = await getDeployer(hre);
const deployerAddress = await deployer.signer.getAddress();
const network = networks[hre.networkName];
const environment: Environment = getEnvironment();
const salt = hre.deploymentSalt;
const holograph = await hre.ethers.getContract('Holograph', deployerAddress);
const hlgTokenAddress = await holograph.getUtilityToken();
const currentNetworkType: NetworkType = network.type;
if (currentNetworkType === NetworkType.testnet || currentNetworkType === NetworkType.local) {
// Only deploy faucet on develop or testnet environment
if (environment !== Environment.mainnet && environment) {
console.log(`Deploying faucet on ${currentNetworkType} network`);
const hlgContract = (await hre.ethers.getContract('HolographERC20', deployerAddress)).attach(hlgTokenAddress);
const futureFaucetAddress = await genesisDeriveFutureAddress(
hre,
salt,
'Faucet',
generateInitCode(['address', 'address'], [deployerAddress, hlgTokenAddress])
);
console.log('the future "Faucet" address is', futureFaucetAddress);
// Faucet
let faucetDeployedCode: string = await hre.provider.send('eth_getCode', [futureFaucetAddress, 'latest']);
if (faucetDeployedCode === '0x' || faucetDeployedCode === '') {
console.log('"Faucet" bytecode not found, need to deploy"');
let faucet = await genesisDeployHelper(
hre,
salt,
'Faucet',
generateInitCode(['address', 'address'], [deployerAddress, hlgTokenAddress]),
futureFaucetAddress
);
console.log(`Faucet deployed at: ${futureFaucetAddress}`);
const hlgContract = (await hre.ethers.getContract('HolographERC20', deployerAddress)).attach(hlgTokenAddress);
console.log(`Transferring 5M HLG to faucet`);
const transferTx = await MultisigAwareTx(
hre,
'HolographUtilityToken',
hlgContract,
await hlgContract.populateTransaction.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS), {
...(await txParams({
hre,
from: deployerAddress,
to: hlgContract,
gasLimit: (
await hre.ethers.provider.estimateGas(
await hlgContract.populateTransaction.transfer(
futureFaucetAddress,
BigNumber.from(FIVE_MILLION_TOKENS)
)
)
).mul(BigNumber.from('2')),
})),
})
);
await transferTx.wait();
} else {
console.log('"Faucet" is already deployed.');
}
console.log(`Checking if HLG reference is updated in Faucet contract`);
const faucetContract = await hre.ethers.getContract('Faucet', deployerAddress);
if ((await faucetContract.token()) !== hlgTokenAddress) {
console.log('HLG reference not updated in Faucet contract, updating now...');
const tx = await MultisigAwareTx(
hre,
'Faucet',
faucetContract,
await faucetContract.populateTransaction.setToken(hlgTokenAddress, {
...(await txParams({
hre,
from: deployerAddress,
to: faucetContract,
data: faucetContract.populateTransaction.setToken(hlgTokenAddress),
})),
})
);
await tx.wait();
console.log('Updated HLG reference');
console.log('Transferring 5M HLG to faucet');
const transferTx = await hlgContract.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS), {
...(await txParams({
hre,
from: deployerAddress,
to: hlgContract,
gasLimit: (
await hre.ethers.provider.estimateGas(
await hlgContract.populateTransaction.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS))
)
).mul(BigNumber.from('2')),
})),
});
const receipt = await transferTx.wait();
console.log(`Transfer tx hash: ${receipt.transactionHash}`);
} else {
console.log('HLG reference already updated in Faucet contract');
}
}
} else {
console.log(`Skipping faucet deployment on ${currentNetworkType} network`);
}
console.log(`Exiting script: ${__filename} ✅\n`);
// console.log(`Starting deploy script: ${path.basename(__filename)} 👇`);
// let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
// const deployer = await getDeployer(hre);
// const deployerAddress = await deployer.signer.getAddress();
// const network = networks[hre.networkName];
// const environment: Environment = getEnvironment();
// const salt = hre.deploymentSalt;
// const holograph = await hre.ethers.getContract('Holograph', deployerAddress);
// const hlgTokenAddress = await holograph.getUtilityToken();
// const currentNetworkType: NetworkType = network.type;
// if (currentNetworkType === NetworkType.testnet || currentNetworkType === NetworkType.local) {
// // Only deploy faucet on develop or testnet environment
// if (environment !== Environment.mainnet && environment) {
// console.log(`Deploying faucet on ${currentNetworkType} network`);
// const hlgContract = (await hre.ethers.getContract('HolographERC20', deployerAddress)).attach(hlgTokenAddress);
// const futureFaucetAddress = await genesisDeriveFutureAddress(
// hre,
// salt,
// 'Faucet',
// generateInitCode(['address', 'address'], [deployerAddress, hlgTokenAddress])
// );
// console.log('the future "Faucet" address is', futureFaucetAddress);
// // Faucet
// let faucetDeployedCode: string = await hre.provider.send('eth_getCode', [futureFaucetAddress, 'latest']);
// if (faucetDeployedCode === '0x' || faucetDeployedCode === '') {
// console.log('"Faucet" bytecode not found, need to deploy"');
// let faucet = await genesisDeployHelper(
// hre,
// salt,
// 'Faucet',
// generateInitCode(['address', 'address'], [deployerAddress, hlgTokenAddress]),
// futureFaucetAddress
// );
// console.log(`Faucet deployed at: ${futureFaucetAddress}`);
// const hlgContract = (await hre.ethers.getContract('HolographERC20', deployerAddress)).attach(hlgTokenAddress);
// console.log(`Transferring 5M HLG to faucet`);
// const transferTx = await MultisigAwareTx(
// hre,
// 'HolographUtilityToken',
// hlgContract,
// await hlgContract.populateTransaction.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS), {
// ...(await txParams({
// hre,
// from: deployerAddress,
// to: hlgContract,
// gasLimit: (
// await hre.ethers.provider.estimateGas(
// await hlgContract.populateTransaction.transfer(
// futureFaucetAddress,
// BigNumber.from(FIVE_MILLION_TOKENS)
// )
// )
// ).mul(BigNumber.from('2')),
// })),
// })
// );
// await transferTx.wait();
// } else {
// console.log('"Faucet" is already deployed.');
// }
// console.log(`Checking if HLG reference is updated in Faucet contract`);
// const faucetContract = await hre.ethers.getContract('Faucet', deployerAddress);
// if ((await faucetContract.token()) !== hlgTokenAddress) {
// console.log('HLG reference not updated in Faucet contract, updating now...');
// const tx = await MultisigAwareTx(
// hre,
// 'Faucet',
// faucetContract,
// await faucetContract.populateTransaction.setToken(hlgTokenAddress, {
// ...(await txParams({
// hre,
// from: deployerAddress,
// to: faucetContract,
// data: faucetContract.populateTransaction.setToken(hlgTokenAddress),
// })),
// })
// );
// await tx.wait();
// console.log('Updated HLG reference');
// console.log('Transferring 5M HLG to faucet');
// const transferTx = await hlgContract.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS), {
// ...(await txParams({
// hre,
// from: deployerAddress,
// to: hlgContract,
// gasLimit: (
// await hre.ethers.provider.estimateGas(
// await hlgContract.populateTransaction.transfer(futureFaucetAddress, BigNumber.from(FIVE_MILLION_TOKENS))
// )
// ).mul(BigNumber.from('2')),
// })),
// });
// const receipt = await transferTx.wait();
// console.log(`Transfer tx hash: ${receipt.transactionHash}`);
// } else {
// console.log('HLG reference already updated in Faucet contract');
// }
// }
// } else {
// console.log(`Skipping faucet deployment on ${currentNetworkType} network`);
// }
// console.log(`Exiting script: ${__filename} ✅\n`);
};

export default func;
Expand Down
Loading
Loading