diff --git a/packages/wallet/backend/src/account/service.ts b/packages/wallet/backend/src/account/service.ts index 70bc64631..ce1f5a589 100644 --- a/packages/wallet/backend/src/account/service.ts +++ b/packages/wallet/backend/src/account/service.ts @@ -22,7 +22,7 @@ interface IAccountService { includeWalletKeys?: boolean ) => Promise getAccountById: (userId: string, accountId: string) => Promise - getAccountBalance: (userId: string, account: Account) => Promise + getAccountBalance: (account: Account) => Promise } export class AccountService implements IAccountService { @@ -110,7 +110,7 @@ export class AccountService implements IAccountService { if (!includeWalletAddress) { accounts.forEach(async (acc) => { - const balance = await this.getAccountBalance(userId, acc) + const balance = await this.getAccountBalance(acc) acc.balance = transformBalance(balance, acc.assetScale) }) } @@ -132,7 +132,7 @@ export class AccountService implements IAccountService { } account.balance = transformBalance( - await this.getAccountBalance(userId, account), + await this.getAccountBalance(account), account.assetScale ) @@ -152,23 +152,16 @@ export class AccountService implements IAccountService { } account.balance = transformBalance( - await this.getAccountBalance(userId, account), + await this.getAccountBalance(account), account.assetScale ) return account } - async getAccountBalance(userId: string, account: Account): Promise { - const user = await User.query().findById(userId) - - if (!user || !user.gateHubUserId) { - throw new NotFound() - } - + async getAccountBalance(account: Account): Promise { const balances = await this.gateHubClient.getWalletBalance( - account.gateHubWalletId, - userId + account.gateHubWalletId ) return Number( balances.find((balance) => balance.vault.assetCode === account.assetCode) diff --git a/packages/wallet/backend/src/gatehub/client.ts b/packages/wallet/backend/src/gatehub/client.ts index 8f6842765..4164876f3 100644 --- a/packages/wallet/backend/src/gatehub/client.ts +++ b/packages/wallet/backend/src/gatehub/client.ts @@ -255,10 +255,7 @@ export class GateHubClient { return response } - async getWalletBalance( - walletId: string, - _userUuid: string - ): Promise { + async getWalletBalance(walletId: string): Promise { const url = `${this.apiUrl}/core/v1/wallets/${walletId}/balances` const response = await this.request('GET', url)