@talken/talkenkit 2.7.5-beta.1 → 2.7.5-beta.2
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/dist/abcWallet-HKEIJA6T.js +172 -0
- package/dist/chunk-CGSOMXYJ.js +5757 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +874 -792
- package/dist/providers/SignConfirmationProvider/SuppressSignConfirmation.d.ts +11 -0
- package/dist/providers/SignConfirmationProvider/index.d.ts +1 -0
- package/dist/providers/TransactionResultProvider/SuppressTransactionResult.d.ts +11 -0
- package/dist/providers/TransactionResultProvider/index.d.ts +1 -0
- package/dist/providers/TransactionResultProvider/types.d.ts +1 -0
- package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.d.ts +9 -0
- package/dist/wallets/walletConnectors/abcWallet/AbstractChainProvider.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +2 -2
- package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +13 -13
- package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +7 -7
- package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +9 -9
- package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
- package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +14 -14
- package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +6 -6
- package/dist/wallets/walletConnectors/abcWallet/api/index.js +6 -6
- package/dist/wallets/walletConnectors/abcWallet/api/modules/auth.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/api/modules/bitcoin.d.ts +1 -1
- package/dist/wallets/walletConnectors/abcWallet/index.js +45 -45
- package/dist/wallets/walletConnectors/abcWallet/types/api.types.d.ts +10 -10
- package/dist/wallets/walletConnectors/abcWallet/types.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/utils.js +1 -1
- package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +4 -4
- package/dist/wallets/walletConnectors/berasigWallet/berasigWallet.js +2 -2
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/binanceWallet/binanceWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/chunk-25VIZXJZ.js +341 -0
- package/dist/wallets/walletConnectors/chunk-26URNKLZ.js +341 -0
- package/dist/wallets/walletConnectors/chunk-2H2JI5BJ.js +108 -0
- package/dist/wallets/walletConnectors/chunk-3QC567QK.js +94 -0
- package/dist/wallets/walletConnectors/chunk-4K2V7RCL.js +96 -0
- package/dist/wallets/walletConnectors/chunk-4QNRNDMZ.js +378 -0
- package/dist/wallets/walletConnectors/chunk-4V3HRM2R.js +95 -0
- package/dist/wallets/walletConnectors/chunk-5QYCHHVB.js +98 -0
- package/dist/wallets/walletConnectors/chunk-6P3FYHAH.js +108 -0
- package/dist/wallets/walletConnectors/chunk-76M232IF.js +101 -0
- package/dist/wallets/walletConnectors/chunk-7IBMHOYD.js +102 -0
- package/dist/wallets/walletConnectors/chunk-ACGSFRMZ.js +73 -0
- package/dist/wallets/walletConnectors/chunk-BZPKBSWY.js +66 -0
- package/dist/wallets/walletConnectors/chunk-CHEPDEJ2.js +73 -0
- package/dist/wallets/walletConnectors/chunk-CMETID7A.js +1463 -0
- package/dist/wallets/walletConnectors/chunk-DDRPEB2X.js +366 -0
- package/dist/wallets/walletConnectors/chunk-DHWJ3552.js +93 -0
- package/dist/wallets/walletConnectors/chunk-DPVILLWF.js +492 -0
- package/dist/wallets/walletConnectors/chunk-EJALZNAR.js +101 -0
- package/dist/wallets/walletConnectors/chunk-FVA6H2VF.js +95 -0
- package/dist/wallets/walletConnectors/chunk-G7QF44XS.js +378 -0
- package/dist/wallets/walletConnectors/chunk-GCHYGJNO.js +131 -0
- package/dist/wallets/walletConnectors/chunk-GNF5CHDQ.js +102 -0
- package/dist/wallets/walletConnectors/chunk-GZPGNUNF.js +94 -0
- package/dist/wallets/walletConnectors/chunk-HALTGRQW.js +87 -0
- package/dist/wallets/walletConnectors/chunk-I2LB6GVH.js +341 -0
- package/dist/wallets/walletConnectors/chunk-JL3QLDZK.js +186 -0
- package/dist/wallets/walletConnectors/chunk-KLCVXROA.js +71 -0
- package/dist/wallets/walletConnectors/chunk-KNNHGFKJ.js +98 -0
- package/dist/wallets/walletConnectors/chunk-KQDFRZT4.js +65 -0
- package/dist/wallets/walletConnectors/chunk-LKNK2KKU.js +76 -0
- package/dist/wallets/walletConnectors/chunk-LLOSDVCH.js +58 -0
- package/dist/wallets/walletConnectors/chunk-MQ57XDYK.js +340 -0
- package/dist/wallets/walletConnectors/chunk-MUAOEA3O.js +103 -0
- package/dist/wallets/walletConnectors/chunk-MVZX47XV.js +366 -0
- package/dist/wallets/walletConnectors/chunk-MWHKTQPO.js +71 -0
- package/dist/wallets/walletConnectors/chunk-MYQPTETH.js +186 -0
- package/dist/wallets/walletConnectors/chunk-NP7RQXKC.js +94 -0
- package/dist/wallets/walletConnectors/chunk-OKTFRDOV.js +340 -0
- package/dist/wallets/walletConnectors/chunk-PXL5G2PM.js +96 -0
- package/dist/wallets/walletConnectors/chunk-QB3QLNSL.js +76 -0
- package/dist/wallets/walletConnectors/chunk-QCM7BJYI.js +366 -0
- package/dist/wallets/walletConnectors/chunk-QRU6XFHH.js +110 -0
- package/dist/wallets/walletConnectors/chunk-RIN5NUVA.js +1463 -0
- package/dist/wallets/walletConnectors/chunk-RM3S3BY3.js +58 -0
- package/dist/wallets/walletConnectors/chunk-S5XGT2XC.js +131 -0
- package/dist/wallets/walletConnectors/chunk-SJ7H7FJB.js +58 -0
- package/dist/wallets/walletConnectors/chunk-TA4DDCKN.js +96 -0
- package/dist/wallets/walletConnectors/chunk-TWVKSPTP.js +91 -0
- package/dist/wallets/walletConnectors/chunk-U5UPCM5V.js +66 -0
- package/dist/wallets/walletConnectors/chunk-UZAUWE5E.js +27 -0
- package/dist/wallets/walletConnectors/chunk-V2C47DTB.js +66 -0
- package/dist/wallets/walletConnectors/chunk-XFUNA24R.js +195 -0
- package/dist/wallets/walletConnectors/chunk-XS6GJRRA.js +98 -0
- package/dist/wallets/walletConnectors/chunk-XSJUQHR7.js +95 -0
- package/dist/wallets/walletConnectors/chunk-XSX5EECZ.js +96 -0
- package/dist/wallets/walletConnectors/chunk-YJ5RF7V4.js +492 -0
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +87 -87
- package/dist/wallets/walletConnectors/iopayWallet/iopayWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaiaWallet/kaiaWallet.js +2 -2
- package/dist/wallets/walletConnectors/kaikasWallet/kaikasWallet.js +2 -2
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zealWallet/zealWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isAndroid,
|
|
4
|
+
isIOS
|
|
5
|
+
} from "./chunk-RETKWSKD.js";
|
|
6
|
+
import {
|
|
7
|
+
getInjectedConnector,
|
|
8
|
+
hasInjectedProvider
|
|
9
|
+
} from "./chunk-PONHGUSY.js";
|
|
10
|
+
import {
|
|
11
|
+
getWalletConnectConnector
|
|
12
|
+
} from "./chunk-PODFK4OS.js";
|
|
13
|
+
|
|
14
|
+
// src/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.ts
|
|
15
|
+
function isMetaMask(ethereum) {
|
|
16
|
+
if (!ethereum?.isMetaMask)
|
|
17
|
+
return false;
|
|
18
|
+
if (ethereum.isBraveWallet && !ethereum._events && !ethereum._state)
|
|
19
|
+
return false;
|
|
20
|
+
if (ethereum.isApexWallet)
|
|
21
|
+
return false;
|
|
22
|
+
if (ethereum.isAvalanche)
|
|
23
|
+
return false;
|
|
24
|
+
if (ethereum.isBackpack)
|
|
25
|
+
return false;
|
|
26
|
+
if (ethereum.isBifrost)
|
|
27
|
+
return false;
|
|
28
|
+
if (ethereum.isBitKeep)
|
|
29
|
+
return false;
|
|
30
|
+
if (ethereum.isBitski)
|
|
31
|
+
return false;
|
|
32
|
+
if (ethereum.isBlockWallet)
|
|
33
|
+
return false;
|
|
34
|
+
if (ethereum.isCoinbaseWallet)
|
|
35
|
+
return false;
|
|
36
|
+
if (ethereum.isDawn)
|
|
37
|
+
return false;
|
|
38
|
+
if (ethereum.isEnkrypt)
|
|
39
|
+
return false;
|
|
40
|
+
if (ethereum.isExodus)
|
|
41
|
+
return false;
|
|
42
|
+
if (ethereum.isFrame)
|
|
43
|
+
return false;
|
|
44
|
+
if (ethereum.isFrontier)
|
|
45
|
+
return false;
|
|
46
|
+
if (ethereum.isGamestop)
|
|
47
|
+
return false;
|
|
48
|
+
if (ethereum.isHyperPay)
|
|
49
|
+
return false;
|
|
50
|
+
if (ethereum.isImToken)
|
|
51
|
+
return false;
|
|
52
|
+
if (ethereum.isKuCoinWallet)
|
|
53
|
+
return false;
|
|
54
|
+
if (ethereum.isMathWallet)
|
|
55
|
+
return false;
|
|
56
|
+
if (ethereum.isNestWallet)
|
|
57
|
+
return false;
|
|
58
|
+
if (ethereum.isOkxWallet || ethereum.isOKExWallet)
|
|
59
|
+
return false;
|
|
60
|
+
if (ethereum.isOneInchIOSWallet || ethereum.isOneInchAndroidWallet)
|
|
61
|
+
return false;
|
|
62
|
+
if (ethereum.isOpera)
|
|
63
|
+
return false;
|
|
64
|
+
if (ethereum.isPhantom)
|
|
65
|
+
return false;
|
|
66
|
+
if (ethereum.isPortal)
|
|
67
|
+
return false;
|
|
68
|
+
if (ethereum.isRabby)
|
|
69
|
+
return false;
|
|
70
|
+
if (ethereum.isRainbow)
|
|
71
|
+
return false;
|
|
72
|
+
if (ethereum.isStatus)
|
|
73
|
+
return false;
|
|
74
|
+
if (ethereum.isTalisman)
|
|
75
|
+
return false;
|
|
76
|
+
if (ethereum.isTally)
|
|
77
|
+
return false;
|
|
78
|
+
if (ethereum.isTokenPocket)
|
|
79
|
+
return false;
|
|
80
|
+
if (ethereum.isTokenary)
|
|
81
|
+
return false;
|
|
82
|
+
if (ethereum.isTrust || ethereum.isTrustWallet)
|
|
83
|
+
return false;
|
|
84
|
+
if (ethereum.isXDEFI)
|
|
85
|
+
return false;
|
|
86
|
+
if (ethereum.isZeal)
|
|
87
|
+
return false;
|
|
88
|
+
if (ethereum.isZerion)
|
|
89
|
+
return false;
|
|
90
|
+
if (ethereum.__seif)
|
|
91
|
+
return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
var metaMaskWallet = ({
|
|
95
|
+
projectId,
|
|
96
|
+
walletConnectParameters
|
|
97
|
+
}) => {
|
|
98
|
+
const isMetaMaskInjected = hasInjectedProvider({ flag: "isMetaMask" });
|
|
99
|
+
const shouldUseWalletConnect = !isMetaMaskInjected;
|
|
100
|
+
const getUri = (uri) => {
|
|
101
|
+
return isAndroid() ? uri : isIOS() ? (
|
|
102
|
+
// currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
|
|
103
|
+
`metamask://wc?uri=${encodeURIComponent(uri)}`
|
|
104
|
+
) : `https://metamask.app.link/wc?uri=${encodeURIComponent(uri)}`;
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
id: "metaMask",
|
|
108
|
+
name: "MetaMask",
|
|
109
|
+
rdns: "io.metamask",
|
|
110
|
+
iconUrl: async () => (await import("./metaMaskWallet-TTFGMJRC.js")).default,
|
|
111
|
+
iconAccent: "#f6851a",
|
|
112
|
+
iconBackground: "#fff",
|
|
113
|
+
installed: !shouldUseWalletConnect ? isMetaMaskInjected : void 0,
|
|
114
|
+
downloadUrls: {
|
|
115
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
116
|
+
ios: "https://apps.apple.com/us/app/metamask/id1438144202",
|
|
117
|
+
mobile: "https://metamask.io/download",
|
|
118
|
+
qrCode: "https://metamask.io/download",
|
|
119
|
+
chrome: "https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",
|
|
120
|
+
edge: "https://microsoftedge.microsoft.com/addons/detail/metamask/ejbalbakoplchlghecdalmeeeajnimhm",
|
|
121
|
+
firefox: "https://addons.mozilla.org/firefox/addon/ether-metamask",
|
|
122
|
+
opera: "https://addons.opera.com/extensions/details/metamask-10",
|
|
123
|
+
browserExtension: "https://metamask.io/download"
|
|
124
|
+
},
|
|
125
|
+
mobile: {
|
|
126
|
+
getUri: shouldUseWalletConnect ? getUri : void 0
|
|
127
|
+
},
|
|
128
|
+
qrCode: shouldUseWalletConnect ? {
|
|
129
|
+
getUri,
|
|
130
|
+
instructions: {
|
|
131
|
+
learnMoreUrl: "https://metamask.io/faqs/",
|
|
132
|
+
steps: [
|
|
133
|
+
{
|
|
134
|
+
description: "wallet_connectors.metamask.qr_code.step1.description",
|
|
135
|
+
step: "install",
|
|
136
|
+
title: "wallet_connectors.metamask.qr_code.step1.title"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
description: "wallet_connectors.metamask.qr_code.step2.description",
|
|
140
|
+
step: "create",
|
|
141
|
+
title: "wallet_connectors.metamask.qr_code.step2.title"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
description: "wallet_connectors.metamask.qr_code.step3.description",
|
|
145
|
+
step: "refresh",
|
|
146
|
+
title: "wallet_connectors.metamask.qr_code.step3.title"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
} : void 0,
|
|
151
|
+
extension: {
|
|
152
|
+
instructions: {
|
|
153
|
+
learnMoreUrl: "https://metamask.io/faqs/",
|
|
154
|
+
steps: [
|
|
155
|
+
{
|
|
156
|
+
description: "wallet_connectors.metamask.extension.step1.description",
|
|
157
|
+
step: "install",
|
|
158
|
+
title: "wallet_connectors.metamask.extension.step1.title"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
description: "wallet_connectors.metamask.extension.step2.description",
|
|
162
|
+
step: "create",
|
|
163
|
+
title: "wallet_connectors.metamask.extension.step2.title"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
description: "wallet_connectors.metamask.extension.step3.description",
|
|
167
|
+
step: "refresh",
|
|
168
|
+
title: "wallet_connectors.metamask.extension.step3.title"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
|
|
174
|
+
projectId,
|
|
175
|
+
walletConnectParameters
|
|
176
|
+
}) : getInjectedConnector({
|
|
177
|
+
target: typeof window !== "undefined" ? window.ethereum?.providers?.find(
|
|
178
|
+
isMetaMask
|
|
179
|
+
) ?? window.ethereum : void 0
|
|
180
|
+
})
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export {
|
|
185
|
+
metaMaskWallet
|
|
186
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getInjectedConnector,
|
|
4
|
+
hasInjectedProvider
|
|
5
|
+
} from "./chunk-PONHGUSY.js";
|
|
6
|
+
import {
|
|
7
|
+
getWalletConnectConnector
|
|
8
|
+
} from "./chunk-PODFK4OS.js";
|
|
9
|
+
|
|
10
|
+
// src/wallets/walletConnectors/kaiaWallet/kaiaWallet.ts
|
|
11
|
+
var kaiaWallet = ({
|
|
12
|
+
projectId,
|
|
13
|
+
walletConnectParameters
|
|
14
|
+
}) => {
|
|
15
|
+
const isKaiaWalletInjected = hasInjectedProvider({
|
|
16
|
+
namespace: "klaytn"
|
|
17
|
+
});
|
|
18
|
+
const shouldUseWalletConnect = !isKaiaWalletInjected;
|
|
19
|
+
const getUri = (uri) => {
|
|
20
|
+
return `kaikas://walletconnect?uri=${encodeURIComponent(uri)}`;
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
id: "kaia",
|
|
24
|
+
name: "Kaia Wallet",
|
|
25
|
+
rdns: "io.kaiawallet",
|
|
26
|
+
iconUrl: async () => (await import("./kaiaWallet-VL3KZ3AU.js")).default,
|
|
27
|
+
installed: isKaiaWalletInjected || void 0,
|
|
28
|
+
iconBackground: "#fff",
|
|
29
|
+
downloadUrls: {
|
|
30
|
+
chrome: "https://chromewebstore.google.com/detail/kaia-wallet/jblndlipeogpafnldhgmapagcccfchpi",
|
|
31
|
+
browserExtension: "https://app.kaiawallet.io",
|
|
32
|
+
qrCode: "https://app.kaiawallet.io",
|
|
33
|
+
ios: "https://apps.apple.com/us/app/kaia-wallet/id6502896387",
|
|
34
|
+
android: "https://play.google.com/store/apps/details?id=io.klutch.wallet",
|
|
35
|
+
mobile: "https://app.kaiawallet.io"
|
|
36
|
+
},
|
|
37
|
+
mobile: { getUri: shouldUseWalletConnect ? getUri : void 0 },
|
|
38
|
+
qrCode: shouldUseWalletConnect ? {
|
|
39
|
+
getUri: (uri) => uri,
|
|
40
|
+
instructions: {
|
|
41
|
+
learnMoreUrl: "https://kaiawallet.io",
|
|
42
|
+
steps: [
|
|
43
|
+
{
|
|
44
|
+
description: "wallet_connectors.kaia.qr_code.step1.description",
|
|
45
|
+
step: "install",
|
|
46
|
+
title: "wallet_connectors.kaia.qr_code.step1.title"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
description: "wallet_connectors.kaia.qr_code.step2.description",
|
|
50
|
+
step: "create",
|
|
51
|
+
title: "wallet_connectors.kaia.qr_code.step2.title"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
description: "wallet_connectors.kaia.qr_code.step3.description",
|
|
55
|
+
step: "refresh",
|
|
56
|
+
title: "wallet_connectors.kaia.qr_code.step3.title"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
} : void 0,
|
|
61
|
+
extension: {
|
|
62
|
+
instructions: {
|
|
63
|
+
learnMoreUrl: "https://kaiawallet.io",
|
|
64
|
+
steps: [
|
|
65
|
+
{
|
|
66
|
+
description: "wallet_connectors.kaia.extension.step1.description",
|
|
67
|
+
step: "install",
|
|
68
|
+
title: "wallet_connectors.kaia.extension.step1.title"
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
description: "wallet_connectors.kaia.extension.step2.description",
|
|
72
|
+
step: "create",
|
|
73
|
+
title: "wallet_connectors.kaia.extension.step2.title"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
description: "wallet_connectors.kaia.extension.step3.description",
|
|
77
|
+
step: "refresh",
|
|
78
|
+
title: "wallet_connectors.kaia.extension.step3.title"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
|
|
84
|
+
projectId,
|
|
85
|
+
walletConnectParameters
|
|
86
|
+
}) : getInjectedConnector({
|
|
87
|
+
namespace: "klaytn"
|
|
88
|
+
})
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
kaiaWallet
|
|
94
|
+
};
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
AbstractChainProvider
|
|
4
|
+
} from "./chunk-GCHYGJNO.js";
|
|
5
|
+
import {
|
|
6
|
+
ProviderErrorCode,
|
|
7
|
+
TronProviderError
|
|
8
|
+
} from "./chunk-GJ4CJL7F.js";
|
|
9
|
+
import {
|
|
10
|
+
createLogger
|
|
11
|
+
} from "./chunk-762I67R6.js";
|
|
12
|
+
import {
|
|
13
|
+
getCredentialManager
|
|
14
|
+
} from "./chunk-P6KWAOFF.js";
|
|
15
|
+
|
|
16
|
+
// src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
|
|
17
|
+
import { keccak256 } from "viem";
|
|
18
|
+
var logger = createLogger("TronProvider");
|
|
19
|
+
function isTalkenApiClient(client) {
|
|
20
|
+
return typeof client?.tron?.transferTrx === "function";
|
|
21
|
+
}
|
|
22
|
+
var TRON_NETWORKS = {
|
|
23
|
+
mainnet: {
|
|
24
|
+
name: "TRON Mainnet",
|
|
25
|
+
type: "tron",
|
|
26
|
+
explorer: "https://tronscan.org"
|
|
27
|
+
},
|
|
28
|
+
nile: {
|
|
29
|
+
name: "TRON Nile Testnet",
|
|
30
|
+
type: "tron_nile",
|
|
31
|
+
explorer: "https://nile.tronscan.org"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
var AbcTronProvider = class extends AbstractChainProvider {
|
|
35
|
+
constructor(client) {
|
|
36
|
+
super(isTalkenApiClient(client) ? client : void 0);
|
|
37
|
+
this.network = TRON_NETWORKS.mainnet;
|
|
38
|
+
this.tokenMetadataCache = /* @__PURE__ */ new Map();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Call request interceptor if set (throws on user cancel)
|
|
42
|
+
*/
|
|
43
|
+
async callInterceptor(request) {
|
|
44
|
+
if (this.requestInterceptor) {
|
|
45
|
+
await this.requestInterceptor(request);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onWalletSet(wallet) {
|
|
49
|
+
if (wallet.network === "tron") {
|
|
50
|
+
this.network = TRON_NETWORKS.mainnet;
|
|
51
|
+
} else {
|
|
52
|
+
this.network = TRON_NETWORKS.nile;
|
|
53
|
+
}
|
|
54
|
+
this.emit("connect", {
|
|
55
|
+
address: wallet.address,
|
|
56
|
+
network: this.network.type
|
|
57
|
+
});
|
|
58
|
+
logger.info(
|
|
59
|
+
"Wallet connected:",
|
|
60
|
+
`${wallet.address.substring(0, 6)}...${wallet.address.substring(wallet.address.length - 6)}`
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
clearWallet() {
|
|
64
|
+
super.clearWallet();
|
|
65
|
+
logger.info("Wallet disconnected");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Fetch token metadata (symbol, logo) from walletscan API with caching.
|
|
69
|
+
* Falls back to 'TRX'/'TRC20' on failure.
|
|
70
|
+
*/
|
|
71
|
+
async fetchTokenMetadata(contractAddress) {
|
|
72
|
+
const cacheKey = contractAddress || "__native__";
|
|
73
|
+
const cached = this.tokenMetadataCache.get(cacheKey);
|
|
74
|
+
if (cached)
|
|
75
|
+
return cached;
|
|
76
|
+
try {
|
|
77
|
+
const api = this.getTalkenApiClientOrThrow();
|
|
78
|
+
const chainKeys = this.network.type === "tron_nile" ? "tronNile" : "tron";
|
|
79
|
+
let tokens;
|
|
80
|
+
if (contractAddress) {
|
|
81
|
+
tokens = await api.walletscan.getToken({ chainKeys, contractAddress });
|
|
82
|
+
} else {
|
|
83
|
+
tokens = await api.walletscan.getNativeTokens({
|
|
84
|
+
chainKeys,
|
|
85
|
+
walletAddress: this.wallet.address
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (tokens.length > 0) {
|
|
89
|
+
const info = { symbol: tokens[0].symbol, logo: tokens[0].logo };
|
|
90
|
+
this.tokenMetadataCache.set(cacheKey, info);
|
|
91
|
+
return info;
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
}
|
|
95
|
+
return { symbol: contractAddress ? "TRC20" : "TRX" };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if connected
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Get TRON address
|
|
102
|
+
*/
|
|
103
|
+
async getAddress() {
|
|
104
|
+
if (!this.wallet) {
|
|
105
|
+
throw new TronProviderError(
|
|
106
|
+
ProviderErrorCode.DISCONNECTED,
|
|
107
|
+
"Wallet not connected"
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return this.wallet.address;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get public key
|
|
114
|
+
*/
|
|
115
|
+
async getPublicKey() {
|
|
116
|
+
if (!this.wallet) {
|
|
117
|
+
throw new TronProviderError(
|
|
118
|
+
ProviderErrorCode.DISCONNECTED,
|
|
119
|
+
"Wallet not connected"
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
return this.wallet.publicKey;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Get current network
|
|
126
|
+
*/
|
|
127
|
+
getNetwork() {
|
|
128
|
+
return this.network;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Sign TRON message using secp256k1 MPC (signHash)
|
|
132
|
+
* Convention: keccak256("\x19TRON Signed Message:\n" + length + message)
|
|
133
|
+
*/
|
|
134
|
+
async signMessage(message) {
|
|
135
|
+
if (!this.wallet) {
|
|
136
|
+
throw new TronProviderError(
|
|
137
|
+
ProviderErrorCode.DISCONNECTED,
|
|
138
|
+
"Wallet not connected"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
await this.callInterceptor({
|
|
143
|
+
chain: "tron",
|
|
144
|
+
method: "signMessage",
|
|
145
|
+
address: this.wallet.address,
|
|
146
|
+
network: this.network.type,
|
|
147
|
+
message
|
|
148
|
+
});
|
|
149
|
+
logger.info("Signing TRON message...");
|
|
150
|
+
const msgBytes = new TextEncoder().encode(message);
|
|
151
|
+
const prefix = new TextEncoder().encode(
|
|
152
|
+
`TRON Signed Message:
|
|
153
|
+
${msgBytes.length}`
|
|
154
|
+
);
|
|
155
|
+
const prefixed = new Uint8Array(prefix.length + msgBytes.length);
|
|
156
|
+
prefixed.set(prefix);
|
|
157
|
+
prefixed.set(msgBytes, prefix.length);
|
|
158
|
+
const hash = keccak256(prefixed);
|
|
159
|
+
const pinHash = getCredentialManager().getPinHash() || void 0;
|
|
160
|
+
const email = getCredentialManager().getEmail() || void 0;
|
|
161
|
+
const api = this.getTalkenApiClientOrThrow();
|
|
162
|
+
const result = await api.bitcoin.signHash({
|
|
163
|
+
hash: hash.startsWith("0x") ? hash.slice(2) : hash,
|
|
164
|
+
pin: pinHash || "",
|
|
165
|
+
network: this.network.type,
|
|
166
|
+
...email && { email }
|
|
167
|
+
});
|
|
168
|
+
const signature = result.signstr.startsWith("0x") ? result.signstr : `0x${result.signstr}`;
|
|
169
|
+
logger.info("Message signed successfully");
|
|
170
|
+
return signature;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
logger.error("Message signing failed:", error.message);
|
|
173
|
+
throw new TronProviderError(
|
|
174
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
175
|
+
error.message || "Failed to sign TRON message",
|
|
176
|
+
error
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Send TRON transaction (TRX native or TRC20)
|
|
182
|
+
* Complete flow: create unsigned tx -> request PIN -> sign -> broadcast
|
|
183
|
+
*
|
|
184
|
+
* @param params - Transaction parameters
|
|
185
|
+
* @returns Transaction hash
|
|
186
|
+
*/
|
|
187
|
+
async sendTransaction(params) {
|
|
188
|
+
if (!this.wallet) {
|
|
189
|
+
throw new TronProviderError(
|
|
190
|
+
ProviderErrorCode.DISCONNECTED,
|
|
191
|
+
"Wallet not connected"
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
const tokenMetadata = await this.fetchTokenMetadata(
|
|
196
|
+
params.contractAddress
|
|
197
|
+
);
|
|
198
|
+
await this.callInterceptor({
|
|
199
|
+
chain: "tron",
|
|
200
|
+
method: "sendTransaction",
|
|
201
|
+
fromAddress: this.wallet.address,
|
|
202
|
+
toAddress: params.toAddress,
|
|
203
|
+
amount: params.amount,
|
|
204
|
+
symbol: tokenMetadata.symbol,
|
|
205
|
+
network: this.network.type,
|
|
206
|
+
tokenAddress: params.contractAddress,
|
|
207
|
+
isNativeToken: !params.contractAddress,
|
|
208
|
+
feeSymbol: "TRX",
|
|
209
|
+
tokenLogo: tokenMetadata.logo
|
|
210
|
+
});
|
|
211
|
+
logger.info("Starting TRON transaction...");
|
|
212
|
+
const api = this.getTalkenApiClientOrThrow();
|
|
213
|
+
const pinHash = api.isAccessKeyMode() ? void 0 : getCredentialManager().getPinHash();
|
|
214
|
+
if (!pinHash && !api.isAccessKeyMode()) {
|
|
215
|
+
throw new TronProviderError(
|
|
216
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
217
|
+
"PIN hash not found. Please login again."
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
const txType = params.contractAddress ? "TRC20" : "NATIVE";
|
|
221
|
+
let amountRaw;
|
|
222
|
+
if (txType === "NATIVE") {
|
|
223
|
+
amountRaw = Math.floor(
|
|
224
|
+
Number.parseFloat(params.amount) * 1e6
|
|
225
|
+
).toString();
|
|
226
|
+
logger.debug(`Converting ${params.amount} TRX -> ${amountRaw} SUN`);
|
|
227
|
+
} else {
|
|
228
|
+
const decimals = params.decimals ?? 6;
|
|
229
|
+
amountRaw = Math.floor(
|
|
230
|
+
Number.parseFloat(params.amount) * 10 ** decimals
|
|
231
|
+
).toString();
|
|
232
|
+
logger.debug(
|
|
233
|
+
`Converting ${params.amount} -> ${amountRaw} (decimals: ${decimals})`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
const email = getCredentialManager().getEmail() || void 0;
|
|
237
|
+
const request = txType === "NATIVE" ? {
|
|
238
|
+
kind: "native",
|
|
239
|
+
network: this.network.type,
|
|
240
|
+
toAddress: params.toAddress,
|
|
241
|
+
amountSun: amountRaw,
|
|
242
|
+
pin: pinHash || void 0,
|
|
243
|
+
waitForConfirmation: true,
|
|
244
|
+
...email && { email }
|
|
245
|
+
} : {
|
|
246
|
+
kind: "trc20",
|
|
247
|
+
network: this.network.type,
|
|
248
|
+
toAddress: params.toAddress,
|
|
249
|
+
contractAddress: params.contractAddress,
|
|
250
|
+
amount: amountRaw,
|
|
251
|
+
feeLimit: params.feeLimit,
|
|
252
|
+
pin: pinHash || void 0,
|
|
253
|
+
waitForConfirmation: true,
|
|
254
|
+
...email && { email }
|
|
255
|
+
};
|
|
256
|
+
this.showPendingTx({ network: this.network.type, chain: "tron" });
|
|
257
|
+
const result = await api.tron.transferTrx(request);
|
|
258
|
+
const txHash = result.txHash;
|
|
259
|
+
this.updateTronTransactionResult(result);
|
|
260
|
+
logger.info(
|
|
261
|
+
`${txType === "NATIVE" ? "TRX" : "TRC-20"} transaction complete via TalkenApiClient:`,
|
|
262
|
+
txHash
|
|
263
|
+
);
|
|
264
|
+
this.emit("transactionBroadcasted", {
|
|
265
|
+
txHash,
|
|
266
|
+
explorerUrl: `${this.network.explorer}/#/transaction/${txHash}`
|
|
267
|
+
});
|
|
268
|
+
return txHash;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
if (error.message?.includes("cancelled") || error.message?.includes("rejected")) {
|
|
271
|
+
logger.info("User cancelled transaction");
|
|
272
|
+
throw new TronProviderError(
|
|
273
|
+
ProviderErrorCode.USER_REJECTED,
|
|
274
|
+
"User rejected transaction",
|
|
275
|
+
error
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
logger.error("Transaction failed:", error.message);
|
|
279
|
+
this.failTxResult({
|
|
280
|
+
network: this.network.type,
|
|
281
|
+
chain: "tron",
|
|
282
|
+
errorMessage: error.message
|
|
283
|
+
});
|
|
284
|
+
if (error.message?.includes("insufficient")) {
|
|
285
|
+
throw new TronProviderError(
|
|
286
|
+
ProviderErrorCode.INSUFFICIENT_FUNDS,
|
|
287
|
+
"Insufficient TRX balance",
|
|
288
|
+
error
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
this.emit("error", error);
|
|
292
|
+
throw new TronProviderError(
|
|
293
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
294
|
+
error.message || "Failed to send TRON transaction",
|
|
295
|
+
error
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Get wallet info
|
|
301
|
+
*/
|
|
302
|
+
getWalletInfo() {
|
|
303
|
+
if (!this.wallet)
|
|
304
|
+
return null;
|
|
305
|
+
return {
|
|
306
|
+
address: this.wallet.address,
|
|
307
|
+
publicKey: this.wallet.publicKey,
|
|
308
|
+
network: this.network.type
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
updateTronTransactionResult(result) {
|
|
312
|
+
let receipt = result.receipt;
|
|
313
|
+
if (!receipt && result.confirmation) {
|
|
314
|
+
const conf = result.confirmation;
|
|
315
|
+
const info = conf?.info ?? conf;
|
|
316
|
+
const tx = conf?.transaction ?? conf;
|
|
317
|
+
const blockNumber = info?.blockNumber ?? info?.result?.blockNumber ?? null;
|
|
318
|
+
const rcpt = info?.receipt ?? info?.result?.receipt;
|
|
319
|
+
const ret = tx?.ret ?? tx?.result?.ret;
|
|
320
|
+
const contractRet = Array.isArray(ret) ? ret[0]?.contractRet : void 0;
|
|
321
|
+
receipt = {
|
|
322
|
+
status: contractRet === "SUCCESS" ? 1 : contractRet ? 0 : null,
|
|
323
|
+
blockNumber,
|
|
324
|
+
gasUsed: rcpt?.energy_usage_total != null ? String(rcpt.energy_usage_total) : null
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
this.updateTxResult({
|
|
328
|
+
txHash: result.txHash,
|
|
329
|
+
network: this.network.type,
|
|
330
|
+
chain: "tron",
|
|
331
|
+
receipt,
|
|
332
|
+
explorerUrl: `${this.network.explorer}/#/transaction/${result.txHash}`
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export {
|
|
338
|
+
TRON_NETWORKS,
|
|
339
|
+
AbcTronProvider
|
|
340
|
+
};
|