Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73eb7aff96 | ||
|
|
6a3c4ec7f6 | ||
|
|
47b6618299 | ||
|
|
def44ad66e | ||
|
|
a6eb90952a |
@@ -1,6 +0,0 @@
|
|||||||
VITE_BASE_URL=https://v4.testnet.dydx.exchange
|
|
||||||
|
|
||||||
VITE_ALCHEMY_API_KEY=FP275q327Yh7qswtZWenbPXdZZdnAFmC
|
|
||||||
|
|
||||||
VITE_WALLETCONNECT1_BRIDGE=wss://api.dydx.exchange/wc/
|
|
||||||
VITE_WALLETCONNECT2_PROJECT_ID=fbe94eaa691fa8d929561f8567062b32
|
|
||||||
@@ -4,7 +4,6 @@ VITE_ALCHEMY_API_KEY=
|
|||||||
|
|
||||||
VITE_PK_ENCRYPTION_KEY=
|
VITE_PK_ENCRYPTION_KEY=
|
||||||
|
|
||||||
VITE_WALLETCONNECT1_BRIDGE=
|
|
||||||
VITE_WALLETCONNECT2_PROJECT_ID=
|
VITE_WALLETCONNECT2_PROJECT_ID=
|
||||||
|
|
||||||
VITE_V3_TOKEN_ADDRESS=
|
VITE_V3_TOKEN_ADDRESS=
|
||||||
@@ -13,6 +13,7 @@ dist
|
|||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
*.key
|
*.key
|
||||||
|
.env
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@
|
|||||||
"@cosmjs/tendermint-rpc": "^0.31.0",
|
"@cosmjs/tendermint-rpc": "^0.31.0",
|
||||||
"@dydxprotocol/v4-abacus": "^0.6.4",
|
"@dydxprotocol/v4-abacus": "^0.6.4",
|
||||||
"@dydxprotocol/v4-client-js": "^0.36.1",
|
"@dydxprotocol/v4-client-js": "^0.36.1",
|
||||||
"@dydxprotocol/v4-localization": "^0.1.28",
|
"@dydxprotocol/v4-localization": "^0.1.24",
|
||||||
"@ethersproject/providers": "^5.7.2",
|
"@ethersproject/providers": "^5.7.2",
|
||||||
"@js-joda/core": "^5.5.3",
|
"@js-joda/core": "^5.5.3",
|
||||||
"@radix-ui/react-collapsible": "^1.0.3",
|
"@radix-ui/react-collapsible": "^1.0.3",
|
||||||
|
|||||||
Generated
+8
-8
@@ -1,5 +1,9 @@
|
|||||||
lockfileVersion: '6.0'
|
lockfileVersion: '6.0'
|
||||||
|
|
||||||
|
settings:
|
||||||
|
autoInstallPeers: true
|
||||||
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@0xsquid/sdk':
|
'@0xsquid/sdk':
|
||||||
specifier: ^1.10.0
|
specifier: ^1.10.0
|
||||||
@@ -29,8 +33,8 @@ dependencies:
|
|||||||
specifier: ^0.36.1
|
specifier: ^0.36.1
|
||||||
version: 0.36.1
|
version: 0.36.1
|
||||||
'@dydxprotocol/v4-localization':
|
'@dydxprotocol/v4-localization':
|
||||||
specifier: ^0.1.28
|
specifier: ^0.1.24
|
||||||
version: 0.1.28
|
version: 0.1.24
|
||||||
'@ethersproject/providers':
|
'@ethersproject/providers':
|
||||||
specifier: ^5.7.2
|
specifier: ^5.7.2
|
||||||
version: 5.7.2
|
version: 5.7.2
|
||||||
@@ -1006,8 +1010,8 @@ packages:
|
|||||||
- utf-8-validate
|
- utf-8-validate
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-localization@0.1.28:
|
/@dydxprotocol/v4-localization@0.1.24:
|
||||||
resolution: {integrity: sha512-g6LwjX7EIRm9HISfSX0H6yhktBCZby5opP/yI2aIUvn2OYyB25WcjLEuEvzW5Bh9XXiLijgLf3Tk91wPKWuFbA==}
|
resolution: {integrity: sha512-zSiu8+/6BWNWZXxe73zUp/UjuLG1Cp5UuhXKtbATqqkeZyVCs01QxbBCTs1MLfgsLh02IrfhXCPHvXnzZyReEw==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/@dydxprotocol/v4-proto@0.2.1:
|
/@dydxprotocol/v4-proto@0.2.1:
|
||||||
@@ -14095,7 +14099,3 @@ packages:
|
|||||||
/zwitch@2.0.4:
|
/zwitch@2.0.4:
|
||||||
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
settings:
|
|
||||||
autoInstallPeers: true
|
|
||||||
excludeLinksFromLockfile: false
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
@@ -8,5 +8,5 @@ export const AVAILABLE_ENVIRONMENTS =
|
|||||||
|
|
||||||
export const CURRENT_ABACUS_DEPLOYMENT = import.meta.env.MODE === 'production' ? 'TESTNET' : 'DEV';
|
export const CURRENT_ABACUS_DEPLOYMENT = import.meta.env.MODE === 'production' ? 'TESTNET' : 'DEV';
|
||||||
export const ENVIRONMENT_CONFIG_MAP = environments.environments;
|
export const ENVIRONMENT_CONFIG_MAP = environments.environments;
|
||||||
export type DydxNetwork = (typeof AVAILABLE_ENVIRONMENTS.environments)[number];
|
export type DydxNetwork = keyof typeof ENVIRONMENT_CONFIG_MAP;
|
||||||
export const DEFAULT_APP_ENVIRONMENT = AVAILABLE_ENVIRONMENTS.default as DydxNetwork;
|
export const DEFAULT_APP_ENVIRONMENT = AVAILABLE_ENVIRONMENTS.default as DydxNetwork;
|
||||||
|
|||||||
+12
-69
@@ -32,7 +32,6 @@ export enum WalletConnectionType {
|
|||||||
CoinbaseWalletSdk = 'coinbaseWalletSdk',
|
CoinbaseWalletSdk = 'coinbaseWalletSdk',
|
||||||
CosmosSigner = 'CosmosSigner',
|
CosmosSigner = 'CosmosSigner',
|
||||||
InjectedEip1193 = 'injectedEip1193',
|
InjectedEip1193 = 'injectedEip1193',
|
||||||
WalletConnect1 = 'walletConnect1',
|
|
||||||
WalletConnect2 = 'walletConnect2',
|
WalletConnect2 = 'walletConnect2',
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,10 +61,6 @@ export const walletConnectionTypes: Record<WalletConnectionType, WalletConnectio
|
|||||||
name: 'injected EIP-1193 provider',
|
name: 'injected EIP-1193 provider',
|
||||||
wagmiConnectorId: 'injected',
|
wagmiConnectorId: 'injected',
|
||||||
},
|
},
|
||||||
[WalletConnectionType.WalletConnect1]: {
|
|
||||||
name: 'WalletConnect 1.0',
|
|
||||||
wagmiConnectorId: 'walletConnectLegacy',
|
|
||||||
},
|
|
||||||
[WalletConnectionType.WalletConnect2]: {
|
[WalletConnectionType.WalletConnect2]: {
|
||||||
name: 'WalletConnect 2.0',
|
name: 'WalletConnect 2.0',
|
||||||
wagmiConnectorId: 'walletConnect',
|
wagmiConnectorId: 'walletConnect',
|
||||||
@@ -92,7 +87,6 @@ export enum WalletType {
|
|||||||
Rainbow = 'RAINBOW_WALLET',
|
Rainbow = 'RAINBOW_WALLET',
|
||||||
TokenPocket = 'TOKEN_POCKET',
|
TokenPocket = 'TOKEN_POCKET',
|
||||||
TrustWallet = 'TRUST_WALLET',
|
TrustWallet = 'TRUST_WALLET',
|
||||||
WalletConnect = 'WALLETCONNECT',
|
|
||||||
WalletConnect2 = 'WALLETCONNECT_2',
|
WalletConnect2 = 'WALLETCONNECT_2',
|
||||||
// TestWallet = 'TEST_WALLET',
|
// TestWallet = 'TEST_WALLET',
|
||||||
OtherWallet = 'OTHER_WALLET',
|
OtherWallet = 'OTHER_WALLET',
|
||||||
@@ -104,7 +98,6 @@ type WalletConfig = {
|
|||||||
icon: string;
|
icon: string;
|
||||||
connectionTypes: WalletConnectionType[];
|
connectionTypes: WalletConnectionType[];
|
||||||
matchesInjectedEip1193?: (provider: ExternalProvider & any) => boolean;
|
matchesInjectedEip1193?: (provider: ExternalProvider & any) => boolean;
|
||||||
walletconnect1Name?: string;
|
|
||||||
walletconnect2Id?: string;
|
walletconnect2Id?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,7 +110,6 @@ export const wallets: Record<WalletType, WalletConfig> = {
|
|||||||
WalletConnectionType.InjectedEip1193,
|
WalletConnectionType.InjectedEip1193,
|
||||||
// WalletConnectionType.CoinbaseWalletSdk,
|
// WalletConnectionType.CoinbaseWalletSdk,
|
||||||
WalletConnectionType.WalletConnect2,
|
WalletConnectionType.WalletConnect2,
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
],
|
||||||
matchesInjectedEip1193: (provider) =>
|
matchesInjectedEip1193: (provider) =>
|
||||||
Object.entries(wallets).every(
|
Object.entries(wallets).every(
|
||||||
@@ -131,30 +123,23 @@ export const wallets: Record<WalletType, WalletConfig> = {
|
|||||||
type: WalletType.BitKeep,
|
type: WalletType.BitKeep,
|
||||||
stringKey: STRING_KEYS.BITKEEP,
|
stringKey: STRING_KEYS.BITKEEP,
|
||||||
icon: BitkeepIcon,
|
icon: BitkeepIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isBitKeep, // isBitKeepChrome, isBitEthereum
|
matchesInjectedEip1193: (provider) => provider.isBitKeep, // isBitKeepChrome, isBitEthereum
|
||||||
walletconnect1Name: 'bitkeep',
|
|
||||||
walletconnect2Id: '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662',
|
walletconnect2Id: '38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662',
|
||||||
},
|
},
|
||||||
[WalletType.BitPie]: {
|
[WalletType.BitPie]: {
|
||||||
type: WalletType.BitPie,
|
type: WalletType.BitPie,
|
||||||
stringKey: STRING_KEYS.BITPIE,
|
stringKey: STRING_KEYS.BITPIE,
|
||||||
icon: BitpieIcon,
|
icon: BitpieIcon,
|
||||||
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1],
|
connectionTypes: [WalletConnectionType.InjectedEip1193],
|
||||||
matchesInjectedEip1193: (provider) => provider.isBitpie,
|
matchesInjectedEip1193: (provider) => provider.isBitpie,
|
||||||
walletconnect1Name: 'bitpie',
|
|
||||||
},
|
},
|
||||||
[WalletType.CloverWallet]: {
|
[WalletType.CloverWallet]: {
|
||||||
type: WalletType.CloverWallet,
|
type: WalletType.CloverWallet,
|
||||||
stringKey: STRING_KEYS.CLOVER_WALLET,
|
stringKey: STRING_KEYS.CLOVER_WALLET,
|
||||||
icon: CloverWalletIcon,
|
icon: CloverWalletIcon,
|
||||||
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1],
|
connectionTypes: [WalletConnectionType.InjectedEip1193],
|
||||||
matchesInjectedEip1193: (provider) => provider.isClover,
|
matchesInjectedEip1193: (provider) => provider.isClover,
|
||||||
// walletconnect1Name: 'clover',
|
|
||||||
},
|
},
|
||||||
[WalletType.CoinbaseWallet]: {
|
[WalletType.CoinbaseWallet]: {
|
||||||
type: WalletType.CoinbaseWallet,
|
type: WalletType.CoinbaseWallet,
|
||||||
@@ -163,33 +148,23 @@ export const wallets: Record<WalletType, WalletConfig> = {
|
|||||||
connectionTypes: [
|
connectionTypes: [
|
||||||
WalletConnectionType.CoinbaseWalletSdk,
|
WalletConnectionType.CoinbaseWalletSdk,
|
||||||
WalletConnectionType.InjectedEip1193,
|
WalletConnectionType.InjectedEip1193,
|
||||||
WalletConnectionType.WalletConnect1,
|
WalletConnectionType.WalletConnect2,
|
||||||
],
|
],
|
||||||
matchesInjectedEip1193: (provider) => provider.isCoinbaseWallet, // provider.selectedProvider?.isCoinbaseWallet,
|
matchesInjectedEip1193: (provider) => provider.isCoinbaseWallet, // provider.selectedProvider?.isCoinbaseWallet,
|
||||||
walletconnect1Name: 'coinbase',
|
|
||||||
},
|
},
|
||||||
[WalletType.Coin98]: {
|
[WalletType.Coin98]: {
|
||||||
type: WalletType.Coin98,
|
type: WalletType.Coin98,
|
||||||
stringKey: STRING_KEYS.COIN98,
|
stringKey: STRING_KEYS.COIN98,
|
||||||
icon: Coin98Icon,
|
icon: Coin98Icon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isCoin98,
|
matchesInjectedEip1193: (provider) => provider.isCoin98,
|
||||||
walletconnect1Name: 'coin98',
|
|
||||||
walletconnect2Id: '2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01',
|
walletconnect2Id: '2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01',
|
||||||
},
|
},
|
||||||
[WalletType.HuobiWallet]: {
|
[WalletType.HuobiWallet]: {
|
||||||
type: WalletType.HuobiWallet,
|
type: WalletType.HuobiWallet,
|
||||||
stringKey: STRING_KEYS.HUOBI_WALLET,
|
stringKey: STRING_KEYS.HUOBI_WALLET,
|
||||||
icon: HuobiIcon,
|
icon: HuobiIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isHbWallet,
|
matchesInjectedEip1193: (provider) => provider.isHbWallet,
|
||||||
walletconnect2Id: '797c615e2c556b610c048eb35535f212c0dd58de5d03e763120e90a7d1350a77',
|
walletconnect2Id: '797c615e2c556b610c048eb35535f212c0dd58de5d03e763120e90a7d1350a77',
|
||||||
},
|
},
|
||||||
@@ -197,74 +172,48 @@ export const wallets: Record<WalletType, WalletConfig> = {
|
|||||||
type: WalletType.ImToken,
|
type: WalletType.ImToken,
|
||||||
stringKey: STRING_KEYS.IMTOKEN,
|
stringKey: STRING_KEYS.IMTOKEN,
|
||||||
icon: ImTokenIcon,
|
icon: ImTokenIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isImToken,
|
matchesInjectedEip1193: (provider) => provider.isImToken,
|
||||||
walletconnect1Name: 'imtoken',
|
|
||||||
walletconnect2Id: 'ef333840daf915aafdc4a004525502d6d49d77bd9c65e0642dbaefb3c2893bef',
|
walletconnect2Id: 'ef333840daf915aafdc4a004525502d6d49d77bd9c65e0642dbaefb3c2893bef',
|
||||||
},
|
},
|
||||||
[WalletType.MathWallet]: {
|
[WalletType.MathWallet]: {
|
||||||
type: WalletType.MathWallet,
|
type: WalletType.MathWallet,
|
||||||
stringKey: STRING_KEYS.MATH_WALLET,
|
stringKey: STRING_KEYS.MATH_WALLET,
|
||||||
icon: MathWalletIcon,
|
icon: MathWalletIcon,
|
||||||
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect1],
|
connectionTypes: [WalletConnectionType.InjectedEip1193],
|
||||||
matchesInjectedEip1193: (provider) => provider.isMathWallet,
|
matchesInjectedEip1193: (provider) => provider.isMathWallet,
|
||||||
walletconnect1Name: 'math',
|
|
||||||
walletconnect2Id: '7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26',
|
walletconnect2Id: '7674bb4e353bf52886768a3ddc2a4562ce2f4191c80831291218ebd90f5f5e26',
|
||||||
},
|
},
|
||||||
[WalletType.MetaMask]: {
|
[WalletType.MetaMask]: {
|
||||||
type: WalletType.MetaMask,
|
type: WalletType.MetaMask,
|
||||||
stringKey: STRING_KEYS.METAMASK,
|
stringKey: STRING_KEYS.METAMASK,
|
||||||
icon: MetaMaskIcon,
|
icon: MetaMaskIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: isMetaMask,
|
matchesInjectedEip1193: isMetaMask,
|
||||||
walletconnect1Name: 'metamask',
|
|
||||||
walletconnect2Id: 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96',
|
walletconnect2Id: 'c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96',
|
||||||
},
|
},
|
||||||
[WalletType.Rainbow]: {
|
[WalletType.Rainbow]: {
|
||||||
type: WalletType.Rainbow,
|
type: WalletType.Rainbow,
|
||||||
stringKey: STRING_KEYS.RAINBOW_WALLET,
|
stringKey: STRING_KEYS.RAINBOW_WALLET,
|
||||||
icon: RainbowIcon,
|
icon: RainbowIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isRainbowWallet,
|
matchesInjectedEip1193: (provider) => provider.isRainbowWallet,
|
||||||
walletconnect1Name: 'rainbow',
|
|
||||||
walletconnect2Id: '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369',
|
walletconnect2Id: '1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369',
|
||||||
},
|
},
|
||||||
[WalletType.TokenPocket]: {
|
[WalletType.TokenPocket]: {
|
||||||
type: WalletType.TokenPocket,
|
type: WalletType.TokenPocket,
|
||||||
stringKey: STRING_KEYS.TOKEN_POCKET,
|
stringKey: STRING_KEYS.TOKEN_POCKET,
|
||||||
icon: TokenPocketIcon,
|
icon: TokenPocketIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isTokenPocket,
|
matchesInjectedEip1193: (provider) => provider.isTokenPocket,
|
||||||
walletconnect1Name: 'tokenpocket',
|
|
||||||
walletconnect2Id: '20459438007b75f4f4acb98bf29aa3b800550309646d375da5fd4aac6c2a2c66',
|
walletconnect2Id: '20459438007b75f4f4acb98bf29aa3b800550309646d375da5fd4aac6c2a2c66',
|
||||||
},
|
},
|
||||||
[WalletType.TrustWallet]: {
|
[WalletType.TrustWallet]: {
|
||||||
type: WalletType.TrustWallet,
|
type: WalletType.TrustWallet,
|
||||||
stringKey: STRING_KEYS.TRUST_WALLET,
|
stringKey: STRING_KEYS.TRUST_WALLET,
|
||||||
icon: TrustWalletIcon,
|
icon: TrustWalletIcon,
|
||||||
connectionTypes: [
|
connectionTypes: [WalletConnectionType.InjectedEip1193, WalletConnectionType.WalletConnect2],
|
||||||
WalletConnectionType.InjectedEip1193,
|
|
||||||
WalletConnectionType.WalletConnect2,
|
|
||||||
WalletConnectionType.WalletConnect1,
|
|
||||||
],
|
|
||||||
matchesInjectedEip1193: (provider) => provider.isTrust,
|
matchesInjectedEip1193: (provider) => provider.isTrust,
|
||||||
walletconnect1Name: 'trust',
|
|
||||||
walletconnect2Id: '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0',
|
walletconnect2Id: '4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0',
|
||||||
},
|
},
|
||||||
[WalletType.WalletConnect2]: {
|
[WalletType.WalletConnect2]: {
|
||||||
@@ -273,12 +222,6 @@ export const wallets: Record<WalletType, WalletConfig> = {
|
|||||||
icon: WalletConnectIcon,
|
icon: WalletConnectIcon,
|
||||||
connectionTypes: [WalletConnectionType.WalletConnect2],
|
connectionTypes: [WalletConnectionType.WalletConnect2],
|
||||||
},
|
},
|
||||||
[WalletType.WalletConnect]: {
|
|
||||||
type: WalletType.WalletConnect,
|
|
||||||
stringKey: STRING_KEYS.WALLET_CONNECT,
|
|
||||||
icon: WalletConnectIcon,
|
|
||||||
connectionTypes: [WalletConnectionType.WalletConnect1],
|
|
||||||
},
|
|
||||||
[WalletType.Keplr]: {
|
[WalletType.Keplr]: {
|
||||||
type: WalletType.Keplr,
|
type: WalletType.Keplr,
|
||||||
stringKey: STRING_KEYS.KEPLR,
|
stringKey: STRING_KEYS.KEPLR,
|
||||||
|
|||||||
@@ -2,27 +2,23 @@ import { WalletType } from '@/constants/wallets';
|
|||||||
|
|
||||||
import { isTruthy } from '@/lib/isTruthy';
|
import { isTruthy } from '@/lib/isTruthy';
|
||||||
|
|
||||||
import { useSelectedNetwork } from './useSelectedNetwork';
|
|
||||||
|
|
||||||
export const useDisplayedWallets = () => {
|
export const useDisplayedWallets = () => {
|
||||||
const { selectedNetwork } = useSelectedNetwork();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
WalletType.MetaMask,
|
WalletType.MetaMask,
|
||||||
|
|
||||||
import.meta.env.MODE !== 'production' && WalletType.Keplr,
|
import.meta.env.MODE !== 'production' && WalletType.Keplr,
|
||||||
|
|
||||||
WalletType.WalletConnect2,
|
WalletType.WalletConnect2,
|
||||||
WalletType.WalletConnect,
|
|
||||||
|
|
||||||
WalletType.CoinbaseWallet,
|
WalletType.CoinbaseWallet,
|
||||||
|
|
||||||
WalletType.ImToken,
|
// Hide these wallet options until they can be properly tested on mainnet
|
||||||
WalletType.Rainbow,
|
// WalletType.ImToken,
|
||||||
WalletType.TrustWallet,
|
// WalletType.Rainbow,
|
||||||
WalletType.HuobiWallet,
|
// WalletType.TrustWallet,
|
||||||
WalletType.BitKeep,
|
// WalletType.HuobiWallet,
|
||||||
WalletType.Coin98,
|
// WalletType.BitKeep,
|
||||||
|
// WalletType.Coin98,
|
||||||
|
|
||||||
WalletType.OtherWallet,
|
WalletType.OtherWallet,
|
||||||
].filter(isTruthy);
|
].filter(isTruthy);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import { useLocalStorage } from '@/hooks';
|
|||||||
import { initializeLocalization } from '@/state/app';
|
import { initializeLocalization } from '@/state/app';
|
||||||
|
|
||||||
import abacusStateManager from '@/lib/abacus';
|
import abacusStateManager from '@/lib/abacus';
|
||||||
import { validateAgainstAvailableEnvironments } from '@/lib/network';
|
|
||||||
|
|
||||||
export const useInitializePage = () => {
|
export const useInitializePage = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@@ -19,7 +18,6 @@ export const useInitializePage = () => {
|
|||||||
const [localStorageNetwork] = useLocalStorage<DydxNetwork>({
|
const [localStorageNetwork] = useLocalStorage<DydxNetwork>({
|
||||||
key: LocalStorageKey.SelectedNetwork,
|
key: LocalStorageKey.SelectedNetwork,
|
||||||
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
||||||
validateFn: validateAgainstAvailableEnvironments,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import { useAccounts, useLocalStorage } from '@/hooks';
|
|||||||
import { setSelectedNetwork } from '@/state/app';
|
import { setSelectedNetwork } from '@/state/app';
|
||||||
import { getSelectedNetwork } from '@/state/appSelectors';
|
import { getSelectedNetwork } from '@/state/appSelectors';
|
||||||
|
|
||||||
import { validateAgainstAvailableEnvironments } from '@/lib/network';
|
|
||||||
|
|
||||||
export const useSelectedNetwork = (): {
|
export const useSelectedNetwork = (): {
|
||||||
switchNetwork: (network: DydxNetwork) => void;
|
switchNetwork: (network: DydxNetwork) => void;
|
||||||
selectedNetwork: DydxNetwork;
|
selectedNetwork: DydxNetwork;
|
||||||
@@ -22,7 +20,6 @@ export const useSelectedNetwork = (): {
|
|||||||
const [, setLocalStorageNetwork] = useLocalStorage<DydxNetwork>({
|
const [, setLocalStorageNetwork] = useLocalStorage<DydxNetwork>({
|
||||||
key: LocalStorageKey.SelectedNetwork,
|
key: LocalStorageKey.SelectedNetwork,
|
||||||
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
||||||
validateFn: validateAgainstAvailableEnvironments,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const switchNetwork = useCallback(
|
const switchNetwork = useCallback(
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
import environments from '../../../public/configs/env.json';
|
|
||||||
|
|
||||||
import { validateAgainstAvailableEnvironments } from '../network';
|
|
||||||
|
|
||||||
describe('validateAgainstAvailableEnvironments', () => {
|
|
||||||
describe('production environment', () => {
|
|
||||||
beforeAll(() => {
|
|
||||||
jest.mock('../../constants/networks', () => ({
|
|
||||||
AVAILABLE_ENVIRONMENTS: {
|
|
||||||
environments: [],
|
|
||||||
default: 'dydxprotocol-testnet-dydx',
|
|
||||||
}, //environments.deployments.TESTNET,
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
jest.unmock('../../constants/networks');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Returns true for valid environments', () => {
|
|
||||||
expect(validateAgainstAvailableEnvironments('dydxprotocol-testnet-dydx')).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Returns false for invalid environments', () => {
|
|
||||||
expect(validateAgainstAvailableEnvironments('dydxprotocol-dev')).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('staging environment', () => {
|
|
||||||
it('Returns true for valid environments', () => {
|
|
||||||
expect(validateAgainstAvailableEnvironments('dydxprotocol-dev')).toEqual(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Returns false for invalid environments', () => {
|
|
||||||
expect(validateAgainstAvailableEnvironments('INVALID')).toEqual(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -45,15 +45,11 @@ describe('getStringsForDateTimeDiff', () => {
|
|||||||
|
|
||||||
describe('getStringsForTimeInterval', () => {
|
describe('getStringsForTimeInterval', () => {
|
||||||
it.each([
|
it.each([
|
||||||
[Duration.fromObject({ months: 2 }), '2', 'APP.GENERAL.TIME_STRINGS.MONTHS_ABBREVIATED'],
|
[Duration.fromObject({ months: 2 }), '2', 'MONTHS_ABBREVIATED'],
|
||||||
[Duration.fromObject({ weeks: 3, days: 2 }), '3', 'APP.GENERAL.TIME_STRINGS.WEEKS_ABBREVIATED'],
|
[Duration.fromObject({ weeks: 3, days: 2 }), '3', 'WEEKS_ABBREVIATED'],
|
||||||
[Duration.fromObject({ days: 5, hours: 12 }), '6', 'APP.GENERAL.TIME_STRINGS.DAYS_ABBREVIATED'],
|
[Duration.fromObject({ days: 5, hours: 12 }), '6', 'DAYS_ABBREVIATED'],
|
||||||
[
|
[Duration.fromObject({ hours: 8, minutes: 30 }), '9', 'HOURS_ABBREVIATED'],
|
||||||
Duration.fromObject({ hours: 8, minutes: 30 }),
|
[Duration.fromObject({ minutes: 45 }), '45', 'MINUTES_ABBREVIATED'],
|
||||||
'9',
|
|
||||||
'APP.GENERAL.TIME_STRINGS.HOURS_ABBREVIATED',
|
|
||||||
],
|
|
||||||
[Duration.fromObject({ minutes: 45 }), '45', 'APP.GENERAL.TIME_STRINGS.MINUTES_ABBREVIATED'],
|
|
||||||
])(
|
])(
|
||||||
'returns the correct timeString and unitStringKey',
|
'returns the correct timeString and unitStringKey',
|
||||||
(timeInterval, expectedTimeString, expectedUnitStringKey) => {
|
(timeInterval, expectedTimeString, expectedUnitStringKey) => {
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import { AVAILABLE_ENVIRONMENTS, type DydxNetwork } from '@/constants/networks';
|
|
||||||
|
|
||||||
export const validateAgainstAvailableEnvironments = (value: DydxNetwork) =>
|
|
||||||
AVAILABLE_ENVIRONMENTS.environments.includes(value);
|
|
||||||
@@ -10,7 +10,7 @@ export const getTimestamp = (value?: BigNumberish | null) =>
|
|||||||
? value
|
? value
|
||||||
: typeof value === 'string'
|
: typeof value === 'string'
|
||||||
? new Date(value).getTime()
|
? new Date(value).getTime()
|
||||||
: new Date(value.toNumber()).getTime()
|
: new Date(value.toString()).getTime()
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
export const getStringsForDateTimeDiff = (dateTime: DateTime) => {
|
export const getStringsForDateTimeDiff = (dateTime: DateTime) => {
|
||||||
@@ -77,4 +77,4 @@ export const formatSeconds = (seconds: number) => {
|
|||||||
const minutes = Math.floor(seconds / 60);
|
const minutes = Math.floor(seconds / 60);
|
||||||
const remainingSeconds = seconds % 60;
|
const remainingSeconds = seconds % 60;
|
||||||
return `${getTimeString(minutes)}:${getTimeString(remainingSeconds)}`;
|
return `${getTimeString(minutes)}:${getTimeString(remainingSeconds)}`;
|
||||||
};
|
}
|
||||||
|
|||||||
+3
-27
@@ -87,23 +87,16 @@ const injectedConnectorOptions = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const walletconnect1ConnectorOptions = {
|
|
||||||
chains,
|
|
||||||
options: {
|
|
||||||
bridge: import.meta.env.VITE_WALLETCONNECT1_BRIDGE,
|
|
||||||
qrcode: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const walletconnect2ConnectorOptions: ConstructorParameters<typeof WalletConnectConnector>[0] = {
|
const walletconnect2ConnectorOptions: ConstructorParameters<typeof WalletConnectConnector>[0] = {
|
||||||
chains,
|
chains,
|
||||||
options: {
|
options: {
|
||||||
projectId: import.meta.env.VITE_WALLETCONNECT2_PROJECT_ID,
|
projectId: import.meta.env.VITE_WALLETCONNECT2_PROJECT_ID,
|
||||||
metadata: {
|
metadata: {
|
||||||
|
// TODO: update to local URLs/images
|
||||||
name: 'dYdX',
|
name: 'dYdX',
|
||||||
description: '',
|
description: '',
|
||||||
url: import.meta.env.VITE_BASE_URL,
|
url: 'https://trade.dydx.exchange',
|
||||||
icons: [`${import.meta.env.VITE_BASE_URL}/cbw-image.png}`],
|
icons: ['https://trade.dydx.exchange/cbw-image.png'],
|
||||||
},
|
},
|
||||||
showQrModal: true,
|
showQrModal: true,
|
||||||
qrModalOptions: {
|
qrModalOptions: {
|
||||||
@@ -142,7 +135,6 @@ const connectors = [
|
|||||||
reloadOnDisconnect: false,
|
reloadOnDisconnect: false,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
new WalletConnectLegacyConnector(walletconnect1ConnectorOptions),
|
|
||||||
new WalletConnectConnector(walletconnect2ConnectorOptions),
|
new WalletConnectConnector(walletconnect2ConnectorOptions),
|
||||||
new InjectedConnector(injectedConnectorOptions),
|
new InjectedConnector(injectedConnectorOptions),
|
||||||
];
|
];
|
||||||
@@ -165,19 +157,6 @@ const createInjectedConnectorWithProvider = (provider: ExternalProvider) =>
|
|||||||
provider as unknown as Awaited<ReturnType<InjectedConnector['getProvider']>>;
|
provider as unknown as Awaited<ReturnType<InjectedConnector['getProvider']>>;
|
||||||
})(injectedConnectorOptions) as InjectedConnector;
|
})(injectedConnectorOptions) as InjectedConnector;
|
||||||
|
|
||||||
// Create a custom wagmi WalletConnectLegacyConnector with a modal showing only wallet links matching the given name
|
|
||||||
const createWalletConnect1ConnectorWithName = (walletconnect1Name: string) =>
|
|
||||||
new WalletConnectLegacyConnector({
|
|
||||||
...walletconnect1ConnectorOptions,
|
|
||||||
options: {
|
|
||||||
...walletconnect1ConnectorOptions.options,
|
|
||||||
qrcodeModalOptions: {
|
|
||||||
desktopLinks: [walletconnect1Name],
|
|
||||||
mobileLinks: [walletconnect1Name],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const createWalletConnect2ConnectorWithId = (walletconnect2Id: string) =>
|
const createWalletConnect2ConnectorWithId = (walletconnect2Id: string) =>
|
||||||
new WalletConnectConnector({
|
new WalletConnectConnector({
|
||||||
...walletconnect2ConnectorOptions,
|
...walletconnect2ConnectorOptions,
|
||||||
@@ -213,9 +192,6 @@ export const resolveWagmiConnector = ({
|
|||||||
|
|
||||||
return walletConnection.type === WalletConnectionType.InjectedEip1193 && walletConnection.provider
|
return walletConnection.type === WalletConnectionType.InjectedEip1193 && walletConnection.provider
|
||||||
? createInjectedConnectorWithProvider(walletConnection.provider)
|
? createInjectedConnectorWithProvider(walletConnection.provider)
|
||||||
: walletConnection.type === WalletConnectionType.WalletConnect1 &&
|
|
||||||
walletConfig.walletconnect1Name
|
|
||||||
? createWalletConnect1ConnectorWithName(walletConfig.walletconnect1Name)
|
|
||||||
: walletConnection.type === WalletConnectionType.WalletConnect2 && walletConfig.walletconnect2Id
|
: walletConnection.type === WalletConnectionType.WalletConnect2 && walletConfig.walletconnect2Id
|
||||||
? createWalletConnect2ConnectorWithId(walletConfig.walletconnect2Id)
|
? createWalletConnect2ConnectorWithId(walletConfig.walletconnect2Id)
|
||||||
: connectors.find(({ id }: { id: string }) => id === walletConnectionConfig.wagmiConnectorId);
|
: connectors.find(({ id }: { id: string }) => id === walletConnectionConfig.wagmiConnectorId);
|
||||||
|
|||||||
@@ -45,12 +45,6 @@ export const getWalletConnection = ({
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WalletConnectionType.WalletConnect1: {
|
|
||||||
return {
|
|
||||||
type: WalletConnectionType.WalletConnect1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
case WalletConnectionType.WalletConnect2: {
|
case WalletConnectionType.WalletConnect2: {
|
||||||
return {
|
return {
|
||||||
type: WalletConnectionType.WalletConnect2,
|
type: WalletConnectionType.WalletConnect2,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { LocalStorageKey } from '@/constants/localStorage';
|
|||||||
import { DEFAULT_APP_ENVIRONMENT, type DydxNetwork } from '@/constants/networks';
|
import { DEFAULT_APP_ENVIRONMENT, type DydxNetwork } from '@/constants/networks';
|
||||||
|
|
||||||
import { getLocalStorage } from '@/lib/localStorage';
|
import { getLocalStorage } from '@/lib/localStorage';
|
||||||
import { validateAgainstAvailableEnvironments } from '@/lib/network';
|
|
||||||
|
|
||||||
export interface AppState {
|
export interface AppState {
|
||||||
apiState: AbacusApiState | undefined;
|
apiState: AbacusApiState | undefined;
|
||||||
@@ -20,7 +19,6 @@ const initialState: AppState = {
|
|||||||
selectedNetwork: getLocalStorage({
|
selectedNetwork: getLocalStorage({
|
||||||
key: LocalStorageKey.SelectedNetwork,
|
key: LocalStorageKey.SelectedNetwork,
|
||||||
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
defaultValue: DEFAULT_APP_ENVIRONMENT,
|
||||||
validateFn: validateAgainstAvailableEnvironments,
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ export const DisconnectDialog = ({ setIsOpen }: ElementProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog isOpen setIsOpen={setIsOpen} title={stringGetter({ key: STRING_KEYS.DISCONNECT })}>
|
<Dialog isOpen setIsOpen={setIsOpen} title="Disconnect">
|
||||||
<Styled.Content>
|
<Styled.Content>
|
||||||
<p>{stringGetter({ key: STRING_KEYS.DISCONNECT_CONFIRMATION })}</p>
|
<p>Are you sure you want to disconnect your account?</p>
|
||||||
<Styled.ButtonRow>
|
<Styled.ButtonRow>
|
||||||
<Close asChild>
|
<Close asChild>
|
||||||
<Button action={ButtonAction.Destroy} onClick={disconnect}>
|
<Button action={ButtonAction.Destroy} onClick={disconnect}>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import { useDisplayedWallets } from '@/hooks/useDisplayedWallets';
|
|||||||
import { breakpoints } from '@/styles';
|
import { breakpoints } from '@/styles';
|
||||||
import { layoutMixins } from '@/styles/layoutMixins';
|
import { layoutMixins } from '@/styles/layoutMixins';
|
||||||
|
|
||||||
const aboutWalletsLink = `https://www.dydx.academy/video/defi-wallet`;
|
const aboutWalletsLink = `https://www.dydxacademy.info/educational-video-series/onboarding-to-defi-with-dydx`;
|
||||||
|
|
||||||
export const ChooseWallet = () => {
|
export const ChooseWallet = () => {
|
||||||
const stringGetter = useStringGetter();
|
const stringGetter = useStringGetter();
|
||||||
@@ -34,14 +34,7 @@ export const ChooseWallet = () => {
|
|||||||
<Styled.AlertMessage type={AlertType.Error}>
|
<Styled.AlertMessage type={AlertType.Error}>
|
||||||
{
|
{
|
||||||
<h4>
|
<h4>
|
||||||
{stringGetter({
|
Couldn't connect to {stringGetter({ key: wallets[selectedWalletType].stringKey })}.
|
||||||
key: STRING_KEYS.COULD_NOT_CONNECT,
|
|
||||||
params: {
|
|
||||||
WALLET: stringGetter({
|
|
||||||
key: wallets[selectedWalletType].stringKey,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</h4>
|
</h4>
|
||||||
}
|
}
|
||||||
{selectedWalletError}
|
{selectedWalletError}
|
||||||
|
|||||||
Reference in New Issue
Block a user