diff --git a/package.json b/package.json index 4409d61..dab0561 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@project-serum/anchor": "^0.5.1-beta.2", "@project-serum/serum": "^0.13.34", "@project-serum/sol-wallet-adapter": "^0.2.0", - "@project-serum/swap": "^0.1.0-alpha.4", + "@project-serum/swap": "^0.1.0-alpha.5", "@solana/spl-token": "^0.1.4", "@solana/spl-token-registry": "^0.2.86", "@solana/web3.js": "^1.10.1", diff --git a/src/swap/components/Info.tsx b/src/swap/components/Info.tsx index c7ccd81..197218f 100644 --- a/src/swap/components/Info.tsx +++ b/src/swap/components/Info.tsx @@ -108,6 +108,7 @@ function InfoDetails() { { ticker: fromMintTicker, mint: fromMint }, { ticker: toMintTicker, mint: toMint }, ]; + const route = swapClient.route(fromMint, toMint); return (
@@ -117,9 +118,13 @@ function InfoDetails() { > Trade Route - {swapClient.route(fromMint, toMint).map((market: PublicKey) => { - return ; - })} + {route ? ( + route.map((market: PublicKey) => { + return ; + }) + ) : ( + Route not found + )}
{ if (!fromMintInfo || !toMintInfo) { @@ -307,7 +307,9 @@ function SwapButton() { variant="contained" className={styles.swapButton} onClick={sendSwapTransaction} - disabled={swapClient.program.provider.wallet.publicKey === null} + disabled={ + swapClient.program.provider.wallet.publicKey === null || route === null + } > Swap diff --git a/src/swap/components/TokenDialog.tsx b/src/swap/components/TokenDialog.tsx index 3b71c82..3e889ce 100644 --- a/src/swap/components/TokenDialog.tsx +++ b/src/swap/components/TokenDialog.tsx @@ -40,7 +40,12 @@ export default function TokenDialog({ const styles = useStyles(); const { swapClient } = useDexContext(); const tokens = useMemo(() => { - return swapClient.tokens().concat([USDC_MINT, USDT_MINT]); + return swapClient + .tokens() + .concat([USDC_MINT, USDT_MINT]) + .filter( + (t) => t.toString() !== "So11111111111111111111111111111111111111112" + ); }, [swapClient]); return ( { +): Array | null { const { swapClient } = useDexContext(); return useMemo( () => swapClient.route(fromMint, toMint), diff --git a/yarn.lock b/yarn.lock index a270048..197153c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1588,10 +1588,10 @@ bs58 "^4.0.1" eventemitter3 "^4.0.4" -"@project-serum/swap@^0.1.0-alpha.4": - version "0.1.0-alpha.4" - resolved "https://registry.yarnpkg.com/@project-serum/swap/-/swap-0.1.0-alpha.4.tgz#f5035218173d7f8ccb0d53c637c10f50b4734c3f" - integrity sha512-5O6rJjLmaZTiPJUZq5iHBV1c3LQ11ZBv4wD1ol5rIPxDkHlmxqfH23XQVkC3aEJXIry5ffRf7hL/e1VgSW5C3A== +"@project-serum/swap@^0.1.0-alpha.5": + version "0.1.0-alpha.5" + resolved "https://registry.yarnpkg.com/@project-serum/swap/-/swap-0.1.0-alpha.5.tgz#106fdf5354c3c17f1832ab623122739fd45e2e52" + integrity sha512-ZJW9XNlZyhIq/C8pwKhFvf7duKth8dfu7vkgVtfUp281dBgSXx6IwrigpYcJ9x/VZMr9LMrkUVW1LiXd8XZdEQ== dependencies: "@project-serum/anchor" "^0.5.1-beta.2" "@project-serum/serum" "^0.13.34"