-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Phase 6b #44
Merged
TorstenStueber
merged 7 commits into
offramp-prototype-staging
from
36-phase-6b-start-anchor-flow-before-nabla-transaction-1
Jul 3, 2024
Merged
Phase 6b #44
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1cd589c
Execute Nabla after SEP-24
TorstenStueber 9ba0981
Some fixes
TorstenStueber 34c1a32
Fix `yarn test` not working
ebma 3bf2a49
Fix errors: useQuery result must not be undefined
TorstenStueber 2afef0c
Merge branch '36-phase-6b-start-anchor-flow-before-nabla-transaction-…
TorstenStueber df49813
Update min offramp amount for nTokens
TorstenStueber 21b8d70
Fix typo
TorstenStueber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ interface FromProps<FormFieldValues extends FieldValues, TFieldName extends Fiel | |
inputHasError: boolean; | ||
fromFormFieldName: TFieldName; | ||
form: UseFormReturn<FormFieldValues>; | ||
fromTokenBalances: { [key: string]: BalanceInfo }; | ||
tokenBalances: { [key: string]: BalanceInfo }; | ||
offrampStarted: boolean; | ||
} | ||
|
||
|
@@ -27,11 +27,11 @@ export function From<FormFieldValues extends FieldValues, TFieldName extends Fie | |
inputHasError, | ||
fromFormFieldName, | ||
form, | ||
fromTokenBalances, | ||
tokenBalances, | ||
offrampStarted, | ||
}: FromProps<FormFieldValues, TFieldName>) { | ||
const { setValue } = useFormContext<SwapFormValues>(); | ||
const fromTokenBalance = tokenId ? fromTokenBalances[tokenId] : undefined; | ||
const fromTokenBalance = tokenId ? tokenBalances[tokenId] : undefined; | ||
|
||
return ( | ||
<div | ||
|
@@ -54,51 +54,43 @@ export function From<FormFieldValues extends FieldValues, TFieldName extends Fie | |
type="button" | ||
> | ||
<span className="rounded-full bg-[rgba(0,0,0,0.15)] h-full p-px mr-1"> | ||
{fromToken && ( | ||
<img | ||
src={`/assets/coins/${fromToken.assetCode.toUpperCase()}.png`} | ||
alt="Pendulum" | ||
className="h-full w-auto" | ||
/> | ||
)} | ||
{fromToken && <img src={fromToken.icon} alt="Pendulum" className="h-full w-auto" />} | ||
{!fromToken && <img src={pendulumIcon} alt="Pendulum" className="h-full w-auto" />} | ||
</span> | ||
<strong className="font-bold">{fromToken?.assetCode || 'Select'}</strong> | ||
<ChevronDownIcon className="w-4 h-4 inline ml-px" /> | ||
</Button> | ||
</div> | ||
<div className="flex justify-between items-center mt-1 dark:text-neutral-400 text-neutral-500"> | ||
<div className="flex gap-1 text-sm"> | ||
{fromTokenBalance !== undefined && ( | ||
<> | ||
<span className="mr-1"> | ||
Your Balance: <TokenBalance query={fromTokenBalance} symbol={fromToken?.assetCode}></TokenBalance> | ||
</span> | ||
<button | ||
className="text-primary hover:underline" | ||
onClick={() => { | ||
if (fromTokenBalance.approximateNumber !== undefined) { | ||
setValue('fromAmount', (fromTokenBalance.approximateNumber * 0.5).toString()); | ||
} | ||
}} | ||
type="button" | ||
> | ||
50% | ||
</button> | ||
<button | ||
className="text-primary hover:underline" | ||
onClick={() => { | ||
if (fromTokenBalance.approximateNumber !== undefined) { | ||
setValue('fromAmount', fromTokenBalance.approximateNumber.toString()); | ||
} | ||
}} | ||
type="button" | ||
> | ||
MAX | ||
</button> | ||
</> | ||
)} | ||
</div> | ||
<div className="justify-between items-center mt-1 dark:text-neutral-400 text-neutral-500"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just changed the rendering of the flex box here to get better spacing between the 50% and MAX buttons. |
||
{fromTokenBalance !== undefined && ( | ||
<div className="flex text-sm gap-4"> | ||
<span className="mr-1 grow"> | ||
Your Balance: <TokenBalance query={fromTokenBalance} symbol={fromToken?.assetCode}></TokenBalance> | ||
</span> | ||
<button | ||
className="text-primary hover:underline" | ||
onClick={() => { | ||
if (fromTokenBalance.approximateNumber !== undefined) { | ||
setValue('fromAmount', (fromTokenBalance.approximateNumber * 0.5).toString()); | ||
} | ||
}} | ||
type="button" | ||
> | ||
50% | ||
</button> | ||
<button | ||
className="text-primary hover:underline" | ||
onClick={() => { | ||
if (fromTokenBalance.approximateNumber !== undefined) { | ||
setValue('fromAmount', fromTokenBalance.approximateNumber.toString()); | ||
} | ||
}} | ||
type="button" | ||
> | ||
MAX | ||
</button> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we don't want the user to check the swap options even if they don't have the balance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user can still check the swap options.
I understand that the only result here is that the UX will show an error message and will not process the offramp. So I think it has only upsides, no downsides.