Skip to content

Commit

Permalink
Merge pull request #997 from oraichain/fix/validate-address
Browse files Browse the repository at this point in the history
Fix/validate address
  • Loading branch information
haunv3 authored Oct 17, 2024
2 parents aa46afd + 4c39f92 commit 1bba400
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 32 deletions.
48 changes: 24 additions & 24 deletions src/config/chainInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,22 @@ export const bitcoinMainnet: CustomChainInfo = {
average: 0,
high: 0
}
},
{
coinDenom: 'BTC V2',
coinMinimalDenom: 'btc-v2',
prefixToken: 'oraibtc',
coinDecimals: 8 as any,
bridgeTo: ['Oraichain'],
Icon: BTCIcon,
coinGeckoId: 'bitcoin',
coinImageUrl: 'https://assets.coingecko.com/coins/images/1/small/bitcoin.png',
gasPriceStep: {
low: 0,
average: 0,
high: 0
}
}
// {
// coinDenom: 'BTC V2',
// coinMinimalDenom: 'btc-v2',
// prefixToken: 'oraibtc',
// coinDecimals: 8 as any,
// bridgeTo: ['Oraichain'],
// Icon: BTCIcon,
// coinGeckoId: 'bitcoin',
// coinImageUrl: 'https://assets.coingecko.com/coins/images/1/small/bitcoin.png',
// gasPriceStep: {
// low: 0,
// average: 0,
// high: 0
// }
// }
],
get feeCurrencies() {
return this.currencies;
Expand Down Expand Up @@ -207,15 +207,15 @@ export const OraiToken: BridgeAppCurrency = {
export const oraichainNetwork: CustomChainInfo = {
...customOraichainNetwork,
currencies: [
...customOraichainNetwork.currencies,
{
coinDenom: 'BTC V2',
coinGeckoId: 'bitcoin',
coinMinimalDenom: CWBitcoinFactoryDenom,
bridgeTo: ['bitcoin'] as any,
coinDecimals: 14 as any,
coinImageUrl: 'https://s2.coinmarketcap.com/static/img/coins/64x64/1.png'
}
...customOraichainNetwork.currencies
// {
// coinDenom: 'BTC V2',
// coinGeckoId: 'bitcoin',
// coinMinimalDenom: CWBitcoinFactoryDenom,
// bridgeTo: ['bitcoin'] as any,
// coinDecimals: 14 as any,
// coinImageUrl: 'https://s2.coinmarketcap.com/static/img/coins/64x64/1.png'
// }
]
};

Expand Down
6 changes: 3 additions & 3 deletions src/layouts/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ const Menu: React.FC = () => {
{Icon}
<span className={getTextClasses()}>
{title}
{(to === '/pools/v3' || to === `/bitcoin-dashboard-v2`) && (
{/* {(to === '/pools/v3' || to === `/bitcoin-dashboard-v2`) && (
<span className={classNames(styles.suffix)}>
<Lottie animationData={PoolV3Lottie} autoPlay={open} loop />
</span>
)}
)} */}
</span>
</>
);
Expand Down Expand Up @@ -187,7 +187,7 @@ const Menu: React.FC = () => {
{renderLink('/staking', 'Staking', setLink, false, <StakingIcon />)}
{renderLink('/co-harvest', 'Co-Harvest', setLink, false, <CohavestIcon />)}
{renderLink('/bitcoin-dashboard', 'BTC Dashboard', setLink, false, <BtcDashboardIcon />)}
{renderLink('/bitcoin-dashboard-v2', 'BTC V2', setLink, false, <BtcDashboardIcon />)}
{/* {renderLink('/bitcoin-dashboard-v2', 'BTC V2', setLink, false, <BtcDashboardIcon />)} */}
{!isBeta && renderLink('https://beta.oraidex.io', 'OraiDEX Beta', setLink, true, <OraidexBetaIcon />)}
<div className={styles.divider}></div>
{renderLink('https://orderbook.oraidex.io', 'Order Book', () => {}, true, <OrderbookIcon />)}
Expand Down
6 changes: 3 additions & 3 deletions src/layouts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ const Sidebar: React.FC<{}> = React.memo(() => {
{icon}
<span className={classNames(styles.menu_item_text, { [styles.active]: link === to }, styles[theme])}>
{title}
{to === `/bitcoin-dashboard-v2` && (
{/* {to === `/bitcoin-dashboard-v2` && (
<span className={classNames(styles.suffix)}>
<Lottie animationData={PoolV3Lottie} autoPlay={open} loop />
</span>
)}
)} */}
</span>
</Link>
);
Expand All @@ -110,7 +110,7 @@ const Sidebar: React.FC<{}> = React.memo(() => {
{renderLink('/staking', 'Staking', setLink, <StakingIcon />)}
{renderLink('/co-harvest', 'Co-Harvest', setLink, <CohavestIcon />)}
{renderLink('/bitcoin-dashboard', 'BTC Dashboard', setLink, <BtcDashboardIcon />)}
{renderLink('/bitcoin-dashboard-v2', 'BTC V2', setLink, <BtcDashboardIcon />)}
{/* {renderLink('/bitcoin-dashboard-v2', 'BTC V2', setLink, <BtcDashboardIcon />)} */}
{!isBeta && renderLink('https://beta.oraidex.io', 'OraiDEX Beta', setLink, <OraidexBetaIcon />, true)}
</div>
</div>
Expand Down
16 changes: 15 additions & 1 deletion src/libs/keplr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { OfflineSigner } from '@cosmjs/proto-signing';
import { ChainInfo, FeeCurrency, Keplr as keplr, Key } from '@keplr-wallet/types';
import { CosmosChainId, CosmosWallet, NetworkChainId, TokenItemType, WalletType } from '@oraichain/oraidex-common';
import {
CosmosChainId,
CosmosWallet,
NetworkChainId,
TokenItemType,
WalletType,
checkValidateAddressWithNetwork
} from '@oraichain/oraidex-common';
import { isMobile } from '@walletconnect/browser-utils';
import { displayToast, TToastType } from 'components/Toasts/Toast';
import { chainInfos, OraiBTCBridgeNetwork } from 'config/chainInfos';
Expand Down Expand Up @@ -111,6 +118,13 @@ export default class Keplr extends CosmosWallet {

const keplr = await this.getKeplr();
if (keplr) {
if (chainId !== 'bitcoin') {
const keplrKey = await keplr.getKey(chainId);
if (!keplrKey?.bech32Address) return undefined;
const { isValid } = checkValidateAddressWithNetwork(keplrKey?.bech32Address, chainId as NetworkChainId);
if (!isValid) return undefined;
}

return keplr.getKey(chainId);
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default () => (
<Route path="/" element={<UniversalSwap />} />
<Route path="/bridge" element={<Balance />} />
<Route path="/bitcoin-dashboard" element={<BitcoinDashboard />} />
<Route path="/bitcoin-dashboard-v2" element={<BitcoinDashboardV2 />} />
{/* <Route path="/bitcoin-dashboard-v2" element={<BitcoinDashboardV2 />} /> */}
<Route path="/universalswap" element={<UniversalSwap />} />
<Route path="/swap" element={<UniversalSwap />} />
{/* <Route path="/pools" element={<Pools />} /> */}
Expand Down

0 comments on commit 1bba400

Please sign in to comment.