chore: remove superfluous .then
[crowdnode.js/.git] / bin / crowdnode.js
index a867b5663c19595c4d27742129c1f157adf55e1a..60a251f451d7b43f6f92fff2446e9f4ac995acd2 100755 (executable)
@@ -301,30 +301,32 @@ async function generate(name) {
     note = `\n(for pubkey address ${pub})`;
   }
 
+  let testDash = 0.01;
+  let testDuff = toDuff(testDash);
+
   let err = await Fs.access(filepath).catch(Object);
   if (!err) {
     // TODO show QR anyway
     //wif = await Fs.readFile(filepath, 'utf8')
-    //showQr(pub, 0.01);
+    //showQr(pub, testDuff);
     console.info(`'${filepath}' already exists (will not overwrite)`);
     process.exit(0);
     return;
   }
 
-  await Fs.writeFile(filepath, wif, "utf8").then(function () {
-    console.info(``);
-    console.info(
-      `Use the QR Code below to load a test deposit of Đ0.01 onto your staking key.`,
-    );
-    console.info(``);
-    showQr(pub, 0.01);
-    console.info(``);
-    console.info(
-      `Use the QR Code above to load a test deposit of Đ0.01 onto your staking key.`,
-    );
-    console.info(``);
-    console.info(`Generated ${filepath} ${note}`);
-  });
+  await Fs.writeFile(filepath, wif, "utf8");
+  console.info(``);
+  console.info(
+    `Use the QR Code below to load a test deposit of Đ${testDash} onto your staking key.`,
+  );
+  console.info(``);
+  showQr(pub, testDuff);
+  console.info(``);
+  console.info(
+    `Use the QR Code above to load a test deposit of Đ${testDash} onto your staking key.`,
+  );
+  console.info(``);
+  console.info(`Generated ${filepath} ${note}`);
   process.exit(0);
 }
 
@@ -613,6 +615,10 @@ function toDash(duffs) {
   return (duffs / DUFFS).toFixed(8);
 }
 
+function toDuff(dash) {
+  return Math.round(parseFloat(dash) * DUFFS);
+}
+
 // Run
 
 main().catch(function (err) {