From a0fa8fed349b8911d53b244f9d3b989e9ad1874b Mon Sep 17 00:00:00 2001 From: Xinyu Li Date: Thu, 22 Aug 2024 14:39:44 -0700 Subject: [PATCH] revert wallet level historical balance call --- CHANGELOG.md | 4 +++ src/coinbase/wallet.ts | 26 ------------------ src/tests/wallet_test.ts | 58 ---------------------------------------- 3 files changed, 4 insertions(+), 84 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b43089fe..4f567e10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Reverted + +- Remove `listHistoricalBalances` wallet method to avoid confusion. + ## [0.1.0] - 2024-08-22 ### Added diff --git a/src/coinbase/wallet.ts b/src/coinbase/wallet.ts index 7c3267f3..e5fe9b6f 100644 --- a/src/coinbase/wallet.ts +++ b/src/coinbase/wallet.ts @@ -19,8 +19,6 @@ import { Amount, CreateTransferOptions, CreateTradeOptions, - ListHistoricalBalancesOptions, - ListHistoricalBalancesResult, SeedData, ServerSignerStatus, StakeOptionsMode, @@ -415,30 +413,6 @@ export class Wallet { return await this.getDefaultAddress()!.historicalStakingBalances(assetId, startTime, endTime); } - /** - * Lists the historical balances for a given asset belonging to the default address of the wallet. - * - * @param options - The options to list historical balances. - * @param options.assetId - The asset ID. - * @param options.limit - A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10. - * @param options.page - A cursor for pagination across multiple pages of results. Don\'t include this parameter on the first call. Use the next_page value returned in a previous response to request subsequent results. - * @returns The list of historical balance of the asset and next page token. - */ - public async listHistoricalBalances({ - assetId, - limit, - page, - }: ListHistoricalBalancesOptions): Promise { - if (!this.getDefaultAddress()) { - throw new InternalError("Default address not found"); - } - return await this.getDefaultAddress()!.listHistoricalBalances({ - assetId: assetId, - limit: limit, - page: page, - }); - } - /** * Creates a staking operation to stake, signs it, and broadcasts it on the blockchain. * diff --git a/src/tests/wallet_test.ts b/src/tests/wallet_test.ts index 8282d613..555d63db 100644 --- a/src/tests/wallet_test.ts +++ b/src/tests/wallet_test.ts @@ -10,7 +10,6 @@ import { Transfer } from "../coinbase/transfer"; import { ServerSignerStatus, StakeOptionsMode, TransferStatus } from "../coinbase/types"; import { AddressBalanceList, - AddressHistoricalBalanceList, Address as AddressModel, Balance as BalanceModel, TransactionStatusEnum, @@ -441,63 +440,6 @@ describe("Wallet Class", () => { }); }); - describe(".listHistoricalBalances", () => { - beforeEach(() => { - const mockHistoricalBalanceResponse: AddressHistoricalBalanceList = { - data: [ - { - amount: "1000000", - block_hash: "0x0dadd465fb063ceb78babbb30abbc6bfc0730d0c57a53e8f6dc778dafcea568f", - block_height: "12345", - asset: { - asset_id: "usdc", - network_id: Coinbase.networks.EthereumHolesky, - decimals: 6, - }, - }, - { - amount: "5000000", - block_hash: "0x5c05a37dcb4910b22a775fc9480f8422d9d615ad7a6a0aa9d8778ff8cc300986", - block_height: "67890", - asset: { - asset_id: "usdc", - network_id: Coinbase.networks.EthereumHolesky, - decimals: 6, - }, - }, - ], - has_more: false, - next_page: "", - }; - Coinbase.apiClients.externalAddress = externalAddressApiMock; - Coinbase.apiClients.externalAddress!.listAddressHistoricalBalance = mockReturnValue( - mockHistoricalBalanceResponse, - ); - }); - - it("should throw an error when the wallet does not have a default address", async () => { - const newWallet = Wallet.init(walletModel); - await expect( - async () => - await newWallet.listHistoricalBalances({ - assetId: Coinbase.assets.Usdc, - }), - ).rejects.toThrow(InternalError); - }); - - it("should successfully return historical balances", async () => { - const wallet = await Wallet.create({ networkId: Coinbase.networks.EthereumHolesky }); - Coinbase.apiClients.asset!.getAsset = getAssetMock(); - const response = await wallet.listHistoricalBalances({ - assetId: Coinbase.assets.Usdc, - }); - expect(response.historicalBalances.length).toEqual(2); - expect(response.historicalBalances[0].amount).toEqual(new Decimal(1)); - expect(response.historicalBalances[1].amount).toEqual(new Decimal(5)); - expect(response.nextPageToken).toEqual(""); - }); - }); - describe(".createTransfer", () => { let weiAmount, destination, intervalSeconds, timeoutSeconds; let balanceModel: BalanceModel;