@@ -29,7 +29,7 @@ export const getChainID = (): number => {
29
29
return 4 // Only works for rinkeby right now
30
30
}
31
31
32
- const hash = ( input : string ) : string => keccak256 ( `0x${ input . replace ( / ^ 0 x / , '' ) } ` )
32
+ export const hashHexString = ( input : string ) : string => keccak256 ( `0x${ input . replace ( / ^ 0 x / , '' ) } ` )
33
33
34
34
type ContractParam = string | BigNumber | number
35
35
type DeployResult = {
@@ -61,7 +61,7 @@ export const isContractDeployed = async (
61
61
62
62
if ( checkCreationCode ) {
63
63
const savedCreationCodeHash = addressEntry . creationCodeHash
64
- const creationCodeHash = hash ( artifact . bytecode )
64
+ const creationCodeHash = hashHexString ( artifact . bytecode )
65
65
if ( ! savedCreationCodeHash || savedCreationCodeHash !== creationCodeHash ) {
66
66
logger . warn ( `creationCodeHash in our address book doesn't match ${ name } artifacts` )
67
67
logger . info ( `${ savedCreationCodeHash } !== ${ creationCodeHash } ` )
@@ -70,8 +70,8 @@ export const isContractDeployed = async (
70
70
}
71
71
72
72
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' ) ) {
75
75
logger . warn ( 'No runtimeCode exists at the address in our address book' )
76
76
return false
77
77
}
@@ -199,10 +199,10 @@ export const deployContract = async (
199
199
await sender . provider . waitForTransaction ( txHash )
200
200
201
201
// 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 } ` )
206
206
logger . info ( `${ name } has been deployed to address: ${ contract . address } ` )
207
207
208
208
return { contract, creationCodeHash, runtimeCodeHash, txHash, libraries }
@@ -325,8 +325,8 @@ export const deployContractWithProxyAndSave = async (
325
325
addressBook . setEntry ( name , {
326
326
address : proxy . address ,
327
327
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 ) ) ,
330
330
txHash : proxy . deployTransaction . hash ,
331
331
proxy : true ,
332
332
implementation : contractEntry ,
0 commit comments