diff --git a/src/helpers/ethereum.ts b/src/helpers/ethereum.ts index 7ffb61e..154fd57 100644 --- a/src/helpers/ethereum.ts +++ b/src/helpers/ethereum.ts @@ -25,13 +25,11 @@ export function getIndexFromPath(path: string): number { return Number(path.replace(ETH_STANDARD_PATH, "").replace("/", "")); } -export async function getFreeBalanceOffChain( +export function getFreeBalanceOffChain( client: IConnextClient, assetId: string, -): Promise { - return (await client.getFreeBalance(assetId !== constants.AddressZero ? assetId : undefined))[ - client.signerAddress - ].toString(); +): Promise<{ [address: string]: BigNumber }> { + return client.getFreeBalance(assetId !== constants.AddressZero ? assetId : undefined); } export function getFreeBalanceOnChain( @@ -54,7 +52,11 @@ export async function getClientBalance( client.ethProvider, assetId, ); - return { freeBalanceOffChain, freeBalanceOnChain }; + return { + freeBalanceOffChain: freeBalanceOffChain[client.signerAddress].toString(), + nodeFreeBalanceOffChain: freeBalanceOffChain[client.nodeSignerAddress].toString(), + freeBalanceOnChain, + }; } export async function getEthBalance( diff --git a/src/helpers/types.ts b/src/helpers/types.ts index 6c3b77c..cd52fe4 100644 --- a/src/helpers/types.ts +++ b/src/helpers/types.ts @@ -105,6 +105,7 @@ export namespace RouteMethods { }; export type GetBalanceResponse = { freeBalanceOffChain?: string; + nodeFreeBalanceOffChain?: string; freeBalanceOnChain: string; }; diff --git a/src/schemas.ts b/src/schemas.ts index 8e5a6cd..f0cd7d4 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -56,6 +56,7 @@ export const BalanceResponseSchema = { properties: { freeBalanceOffChain: { type: "string", nullable: true }, freeBalanceOnChain: { type: "string" }, + nodeFreeBalanceOffChain: { type: "string", nullable: true }, }, };