Skip to content

Commit

Permalink
Update orai-token-inspector to version 0.2.5; implement temporary dis…
Browse files Browse the repository at this point in the history
…ablement of BTC functionality across multiple components
  • Loading branch information
vuonghuuhung committed Jan 8, 2025
1 parent d389616 commit f8c3b82
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@oraichain/kawaiiverse-txs": "^0.0.3",
"@oraichain/orai-bitcoin": "2.0.0",
"@oraichain/oraidex-common": "2.0.6",
"@oraichain/orai-token-inspector": "^0.2.3",
"@oraichain/orai-token-inspector": "^0.2.5",
"@oraichain/oraidex-common-ui": "1.0.11",
"@oraichain/oraidex-contracts-sdk": "1.0.55",
"@oraichain/oraidex-universal-swap": "1.3.1",
Expand Down
2 changes: 2 additions & 0 deletions src/libs/cw-bitcoin/models/cw-bitcoin-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class CwBitcoinClient implements CwBitcoinClientInterface {
public depositAddress: DepositSuccess | null = null;

public async generateAddress(dest: Dest) {
// FIXME: TURN OFF BTC NOW
return null;
try {
// @ts-ignore-check
const config = {
Expand Down
3 changes: 3 additions & 0 deletions src/libs/nomic/models/nomic-client/nomic-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class NomicClient implements NomicClientInterface {
);
}
public async getRecoveredAddress(accAddress: string) {
// FIXME: TURN OFF BTC NOW
return null
return await fetch(`${Config.restUrl}/bitcoin/recovery_address/${accAddress}?network=${btcNetwork}`, {
method: 'GET'
}).then((data) => data.json());
Expand All @@ -50,6 +52,7 @@ export class NomicClient implements NomicClientInterface {
}

public async generateAddress() {
return null;
const isKeplrActive = await window.Keplr.getKeplr();
if (isKeplrActive) {
// @ts-ignore-check
Expand Down
3 changes: 3 additions & 0 deletions src/pages/Balance/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,9 @@ export const useGetWithdrawlFeesBitcoinV2 = ({
};

export const useDepositFeesBitcoinV2 = (enabled: boolean) => {
// FIXME: TURN OFF BTC NOW
return null

const getDepositFeeBTC = async () => {
try {
const { data } = await axios({
Expand Down
25 changes: 16 additions & 9 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import RefreshIcon from 'assets/icons/reload.svg?react';
import { BitcoinUnit } from 'bitcoin-units';
import classNames from 'classnames';
import CheckBox from 'components/CheckBox';
import LoadingBox from 'components/LoadingBox';
import { SelectTokenModal } from 'components/Modals/SelectTokenModal';
import SearchInput from './SearchInput';
import { displayToast, TToastType } from 'components/Toasts/Toast';
import TokenBalance from 'components/TokenBalance';
import { CwBitcoinContext } from 'context/cw-bitcoin-context';
Expand Down Expand Up @@ -74,7 +72,7 @@ import isEqual from 'lodash/isEqual';
import { refreshBalances } from 'pages/UniversalSwap/helpers';
import { ORAICHAIN_RELAYER_ADDRESS, SOL_RELAYER_ADDRESS, Web3SolanaProgramInteraction } from 'program/web3';
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
import { useSelector } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useNavigate, useSearchParams } from 'react-router-dom';
import { getSubAmountDetails } from 'rest/api';
import { RootState } from 'store/configure';
Expand All @@ -93,18 +91,20 @@ import {
} from './helpers';
import useTonBridgeHandler from './hooks/useTonBridgeHandler';
import KwtModal from './KwtModal';
import SearchInput from './SearchInput';
import StuckOraib from './StuckOraib';
import useGetOraiBridgeBalances from './StuckOraib/useGetOraiBridgeBalances';
import TokenItem, { TokenItemProps } from './TokenItem';
import { TokenItemBtc } from './TokenItem/TokenItemBtc';
// import { SolanaNetworkConfig } from '@oraichain/orai-token-inspector';
import { CHAIN } from '@oraichain/orai-token-inspector';
import loadingGif from 'assets/gif/loading-page.gif';
import CloseIcon from 'assets/icons/close-icon.svg?react';
import OraiDarkIcon from 'assets/icons/oraichain.svg?react';
import { FallbackEmptyData } from 'components/FallbackEmptyData';
import { getTokenInspectorInstance } from 'initTokenInspector';
import { onChainTokenToTokenItem } from 'reducer/onchainTokens';
import loadingGif from 'assets/gif/loading-page.gif';
import { FallbackEmptyData } from 'components/FallbackEmptyData';
import CloseIcon from 'assets/icons/close-icon.svg?react';
import { CHAIN } from '@oraichain/orai-token-inspector';
import { addToOraichainTokens, addToOtherChainTokens } from 'reducer/token';

interface BalanceProps {}
export const isMaintainBridge = false;
Expand All @@ -123,6 +123,7 @@ const Balance: React.FC<BalanceProps> = () => {
const nomic = useContext(NomicContext);
const cwBitcoinContext = useContext(CwBitcoinContext);
const [walletByNetworks] = useWalletReducer('walletsByNetwork');
const dispatch = useDispatch();

// state internal
const [loadingRefresh, setLoadingRefresh] = useState(false);
Expand Down Expand Up @@ -220,8 +221,13 @@ const Balance: React.FC<BalanceProps> = () => {
const inspectedToken = res.fromToken;
const toTokens = res.toTokens;
if (toTokens) setToTokens(toTokens);
if (inspectedToken.chainId === 'Oraichain') setTokens([[], [onChainTokenToTokenItem(inspectedToken)]]);
else setTokens([[onChainTokenToTokenItem(inspectedToken)], []]);
if (inspectedToken.chainId === 'Oraichain') {
setTokens([[], [onChainTokenToTokenItem(inspectedToken)]]);
dispatch(addToOraichainTokens([inspectedToken]));
} else {
setTokens([[onChainTokenToTokenItem(inspectedToken)], []]);
dispatch(addToOtherChainTokens([inspectedToken]));
}
} else {
setTokens(foundTokens);
}
Expand All @@ -230,6 +236,7 @@ const Balance: React.FC<BalanceProps> = () => {
setTokens([[], []]);
} finally {
setLoadingInspector(false);
await loadTokenAmounts({ metamaskAddress, tronAddress, oraiAddress, btcAddress, solAddress, tonAddress });
}
})();
}, [searchTokenAddress, filterNetworkUI]);
Expand Down
1 change: 1 addition & 0 deletions src/pages/BitcoinDashboardV2/hooks/lcd.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export interface ConfigResponse {
}

const getContractConfig = async (): Promise<ConfigResponse> => {
return null
try {
const res = await axios.get('/contract/config', {
params: {}
Expand Down
14 changes: 10 additions & 4 deletions src/reducer/token.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createSlice } from '@reduxjs/toolkit';
import type { PayloadAction } from '@reduxjs/toolkit';
import { ConfigResponse } from '@oraichain/common-contracts-sdk/build/CwIcs20Latest.types';
import { TokenItemType } from '@oraichain/oraidex-common';
import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';

export interface TokenState {
amounts: AmountDetails;
Expand Down Expand Up @@ -99,7 +99,10 @@ export const tokenSlice = createSlice({
state.allOtherChainTokens = [
...state.allOtherChainTokens,
...action.payload.filter(
(token: TokenItemType) => !state.allOtherChainTokens.find((t) => t.denom === token.denom)
(token: TokenItemType) =>
!state.allOtherChainTokens.find(
(t) => t?.denom === token?.denom || t?.contractAddress === token?.contractAddress
)
)
];
} catch (error) {
Expand All @@ -109,7 +112,10 @@ export const tokenSlice = createSlice({
updateAddedTokens: (state, action: PayloadAction<any>) => {
state.addedTokens = [
...state.addedTokens,
...action.payload.filter((token: TokenItemType) => !state.addedTokens.find((t) => t.denom === token.denom))
...action.payload.filter(
(token: TokenItemType) =>
!state.addedTokens.find((t) => t?.denom === token?.denom || t?.contractAddress === token?.contractAddress)
)
];
}
}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3924,10 +3924,10 @@
serialize-error "^8.1.0"
varuint-bitcoin "^1.1.2"

"@oraichain/orai-token-inspector@^0.2.3":
version "0.2.3"
resolved "https://registry.yarnpkg.com/@oraichain/orai-token-inspector/-/orai-token-inspector-0.2.3.tgz#f25cfb2250b37ec7c0b2c8d0499560cd7ab999d1"
integrity sha512-uIXYvI3fFJKXEMeBsxh2NniKY/yC5xkC6M4n7wYVBMiGg0qjBwXGaLbZ8MgY3okzInuvkGW8lI87+y/xAYvIhw==
"@oraichain/orai-token-inspector@^0.2.5":
version "0.2.5"
resolved "https://registry.yarnpkg.com/@oraichain/orai-token-inspector/-/orai-token-inspector-0.2.5.tgz#342934db7070b17c7a18cab1cfe0f0120446cbd6"
integrity sha512-7agqwqFK7SR0ZbR5qftnyNqWyZ2ShzrfHBw4v4R5FxXinXUE4gnYaWchNqYjQ27HXxPXwDIo3GjB2WALfnOPZQ==
dependencies:
"@keplr-wallet/types" "0.12.141"
"@metaplex-foundation/mpl-token-metadata" "^3.3.0"
Expand All @@ -3942,7 +3942,7 @@
"@ton-api/ton-adapter" "^0.3.0"
"@ton/core" "^0.59.0"
"@ton/ton" "^15.1.0"
bech32 "^2.0.0"
bech32 "1.1.4"
ethers "5.7.2"
ton-crypto "^3.2.0"

Expand Down

0 comments on commit f8c3b82

Please sign in to comment.