Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
fix: use console stdout to return values
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiendan committed Jun 15, 2023
1 parent 9683a17 commit 6cbf872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
29 changes: 4 additions & 25 deletions scripts/deploy-topos-msg-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const main = async function (...args: string[]) {
const wallet = new Wallet(toposDeployerPrivateKey, provider)

const tokenDeployerAddress = await processContract(
'TokenDeployer',
wallet,
tokenDeployerJSON,
tokenDeployerSalt!,
Expand All @@ -67,7 +66,6 @@ const main = async function (...args: string[]) {
)

const toposCoreAddress = await processContract(
'ToposCore',
wallet,
toposCoreJSON,
toposCoreSalt!,
Expand All @@ -80,7 +78,6 @@ const main = async function (...args: string[]) {
[[wallet.address], 1] // TODO: Use a different admin address than ToposDeployer
)
const toposCoreProxyAddress = await processContract(
'ToposCoreProxy',
wallet,
toposCoreProxyJSON,
toposCoreProxySalt!,
Expand All @@ -89,7 +86,6 @@ const main = async function (...args: string[]) {
)

const erc20MessagingAddresss = await processContract(
'ERC20Messaging',
wallet,
erc20MessagingJSON,
erc20MessagingSalt!,
Expand All @@ -99,12 +95,12 @@ const main = async function (...args: string[]) {

setSubnetId(toposCoreProxyAddress, wallet, subnetId)

return `
console.log(`
export TOPOS_CORE_CONTRACT_ADDRESS=${toposCoreAddress}
export TOPOS_CORE_PROXY_CONTRACT_ADDRESS=${toposCoreProxyAddress}
export TOKEN_DEPLOYER_CONTRACT_ADDRESS=${tokenDeployerAddress}
export ERC20_MESSAGING_CONTRACT_ADDRESS=${erc20MessagingAddresss}
`
`)
}

const sanitizeHexString = function (hexString: string) {
Expand All @@ -125,15 +121,12 @@ const verifySalt = function (
}

const processContract = async function (
contractName: string,
wallet: Wallet,
contractJson: ContractOutputJSON,
salt: string,
args: Arg[] = [],
gasLimit: number | null = null
) {
console.info(`\nVerifying if ${contractName} is already deployed...`)

const predictedContractAddress = await predictContractConstant(
wallet,
contractJson,
Expand All @@ -151,14 +144,8 @@ const processContract = async function (
const thereIsCodeAtAddress = codeAtPredictedAddress !== '0x'

if (thereIsCodeAtAddress) {
console.info(
`${contractName} is already deployed! (${predictedContractAddress})`
)

return predictedContractAddress
} else {
console.info(`Deploying ${contractName} with constant address...`)

const newContractAddress = await deployContractConstant(
wallet,
contractJson,
Expand All @@ -172,10 +159,6 @@ const processContract = async function (
process.exit(1)
})

console.info(
`Successfully deployed ${contractName} at ${newContractAddress}\n`
)

return newContractAddress
}
}
Expand All @@ -185,8 +168,6 @@ const setSubnetId = async function (
wallet: Wallet,
subnetId: string
) {
console.info(`\nSetting subnetId on ToposCore via proxy`)

const toposCoreInterface = new Contract(
toposCoreProxyAddress,
toposCoreInterfaceJSON.abi,
Expand All @@ -211,10 +192,8 @@ const setSubnetId = async function (
console.error(error)
process.exit(1)
})
const networkSubnetId = await toposCoreInterface.networkSubnetId()
console.info(
`Successfully set ${networkSubnetId} subnetId on ToposCore via proxy\n`
)

await toposCoreInterface.networkSubnetId()
}

const args = process.argv.slice(2)
Expand Down
11 changes: 2 additions & 9 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,10 @@ const main = async function (..._args: Arg[]) {
args,
<number>gasLimit
)
.then((contract) => {
console.info(
`Successfully deployed ${
(<string>contractJsonPath).split('.json')[0]
} at ${contract.address}`
)
return contract.address
})
.then(({ address }) => address)
.catch(console.error)

return address
console.log(address)
}

const args = process.argv.slice(2)
Expand Down

0 comments on commit 6cbf872

Please sign in to comment.