import { ContractClass } from '.' ; export function getInitializerData ( Contract , args , initializer ? ) { if ( initializer === false ) { return '0x' ; } const allowNoInitialization = initializer === undefined && args . length === 0 ; initializer = initializer ?? 'initialize' ; const stub = new Contract ( '' ) ; if ( initializer in stub . contract . methods ) { return stub . contract . methods [ initializer ] ( ... args ) . encodeABI ( ) ; } else if ( allowNoInitialization ) { return '0x' ; } else { throw new Error ( `Contract ${ Contract . name } does not have a function \`${ initializer }\`` ) ; } }