Skip to content
Merged
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
14 changes: 14 additions & 0 deletions example-next/src/components/ConnectedAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,20 @@ const ConnectedAccountItem = ({ account }: { account: ConnectedAccount }) => {
console.log('[inj] tx = ', { tx });
};

// console.log('tx data ', account);

// const tx = await handleTokenPrerequisite();
// console.log('[tron] tx = ', tx);
// };

// const { mutateAsync: handleTokenPrerequisite } = useTokenHandlers({
// amount: 1n,
// chainId: tronMainnet.id,
// owner: account.address,
// spender: '0x0259094fde1684b82d2c6b10b65d044c31c0693a',
// token: '0xa614f803B6FD780986A42c78Ec9c7f77e6DeD13C',
// });

// const currentWallet = useCurrentWallet();
// const walletInstance = useWallet(currentWallet?.type, currentWallet?.id);

Expand Down
42 changes: 42 additions & 0 deletions packages/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
# @tangled3/react

## 1.17.16

### Patch Changes

- fix/tron-wallet

## 1.17.15

### Patch Changes

- match id login fix

## 1.17.14

### Patch Changes

- add pnpm lock file

## 1.17.13

### Patch Changes

- add tron approval

## 1.17.12

### Patch Changes

- added match id wallets

## 1.17.11

### Patch Changes

- match chain approval added

## 1.17.10

### Patch Changes

- match id v1

## 1.17.9

### Patch Changes
Expand Down
5 changes: 3 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tangled3/react",
"private": false,
"version": "1.17.9",
"version": "1.17.16",
"type": "module",
"license": "MIT",
"main": "./src/index.ts",
Expand Down Expand Up @@ -41,6 +41,7 @@
"@cosmos-kit/keplr": "^2.12.2",
"@cosmos-kit/leap": "^2.14.1",
"@cosmos-kit/xdefi": "^2.10.2",
"@matchain/matchid-sdk-react": "^0.1.52",
"@injectivelabs/exceptions": "^1.14.41",
"@injectivelabs/sdk-ts": "^1.14.41",
"@injectivelabs/utils": "^1.14.41",
Expand All @@ -63,7 +64,7 @@
"detect-browser": "^5.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tronweb": "^6.0.1",
"tronweb": "6.0.1",
"usehooks-ts": "^3.1.0",
"viem": "^2.22.2",
"wagmi": "2.14.6",
Expand Down
52 changes: 45 additions & 7 deletions packages/react/src/actions/sendTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type { Network as RouterChainNetwork } from '@routerprotocol/router-chain-sdk-ts';
import { VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
import { sendTransaction as sendEVMTransaction } from '@wagmi/core';
import { Address as EVMAddress } from 'viem';
import { Chain, Address as EVMAddress } from 'viem';
import { ChainData, ChainType, ConnectionOrConfig } from '../types/index.js';
import { WalletInstance } from '../types/wallet.js';
import { signBitcoinTransaction } from './bitcoin/transaction.js';
Expand All @@ -19,10 +19,11 @@
from: string;
value: bigint;
args: TransactionArgs<CData['type']>;
overrides?: any;

Check warning on line 22 in packages/react/src/actions/sendTransaction.ts

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected any. Specify a different type
config: ConnectionOrConfig & {
connector: WalletInstance<CData['type']>;
};
walletClient?: any;

Check warning on line 26 in packages/react/src/actions/sendTransaction.ts

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected any. Specify a different type
};

