Skip to content

Commit 1aa8e07

Browse files
authored
Merge pull request #62 from tronweb3/release/v1.2.10
Release/v1.2.10
2 parents 16fd9fa + 6b4e94d commit 1aa8e07

33 files changed

+1073
-234
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ This repository contains wallet adapters and components for Tron DApps. With out
3737
| [Trust](https://trustwallet.com) | Android | Not Support |
3838
| | IOS | Not Support |
3939
| | Browser Extension | >= 1.0.0 |
40+
| [Tomo](https://tomo.inc/) | Android | 4.2.0 |
41+
| | IOS | 4.2.0 |
42+
| | Browser Extension | Not Support |
4043

4144
> **Note**: In case wallet developers intend to release breaking changes, you can [open an issue here](https://github.com/tronweb3/tronwallet-adapter/issues/new) to inform us, thus enabling us to update the new protocols accordingly.
4245
@@ -200,6 +203,7 @@ tronwallet-adapter
200203
| | ├─foxwallet # adapter for FoxWallet
201204
| | ├─bybit # adapter for Bybit Wallet
202205
| | ├─trust # adapter for Trust Wallet
206+
| | ├─tomowallet # adapter for Tomo Wallet
203207
| ├─react
204208
| | ├─react-hooks # react hooks to manage wallet state
205209
| | ├─react-ui # react ui components to select/connect wallets
@@ -236,6 +240,7 @@ You can use the `@tronweb3/tronwallet-adapters` package, or add the individual w
236240
| [`@tronweb3/tronwallet-adapter-foxwallet`](https://www.npmjs.com/package/@tronweb3/tronwallet-adapter-foxwallet) | Adapter for FoxWallet App(IOS and Android) |
237241
| [`@tronweb3/tronwallet-adapter-bybit`](https://www.npmjs.com/package/@tronweb3/tronwallet-adapter-bybit) | Adapter for Bybit Wallet App(IOS and Android) and Extension |
238242
| [`@tronweb3/tronwallet-adapter-trust`](https://www.npmjs.com/package/@tronweb3/tronwallet-adapter-trust) | Adapter for TrustWallet Extension |
243+
| [`@tronweb3/tronwallet-adapter-tomowallet`](https://www.npmjs.com/package/@tronweb3/tronwallet-adapter-tomowallet) | Adapter for Tomo Wallet App(IOS and Android) |
239244

240245
### React Components
241246

@@ -272,6 +277,7 @@ This package contains all wallet adapters for Tron including:
272277
- [Fox Wallet](https://foxwallet.com/)
273278
- [Bybit Wallet](https://www.bybit.com/web3)
274279
- [Trust](https://trustwallet.com)
280+
- [Tomo](https://tomo.inc/)
275281

276282
Code example:
277283

demos/dev-demo/package.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "dev-demo",
33
"private": true,
4-
"version": "0.0.3",
4+
"version": "0.0.4",
55
"type": "module",
66
"scripts": {
77
"dev": "vite --force",
@@ -21,16 +21,9 @@
2121
"@noble/secp256k1": "1.7.1",
2222
"@tronweb3/abstract-adapter-evm": "latest",
2323
"@tronweb3/tronwallet-abstract-adapter": "latest",
24-
"@tronweb3/tronwallet-adapter-bitkeep": "latest",
25-
"@tronweb3/tronwallet-adapter-imtoken": "latest",
26-
"@tronweb3/tronwallet-adapter-ledger": "latest",
27-
"@tronweb3/tronwallet-adapter-metamask": "latest",
28-
"@tronweb3/tronwallet-adapter-okxwallet": "latest",
29-
"@tronweb3/tronwallet-adapter-react-hooks": "latest",
30-
"@tronweb3/tronwallet-adapter-react-ui": "latest",
31-
"@tronweb3/tronwallet-adapter-tokenpocket": "latest",
32-
"@tronweb3/tronwallet-adapter-tronlink-evm": "latest",
33-
"@tronweb3/tronwallet-adapter-trust": "latest",
24+
"@tronweb3/tronwallet-adapter-ledger": "^1.1.11",
25+
"@tronweb3/tronwallet-adapter-react-hooks": "^1.1.10",
26+
"@tronweb3/tronwallet-adapter-react-ui": "^1.1.11",
3427
"@tronweb3/tronwallet-adapters": "latest",
3528
"events": "^3.3.0",
3629
"ganache": "^7.9.0",
@@ -48,7 +41,7 @@
4841
"@vitejs/plugin-react": "^4.2.1",
4942
"dotenv": "^16.3.1",
5043
"typescript": "^5.5.4",
51-
"vite": "latest",
44+
"vite": "^6.3.5",
5245
"vite-plugin-node-polyfills": "0.17.0"
5346
},
5447
"overrides": {

demos/dev-demo/src/AdapterBasicTest.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
WalletConnectAdapter,
1515
FoxWalletAdapter,
1616
BybitWalletAdapter,
17+
TomoWalletAdapter,
1718
TrustAdapter
1819
} from '@tronweb3/tronwallet-adapters';
1920
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
@@ -24,6 +25,7 @@ const receiver = 'TMDKznuDWaZwfZHcM61FVFstyYNmK6Njk1';
2425
export const AdapterBasicTest = memo(function AdapterBasicTest() {
2526
const adapters = useMemo(
2627
() => [
28+
new TomoWalletAdapter(),
2729
new TronLinkAdapter(),
2830
new TokenPocketAdapter(),
2931
new OkxWalletAdapter(),

demos/dev-demo/src/TronLinkAdapterDemo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export function Detail(props: { children: ReactNode }) {
192192
return <div style={{ margin: 15 }}>{props.children}</div>;
193193
}
194194

195-
function MultiSignDemo(props: { address: string; adapter: Adapter }) {
195+
export function MultiSignDemo(props: { address: string; adapter: Adapter }) {
196196
const [address1, setAddress1] = useState('');
197197
const [open, setOpen] = useState(false);
198198

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import type { Adapter, Transaction } from "@tronweb3/tronwallet-abstract-adapter";
2+
import { useState } from "react";
3+
import { tronWeb } from "../tronweb";
4+
5+
const receiver = 'TMDKznuDWaZwfZHcM61FVFstyYNmK6Njk1';
6+
7+
// update permissionId with yourself permissionId
8+
const permissionId = 2;
9+
// update the first private key with your private key
10+
const privateKey1 = '';
11+
// update the second private key with your private key
12+
const privateKey2 = '';
13+
export function MultiSignUsage({ adapter }: {adapter: Adapter}) {
14+
const [ transaction, setTransaction] = useState<Transaction>();
15+
16+
async function createTransaction() {
17+
const transaction = await tronWeb.transactionBuilder.sendTrx(receiver, tronWeb.toSun(0.000001) as unknown as number, adapter.address!, { permissionId });
18+
setTransaction(transaction);
19+
console.log('Created transaction:', transaction);
20+
alert('success Created')
21+
}
22+
23+
async function signWithAddress1() {
24+
const signedTransaction = await adapter.multiSign(transaction, privateKey1, permissionId);
25+
setTransaction(signedTransaction);
26+
console.log('signedTransaction:', signedTransaction);
27+
alert('success signed')
28+
}
29+
30+
async function signWithAddress2() {
31+
const signedTransaction = await adapter.multiSign(transaction, privateKey2, permissionId);
32+
setTransaction(signedTransaction);
33+
console.log('signedTransaction:', signedTransaction);
34+
alert('success signed')
35+
}
36+
37+
async function broadcast() {
38+
const result = await tronWeb.trx.sendRawTransaction(transaction as any);
39+
console.log('broadcast result:', result);
40+
alert('success broadcast')
41+
}
42+
43+
44+
async function getAccounts() {
45+
const accounts = await tronWeb.trx.getAccount(adapter.address!);
46+
console.log('accounts:', accounts);
47+
}
48+
49+
async function getWeight() {
50+
const signWeight = await tronWeb.trx.getSignWeight(transaction as any);
51+
console.log('signWeight:', signWeight);
52+
}
53+
54+
return <div>
55+
<button onClick={createTransaction}>Create Transaction</button>
56+
<button onClick={signWithAddress1}>sign With Address1</button>
57+
<button onClick={signWithAddress2}>sign With Address2</button>
58+
<button onClick={broadcast}>Broadcast</button>
59+
60+
{/* <button onClick={getAccounts}>getAccount</button>
61+
<button onClick={getWeight}>getWeight</button> */}
62+
</div>
63+
}

demos/dev-demo/src/components/SignUsage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Grid, Input, Link, Snackbar, Stack, styled, Typography } from "@mui/material";
1+
import { Box, Input, Link, Snackbar, Stack, styled, Typography } from "@mui/material";
22
import { Button } from "./common";
33
import { useMemo, useState } from "react";
44
import SuccessIcon from "./SuccessIcon";

demos/dev-demo/src/components/WalletProvider.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
import { WalletProvider as _WalletProvider, useLocalStorage } from "@tronweb3/tronwallet-adapter-react-hooks";
22
import type { PropsWithChildren } from "react";
33
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
4+
import {
5+
TronLinkAdapter} from '@tronweb3/tronwallet-adapters';
46
import {
57
BitKeepAdapter,
68
GateWalletAdapter,
79
ImTokenAdapter,
810
LedgerAdapter,
911
OkxWalletAdapter,
1012
TokenPocketAdapter,
11-
TronLinkAdapter,
1213
WalletConnectAdapter,
1314
FoxWalletAdapter,
1415
BybitWalletAdapter,
16+
TomoWalletAdapterName,
17+
TomoWalletAdapter,
1518
TronLinkAdapterName,
1619
TrustAdapter
1720
} from '@tronweb3/tronwallet-adapters';
@@ -52,6 +55,7 @@ const Context = createContext<WalletContextType>({
5255
export default function WalletProvider({ children }: PropsWithChildren) {
5356
const adapters = useMemo(() => {
5457
return [
58+
new TomoWalletAdapter(),
5559
new TronLinkAdapter(),
5660
new TokenPocketAdapter(),
5761
new OkxWalletAdapter(),
@@ -98,7 +102,7 @@ export default function WalletProvider({ children }: PropsWithChildren) {
98102
connected: true,
99103
address: adapter?.address || '',
100104
}));
101-
(adapter as TronLinkAdapter)?.network?.().then((network) => {
105+
(adapter as unknown as TronLinkAdapter)?.network?.().then((network) => {
102106
setConnectionState(preState => ({
103107
...preState,
104108
chainId: network.chainId,
@@ -142,7 +146,7 @@ export default function WalletProvider({ children }: PropsWithChildren) {
142146
adapter.on('disconnect', onDisconnect);
143147
adapter.on('chainChanged', onChainChanged);
144148
if (adapter?.connected) {
145-
(adapter as TronLinkAdapter)?.network?.().then((network) => {
149+
(adapter as unknown as TronLinkAdapter)?.network?.().then((network) => {
146150
setConnectionState(preState => ({
147151
...preState,
148152
chainId: network.chainId,

demos/dev-demo/src/theme.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { red } from '@mui/material/colors';
44
// Create a theme instance.
55
const theme = createTheme({
66
palette: {
7+
mode: 'light',
78
primary: {
89
main: '#556cd6',
910
},

demos/react-ui/vite-app/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@
1515
"@mui/material": "^5.10.10",
1616
"@noble/secp256k1": "1.7.1",
1717
"@tronweb3/tronwallet-abstract-adapter": "latest",
18-
"@tronweb3/tronwallet-adapter-ledger": "latest",
1918
"@tronweb3/tronwallet-adapter-react-hooks": "latest",
2019
"@tronweb3/tronwallet-adapter-react-ui": "latest",
21-
"@tronweb3/tronwallet-adapter-tronlink": "latest",
22-
"@tronweb3/tronwallet-adapter-walletconnect": "latest",
2320
"@tronweb3/tronwallet-adapters": "latest",
2421
"buffer": "^6.0.3",
2522
"events": "^3.3.0",

demos/vue-ui/vite-app/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
"dependencies": {
1212
"@noble/secp256k1": "^1.7.1",
1313
"@tronweb3/tronwallet-abstract-adapter": "latest",
14-
"@tronweb3/tronwallet-adapter-tronlink": "latest",
1514
"@tronweb3/tronwallet-adapter-vue-hooks": "latest",
1615
"@tronweb3/tronwallet-adapter-vue-ui": "latest",
17-
"@tronweb3/tronwallet-adapter-walletconnect": "latest",
1816
"@tronweb3/tronwallet-adapters": "latest",
1917
"element-plus": "^2.4.3",
2018
"tronweb": "6.0.0",

0 commit comments

Comments
 (0)