Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing memo on bridge #1070

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { WalletType as WalletCosmosType } from '@oraichain/oraidex-common';
import { Button } from 'components/Button';
import { TToastType, displayToast } from 'components/Toasts/Toast';
import type { WalletNetwork, WalletProvider, WalletType } from 'components/WalletManagement/walletConfig';
import { getListAddressCosmos, setStorageKey, switchWalletTron } from 'helper';
import { getListAddressCosmos, retry, setStorageKey, switchWalletTron } from 'helper';
import useConfigReducer from 'hooks/useConfigReducer';
import useTheme from 'hooks/useTheme';
import useWalletReducer from 'hooks/useWalletReducer';
Expand Down Expand Up @@ -101,11 +101,23 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv
}

solanaWallet.select(selectType as any);
await solanaWallet.connect();
const { publicKey } = await provider.connect();
if (publicKey) {
setSolanaAddress(publicKey.toBase58());
}
await retry(
async () => {
try {
await solanaWallet.connect();
} catch (err) {
console.log('err', err);
}
const { publicKey } = await provider.connect();
if (publicKey) {
setSolanaAddress(publicKey.toBase58());
} else {
throw new Error('Cannot connect to Solana wallet');
}
},
3,
1000
);
};

const handleConnectWalletByNetwork = async (wallet: WalletNetwork) => {
Expand Down
12 changes: 12 additions & 0 deletions src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -692,3 +692,15 @@ export const handleErrorRateLimit = (errorMsg: string) => {
});
}
};

export const retry = async (fn, retries = 3, delay = 1000) => {
try {
return await fn();
} catch (error) {
if (retries <= 0) {
throw error;
}
await sleep(delay);
return retry(fn, retries - 1, delay);
}
};
8 changes: 8 additions & 0 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,10 @@ const Balance: React.FC<BalanceProps> = () => {
fromToken: TokenItemType;
transferAmount: number;
}) => {
if (!oraiAddress) {
throw new Error('Please connect to Oraichain wallet');
}

const web3Solana = new Web3SolanaProgramInteraction();
console.log('from token address: ', fromToken.contractAddress);
const bridgeBalance =
Expand Down Expand Up @@ -481,6 +485,10 @@ const Balance: React.FC<BalanceProps> = () => {
fromToken: TokenItemType;
transferAmount: number;
}) => {
if (!solAddress) {
throw new Error('Please connect to Solana wallet');
}

const receiverAddress = ORAICHAIN_RELAYER_ADDRESS;
const currentBridgeBalance = await window.client.getBalance(receiverAddress, fromToken.denom);
console.log(
Expand Down
Loading