Skip to content

Commit

Permalink
Merge pull request #31 from router-protocol/remove/near
Browse files Browse the repository at this point in the history
remove: near
  • Loading branch information
jayeshbhole-rp authored Dec 26, 2024
2 parents 66ac98b + 79212fe commit adb83bf
Show file tree
Hide file tree
Showing 32 changed files with 77 additions and 2,986 deletions.
47 changes: 0 additions & 47 deletions example-next/src/app/wallets/mynearwallet/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion example-next/src/components/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const Providers = ({ children }: { children: ReactNode }) => {
twaReturnUrl: `${window.location.origin}/` as `${string}://${string}`,
projectId: '41980758771052df3f01be0a46f172a5',
tonconnectManifestUrl: `${window.location.origin}/tonconnect-manifest.json`,
nearNetwork: 'mainnet',
bitcoinNetwork: 'mainnet',
}}
>
Expand Down
31 changes: 17 additions & 14 deletions example-next/src/components/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,125 +63,128 @@ const tokens: TokenMetadata[] = [
name: 'OSMO',
symbol: 'OSMO',
chainId: 'osmosis-1',
isNative: true,
},
{
address: ETH_ADDRESS,
decimals: 18,
name: 'Ether',
symbol: 'ETH',
chainId: '1',
isNative: true,
},
{
address: '',
decimals: 18,
name: 'Polygon MATIC',
symbol: 'MATIC',
chainId: '137',
isNative: true,
},
{
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
chainId: '42161',
isNative: false,
},
{
address: SOL_ADDRESS,
decimals: 9,
name: 'Solana SOL',
symbol: 'SOL',
chainId: 'solana',
isNative: true,
},
{
address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
chainId: 'solana',
isNative: false,
},
{
address: 'So11111111111111111111111111111111111111112',
decimals: 9,
name: 'Wrapped SOL',
symbol: 'WSOL',
chainId: 'solana',
isNative: false,
},
{
address: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
decimals: 6,
name: 'USDT',
symbol: 'USDT',
chainId: 'solana',
isNative: false,
},
{
address: ETH_ADDRESS,
decimals: 6,
name: 'Tron TRX',
symbol: 'TRX',
chainId: '728126428',
isNative: true,
},
{
address: 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8',
decimals: 6,
name: 'Tron USDC',
symbol: 'USDC',
chainId: '728126428',
isNative: false,
},
{
address: ETH_ADDRESS,
decimals: 9,
name: 'Toncoin',
symbol: 'TON',
chainId: '-239',
isNative: true,
},
{
address: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
decimals: 6,
name: 'Tether USD',
symbol: 'USDT',
chainId: '-239',
isNative: false,
},
{
address: ETH_ADDRESS,
decimals: 8,
name: 'Bitcoin',
symbol: 'BTC',
chainId: 'bitcoin',
isNative: true,
},
{
address: ETH_ADDRESS,
decimals: 24,
name: 'NEAR',
symbol: 'NEAR',
chainId: '397',
},
{
address: 'usdt.tether-token.near',
decimals: 6,
name: 'Tether USD',
symbol: 'USDt',
chainId: '397',
},

{
address: '0x2::sui::SUI',
decimals: 9,
name: 'Sui Token',
symbol: 'SUI',
chainId: 'sui',
isNative: true,
},
{
address: '0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN',
decimals: 6,
name: 'Tether USD',
symbol: 'USDT',
chainId: 'sui',
isNative: false,
},
{
address: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
chainId: 'sui',
isNative: false,
},
];

