Skip to content

Commit

Permalink
improve continue page
Browse files Browse the repository at this point in the history
  • Loading branch information
pseudozach committed Nov 7, 2023
1 parent 9fdc5d6 commit 8dfe305
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lnstxbridge-frontend",
"version": "1.0.2",
"version": "1.0.3",
"scripts": {
"start": "BROWSER=none react-scripts start",
"build": "react-scripts build",
Expand Down
51 changes: 30 additions & 21 deletions src/views/continue/continuePageDesktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ const boltz_logo = require('../../asset/icons/scuba2.png');
// const loading = currencies.length === 0;

function status2HumanReadable(str) {
// console.log('status2HumanReadable ', str, str.slice(0, 2));
if (str.slice(0, 2) === 'as') {
// console.log('status2HumanReadable ', str,);
if (!str) return;
if (str?.slice(0, 2) === 'as') {
// Atomic Swap
str = str.replace('as', '⬇️ ');
}
Expand Down Expand Up @@ -89,26 +90,33 @@ class LandingPageDeskTopContent extends React.Component {
localStorage[item].includes('preimageHash')
) {
const swapId = item.split('lnswaps_')[1];
if (!swapId) return;
if (!swapId) continue;
const swapData = JSON.parse(localStorage[item]);
const status = await this.getSwapStatus(swapId);
swapData.status = status;
swapData.statusText = status2HumanReadable(status);
if (status === 'invoice.expired' || status === 'swap.expired') {
swapData.buttonText = 'Failed';
} else if (status === 'transaction.claimed') {
swapData.buttonText = 'Finished';
} else if (status.includes('refund')) {
swapData.buttonText = 'Refund';
swapData.link = '/refund';
} else {
swapData.buttonText = 'Continue';
swapData.link = '/swap';
try {
console.log('getting swap status for ', swapId);
const status = await this.getSwapStatus(swapId);
if (!status) continue;
swapData.status = status;
swapData.statusText = status2HumanReadable(status);
if (status === 'invoice.expired' || status === 'swap.expired') {
swapData.buttonText = 'Failed';
} else if (status === 'transaction.claimed') {
swapData.buttonText = 'Finished';
} else if (status.includes('refund')) {
swapData.buttonText = 'Refund';
swapData.link = '/refund';
} else {
swapData.buttonText = 'Continue';
swapData.link = '/swap';
}
swapData.link = swapData.link + '?swapId=' + swapId;
// TODO: check if preimagehash was refunded before
console.log('swapId, swapData, status: ', swapId, swapData, status);
lnswaps.push(swapData);
} catch (error) {
// skip - could be testnet/mainnet swaps
// console.log('swap not found: ', error.message);
}
swapData.link = swapData.link + '?swapId=' + swapId;
// TODO: check if preimagehash was refunded before
console.log('swapId, swapData, status: ', swapId, swapData, status);
lnswaps.push(swapData);
}
}
this.setState({ lnswaps, loadingSwaps: false });
Expand All @@ -123,10 +131,11 @@ class LandingPageDeskTopContent extends React.Component {
const response = await axios.post(url, {
id: swapId,
});
// console.log('getSwapStatus ', swapId, response.data);
console.log('getSwapStatus ', swapId, response.data);
return response.data.status;
} catch (error) {
console.log('error ', error);
return null;
}
};

Expand Down
5 changes: 5 additions & 0 deletions src/views/refund/steps/InputDestinationAddress.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,11 @@ class InputDestinationAddress extends React.Component {
if (assetContractName.includes('Wrapped-USD')) {
assetName = assetContractName.toLowerCase();
}
console.log('assetAddress, assetContractName, assetName: ', {
assetAddress,
assetContractName,
assetName,
});
const fungibleAssetInfo = createAssetInfo(
assetAddress,
assetContractName,
Expand Down

1 comment on commit 8dfe305

@vercel
Copy link

@vercel vercel bot commented on 8dfe305 Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.