Skip to content
Draft
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
23 changes: 0 additions & 23 deletions examples/hello/frontend/public/logos/arbitrum-logo.svg

This file was deleted.

6 changes: 0 additions & 6 deletions examples/hello/frontend/public/logos/avalanche-logo.svg

This file was deleted.

263 changes: 0 additions & 263 deletions examples/hello/frontend/public/logos/base-logo.svg

This file was deleted.

8 changes: 0 additions & 8 deletions examples/hello/frontend/public/logos/bsc-logo.svg

This file was deleted.

16 changes: 0 additions & 16 deletions examples/hello/frontend/public/logos/ethereum-logo.svg

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions examples/hello/frontend/public/logos/polygon-logo.svg

This file was deleted.

2 changes: 2 additions & 0 deletions examples/hello/frontend/src/ConnectedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
4 changes: 4 additions & 0 deletions examples/hello/frontend/src/DynamicAppContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export function DynamicAppContent() {
return 901;
}

if (network === '502') {
return 103;
}

return null;
}, [network]);

Expand Down
7 changes: 5 additions & 2 deletions examples/hello/frontend/src/components/NetworkSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,18 @@ 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';
}
}).map((chain) => ({
id: chain.chainId,
label: chain.name,
value: chain,
icon: <img src={chain.icon} alt={chain.name} />,
colorHex: chain.colorHex,
})),
[]
Expand Down
18 changes: 8 additions & 10 deletions examples/hello/frontend/src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -13,7 +12,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Arbitrum Sepolia',
chainId: 421614,
chainType: 'EVM',
icon: '/logos/arbitrum-logo.svg',
colorHex: '#28446A',
},
{
Expand All @@ -22,7 +20,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Avalanche Fuji',
chainId: 43113,
chainType: 'EVM',
icon: '/logos/avalanche-logo.svg',
colorHex: '#FF394A',
},
{
Expand All @@ -31,15 +28,13 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Base Sepolia',
chainId: 84532,
chainType: 'EVM',
icon: '/logos/base-logo.svg',
colorHex: '#0052FF',
},
{
explorerUrl: (txHash: string) => `https://testnet.bscscan.com/tx/${txHash}`,
name: 'BSC Testnet',
chainId: 97,
chainType: 'EVM',
icon: '/logos/bsc-logo.svg',
colorHex: '#E1A411',
},
{
Expand All @@ -48,7 +43,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Ethereum Sepolia',
chainId: 11155111,
chainType: 'EVM',
icon: '/logos/ethereum-logo.svg',
colorHex: '#3457D5',
},
{
Expand All @@ -57,7 +51,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Polygon Amoy',
chainId: 80002,
chainType: 'EVM',
icon: '/logos/polygon-logo.svg',
colorHex: '#692BD7',
},
{
Expand All @@ -66,7 +59,6 @@ export const SUPPORTED_CHAINS: SupportedChain[] = [
name: 'Solana Devnet',
chainId: 901,
chainType: 'SOL',
icon: '/logos/solana-logo.svg',
colorHex: '#9945FF',
},
{
Expand All @@ -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 =
Expand Down
44 changes: 44 additions & 0 deletions examples/hello/frontend/src/hooks/useHandleCall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<void> {
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
*/
Expand Down Expand Up @@ -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');
Expand Down