@dynamic-labs/tron 4.36.0 → 4.37.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 +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +6 -6
- package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.cjs +28 -0
- package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.d.ts +7 -0
- package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.js +24 -0
- package/src/connectors/TokenPocketTronConnector/index.d.ts +1 -0
- package/src/connectors/TrustTronConnector/TrustTronConnector.cjs +13 -2
- package/src/connectors/TrustTronConnector/TrustTronConnector.js +13 -2
- package/src/index.cjs +2 -0
- package/src/index.js +2 -0
- package/src/types.d.ts +4 -0
- package/src/utils/detectTronNetworkFromProvider.cjs +67 -0
- package/src/utils/detectTronNetworkFromProvider.d.ts +30 -0
- package/src/utils/detectTronNetworkFromProvider.js +62 -0
- package/src/utils/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.37.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.36.1...v4.37.0) (2025-10-08)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add workflow to auto-update documentation changelog on release ([#9642](https://github.com/dynamic-labs/dynamic-auth/issues/9642)) ([701041e](https://github.com/dynamic-labs/dynamic-auth/commit/701041e05d6f2e46869f4e864e4533bbd046b3b6))
|
|
8
|
+
* add delegation ui
|
|
9
|
+
* add token pocket connector for tron
|
|
10
|
+
|
|
11
|
+
### [4.36.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.36.0...v4.36.1) (2025-10-06)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
- Multiple internal improvements
|
|
16
|
+
|
|
2
17
|
## [4.36.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.35.0...v4.36.0) (2025-10-03)
|
|
3
18
|
|
|
4
19
|
|
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.37.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",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.37.0",
|
|
22
22
|
"tronweb": "6.0.4",
|
|
23
|
-
"@dynamic-labs/types": "4.
|
|
24
|
-
"@dynamic-labs/utils": "4.
|
|
25
|
-
"@dynamic-labs/wallet-book": "4.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
23
|
+
"@dynamic-labs/types": "4.37.0",
|
|
24
|
+
"@dynamic-labs/utils": "4.37.0",
|
|
25
|
+
"@dynamic-labs/wallet-book": "4.37.0",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "4.37.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {}
|
|
29
29
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var TronWalletConnector = require('../TronWalletConnector/TronWalletConnector.cjs');
|
|
7
|
+
require('../../../_virtual/_tslib.cjs');
|
|
8
|
+
require('@dynamic-labs/utils');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
var detectTronNetworkFromProvider = require('../../utils/detectTronNetworkFromProvider.cjs');
|
|
11
|
+
|
|
12
|
+
class TokenPocketTronConnector extends TronWalletConnector.TronWalletConnector {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.name = 'TokenPocket';
|
|
16
|
+
this.overrideKey = 'tokenpockettron';
|
|
17
|
+
}
|
|
18
|
+
getProvider() {
|
|
19
|
+
var _a;
|
|
20
|
+
const provider = (_a = window.tokenpocket) === null || _a === void 0 ? void 0 : _a.tron;
|
|
21
|
+
if (!provider) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
return detectTronNetworkFromProvider.detectTronNetworkFromProvider(provider);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exports.TokenPocketTronConnector = TokenPocketTronConnector;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ITronProvider } from '../../types';
|
|
2
|
+
import { TronWalletConnector } from '../TronWalletConnector';
|
|
3
|
+
export declare class TokenPocketTronConnector extends TronWalletConnector {
|
|
4
|
+
name: string;
|
|
5
|
+
overrideKey: string;
|
|
6
|
+
getProvider(): ITronProvider | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { TronWalletConnector } from '../TronWalletConnector/TronWalletConnector.js';
|
|
3
|
+
import '../../../_virtual/_tslib.js';
|
|
4
|
+
import '@dynamic-labs/utils';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import { detectTronNetworkFromProvider } from '../../utils/detectTronNetworkFromProvider.js';
|
|
7
|
+
|
|
8
|
+
class TokenPocketTronConnector extends TronWalletConnector {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.name = 'TokenPocket';
|
|
12
|
+
this.overrideKey = 'tokenpockettron';
|
|
13
|
+
}
|
|
14
|
+
getProvider() {
|
|
15
|
+
var _a;
|
|
16
|
+
const provider = (_a = window.tokenpocket) === null || _a === void 0 ? void 0 : _a.tron;
|
|
17
|
+
if (!provider) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return detectTronNetworkFromProvider(provider);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { TokenPocketTronConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TokenPocketTronConnector } from './TokenPocketTronConnector';
|
|
@@ -12,8 +12,19 @@ class TrustTronConnector extends TronWalletConnector.TronWalletConnector {
|
|
|
12
12
|
this.overrideKey = 'trusttron';
|
|
13
13
|
}
|
|
14
14
|
getProvider() {
|
|
15
|
-
var _a;
|
|
16
|
-
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
const provider = (_a = window.trustwallet) === null || _a === void 0 ? void 0 : _a.tronLink;
|
|
17
|
+
if (provider && provider.ready && !provider.chainId) {
|
|
18
|
+
// Trust Wallet doesn't expose chainId/network, set them manually
|
|
19
|
+
const host = (_c = (_b = provider.tronWeb) === null || _b === void 0 ? void 0 : _b.fullNode) === null || _c === void 0 ? void 0 : _c.host;
|
|
20
|
+
if (host === null || host === void 0 ? void 0 : host.includes('tron.twnodes.com')) {
|
|
21
|
+
Object.assign(provider, {
|
|
22
|
+
chainId: '728126428',
|
|
23
|
+
network: 'mainnet',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return provider;
|
|
17
28
|
}
|
|
18
29
|
}
|
|
19
30
|
|
|
@@ -8,8 +8,19 @@ class TrustTronConnector extends TronWalletConnector {
|
|
|
8
8
|
this.overrideKey = 'trusttron';
|
|
9
9
|
}
|
|
10
10
|
getProvider() {
|
|
11
|
-
var _a;
|
|
12
|
-
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const provider = (_a = window.trustwallet) === null || _a === void 0 ? void 0 : _a.tronLink;
|
|
13
|
+
if (provider && provider.ready && !provider.chainId) {
|
|
14
|
+
// Trust Wallet doesn't expose chainId/network, set them manually
|
|
15
|
+
const host = (_c = (_b = provider.tronWeb) === null || _b === void 0 ? void 0 : _b.fullNode) === null || _c === void 0 ? void 0 : _c.host;
|
|
16
|
+
if (host === null || host === void 0 ? void 0 : host.includes('tron.twnodes.com')) {
|
|
17
|
+
Object.assign(provider, {
|
|
18
|
+
chainId: '728126428',
|
|
19
|
+
network: 'mainnet',
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return provider;
|
|
13
24
|
}
|
|
14
25
|
}
|
|
15
26
|
|
package/src/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ var _package = require('../package.cjs');
|
|
|
8
8
|
var BitgetTronConnector = require('./connectors/BitgetTronConnector/BitgetTronConnector.cjs');
|
|
9
9
|
var BybitTronConnector = require('./connectors/BybitTronConnector/BybitTronConnector.cjs');
|
|
10
10
|
var OKXTronConnector = require('./connectors/OKXTronConnector/OKXTronConnector.cjs');
|
|
11
|
+
var TokenPocketTronConnector = require('./connectors/TokenPocketTronConnector/TokenPocketTronConnector.cjs');
|
|
11
12
|
var TrustTronConnector = require('./connectors/TrustTronConnector/TrustTronConnector.cjs');
|
|
12
13
|
var isTronWallet = require('./wallet/isTronWallet/isTronWallet.cjs');
|
|
13
14
|
var TronWallet = require('./wallet/TronWallet.cjs');
|
|
@@ -17,6 +18,7 @@ const TronWalletConnectors = () => [
|
|
|
17
18
|
BitgetTronConnector.BitgetTronConnector,
|
|
18
19
|
BybitTronConnector.BybitTronConnector,
|
|
19
20
|
OKXTronConnector.OKXTronConnector,
|
|
21
|
+
TokenPocketTronConnector.TokenPocketTronConnector,
|
|
20
22
|
TrustTronConnector.TrustTronConnector,
|
|
21
23
|
];
|
|
22
24
|
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { version } from '../package.js';
|
|
|
4
4
|
import { BitgetTronConnector } from './connectors/BitgetTronConnector/BitgetTronConnector.js';
|
|
5
5
|
import { BybitTronConnector } from './connectors/BybitTronConnector/BybitTronConnector.js';
|
|
6
6
|
import { OKXTronConnector } from './connectors/OKXTronConnector/OKXTronConnector.js';
|
|
7
|
+
import { TokenPocketTronConnector } from './connectors/TokenPocketTronConnector/TokenPocketTronConnector.js';
|
|
7
8
|
import { TrustTronConnector } from './connectors/TrustTronConnector/TrustTronConnector.js';
|
|
8
9
|
export { isTronWallet } from './wallet/isTronWallet/isTronWallet.js';
|
|
9
10
|
export { TronWallet } from './wallet/TronWallet.js';
|
|
@@ -13,6 +14,7 @@ const TronWalletConnectors = () => [
|
|
|
13
14
|
BitgetTronConnector,
|
|
14
15
|
BybitTronConnector,
|
|
15
16
|
OKXTronConnector,
|
|
17
|
+
TokenPocketTronConnector,
|
|
16
18
|
TrustTronConnector,
|
|
17
19
|
];
|
|
18
20
|
|
package/src/types.d.ts
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default endpoint mappings for common TRON networks
|
|
8
|
+
*/
|
|
9
|
+
const DEFAULT_TRON_ENDPOINT_MAPPINGS = [
|
|
10
|
+
{
|
|
11
|
+
hostPatterns: ['api.trongrid.io', 'trx.mytokenpocket.vip'],
|
|
12
|
+
networkConfig: {
|
|
13
|
+
chainId: '728126428',
|
|
14
|
+
network: 'mainnet',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
hostPatterns: ['api.shasta.trongrid.io'],
|
|
19
|
+
networkConfig: {
|
|
20
|
+
chainId: '2494104990',
|
|
21
|
+
network: 'shasta',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
hostPatterns: ['api.nileex.io'],
|
|
26
|
+
networkConfig: {
|
|
27
|
+
chainId: '3448148188',
|
|
28
|
+
network: 'nile',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
/**
|
|
33
|
+
* Detects and sets TRON network information based on the provider's TronWeb endpoint.
|
|
34
|
+
* This is useful for wallets that don't expose chainId/network properties directly.
|
|
35
|
+
*
|
|
36
|
+
* @param provider - The TRON provider to detect network information for
|
|
37
|
+
* @param additionalMappings - Additional endpoint mappings to check before the defaults.
|
|
38
|
+
* @returns The provider with network information set (if detected), or the original provider
|
|
39
|
+
*/
|
|
40
|
+
const detectTronNetworkFromProvider = (provider, additionalMappings = []) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
if (!provider || provider.chainId) {
|
|
43
|
+
// Return early if provider is null/undefined or already has chainId
|
|
44
|
+
return provider;
|
|
45
|
+
}
|
|
46
|
+
const host = (_b = (_a = provider.tronWeb) === null || _a === void 0 ? void 0 : _a.fullNode) === null || _b === void 0 ? void 0 : _b.host;
|
|
47
|
+
if (!host) {
|
|
48
|
+
return provider;
|
|
49
|
+
}
|
|
50
|
+
// Combine additional mappings with defaults, with additional mappings taking precedence
|
|
51
|
+
const allMappings = [
|
|
52
|
+
...additionalMappings,
|
|
53
|
+
...DEFAULT_TRON_ENDPOINT_MAPPINGS,
|
|
54
|
+
];
|
|
55
|
+
// Find the first matching endpoint mapping
|
|
56
|
+
for (const mapping of allMappings) {
|
|
57
|
+
const isMatch = mapping.hostPatterns.some((pattern) => host.includes(pattern));
|
|
58
|
+
if (isMatch) {
|
|
59
|
+
Object.assign(provider, mapping.networkConfig);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return provider;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.DEFAULT_TRON_ENDPOINT_MAPPINGS = DEFAULT_TRON_ENDPOINT_MAPPINGS;
|
|
67
|
+
exports.detectTronNetworkFromProvider = detectTronNetworkFromProvider;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ITronProvider } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Network configuration for TRON networks
|
|
4
|
+
*/
|
|
5
|
+
export interface TronNetworkConfig {
|
|
6
|
+
chainId: string;
|
|
7
|
+
network: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Endpoint mapping configuration for network detection
|
|
11
|
+
*/
|
|
12
|
+
export interface TronEndpointMapping {
|
|
13
|
+
/** URL patterns that should match this network (checked with includes()) */
|
|
14
|
+
hostPatterns: string[];
|
|
15
|
+
/** Network configuration to apply when pattern matches */
|
|
16
|
+
networkConfig: TronNetworkConfig;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Default endpoint mappings for common TRON networks
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_TRON_ENDPOINT_MAPPINGS: TronEndpointMapping[];
|
|
22
|
+
/**
|
|
23
|
+
* Detects and sets TRON network information based on the provider's TronWeb endpoint.
|
|
24
|
+
* This is useful for wallets that don't expose chainId/network properties directly.
|
|
25
|
+
*
|
|
26
|
+
* @param provider - The TRON provider to detect network information for
|
|
27
|
+
* @param additionalMappings - Additional endpoint mappings to check before the defaults.
|
|
28
|
+
* @returns The provider with network information set (if detected), or the original provider
|
|
29
|
+
*/
|
|
30
|
+
export declare const detectTronNetworkFromProvider: <T extends ITronProvider>(provider: T, additionalMappings?: TronEndpointMapping[]) => T;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
/**
|
|
3
|
+
* Default endpoint mappings for common TRON networks
|
|
4
|
+
*/
|
|
5
|
+
const DEFAULT_TRON_ENDPOINT_MAPPINGS = [
|
|
6
|
+
{
|
|
7
|
+
hostPatterns: ['api.trongrid.io', 'trx.mytokenpocket.vip'],
|
|
8
|
+
networkConfig: {
|
|
9
|
+
chainId: '728126428',
|
|
10
|
+
network: 'mainnet',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
hostPatterns: ['api.shasta.trongrid.io'],
|
|
15
|
+
networkConfig: {
|
|
16
|
+
chainId: '2494104990',
|
|
17
|
+
network: 'shasta',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
hostPatterns: ['api.nileex.io'],
|
|
22
|
+
networkConfig: {
|
|
23
|
+
chainId: '3448148188',
|
|
24
|
+
network: 'nile',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Detects and sets TRON network information based on the provider's TronWeb endpoint.
|
|
30
|
+
* This is useful for wallets that don't expose chainId/network properties directly.
|
|
31
|
+
*
|
|
32
|
+
* @param provider - The TRON provider to detect network information for
|
|
33
|
+
* @param additionalMappings - Additional endpoint mappings to check before the defaults.
|
|
34
|
+
* @returns The provider with network information set (if detected), or the original provider
|
|
35
|
+
*/
|
|
36
|
+
const detectTronNetworkFromProvider = (provider, additionalMappings = []) => {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
if (!provider || provider.chainId) {
|
|
39
|
+
// Return early if provider is null/undefined or already has chainId
|
|
40
|
+
return provider;
|
|
41
|
+
}
|
|
42
|
+
const host = (_b = (_a = provider.tronWeb) === null || _a === void 0 ? void 0 : _a.fullNode) === null || _b === void 0 ? void 0 : _b.host;
|
|
43
|
+
if (!host) {
|
|
44
|
+
return provider;
|
|
45
|
+
}
|
|
46
|
+
// Combine additional mappings with defaults, with additional mappings taking precedence
|
|
47
|
+
const allMappings = [
|
|
48
|
+
...additionalMappings,
|
|
49
|
+
...DEFAULT_TRON_ENDPOINT_MAPPINGS,
|
|
50
|
+
];
|
|
51
|
+
// Find the first matching endpoint mapping
|
|
52
|
+
for (const mapping of allMappings) {
|
|
53
|
+
const isMatch = mapping.hostPatterns.some((pattern) => host.includes(pattern));
|
|
54
|
+
if (isMatch) {
|
|
55
|
+
Object.assign(provider, mapping.networkConfig);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return provider;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export { DEFAULT_TRON_ENDPOINT_MAPPINGS, detectTronNetworkFromProvider };
|
package/src/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { assertProvider, getCurrentAddress, isProviderReady } from './provider';
|
|
2
2
|
export { getDefaultTronNetworks } from './getDefaultTronNetworks';
|
|
3
3
|
export { TronUiTransaction, SUN_PER_TRX } from './TronUiTransaction';
|
|
4
|
+
export { detectTronNetworkFromProvider, DEFAULT_TRON_ENDPOINT_MAPPINGS, type TronNetworkConfig, type TronEndpointMapping, } from './detectTronNetworkFromProvider';
|