Skip to content

Commit

Permalink
Adds a new function to filter hidden assets and uses it for issued as…
Browse files Browse the repository at this point in the history
…sets
  • Loading branch information
ebma committed Jul 30, 2024
1 parent e9cfee9 commit 712d7ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/pages/spacewalk/bridge/Issue/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TenantName } from '../../../../models/Tenant';
import { ToastMessage, showToast } from '../../../../shared/showToast';

import { FeeBox } from '../FeeBox';
import { prioritizeXLMAsset } from '../helpers';
import { filterHiddenAssets, prioritizeXLMAsset } from '../helpers';

import { ConfirmationDialog } from './ConfirmationDialog';
import Disclaimer from './Disclaimer';
Expand Down Expand Up @@ -101,7 +101,7 @@ function Issue(props: IssueProps): JSX.Element {
operator program, more
<a
target="_blank"
className="text-primary ml-1"
className="ml-1 text-primary"
href="https://pendulum.gitbook.io/pendulum-docs/build/spacewalk-stellar-bridge/operating-a-vault"
rel="noreferrer"
>
Expand Down Expand Up @@ -194,7 +194,7 @@ function Issue(props: IssueProps): JSX.Element {
}, [trigger, selectedAsset, maxIssuable]);

return (
<div className="flex items-center justify-center h-full space-walk py-4">
<div className="space-walk flex h-full items-center justify-center py-4">
<ConfirmationDialog
issueRequest={submittedIssueRequest}
visible={confirmationDialogVisible}
Expand All @@ -205,7 +205,7 @@ function Issue(props: IssueProps): JSX.Element {
}}
/>
<div className="w-full">
<form className="px-5 flex flex-col" onSubmit={handleSubmit(submitRequestIssueExtrinsic, () => undefined)}>
<form className="flex flex-col px-5" onSubmit={handleSubmit(submitRequestIssueExtrinsic, () => undefined)}>
<From
{...{
formControl: {
Expand All @@ -217,7 +217,7 @@ function Issue(props: IssueProps): JSX.Element {
(!isU128Compatible(amountNative) ? 'Exceeds the max allowed value.' : ''),
},
asset: {
assets: prioritizeXLMAsset(wrappedAssets),
assets: prioritizeXLMAsset(filterHiddenAssets(wrappedAssets)),
selectedAsset,
setSelectedAsset,
},
Expand All @@ -228,7 +228,7 @@ function Issue(props: IssueProps): JSX.Element {
}}
/>
<input type="hidden" {...register('securityDeposit')} />
<label className="label flex align-center">
<label className="align-center label flex">
<span className="text-sm">{`Max issuable: ${maxIssuable.toFixed(2)} ${selectedAsset?.code || ''}`}</span>
</label>

Expand Down
16 changes: 16 additions & 0 deletions src/pages/spacewalk/bridge/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
import { Asset } from 'stellar-base';

const MYKOBO_EURC = new Asset('EURC', 'GAQRF3UGHBT6JYQZ7YSUYCIYWAF4T2SAA5237Q5LIQYJOHHFAWDXZ7NM');
const HIDDEN_SPACEWALK_ASSETS = [MYKOBO_EURC];

export function prioritizeXLMAsset(assets?: Asset[]): Asset[] {
if (!assets) {
return [];
}

return assets.sort((a, b) => (a.code === 'XLM' ? -1 : b.code === 'XLM' ? 1 : 0));
}

// Filter out hardcoded hidden assets
export function filterHiddenAssets(assets?: Asset[]): Asset[] {
if (!assets) {
return [];
}

return assets.filter((asset) => {
const isHidden = Boolean(HIDDEN_SPACEWALK_ASSETS.find((hidden) => hidden.equals(asset)));
console.log('isHidden', isHidden, 'asset', asset);
return !isHidden;
});
}

0 comments on commit 712d7ee

Please sign in to comment.