From e599637d9a7f90582c8c28fcd403b853c2d36e80 Mon Sep 17 00:00:00 2001 From: John Peterson Date: Mon, 3 Jun 2024 10:49:43 -0700 Subject: [PATCH 1/2] [Chore] Fix GWei Transfers Asset Id --- src/coinbase/address.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index e8939e1b..ef89489b 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -198,6 +198,7 @@ export class Address { const normalizedAssetId = ((): string => { switch (assetId) { case Coinbase.assets.Gwei: + return Coinbase.assets.Eth; case Coinbase.assets.Wei: return Coinbase.assets.Eth; default: From 7a351ccef94996e5afceba88ba23601ae34f8b2e Mon Sep 17 00:00:00 2001 From: John Peterson Date: Mon, 3 Jun 2024 11:40:39 -0700 Subject: [PATCH 2/2] fix getBalance --- src/coinbase/address.ts | 13 ++++++++++++- src/coinbase/tests/address_test.ts | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/coinbase/address.ts b/src/coinbase/address.ts index ef89489b..e336e573 100644 --- a/src/coinbase/address.ts +++ b/src/coinbase/address.ts @@ -120,10 +120,21 @@ export class Address { * @returns {Decimal} The balance of the asset. */ async getBalance(assetId: string): Promise { + const normalizedAssetId = ((): string => { + switch (assetId) { + case Coinbase.assets.Gwei: + return Coinbase.assets.Eth; + case Coinbase.assets.Wei: + return Coinbase.assets.Eth; + default: + return assetId; + } + })(); + const response = await Coinbase.apiClients.address!.getAddressBalance( this.model.wallet_id, this.model.address_id, - assetId, + normalizedAssetId, ); if (!response.data) { diff --git a/src/coinbase/tests/address_test.ts b/src/coinbase/tests/address_test.ts index 2b2e6288..5b68d051 100644 --- a/src/coinbase/tests/address_test.ts +++ b/src/coinbase/tests/address_test.ts @@ -101,7 +101,7 @@ describe("Address", () => { expect(Coinbase.apiClients.address!.getAddressBalance).toHaveBeenCalledWith( address.getWalletId(), address.getId(), - assetId, + Coinbase.assets.Eth, ); expect(Coinbase.apiClients.address!.getAddressBalance).toHaveBeenCalledTimes(1); }); @@ -114,7 +114,7 @@ describe("Address", () => { expect(Coinbase.apiClients.address!.getAddressBalance).toHaveBeenCalledWith( address.getWalletId(), address.getId(), - assetId, + Coinbase.assets.Eth, ); expect(Coinbase.apiClients.address!.getAddressBalance).toHaveBeenCalledTimes(1); });