Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook up UI with fiat API (local only) #1

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions background/redux-slices/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export type AssetsState = SingleAssetState[]

export type OffChainAsset = {
amount: number,
currency_symbol: string,
currencySymbol: string,
label: string,
account_id: string
accountId: string
}

export const initialState = [] as AssetsState
Expand Down
4 changes: 2 additions & 2 deletions ui/components/Wallet/WalletAssetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ export default function WalletAssetList(props: Props): ReactElement {
console.log("loadOffChainAccounts");

setOffChainAssets([]);
const assets = (await OffChainService.assets({user_id: "foobar"})).accounts;
const assets = (await OffChainService.assets({userId: "foobar"})).assets;
console.log({assets});
const newOffChainAssets = assets.map(asset => {
const offChainAsset = Object.assign({}, assetAmounts[0]); // TODO: fix pass by reference bug, find a way to deep copy
offChainAsset.asset.symbol = asset.currency_symbol;
offChainAsset.asset.symbol = asset.currencySymbol;
offChainAsset.decimalAmount = asset.amount;
offChainAsset.localizedDecimalAmount = new Intl.NumberFormat().format(asset.amount)
offChainAsset.asset.metadata!.logoURL = "https://media.glassdoor.com/sqll/908271/wealthsimple-squareLogo-1625583235383.png";
Expand Down
6 changes: 3 additions & 3 deletions ui/services/OffChainService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { OffChainAsset } from "@tallyho/tally-background/redux-slices/assets";

export class OffChainService {

static assets({ user_id = ""}): Promise<{accounts: OffChainAsset[]}> {
// const apiResponsePromise = fetch(`http:localhost:8000/api/v1/balances`, {
const apiResponsePromise = fetch(`https://mocki.io/v1/13770a8a-231a-46fd-9acd-f337b42e0436`, {
static assets({ userId = ""}): Promise<{assets: OffChainAsset[]}> {
// const apiResponsePromise = fetch(`https://mocki.io/v1/13770a8a-231a-46fd-9acd-f337b42e0436`, {
const apiResponsePromise = fetch(`http://192.168.1.120:8000/api/v1/balances?user_id=${userId}`, {
method: 'GET',
headers: {
'Accept': 'application/json',
Expand Down