Skip to content

Commit

Permalink
Update some typo and removed walletConnection[coinbase and wallerConn…
Browse files Browse the repository at this point in the history
…ect2]
  • Loading branch information
VegeBun-csj committed Sep 18, 2024
1 parent 43201bb commit 7b391b8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/constants/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* OnboardingSteps
* 1. Choose wallet
* 2. Key derivation
* a. If wallet has no dYdX Chain transactions and not on whitelist, sign twice (future)
* a. If wallet has no Vota Chain transactions and not on whitelist, sign twice (future)
* i. Success
* ii. Signatures don't match error (Wallet is non-deterministic)
* b. Success
Expand Down
14 changes: 7 additions & 7 deletions src/constants/localStorage.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
export enum LocalStorageKey {
// Onboarding / Accounts
EvmAddress = 'dydx.migrate.EvmAddress',
DoraAddress = 'dydx.migrate.DoraAddress',
OnboardingSelectedWalletType = 'dydx.migrate.OnboardingSelectedWalletType',
WalletConnectionType = 'dydx.migrate.WalletConnectionType',
OnboardingHasAcknowledgedTerms = 'dydx.migrate.OnboardingHasAcknowledgedTerms',
EvmDerivedAddresses = 'dydx.migrate.EvmDerivedAddresses',
EvmAddress = 'dora.migrate.EvmAddress',
DoraAddress = 'dora.migrate.DoraAddress',
OnboardingSelectedWalletType = 'dora.migrate.OnboardingSelectedWalletType',
WalletConnectionType = 'dora.migrate.WalletConnectionType',
OnboardingHasAcknowledgedTerms = 'dora.migrate.OnboardingHasAcknowledgedTerms',
EvmDerivedAddresses = 'dora.migrate.EvmDerivedAddresses',

// UI State
SelectedLocale = 'dydx.migrate.SelectedLocale',
SelectedLocale = 'dora.migrate.SelectedLocale',
}

