diff --git a/bin/registro-verificar b/bin/registro-verificar index 23b90b1a11ffbddc8bd6560cbf8db6421ea5cc9a..ed2e286a8e8c629efa26e7bfd5694097cd13af62 100755 --- a/bin/registro-verificar +++ b/bin/registro-verificar @@ -17,7 +17,7 @@ var estimate; if ( myArgs.length < 2 || myArgs.length > 3 ) { - let myname = process.argv[1].replace(/^.*\//, '');; + let myname = process.argv[1].replace(/^.*\//, ''); console.error( "Wrong number of arguments."); console.error( "Usage: " + myname + " <account> <proof> [<privatekeypassword>]"); process.exit( 1 ); @@ -28,7 +28,9 @@ function findMatchingFile( needle, accountdir ) return new Promise( function(resolve, reject) { - needle = needle.toLowerCase(); + // strip leading '0x' from the needle, if present + // also lowercase the name + needle = needle.replace(/^0x/, '').toLowerCase(); let haystack = fs.readdirSync( accountdir, 'utf8' ); haystack.forEach( (filename) => { @@ -47,16 +49,13 @@ function findaccountfile( accountfile ) function( resolve, reject ) { // find account file - let accountdir; // is it actually just a file? if ( accountfile.includes('/') ) { resolve( accountfile ); return; } - // strip leading '0x' from the account name, if present - if ( accountfile.startsWith( '0x' ) ) - accountfile = accountfile.substring(2); + let accountdir; // if not a file, then look (only) at the most specific directory we have been told about. if ( process.env.KEYSTORE !== undefined ) accountdir = process.env.KEYSTORE; @@ -213,8 +212,8 @@ function prepareCall() let method = contractInstance.methods.proveControl( proof ); // contractInstance.methods.hash(proof).call().then( console.log ); rawdata = method.encodeABI(); - gasestimate( method ). - then( resolve ); + gasestimate( method ) + .then( resolve ); }); } );