Skip to content

Commit

Permalink
Add config option to fully disable Fastspot and don't hide swaps unle…
Browse files Browse the repository at this point in the history
…ss fully disabled
  • Loading branch information
danimoh committed Aug 29, 2024
1 parent 9fbc084 commit 7b7b83f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 42 deletions.
13 changes: 5 additions & 8 deletions src/components/layouts/AccountOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
</div>

<Tooltip
v-if="$config.fastspot.enabledSwapAssets.includes(SwapAsset.NIM)
&& $config.fastspot.enabledSwapAssets.includes(SwapAsset.BTC)
v-if="$config.fastspot.enabled
&& hasBitcoinAddresses && $config.enableBitcoin
&& (nimAccountBalance > 0 || btcAccountBalance > 0)"
class="nim-btc-swap-button"
Expand All @@ -83,11 +82,10 @@
</Tooltip>

<Tooltip
v-if="$config.fastspot.enabledSwapAssets.includes(SwapAsset.NIM)
/* only swap with native USDC supported, not bridged */
&& $config.fastspot.enabledSwapAssets.includes(SwapAsset.USDC_MATIC)
v-if="$config.fastspot.enabled
&& activeAccountInfo.type !== AccountType.LEDGER
&& hasUsdcAddresses && $config.usdc.enabled
/* only swap with native USDC supported, not bridged */
&& (nimAccountBalance > 0 || nativeUsdcAccountBalance > 0)"
class="nim-usdc-swap-button"
ref="nimUsdcSwapTooltip$"
Expand Down Expand Up @@ -140,12 +138,11 @@
</button>

<Tooltip
v-if="$config.fastspot.enabledSwapAssets.includes(SwapAsset.BTC)
/* only swap with native USDC supported, not bridged */
&& $config.fastspot.enabledSwapAssets.includes(SwapAsset.USDC_MATIC)
v-if="$config.fastspot.enabled
&& activeAccountInfo.type !== AccountType.LEDGER
&& hasBitcoinAddresses && $config.enableBitcoin
&& hasUsdcAddresses && $config.usdc.enabled
/* only swap with native USDC supported, not bridged */
&& (btcAccountBalance > 0 || nativeUsdcAccountBalance > 0)"
class="btc-usdc-swap-button"
ref="btcUsdcSwapTooltip$"
Expand Down
8 changes: 6 additions & 2 deletions src/components/layouts/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@

<div class="trade-actions" v-if="!isLegacyAccount">
<Tooltip
v-if="(fastspotEnabledCryptoSwapAssets.length && fastspotEnabledFiatSwapAssets.length)
v-if="(
$config.fastspot.enabled
&& fastspotEnabledCryptoSwapAssets.length
&& fastspotEnabledFiatSwapAssets.length
)
|| $config.moonpay.enabled
|| $config.simplex.enabled"
preferredPosition="top right"
Expand Down Expand Up @@ -111,7 +115,7 @@
<BalanceDistribution />
</div>

