Skip to content

Commit

Permalink
Remove v2 from WalletConnect naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
ccali11 committed Dec 20, 2023
1 parent cc58800 commit 7518c8e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions apps/mvp/src/components/ConnectWalletsFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import useLedger from "@/composables/ledger"
import useTrezor from "@/composables/trezor"
import useUser from "@/composables/user"
import useWallets from "@/composables/wallets"
import useWalletConnect from "@/composables/walletConnectV2"
import useWalletConnect from "@/composables/walletConnect"
// import useWallets from '@/composables/wallets'
type UserAuthFlowState =
Expand Down Expand Up @@ -40,7 +40,7 @@ const { getEthersLedgerAddresses } = useLedger()
const { getEthersTrezorAddresses } = useTrezor()
const { user } = useUser()
const { detectActiveNetwork, switchEthersNetwork } = useWallets()
const { connectWalletConnectV2, walletConnectSelectedAccount } = useWalletConnect()
const { connectWalletConnect, walletConnectSelectedAccount } = useWalletConnect()
// const { installedWallets, detectInstalledWalletProviders } = useWallets()
// eslint-disable-next-line no-undef
Expand Down Expand Up @@ -164,7 +164,7 @@ async function selectProvider(provider: ProviderString): Promise<void> {
if (provider === "WalletConnect") {
// TODO: @@cali1 - pass in the network id dynamically
walletProviderAddresses.value = await connectWalletConnectV2(requiredNetwork) as CryptoAddress[]
walletProviderAddresses.value = await connectWalletConnect(requiredNetwork) as CryptoAddress[]
} else if (browserProvidersList.includes(provider)) {
walletProviderAddresses.value = await getEthersAddressesWithBalances(provider) as CryptoAddress[]
} else if (provider === "Ledger") {
Expand Down Expand Up @@ -684,4 +684,4 @@ watch(walletConnectSelectedAccount, () => {
letter-spacing: -0.01em;
color: #667085;
}
</style>@/composables/eventBus
</style>@/composables/eventBus@/composables/walletConnect
6 changes: 3 additions & 3 deletions apps/mvp/src/composables/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useEthers from "@/composables/ethers"
import useLedger from "@/composables/ledger"
import useTrezor from "@/composables/trezor"
import useUser from "@/composables/user"
import useWalletConnect from "@/composables/walletConnectV2"
import useWalletConnect from "@/composables/walletConnect"
import useWallets from "@/composables/wallets"
import {
Account,
Expand All @@ -20,7 +20,7 @@ const { browserProvidersList, loginWithEthers } = useEthers()
const { loginWithLedger } = useLedger()
const { loginWithTrezor } = useTrezor()
const { setUser, user } = useUser()
const { disconnectWalletConnect, loginWithWalletConnectV2, initializeWalletConnect } = useWalletConnect()
const { disconnectWalletConnect, loginWithWalletConnect, initializeWalletConnect } = useWalletConnect()
const { detectActiveWalletAddress } = useWallets()

const initializedAuthComposable = ref(false)
Expand Down Expand Up @@ -265,7 +265,7 @@ export default function useAuth() {
} else if (provider === "Trezor") {
await loginWithTrezor(loginCredentials)
} else if (provider === "WalletConnect") {
await loginWithWalletConnectV2(loginCredentials)
await loginWithWalletConnect(loginCredentials)
} else {
console.log("Sign up not yet supported for this wallet provider")
}
Expand Down
6 changes: 3 additions & 3 deletions apps/mvp/src/composables/operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import useLedger from "@/composables/ledger"
import useTrezor from "@/composables/trezor"
import useUser from "@/composables/user"
import useWallets from "@/composables/wallets"
import useWalletConnectV2 from "@/composables/walletConnectV2"
import useWalletConnect from "@/composables/walletConnect"
import { CasimirManager, CasimirRegistry, CasimirViews } from "@casimir/ethereum/build/@types"

let baseManager: CasimirManager
Expand All @@ -35,7 +35,7 @@ const { getEthersLedgerSigner } = useLedger()
const { getEthersTrezorSigner } = useTrezor()
const { user } = useUser()
const { detectActiveNetwork, switchEthersNetwork } = useWallets()
const { getWalletConnectSignerV2 } = useWalletConnectV2()
const { getWalletConnectSigner } = useWalletConnect()
const loadingInitializeOperators = ref(false)
const loadingInitializeOperatorsError = ref(false)

Expand Down Expand Up @@ -210,7 +210,7 @@ export default function useOperators() {
if (browserProvidersList.includes(walletProvider)) {
signer = getEthersBrowserSigner(walletProvider)
} else if (walletProvider === "WalletConnect") {
await getWalletConnectSignerV2()
await getWalletConnectSigner()
} else if (walletProvider === "Ledger") {
getEthersLedgerSigner()
} else if (walletProvider === "Trezor") {
Expand Down
14 changes: 7 additions & 7 deletions apps/mvp/src/composables/staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import useLedger from "@/composables/ledger"
import useTrezor from "@/composables/trezor"
import useUser from "@/composables/user"
import useWallets from "@/composables/wallets"
import useWalletConnectV2 from "./walletConnectV2"
import useWalletConnect from "./walletConnect"
import { CasimirManager } from "@casimir/ethereum/build/@types"
import { StakeDetails } from "@casimir/types"

Expand All @@ -17,7 +17,7 @@ const { getEthersLedgerSigner } = useLedger()
const { getEthersTrezorSigner } = useTrezor()
const { user } = useUser()
const { detectActiveNetwork, switchEthersNetwork } = useWallets()
const { getWalletConnectSignerV2 } = useWalletConnectV2()
const { getWalletConnectSigner } = useWalletConnect()

const stakingComposableInitialized = ref(false)
const awaitingStakeOrWithdrawConfirmation = ref(false)
Expand Down Expand Up @@ -50,7 +50,7 @@ export default function useStaking() {
async function deposit({ amount, walletProvider, type, pathIndex }: { amount: string, walletProvider: ProviderString, type: "default" | "eigen", pathIndex: number | undefined}) {
stakeWithdrawError.value = ""
try {
// This is currently handling the connectWalletConnectV2 if no current session
// This is currently handling the connectWalletConnect if no current session
const activeNetwork = await detectActiveNetwork(walletProvider)
console.log("activeNetwork :>> ", activeNetwork)
if (activeNetwork !== 5) {
Expand All @@ -62,7 +62,7 @@ export default function useStaking() {
if (browserProvidersList.includes(walletProvider)) {
signer = getEthersBrowserSigner(walletProvider)
} else if (walletProvider === "WalletConnect") {
signer = await getWalletConnectSignerV2()
signer = await getWalletConnectSigner()
} else if (walletProvider === "Ledger") {
signer = getEthersLedgerSigner(pathIndex)
} else if (walletProvider === "Trezor") {
Expand Down Expand Up @@ -168,7 +168,7 @@ export default function useStaking() {
if (browserProvidersList.includes(walletProvider)) {
signer = getEthersBrowserSigner(walletProvider)
} else if (walletProvider === "WalletConnect") {
await getWalletConnectSignerV2()
await getWalletConnectSigner()
} else if (walletProvider === "Ledger") {
getEthersLedgerSigner()
} else if (walletProvider === "Trezor") {
Expand All @@ -186,7 +186,7 @@ export default function useStaking() {
async function withdraw({ amount, walletProvider, type }: { amount: string, walletProvider: ProviderString, type: "default" | "eigen" }) {
try {
stakeWithdrawError.value = ""
// This is currently handling the connectWalletConnectV2 if no current session
// This is currently handling the connectWalletConnect if no current session
const activeNetwork = await detectActiveNetwork(walletProvider)
if (activeNetwork !== 5) {
await switchEthersNetwork(walletProvider, "0x5")
Expand All @@ -197,7 +197,7 @@ export default function useStaking() {
if (browserProvidersList.includes(walletProvider)) {
signer = getEthersBrowserSigner(walletProvider)
} else if (walletProvider === "WalletConnect") {
await getWalletConnectSignerV2()
await getWalletConnectSigner()
} else if (walletProvider === "Ledger") {
getEthersLedgerSigner()
} else if (walletProvider === "Trezor") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const isInitializing = ref(false)

const walletConnectSelectedAccount = ref([] as Array<CryptoAddress>)

export default function useWalletConnectV2() {
async function connectWalletConnectV2(chainId: "1" | "5" | "1337", pairing?: PairingTypes.Struct): Promise<CryptoAddress[]> {
export default function useWalletConnect() {
async function connectWalletConnect(chainId: "1" | "5" | "1337", pairing?: PairingTypes.Struct): Promise<CryptoAddress[]> {
try {
if (!ethereumProvider.value) throw new ReferenceError("WalletConnect Client is not initialized.")

Expand Down Expand Up @@ -106,7 +106,7 @@ export default function useWalletConnectV2() {
_resetApp()
}

function getWalletConnectSignerV2() {
function getWalletConnectSigner() {
if (!web3Provider.value) throw new Error("Web3Provider is not initialized")
return web3Provider.value.getSigner()
}
Expand All @@ -118,7 +118,7 @@ export default function useWalletConnectV2() {
await createClient()
}

async function loginWithWalletConnectV2(loginCredentials: LoginCredentials) {
async function loginWithWalletConnect(loginCredentials: LoginCredentials) {
const { provider, address, currency } = loginCredentials
const message = await createSiweMessage(address, "Sign in with Ethereum to the Casimir.")
const signedMessage = await signWalletConnectMessage(message)
Expand Down Expand Up @@ -250,10 +250,10 @@ export default function useWalletConnectV2() {
return {
walletConnectSelectedAccount,
web3Provider,
connectWalletConnectV2,
connectWalletConnect,
disconnectWalletConnect,
getWalletConnectSignerV2,
getWalletConnectSigner,
initializeWalletConnect,
loginWithWalletConnectV2,
loginWithWalletConnect,
}
}
6 changes: 3 additions & 3 deletions apps/mvp/src/composables/wallets.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ref, readonly } from "vue"
import { ProviderString } from "@casimir/types"
import useEthers from "@/composables/ethers"
import useWalletConnectV2 from "@/composables/walletConnectV2"
import useWalletConnect from "@/composables/walletConnect"

const installedWallets = ref([] as ProviderString[])
const { browserProvidersList, detectActiveEthersWalletAddress, getBrowserProvider } = useEthers()
const { connectWalletConnectV2, web3Provider } = useWalletConnectV2()
const { connectWalletConnect, web3Provider } = useWalletConnect()

export default function useWallets() {
async function detectActiveNetwork(providerString: ProviderString): Promise<number> {
Expand All @@ -16,7 +16,7 @@ export default function useWallets() {
return chainId
} else if (providerString === "WalletConnect") {
if (!web3Provider.value) {
await connectWalletConnectV2("5")
await connectWalletConnect("5")
}
return web3Provider.value.provider.chainId
} else if (providerString === "Ledger") {
Expand Down

0 comments on commit 7518c8e

Please sign in to comment.