Expand Down
11 changes: 1 addition & 10 deletions example-next/src/components/WalletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ const WalletList = () => {
const wallets = useWallets();
const { connect } = useConnect();

const getNearContractId = (chainType: unknown) => {
// TODO: add contractId for both 'testnet' & 'mainnet'
if (chainType === 'near') {
return 'usdt.tether-token.near'; // For testnet: 'routetoken.i-swap.testnet'
}
};

return (
<div className='max-h-[60rem] overflow-scroll bg-neutral-900'>
<h2 className='text-xl font-bold sticky top-0 bg-black'>WALLETS</h2>
Expand Down Expand Up @@ -48,9 +41,7 @@ const WalletList = () => {
<td className='px-4 py-2'>
{wallet.installed ? (
<button
onClick={() =>
connect({ walletId: wallet.id, chainType, nearContractId: getNearContractId(chainType) })
}
onClick={() => connect({ walletId: wallet.id, chainType })}
className='bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded'
>
connect
Expand Down
1 change: 0 additions & 1 deletion example/src/components/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const Providers = ({ children }: { children: ReactNode }) => {

twaReturnUrl: `${window.location.origin}/` as `${string}://${string}`,
projectId: '41980758771052df3f01be0a46f172a5',
nearNetwork: 'mainnet',
tonconnectManifestUrl: `${window.location.origin}/tonconnect-manifest.json`,
bitcoinNetwork: 'mainnet',
}}
Expand Down
12 changes: 12 additions & 0 deletions example/src/components/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,83 +63,95 @@ const tokens: TokenMetadata[] = [
name: 'OSMO',
symbol: 'OSMO',
chainId: 'osmosis-1',
isNative: true,
},
{
address: ETH_ADDRESS,
decimals: 18,
name: 'Ether',
symbol: 'ETH',
chainId: '1',
isNative: true,
},
{
address: '',
decimals: 18,
name: 'Polygon MATIC',
symbol: 'MATIC',
chainId: '137',
isNative: true,
},
{
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
chainId: '42161',
isNative: false,
},
{
address: SOL_ADDRESS,
decimals: 9,
name: 'Solana SOL',
symbol: 'SOL',
chainId: 'solana',
isNative: true,
},
{
address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
decimals: 6,
name: 'USDC',
symbol: 'USDC',
chainId: 'solana',
isNative: false,
},
{
address: 'So11111111111111111111111111111111111111112',
decimals: 9,
name: 'Wrapped SOL',
symbol: 'WSOL',
chainId: 'solana',
isNative: false,
},
{
address: 'Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB',
decimals: 6,
name: 'USDT',
symbol: 'USDT',
chainId: 'solana',
isNative: false,
},
{
address: ETH_ADDRESS,
decimals: 6,
name: 'Tron TRX',
symbol: 'TRX',
chainId: '728126428',
isNative: true,
},
{
address: 'TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8',
decimals: 6,
name: 'Tron USDC',
symbol: 'USDC',
chainId: '728126428',
isNative: false,
},
{
address: ETH_ADDRESS,
decimals: 9,
name: 'Toncoin',
symbol: 'TON',
chainId: '-239',
isNative: true,
},
{
address: 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs',
decimals: 6,
name: 'Tether USD',
symbol: 'USDT',
chainId: '-239',
isNative: false,
},
];

Expand Down
7 changes: 0 additions & 7 deletions packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
"@cosmos-kit/xdefi": "^2.10.2",
"@mysten/dapp-kit": "^0.14.14",
"@mysten/sui": "^1.4.0",
"@near-js/providers": "latest",
"@near-wallet-selector/core": "^8.9.13",
"@near-wallet-selector/ethereum-wallets": "^8.9.13",
"@near-wallet-selector/my-near-wallet": "^8.9.13",
"@near-wallet-selector/near-mobile-wallet": "^8.9.13",
"@near-wallet-selector/wallet-connect": "^8.9.13",
"@routerprotocol/router-chain-sdk-ts": "0.8.70-beta-0.2",
"@safe-global/safe-apps-sdk": "^9.0.0",
"@solana/spl-token": "^0.4.8",
Expand All @@ -62,7 +56,6 @@
"@tronweb3/tronwallet-adapters": "^1.2.1",
"@wagmi/core": "^2.11.0",
"detect-browser": "^5.3.0",
"near-api-js": "^5.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tronweb": "6.0.0-beta.4",
Expand Down
17 changes: 1 addition & 16 deletions packages/react/src/actions/getBalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { multicall } from '@wagmi/core';
import { Address as EVMAddress, erc20Abi } from 'viem';
import { trc20Abi } from '../constants/abi/trc20.js';
import { tronMulticallAbi } from '../constants/abi/tronMulticall.js';
import { ChainData, ConnectionOrConfig, OtherChainData } from '../types/index.js';
import { viewMethodOnNear } from './near/readCalls.js';
import { ChainData, ConnectionOrConfig } from '../types/index.js';

export const getBalances = async (
tokens: { address: string }[],
Expand Down Expand Up @@ -120,19 +119,5 @@ export const getBalances = async (
return balances;
}

if (chain.type === 'near') {
const balances: Record<string, bigint> = {};

for (const token of tokens) {
balances[token.address] = BigInt(
await viewMethodOnNear(chain as OtherChainData<'near'>, token.address, 'ft_balance_of', {
account_id: account,
}),
);
}

return balances;
}

throw new Error('Unsupported chain type');
};
Loading

0 comments on commit adb83bf

Please sign in to comment.