Merge branch 'fix/assets-endpoint' into main

This commit is contained in:
Ben Kremer 2022-02-21 17:54:34 +01:00
commit 6eb13e995e
2 changed files with 12 additions and 3 deletions

View File

@ -18,7 +18,7 @@ import {
DEFAULT_PROJECT_ID,
DEFAULT_RELAY_URL,
} from "../constants";
import { AccountBalances, apiGetAccountAssets } from "../helpers";
import { AccountBalances, apiGetAccountBalance } from "../helpers";
import { ERROR, getAppMetadata } from "@walletconnect/utils";
/**
@ -73,8 +73,8 @@ export function ClientContextProvider({ children }: { children: ReactNode | Reac
_accounts.map(async account => {
const [namespace, reference, address] = account.split(":");
const chainId = `${namespace}:${reference}`;
const assets = await apiGetAccountAssets(address, chainId);
return { account, assets };
const assets = await apiGetAccountBalance(address, chainId);
return { account, assets: [assets] };
}),
);

View File

@ -19,6 +19,15 @@ export async function apiGetAccountAssets(address: string, chainId: string): Pro
return result;
}
export async function apiGetAccountBalance(address: string, chainId: string): Promise<AssetData> {
const ethChainId = chainId.split(":")[1];
const response = await ethereumApi.get(
`/account-balance?address=${address}&chainId=${ethChainId}`,
);
const { result } = response.data;
return result;
}
export async function apiGetAccountTransactions(
address: string,
chainId: string,