Skip to content

Commit

Permalink
feat: add ability to see tuna balance
Browse files Browse the repository at this point in the history
  • Loading branch information
rvcas committed Aug 26, 2023
1 parent 6ff206c commit 67e673d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions miner/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,25 @@ const address = new Command()

console.log(`Address: ${address}`);
console.log(`ADA Balance: ${balance / 1_000_000n}`);

try {
const genesisFile = Deno.readTextFileSync(
`genesis/${preview ? "preview" : "mainnet"}.json`,
);

const { validatorHash }: Genesis = JSON
.parse(
genesisFile,
);

const tunaBalance = utxos.reduce((acc, u) => {
return acc + (u.assets[validatorHash + fromText("TUNA")] ?? 0n);
}, 0n);

console.log(`TUNA Balance: ${tunaBalance / 100_000_000n}`);
} catch {
console.log(`TUNA Balance: 0`);
}
});

await new Command()
Expand Down

0 comments on commit 67e673d

Please sign in to comment.