Skip to content

Commit

Permalink
Handle the case of entering an existing token
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge authored and swansontec committed Sep 4, 2023
1 parent 9220ae1 commit 0536901
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/scenes/EditTokenScene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,17 @@ function EditTokenSceneComponent(props: Props) {

const matchingContractToken =
Object.keys(builtinTokens).find(builtinTokenId => builtinTokenId === newTokenId) == null ? undefined : builtinTokens[newTokenId]
const isMatchingCurrencyCode = Object.values(builtinTokens).find(builtInToken => builtInToken.currencyCode === currencyCode) != null

if (matchingContractToken != null && isMatchingCurrencyCode) {
await showMessage(sprintf(lstrings.warning_token_exists_1s, currencyCode))
return
}

const warningMessage =
Object.values(builtinTokens).find(builtInToken => builtInToken.currencyCode === currencyCode) != null
isMatchingCurrencyCode && matchingContractToken == null
? sprintf(lstrings.warning_token_code_override_2s, currencyCode, config.supportEmail)
: matchingContractToken != null
: matchingContractToken != null && !isMatchingCurrencyCode
? sprintf(lstrings.warning_token_contract_override_3s, currencyCode, matchingContractToken.currencyCode, config.supportEmail)
: undefined

Expand Down
1 change: 1 addition & 0 deletions src/locales/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const strings = {
'The entered contract address differs from the contract address of built-in token %1$s. Please proceed with caution and verify the contract is legitimate as use of this token can result in loss of funds. If you have questions about this feature or contract please contact %2$s.',
warning_token_contract_override_3s:
'The entered token %1$s exists as a built-in token %2$s with the same contract address. Please proceed with caution and verify the contract is legitimate as use of this token can result in loss of funds. If you have questions about this feature please contact %3$s.',
warning_token_exists_1s: 'The entered token is already exists as a built-in token %1$s',

// Alert component:
alert_dropdown_alert: 'Alert! ',
Expand Down
1 change: 1 addition & 0 deletions src/locales/strings/enUS.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"warning_scam_footer_s": "If you have any questions or concerns regarding this send, please contact %s",
"warning_token_code_override_2s": "The entered contract address differs from the contract address of built-in token %1$s. Please proceed with caution and verify the contract is legitimate as use of this token can result in loss of funds. If you have questions about this feature or contract please contact %2$s.",
"warning_token_contract_override_3s": "The entered token %1$s exists as a built-in token %2$s with the same contract address. Please proceed with caution and verify the contract is legitimate as use of this token can result in loss of funds. If you have questions about this feature please contact %3$s.",
"warning_token_exists_1s": "The entered token is already exists as a built-in token %1$s",
"alert_dropdown_alert": "Alert! ",
"alert_dropdown_warning": "Warning! ",
"azteco_success": "You've redeemed an Azteco bitcoin card. Funds should arrive shortly.",
Expand Down

0 comments on commit 0536901

Please sign in to comment.