Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ jobs:
echo "No release assets found"
exit 1
fi
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
if gh release view "$TAG_NAME" -R "$REPO" >/dev/null 2>&1; then
release_json=$(gh api "repos/${{ github.repository }}/releases/tags/$TAG_NAME")
upload_files=()
for file in "${release_files[@]}"; do
Expand All @@ -436,10 +436,11 @@ jobs:
if [ "${#upload_files[@]}" -eq 0 ]; then
echo "All release assets already exist, skip upload"
else
gh release upload "$TAG_NAME" "${upload_files[@]}"
gh release upload "$TAG_NAME" -R "$REPO" "${upload_files[@]}"
fi
else
gh release create "$TAG_NAME" \
-R "$REPO" \
--title "$RELEASE_TITLE" \
--notes "$RELEASE_NOTES" \
${{ steps.channel.outputs.channel == 'beta' && '--prerelease' || '' }} \
Expand All @@ -448,6 +449,7 @@ jobs:
fi
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ steps.channel.outputs.channel == 'stable' && format('v{0}', steps.version.outputs.version) || 'beta' }}
RELEASE_TITLE: ${{ steps.channel.outputs.channel == 'stable' && format('BFM Pay v{0}', steps.version.outputs.version) || 'BFM Pay Beta' }}
RELEASE_NOTES: |
Expand Down Expand Up @@ -951,7 +953,7 @@ jobs:
echo "No release assets found"
exit 1
fi
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
if gh release view "$TAG_NAME" -R "$REPO" >/dev/null 2>&1; then
release_json=$(gh api "repos/${{ github.repository }}/releases/tags/$TAG_NAME")
upload_files=()
for file in "${release_files[@]}"; do
Expand All @@ -966,10 +968,11 @@ jobs:
if [ "${#upload_files[@]}" -eq 0 ]; then
echo "All release assets already exist, skip upload"
else
gh release upload "$TAG_NAME" "${upload_files[@]}"
gh release upload "$TAG_NAME" -R "$REPO" "${upload_files[@]}"
fi
else
gh release create "$TAG_NAME" \
-R "$REPO" \
--title "$RELEASE_TITLE" \
--notes "$RELEASE_NOTES" \
${{ needs.build-standard.outputs.channel == 'beta' && '--prerelease' || '' }} \
Expand All @@ -978,6 +981,7 @@ jobs:
fi
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ needs.build-standard.outputs.channel == 'stable' && format('v{0}', needs.build-standard.outputs.version) || 'beta' }}
RELEASE_TITLE: ${{ needs.build-standard.outputs.channel == 'stable' && format('BFM Pay v{0}', needs.build-standard.outputs.version) || 'BFM Pay Beta' }}
RELEASE_NOTES: |
Expand Down
8 changes: 6 additions & 2 deletions miniapps/teleport/src/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,12 @@ describe('Teleport App', () => {
fireEvent.click(screen.getByTestId('target-button'))

await waitFor(() => {
expect(screen.getByText('1 BFT = 0.0416 BFM')).toBeInTheDocument()
expect(screen.getByText(/416 BFM/)).toBeInTheDocument()
expect(screen.getByText('1 BFT = 24.03846154 BFM')).toBeInTheDocument()
expect(screen.getByText('1 BFM = 0.0416 BFT')).toBeInTheDocument()
expect(
screen.getAllByText((_, node) => node?.textContent?.includes('240384.61538462 BFM') ?? false)
.length,
).toBeGreaterThan(0)
})
})

Expand Down
36 changes: 32 additions & 4 deletions miniapps/teleport/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,16 @@ const formatRawBalance = (raw: string, decimals: number): string => {

const formatRatioRate = (
ratio: { numerator: number | string; denominator: number | string } | null | undefined,
): string => {
if (!ratio) return '0';
const numerator = Number(ratio.numerator);
const denominator = Number(ratio.denominator);
if (!Number.isFinite(numerator) || !Number.isFinite(denominator) || numerator === 0) return '0';
return (denominator / numerator).toFixed(8).replace(/\.?0+$/, '');
};

const formatInverseRatioRate = (
ratio: { numerator: number | string; denominator: number | string } | null | undefined,
): string => {
if (!ratio) return '0';
const numerator = Number(ratio.numerator);
Expand Down Expand Up @@ -602,7 +612,7 @@ export default function App() {
if (!selectedAsset || !amount) return '0';
const amountNum = Number(amount);
if (!Number.isFinite(amountNum)) return '0';
const ratioNum = Number(selectedAsset.ratio.numerator) / Number(selectedAsset.ratio.denominator);
const ratioNum = Number(selectedAsset.ratio.denominator) / Number(selectedAsset.ratio.numerator);
if (!Number.isFinite(ratioNum)) return '0';
return (amountNum * ratioNum).toFixed(8).replace(/\.?0+$/, '');
}, [selectedAsset, amount]);
Expand Down Expand Up @@ -746,6 +756,7 @@ export default function App() {
) : (
sortedAvailableAssets.map((asset, i) => {
const rate = formatRatioRate(asset.ratio);
const inverseRate = formatInverseRatioRate(asset.ratio);
const routeLabel = `${asset.chain}/${asset.symbol} ${t('common.arrow')} ${asset.targetChain}/${asset.targetAsset}`;
return (
<motion.div
Expand All @@ -770,8 +781,17 @@ export default function App() {
<AssetAvatar symbol={asset.symbol} chain={asset.chain} />
<div className="min-w-0 flex-1">
<CardTitle className="text-base break-words">{routeLabel}</CardTitle>
<CardDescription>
{t('asset.ratio', { from: asset.symbol, rate, to: asset.targetAsset })}
<CardDescription className="space-y-0.5">
<div>
{t('asset.ratio', { from: asset.symbol, rate, to: asset.targetAsset })}
</div>
<div className="text-muted-foreground/70">
{t('asset.ratio', {
from: asset.targetAsset,
rate: inverseRate,
to: asset.symbol,
})}
</div>
</CardDescription>
</div>
</div>
Expand Down Expand Up @@ -996,12 +1016,20 @@ export default function App() {
<Separator />
<div className="flex justify-between">
<span className="text-muted-foreground">{t('confirm.ratio')}</span>
<span>
<span className="text-right">
{t('asset.ratio', {
from: selectedAsset?.symbol ?? '',
rate: formatRatioRate(selectedAsset?.ratio),
to: selectedAsset?.targetAsset ?? '',
})}
<br />
<span className="text-muted-foreground/70">
{t('asset.ratio', {
from: selectedAsset?.targetAsset ?? '',
rate: formatInverseRatioRate(selectedAsset?.ratio),
to: selectedAsset?.symbol ?? '',
})}
</span>
</span>
</div>
<Separator />
Expand Down