Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Refactor Token type into utils
Sebastian Martinez committed 4 years ago
commit b73177ad06e2f48eb067c08eff1e76cc1e46b5ae
parent 497074a0a5dda9539c570911c93648f4da223bf5
2 files changed +10 -5
modified src/base/orgs/View.svelte
@@ -1,7 +1,6 @@
<script lang="ts">
  import type { SvelteComponent } from 'svelte';
  import type { Config } from '@app/config';
-
  import type { BigNumber } from "ethers";
  import { formatName, explorerLink } from '@app/utils';
  import { session } from '@app/session';
  import Loading from '@app/Loading.svelte';
@@ -45,7 +44,7 @@
  const transferOwnership = () => {
    transferOwnerForm = TransferOwnership;
  };
-
  $: getOrgTreasury = async (org: Org): Promise<Array<{ name: string; symbol: string; logo: string; decimals: number; balance: BigNumber }>| undefined> => {
+
  $: getOrgTreasury = async (org: Org): Promise<Array<utils.Token>| undefined> => {
    const addressType = await utils.identifyAddress(org.owner, config);
    // We query the org treasury only for Gnosis Safes, to maintain some privacy for EOA org owners.
    if (addressType === utils.AddressType.Safe) {
modified src/utils.ts
@@ -31,6 +31,14 @@ export interface SafeTransaction {
    operation: number;
}

+
export interface Token {
+
  name: string;
+
  symbol: string;
+
  logo: string;
+
  decimals: number;
+
  balance: BigNumber;
+
}
+

export async function isReverseRecordSet(address: string, domain: string, config: Config): Promise<boolean> {
  const name = await config.provider.lookupAddress(address);
  return name === domain;
@@ -379,9 +387,7 @@ export async function getOwnerSafes(owner: string, config: Config): Promise<stri
}

// Get token balances for an address.
-
export async function getTokens(address: string, config: Config):
-
  Promise<Array<{ name: string; symbol: string; decimals: number; logo: string; balance: BigNumber }>>
-
{
+
export async function getTokens(address: string, config: Config): Promise<Array<Token>> {
  const userBalances = await config.provider.send("alchemy_getTokenBalances", [address, "DEFAULT_TOKENS"]);
  const balances = userBalances.tokenBalances.filter((token: any) => {
    // alchemy_getTokenBalances sometimes returns 0x and this does not work well with ethers.BigNumber