Skip to content

Commit

Permalink
Restrict light accounts from buying more than $50 at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon-edge committed Mar 29, 2024
1 parent ac2da52 commit 756e087
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- changed: Allow light accounts to buy up to $50 worth of crypto at a time

## 4.4.0

- added: Add Cardano (ADA)
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 @@ -1421,6 +1421,7 @@ const strings = {
fiat_plugin_sell_failed_try_again: 'Sell order failed. Please try again.',
fiat_plugin_sell_failed_to_send_try_again: 'Failed to send funds for sell transaction. Please try again.',
fiat_plugin_cannot_continue_camera_permission: 'Cannot continue. Camera permission needed for ID verifications',
fiat_plugin_purchase_limit_error: 'Please back up your account to increase the purchase limit',
fiat_plugin_max_buy_quote_error: 'Provider cannot create max buy quote',
fiat_plugin_max_sell_quote_error: 'Provider cannot create max sell quote',
fiat_plugin_max_sell_quote_error_1s: 'Cannot create max sell quote for %$1s',
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 @@ -1248,6 +1248,7 @@
"fiat_plugin_sell_failed_try_again": "Sell order failed. Please try again.",
"fiat_plugin_sell_failed_to_send_try_again": "Failed to send funds for sell transaction. Please try again.",
"fiat_plugin_cannot_continue_camera_permission": "Cannot continue. Camera permission needed for ID verifications",
"fiat_plugin_purchase_limit_error": "Please back up your account to increase the purchase limit",
"fiat_plugin_max_buy_quote_error": "Provider cannot create max buy quote",
"fiat_plugin_max_sell_quote_error": "Provider cannot create max sell quote",
"fiat_plugin_max_sell_quote_error_1s": "Cannot create max sell quote for %$1s",
Expand Down
13 changes: 10 additions & 3 deletions src/plugins/gui/amountQuotePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const MAX_QUOTE_VALUE = '10000000000'
export const amountQuoteFiatPlugin: FiatPluginFactory = async (params: FiatPluginFactoryArgs) => {
const { account, guiPlugin, longPress = false, showUi } = params
const { pluginId } = guiPlugin
const isLightAccount = account.username == null

const assetPromises: Array<Promise<FiatProviderAssetMap>> = []

Expand Down Expand Up @@ -472,12 +473,18 @@ export const amountQuoteFiatPlugin: FiatPluginFactory = async (params: FiatPlugi
}
}
},
async onSubmit() {
logEvent(isBuy ? 'Buy_Quote_Next' : 'Sell_Quote_Next')

async onSubmit(_event, stateManager) {
if (bestQuote == null) {
return
}

// Restrict light accounts from buying more than $50 at a time
if (isLightAccount && gt(bestQuote.fiatAmount, '50')) {
stateManager.update({ statusText: { content: lstrings.fiat_plugin_purchase_limit_error, textType: 'error' } })
return
}

logEvent(isBuy ? 'Buy_Quote_Next' : 'Sell_Quote_Next')
await bestQuote.approveQuote({ showUi, coreWallet })
}
}
Expand Down

0 comments on commit 756e087

Please sign in to comment.