From 827965e8eb3ccdb54a2a67a19bc253d4890d1613 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Thu, 2 Apr 2020 11:06:53 +0300 Subject: [PATCH] avoid parallel tx execution --- scripts/create-gift.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/create-gift.js b/scripts/create-gift.js index df6e4e4..d685531 100644 --- a/scripts/create-gift.js +++ b/scripts/create-gift.js @@ -76,11 +76,11 @@ async function createGift(sender, bucket, keycard) { let methodCall = GiftBucket.methods.createGift(keycard.keycard, keycard.amount, keycard.code); try { - await sendMethod(methodCall, sender, GiftBucket.options.address); - return true; + let receipt = await sendMethod(methodCall, sender, GiftBucket.options.address); + return receipt; } catch(err) { console.error(err); - return false; + return null; } } @@ -151,7 +151,9 @@ async function run() { if (argv["file"]) { let file = fs.readFileSync(argv["file"], 'utf8'); keycards = file.split("\n").map(processLine); - await Promise.all(keycards.map((keycard) => createGift(sender, bucket, keycard))); + for (let keycard of keycards) { + await createGift(sender, bucket, keycard) + } } else if (!hasDoneSomething) { console.error("the --file option must be specified"); process.exit(0);