@dynamic-labs/tron 4.40.1 → 4.41.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +6 -6
  5. package/src/connectors/TronWalletAdapterConnector/TronWalletAdapterConnector.cjs +201 -69
  6. package/src/connectors/TronWalletAdapterConnector/TronWalletAdapterConnector.d.ts +25 -17
  7. package/src/connectors/TronWalletAdapterConnector/TronWalletAdapterConnector.js +201 -69
  8. package/src/index.cjs +2 -10
  9. package/src/index.d.ts +4 -5
  10. package/src/index.js +2 -10
  11. package/src/utils/fetchTronWalletAdapterConnectors/fetchTronWalletAdapterConnectors.cjs +80 -0
  12. package/src/utils/fetchTronWalletAdapterConnectors/fetchTronWalletAdapterConnectors.d.ts +35 -0
  13. package/src/utils/fetchTronWalletAdapterConnectors/fetchTronWalletAdapterConnectors.js +75 -0
  14. package/src/utils/fetchTronWalletAdapterConnectors/index.d.ts +1 -0
  15. package/src/utils/index.d.ts +1 -0
  16. package/src/connectors/BitgetTronConnector/BitgetTronConnector.cjs +0 -20
  17. package/src/connectors/BitgetTronConnector/BitgetTronConnector.d.ts +0 -7
  18. package/src/connectors/BitgetTronConnector/BitgetTronConnector.js +0 -16
  19. package/src/connectors/BitgetTronConnector/index.d.ts +0 -1
  20. package/src/connectors/OKXTronConnector/OKXTronConnector.cjs +0 -20
  21. package/src/connectors/OKXTronConnector/OKXTronConnector.d.ts +0 -7
  22. package/src/connectors/OKXTronConnector/OKXTronConnector.js +0 -16
  23. package/src/connectors/OKXTronConnector/index.d.ts +0 -1
  24. package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.cjs +0 -20
  25. package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.d.ts +0 -7
  26. package/src/connectors/TokenPocketTronConnector/TokenPocketTronConnector.js +0 -16
  27. package/src/connectors/TokenPocketTronConnector/index.d.ts +0 -1
  28. package/src/connectors/TrustTronConnector/TrustTronConnector.cjs +0 -20
  29. package/src/connectors/TrustTronConnector/TrustTronConnector.d.ts +0 -7
  30. package/src/connectors/TrustTronConnector/TrustTronConnector.js +0 -16
  31. package/src/connectors/TrustTronConnector/index.d.ts +0 -1
