diff --git a/package.json b/package.json index e620635fa..a95d3e815 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "token-dashboard", - "version": "1.10.0-pre", + "version": "1.11.0-pre", "private": true, "dependencies": { "@chakra-ui/icons": "^1.0.15", diff --git a/src/components/tBTC/BridgeActivity.tsx b/src/components/tBTC/BridgeActivity.tsx index ab7f42c05..39399a178 100644 --- a/src/components/tBTC/BridgeActivity.tsx +++ b/src/components/tBTC/BridgeActivity.tsx @@ -19,7 +19,7 @@ import { import { BridgeActivityStatus, BridgeActivity as BridgeActivityType, - UnminBridgeActivityAdditionalData, + UnmintBridgeActivityAdditionalData, } from "../../threshold-ts/tbtc" import emptyHistoryImageSrcDark from "../../static/images/tBTC-bridge-no-history-dark.svg" import emptyHistoryImageSrcLight from "../../static/images/tBTC-bridge-no-history-light.svg" @@ -112,11 +112,11 @@ const ActivityItem: FC = ({ ? RedemptionDetailsLinkBuilder.createFromTxHash(txHash) .withRedeemer(account!) .withRedeemerOutputScript( - (additionalData as UnminBridgeActivityAdditionalData) + (additionalData as UnmintBridgeActivityAdditionalData) .redeemerOutputScript ) .withWalletPublicKeyHash( - (additionalData as UnminBridgeActivityAdditionalData) + (additionalData as UnmintBridgeActivityAdditionalData) .walletPublicKeyHash ) .build() diff --git a/src/setupTests.js b/src/setupTests.js index 51188572d..2f0638379 100644 --- a/src/setupTests.js +++ b/src/setupTests.js @@ -44,6 +44,7 @@ jest.mock("@keep-network/tbtc-v2.ts/dist/src/bitcoin", () => ({ jest.mock("@keep-network/tbtc-v2.ts/dist/src", () => ({ EthereumBridge: jest.fn(), ElectrumClient: jest.fn(), + EthereumTBTCToken: jest.fn(), })) jest.mock("crypto-js") diff --git a/src/store/tbtc/tbtcSlice.ts b/src/store/tbtc/tbtcSlice.ts index d919e4cf3..c0ce5ea11 100644 --- a/src/store/tbtc/tbtcSlice.ts +++ b/src/store/tbtc/tbtcSlice.ts @@ -5,7 +5,7 @@ import { UpdateStateActionPayload } from "../../types/state" import { BridgeActivityStatus, BridgeActivity, - UnminBridgeActivityAdditionalData, + UnmintBridgeActivityAdditionalData, } from "../../threshold-ts/tbtc" import { featureFlags } from "../../constants" import { startAppListening } from "../listener" @@ -127,7 +127,7 @@ export const tbtcSlice = createSlice({ blockNumber: number amount: string txHash: string - additionalData: UnminBridgeActivityAdditionalData + additionalData: UnmintBridgeActivityAdditionalData }> ) => { const { diff --git a/src/threshold-ts/tbtc/__test__/tbtc.test.ts b/src/threshold-ts/tbtc/__test__/tbtc.test.ts index 60c064ab2..1e9f90e49 100644 --- a/src/threshold-ts/tbtc/__test__/tbtc.test.ts +++ b/src/threshold-ts/tbtc/__test__/tbtc.test.ts @@ -89,6 +89,7 @@ describe("TBTC test", () => { const mockBridgeContract = { interface: {}, address: Bridge.address, + queryFilter: jest.fn(), } const mockTokenContract = { @@ -610,27 +611,31 @@ describe("TBTC test", () => { describe("bridgeActivity", () => { const mockDepositor = "0xCDAfb5A23A1F1c6f80706Cc101BCcf4b9A1A3e3B" - const mockDepositKey = + const mockActivityKey = "0x53361a338f43dad8c81bc46c11be21fc95ad4a24fc16dc6593462670b87378c6" const mockTxHash = "0x615b4a8dac2067cc0cff909aca62cd937538fd750920d44a9af0a34b9f49f2c9" + const mockBlockNumber = "12345" const mockRevealedDeposit = { amount: "1000000", - depositKey: mockDepositKey, + depositKey: mockActivityKey, fundingOutputIndex: 0, fundingTxHash: "0xf178ee999b6550ad172b94683e0497f77d91fc183390cbffecff9cb585961b76", txHash: mockTxHash, walletPublicKeyHash: "0x56988a974575d42db330193acd7a8d9efc67f830", + blockNumber: mockBlockNumber, } const mockEstimatedAmountToMint = BigNumber.from("9975010000000000") const expectedBridgeHistory = [ { amount: "9975010000000000", - depositKey: mockDepositKey, + activityKey: mockActivityKey, status: "PENDING", txHash: mockTxHash, + bridgeProcess: "mint", + blockNumber: mockBlockNumber, }, ] @@ -638,6 +643,7 @@ describe("TBTC test", () => { let mockFindAllMintedDepositsFunction: jest.SpyInstance let mockCalculateEstimatedAmountToMintForRevealedDepositsFunction: jest.SpyInstance let mockFindAllCancelledDepositsFunction: jest.SpyInstance + let mockFindRedemptionActivities: jest.SpyInstance let result: BridgeActivity[] @@ -662,7 +668,7 @@ describe("TBTC test", () => { "_calculateEstimatedAmountToMintForRevealedDeposits" ) mockCalculateEstimatedAmountToMintForRevealedDepositsFunction.mockResolvedValue( - new Map([[mockDepositKey, mockEstimatedAmountToMint]]) + new Map([[mockActivityKey, mockEstimatedAmountToMint]]) ) mockFindAllCancelledDepositsFunction = jest.spyOn( @@ -671,22 +677,29 @@ describe("TBTC test", () => { ) mockFindAllCancelledDepositsFunction.mockResolvedValue([]) + mockFindRedemptionActivities = jest.spyOn( + tBTC as any, + "_findRedemptionActivities" + ) + mockFindRedemptionActivities.mockResolvedValue([]) + result = await tBTC.bridgeActivity(mockDepositor) }) test("should fetch the bridge history properly", () => { + expect(mockFindRedemptionActivities).toHaveBeenCalledWith(mockDepositor) expect(mockFindAllRevealedDepositsFunction).toHaveBeenCalledWith( mockDepositor ) expect(mockFindAllMintedDepositsFunction).toHaveBeenCalledWith( mockDepositor, - [mockDepositKey] + [mockActivityKey] ) expect( mockCalculateEstimatedAmountToMintForRevealedDepositsFunction - ).toHaveBeenCalledWith([mockDepositKey]) + ).toHaveBeenCalledWith([mockActivityKey]) expect(mockFindAllCancelledDepositsFunction).toHaveBeenCalledWith([ - mockDepositKey, + mockActivityKey, ]) expect(result).toEqual(expectedBridgeHistory) }) diff --git a/src/threshold-ts/tbtc/index.ts b/src/threshold-ts/tbtc/index.ts index b4b15dd6c..692930095 100644 --- a/src/threshold-ts/tbtc/index.ts +++ b/src/threshold-ts/tbtc/index.ts @@ -77,7 +77,7 @@ export interface BridgeActivity { blockNumber: number } -export interface UnminBridgeActivityAdditionalData { +export interface UnmintBridgeActivityAdditionalData { redeemerOutputScript: string walletPublicKeyHash: string } @@ -909,7 +909,7 @@ export class TBTC implements ITBTC { additionalData: { redeemerOutputScript: event.redeemerOutputScript, walletPublicKeyHash: event.walletPublicKeyHash, - } as UnminBridgeActivityAdditionalData, + } as UnmintBridgeActivityAdditionalData, }) }