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

auto connect with solana owallet #1094

Merged
merged 4 commits into from
Dec 27, 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 @@ -8,7 +8,13 @@ import ToggleSwitch from 'components/ToggleSwitch';
import { type NetworkType } from 'components/WalletManagement/walletConfig';
import { ThemeContext } from 'context/theme-context';
import copy from 'copy-to-clipboard';
import { btcNetworksWithIcon, cosmosNetworksWithIcon, evmNetworksIconWithoutTron, tronNetworksWithIcon } from 'helper';
import {
btcNetworksWithIcon,
cosmosNetworksWithIcon,
evmNetworksIconWithoutTron,
solanaNetworksWithIcon,
tronNetworksWithIcon
} from 'helper';
import { useCoinGeckoPrices } from 'hooks/useCoingecko';
import useConfigReducer from 'hooks/useConfigReducer';
import useOnClickOutside from 'hooks/useOnClickOutside';
Expand All @@ -33,6 +39,7 @@ export const MyWalletMobile: React.FC<{
const [metamaskAddress] = useConfigReducer('metamaskAddress');
const [cosmosAddresses] = useConfigReducer('cosmosAddress');
const [btcAddress] = useConfigReducer('btcAddress');
const [solAddress] = useConfigReducer('solAddress');

const [currentDisconnectingNetwork, setCurrentDisconnectingNetwork] = useState<NetworkType>(null);
const [isShowDisconnect, setIsShowDisconnect] = useState(false);
Expand Down Expand Up @@ -223,6 +230,43 @@ export const MyWalletMobile: React.FC<{
);
};

const renderSolAddresses = () => {
if (!solAddress) return <></>;

return (
<div className={styles.addressByNetworkItem}>
{solanaNetworksWithIcon.map((network) => {
let NetworkIcon = theme === 'dark' ? network.Icon : network.IconLight;
if (!NetworkIcon) NetworkIcon = DefaultIcon;
return (
<div key={network.chainId} className={styles.addressByChainInNetwork}>
<div className={styles.left}>
<div className={styles.icon}>
<div className={styles.iconChain}>
<NetworkIcon width={30} height={30} />
</div>
</div>
<div className={styles.info}>
<div className={styles.chainName}>{network.chainName}</div>
<div className={styles.chainAddress}>
<span>{reduceString(solAddress, 6, 6)}</span>
<div className={styles.copyBtn} onClick={(e) => copyWalletAddress(e, solAddress)}>
{copiedValue === solAddress ? (
<SuccessIcon width={15} height={15} />
) : (
<CopyIcon width={15} height={15} />
)}
</div>
</div>
</div>
</div>
</div>
);
})}
</div>
);
};

return (
<div
ref={myWalletRef}
Expand Down Expand Up @@ -273,6 +317,7 @@ export const MyWalletMobile: React.FC<{
</div>
<div className={styles.listAddressByNetwork}>
{renderCosmosAddresses()}
{renderSolAddresses()}
{renderEvmAddresses()}
{renderTronAddresses()}
{renderBtcAddresses()}
Expand Down
8 changes: 4 additions & 4 deletions src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,16 +427,16 @@ export const getAddressTransferForEvm = async (walletByNetworks: WalletsByNetwor
export const getAddressTransfer = async (network: CustomChainInfo, walletByNetworks: WalletsByNetwork) => {
try {
let address = '';
if (network.networkType === 'ton' && walletByNetworks.ton) {
if (network.networkType === 'ton' && isConnectSpecificNetwork(walletByNetworks.ton)) {
address =
JSON.parse(JSON.parse(localStorage.getItem('persist:root'))?.config)?.tonAddress ||
toUserFriendlyAddress(window.Ton?.account?.address);
// address = useTonAddress();
} else if (network.networkType === 'evm') {
} else if (network.networkType === 'evm' && isConnectSpecificNetwork(walletByNetworks.evm)) {
address = await getAddressTransferForEvm(walletByNetworks, network);
} else if (network.networkType == 'svm' && walletByNetworks.solana) {
} else if (network.networkType == 'svm' && isConnectSpecificNetwork(walletByNetworks.solana)) {
let provider = window?.solana;
if (walletByNetworks.solana === 'owallet') {
if (walletByNetworks.solana === 'owallet' || isMobile()) {
provider = window?.owalletSolana;
}
const { publicKey } = await provider.connect();
Expand Down
4 changes: 2 additions & 2 deletions src/pages/UniversalSwap/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export const getExplorerScan = (chainId: NetworkChainId) => {
case '0x1ae6':
return 'https://scan.kawaii.global/tx';
case 'Oraichain':
return 'https://scan.orai.io/txs';
return 'https://scanium.io/Oraichain/tx';
case 'osmosis-1':
return 'https://www.mintscan.io/osmosis/tx';
case 'cosmoshub-4':
Expand All @@ -211,7 +211,7 @@ export const getExplorerScan = (chainId: NetworkChainId) => {
case 'ton':
return 'https://tonscan.org/address';
default:
return 'https://scan.orai.io/txs';
return 'https://scanium.io/Oraichain/tx';
}
};

Expand Down
Loading