Skip to content

Commit c4f9f76

Browse files
committed
chore(demo): only allow nim-btc swaps
1 parent df14935 commit c4f9f76

File tree

1 file changed

+73
-49
lines changed

1 file changed

+73
-49
lines changed

src/stores/Demo.ts

Lines changed: 73 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const useDemoStore = createStore({
9494
rewriteDemoRoutes();
9595
setupVisualCues();
9696
addDemoModalRoutes();
97+
disableSwapTriggers();
9798
interceptFetchRequest();
9899

99100
setupDemoAddresses();
@@ -203,6 +204,18 @@ function setupVisualCues() {
203204
mutationObserver.observe(document.body, { childList: true, subtree: true });
204205
}
205206

207+
function disableSwapTriggers() {
208+
const mutationObserver = new MutationObserver(() => {
209+
const swapTriggers = document.querySelectorAll(
210+
'.account-grid > :where(.nim-usdc-swap-button, .nim-btc-swap-button, .btc-usdc-swap-button, .account-backgrounds)'
211+
) as NodeListOf<HTMLDivElement>;
212+
swapTriggers.forEach((trigger) => trigger.remove());
213+
const pairSelection = document.querySelector('.pair-selection');
214+
if (pairSelection) pairSelection.remove();
215+
});
216+
mutationObserver.observe(document.body, { childList: true, subtree: true });
217+
}
218+
206219
/**
207220
* Adds routes pointing to our demo modals.
208221
*/
@@ -1055,6 +1068,17 @@ const demoCSS = `
10551068
.send-modal-footer .footer-notice {
10561069
display: none;
10571070
}
1071+
1072+
.account-grid > button.reset,
1073+
.account-grid > .nimiq-account {
1074+
background: #e7e8ea;
1075+
border-radius: 8px;
1076+
transition: background 0.2s var(--nimiq-ease);
1077+
}
1078+
1079+
.account-grid > button:where(:hover, :focus-visible) {
1080+
background: #dedee2 !important;
1081+
}
10581082
`;
10591083

10601084
/**
@@ -1433,30 +1457,30 @@ function completeSwap(activeSwap: any) {
14331457
insertFakeBtcTransactions(transformBtcTransaction([tx]));
14341458
break;
14351459
}
1436-
case 'USDC_MATIC': {
1437-
const tx: UsdcTransactionDefinition = {
1438-
fraction: 1,
1439-
daysAgo: 0,
1440-
description: `Swap ${fromAsset} to ${toAsset}`,
1441-
incoming: false,
1442-
recipientLabel: demoPolygonAddress,
1443-
};
1444-
1445-
insertFakeUsdcTransactions(transformUsdcTransaction([tx]));
1446-
break;
1447-
}
1448-
case 'USDT_MATIC': {
1449-
const tx: UsdtTransactionDefinition = {
1450-
fraction: 1,
1451-
daysAgo: 0,
1452-
description: `Swap ${fromAsset} to ${toAsset}`,
1453-
incoming: false,
1454-
recipientLabel: demoPolygonAddress,
1455-
};
1456-
1457-
insertFakeUsdtTransactions(transformUsdtTransaction([tx]));
1458-
break;
1459-
}
1460+
// case 'USDC_MATIC': {
1461+
// const tx: UsdcTransactionDefinition = {
1462+
// fraction: 1,
1463+
// daysAgo: 0,
1464+
// description: `Swap ${fromAsset} to ${toAsset}`,
1465+
// incoming: false,
1466+
// recipientLabel: demoPolygonAddress,
1467+
// };
1468+
1469+
// insertFakeUsdcTransactions(transformUsdcTransaction([tx]));
1470+
// break;
1471+
// }
1472+
// case 'USDT_MATIC': {
1473+
// const tx: UsdtTransactionDefinition = {
1474+
// fraction: 1,
1475+
// daysAgo: 0,
1476+
// description: `Swap ${fromAsset} to ${toAsset}`,
1477+
// incoming: false,
1478+
// recipientLabel: demoPolygonAddress,
1479+
// };
1480+
1481+
// insertFakeUsdtTransactions(transformUsdtTransaction([tx]));
1482+
// break;
1483+
// }
14601484
default: {
14611485
console.warn(`Unsupported asset type: ${fromAsset}`);
14621486
}
@@ -1496,29 +1520,29 @@ function completeSwap(activeSwap: any) {
14961520
insertFakeBtcTransactions(transformBtcTransaction([tx]));
14971521
break;
14981522
}
1499-
case 'USDC_MATIC': {
1500-
const tx: UsdcTransactionDefinition = {
1501-
fraction: 1,
1502-
daysAgo: 0,
1503-
description: `Swap ${fromAsset} to ${toAsset}`,
1504-
incoming: true,
1505-
recipientLabel: demoPolygonAddress,
1506-
};
1507-
insertFakeUsdcTransactions(transformUsdcTransaction([tx]));
1508-
break;
1509-
}
1510-
case 'USDT_MATIC': {
1511-
const tx: UsdtTransactionDefinition = {
1512-
fraction: 1,
1513-
daysAgo: 0,
1514-
description: `Swap ${fromAsset} to ${toAsset}`,
1515-
incoming: true,
1516-
recipientLabel: demoPolygonAddress,
1517-
};
1518-
1519-
insertFakeUsdtTransactions(transformUsdtTransaction([tx]));
1520-
break;
1521-
}
1523+
// case 'USDC_MATIC': {
1524+
// const tx: UsdcTransactionDefinition = {
1525+
// fraction: 1,
1526+
// daysAgo: 0,
1527+
// description: `Swap ${fromAsset} to ${toAsset}`,
1528+
// incoming: true,
1529+
// recipientLabel: demoPolygonAddress,
1530+
// };
1531+
// insertFakeUsdcTransactions(transformUsdcTransaction([tx]));
1532+
// break;
1533+
// }
1534+
// case 'USDT_MATIC': {
1535+
// const tx: UsdtTransactionDefinition = {
1536+
// fraction: 1,
1537+
// daysAgo: 0,
1538+
// description: `Swap ${fromAsset} to ${toAsset}`,
1539+
// incoming: true,
1540+
// recipientLabel: demoPolygonAddress,
1541+
// };
1542+
1543+
// insertFakeUsdtTransactions(transformUsdtTransaction([tx]));
1544+
// break;
1545+
// }
15221546
default: {
15231547
console.warn(`Unsupported asset type: ${toAsset}`);
15241548
}
@@ -1535,7 +1559,7 @@ interface SetupSwapArgs {
15351559
accountId: string;
15361560
swapId: string;
15371561
fund: {
1538-
type: 'BTC' | 'NIM' | 'USDC' | 'USDT',
1562+
type: 'BTC' | 'NIM' /*| 'USDC' | 'USDT' */,
15391563
inputs: {
15401564
address: string,
15411565
transactionHash: string,
@@ -1553,7 +1577,7 @@ interface SetupSwapArgs {
15531577
refundAddress: string,
15541578
};
15551579
redeem: {
1556-
type: 'BTC' | 'NIM' | 'USDC' | 'USDT',
1580+
type: 'BTC' | 'NIM' /*| 'USDC' | 'USDT' */,
15571581
recipient: string,
15581582
value: number,
15591583
fee: number,

0 commit comments

Comments
 (0)