diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index 6ba1bfb5..aeb9fb76 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -166,6 +166,7 @@ export class Address { throw new InternalError("Cannot transfer from address without private key loaded"); } let normalizedAmount = new Decimal(amount.toString()); + const currentBalance = await this.getBalance(assetId); if (currentBalance.lessThan(normalizedAmount)) { throw new ArgumentError( diff --git a/src/coinbase/tests/address_test.ts b/src/coinbase/tests/address_test.ts index d9865d5a..df2462ee 100644 --- a/src/coinbase/tests/address_test.ts +++ b/src/coinbase/tests/address_test.ts @@ -317,7 +317,9 @@ describe("Address", () => { next_page: "", total_count: 0, } as TransferList; - Coinbase.apiClients.transfer!.listTransfers = mockFn(() => { + Coinbase.apiClients.transfer!.listTransfers = mockFn((walletId, addressId) => { + VALID_TRANSFER_MODEL.wallet_id = walletId; + VALID_TRANSFER_MODEL.address_id = addressId; response.next_page = pages.shift() as string; response.data = [VALID_TRANSFER_MODEL]; response.has_more = !!response.next_page;