Skip to content

Commit

Permalink
Add config option to disable network interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
danimoh committed Nov 25, 2024
1 parent 77fd5fd commit 3db9187
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/components/MobileActionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</button>
<button class="send nq-button-pill light-blue flex-row"
@click="send" @mousedown.prevent
:disabled="sendDisabled"
:disabled="$config.disableNetworkInteraction || sendDisabled"
>
<ArrowRightSmallIcon />{{ $t('Send') }}
</button>
Expand Down
9 changes: 6 additions & 3 deletions src/components/layouts/AccountOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
</div>

<Tooltip
v-if="$config.fastspot.enabled
v-if="!$config.disableNetworkInteraction
&& $config.fastspot.enabled
&& hasBitcoinAddresses && $config.enableBitcoin
&& (nimAccountBalance > 0 || btcAccountBalance > 0)"
class="nim-btc-swap-button"
Expand All @@ -84,7 +85,8 @@
</Tooltip>

<Tooltip
v-if="$config.fastspot.enabled
v-if="!$config.disableNetworkInteraction
&& $config.fastspot.enabled
&& activeAccountInfo && activeAccountInfo.type !== AccountType.LEDGER
&& hasPolygonAddresses && $config.polygon.enabled
&& (
Expand Down Expand Up @@ -154,7 +156,8 @@
</button>

<Tooltip
v-if="$config.fastspot.enabled
v-if="!$config.disableNetworkInteraction
&& $config.fastspot.enabled
&& activeAccountInfo && activeAccountInfo.type !== AccountType.LEDGER
&& hasBitcoinAddresses && $config.enableBitcoin
&& hasPolygonAddresses && $config.polygon.enabled
Expand Down
3 changes: 2 additions & 1 deletion src/components/layouts/AddressOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@

<button class="send nq-button-pill light-blue flex-row"
@click="$router.push(`/send/${activeCurrency}`)" @mousedown.prevent
:disabled="(activeCurrency === 'nim' && (!activeAddressInfo || !activeAddressInfo.balance))
:disabled="$config.disableNetworkInteraction
|| (activeCurrency === 'nim' && (!activeAddressInfo || !activeAddressInfo.balance))
|| (activeCurrency === 'btc' && !btcAccountBalance)
|| (activeCurrency === 'usdc' && !accountUsdcBalance /* can only send native usdc */)
|| (activeCurrency === CryptoCurrency.USDT && !accountUsdtBridgedBalance)"
Expand Down
7 changes: 4 additions & 3 deletions src/components/layouts/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<template #trigger>
<button
class="nq-button-s inverse"
:disabled="hasActiveSwap"
:disabled="$config.disableNetworkInteraction || hasActiveSwap"
@click="openModal('buy')"
@mousedown.prevent="hideTooltips"
>{{ $t('Buy') }}</button>
Expand All @@ -74,7 +74,7 @@
>
<template #trigger>
<button class="nq-button-s inverse"
:disabled="!canSellCryptoWithMoonpay"
:disabled="$config.disableNetworkInteraction || !canSellCryptoWithMoonpay"
@click="openModal('moonpay-sell-info')"
@mousedown.prevent="hideTooltips"
>{{ $t('Sell') }}</button>
Expand Down Expand Up @@ -130,7 +130,8 @@
>
<template #trigger>
<button
:disabled="fastspotEnabledCryptoSwapAssets.length <= 1
:disabled="$config.disableNetworkInteraction
|| fastspotEnabledCryptoSwapAssets.length <= 1
|| walletActivatedCurrencies.length <= 1
|| !hasSwappableBalance
|| !canUseSwaps
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/BuyCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
v-if="!insufficientLimit || !$config.ten31Pass.enabled || kycUser"
:assets="[activeCurrency]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="!canSign"
:disabled="$config.disableNetworkInteraction || !canSign"
:error="estimateError || swapError"
:requireCompleteBtcHistory="false"
@click="sign"
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/SellCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
v-if="!insufficientLimit || !$config.ten31Pass.enabled || kycUser"
:assets="[activeCurrency]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="!canSign"
:disabled="$config.disableNetworkInteraction || !canSign"
:error="estimateError || swapError"
requireCompleteBtcHistory
@click="sign"
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
</PageBody>
<SendModalFooter
:assets="[CryptoCurrency.NIM]"
:disabled="!canSend"
:disabled="$config.disableNetworkInteraction || !canSend"
@click="sign"
><template #cta>{{ $t('Send {currency}', { currency: 'NIM' }) }}</template></SendModalFooter>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/staking/StakingButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-if="!totalActiveStake && activeAddressInfo && activeAddressInfo.balance"
preferredPosition="bottom"
:container="$parent.$el ? { $el: $parent.$el } : undefined"
:disabled="isCTATooltipDisabled"
:disabled="$config.disableNetworkInteraction || isCTATooltipDisabled"
>
<span>
{{ $t('Earn NIM every month by staking your NIM') }}
Expand All @@ -14,11 +14,11 @@
<Tooltip class="staking-button-tooltip" ref="$tooltip"
preferredPosition="top"
:container="$parent.$el ? { $el: $parent.$el } : undefined"
:disabled="!isCTATooltipDisabled"
:disabled="$config.disableNetworkInteraction || !isCTATooltipDisabled"
>
<div slot="trigger">
<button class="stake"
:disabled="!canStake"
:disabled="$config.disableNetworkInteraction || !canStake"
@click="$router.push('/staking')"
@mousedown.prevent
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/swap/SwapModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
v-if="!isLimitReached || !$config.ten31Pass.enabled || kycUser"
:assets="[assetToCurrency(leftAsset), assetToCurrency(rightAsset)]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="!canSign || currentlySigning"
:disabled="$config.disableNetworkInteraction || !canSign || currentlySigning"
:error="disabledAssetError || estimateError || swapError || polygonFeeError"
requireCompleteBtcHistory
@click="sign"
Expand Down
1 change: 1 addition & 0 deletions src/config/config.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
'/dns4/seed3.pos.nimiq-testnet.com/tcp/8443/wss',
'/dns4/seed4.pos.nimiq-testnet.com/tcp/8443/wss',
],
disableNetworkInteraction: true,
faucetEndpoint: 'https://faucet.pos.nimiq-testnet.com',
reportToSentry: false,
enableBitcoin: true,
Expand Down
1 change: 1 addition & 0 deletions src/config/config.mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
'/dns4/vortex.seed.nimiq.cloud/tcp/443/wss',
'/dns4/zenith.seed.nimiq.systems/tcp/443/wss',
],
disableNetworkInteraction: true,
faucetEndpoint: '',
reportToSentry: true,
enableBitcoin: true,
Expand Down
1 change: 1 addition & 0 deletions src/config/config.testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default {
'/dns4/seed3.pos.nimiq-testnet.com/tcp/8443/wss',
'/dns4/seed4.pos.nimiq-testnet.com/tcp/8443/wss',
],
disableNetworkInteraction: true,
faucetEndpoint: 'https://faucet.pos.nimiq-testnet.com',
reportToSentry: true,
enableBitcoin: true,
Expand Down

0 comments on commit 3db9187

Please sign in to comment.