<Tooltip v-if="!isLegacyAccount"
<Tooltip v-if="$config.fastspot.enabled && !isLegacyAccount"
preferredPosition="bottom right"
:container="$parent"
:disabled="fastspotEnabledCryptoSwapAssets.length > 1
Expand Down
9 changes: 7 additions & 2 deletions src/components/swap/SwapModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ export default defineComponent({
const fixedAsset = ref<SwapAsset>(leftAsset.value);
const disabledAssetError = computed(() => {
if (!config.fastspot.enabled) return i18n.t('Crypto swaps are currently under maintenance.') as string;
const disabledAsset = [leftAsset.value, rightAsset.value]
.find((asset) => !config.fastspot.enabledSwapAssets.includes(asset));
if (!disabledAsset) return null;
Expand Down Expand Up @@ -1358,7 +1359,10 @@ export default defineComponent({
const canSign = computed(() => { // eslint-disable-line arrow-body-style
// console.log(
// 'canSign:\n',
// `!estimateError: ${!estimateError.value} (estimateError: ${estimateError.value})\n`
// `config.fastspot.enabled: ${config.fastspot.enabled}\n`
// + `!disabledAssetError: ${!disabledAssetError.value} `
// + `(disabledAssetError: ${disabledAssetError.value})\n`
// + `!estimateError: ${!estimateError.value} (estimateError: ${estimateError.value})\n`
// + `!swapError: ${!swapError.value} (swapError: ${swapError.value})\n`
// + `!usdcFeeError: ${!usdcFeeError.value} (usdcFeeError: ${usdcFeeError.value})\n`
// + `!!estimate: ${!!estimate.value} (estimate: ${estimate.value})\n`
Expand All @@ -1370,7 +1374,8 @@ export default defineComponent({
// Don't need to wait for fees because they're calculated from the estimate and swapSuggestion for NIM and
// BTC, and for USDC waiting for usdcFeeStuff is covered by fetchingEstimate via calculateMyFees in
// updateEstimate, which waits for usdcFeeStuff (but usdcFeeStuff is also re-fetched in sign() anyways).
return !estimateError.value && !swapError.value && !usdcFeeError.value
return config.fastspot.enabled
&& !disabledAssetError.value && !estimateError.value && !swapError.value && !usdcFeeError.value
&& estimate.value
&& limits.value?.current.usd
&& !fetchingEstimate.value
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
},

fastspot: {
// To disable Fastspot entirely, set an empty enabledSwapAssets array of type string[].
enabled: true, // Set to false to hide the swap feature.
enabledSwapAssets: [SwapAsset.NIM, SwapAsset.BTC, SwapAsset.USDC_MATIC],
apiEndpoint: 'https://api.test.fastspot.io/fast/v1',
// This is a publishable key
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
},

fastspot: {
// To disable Fastspot entirely, set an empty enabledSwapAssets array of type string[].
enabled: true, // Set to false to hide the swap feature.
enabledSwapAssets: [SwapAsset.NIM, SwapAsset.USDC_MATIC],
apiEndpoint: 'https://api.go.fastspot.io/fast/v1',
// This is a publishable key
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
},

fastspot: {
// To disable Fastspot entirely, set an empty enabledSwapAssets array of type string[].
enabled: true, // Set to false to hide the swap feature.
enabledSwapAssets: [SwapAsset.NIM, SwapAsset.BTC, SwapAsset.USDC_MATIC],
apiEndpoint: 'https://api.test.fastspot.io/fast/v1',
// This is a publishable key
Expand Down
55 changes: 28 additions & 27 deletions src/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ msgstr ""
msgid "{currency} payout pending"
msgstr ""

#: src/components/swap/SwapModal.vue:402
#: src/components/swap/SwapModal.vue:403
msgid "{disabledAsset} swaps are currently under maintenance."
msgstr ""

Expand Down Expand Up @@ -203,8 +203,8 @@ msgstr ""
msgid "Accounts"
msgstr ""

#: src/components/layouts/AccountOverview.vue:138
#: src/components/layouts/AccountOverview.vue:203
#: src/components/layouts/AccountOverview.vue:136
#: src/components/layouts/AccountOverview.vue:200
msgid "Activate"
msgstr ""

Expand Down Expand Up @@ -281,7 +281,7 @@ msgstr ""
msgid "All countries"
msgstr ""

#: src/components/layouts/AccountOverview.vue:241
#: src/components/layouts/AccountOverview.vue:238
#: src/components/LegacyAccountNotice.vue:37
msgid "All new features are exclusive to new accounts. Upgrade now, it only takes seconds."
msgstr ""
Expand Down Expand Up @@ -400,7 +400,7 @@ msgid "BIC works, too."
msgstr ""

#: src/components/AddressList.vue:176
#: src/components/layouts/AccountOverview.vue:119
#: src/components/layouts/AccountOverview.vue:117
#: src/components/layouts/AddressOverview.vue:83
#: src/components/layouts/Settings.vue:119
#: src/components/LegacyAccountNotice.vue:21
Expand Down Expand Up @@ -445,7 +445,7 @@ msgstr ""
msgid "BTC network fee"
msgstr ""

#: src/components/layouts/Sidebar.vue:54
#: src/components/layouts/Sidebar.vue:58
msgid "Buy"
msgstr ""

Expand Down Expand Up @@ -811,7 +811,8 @@ msgstr ""
msgid "Credit Card"
msgstr ""

#: src/components/layouts/Sidebar.vue:140
#: src/components/layouts/Sidebar.vue:144
#: src/components/swap/SwapModal.vue:399
msgid "Crypto swaps are currently under maintenance."
msgstr ""

Expand Down Expand Up @@ -1011,7 +1012,7 @@ msgid "Failed"
msgstr ""

#: src/components/modals/UsdcSendModal.vue:722
#: src/components/swap/SwapModal.vue:970
#: src/components/swap/SwapModal.vue:971
msgid "Failed to fetch USDC fees. Retrying... (Error: {message})"
msgstr ""

Expand Down Expand Up @@ -1291,7 +1292,7 @@ msgstr ""
msgid "invalid"
msgstr ""

#: src/components/swap/SwapModal.vue:1835
#: src/components/swap/SwapModal.vue:1840
msgid "Invalid swap state, swap aborted!"
msgstr ""

Expand Down Expand Up @@ -1473,7 +1474,7 @@ msgstr ""
msgid "Name your contact"
msgstr ""

#: src/components/layouts/Sidebar.vue:170
#: src/components/layouts/Sidebar.vue:174
msgid "Network"
msgstr ""

Expand Down Expand Up @@ -1540,7 +1541,7 @@ msgstr ""
msgid "Not all accounts provided by this bank support instant transactions."
msgstr ""

#: src/components/layouts/Sidebar.vue:150
#: src/components/layouts/Sidebar.vue:154
msgid "Not available in your browser"
msgstr ""

Expand Down Expand Up @@ -1659,7 +1660,7 @@ msgstr ""
msgid "Performing swap {progress}/5"
msgstr ""

#: src/components/layouts/Sidebar.vue:143
#: src/components/layouts/Sidebar.vue:147
msgid "Please activate BTC or USDC in your account first to be able to swap to these currencies."
msgstr ""

Expand Down Expand Up @@ -1688,8 +1689,8 @@ msgstr ""
msgid "Please transfer"
msgstr ""

#: src/components/layouts/Sidebar.vue:154
#: src/components/layouts/Sidebar.vue:57
#: src/components/layouts/Sidebar.vue:158
#: src/components/layouts/Sidebar.vue:61
msgid "Please wait for your current swap to finish before starting a new one."
msgstr ""

Expand Down Expand Up @@ -1883,7 +1884,7 @@ msgstr ""
msgid "Restart payout process"
msgstr ""

#: src/components/swap/SwapModal.vue:1063
#: src/components/swap/SwapModal.vue:1064
msgid "Resulting BTC amount is too small."
msgstr ""

Expand Down Expand Up @@ -1941,7 +1942,7 @@ msgstr ""
msgid "Select which unit to show Bitcoin amounts in."
msgstr ""

#: src/components/layouts/Sidebar.vue:76
#: src/components/layouts/Sidebar.vue:80
msgid "Sell"
msgstr ""

Expand Down Expand Up @@ -1976,7 +1977,7 @@ msgstr ""
msgid "Selling and refunds will not work with a generic IBAN!"
msgstr ""

#: src/components/layouts/Sidebar.vue:79
#: src/components/layouts/Sidebar.vue:83
msgid "Selling NIM directly is currently unavailable in the Wallet."
msgstr ""

Expand Down Expand Up @@ -2109,7 +2110,7 @@ msgstr ""
msgid "Setting up the {currency} side of the swap."
msgstr ""

#: src/components/layouts/Sidebar.vue:178
#: src/components/layouts/Sidebar.vue:182
msgid "Settings"
msgstr ""

Expand Down Expand Up @@ -2225,7 +2226,7 @@ msgid "Super low fees, super fast payments"
msgstr ""

#. avoid displaying the proxy address until we know related peer address
#: src/components/layouts/Sidebar.vue:137
#: src/components/layouts/Sidebar.vue:141
#: src/components/modals/BtcTransactionModal.vue:9
#: src/components/modals/TransactionModal.vue:7
#: src/components/modals/UsdcTransactionModal.vue:9
Expand All @@ -2235,7 +2236,7 @@ msgstr ""
msgid "Swap"
msgstr ""

#: src/components/layouts/AccountOverview.vue:164
#: src/components/layouts/AccountOverview.vue:161
msgid "Swap BTC {arrowIcon} USDC"
msgstr ""

Expand Down Expand Up @@ -2267,11 +2268,11 @@ msgstr ""
msgid "Swap more per 30 days."
msgstr ""

#: src/components/layouts/AccountOverview.vue:80
#: src/components/layouts/AccountOverview.vue:79
msgid "Swap NIM {arrowIcon} BTC"
msgstr ""

#: src/components/layouts/AccountOverview.vue:106
#: src/components/layouts/AccountOverview.vue:104
msgid "Swap NIM {arrowIcon} USDC"
msgstr ""

Expand Down Expand Up @@ -2335,7 +2336,7 @@ msgstr ""
msgid "The fees (currently {amount}) determine the minimum amount."
msgstr ""

#: src/components/swap/SwapModal.vue:1057
#: src/components/swap/SwapModal.vue:1058
#: src/lib/swap/utils/BuyUtils.ts:95
#: src/lib/swap/utils/SellUtils.ts:115
msgid "The fees determine the minimum amount."
Expand Down Expand Up @@ -2602,7 +2603,7 @@ msgid "Update now"
msgstr ""

#: src/components/AddressList.vue:183
#: src/components/layouts/AccountOverview.vue:179
#: src/components/layouts/AccountOverview.vue:176
#: src/components/layouts/AddressOverview.vue:84
#: src/components/UsdcAddressInfo.vue:12
#: src/composables/useBtcTransactionInfo.ts:124
Expand Down Expand Up @@ -2715,14 +2716,14 @@ msgstr ""
msgid "You can receive more free NIM in {waitTime} hours."
msgstr ""

#: src/components/layouts/Sidebar.vue:306
#: src/components/layouts/Sidebar.vue:310
msgid ""
"You can sell NIM\n"
"- in the Wallet by swapping NIM to BTC or USDC first, which can then be sold.\n"
"- on supported exchanges."
msgstr ""

#: src/components/layouts/Sidebar.vue:146
#: src/components/layouts/Sidebar.vue:150
msgid "You currently have no balance to swap."
msgstr ""

Expand Down Expand Up @@ -2786,7 +2787,7 @@ msgstr ""
msgid "Your browser"
msgstr ""

#: src/components/layouts/Sidebar.vue:151
#: src/components/layouts/Sidebar.vue:155
msgid "Your browser does not support Keyguard popups, or they are disabled in the Settings."
msgstr ""

Expand Down

0 comments on commit 7b7b83f

Please sign in to comment.