Skip to content

Commit

Permalink
Fix/Invalid-network-modal (#35)
Browse files Browse the repository at this point in the history
* draft: removed invalid-network-modal

* added chain selecting to forms

---------

Co-authored-by: Yehor Podporinov <[email protected]>
  • Loading branch information
yehor-podporinov and Yehor Podporinov authored Mar 12, 2024
1 parent bea6be0 commit d82b57e
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 220 deletions.
17 changes: 2 additions & 15 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,24 @@
</transition>
</router-view>
</div>
<invalid-network-modal v-model:is-shown="isShownInvalidNetworkModal" />
</div>
</transition>
</template>

<script lang="ts" setup>
import { AppNavbar, AppNavbarMobile, InvalidNetworkModal } from '@/common'
import { AppNavbar, AppNavbarMobile } from '@/common'
import { useNotifications } from '@/composables'
import { bus, BUS_EVENTS, ErrorHandler } from '@/helpers'
import { useWeb3ProvidersStore } from '@/store'
import { type NotificationPayload } from '@/types'
import { config } from '@config'
import { ref, watch } from 'vue'
import { ref } from 'vue'
const isAppInitialized = ref(false)
const isShownInvalidNetworkModal = ref(false)
const { showToast } = useNotifications()
const web3ProvidersStore = useWeb3ProvidersStore()
watch(
[
() => web3ProvidersStore.isValidChain,
() => web3ProvidersStore.provider.isConnected,
() => isAppInitialized.value,
],
([isValidChain, isConnected]) => {
if (isConnected) isShownInvalidNetworkModal.value = !isValidChain
},
)
const initNotifications = () => {
bus.on(BUS_EVENTS.success, payload =>
showToast('success', payload as NotificationPayload),
Expand Down
16 changes: 0 additions & 16 deletions src/assets/icons/arbitrum-alt-1-icon.svg

This file was deleted.

9 changes: 0 additions & 9 deletions src/assets/icons/ethereum-alt-1-icon.svg

This file was deleted.

169 changes: 0 additions & 169 deletions src/common/modals/compositions/InvalidNetworkModal.vue

This file was deleted.

1 change: 0 additions & 1 deletion src/common/modals/compositions/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as ClaimModal } from './ClaimModal.vue'
export { default as DepositModal } from './DepositModal.vue'
export { default as InvalidNetworkModal } from './InvalidNetworkModal.vue'
export { default as WithdrawModal } from './WithdrawModal.vue'
3 changes: 3 additions & 0 deletions src/composables/use-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const useProvider = (): IUseProvider => {

const isChainSelecting: I['isChainSelecting'] = ref(false)
const selectChain: I['selectChain'] = async chainId => {
if (_providerReactiveState.chainId === chainId) return

isChainSelecting.value = true

try {
Expand Down Expand Up @@ -124,6 +126,7 @@ export const useProvider = (): IUseProvider => {
'--w3m-font-family': 'var(--app-font-family)',
'--w3m-accent': 'var(--primary-main)',
'--w3m-border-radius-master': '0',
'--w3m-z-index': 1500,
},
})

Expand Down
2 changes: 0 additions & 2 deletions src/enums/icon-names.enum.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
export enum ICON_NAMES {
arbitrumAlt1 = 'arbitrum-alt-1',
arbitrum = 'arbitrum',
checkCircle = 'check-circle',
chevronDown = 'chevron-down',
copy = 'copy',
ethereumAlt1 = 'ethereum-alt-1',
ethereum = 'ethereum',
exclamationCircle = 'exclamation-circle',
externalLink = 'external-link',
Expand Down
7 changes: 4 additions & 3 deletions src/forms/ClaimForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,16 @@ const { getFieldErrorMessage, isFieldsValid, isFormValid, touchField } =
const { t } = useI18n()
const { endpointContract, erc1967ProxyContract, networkId } = storeToRefs(
useWeb3ProvidersStore(),
)
const { endpointContract, erc1967ProxyContract, networkId, provider } =
storeToRefs(useWeb3ProvidersStore())
const submit = async (): Promise<void> => {
if (!isFormValid()) return
isSubmitting.value = true
try {
await provider.value.selectChain(config.networks[networkId.value].chainId)
const fees = await endpointContract.value.providerBased.value.estimateFees(
config.networks[networkId.value].extendedChainLayerZeroEndpoint,
await erc1967ProxyContract.value.providerBased.value.l1Sender(),
Expand Down
4 changes: 4 additions & 0 deletions src/forms/DepositForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ const submit = async (action: ACTIONS): Promise<void> => {
isSubmitting.value = true
try {
await web3ProvidersStore.provider.selectChain(
config.networks[web3ProvidersStore.networkId].chainId,
)
let tx
if (action === ACTIONS.approve && balanceOfForm.value) {
tx = await approveByCurrency(balanceOfForm.value.value.currency)
Expand Down
4 changes: 4 additions & 0 deletions src/forms/WithdrawForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ const submit = async (): Promise<void> => {
isSubmitting.value = true
try {
await web3ProvidersStore.provider.selectChain(
config.networks[web3ProvidersStore.networkId].chainId,
)
const tx =
await web3ProvidersStore.erc1967ProxyContract.signerBased.value.withdraw(
props.poolId,
Expand Down
5 changes: 0 additions & 5 deletions src/localization/resources/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,6 @@
"status--public": "Automated",
"status--private": "Non-Automated"
},
"invalid-network-modal": {
"title": "Invalid Network",
"subtitle": "Your wallet is connected to an unsupported chain. Please, switch to another network:",
"switch-btn": "Switch Network"
},
"network-switch": {
"mainnet": "Ethereum Mainnet",
"testnet": "Ethereum Sepolia"
Expand Down

0 comments on commit d82b57e

Please sign in to comment.