Skip to content

Commit

Permalink
fix(ui-ux): set default network to mainnet (#865)
Browse files Browse the repository at this point in the history
* feature(ui-ux): refetch hot wallet balance and transfer guard (#763)

* init

* refactor on transfer token flow

* code cleanup

* code cleanup

* code cleanup -S

* code cleanup

* code cleanup

* resolve pr comment -S

* resolve pr comment

* fix getBalanceFn response type

* code cleanup

---------

Co-authored-by: JJ Adonis <[email protected]>
Co-authored-by: Pierre Gee <[email protected]>

* chore(ops): enable DFI on client (#804)

chore: enable DFI on client

* feature(ui-ux): added liquidity overview screen (#794)

* feature(ui-ux): added liquidity overview screen

* added Link component

* added Disclosure for mobile view

* removed env variables

* removed unused api endpoint

* lint fix

* fixed width in small screen

* renamed router

* added tool tip and added fetch balances on network change

* minor ui updates

* hide navigation when bridge is down

* desc update

* minor fix

* minor updates

* updated hotWalletAddress to HotWalletAddress

* chore: update dfi label on ethereum

Refactor TokenInfo prop and rename component

---------

Co-authored-by: Keng Ye <[email protected]>
Co-authored-by: Keng Ye <[email protected]>

* chore: re-add dfi into client

* feature(ui-ux): added on click event on entire token header bar while closing (#821)

* feature(ui-ux): added test ids for better cypress testing on liquidity screen (#837)

feature(ui-ux): added testids for better cypress testing on liquidity screen

* chore(ui-ux): update warning message when balance is insufficient (#841)

* feat: add reserved utxo on client form

* feat: support all token for liquidity check

* chore: add liquidity as dependency

* revert: all previous changes

Only update warning message when insufficient balance

* fix(ui-ux): set default network to mainnet

* pr comment fix

---------

Co-authored-by: Julio Caesar <[email protected]>
Co-authored-by: JJ Adonis <[email protected]>
Co-authored-by: Pierre Gee <[email protected]>
Co-authored-by: Keng Ye <[email protected]>
Co-authored-by: Keng Ye <[email protected]>
  • Loading branch information
6 people authored Mar 30, 2023
1 parent d758573 commit d5594f8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions apps/web/src/components/WalletAddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ export default function WalletAddressInput({
isPrimary && (
<EnvironmentNetworkSwitch
onChange={() => onAddressInputChange("")}
disabled={chain !== undefined}
/>
)}
<div
Expand Down
35 changes: 17 additions & 18 deletions apps/web/src/layouts/contexts/NetworkEnvironmentContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ export function NetworkEnvironmentProvider({
const router = useRouter();
const env = getEnvironment(process.env.NODE_ENV);
const networkQuery = router.query.network;

const defaultNetwork = EnvironmentNetwork.MainNet;
const { chain } = useNetwork();
const isEthereumMainNet = chain?.id === ETHEREUM_MAINNET_ID;

function getNetwork(n: EnvironmentNetwork): EnvironmentNetwork {
if (!isEthereumMainNet && env.networks.includes(n)) {
return n;
if (chain === undefined) {
return env.networks.includes(n) ? n : defaultNetwork;
}
return isEthereumMainNet
? EnvironmentNetwork.MainNet
Expand All @@ -48,22 +48,20 @@ export function NetworkEnvironmentProvider({
const [networkEnv, setNetworkEnv] =
useState<EnvironmentNetwork>(initialNetwork);

const updateRoute = (value: EnvironmentNetwork) => {
router.replace(
{
pathname: router.pathname,
query: value === defaultNetwork ? {} : { network: value },
},
undefined,
{ shallow: true }
);
};

const handleNetworkEnvChange = (value: EnvironmentNetwork) => {
if (isEthereumMainNet) {
// Network environment should never be updated
return;
}
setNetworkEnv(value);
if (value !== initialNetwork) {
router.replace(
{
pathname: "/",
query: { network: value },
},
undefined,
{ shallow: true }
);
}
updateRoute(value);
};

const resetNetworkEnv = () => {
Expand All @@ -72,7 +70,8 @@ export function NetworkEnvironmentProvider({

useEffect(() => {
setNetworkEnv(initialNetwork);
}, [initialNetwork]);
updateRoute(initialNetwork);
}, [initialNetwork, chain]);

const context: NetworkContextI = useMemo(
() => ({
Expand Down

0 comments on commit d5594f8

Please sign in to comment.