@@ -0,0 +1,75 @@
1
+ 'use client'
2
+ import { renderTemplate } from '@dynamic-labs/wallet-book';
3
+ import { TronWalletAdapterConnector } from '../../connectors/TronWalletAdapterConnector/TronWalletAdapterConnector.js';
4
+
5
+ /**
6
+ * Checks if a wallet configuration supports TronWallet Adapters.
7
+ *
8
+ * A wallet is considered valid if it has:
9
+ * - An injected config for the 'tron' chain
10
+ * - The tronwallet-adapters feature included in wallet standard features
11
+ * - A valid provider ID
12
+ *
13
+ * @param wallet - The wallet configuration to check
14
+ * @returns true if the wallet supports TronWallet Adapters, false otherwise
15
+ */
16
+ const isValidTronWalletAdapterWallet = (wallet) => {
17
+ var _a;
18
+ return Boolean((_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => {
19
+ var _a, _b;
20
+ return config.chain === 'tron' &&
21
+ Array.isArray((_a = config.walletStandard) === null || _a === void 0 ? void 0 : _a.features) &&
22
+ config.walletStandard.features.includes('tronwallet-adapters:') &&
23
+ ((_b = config.walletStandard) === null || _b === void 0 ? void 0 : _b.providerId);
24
+ }));
25
+ };
26
+ /**
27
+ * Fetches all Tron wallet connectors that support TronWallet Adapters from the wallet book.
28
+ *
29
+ * This function scans the wallet book for wallets with Tron chain configuration
30
+ * and creates connector classes for each matching wallet.
31
+ *
32
+ * @param walletBook - The wallet book schema containing all wallet configurations
33
+ * @param tronNetworks - The Tron networks configuration
34
+ * @returns Array of wallet connector constructors for TronWallet Adapter enabled wallets
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const tronConnectors = fetchTronWalletAdapterConnectors({ walletBook, tronNetworks });
39
+ * // Returns connectors for wallets like TronLink, TokenPocket, OKX, etc.
40
+ * ```
41
+ */
42
+ const fetchTronWalletAdapterConnectors = ({ walletBook, tronNetworks, }) => {
43
+ var _a;
44
+ return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
+ .filter(([_, wallet]) => isValidTronWalletAdapterWallet(wallet))
47
+ .map(([key, wallet]) => {
48
+ const { shortName } = wallet;
49
+ const name = shortName || wallet.name;
50
+ return class extends TronWalletAdapterConnector {
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
+ constructor(props) {
53
+ var _a;
54
+ super(Object.assign(Object.assign({}, props), { metadata: {
55
+ brandColor: undefined,
56
+ deepLinks: undefined,
57
+ downloadLinks: undefined,
58
+ groupKey: undefined,
59
+ icon: ((_a = wallet === null || wallet === void 0 ? void 0 : wallet.brand) === null || _a === void 0 ? void 0 : _a.spriteId)
60
+ ? renderTemplate('iconicUrl', wallet.brand.spriteId)
61
+ : '',
62
+ id: key,
63
+ name: name,
64
+ rdns: undefined,
65
+ supportedHardwareWallets: undefined,
66
+ walletLimitations: undefined,
67
+ }, overrideKey: key, tronNetworks, walletData: wallet }));
68
+ this.name = name;
69
+ this.overrideKey = key;
70
+ }
71
+ };
72
+ });
73
+ };
74
+
75
+ export { fetchTronWalletAdapterConnectors, isValidTronWalletAdapterWallet };
@@ -0,0 +1 @@
1
+ export { fetchTronWalletAdapterConnectors } from './fetchTronWalletAdapterConnectors';
@@ -0,0 +1 @@
1
+ export { fetchTronWalletAdapterConnectors } from './fetchTronWalletAdapterConnectors/fetchTronWalletAdapterConnectors';
@@ -1,20 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var tronwalletAdapters = require('@tronweb3/tronwallet-adapters');
7
- var TronWalletAdapterConnector = require('../TronWalletAdapterConnector/TronWalletAdapterConnector.cjs');
8
-
9
- class BitgetTronConnector extends TronWalletAdapterConnector.TronWalletAdapterConnector {
10
- constructor() {
11
- super(...arguments);
12
- this.name = 'Bitget Wallet';
13
- this.overrideKey = 'bitgettron';
14
- }
15
- createAdapter() {
16
- return new tronwalletAdapters.BitKeepAdapter();
17
- }
18
- }
19
-
20
- exports.BitgetTronConnector = BitgetTronConnector;
@@ -1,7 +0,0 @@
1
- import { BitKeepAdapter } from '@tronweb3/tronwallet-adapters';
2
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector';
3
- export declare class BitgetTronConnector extends TronWalletAdapterConnector {
4
- name: string;
5
- overrideKey: string;
6
- protected createAdapter(): BitKeepAdapter;
7
- }
@@ -1,16 +0,0 @@
1
- 'use client'
2
- import { BitKeepAdapter } from '@tronweb3/tronwallet-adapters';
3
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector/TronWalletAdapterConnector.js';
4
-
5
- class BitgetTronConnector extends TronWalletAdapterConnector {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'Bitget Wallet';
9
- this.overrideKey = 'bitgettron';
10
- }
11
- createAdapter() {
12
- return new BitKeepAdapter();
13
- }
14
- }
15
-
16
- export { BitgetTronConnector };
@@ -1 +0,0 @@
1
- export { BitgetTronConnector } from './BitgetTronConnector';
@@ -1,20 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var tronwalletAdapters = require('@tronweb3/tronwallet-adapters');
7
- var TronWalletAdapterConnector = require('../TronWalletAdapterConnector/TronWalletAdapterConnector.cjs');
8
-
9
- class OKXTronConnector extends TronWalletAdapterConnector.TronWalletAdapterConnector {
10
- constructor() {
11
- super(...arguments);
12
- this.name = 'OKX Wallet';
13
- this.overrideKey = 'okxtron';
14
- }
15
- createAdapter() {
16
- return new tronwalletAdapters.OkxWalletAdapter();
17
- }
18
- }
19
-
20
- exports.OKXTronConnector = OKXTronConnector;
@@ -1,7 +0,0 @@
1
- import { OkxWalletAdapter } from '@tronweb3/tronwallet-adapters';
2
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector';
3
- export declare class OKXTronConnector extends TronWalletAdapterConnector {
4
- name: string;
5
- overrideKey: string;
6
- protected createAdapter(): OkxWalletAdapter;
7
- }
@@ -1,16 +0,0 @@
1
- 'use client'
2
- import { OkxWalletAdapter } from '@tronweb3/tronwallet-adapters';
3
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector/TronWalletAdapterConnector.js';
4
-
5
- class OKXTronConnector extends TronWalletAdapterConnector {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'OKX Wallet';
9
- this.overrideKey = 'okxtron';
10
- }
11
- createAdapter() {
12
- return new OkxWalletAdapter();
13
- }
14
- }
15
-
16
- export { OKXTronConnector };
@@ -1 +0,0 @@
1
- export { OKXTronConnector } from './OKXTronConnector';
@@ -1,20 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var tronwalletAdapters = require('@tronweb3/tronwallet-adapters');
7
- var TronWalletAdapterConnector = require('../TronWalletAdapterConnector/TronWalletAdapterConnector.cjs');
8
-
9
- class TokenPocketTronConnector extends TronWalletAdapterConnector.TronWalletAdapterConnector {
10
- constructor() {
11
- super(...arguments);
12
- this.name = 'TokenPocket';
13
- this.overrideKey = 'tokenpockettron';
14
- }
15
- createAdapter() {
16
- return new tronwalletAdapters.TokenPocketAdapter();
17
- }
18
- }
19
-
20
- exports.TokenPocketTronConnector = TokenPocketTronConnector;
@@ -1,7 +0,0 @@
1
- import { TokenPocketAdapter } from '@tronweb3/tronwallet-adapters';
2
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector';
3
- export declare class TokenPocketTronConnector extends TronWalletAdapterConnector {
4
- name: string;
5
- overrideKey: string;
6
- protected createAdapter(): TokenPocketAdapter;
7
- }
@@ -1,16 +0,0 @@
1
- 'use client'
2
- import { TokenPocketAdapter } from '@tronweb3/tronwallet-adapters';
3
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector/TronWalletAdapterConnector.js';
4
-
5
- class TokenPocketTronConnector extends TronWalletAdapterConnector {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'TokenPocket';
9
- this.overrideKey = 'tokenpockettron';
10
- }
11
- createAdapter() {
12
- return new TokenPocketAdapter();
13
- }
14
- }
15
-
16
- export { TokenPocketTronConnector };
@@ -1 +0,0 @@
1
- export { TokenPocketTronConnector } from './TokenPocketTronConnector';
@@ -1,20 +0,0 @@
1
- 'use client'
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var tronwalletAdapters = require('@tronweb3/tronwallet-adapters');
7
- var TronWalletAdapterConnector = require('../TronWalletAdapterConnector/TronWalletAdapterConnector.cjs');
8
-
9
- class TrustTronConnector extends TronWalletAdapterConnector.TronWalletAdapterConnector {
10
- constructor() {
11
- super(...arguments);
12
- this.name = 'Trust Wallet';
13
- this.overrideKey = 'trusttron';
14
- }
15
- createAdapter() {
16
- return new tronwalletAdapters.TrustAdapter();
17
- }
18
- }
19
-
20
- exports.TrustTronConnector = TrustTronConnector;
@@ -1,7 +0,0 @@
1
- import { TrustAdapter } from '@tronweb3/tronwallet-adapters';
2
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector';
3
- export declare class TrustTronConnector extends TronWalletAdapterConnector {
4
- name: string;
5
- overrideKey: string;
6
- protected createAdapter(): TrustAdapter;
7
- }
@@ -1,16 +0,0 @@
1
- 'use client'
2
- import { TrustAdapter } from '@tronweb3/tronwallet-adapters';
3
- import { TronWalletAdapterConnector } from '../TronWalletAdapterConnector/TronWalletAdapterConnector.js';
4
-
5
- class TrustTronConnector extends TronWalletAdapterConnector {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'Trust Wallet';
9
- this.overrideKey = 'trusttron';
10
- }
11
- createAdapter() {
12
- return new TrustAdapter();
13
- }
14
- }
15
-
16
- export { TrustTronConnector };
@@ -1 +0,0 @@
1
- export { TrustTronConnector } from './TrustTronConnector';