-
Notifications
You must be signed in to change notification settings - Fork 3
[READY] add token disable config/logic in the frontend #607
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e916210
add token disable config in the frontend
Sharqiewicz 649f081
add DEFAULT_RAMP_DIRECTION
Sharqiewicz 0f189a1
add DEFAULT values for rampFormStore
Sharqiewicz 71e700f
add handling for disabled tokens in the url param
Sharqiewicz 251d45e
add handling disabled tokens in SelectionModal
Sharqiewicz e76481b
add handling for disabled tokens in SelectionModal ListItem
Sharqiewicz ac398f2
add english translations for unavailable tokens
Sharqiewicz dfdc7b8
add portuguese translations for unavailable tokens
Sharqiewicz 23dad7e
add ramp validation error for unavailable token
Sharqiewicz 82c77d6
change tokenAvailability reason to translationKey
Sharqiewicz f698839
use translation key for disabled token SelectionModal
Sharqiewicz 2d05950
add token_unavailable error type
Sharqiewicz 5daac65
add missing translation
Sharqiewicz 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { FiatToken } from 'shared'; | ||
| import { DEFAULT_FIAT_TOKEN } from '../stores/ramp/useRampFormStore'; | ||
|
|
||
| export interface TokenAvailabilityConfig { | ||
| enabled: boolean; | ||
| disabledReasonTranslationKey: string; | ||
| } | ||
|
|
||
| // This is our central configuration for token availability | ||
| export const fiatTokenAvailability: Record<FiatToken, TokenAvailabilityConfig> = { | ||
| [FiatToken.EURC]: { | ||
| enabled: false, | ||
| disabledReasonTranslationKey: 'pages.swap.error.EURC_tokenUnavailable', | ||
| }, | ||
| [FiatToken.ARS]: { | ||
| enabled: true, | ||
| disabledReasonTranslationKey: 'pages.swap.error.ARS_tokenUnavailable', | ||
| }, | ||
| [FiatToken.BRL]: { | ||
| enabled: true, | ||
| disabledReasonTranslationKey: 'pages.swap.error.BRL_tokenUnavailable', | ||
| }, | ||
| }; | ||
|
|
||
| export function isFiatTokenEnabled(token: FiatToken): boolean { | ||
| return fiatTokenAvailability[token]?.enabled ?? false; | ||
| } | ||
|
|
||
| export function isFiatTokenDisabled(token: FiatToken): boolean { | ||
| return fiatTokenAvailability[token]?.enabled === false; | ||
| } | ||
|
|
||
| export function getTokenDisabledReason(token: FiatToken): string { | ||
| return fiatTokenAvailability[token].disabledReasonTranslationKey; | ||
| } | ||
|
|
||
| export function getEnabledFiatTokens(): FiatToken[] { | ||
| return Object.entries(fiatTokenAvailability) | ||
| .filter(([_, config]) => config.enabled) | ||
| .map(([token]) => token as FiatToken); | ||
| } | ||
|
|
||
| export function getFirstEnabledFiatToken(): FiatToken { | ||
| const enabledTokens = getEnabledFiatTokens(); | ||
| return enabledTokens.length > 0 ? enabledTokens[0] : DEFAULT_FIAT_TOKEN; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -55,6 +55,9 @@ | |
| }, | ||
| "swap": { | ||
| "error": { | ||
| "EURC_tokenUnavailable": "Ajustando sua saída EUR - em breve!", | ||
| "ARS_tokenUnavailable": "Ajustando sua saída ARS - em breve!", | ||
| "BRL_tokenUnavailable": "Ajustando sua saída BRL - em breve!", | ||
| "initializeFailed": { | ||
| "default": "Estamos enfrentando um congestionamento digital. Por favor, aguarde enquanto liberamos o caminho e fazemos as coisas funcionarem novamente!", | ||
| "noAddress": "Nenhum endereço encontrado.", | ||
|
|
@@ -63,7 +66,7 @@ | |
| }, | ||
| "insufficientFunds": "Saldo insuficiente. Seu saldo é {{userInputTokenBalance}} {{assetSymbol}}", | ||
| "moreThanMaximumWithdrawal": { | ||
| "sell": "O valor máximo de compra é {{maxAmountUnits}} {{assetSymbol}}.", | ||
|
Member
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 think the problem here is not a duplicate but the same key name, ie both being called "sell". Please re-add the key and call it "buy" instead. |
||
| "buy": "O valor máximo de compra é {{maxAmountUnits}} {{assetSymbol}}.", | ||
| "sell": "O valor máximo de venda é {{maxAmountUnits}} {{assetSymbol}}." | ||
| }, | ||
| "lessThanMinimumWithdrawal": { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.