Skip to content

Commit

Permalink
pumb common
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Dec 3, 2024
1 parent 47fae8d commit e917a4f
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 128 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"bitcoinjs-lib": "5.2.0",
"axios": "0.26.1",
"@sentry/react": "7.99.0",
"@oraichain/oraidex-common": "1.1.34"
"@oraichain/oraidex-common": "1.1.35"
},
"engines": {
"node": "^18 || ^20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ export const WalletByNetwork = ({ walletProvider }: { walletProvider: WalletProv

const handleConnectWalletInSolanaNetwork = async (walletType: WalletType) => {
let provider = window?.solana;
let selectType = 'Phantom';
if (walletType === 'owallet') {
provider = window?.owalletSolana;
selectType = 'OWallet';
}

solanaWallet.select(selectType as any);
await solanaWallet.connect();
const { publicKey } = await provider.connect();
if (publicKey) {
setSolanaAddress(publicKey.toBase58());
Expand Down
7 changes: 4 additions & 3 deletions src/config/bridgeTokens.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import flatten from 'lodash/flatten';
import uniqBy from 'lodash/uniqBy';
import { chainInfos, oraichainNetwork, solChainId } from './chainInfos';
import { chainInfos, oraichainNetwork } from './chainInfos';
import {
CustomChainInfo,
INJECTIVE_ORAICHAIN_DENOM,
KWTBSC_ORAICHAIN_DENOM,
MILKYBSC_ORAICHAIN_DENOM,
TokenItemType,
KWT_BSC_CONTRACT,
MILKY_BSC_CONTRACT
MILKY_BSC_CONTRACT,
solChainId
} from '@oraichain/oraidex-common';
import { bitcoinChainId } from 'helper/constants';

Expand Down Expand Up @@ -96,7 +97,7 @@ export const btcTokens = uniqBy(
);

export const solTokens = uniqBy(
flattenTokens.filter((token) => token.chainId === (solChainId as any)),
flattenTokens.filter((token) => token.chainId === solChainId),
(c) => c.denom
);

Expand Down
105 changes: 4 additions & 101 deletions src/config/chainInfos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,86 +121,8 @@ export const bitcoinMainnet: CustomChainInfo = {
}
};

export const solChainId = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp';

export const solanaMainnet: CustomChainInfo = {
rpc: 'https://swr.xnftdata.com/rpc-proxy/',
rest: 'https://swr.xnftdata.com/rpc-proxy/',
chainId: solChainId as any,
chainName: 'Solana' as any,
bip44: {
coinType: 501 as any
},
bech32Config: defaultBech32Config('sol'),
stakeCurrency: {
coinDenom: 'SOL',
coinMinimalDenom: 'sol',
coinDecimals: 9,
coinGeckoId: 'solana',
coinImageUrl: 'https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756'
},
chainSymbolImageUrl: 'https://upload.wikimedia.org/wikipedia/en/b/b9/Solana_logo.png',
networkType: 'svm' as any,
currencies: [
// {
// coinDenom: 'SOL',
// coinMinimalDenom: 'sol',
// coinDecimals: 9,
// bridgeTo: ['Oraichain'],
// coinGeckoId: 'solana' as any,
// coinImageUrl: 'https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756'
// },
{
coinDenom: 'MAX',
coinMinimalDenom: 'max',
coinDecimals: 6,
bridgeTo: ['Oraichain'],
contractAddress: 'oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h',
coinGeckoId: 'max.clan' as any,
coinImageUrl:
'https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2'
}
],
get feeCurrencies() {
return [
{
coinDenom: 'SOL',
coinMinimalDenom: 'sol',
coinDecimals: 9,
coinGeckoId: 'solana',
coinImageUrl: 'https://assets.coingecko.com/coins/images/4128/standard/solana.png?1718769756',
gasPriceStep: {
low: 1,
average: 1.25,
high: 1.5
}
},
{
coinDenom: 'MAX',
coinMinimalDenom: 'max',
coinDecimals: 6,
coinGeckoId: 'max.clan',
coinImageUrl:
'https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2',
gasPriceStep: {
low: 1,
average: 1.25,
high: 1.5
}
}
];
},

features: [],
txExplorer: {
name: 'Sol Scan',
txUrl: 'https://solscan.io/tx/{txHash}',
accountUrl: 'https://solscan.io/address/{address}'
}
};

export const chainInfosWithIcon = mapListWithIcon(
[...customChainInfos, bitcoinMainnet, oraibtcNetwork, solanaMainnet],
[...customChainInfos, bitcoinMainnet, oraibtcNetwork],
chainIcons,
'chainId'
);
Expand Down Expand Up @@ -228,26 +150,7 @@ export const OraiToken: BridgeAppCurrency = {
export const oraichainNetwork: CustomChainInfo = {
...customOraichainNetwork,
currencies: [
...customOraichainNetwork.currencies,
// {
// coinDenom: 'SOL',
// coinGeckoId: 'solana' as any,
// coinMinimalDenom: 'factory/orai1wuvhex9xqs3r539mvc6mtm7n20fcj3qr2m0y9khx6n5vtlngfzes3k0rq9/sol',
// bridgeTo: [solChainId] as any,
// coinDecimals: 9,
// coinImageUrl:
// 'https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2'
// },
{
coinDenom: 'MAX',
coinGeckoId: 'max.clan' as any,
coinMinimalDenom:
'factory/orai17hyr3eg92fv34fdnkend48scu32hn26gqxw3hnwkfy904lk9r09qqzty42/oraim8c9d1nkfuQk9EzGYEUGxqL3MHQYndRw1huVo5h',
bridgeTo: [solChainId] as any,
coinDecimals: 6,
coinImageUrl:
'https://pump.mypinata.cloud/ipfs/QmcGwYebsQfYbNSM9QDAMS2wKZ8fZNEiMbezJah1zgEWWS?img-width=256&img-dpr=2'
}
...customOraichainNetwork.currencies
// {
// coinDenom: 'BTC V2',
// coinGeckoId: 'bitcoin',
Expand Down Expand Up @@ -313,12 +216,12 @@ export const OraiBTCBridgeNetwork = {
}
};

export const chainInfosWithSdk = [...customChainInfos, bitcoinMainnet, oraibtcNetwork, solanaMainnet];
export const chainInfosWithSdk = [...customChainInfos, bitcoinMainnet, oraibtcNetwork];
export const chainInfos = mapListWithIcon(chainInfosWithSdk, chainIcons, 'chainId');

// exclude kawaiverse subnet and other special evm that has different cointype
export const evmChains = chainInfos.filter(
(c) => c.networkType === 'evm' && c.bip44.coinType === 60 && c.chainId !== '0x1ae6'
);

export const btcChains = chainInfos.filter((c) => c.networkType === ('bitcoin' as any));
export const btcChains = chainInfos.filter((c) => c.networkType === 'bitcoin');
8 changes: 5 additions & 3 deletions src/helper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
MULTIPLIER,
TRON_SCAN,
EVM_CHAIN_ID_COMMON,
WalletType as WalletCosmosType
SOL_SCAN,
WalletType as WalletCosmosType,
solChainId
} from '@oraichain/oraidex-common';
import { network } from 'config/networks';
import { serializeError } from 'serialize-error';
Expand All @@ -24,7 +26,7 @@ import { CustomChainInfo, EvmDenom, NetworkChainId, TokenItemType } from '@oraic
import { isMobile } from '@walletconnect/browser-utils';
import { displayToast, TToastType } from 'components/Toasts/Toast';
import { WalletType } from 'components/WalletManagement/walletConfig';
import { chainIcons, chainInfos, chainInfosWithIcon, flattenTokensWithIcon, solChainId } from 'config/chainInfos';
import { chainIcons, chainInfos, chainInfosWithIcon, flattenTokensWithIcon } from 'config/chainInfos';
import { MetamaskOfflineSigner } from 'libs/eip191';
import Keplr from 'libs/keplr';
import { WalletsByNetwork } from 'reducer/wallet';
Expand Down Expand Up @@ -109,7 +111,7 @@ export const getTransactionUrl = (chainId: NetworkChainId, transactionHash: stri
case Networks.tron:
return `${TRON_SCAN}/#/transaction/${transactionHash.replace(/^0x/, '')}`;
case Number(solChainId):
return `https://solscan.io/tx/${transactionHash}`;
return `${SOL_SCAN}/tx/${transactionHash}`;
default:
// raw string
switch (chainId) {
Expand Down
5 changes: 3 additions & 2 deletions src/hooks/useLoadTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import {
EVM_BALANCE_RETRY_COUNT,
ERC20__factory,
getEvmAddress,
tronToEthAddress
tronToEthAddress,
solChainId
} from '@oraichain/oraidex-common';
import { UniversalSwapHelper } from '@oraichain/oraidex-universal-swap';
import { chainInfos, evmChains, solChainId } from 'config/chainInfos';
import { chainInfos, evmChains } from 'config/chainInfos';
import { network } from 'config/networks';
import { ethers } from 'ethers';
import axios from 'rest/request';
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ const App = () => {

const handleAddressSolOwallet = async () => {
let solAddress;
if (walletByNetworks.solana === 'phantom' || mobileMode) {
if (solanaWallet.publicKey) {
solAddress = solanaWallet.publicKey.toBase58();
if (solAddress) setSolAddress(solAddress);
if (walletByNetworks.solana === 'owallet' || mobileMode) {
if (window.owalletSolana) {
const { publicKey } = await window.owalletSolana.connect();
if (publicKey) setSolAddress(publicKey.toBase58());
}
}
return solAddress;
Expand Down
7 changes: 4 additions & 3 deletions src/pages/Balance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import {
toAmount,
TokenItemType,
calculateTimeoutTimestamp,
getCosmosGasPrice
getCosmosGasPrice,
solChainId,
ORAICHAIN_RELAYER_ADDRESS
} from '@oraichain/oraidex-common';
import { UniversalSwapHandler, UniversalSwapHelper } from '@oraichain/oraidex-universal-swap';
import { isMobile } from '@walletconnect/browser-utils';
Expand All @@ -27,7 +29,7 @@ import SearchInput from 'components/SearchInput';
import { displayToast, TToastType } from 'components/Toasts/Toast';
import TokenBalance from 'components/TokenBalance';
import { flattenTokens, tokens } from 'config/bridgeTokens';
import { chainInfos, solChainId } from 'config/chainInfos';
import { chainInfos } from 'config/chainInfos';
import { NomicContext } from 'context/nomic-context';
import {
assert,
Expand Down Expand Up @@ -462,7 +464,6 @@ const Balance: React.FC<BalanceProps> = () => {
fromToken: TokenItemType;
transferAmount: number;
}) => {
const ORAICHAIN_RELAYER_ADDRESS = 'orai1ehmhqcn8erf3dgavrca69zgp4rtxj5kqgtcnyd';
const receiverAddress = ORAICHAIN_RELAYER_ADDRESS;
const result = await window.client.sendTokens(
oraiAddress,
Expand Down
15 changes: 8 additions & 7 deletions src/program/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ import * as anchor from '@coral-xyz/anchor';
import { WalletContextState } from '@solana/wallet-adapter-react';
import { BN, Program } from '@coral-xyz/anchor';
import BigNumber from 'bignumber.js';
import { toAmount, TokenItemType } from '@oraichain/oraidex-common';
import {
toAmount,
TokenItemType,
SOL_RELAYER_ADDRESS,
SOLANA_RPC as DEFAULT_SOLANA_RPC,
SOLANA_WEBSOCKET as DEFAULT_SOLANA_WEBSOCKET,
MEMO_PROGRAM_ID
} from '@oraichain/oraidex-common';

export const commitmentLevel = 'confirmed';
export const TOKEN_RESERVES = 1_000_000_000_000_000;
export const LAMPORT_RESERVES = 1_000_000_000;
export const INIT_BONDING_CURVE = 95;

export const SOL_RELAYER_ADDRESS = '4k7xvinq6nB221iBhcP9uMFCPFh29MxQ6LieMH7cqw45';
export const DEFAULT_SOLANA_RPC = 'https://swr.xnftdata.com/rpc-proxy/';
export const DEFAULT_SOLANA_WEBSOCKET = 'wss://go.getblock.io/52d75331a9b74f9fa4a0056f15a1c022';
export const MEMO_PROGRAM_ID = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';

export class Web3SolanaProgramInteraction {
connection: Connection;

constructor() {
console.log(SOL_RELAYER_ADDRESS, DEFAULT_SOLANA_RPC, DEFAULT_SOLANA_WEBSOCKET);
this.connection = new Connection(DEFAULT_SOLANA_RPC, {
commitment: commitmentLevel,
wsEndpoint: DEFAULT_SOLANA_WEBSOCKET
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3847,10 +3847,10 @@
react-use "^17.4.0"
react-use-websocket "^4.5.0"

"@oraichain/[email protected].34", "@oraichain/oraidex-common@^1.1.27", "@oraichain/oraidex-common@^1.1.32":
version "1.1.34"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.34.tgz#257d25408450c438dc2bf0870fa8de9125af92ed"
integrity sha512-3PzjIS7+QlhSl/5w1NDXr5hZ8LXgJP0IqMWK/ZwJNM7yySeWRui6pwzFwariW2AQ/raU/z1Umr1Bh13idfeQ4Q==
"@oraichain/[email protected].35", "@oraichain/oraidex-common@^1.1.27", "@oraichain/oraidex-common@^1.1.32":
version "1.1.35"
resolved "https://registry.yarnpkg.com/@oraichain/oraidex-common/-/oraidex-common-1.1.35.tgz#079df95eb914b896c0cd432176a4f01ae8ffa8a1"
integrity sha512-gDK6/NIk+a+RvroIlcT/wr5DCqe3gzbpBtigs8l0aNRRbT6nTmc1baI0MFyF1TMN8kfQHICYlOoQdr+sx1HtIA==
dependencies:
"@cosmjs/amino" "^0.32.4"
"@cosmjs/cosmwasm-stargate" "^0.32.4"
Expand Down

0 comments on commit e917a4f

Please sign in to comment.