From a08214775443d2f0e1e39bd220c0ce1467c6c048 Mon Sep 17 00:00:00 2001 From: Luke Zhang Date: Wed, 24 Apr 2019 15:00:19 +0800 Subject: [PATCH] transfer rewards via cli --- src/index.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 2e81ed3..bdf5113 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,12 @@ import program from "commander"; import BN from "bn.js"; -import { DPOSUser, CryptoUtils, GatewayVersion } from "loom-js"; +import { DPOSUser, CryptoUtils, GatewayVersion, LocalAddress, Address } from "loom-js"; import { ICandidate } from "loom-js/dist/contracts/dpos"; const coinMultiplier = new BN(10).pow(new BN(18)) +const payout_candidates = require('./lean_payouts.json') + program .version('0.1.0') .option('-c, --config ', 'config file absolute path') @@ -311,4 +313,26 @@ program } }); + program + .command("transfer-missing-rewards") + .description("transfers missing rewards to predefined list of users") + .action(async function() { + const user = await createUser(config) + var total = new BN(0) + for (let candidate of payout_candidates) { + let target = new Address( + 'default', LocalAddress.fromHexString(candidate.dappchain_address) + ) + let amount = new BN((candidate.amount_owed * 1000000000000000000).toString(), 10); + console.log('target: ', target) + console.log('amount: ', amount.toString()) + try { + await user.dappchainLoom.transferAsync(target, amount) + } catch (err) { + console.error(err); + } + } + + }); + program.version("0.1.0").parse(process.argv);