export const LOCAL_STORAGE_VERSIONS = {
Expand Down
39 changes: 6 additions & 33 deletions src/constants/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import { isMetaMask } from '@/lib/wallet/providers';
// Wallet connection types

export enum WalletConnectionType {
CoinbaseWalletSdk = 'coinbaseWalletSdk',
InjectedEip1193 = 'injectedEip1193',
WalletConnect2 = 'walletConnect2',
}

export enum WalletErrorType {
Expand All @@ -32,33 +30,21 @@ type WalletConnectionTypeConfig = {
};

export const walletConnectionTypes: Record<WalletConnectionType, WalletConnectionTypeConfig> = {
[WalletConnectionType.CoinbaseWalletSdk]: {
name: 'Coinbase Wallet SDK',
wagmiConnectorId: 'coinbaseWallet',
},
[WalletConnectionType.InjectedEip1193]: {
name: 'injected EIP-1193 provider',
wagmiConnectorId: 'injected',
},
[WalletConnectionType.WalletConnect2]: {
name: 'WalletConnect 2.0',
wagmiConnectorId: 'walletConnect',
},
};

// Wallets

export enum WalletType {
CoinbaseWallet = 'COINBASE_WALLET',
MetaMask = 'METAMASK',
WalletConnect2 = 'WALLETCONNECT_2',
OtherWallet = 'OTHER_WALLET',
}

export const DISPLAYED_WALLETS: WalletType[] = [
WalletType.MetaMask,
WalletType.WalletConnect2,
WalletType.CoinbaseWallet,
WalletType.OtherWallet,
];

Expand Down Expand Up @@ -94,7 +80,7 @@ export const wallets: Record<WalletType, WalletConfig> = {
type: WalletType.OtherWallet,
stringKey: "Other",
icon: GenericWalletIcon,
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
connectionTypes: [WalletConnectionType.InjectedEip1193],
matchesInjectedEip1193: (provider) =>
Object.entries(wallets).every(
([walletType, walletConfig]) =>
Expand All @@ -103,27 +89,14 @@ export const wallets: Record<WalletType, WalletConfig> = {
!walletConfig.matchesInjectedEip1193(provider)
),
},
[WalletType.CoinbaseWallet]: {
type: WalletType.CoinbaseWallet,
stringKey: "Coinbase Wallet",
icon: CoinbaseIcon,
connectionTypes: [WalletConnectionType.CoinbaseWalletSdk, WalletConnectionType.InjectedEip1193],
matchesInjectedEip1193: (provider) => provider.isCoinbaseWallet,
},
[WalletType.MetaMask]: {
type: WalletType.MetaMask,
stringKey: "MetaMask",
icon: MetaMaskIcon,
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
connectionTypes: [WalletConnectionType.InjectedEip1193],
matchesInjectedEip1193: isMetaMask,
walletconnect2Id: WALLET_CONNECT_EXPLORER_RECOMMENDED_WALLETS.Metamask,
},
[WalletType.WalletConnect2]: {
type: WalletType.WalletConnect2,
stringKey: "WalletConnect",
icon: WalletConnectIcon,
connectionTypes: [WalletConnectionType.WalletConnect2],
},
};

// Injected EIP-1193 Providers
Expand Down Expand Up @@ -155,22 +128,22 @@ export type WalletConnection = {
provider?: ExternalProvider;
};

// dYdX Chain wallets
// Chain wallets

import { type onboarding } from '@dydxprotocol/v4-client-js';

export const COSMOS_DERIVATION_PATH = "m/44'/118'/0'/0/0";

/**
* @description typed data to sign for dYdX Chain onboarding
* @description typed data to sign for Dora Vota Chain onboarding
*/
export const SIGN_TYPED_DATA = {
primaryType: 'dYdx',
primaryType: 'DORA',
domain: {
name: 'Dora Vota',
},
types: {
dYdx: [{ name: 'action', type: 'string' }],
DORA: [{ name: 'action', type: 'string' }],
},
message: {
action: 'DORA Token Migration Onboarding',
Expand Down
43 changes: 0 additions & 43 deletions src/lib/wagmi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,6 @@ const injectedConnectorOptions = {
},
};

const walletconnect2ConnectorOptions: ConstructorParameters<typeof WalletConnectConnector>[0] = {
chains,
options: {
projectId: import.meta.env.VITE_WALLETCONNECT2_PROJECT_ID,
metadata: {
name: 'dYdX',
description: '',
url: import.meta.env.VITE_BASE_URL,
icons: [`${import.meta.env.VITE_BASE_URL}/cbw-image.png}`],
},
showQrModal: true,
qrModalOptions: {
themeMode: 'dark' as const,
themeVariables: {
'--wcm-accent-color': '#5973fe',
'--wcm-font-family': 'var(--fontFamily-base)',
},
explorerRecommendedWalletIds: WALLET_CONNECT_EXPLORER_RECOMMENDED_IDS,
},
},
};

const connectors = [
new MetaMaskConnector({
Expand All @@ -67,14 +46,6 @@ const connectors = [
shimDisconnect: true,
},
}),
new CoinbaseWalletConnector({
chains,
options: {
appName: 'dYdX',
reloadOnDisconnect: false,
},
}),
new WalletConnectConnector(walletconnect2ConnectorOptions),
new InjectedConnector(injectedConnectorOptions),
];

Expand All @@ -96,18 +67,6 @@ const createInjectedConnectorWithProvider = (provider: ExternalProvider) =>
provider as unknown as Awaited<ReturnType<InjectedConnector['getProvider']>>;
})(injectedConnectorOptions) as InjectedConnector;

const createWalletConnect2ConnectorWithId = (walletconnect2Id: string) =>
new WalletConnectConnector({
...walletconnect2ConnectorOptions,
options: {
...walletconnect2ConnectorOptions.options,
qrModalOptions: {
...walletconnect2ConnectorOptions.options.qrModalOptions,
explorerRecommendedWalletIds: [walletconnect2Id],
explorerExcludedWalletIds: 'ALL',
},
},
});

// Custom connector from wallet selection
import {
Expand All @@ -131,7 +90,5 @@ export const resolveWagmiConnector = ({

return walletConnection.type === WalletConnectionType.InjectedEip1193 && walletConnection.provider
? createInjectedConnectorWithProvider(walletConnection.provider)
: walletConnection.type === WalletConnectionType.WalletConnect2 && walletConfig.walletconnect2Id
? createWalletConnect2ConnectorWithId(walletConfig.walletconnect2Id)
: connectors.find(({ id }: { id: string }) => id === walletConnectionConfig.wagmiConnectorId);
};
8 changes: 0 additions & 8 deletions src/views/dialogs/OnboardingDialog/ChooseWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import { Button } from '@/components/Button';
import { Icon } from '@/components/Icon';
import { Link } from '@/components/Link';

const aboutWalletsLink = `https://www.dydx.academy/video/defi-wallet`;

export const ChooseWallet = () => {
const stringGetter = useStringGetter();

Expand Down Expand Up @@ -48,12 +46,6 @@ export const ChooseWallet = () => {
</Styled.WalletButton>
))}
</Styled.Wallets>

<Styled.Footer>
<Link href={aboutWalletsLink} withIcon>
About wallets
</Link>
</Styled.Footer>
</>
);
};
Expand Down

0 comments on commit 7b391b8

Please sign in to comment.