diff --git a/examples/hello/frontend/public/logos/arbitrum-logo.svg b/examples/hello/frontend/public/logos/arbitrum-logo.svg deleted file mode 100644 index a73530b6..00000000 --- a/examples/hello/frontend/public/logos/arbitrum-logo.svg +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/examples/hello/frontend/public/logos/avalanche-logo.svg b/examples/hello/frontend/public/logos/avalanche-logo.svg deleted file mode 100644 index e8edcf02..00000000 --- a/examples/hello/frontend/public/logos/avalanche-logo.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/examples/hello/frontend/public/logos/base-logo.svg b/examples/hello/frontend/public/logos/base-logo.svg deleted file mode 100644 index 34ce1124..00000000 --- a/examples/hello/frontend/public/logos/base-logo.svg +++ /dev/null @@ -1,263 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/hello/frontend/public/logos/bsc-logo.svg b/examples/hello/frontend/public/logos/bsc-logo.svg deleted file mode 100644 index 4c6f19b7..00000000 --- a/examples/hello/frontend/public/logos/bsc-logo.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/examples/hello/frontend/public/logos/ethereum-logo.svg b/examples/hello/frontend/public/logos/ethereum-logo.svg deleted file mode 100644 index 304e844e..00000000 --- a/examples/hello/frontend/public/logos/ethereum-logo.svg +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/examples/hello/frontend/public/logos/network-placeholder-logo.svg b/examples/hello/frontend/public/logos/network-placeholder-logo.svg deleted file mode 100644 index 142c6453..00000000 --- a/examples/hello/frontend/public/logos/network-placeholder-logo.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/examples/hello/frontend/public/logos/polygon-logo.svg b/examples/hello/frontend/public/logos/polygon-logo.svg deleted file mode 100644 index 732a0beb..00000000 --- a/examples/hello/frontend/public/logos/polygon-logo.svg +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/examples/hello/frontend/src/ConnectedContent.tsx b/examples/hello/frontend/src/ConnectedContent.tsx index 07eeb73b..272a44ca 100644 --- a/examples/hello/frontend/src/ConnectedContent.tsx +++ b/examples/hello/frontend/src/ConnectedContent.tsx @@ -36,10 +36,12 @@ const DynamicConnectedContent = ({ (wallet) => wallet.chain === 'SOL' )?.id; const evmWallet = userWallets.find((wallet) => wallet.chain === 'EVM')?.id; + const suiWallet = userWallets.find((wallet) => wallet.chain === 'SUI')?.id; return { EVM: evmWallet || '', SOL: solanaWallet || '', + SUI: suiWallet || '', }; }, [userWallets]); diff --git a/examples/hello/frontend/src/DynamicAppContent.tsx b/examples/hello/frontend/src/DynamicAppContent.tsx index 5981418a..240d8429 100644 --- a/examples/hello/frontend/src/DynamicAppContent.tsx +++ b/examples/hello/frontend/src/DynamicAppContent.tsx @@ -19,6 +19,10 @@ export function DynamicAppContent() { return 901; } + if (network === '502') { + return 103; + } + return null; }, [network]); diff --git a/examples/hello/frontend/src/components/NetworkSelector.tsx b/examples/hello/frontend/src/components/NetworkSelector.tsx index 5f3b04af..3a27dc14 100644 --- a/examples/hello/frontend/src/components/NetworkSelector.tsx +++ b/examples/hello/frontend/src/components/NetworkSelector.tsx @@ -28,7 +28,11 @@ export const NetworkSelector = ({ () => SUPPORTED_CHAINS.filter((chain) => { if (USE_DYNAMIC_WALLET) { - return chain.chainType === 'EVM' || chain.chainType === 'SOL'; + return ( + chain.chainType === 'EVM' || + chain.chainType === 'SOL' || + chain.chainType === 'SUI' + ); } else { return chain.chainType === 'EVM' || chain.chainType === 'BTC'; } @@ -36,7 +40,6 @@ export const NetworkSelector = ({ id: chain.chainId, label: chain.name, value: chain, - icon: {chain.name}, colorHex: chain.colorHex, })), [] diff --git a/examples/hello/frontend/src/constants/chains.ts b/examples/hello/frontend/src/constants/chains.ts index 472f3200..964d133f 100644 --- a/examples/hello/frontend/src/constants/chains.ts +++ b/examples/hello/frontend/src/constants/chains.ts @@ -2,8 +2,7 @@ export interface SupportedChain { explorerUrl: (txHash: string) => string; name: string; chainId: number; - chainType: 'EVM' | 'SOL' | 'BTC'; - icon: string; + chainType: 'EVM' | 'SOL' | 'BTC' | 'SUI'; colorHex: string; } @@ -13,7 +12,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Arbitrum Sepolia', chainId: 421614, chainType: 'EVM', - icon: '/logos/arbitrum-logo.svg', colorHex: '#28446A', }, { @@ -22,7 +20,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Avalanche Fuji', chainId: 43113, chainType: 'EVM', - icon: '/logos/avalanche-logo.svg', colorHex: '#FF394A', }, { @@ -31,7 +28,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Base Sepolia', chainId: 84532, chainType: 'EVM', - icon: '/logos/base-logo.svg', colorHex: '#0052FF', }, { @@ -39,7 +35,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'BSC Testnet', chainId: 97, chainType: 'EVM', - icon: '/logos/bsc-logo.svg', colorHex: '#E1A411', }, { @@ -48,7 +43,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Ethereum Sepolia', chainId: 11155111, chainType: 'EVM', - icon: '/logos/ethereum-logo.svg', colorHex: '#3457D5', }, { @@ -57,7 +51,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Polygon Amoy', chainId: 80002, chainType: 'EVM', - icon: '/logos/polygon-logo.svg', colorHex: '#692BD7', }, { @@ -66,7 +59,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Solana Devnet', chainId: 901, chainType: 'SOL', - icon: '/logos/solana-logo.svg', colorHex: '#9945FF', }, { @@ -75,9 +67,15 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [ name: 'Bitcoin Signet', chainId: 18333, chainType: 'BTC', - icon: '/logos/bitcoin-logo.svg', colorHex: '#F7931A', }, + { + explorerUrl: (txHash: string) => `https://suiscan.xyz/testnet/tx/${txHash}`, + name: 'Sui Testnet', + chainId: 103, + chainType: 'SUI', + colorHex: '#4DA2FF', + }, ]; export const BITCOIN_GATEWAY_ADDRESS_SIGNET = diff --git a/examples/hello/frontend/src/hooks/useHandleCall.ts b/examples/hello/frontend/src/hooks/useHandleCall.ts index f032a0fd..f137be32 100644 --- a/examples/hello/frontend/src/hooks/useHandleCall.ts +++ b/examples/hello/frontend/src/hooks/useHandleCall.ts @@ -5,8 +5,10 @@ import { } from '@zetachain/toolkit/chains/bitcoin'; import { evmCall } from '@zetachain/toolkit/chains/evm'; import { solanaCall } from '@zetachain/toolkit/chains/solana'; +import { prepareSuiDepositAndCall } from '@zetachain/toolkit/chains/sui'; import { type PrimaryWallet } from '@zetachain/wallet'; import { getSolanaWalletAdapter } from '@zetachain/wallet/solana'; +import { getSuiWallet, getSuiWalletClient } from '@zetachain/wallet/sui'; import { ZeroAddress } from 'ethers'; import { useCallback } from 'react'; @@ -122,6 +124,43 @@ async function handleSolanaCall( callbacks.onTransactionConfirmed?.(result); } +/** + * Handles Sui-specific call logic + */ +async function handleSuiCall( + callParams: CallParams, + primaryWallet: PrimaryWallet, + callbacks: { + onSigningStart?: UseHandleCallParams['onSigningStart']; + onTransactionSubmitted?: UseHandleCallParams['onTransactionSubmitted']; + onTransactionConfirmed?: UseHandleCallParams['onTransactionConfirmed']; + } +): Promise { + const suiWallet = getSuiWallet(primaryWallet); + const walletClient = await getSuiWalletClient(primaryWallet); + + callbacks.onSigningStart?.(); + + const { transaction } = await prepareSuiDepositAndCall( + { ...callParams, amount: '0.001' }, + { + chainId: '103', + } + ); + + const signedTransaction = await suiWallet.signTransaction(transaction); + + const executionResult = await walletClient.executeTransactionBlock({ + options: {}, + signature: signedTransaction.signature, + transactionBlock: signedTransaction.bytes, + }); + + callbacks.onTransactionSubmitted?.(); + + callbacks.onTransactionConfirmed?.(executionResult.digest); +} + /** * Handles Bitcoin-specific call logic using Unisat + Signet */ @@ -277,6 +316,11 @@ export function useHandleCall({ selectedProvider, callbacks ); + } else if (walletType === 'SUI') { + if (!primaryWallet) { + throw new Error('Sui transactions require primaryWallet'); + } + await handleSuiCall(callParams, primaryWallet, callbacks); } else if (walletType === 'SOL') { if (!primaryWallet) { throw new Error('Solana transactions require primaryWallet');