Skip to content

Commit

Permalink
Merge pull request #461 from consensusnetworks/hotfix/withdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
ccali11 committed Nov 16, 2023
2 parents 363e33c + a7804ac commit 000d761
Show file tree
Hide file tree
Showing 24 changed files with 1,047 additions and 951 deletions.
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"css.lint.unknownAtRules": "ignore",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.validate": [
"vue",
"typescript"
],
"[html]": {
"editor.defaultFormatter": "Vue.volar"
},
Expand All @@ -14,10 +19,5 @@
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"eslint.validate": [
"vue",
"typescript"
],
"css.lint.unknownAtRules": "ignore",
"volar.inlayHints.eventArgumentInInlineHandlers": false
}
12 changes: 10 additions & 2 deletions apps/web/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
"@typescript-eslint"
],
"rules": {
"max-len": ["error", { "code": 200, "ignoreStrings": true, "comments":300, "ignoreTemplateLiterals": true }],
"vue/multi-word-component-names": "off",
"max-len": [
"error",
{
"code": 200,
"ignoreStrings": true,
"comments": 300,
"ignoreTemplateLiterals": true
}
],
"vue/multi-word-component-names": "off"
},
"ignorePatterns": [
"**/node_modules/**",
Expand Down
21 changes: 21 additions & 0 deletions apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
<script lang="ts" setup>
import { watch } from "vue"
import { RouterView } from "vue-router"
import DefaultLayout from "@/layouts/default-layout.vue"
import useBreakdownMetrics from "@/composables/breakdownMetrics"
import useContracts from "@/composables/contracts"
import useUser from "@/composables/user"
const { initializeContractsComposable } = useContracts()
const { initializeBreakdownMetricsComposable } = useBreakdownMetrics()
const { initializeUserComposable, user } = useUser()
watch(user, async (newUser, oldUser) => {
// On Sign in
if (newUser && !oldUser) {
await initializeContractsComposable()
await initializeBreakdownMetricsComposable()
} else if (newUser && oldUser) {
// On page refresh when signed in}
await initializeContractsComposable()
await initializeBreakdownMetricsComposable()
}
})
</script>

<template>
Expand Down
12 changes: 7 additions & 5 deletions apps/web/src/components/ConnectWalletsFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const supportedWalletProviders = [
const { login, loginWithSecondaryAddress } = useAuth()
const { requiredNetwork } = useEnvironment()
const { browserProvidersList, getEthersAddressesWithBalances } = useEthers()
const { convertString, trimAndLowercaseAddress } = useFormat()
const { convertString, formatEthersCasimir, trimAndLowercaseAddress } = useFormat()
const { getLedgerAddress } = useLedger()
const { getTrezorAddress } = useTrezor()
const { user } = useUser()
Expand Down Expand Up @@ -112,7 +112,7 @@ async function selectAddress(address: string, pathIndex: number): Promise<void>
errorMassageText.value = "Address selected is already connected to your account."
} else if (
response === "Address already exists as a primary address on another account" ||
response === "Address already exists as a secondary address on another account"
response === "Address already exists as a secondary address on another account"
) {
flowState.value = "confirm_signage_with_existing_secondary"
} else if (response === "Selected address is not active address in wallet") {
Expand Down Expand Up @@ -342,7 +342,7 @@ onUnmounted(() => {
{{ convertString(act.address) }}
</div>
<div>
{{ parseFloat(parseFloat(act.balance).toFixed(2)) }} ETH
{{ formatEthersCasimir(act.balance) }} ETH
</div>
</button>
</div>
Expand Down Expand Up @@ -420,9 +420,11 @@ onUnmounted(() => {
<h1 class="mb-[15px]">
Confirm Signage
</h1>
<p class="">
<p>
The current wallet you are trying to connect exists under another primary wallet or is a primary account.
</p>
<br>
<p>Would you like to create a new account with this address as the primary wallet address?</p>
</div>

<div class="mt-15 h-[220px] w-full flex items-center justify-center gap-5">
Expand All @@ -440,7 +442,7 @@ onUnmounted(() => {
class="action_button w-full"
@click="handleConfirmCreateAccountWithExistingSecondary"
>
Confirm
Create Account
</button>
</div>
<div class="h-15 w-full text-[11px] font-[500] mb-5 text-decline">
Expand Down
21 changes: 6 additions & 15 deletions apps/web/src/composables/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,11 @@ import {
} from "@casimir/types"

const { usersUrl } = useEnvironment()
const { browserProvidersList, detectActiveEthersWalletAddress, loginWithEthers } =
useEthers()
const { browserProvidersList, detectActiveEthersWalletAddress, loginWithEthers } = useEthers()
const { loginWithLedger } = useLedger()
const { loginWithTrezor } = useTrezor()
const { setUser, user } = useUser()
const {
loginWithWalletConnectV2,
initializeWalletConnect,
uninitializeWalletConnect,
} = useWalletConnect()
const { loginWithWalletConnectV2, initializeWalletConnect, uninitializeWalletConnect } = useWalletConnect()

const initializedAuthComposable = ref(false)
const loadingSessionLogin = ref(false)
Expand Down Expand Up @@ -101,7 +96,7 @@ export default function useAuth() {
const response = await fetch(`${usersUrl}/user`, requestOptions)
const { user: retrievedUser, error } = await response.json()
if (error) throw new Error(error)
await setUser(retrievedUser)
setUser(retrievedUser)
} catch (error: any) {
throw new Error("Error getting user from API route")
}
Expand Down Expand Up @@ -173,12 +168,9 @@ export default function useAuth() {
}

// Then check if address is being used as a secondary account by another user
const { data: accountsIfSecondaryAddress } =
await checkIfSecondaryAddress(address)
const { data: accountsIfSecondaryAddress } = await checkIfSecondaryAddress(address)
console.log("accountsIfSecondaryAddress :>> ", accountsIfSecondaryAddress)
if (accountsIfSecondaryAddress.length) {
return "Address already exists as a secondary address on another account"
}
if (accountsIfSecondaryAddress.length) return "Address already exists as a secondary address on another account"

// Handle user interaction (do they want to sign in with another account?)
// If yes, log out (and/or log them in with the other account)
Expand Down Expand Up @@ -288,11 +280,10 @@ export default function useAuth() {
}

async function logout() {
// Loader
try {
loadingSessionLogout.value = true
await Session.signOut()
await setUser(undefined)
setUser(undefined)
loadingSessionLogout.value = false
} catch (error) {
loadingSessionLogoutError.value = true
Expand Down
Loading

0 comments on commit 000d761

Please sign in to comment.