Skip to content
Snippets Groups Projects
Commit 5b8fac4e authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

Now actually stripping 0x

parent 055bb214
No related branches found
No related tags found
No related merge requests found
...@@ -17,7 +17,7 @@ var estimate; ...@@ -17,7 +17,7 @@ var estimate;
if ( myArgs.length < 2 || myArgs.length > 3 ) 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( "Wrong number of arguments.");
console.error( "Usage: " + myname + " <account> <proof> [<privatekeypassword>]"); console.error( "Usage: " + myname + " <account> <proof> [<privatekeypassword>]");
process.exit( 1 ); process.exit( 1 );
...@@ -28,7 +28,9 @@ function findMatchingFile( needle, accountdir ) ...@@ -28,7 +28,9 @@ function findMatchingFile( needle, accountdir )
return new Promise( return new Promise(
function(resolve, reject) 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' ); let haystack = fs.readdirSync( accountdir, 'utf8' );
haystack.forEach( haystack.forEach(
(filename) => { (filename) => {
...@@ -47,16 +49,13 @@ function findaccountfile( accountfile ) ...@@ -47,16 +49,13 @@ function findaccountfile( accountfile )
function( resolve, reject ) function( resolve, reject )
{ {
// find account file // find account file
let accountdir;
// is it actually just a file? // is it actually just a file?
if ( accountfile.includes('/') ) if ( accountfile.includes('/') )
{ {
resolve( accountfile ); resolve( accountfile );
return; return;
} }
// strip leading '0x' from the account name, if present let accountdir;
if ( accountfile.startsWith( '0x' ) )
accountfile = accountfile.substring(2);
// if not a file, then look (only) at the most specific directory we have been told about. // if not a file, then look (only) at the most specific directory we have been told about.
if ( process.env.KEYSTORE !== undefined ) if ( process.env.KEYSTORE !== undefined )
accountdir = process.env.KEYSTORE; accountdir = process.env.KEYSTORE;
...@@ -213,8 +212,8 @@ function prepareCall() ...@@ -213,8 +212,8 @@ function prepareCall()
let method = contractInstance.methods.proveControl( proof ); let method = contractInstance.methods.proveControl( proof );
// contractInstance.methods.hash(proof).call().then( console.log ); // contractInstance.methods.hash(proof).call().then( console.log );
rawdata = method.encodeABI(); rawdata = method.encodeABI();
gasestimate( method ). gasestimate( method )
then( resolve ); .then( resolve );
}); });
} }
); );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment