@dynamic-labs/tron 4.32.1 → 4.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -4
- package/src/types.d.ts +67 -39
- package/src/utils/getDefaultTronNetworks.d.ts +9 -0
- package/src/utils/index.d.ts +2 -0
- package/src/utils/provider.d.ts +24 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.34.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.33.0...v4.34.0) (2025-09-30)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add getMultichainBalances to react-native ([#9593](https://github.com/dynamic-labs/dynamic-auth/issues/9593)) ([2e482c3](https://github.com/dynamic-labs/dynamic-auth/commit/2e482c3a3d17e4570173c3ca6e27d83c9fac7265))
|
|
8
|
+
|
|
9
|
+
## [4.33.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.32.1...v4.33.0) (2025-09-26)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add support for signAndExecuteTransactionBlock and signTransactionBlock legacy sui features ([#9574](https://github.com/dynamic-labs/dynamic-auth/issues/9574)) ([316481f](https://github.com/dynamic-labs/dynamic-auth/commit/316481f9255ccc8873d267e85932df3b9d58184b))
|
|
15
|
+
* add viem account for waas wallets ([#9518](https://github.com/dynamic-labs/dynamic-auth/issues/9518)) ([39b6314](https://github.com/dynamic-labs/dynamic-auth/commit/39b631489a5fc38bf8077a91f7dd36d517e42512))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* unable to use backup codes to delete totp method on dynamics ui ([#9575](https://github.com/dynamic-labs/dynamic-auth/issues/9575)) ([db55161](https://github.com/dynamic-labs/dynamic-auth/commit/db5516191103ba00f3d993db28ec0df630e066b0))
|
|
21
|
+
|
|
2
22
|
### [4.32.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.32.0...v4.32.1) (2025-09-25)
|
|
3
23
|
|
|
4
24
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/tron",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.0",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -9,11 +9,18 @@
|
|
|
9
9
|
"types": "./src/index.d.ts",
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./src/index.d.ts",
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.cjs"
|
|
16
|
+
},
|
|
12
17
|
"./package.json": "./package.json"
|
|
13
18
|
},
|
|
14
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
15
20
|
"dependencies": {
|
|
16
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
17
|
-
"tronweb": "6.0.4"
|
|
18
|
-
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.34.0",
|
|
22
|
+
"tronweb": "6.0.4",
|
|
23
|
+
"@dynamic-labs/types": "4.34.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {}
|
|
19
26
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import type { TronWeb, Types } from 'tronweb';
|
|
2
2
|
/**
|
|
3
|
-
* Tron wallet
|
|
4
|
-
|
|
3
|
+
* Global window interface extension for Tron wallet providers
|
|
4
|
+
*/
|
|
5
|
+
declare global {
|
|
6
|
+
interface Window {
|
|
7
|
+
tronLink?: ITronProvider;
|
|
8
|
+
tronWeb?: TronWeb;
|
|
9
|
+
tokenpocket?: {
|
|
10
|
+
tronWeb?: TronWeb;
|
|
11
|
+
tron?: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface that all Tron wallet providers must implement.
|
|
17
|
+
*
|
|
18
|
+
* This interface is designed to be flexible and work with different
|
|
19
|
+
* Tron wallet implementations like TronLink, TokenPocket, etc.
|
|
5
20
|
*/
|
|
6
21
|
export interface ITronProvider {
|
|
7
22
|
/** Whether the wallet is currently connected */
|
|
8
|
-
isConnected
|
|
23
|
+
isConnected?: boolean;
|
|
24
|
+
/** Whether the wallet is ready */
|
|
25
|
+
ready?: boolean;
|
|
9
26
|
/** The current network chain ID */
|
|
10
27
|
chainId?: string;
|
|
11
28
|
/** The current network name */
|
|
@@ -14,60 +31,52 @@ export interface ITronProvider {
|
|
|
14
31
|
address?: string;
|
|
15
32
|
/** TronWeb instance */
|
|
16
33
|
tronWeb?: TronWeb;
|
|
34
|
+
/** TronLink specific flag */
|
|
35
|
+
isTronLink?: boolean;
|
|
17
36
|
/**
|
|
18
|
-
*
|
|
37
|
+
* Request connection to the wallet
|
|
19
38
|
* @returns Promise that resolves to connection result
|
|
20
39
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}>;
|
|
40
|
+
request?(params: {
|
|
41
|
+
method: string;
|
|
42
|
+
params?: unknown;
|
|
43
|
+
}): Promise<unknown>;
|
|
26
44
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @returns Promise that resolves
|
|
29
|
-
*/
|
|
30
|
-
disconnect(): Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Get the current account address
|
|
33
|
-
* @returns Promise that resolves to the address
|
|
45
|
+
* Connect to the wallet (TronLink style)
|
|
46
|
+
* @returns Promise that resolves to connection result
|
|
34
47
|
*/
|
|
35
|
-
|
|
48
|
+
connect?(): Promise<TronConnectionResult>;
|
|
36
49
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @returns Promise that resolves
|
|
50
|
+
* Disconnect from the wallet
|
|
51
|
+
* @returns Promise that resolves when disconnected
|
|
39
52
|
*/
|
|
40
|
-
|
|
41
|
-
chainId: string;
|
|
42
|
-
name: string;
|
|
43
|
-
}>;
|
|
53
|
+
disconnect?(): Promise<void>;
|
|
44
54
|
/**
|
|
45
55
|
* Sign a message
|
|
46
56
|
* @param message - Message to sign
|
|
47
|
-
* @param useTronHeader - Whether to use Tron message header
|
|
48
57
|
* @returns Promise that resolves to the signature
|
|
49
58
|
*/
|
|
50
|
-
signMessage(message: string
|
|
59
|
+
signMessage?(message: string): Promise<string>;
|
|
51
60
|
/**
|
|
52
61
|
* Sign a transaction
|
|
53
62
|
* @param transaction - Transaction to sign
|
|
54
|
-
* @param privateKey - Optional private key (if not using wallet's key)
|
|
55
63
|
* @returns Promise that resolves to the signed transaction
|
|
56
64
|
*/
|
|
57
|
-
signTransaction(transaction: Types.Transaction
|
|
65
|
+
signTransaction?(transaction: Types.Transaction): Promise<Types.SignedTransaction>;
|
|
58
66
|
/**
|
|
59
67
|
* Send a transaction
|
|
60
68
|
* @param transaction - Transaction to send
|
|
61
69
|
* @returns Promise that resolves to transaction result
|
|
62
70
|
*/
|
|
63
|
-
sendTransaction(transaction: Types.SignedTransaction): Promise<Types.BroadcastReturn<Types.SignedTransaction>>;
|
|
71
|
+
sendTransaction?(transaction: Types.SignedTransaction): Promise<Types.BroadcastReturn<Types.SignedTransaction>>;
|
|
64
72
|
/**
|
|
65
73
|
* Send TRX to an address
|
|
66
74
|
* @param to - Recipient address
|
|
67
75
|
* @param amount - Amount in TRX
|
|
76
|
+
* @param options - Optional parameters
|
|
68
77
|
* @returns Promise that resolves to transaction result
|
|
69
78
|
*/
|
|
70
|
-
sendTrx(to: string, amount: number, options?: {
|
|
79
|
+
sendTrx?(to: string, amount: number, options?: {
|
|
71
80
|
from?: string;
|
|
72
81
|
}): Promise<Types.BroadcastReturn<Types.SignedTransaction>>;
|
|
73
82
|
/**
|
|
@@ -75,36 +84,45 @@ export interface ITronProvider {
|
|
|
75
84
|
* @param to - Recipient address
|
|
76
85
|
* @param amount - Amount of tokens
|
|
77
86
|
* @param tokenId - Token ID
|
|
87
|
+
* @param options - Optional parameters
|
|
78
88
|
* @returns Promise that resolves to transaction result
|
|
79
89
|
*/
|
|
80
|
-
sendToken(to: string, amount: number, tokenId: string | number, options?: {
|
|
90
|
+
sendToken?(to: string, amount: number, tokenId: string | number, options?: {
|
|
81
91
|
from?: string;
|
|
82
92
|
}): Promise<Types.BroadcastReturn<Types.SignedTransaction>>;
|
|
83
93
|
/**
|
|
84
94
|
* Get account balance
|
|
85
95
|
* @param address - Optional address (defaults to current account)
|
|
86
|
-
* @returns Promise that resolves to balance
|
|
96
|
+
* @returns Promise that resolves to balance in SUN
|
|
87
97
|
*/
|
|
88
|
-
getBalance(address?: string): Promise<number>;
|
|
98
|
+
getBalance?(address?: string): Promise<number>;
|
|
89
99
|
/**
|
|
90
100
|
* Get token balance
|
|
91
101
|
* @param tokenId - Token ID
|
|
92
102
|
* @param address - Optional address (defaults to current account)
|
|
93
103
|
* @returns Promise that resolves to token balance
|
|
94
104
|
*/
|
|
95
|
-
getTokenBalance(tokenId: string, address?: string): Promise<number>;
|
|
105
|
+
getTokenBalance?(tokenId: string, address?: string): Promise<number>;
|
|
106
|
+
/**
|
|
107
|
+
* Get current network information
|
|
108
|
+
* @returns Promise that resolves to network info
|
|
109
|
+
*/
|
|
110
|
+
getNetwork?(): Promise<{
|
|
111
|
+
chainId: string;
|
|
112
|
+
name: string;
|
|
113
|
+
}>;
|
|
96
114
|
/**
|
|
97
115
|
* Switch network
|
|
98
116
|
* @param networkId - Network ID to switch to
|
|
99
117
|
* @returns Promise that resolves when network is switched
|
|
100
118
|
*/
|
|
101
|
-
switchNetwork(networkId: string): Promise<void>;
|
|
119
|
+
switchNetwork?(networkId: string): Promise<void>;
|
|
102
120
|
/**
|
|
103
121
|
* Add network
|
|
104
122
|
* @param network - Network configuration to add
|
|
105
123
|
* @returns Promise that resolves when network is added
|
|
106
124
|
*/
|
|
107
|
-
addNetwork(network: {
|
|
125
|
+
addNetwork?(network: {
|
|
108
126
|
networkId: string;
|
|
109
127
|
name: string;
|
|
110
128
|
rpcUrl: string;
|
|
@@ -114,12 +132,12 @@ export interface ITronProvider {
|
|
|
114
132
|
* Listen for account changes
|
|
115
133
|
* @param callback - Callback function for account changes
|
|
116
134
|
*/
|
|
117
|
-
onAccountChange(callback: (address: string) => void): void;
|
|
135
|
+
onAccountChange?(callback: (address: string) => void): void;
|
|
118
136
|
/**
|
|
119
137
|
* Listen for network changes
|
|
120
138
|
* @param callback - Callback function for network changes
|
|
121
139
|
*/
|
|
122
|
-
onNetworkChange(callback: (network: {
|
|
140
|
+
onNetworkChange?(callback: (network: {
|
|
123
141
|
chainId: string;
|
|
124
142
|
name: string;
|
|
125
143
|
}) => void): void;
|
|
@@ -127,13 +145,23 @@ export interface ITronProvider {
|
|
|
127
145
|
* Remove account change listener
|
|
128
146
|
* @param callback - Callback function to remove
|
|
129
147
|
*/
|
|
130
|
-
removeAccountChangeListener(callback: (address: string) => void): void;
|
|
148
|
+
removeAccountChangeListener?(callback: (address: string) => void): void;
|
|
131
149
|
/**
|
|
132
150
|
* Remove network change listener
|
|
133
151
|
* @param callback - Callback function to remove
|
|
134
152
|
*/
|
|
135
|
-
removeNetworkChangeListener(callback: (network: {
|
|
153
|
+
removeNetworkChangeListener?(callback: (network: {
|
|
136
154
|
chainId: string;
|
|
137
155
|
name: string;
|
|
138
156
|
}) => void): void;
|
|
157
|
+
/** Additional properties that providers may implement */
|
|
158
|
+
[key: string]: unknown;
|
|
139
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* Result from wallet connection
|
|
162
|
+
*/
|
|
163
|
+
export type TronConnectionResult = {
|
|
164
|
+
address: string;
|
|
165
|
+
chainId?: string;
|
|
166
|
+
network?: string;
|
|
167
|
+
} | string | boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GenericNetwork } from '@dynamic-labs/types';
|
|
2
|
+
export declare const TRON_MAINNET_NETWORK: GenericNetwork;
|
|
3
|
+
export declare const TRON_NILE_TESTNET_NETWORK: GenericNetwork;
|
|
4
|
+
export declare const TRON_SHASTA_TESTNET_NETWORK: GenericNetwork;
|
|
5
|
+
/**
|
|
6
|
+
* Gets the default Tron networks configuration
|
|
7
|
+
* @returns Array of default Tron networks
|
|
8
|
+
*/
|
|
9
|
+
export declare const getDefaultTronNetworks: () => GenericNetwork[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for Tron provider validation and error handling
|
|
3
|
+
*/
|
|
4
|
+
import type { ITronProvider } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* Asserts that a provider is available and throws an error if not
|
|
7
|
+
* @param provider - The provider to validate
|
|
8
|
+
* @param providerName - Human-readable name for error messages
|
|
9
|
+
* @returns The validated provider
|
|
10
|
+
* @throws {Error} If provider is not available
|
|
11
|
+
*/
|
|
12
|
+
export declare const assertProvider: <T>(provider: T | undefined, providerName: string) => T;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the current address from a Tron provider using various methods
|
|
15
|
+
* @param provider - The Tron provider
|
|
16
|
+
* @returns The current address or undefined if not available
|
|
17
|
+
*/
|
|
18
|
+
export declare const getCurrentAddress: (provider: ITronProvider) => string | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Checks if a Tron provider is ready and connected
|
|
21
|
+
* @param provider - The Tron provider
|
|
22
|
+
* @returns True if the provider is ready and connected
|
|
23
|
+
*/
|
|
24
|
+
export declare const isProviderReady: (provider: ITronProvider) => boolean;
|