Skip to content

Commit dd7113a

Browse files
committed
cli: fix cli deploy print bytecode hashes
1 parent 6a63a69 commit dd7113a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cli/network.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const getChainID = (): number => {
2929
return 4 // Only works for rinkeby right now
3030
}
3131

32-
const hash = (input: string): string => keccak256(`0x${input.replace(/^0x/, '')}`)
32+
export const hashHexString = (input: string): string => keccak256(`0x${input.replace(/^0x/, '')}`)
3333

3434
type ContractParam = string | BigNumber | number
3535
type DeployResult = {
@@ -61,7 +61,7 @@ export const isContractDeployed = async (
6161

6262
if (checkCreationCode) {
6363
const savedCreationCodeHash = addressEntry.creationCodeHash
64-
const creationCodeHash = hash(artifact.bytecode)
64+
const creationCodeHash = hashHexString(artifact.bytecode)
6565
if (!savedCreationCodeHash || savedCreationCodeHash !== creationCodeHash) {
6666
logger.warn(`creationCodeHash in our address book doesn't match ${name} artifacts`)
6767
logger.info(`${savedCreationCodeHash} !== ${creationCodeHash}`)
@@ -70,8 +70,8 @@ export const isContractDeployed = async (
7070
}
7171

7272
const savedRuntimeCodeHash = addressEntry.runtimeCodeHash
73-
const runtimeCodeHash = hash(await provider.getCode(address))
74-
if (runtimeCodeHash === hash('0x00') || runtimeCodeHash === hash('0x')) {
73+
const runtimeCodeHash = hashHexString(await provider.getCode(address))
74+
if (runtimeCodeHash === hashHexString('0x00') || runtimeCodeHash === hashHexString('0x')) {
7575
logger.warn('No runtimeCode exists at the address in our address book')
7676
return false
7777
}
@@ -199,10 +199,10 @@ export const deployContract = async (
199199
await sender.provider.waitForTransaction(txHash)
200200

201201
// Receipt
202-
const creationCodeHash = hash(factory.bytecode)
203-
const runtimeCodeHash = hash(await sender.provider.getCode(contract.address))
204-
logger.info('= CreationCodeHash: ', creationCodeHash)
205-
logger.info('= RuntimeCodeHash: ', runtimeCodeHash)
202+
const creationCodeHash = hashHexString(factory.bytecode)
203+
const runtimeCodeHash = hashHexString(await sender.provider.getCode(contract.address))
204+
logger.info(`= CreationCodeHash: ${creationCodeHash}`)
205+
logger.info(`= RuntimeCodeHash: ${runtimeCodeHash}`)
206206
logger.info(`${name} has been deployed to address: ${contract.address}`)
207207

208208
return { contract, creationCodeHash, runtimeCodeHash, txHash, libraries }
@@ -325,8 +325,8 @@ export const deployContractWithProxyAndSave = async (
325325
addressBook.setEntry(name, {
326326
address: proxy.address,
327327
initArgs: args.length === 0 ? undefined : args.map((e) => e.toString()),
328-
creationCodeHash: hash(artifact.bytecode),
329-
runtimeCodeHash: hash(await sender.provider.getCode(proxy.address)),
328+
creationCodeHash: hashHexString(artifact.bytecode),
329+
runtimeCodeHash: hashHexString(await sender.provider.getCode(proxy.address)),
330330
txHash: proxy.deployTransaction.hash,
331331
proxy: true,
332332
implementation: contractEntry,

0 commit comments

Comments
 (0)