mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-31 01:00:47 +08:00
Move balance formatting to utils
This commit is contained in:
+1
-4
@@ -3,6 +3,7 @@
|
||||
// TODO: Link to correct network on etherscan
|
||||
import { ethers } from "ethers";
|
||||
import { link } from "svelte-routing";
|
||||
import { formatBalance } from "@app/utils";
|
||||
import { CONNECTION, session, connectWallet, disconnectWallet, shortAddress } from "./session.js";
|
||||
import { error } from './error.js';
|
||||
import Logo from './Logo.svelte';
|
||||
@@ -10,10 +11,6 @@
|
||||
|
||||
let sessionButton = null;
|
||||
let sessionButtonHover = false;
|
||||
|
||||
function formatBalance(balance) {
|
||||
return ethers.utils.commify(ethers.utils.formatUnits(balance));
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ethers } from "ethers";
|
||||
import { formatBalance } from "@app/utils";
|
||||
import { STATE, state } from "./state.js";
|
||||
|
||||
const abi = [
|
||||
@@ -49,12 +50,9 @@ export async function getInfo(address, config) {
|
||||
token: token,
|
||||
symbol: symbol,
|
||||
beneficiary: beneficiary,
|
||||
totalVesting: format(total),
|
||||
withdrawableBalance: format(withdrawable),
|
||||
withdrawn: format(withdrawn),
|
||||
totalVesting: formatBalance(total),
|
||||
withdrawableBalance: formatBalance(withdrawable),
|
||||
withdrawn: formatBalance(withdrawn),
|
||||
};
|
||||
}
|
||||
|
||||
function format(n) {
|
||||
return ethers.utils.commify(parseFloat(ethers.utils.formatUnits(n)).toFixed(2));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ethers } from "ethers";
|
||||
|
||||
export function formatBalance(n) {
|
||||
return ethers.utils.commify(parseFloat(ethers.utils.formatUnits(n)).toFixed(2));
|
||||
}
|
||||
Reference in New Issue
Block a user