Skip to content

Commit

Permalink
refactor: more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Dec 11, 2024
1 parent dbf7a7a commit b36122e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export function SbtcDepositTransactionItem({ deposit }: SbtcDepositTransactionIt
openTxLink={openTxLink}
txCaption={truncateMiddle(deposit.bitcoinTxid, 4)}
txIcon={
// Replace with sBTC avatar icon
<Avatar.Root>
<Avatar.Image alt="ST" src={SbtcAvatarIconSrc} />
</Avatar.Root>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function Sip10TokenAssetItem({
const { isTokenEnabled } = useManageTokens();

const { contractId, imageCanonicalUri, name, symbol } = info;
// This can be removed once an img is available directly from the sip10 token
const isSbtc = symbol === 'sBTC';

const icon = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
import type { SwapFormValues } from '@shared/models/form.model';
import { RouteUrls } from '@shared/route-urls';

// import { bitflow } from '@shared/utils/bitflow-sdk';
import { useSwapContext } from '@app/pages/swap/swap.context';

import type { SwapAssetListProps } from './swap-asset-list';
Expand All @@ -29,13 +28,6 @@ export function useSwapAssetList({ assets, type }: SwapAssetListProps) {
const isBaseList = type === 'base';
const isQuoteList = type === 'quote';

// async function getBtcToken() {
// // const tokens = await bitflow.getAvailableTokens();
// // console.log(tokens.filter(token => token.tokenId === 'token-xbtc'));
// const result = await bitflow.getQuoteForRoute('token-stx', 'token-xbtc', 1);
// console.log(result);
// }

// Filter out selected asset from selectable assets
const selectableAssets = assets
.filter(
Expand Down Expand Up @@ -77,9 +69,8 @@ export function useSwapAssetList({ assets, type }: SwapAssetListProps) {

const onFetchQuoteAmount = useCallback(
async (baseAsset: SwapAsset, quoteAsset: SwapAsset) => {
// await getBtcToken();
const quoteAmount = await fetchQuoteAmount(baseAsset, quoteAsset, values.swapAmountBase);
// Handle race condition; make sure quote amount is 1:1 for BTC swap
// Handle race condition; make sure quote amount is 1:1
if (baseAsset.name === 'BTC') {
void setFieldValue('swapAmountQuote', values.swapAmountBase);
return;
Expand Down
8 changes: 4 additions & 4 deletions tests/page-object-models/swap.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ export class SwapPage {
await this.page.locator('text="BTC"').click();
}

async selectSbtcAsQuoteAsset() {
async selectQuoteAsset() {
const swapAssetSelectors = await this.page.locator(this.selectAssetBtn).all();
await swapAssetSelectors[1].click();
await this.page.locator(this.chooseAssetList).waitFor();
const quoteAssets = await this.page.locator(this.chooseAssetListItem).all();
await quoteAssets[0].click();
// await this.page.locator(this.chooseAssetList).waitFor();
// const quoteAssets = await this.page.locator(this.chooseAssetListItem).all();
// await quoteAssets[0].click();
}
}
13 changes: 7 additions & 6 deletions tests/specs/swap/swap.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ test.describe('Swaps', () => {
await expect(toast).toBeVisible();
});

test('that it preselects cross chain swap assets', async ({ swapPage }) => {
test('that it preselects cross chain swap assets and restricts quote list', async ({
swapPage,
}) => {
await swapPage.selectBtcAsBaseAsset();

const quoteAsset = await swapPage.page.locator('text="sBTC"').innerText();
test.expect(quoteAsset).toEqual('sBTC');

await swapPage.selectAssetToReceive();
await swapPage.selectSbtcAsQuoteAsset();

const baseAsset = await swapPage.page.locator('text="BTC"').innerText();
test.expect(baseAsset).toEqual('BTC');
await swapPage.selectQuoteAsset();
await swapPage.page.locator(swapPage.chooseAssetList).waitFor();
const quoteAssets = await swapPage.page.locator(swapPage.chooseAssetListItem).all();
test.expect(quoteAssets.length).toEqual(1);
});
});

0 comments on commit b36122e

Please sign in to comment.