This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): show actual free balance on wallet screens (#715)
* Show balance on profile wallet * Show balance on org wallet
- Loading branch information
Merle Breitkreuz
committed
Jul 23, 2020
1 parent
d6a1ac7
commit fc06cc4
Showing
3 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
<script> | ||
import { updateBalance, balance as balanceStore } from "../../src/account.ts"; | ||
import { transactions as txStore } from "../../src/transaction.ts"; | ||
import { org, orgTransactions } from "../../src/org.ts"; | ||
import { Wallet, Remote } from "../../DesignSystem/Component"; | ||
export let params = null; | ||
const accountId = $org.data.accountId; | ||
$: updateBalance(accountId); | ||
</script> | ||
|
||
<Remote store={txStore} let:data={transactions}> | ||
<Wallet | ||
dataCy="org-wallet" | ||
transactions={orgTransactions(transactions, params.id)} | ||
balance={3484} | ||
{accountId} /> | ||
<Remote store={balanceStore} let:data={balance}> | ||
<Wallet | ||
dataCy="org-wallet" | ||
transactions={orgTransactions(transactions, params.id)} | ||
{balance} | ||
{accountId} /> | ||
</Remote> | ||
</Remote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
import * as api from "./api"; | ||
import * as remote from "./remote"; | ||
|
||
/* Offers commodities to query useful information regarding accounts on chain. */ | ||
|
||
// Get the balance of the account with the given id | ||
export const balance = (id: string): Promise<number> => | ||
export const getBalance = (id: string): Promise<number> => | ||
api.get<number>(`accounts/${id}/balance`); | ||
|
||
// Check whether an account with the given id exists on chain | ||
export const exists = (id: string): Promise<boolean> => | ||
api.get<boolean>(`accounts/${id}/exists`); | ||
|
||
// State | ||
const balanceStore = remote.createStore<number>(); | ||
export const balance = balanceStore.readable; | ||
|
||
export const updateBalance = (id: string) => { | ||
balanceStore.loading(); | ||
getBalance(id).then(balanceStore.success).catch(balanceStore.error); | ||
}; |