export type TransactionArgs<CType extends ChainType> = CType extends 'evm' | 'tron'
Expand All @@ -45,7 +46,7 @@
? {
messages: Array<{
readonly typeUrl: string;
readonly value: any;

Check warning on line 49 in packages/react/src/actions/sendTransaction.ts

View workflow job for this annotation

GitHub Actions / build (20)

Unexpected any. Specify a different type
}>;
memo?: string;
routerChainArgs?: {
Expand Down Expand Up @@ -77,8 +78,19 @@
* @param args - Additional arguments
* @param config - {@link ConnectionOrConfig}
*/
export const sendTransactionToChain = (async ({ chain, to, from, value, args, config, overrides = {} }) => {
export const sendTransactionToChain = (async ({
chain,
to,
from,
value,
args,
config,
overrides = {},
walletClient,
}) => {
if (chain.type === 'evm') {
const { calldata } = args as TransactionArgs<'evm'>;

if (overrides?.walletType === 'evm') {
const { sendEthTxnToRouterChainPf, getNetworkInfo, MsgExecuteCwContract, getRouterSignerAddress } = await import(
'@routerprotocol/router-chain-sdk-ts'
Expand Down Expand Up @@ -116,9 +128,30 @@
});

return { txHash: txResponse.tx_response.txhash };
}
} else if (overrides?.walletType === 'matchId') {
console.log('MatchID wallet inside sendTransaction');
if (!walletClient) {
throw new Error('MatchID wallet client initialization failed');
}

const { calldata } = args as TransactionArgs<'evm'>;
try {
const txHash = await walletClient.sendTransaction({
chain: chain as Chain,
account: from as EVMAddress,
to: to as EVMAddress,
value,
data: calldata as `0x${string}`,
...overrides,
});

return {
txHash,
};
} catch (error) {
console.error('MatchID transaction failed:', error);
throw error;
}
}

// send transaction to EVM chain
const txHash = await sendEVMTransaction(config.wagmiConfig, {
Expand All @@ -141,12 +174,17 @@
const walletInstance = config.connector as WalletInstance<'tron'>;
const tronWeb = config.tronWeb;

const signedTx = await walletInstance.signTransaction(calldata);
if (walletInstance.name === 'WalletConnect') {
const signedTx = await walletInstance.signTransaction(calldata);
const tx = await tronWeb.trx.sendRawTransaction(signedTx);

return {
txHash: tx.txid,
};
}
const signedTx = await tronWeb.trx.signTransaction(JSON.parse(calldata));
const tx = await tronWeb.trx.sendRawTransaction(signedTx);

console.log('tx - ', tx);

return {
txHash: tx.txid,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/chains/evm/testnets/rome.testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const romeTestnet: EVMChain = {
},
contracts: {
multicall3: {
address: '0xF9cda624FBC7e059355ce98a31693d299FACd963',
address: '0xee783Cc989AFBa38614Cc3d0643255145278a307',
},
},
};
60 changes: 60 additions & 0 deletions packages/react/src/connectors/evm/walletConfigs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,66 @@ export const walletConfigs: {
url: 'https://rabby.io',
isInstalled: true,
},
google: {
// Use consistent ID with connector
name: 'Google',
url: 'https://www.matchid.ai/',
icon: 'https://www.citypng.com/public/uploads/preview/google-logo-icon-gsuite-hd-701751694791470gzbayltphh.png',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
telegram: {
// Use consistent ID with connector
name: 'Telegram',
url: 'https://www.matchid.ai/',
icon: 'https://i.pinimg.com/474x/9f/f9/9c/9ff99cea674681327ba53e7721246f5b.jpg',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
twitter: {
// Use consistent ID with connector
name: 'Twitter',
url: 'https://www.matchid.ai/',
icon: 'https://freepnglogo.com/images/all_img/1725374683twitter-x-logo.png',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
discord: {
// Use consistent ID with connector
name: 'Discord',
url: 'https://www.matchid.ai/',
icon: 'https://static.vecteezy.com/system/resources/previews/023/741/066/non_2x/discord-logo-icon-social-media-icon-free-png.png',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
github: {
// Use consistent ID with connector
name: 'Github',
url: 'https://www.matchid.ai/',
icon: 'https://static.vecteezy.com/system/resources/previews/053/066/802/non_2x/free-logo-github-free-png.png',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
linkedin: {
// Use consistent ID with connector
name: 'Linkedin',
url: 'https://www.matchid.ai/',
icon: 'https://pngimg.com/d/linkedIn_PNG32.png',
getWalletConnectDeeplink: (uri: string) => {
return isAndroid() ? uri : `https://matchid-login-url.com/wc?uri=${encodeURIComponent(uri)}`;
},
isInstalled: true,
},
safe: {
name: 'Safe',

Expand Down
23 changes: 23 additions & 0 deletions packages/react/src/hooks/useConnect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Hooks } from '@matchain/matchid-sdk-react';
import { useConnectWallet as useSuiConnectWallet } from '@mysten/dapp-kit';
import { WalletName } from '@solana/wallet-adapter-base';
import { useWallet as useSolanaWallet } from '@tangled3/solana-react';
Expand Down Expand Up @@ -26,6 +27,9 @@ export const useConnect = () => {
const connectedWallets = useWalletsStore((state) => state.connectedWalletsByChain);
const setCurrentWallet = useWalletsStore((state) => state.setCurrentWallet);
const setRecentWallet = useWalletsStore((state) => state.setRecentWallet);
const setMatchWallet = useWalletsStore((state) => state.setMatchWallet);
const { useUserInfo } = Hooks;
const { login, logout } = useUserInfo();

const connectWallet = useCallback(
async (params: {
Expand Down Expand Up @@ -53,6 +57,24 @@ export const useConnect = () => {
throw new Error('Wallet not found');
}

type LoginMethodType = 'google' | 'twitter' | 'wallet' | 'telegram' | 'discord' | 'github' | 'linkedin';
if (
params.chainType === 'evm' &&
(params.walletId === 'Google' ||
params.walletId === 'Telegram' ||
params.walletId === 'Twitter' ||
params.walletId === 'Discord' ||
params.walletId === 'Github' ||
params.walletId === 'Linkedin')
) {
await logout();
await login(params.walletId.toLowerCase() as LoginMethodType);
// if (isLogin) {
setMatchWallet(params.walletId);
return { chainType: params.chainType, name: walletInstance.name, walletId: params.walletId };
// }
}

if (!walletInstance.connector) {
throw new Error('Wallet connector not found');
}
Expand Down Expand Up @@ -94,6 +116,7 @@ export const useConnect = () => {
connectEVM,
connectSuiWallet,
connectCosmosWallet,
login,
],
);

Expand Down
18 changes: 17 additions & 1 deletion packages/react/src/hooks/useDisconnect.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Hooks } from '@matchain/matchid-sdk-react';
import { useDisconnectWallet as useSuiDisconnectWallet } from '@mysten/dapp-kit';
import { useWallet as useSolanaWallet } from '@tangled3/solana-react';
import { useMutation } from '@tanstack/react-query';
Expand All @@ -22,6 +23,8 @@ export const useDisconnect = () => {
const { mutate: disconnectSuiWallet } = useSuiDisconnectWallet();
const { disconnect: disconnectCosmosWallet } = useCosmosContext();
const { disconnect: disconnectBitcoinWallet } = useBitcoinContext();
const { useUserInfo } = Hooks;
const { logout } = useUserInfo();

const disconnectWallet = useCallback(
async (params: DisconnectParams) => {
Expand All @@ -38,10 +41,22 @@ export const useDisconnect = () => {

if (!walletInstance) {
console.log(wallets, params.walletId);

throw new Error('Wallet not found');
}

if (
params.chainType === 'evm' &&
(params.walletId === 'Google' ||
params.walletId === 'Telegram' ||
params.walletId === 'Twitter' ||
params.walletId === 'Discord' ||
params.walletId === 'Github' ||
params.walletId === 'Linkedin')
) {
await logout();
return;
}

if (!walletInstance.connector) {
throw new Error('Wallet connector not found');
}
Expand Down Expand Up @@ -70,6 +85,7 @@ export const useDisconnect = () => {
disconnectTronWallet,
disconnectCosmosWallet,
disconnectBitcoinWallet,
logout,
wallets,
],
);
Expand Down
Loading
Loading