Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Move balance formatting to utils
Alexis Sellier committed 5 years ago
commit 05c6623e63d028610bb8db1fdffa6bcebf669446
parent cc75deb78bce0472aab0e717323efd99e9e24d87
3 files changed +10 -10
modified src/Header.svelte
@@ -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>
modified src/base/vesting/vesting.js
@@ -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));
-
}
added src/utils.js
@@ -0,0 +1,5 @@
+
import { ethers } from "ethers";
+

+
export function formatBalance(n) {
+
  return ethers.utils.commify(parseFloat(ethers.utils.formatUnits(n)).toFixed(2));
+
}