@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,378 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
WalletscanApi
|
|
4
|
+
} from "./chunk-5MWF2QUP.js";
|
|
5
|
+
import {
|
|
6
|
+
AbstractChainProvider
|
|
7
|
+
} from "./chunk-S5XGT2XC.js";
|
|
8
|
+
import {
|
|
9
|
+
ProviderErrorCode,
|
|
10
|
+
SolanaProviderError
|
|
11
|
+
} from "./chunk-GJ4CJL7F.js";
|
|
12
|
+
import {
|
|
13
|
+
createLogger
|
|
14
|
+
} from "./chunk-762I67R6.js";
|
|
15
|
+
import {
|
|
16
|
+
getCredentialManager
|
|
17
|
+
} from "./chunk-P6KWAOFF.js";
|
|
18
|
+
|
|
19
|
+
// src/utils/apiClientFactory.ts
|
|
20
|
+
function createWalletscanApi() {
|
|
21
|
+
return new WalletscanApi();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
|
|
25
|
+
var logger = createLogger("AbcSolanaProvider");
|
|
26
|
+
var AbcSolanaProvider = class extends AbstractChainProvider {
|
|
27
|
+
onWalletSet(wallet) {
|
|
28
|
+
this.emit("connect", {
|
|
29
|
+
address: wallet.address,
|
|
30
|
+
network: wallet.network
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Call request interceptor if set (throws on user cancel)
|
|
35
|
+
*/
|
|
36
|
+
async callInterceptor(request) {
|
|
37
|
+
if (this.requestInterceptor) {
|
|
38
|
+
await this.requestInterceptor(request);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
getSigningNetwork() {
|
|
42
|
+
return this.wallet?.network === "solana" ? "solana" : "solana_devnet";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get Solana address
|
|
46
|
+
*/
|
|
47
|
+
async getAddress() {
|
|
48
|
+
if (!this.wallet) {
|
|
49
|
+
throw new SolanaProviderError(
|
|
50
|
+
ProviderErrorCode.DISCONNECTED,
|
|
51
|
+
"Wallet not connected"
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
return this.wallet.address;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get public key
|
|
58
|
+
*/
|
|
59
|
+
async getPublicKey() {
|
|
60
|
+
if (!this.wallet) {
|
|
61
|
+
throw new SolanaProviderError(
|
|
62
|
+
ProviderErrorCode.DISCONNECTED,
|
|
63
|
+
"Wallet not connected"
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
return this.wallet.publicKey;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Sign Solana message via PIN mode.
|
|
70
|
+
* Server resolves signing material from PIN hash.
|
|
71
|
+
* In AK mode, PIN is auto-injected by server-side delegated credentials.
|
|
72
|
+
*/
|
|
73
|
+
async signMessage(encodedMessage, _display) {
|
|
74
|
+
if (!this.wallet) {
|
|
75
|
+
throw new SolanaProviderError(
|
|
76
|
+
ProviderErrorCode.DISCONNECTED,
|
|
77
|
+
"Wallet not connected"
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const decodedText = new TextDecoder().decode(encodedMessage);
|
|
82
|
+
await this.callInterceptor({
|
|
83
|
+
chain: "solana",
|
|
84
|
+
method: "signMessage",
|
|
85
|
+
address: this.wallet.address,
|
|
86
|
+
network: this.wallet.network,
|
|
87
|
+
message: decodedText
|
|
88
|
+
});
|
|
89
|
+
const messageHex = `0x${Array.from(encodedMessage).map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
90
|
+
const solApi = this.getTalkenApiClientOrThrow();
|
|
91
|
+
const pinHash = solApi.isAccessKeyMode() ? void 0 : getCredentialManager().getPinHash();
|
|
92
|
+
if (!pinHash && !solApi.isAccessKeyMode()) {
|
|
93
|
+
throw new SolanaProviderError(
|
|
94
|
+
ProviderErrorCode.UNAUTHORIZED,
|
|
95
|
+
"PIN hash not found. Please re-enter your PIN."
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
const result = await solApi.solana.sign({
|
|
99
|
+
message: messageHex,
|
|
100
|
+
pin: pinHash || void 0,
|
|
101
|
+
network: this.getSigningNetwork()
|
|
102
|
+
});
|
|
103
|
+
const signatureHex = result.signature.startsWith("0x") ? result.signature.slice(2) : result.signature;
|
|
104
|
+
const signatureBytes = new Uint8Array(
|
|
105
|
+
signatureHex.match(/.{1,2}/g)?.map((byte) => Number.parseInt(byte, 16)) || []
|
|
106
|
+
);
|
|
107
|
+
return { signature: signatureBytes };
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.emit("error", error);
|
|
110
|
+
throw new SolanaProviderError(
|
|
111
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
112
|
+
"Failed to sign message",
|
|
113
|
+
error
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sign arbitrary Solana transaction (requires PIN)
|
|
119
|
+
* Supports both Legacy Transaction and VersionedTransaction
|
|
120
|
+
* Used for custom transactions, dApp interactions, and protocol integrations
|
|
121
|
+
*/
|
|
122
|
+
async signTransaction(transaction) {
|
|
123
|
+
if (!this.wallet) {
|
|
124
|
+
throw new SolanaProviderError(
|
|
125
|
+
ProviderErrorCode.DISCONNECTED,
|
|
126
|
+
"Wallet not connected"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
let txMessage = "";
|
|
131
|
+
try {
|
|
132
|
+
txMessage = JSON.stringify(transaction, null, 2);
|
|
133
|
+
} catch {
|
|
134
|
+
txMessage = String(transaction);
|
|
135
|
+
}
|
|
136
|
+
await this.callInterceptor({
|
|
137
|
+
chain: "solana",
|
|
138
|
+
method: "signTransaction",
|
|
139
|
+
address: this.wallet.address,
|
|
140
|
+
network: this.wallet.network,
|
|
141
|
+
message: txMessage,
|
|
142
|
+
isTransaction: true
|
|
143
|
+
});
|
|
144
|
+
const { VersionedTransaction, PublicKey } = await import("@solana/web3.js");
|
|
145
|
+
const isVersioned = transaction instanceof VersionedTransaction;
|
|
146
|
+
let serialized;
|
|
147
|
+
if (isVersioned) {
|
|
148
|
+
serialized = transaction.message.serialize();
|
|
149
|
+
} else {
|
|
150
|
+
serialized = transaction.serializeMessage();
|
|
151
|
+
}
|
|
152
|
+
const messageHex = Buffer.from(serialized).toString("hex");
|
|
153
|
+
const pinHash = getCredentialManager().getPinHash();
|
|
154
|
+
const signatureResponse = await this.getTalkenApiClientOrThrow().solana.sign({
|
|
155
|
+
message: messageHex,
|
|
156
|
+
pin: pinHash || void 0,
|
|
157
|
+
network: this.getSigningNetwork()
|
|
158
|
+
});
|
|
159
|
+
const signatureHex = signatureResponse.signature.startsWith("0x") ? signatureResponse.signature.slice(2) : signatureResponse.signature;
|
|
160
|
+
const signatureBytes = Buffer.from(signatureHex, "hex");
|
|
161
|
+
const publicKey = new PublicKey(this.wallet.address);
|
|
162
|
+
if (isVersioned) {
|
|
163
|
+
transaction.addSignature(publicKey, signatureBytes);
|
|
164
|
+
} else {
|
|
165
|
+
transaction.addSignature(publicKey, signatureBytes);
|
|
166
|
+
}
|
|
167
|
+
return transaction;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error.code === 4001 || error.cancelled) {
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
this.emit("error", error);
|
|
173
|
+
throw new SolanaProviderError(
|
|
174
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
175
|
+
"Failed to sign transaction",
|
|
176
|
+
error
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Sign multiple transactions (batch signing)
|
|
182
|
+
*/
|
|
183
|
+
async signAllTransactions(transactions) {
|
|
184
|
+
const signedTransactions = [];
|
|
185
|
+
for (const transaction of transactions) {
|
|
186
|
+
const signed = await this.signTransaction(transaction);
|
|
187
|
+
signedTransactions.push(signed);
|
|
188
|
+
}
|
|
189
|
+
return signedTransactions;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Unified transfer: SOL, SPL token, or NFT
|
|
193
|
+
* - No mintAddress → native SOL transfer (kind='native')
|
|
194
|
+
* - With mintAddress → SPL/NFT transfer (kind='spl')
|
|
195
|
+
* - NFT = transfer({ mintAddress, toAddress, amount: 1 })
|
|
196
|
+
*/
|
|
197
|
+
async transfer(params) {
|
|
198
|
+
if (!this.wallet) {
|
|
199
|
+
throw new SolanaProviderError(
|
|
200
|
+
ProviderErrorCode.DISCONNECTED,
|
|
201
|
+
"Wallet not connected"
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const symbol = params.mintAddress ? "SPL" : "SOL";
|
|
206
|
+
await this.callInterceptor({
|
|
207
|
+
chain: "solana",
|
|
208
|
+
method: "transfer",
|
|
209
|
+
fromAddress: this.wallet.address,
|
|
210
|
+
toAddress: params.toAddress,
|
|
211
|
+
amount: String(params.amount),
|
|
212
|
+
symbol,
|
|
213
|
+
network: this.wallet.network,
|
|
214
|
+
tokenAddress: params.mintAddress,
|
|
215
|
+
isNativeToken: !params.mintAddress,
|
|
216
|
+
estimatedFee: "0.000005",
|
|
217
|
+
feeSymbol: "SOL"
|
|
218
|
+
});
|
|
219
|
+
const api = this.getTalkenApiClientOrThrow();
|
|
220
|
+
const pinHash = api.isAccessKeyMode() ? void 0 : getCredentialManager().getPinHash();
|
|
221
|
+
if (!pinHash && !api.isAccessKeyMode()) {
|
|
222
|
+
throw new SolanaProviderError(
|
|
223
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
224
|
+
"PIN hash not found. Please login again."
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
logger.info("transfer START", {
|
|
228
|
+
kind: params.mintAddress ? "spl" : "native",
|
|
229
|
+
toAddress: params.toAddress,
|
|
230
|
+
amount: params.amount,
|
|
231
|
+
mintAddress: params.mintAddress || null,
|
|
232
|
+
network: this.wallet.network,
|
|
233
|
+
hasPinHash: !!pinHash
|
|
234
|
+
});
|
|
235
|
+
const apiNetwork = this.wallet.network === "solana" ? "solana" : "solana_devnet";
|
|
236
|
+
this.showPendingTx({ network: apiNetwork, chain: "solana" });
|
|
237
|
+
if (params.mintAddress) {
|
|
238
|
+
const walletscanApi = createWalletscanApi();
|
|
239
|
+
const tokenMeta = await walletscanApi.getContractTokenWithTimeout({
|
|
240
|
+
contractAddress: params.mintAddress,
|
|
241
|
+
networks: apiNetwork
|
|
242
|
+
});
|
|
243
|
+
const decimals = tokenMeta?.decimals ?? 9;
|
|
244
|
+
const rawAmount = Math.floor(params.amount * 10 ** decimals);
|
|
245
|
+
const result2 = await api.solana.transfer({
|
|
246
|
+
kind: "spl",
|
|
247
|
+
toAddress: params.toAddress,
|
|
248
|
+
mintAddress: params.mintAddress,
|
|
249
|
+
amount: String(rawAmount),
|
|
250
|
+
decimals,
|
|
251
|
+
network: apiNetwork,
|
|
252
|
+
pin: pinHash || void 0,
|
|
253
|
+
waitForConfirmation: true
|
|
254
|
+
});
|
|
255
|
+
logger.info("SPL transfer result:", result2);
|
|
256
|
+
this.updateSolanaTransactionResult(result2, apiNetwork);
|
|
257
|
+
return { signature: result2.txHash };
|
|
258
|
+
}
|
|
259
|
+
const { LAMPORTS_PER_SOL } = await import("@solana/web3.js");
|
|
260
|
+
const amountLamports = params.amount * LAMPORTS_PER_SOL;
|
|
261
|
+
logger.info("native transfer request:", {
|
|
262
|
+
toAddress: params.toAddress,
|
|
263
|
+
amountLamports: String(amountLamports),
|
|
264
|
+
amountSOL: params.amount
|
|
265
|
+
});
|
|
266
|
+
const result = await api.solana.transfer({
|
|
267
|
+
kind: "native",
|
|
268
|
+
toAddress: params.toAddress,
|
|
269
|
+
amountLamports: String(amountLamports),
|
|
270
|
+
network: apiNetwork,
|
|
271
|
+
pin: pinHash || void 0,
|
|
272
|
+
waitForConfirmation: true
|
|
273
|
+
});
|
|
274
|
+
logger.info("native transfer result:", result);
|
|
275
|
+
this.updateSolanaTransactionResult(result, apiNetwork);
|
|
276
|
+
return { signature: result.txHash };
|
|
277
|
+
} catch (error) {
|
|
278
|
+
logger.error("transfer FAILED:", {
|
|
279
|
+
message: error.message,
|
|
280
|
+
code: error.code,
|
|
281
|
+
status: error.status,
|
|
282
|
+
details: error.details || error.data
|
|
283
|
+
});
|
|
284
|
+
this.failTxResult({
|
|
285
|
+
network: this.wallet?.network || "solana",
|
|
286
|
+
chain: "solana",
|
|
287
|
+
errorMessage: error.message
|
|
288
|
+
});
|
|
289
|
+
if (error.code === 4001 || error.cancelled) {
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
this.emit("error", error);
|
|
293
|
+
throw new SolanaProviderError(
|
|
294
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
295
|
+
"Failed to transfer",
|
|
296
|
+
error
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get wallet info
|
|
302
|
+
*/
|
|
303
|
+
getWalletInfo() {
|
|
304
|
+
if (!this.wallet)
|
|
305
|
+
return null;
|
|
306
|
+
return {
|
|
307
|
+
address: this.wallet.address,
|
|
308
|
+
publicKey: this.wallet.publicKey,
|
|
309
|
+
network: this.wallet.network
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Get SPL token balance
|
|
314
|
+
*
|
|
315
|
+
* @param mintAddress - Token mint address
|
|
316
|
+
* @returns Token balance information
|
|
317
|
+
*/
|
|
318
|
+
async getTokenBalance(mintAddress) {
|
|
319
|
+
if (!this.wallet) {
|
|
320
|
+
throw new SolanaProviderError(
|
|
321
|
+
ProviderErrorCode.DISCONNECTED,
|
|
322
|
+
"Wallet not connected"
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
try {
|
|
326
|
+
const walletscanApi = createWalletscanApi();
|
|
327
|
+
const balance = await walletscanApi.getWalletTokenBalanceWithTimeout({
|
|
328
|
+
walletAddress: this.wallet.address,
|
|
329
|
+
networks: this.wallet.network,
|
|
330
|
+
contractAddress: mintAddress
|
|
331
|
+
});
|
|
332
|
+
if (!balance) {
|
|
333
|
+
return {
|
|
334
|
+
amount: "0",
|
|
335
|
+
decimals: 0,
|
|
336
|
+
uiAmount: 0
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
amount: String(balance.balance ?? 0),
|
|
341
|
+
decimals: balance.decimals ?? 0,
|
|
342
|
+
uiAmount: balance.hrBalance ?? 0
|
|
343
|
+
};
|
|
344
|
+
} catch (error) {
|
|
345
|
+
this.emit("error", error);
|
|
346
|
+
throw new SolanaProviderError(
|
|
347
|
+
ProviderErrorCode.INTERNAL_ERROR,
|
|
348
|
+
"Failed to get token balance",
|
|
349
|
+
error
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
updateSolanaTransactionResult(result, network) {
|
|
354
|
+
let receipt = result.receipt;
|
|
355
|
+
if (!receipt && result.confirmation) {
|
|
356
|
+
const data = result.confirmation?.data?.result ?? result.confirmation?.result ?? result.confirmation;
|
|
357
|
+
const slot = data?.slot;
|
|
358
|
+
const meta = data?.meta;
|
|
359
|
+
receipt = {
|
|
360
|
+
status: meta?.err === null ? 1 : 0,
|
|
361
|
+
blockNumber: slot ?? null,
|
|
362
|
+
gasUsed: meta?.fee != null ? String(meta.fee) : null
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
const cluster = network.includes("devnet") ? "?cluster=devnet" : "";
|
|
366
|
+
this.updateTxResult({
|
|
367
|
+
txHash: result.txHash,
|
|
368
|
+
network,
|
|
369
|
+
chain: "solana",
|
|
370
|
+
receipt,
|
|
371
|
+
explorerUrl: `https://explorer.solana.com/tx/${result.txHash}${cluster}`
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
export {
|
|
377
|
+
AbcSolanaProvider
|
|
378
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isMobile
|
|
4
|
+
} from "./chunk-RETKWSKD.js";
|
|
5
|
+
import {
|
|
6
|
+
getInjectedConnector,
|
|
7
|
+
hasInjectedProvider
|
|
8
|
+
} from "./chunk-PONHGUSY.js";
|
|
9
|
+
import {
|
|
10
|
+
getWalletConnectConnector
|
|
11
|
+
} from "./chunk-PODFK4OS.js";
|
|
12
|
+
|
|
13
|
+
// src/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.ts
|
|
14
|
+
var tokenPocketWallet = ({
|
|
15
|
+
projectId,
|
|
16
|
+
walletConnectParameters
|
|
17
|
+
}) => {
|
|
18
|
+
const isTokenPocketInjected = hasInjectedProvider({ flag: "isTokenPocket" });
|
|
19
|
+
const shouldUseWalletConnect = !isTokenPocketInjected;
|
|
20
|
+
const getUri = (uri) => {
|
|
21
|
+
return isMobile() ? `tpoutside://wc?uri=${encodeURIComponent(uri)}` : uri;
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
id: "tokenPocket",
|
|
25
|
+
name: "TokenPocket",
|
|
26
|
+
rdns: "pro.tokenpocket",
|
|
27
|
+
iconUrl: async () => (await import("./tokenPocketWallet-BVMBOYTC.js")).default,
|
|
28
|
+
iconBackground: "#2980FE",
|
|
29
|
+
installed: !shouldUseWalletConnect ? isTokenPocketInjected : void 0,
|
|
30
|
+
downloadUrls: {
|
|
31
|
+
chrome: "https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii",
|
|
32
|
+
browserExtension: "https://extension.tokenpocket.pro/",
|
|
33
|
+
android: "https://play.google.com/store/apps/details?id=vip.mytokenpocket",
|
|
34
|
+
ios: "https://apps.apple.com/us/app/tp-global-wallet/id6444625622",
|
|
35
|
+
qrCode: "https://tokenpocket.pro/en/download/app",
|
|
36
|
+
mobile: "https://tokenpocket.pro/en/download/app"
|
|
37
|
+
},
|
|
38
|
+
mobile: {
|
|
39
|
+
getUri: shouldUseWalletConnect ? getUri : void 0
|
|
40
|
+
},
|
|
41
|
+
qrCode: shouldUseWalletConnect ? {
|
|
42
|
+
getUri,
|
|
43
|
+
instructions: {
|
|
44
|
+
learnMoreUrl: "https://help.tokenpocket.pro/en/",
|
|
45
|
+
steps: [
|
|
46
|
+
{
|
|
47
|
+
description: "wallet_connectors.token_pocket.qr_code.step1.description",
|
|
48
|
+
step: "install",
|
|
49
|
+
title: "wallet_connectors.token_pocket.qr_code.step1.title"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
description: "wallet_connectors.token_pocket.qr_code.step2.description",
|
|
53
|
+
step: "create",
|
|
54
|
+
title: "wallet_connectors.token_pocket.qr_code.step2.title"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
description: "wallet_connectors.token_pocket.qr_code.step3.description",
|
|
58
|
+
step: "scan",
|
|
59
|
+
title: "wallet_connectors.token_pocket.qr_code.step3.title"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
} : void 0,
|
|
64
|
+
extension: {
|
|
65
|
+
instructions: {
|
|
66
|
+
learnMoreUrl: "https://help.tokenpocket.pro/en/extension-wallet/faq/installation-tutorial",
|
|
67
|
+
steps: [
|
|
68
|
+
{
|
|
69
|
+
description: "wallet_connectors.token_pocket.extension.step1.description",
|
|
70
|
+
step: "install",
|
|
71
|
+
title: "wallet_connectors.token_pocket.extension.step1.title"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
description: "wallet_connectors.token_pocket.extension.step2.description",
|
|
75
|
+
step: "create",
|
|
76
|
+
title: "wallet_connectors.token_pocket.extension.step2.title"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
description: "wallet_connectors.token_pocket.extension.step3.description",
|
|
80
|
+
step: "refresh",
|
|
81
|
+
title: "wallet_connectors.token_pocket.extension.step3.title"
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
|
|
87
|
+
projectId,
|
|
88
|
+
walletConnectParameters
|
|
89
|
+
}) : getInjectedConnector({ flag: "isTokenPocket" })
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export {
|
|
94
|
+
tokenPocketWallet
|
|
95
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
isAndroid
|
|
4
|
+
} from "./chunk-RETKWSKD.js";
|
|
5
|
+
import {
|
|
6
|
+
getInjectedConnector,
|
|
7
|
+
hasInjectedProvider
|
|
8
|
+
} from "./chunk-PONHGUSY.js";
|
|
9
|
+
import {
|
|
10
|
+
getWalletConnectConnector
|
|
11
|
+
} from "./chunk-PODFK4OS.js";
|
|
12
|
+
|
|
13
|
+
// src/wallets/walletConnectors/frontierWallet/frontierWallet.ts
|
|
14
|
+
var frontierWallet = ({
|
|
15
|
+
projectId,
|
|
16
|
+
walletConnectParameters
|
|
17
|
+
}) => {
|
|
18
|
+
const isFrontierInjected = hasInjectedProvider({
|
|
19
|
+
namespace: "frontier.ethereum",
|
|
20
|
+
flag: "isFrontier"
|
|
21
|
+
});
|
|
22
|
+
const shouldUseWalletConnect = !isFrontierInjected;
|
|
23
|
+
return {
|
|
24
|
+
id: "frontier",
|
|
25
|
+
name: "Frontier Wallet",
|
|
26
|
+
rdns: "xyz.frontier.wallet",
|
|
27
|
+
installed: isFrontierInjected,
|
|
28
|
+
iconUrl: async () => (await import("./frontierWallet-HNIG7QYQ.js")).default,
|
|
29
|
+
iconBackground: "#CC703C",
|
|
30
|
+
downloadUrls: {
|
|
31
|
+
android: "https://play.google.com/store/apps/details?id=com.frontierwallet",
|
|
32
|
+
ios: "https://apps.apple.com/us/app/frontier-crypto-defi-wallet/id1482380988",
|
|
33
|
+
qrCode: "https://www.frontier.xyz/download",
|
|
34
|
+
chrome: "https://chrome.google.com/webstore/detail/frontier-wallet/kppfdiipphfccemcignhifpjkapfbihd",
|
|
35
|
+
browserExtension: "https://www.frontier.xyz/download"
|
|
36
|
+
},
|
|
37
|
+
mobile: {
|
|
38
|
+
getUri: shouldUseWalletConnect ? (uri) => {
|
|
39
|
+
return isAndroid() ? `frontier://wc?uri=${encodeURIComponent(uri)}` : uri;
|
|
40
|
+
} : void 0
|
|
41
|
+
},
|
|
42
|
+
qrCode: shouldUseWalletConnect ? {
|
|
43
|
+
getUri: (uri) => {
|
|
44
|
+
return isAndroid() ? `frontier://wc?uri=${encodeURIComponent(uri)}` : uri;
|
|
45
|
+
},
|
|
46
|
+
instructions: {
|
|
47
|
+
learnMoreUrl: "https://help.frontier.xyz/en/",
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
description: "wallet_connectors.im_token.qr_code.step1.description",
|
|
51
|
+
step: "install",
|
|
52
|
+
title: "wallet_connectors.im_token.qr_code.step1.title"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
description: "wallet_connectors.im_token.qr_code.step2.description",
|
|
56
|
+
step: "create",
|
|
57
|
+
title: "wallet_connectors.im_token.qr_code.step2.title"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
description: "wallet_connectors.im_token.qr_code.step3.description",
|
|
61
|
+
step: "scan",
|
|
62
|
+
title: "wallet_connectors.im_token.qr_code.step3.title"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
} : void 0,
|
|
67
|
+
extension: {
|
|
68
|
+
instructions: {
|
|
69
|
+
learnMoreUrl: "https://help.frontier.xyz/en/articles/6967236-setting-up-frontier-on-your-device",
|
|
70
|
+
steps: [
|
|
71
|
+
{
|
|
72
|
+
description: "wallet_connectors.frontier.extension.step1.description",
|
|
73
|
+
step: "install",
|
|
74
|
+
title: "wallet_connectors.frontier.extension.step1.title"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
description: "wallet_connectors.frontier.extension.step2.description",
|
|
78
|
+
step: "create",
|
|
79
|
+
title: "wallet_connectors.frontier.extension.step2.title"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
description: "wallet_connectors.frontier.extension.step3.description",
|
|
83
|
+
step: "refresh",
|
|
84
|
+
title: "wallet_connectors.frontier.extension.step3.title"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({ projectId, walletConnectParameters }) : getInjectedConnector({
|
|
90
|
+
namespace: "frontier.ethereum",
|
|
91
|
+
flag: "isFrontier"
|
|
92
|
+
})
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export {
|
|
97
|
+
frontierWallet
|
|
98
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
getInjectedConnector,
|
|
4
|
+
hasInjectedProvider
|
|
5
|
+
} from "./chunk-PONHGUSY.js";
|
|
6
|
+
import {
|
|
7
|
+
isMobile
|
|
8
|
+
} from "./chunk-RETKWSKD.js";
|
|
9
|
+
import {
|
|
10
|
+
getWalletConnectConnector
|
|
11
|
+
} from "./chunk-PODFK4OS.js";
|
|
12
|
+
|
|
13
|
+
// src/wallets/walletConnectors/trustWallet/trustWallet.ts
|
|
14
|
+
var trustWallet = ({
|
|
15
|
+
projectId,
|
|
16
|
+
walletConnectParameters
|
|
17
|
+
}) => {
|
|
18
|
+
const isTrustWalletInjected = isMobile() ? hasInjectedProvider({ flag: "isTrust" }) : hasInjectedProvider({ flag: "isTrustWallet" });
|
|
19
|
+
const shouldUseWalletConnect = !isTrustWalletInjected;
|
|
20
|
+
const getUriMobile = (uri) => {
|
|
21
|
+
return `trust://wc?uri=${encodeURIComponent(uri)}`;
|
|
22
|
+
};
|
|
23
|
+
const getUriQR = (uri) => {
|
|
24
|
+
return uri;
|
|
25
|
+
};
|
|
26
|
+
const mobileConnector = {
|
|
27
|
+
getUri: shouldUseWalletConnect ? getUriMobile : void 0
|
|
28
|
+
};
|
|
29
|
+
let qrConnector = void 0;
|
|
30
|
+
if (shouldUseWalletConnect) {
|
|
31
|
+
qrConnector = {
|
|
32
|
+
getUri: getUriQR,
|
|
33
|
+
instructions: {
|
|
34
|
+
learnMoreUrl: "https://trustwallet.com/",
|
|
35
|
+
steps: [
|
|
36
|
+
{
|
|
37
|
+
description: "wallet_connectors.trust.qr_code.step1.description",
|
|
38
|
+
step: "install",
|
|
39
|
+
title: "wallet_connectors.trust.qr_code.step1.title"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description: "wallet_connectors.trust.qr_code.step2.description",
|
|
43
|
+
step: "create",
|
|
44
|
+
title: "wallet_connectors.trust.qr_code.step2.title"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
description: "wallet_connectors.trust.qr_code.step3.description",
|
|
48
|
+
step: "scan",
|
|
49
|
+
title: "wallet_connectors.trust.qr_code.step3.title"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const extensionConnector = {
|
|
56
|
+
instructions: {
|
|
57
|
+
learnMoreUrl: "https://trustwallet.com/browser-extension",
|
|
58
|
+
steps: [
|
|
59
|
+
{
|
|
60
|
+
description: "wallet_connectors.trust.extension.step1.description",
|
|
61
|
+
step: "install",
|
|
62
|
+
title: "wallet_connectors.trust.extension.step1.title"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
description: "wallet_connectors.trust.extension.step2.description",
|
|
66
|
+
step: "create",
|
|
67
|
+
title: "wallet_connectors.trust.extension.step2.title"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
description: "wallet_connectors.trust.extension.step3.description",
|
|
71
|
+
step: "refresh",
|
|
72
|
+
title: "wallet_connectors.trust.extension.step3.title"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
id: "trust",
|
|
79
|
+
name: "Trust Wallet",
|
|
80
|
+
rdns: "com.trustwallet.app",
|
|
81
|
+
iconUrl: async () => (await import("./trustWallet-NRSE43DO.js")).default,
|
|
82
|
+
// Note that we never resolve `installed` to `false` because the
|
|
83
|
+
// Trust Wallet provider falls back to other connection methods if
|
|
84
|
+
// the injected connector isn't available
|
|
85
|
+
installed: isTrustWalletInjected || void 0,
|
|
86
|
+
iconAccent: "#3375BB",
|
|
87
|
+
iconBackground: "#fff",
|
|
88
|
+
downloadUrls: {
|
|
89
|
+
android: "https://play.google.com/store/apps/details?id=com.wallet.crypto.trustapp",
|
|
90
|
+
ios: "https://apps.apple.com/us/app/trust-crypto-bitcoin-wallet/id1288339409",
|
|
91
|
+
mobile: "https://trustwallet.com/download",
|
|
92
|
+
qrCode: "https://trustwallet.com/download",
|
|
93
|
+
chrome: "https://chrome.google.com/webstore/detail/trust-wallet/egjidjbpglichdcondbcbdnbeeppgdph",
|
|
94
|
+
browserExtension: "https://trustwallet.com/browser-extension"
|
|
95
|
+
},
|
|
96
|
+
mobile: mobileConnector,
|
|
97
|
+
qrCode: qrConnector,
|
|
98
|
+
extension: extensionConnector,
|
|
99
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
|
|
100
|
+
projectId,
|
|
101
|
+
walletConnectParameters
|
|
102
|
+
}) : isMobile() ? getInjectedConnector({ flag: "isTrust" }) : getInjectedConnector({ flag: "isTrustWallet" })
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export {
|
|
107
|
+
trustWallet
|
|
108
|
+
};
|