Compare commits

..
Author SHA1 Message Date
jaredvu c0a00acdc6 Add validationFn and update tests 2023-10-15 22:11:41 -07:00
aleka c40f5eb549 update about wallets link and localized string nits (#69)
* update about wallets link and localized string nits

* udpate wallet connect2 metadata
2023-10-12 17:10:51 -04:00
20 changed files with 532 additions and 489 deletions
+1 -1
View File
@@ -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.24", "@dydxprotocol/v4-localization": "^0.1.28",
"@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",
+8 -8
View File
@@ -1,9 +1,5 @@
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
@@ -33,8 +29,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.24 specifier: ^0.1.28
version: 0.1.24 version: 0.1.28
'@ethersproject/providers': '@ethersproject/providers':
specifier: ^5.7.2 specifier: ^5.7.2
version: 5.7.2 version: 5.7.2
@@ -1010,8 +1006,8 @@ packages:
- utf-8-validate - utf-8-validate
dev: false dev: false
/@dydxprotocol/v4-localization@0.1.24: /@dydxprotocol/v4-localization@0.1.28:
resolution: {integrity: sha512-zSiu8+/6BWNWZXxe73zUp/UjuLG1Cp5UuhXKtbATqqkeZyVCs01QxbBCTs1MLfgsLh02IrfhXCPHvXnzZyReEw==} resolution: {integrity: sha512-g6LwjX7EIRm9HISfSX0H6yhktBCZby5opP/yI2aIUvn2OYyB25WcjLEuEvzW5Bh9XXiLijgLf3Tk91wPKWuFbA==}
dev: false dev: false
/@dydxprotocol/v4-proto@0.2.1: /@dydxprotocol/v4-proto@0.2.1:
@@ -14099,3 +14095,7 @@ 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.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 193 KiB

-26
View File
@@ -35,8 +35,6 @@
"name": "v4 Dev", "name": "v4 Dev",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -96,8 +94,6 @@
"name": "v4 Dev 2", "name": "v4 Dev 2",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -156,8 +152,6 @@
"name": "v4 Dev 4", "name": "v4 Dev 4",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -216,8 +210,6 @@
"name": "v4 Dev 5", "name": "v4 Dev 5",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -276,8 +268,6 @@
"name": "v4 Staging", "name": "v4 Staging",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -340,8 +330,6 @@
"name": "v4 Staging West", "name": "v4 Staging West",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydxprotocol-testnet", "dydxChainId": "dydxprotocol-testnet",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -404,8 +392,6 @@
"name": "v4 Public Testnet", "name": "v4 Public Testnet",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -470,8 +456,6 @@
"name": "v4 Public Testnet/dYdX", "name": "v4 Public Testnet/dYdX",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -535,8 +519,6 @@
"name": "v4 Public Testnet/DSRV", "name": "v4 Public Testnet/DSRV",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -600,8 +582,6 @@
"name": "v4 Public Testnet/nodefleet", "name": "v4 Public Testnet/nodefleet",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -665,8 +645,6 @@
"name": "v4 Public Testnet/KingNodes", "name": "v4 Public Testnet/KingNodes",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -730,8 +708,6 @@
"name": "v4 Public Testnet/Liquify", "name": "v4 Public Testnet/Liquify",
"ethereumChainId": "5", "ethereumChainId": "5",
"dydxChainId": "dydx-testnet-3", "dydxChainId": "dydx-testnet-3",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": false, "isMainNet": false,
"tokens": { "tokens": {
"chain": { "chain": {
@@ -795,8 +771,6 @@
"name": "v4", "name": "v4",
"ethereumChainId": "1", "ethereumChainId": "1",
"dydxChainId": "[mainnet chain id]", "dydxChainId": "[mainnet chain id]",
"chainName": "dYdX Chain",
"chainLogo": "dydx-chain.png",
"isMainNet": true, "isMainNet": true,
"tokens": { "tokens": {
"comment": "Change according to mainnet release", "comment": "Change according to mainnet release",
+79 -69
View File
@@ -38,7 +38,8 @@
"config":{ "config":{
"comment":"MetaMask", "comment":"MetaMask",
"iosMinVersion":"0", "iosMinVersion":"0",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/metamask.png",
"image":"metamask.png",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"connections":[ "connections":[
{ {
@@ -46,17 +47,10 @@
"native":"metamask:", "native":"metamask:",
"universal":"https://metamask.app.link" "universal":"https://metamask.app.link"
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData",
"wallet_addEthereumChain"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "METAMASK", "analyticEvent":"METAMASK"
"imageName": "metamask.png"
} }
}, },
{ {
@@ -96,7 +90,8 @@
"config":{ "config":{
"comment":"Coinbase", "comment":"Coinbase",
"iosMinVersion":"1.8.0", "iosMinVersion":"1.8.0",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/coinbase-wallet.png",
"image":"coinbase-wallet.png",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"connections":[ "connections":[
{ {
@@ -104,17 +99,10 @@
"native":"cbwallet:", "native":"cbwallet:",
"universal":"" "universal":""
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData",
"wallet_addEthereumChain"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "COINBASE_WALLET", "analyticEvent":"COINBASE_WALLET"
"imageName": "coinbase-wallet.png"
} }
}, },
{ {
@@ -154,23 +142,18 @@
"config":{ "config":{
"comment":"imToken", "comment":"imToken",
"iosMinVersion":"0", "iosMinVersion":"0",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/imtoken.png",
"image":"imtoken.png",
"connections":[ "connections":[
{ {
"type": "walletConnectV2", "type":"walletConnect",
"native":"imtokenv2:", "native":"imtokenv2:",
"universal":"" "universal":""
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "IMTOKEN", "analyticEvent":"IMTOKEN"
"imageName": "imtoken.png"
} }
}, },
{ {
@@ -213,23 +196,18 @@
"comment":"Trust Wallet", "comment":"Trust Wallet",
"iosMinVersion":"0", "iosMinVersion":"0",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/trust-wallet.png",
"image":"trust-wallet.png",
"connections":[ "connections":[
{ {
"type":"walletConnectV2", "type":"walletConnectV2",
"native":"trust:", "native":"trust:",
"universal":"https://link.trustwallet.com" "universal":"https://link.trustwallet.com"
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "TRUST_WALLET", "analyticEvent":"TRUST_WALLET"
"imageName": "trust-wallet.png"
} }
}, },
{ {
@@ -270,23 +248,18 @@
"comment":"Zerion Wallet", "comment":"Zerion Wallet",
"iosMinVersion":"0", "iosMinVersion":"0",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/zerion.png",
"image":"zerion.png",
"connections":[ "connections":[
{ {
"type":"walletConnectV2", "type":"walletConnectV2",
"native":"zerion:", "native":"zerion:",
"universal":"" "universal":""
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "ZERION", "analyticEvent":"ZERION"
"imageName": "zerion.png"
} }
}, },
{ {
@@ -326,23 +299,18 @@
"config":{ "config":{
"comment":"TokenPocket", "comment":"TokenPocket",
"iosMinVersion":"0", "iosMinVersion":"0",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/tokenpocket.png",
"image":"tokenpocket.png",
"connections":[ "connections":[
{ {
"type": "walletConnectV2", "type":"walletConnect",
"native":"tpoutside:", "native":"tpoutside:",
"universal":"" "universal":""
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "TOKEN_POCKET", "analyticEvent":"TOKEN_POCKET"
"imageName": "tokenpocket.png"
} }
}, },
{ {
@@ -384,23 +352,18 @@
"iosMinVersion":"0", "iosMinVersion":"0",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"backlinked":true, "backlinked":true,
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/rainbow-wallet.png",
"image":"rainbow-wallet.png",
"connections":[ "connections":[
{ {
"type":"walletConnectV2", "type":"walletConnectV2",
"native":"rainbow:", "native":"rainbow:",
"universal":"https://rnbwapp.com" "universal":"https://rnbwapp.com"
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "RAINBOW_WALLET", "analyticEvent":"RAINBOW_WALLET"
"imageName": "rainbow-wallet.png"
} }
}, },
{ {
@@ -442,23 +405,70 @@
"comment":"1inch", "comment":"1inch",
"iosMinVersion":"0", "iosMinVersion":"0",
"encoding":"=\"#%/<>?@\\^`{|}:&", "encoding":"=\"#%/<>?@\\^`{|}:&",
"imageUrl": "", "imageUrl":"https://v4.testnet.dydx.exchange/wallets/1inch.png",
"image":"1inch.png",
"connections":[ "connections":[
{ {
"type": "walletConnectV2", "type":"walletConnect",
"native":"oneinch:", "native":"oneinch:",
"universal":"https://wallet.1inch.io" "universal":"https://wallet.1inch.io"
} }
],
"methods": [
"eth_sendTransaction",
"personal_sign",
"eth_signTypedData"
] ]
}, },
"userFields":{ "userFields":{
"analyticEvent": "1INCH", "analyticEvent":"1INCH"
"imageName": "1inch.png" }
},
{
"id":"bae74827272509a6d63ea25514d9c68ad235c14e45e183518c7ded4572a1b0c4",
"name":"Huobi Wallet",
"description":"",
"homepage":"https://huobiwallet.com/",
"chains":[
"eip155:1"
],
"versions":[
"1"
],
"app":{
"browser":"",
"ios":"https://apps.apple.com/us/app/id1433883012",
"android":"https://play.google.com/store/apps/details?id=com.huobionchainwallet.gp",
"mac":"",
"windows":"",
"linux":""
},
"mobile":{
"native":"huobiwallet:",
"universal":""
},
"desktop":{
"native":"",
"universal":""
},
"metadata":{
"shortName":"Huobi",
"colors":{
"primary":"rgb(45,101,248)",
"secondary":""
}
},
"config":{
"comment":"Huobi",
"iosMinVersion":"0",
"encoding":"=\"#%/<>?@\\^`{|}:&",
"imageUrl":"https://v4.testnet.dydx.exchange/wallets/huobi-wallet.png",
"image":"huobi-wallet.png",
"connections":[
{
"type":"walletConnect",
"native":"huobiwallet:",
"universal":""
}
]
},
"userFields":{
"analyticEvent":"HUOBI_WALLET"
} }
} }
] ]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

+1 -1
View File
@@ -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 = keyof typeof ENVIRONMENT_CONFIG_MAP; export type DydxNetwork = (typeof AVAILABLE_ENVIRONMENTS.environments)[number];
export const DEFAULT_APP_ENVIRONMENT = AVAILABLE_ENVIRONMENTS.default as DydxNetwork; export const DEFAULT_APP_ENVIRONMENT = AVAILABLE_ENVIRONMENTS.default as DydxNetwork;
+2
View File
@@ -10,6 +10,7 @@ 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();
@@ -18,6 +19,7 @@ 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(() => {
+3
View File
@@ -9,6 +9,8 @@ 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;
@@ -20,6 +22,7 @@ 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(
+38
View File
@@ -0,0 +1,38 @@
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,11 +45,15 @@ describe('getStringsForDateTimeDiff', () => {
describe('getStringsForTimeInterval', () => { describe('getStringsForTimeInterval', () => {
it.each([ it.each([
[Duration.fromObject({ months: 2 }), '2', 'MONTHS_ABBREVIATED'], [Duration.fromObject({ months: 2 }), '2', 'APP.GENERAL.TIME_STRINGS.MONTHS_ABBREVIATED'],
[Duration.fromObject({ weeks: 3, days: 2 }), '3', 'WEEKS_ABBREVIATED'], [Duration.fromObject({ weeks: 3, days: 2 }), '3', 'APP.GENERAL.TIME_STRINGS.WEEKS_ABBREVIATED'],
[Duration.fromObject({ days: 5, hours: 12 }), '6', 'DAYS_ABBREVIATED'], [Duration.fromObject({ days: 5, hours: 12 }), '6', 'APP.GENERAL.TIME_STRINGS.DAYS_ABBREVIATED'],
[Duration.fromObject({ hours: 8, minutes: 30 }), '9', 'HOURS_ABBREVIATED'], [
[Duration.fromObject({ minutes: 45 }), '45', 'MINUTES_ABBREVIATED'], Duration.fromObject({ hours: 8, minutes: 30 }),
'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) => {
+4
View File
@@ -0,0 +1,4 @@
import { AVAILABLE_ENVIRONMENTS, type DydxNetwork } from '@/constants/networks';
export const validateAgainstAvailableEnvironments = (value: DydxNetwork) =>
AVAILABLE_ENVIRONMENTS.environments.includes(value);
+2 -2
View File
@@ -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.toString()).getTime() : new Date(value.toNumber()).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)}`;
} };
+2 -3
View File
@@ -100,11 +100,10 @@ const walletconnect2ConnectorOptions: ConstructorParameters<typeof WalletConnect
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: 'https://trade.dydx.exchange', url: import.meta.env.VITE_BASE_URL,
icons: ['https://trade.dydx.exchange/cbw-image.png'], icons: [`${import.meta.env.VITE_BASE_URL}/cbw-image.png}`],
}, },
showQrModal: true, showQrModal: true,
qrModalOptions: { qrModalOptions: {
+2
View File
@@ -6,6 +6,7 @@ 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;
@@ -19,6 +20,7 @@ const initialState: AppState = {
selectedNetwork: getLocalStorage({ selectedNetwork: getLocalStorage({
key: LocalStorageKey.SelectedNetwork, key: LocalStorageKey.SelectedNetwork,
defaultValue: DEFAULT_APP_ENVIRONMENT, defaultValue: DEFAULT_APP_ENVIRONMENT,
validateFn: validateAgainstAvailableEnvironments,
}), }),
}; };
+2 -2
View File
@@ -27,9 +27,9 @@ export const DisconnectDialog = ({ setIsOpen }: ElementProps) => {
}; };
return ( return (
<Dialog isOpen setIsOpen={setIsOpen} title="Disconnect"> <Dialog isOpen setIsOpen={setIsOpen} title={stringGetter({ key: STRING_KEYS.DISCONNECT })}>
<Styled.Content> <Styled.Content>
<p>Are you sure you want to disconnect your account?</p> <p>{stringGetter({ key: STRING_KEYS.DISCONNECT_CONFIRMATION })}</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.dydxacademy.info/educational-video-series/onboarding-to-defi-with-dydx`; const aboutWalletsLink = `https://www.dydx.academy/video/defi-wallet`;
export const ChooseWallet = () => { export const ChooseWallet = () => {
const stringGetter = useStringGetter(); const stringGetter = useStringGetter();
@@ -34,7 +34,14 @@ export const ChooseWallet = () => {
<Styled.AlertMessage type={AlertType.Error}> <Styled.AlertMessage type={AlertType.Error}>
{ {
<h4> <h4>
Couldn't connect to {stringGetter({ key: wallets[selectedWalletType].stringKey })}. {stringGetter({
key: STRING_KEYS.COULD_NOT_CONNECT,
params: {
WALLET: stringGetter({
key: wallets[selectedWalletType].stringKey,
}),
},
})}
</h4> </h4>
} }
{selectedWalletError} {selectedWalletError}