Skip to content

Commit

Permalink
Merge branch 'main' into coverage-pools-balance
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsmiarowski committed Sep 22, 2023
2 parents 223a034 + 1fd5463 commit 6c99f97
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
6 changes: 3 additions & 3 deletions src/components/tBTC/BridgeActivity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -112,11 +112,11 @@ const ActivityItem: FC<BridgeActivityType> = ({
? RedemptionDetailsLinkBuilder.createFromTxHash(txHash)
.withRedeemer(account!)
.withRedeemerOutputScript(
(additionalData as UnminBridgeActivityAdditionalData)
(additionalData as UnmintBridgeActivityAdditionalData)
.redeemerOutputScript
)
.withWalletPublicKeyHash(
(additionalData as UnminBridgeActivityAdditionalData)
(additionalData as UnmintBridgeActivityAdditionalData)
.walletPublicKeyHash
)
.build()
Expand Down
1 change: 1 addition & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions src/store/tbtc/tbtcSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -127,7 +127,7 @@ export const tbtcSlice = createSlice({
blockNumber: number
amount: string
txHash: string
additionalData: UnminBridgeActivityAdditionalData
additionalData: UnmintBridgeActivityAdditionalData
}>
) => {
const {
Expand Down
27 changes: 20 additions & 7 deletions src/threshold-ts/tbtc/__test__/tbtc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ describe("TBTC test", () => {
const mockBridgeContract = {
interface: {},
address: Bridge.address,
queryFilter: jest.fn(),
}

const mockTokenContract = {
Expand Down Expand Up @@ -610,34 +611,39 @@ 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,
},
]

let mockFindAllRevealedDepositsFunction: jest.SpyInstance
let mockFindAllMintedDepositsFunction: jest.SpyInstance
let mockCalculateEstimatedAmountToMintForRevealedDepositsFunction: jest.SpyInstance
let mockFindAllCancelledDepositsFunction: jest.SpyInstance
let mockFindRedemptionActivities: jest.SpyInstance

let result: BridgeActivity[]

Expand All @@ -662,7 +668,7 @@ describe("TBTC test", () => {
"_calculateEstimatedAmountToMintForRevealedDeposits"
)
mockCalculateEstimatedAmountToMintForRevealedDepositsFunction.mockResolvedValue(
new Map([[mockDepositKey, mockEstimatedAmountToMint]])
new Map([[mockActivityKey, mockEstimatedAmountToMint]])
)

mockFindAllCancelledDepositsFunction = jest.spyOn(
Expand All @@ -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)
})
Expand Down
4 changes: 2 additions & 2 deletions src/threshold-ts/tbtc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface BridgeActivity {
blockNumber: number
}

export interface UnminBridgeActivityAdditionalData {
export interface UnmintBridgeActivityAdditionalData {
redeemerOutputScript: string
walletPublicKeyHash: string
}
Expand Down Expand Up @@ -909,7 +909,7 @@ export class TBTC implements ITBTC {
additionalData: {
redeemerOutputScript: event.redeemerOutputScript,
walletPublicKeyHash: event.walletPublicKeyHash,
} as UnminBridgeActivityAdditionalData,
} as UnmintBridgeActivityAdditionalData,
})
}

Expand Down

0 comments on commit 6c99f97

Please sign in to comment.