@voyage_ai/v402-web-ts 1.0.0 → 1.0.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/index.js +38 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react/chunk-WDPIFLXY.mjs +633 -0
- package/dist/react/chunk-WDPIFLXY.mjs.map +1 -0
- package/dist/react/index.d.mts +1 -28
- package/dist/react/index.d.ts +1 -28
- package/dist/react/index.js +474 -870
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +128 -1130
- package/dist/react/index.mjs.map +1 -1
- package/dist/react/styles.css +1 -1
- package/dist/react/wallet-discovery-RN3DPV6V.mjs +35 -0
- package/dist/react/wallet-discovery-RN3DPV6V.mjs.map +1 -0
- package/package.json +4 -12
package/dist/index.js
CHANGED
|
@@ -182,6 +182,30 @@ function getWalletDisplayName(networkType) {
|
|
|
182
182
|
return "Unknown Wallet";
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
|
+
function getAllWalletAddresses() {
|
|
186
|
+
if (typeof window === "undefined") {
|
|
187
|
+
return {};
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const cached = localStorage.getItem(WALLET_ADDRESSES_KEY);
|
|
191
|
+
return cached ? JSON.parse(cached) : {};
|
|
192
|
+
} catch (error) {
|
|
193
|
+
console.error("Failed to parse wallet addresses cache:", error);
|
|
194
|
+
return {};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function saveWalletAddress(networkType, address) {
|
|
198
|
+
if (typeof window === "undefined") {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const addresses = getAllWalletAddresses();
|
|
202
|
+
addresses[networkType] = address;
|
|
203
|
+
localStorage.setItem(WALLET_ADDRESSES_KEY, JSON.stringify(addresses));
|
|
204
|
+
}
|
|
205
|
+
function getCachedWalletAddress(networkType) {
|
|
206
|
+
const addresses = getAllWalletAddresses();
|
|
207
|
+
return addresses[networkType] || null;
|
|
208
|
+
}
|
|
185
209
|
function getAllConnectedWalletIds() {
|
|
186
210
|
if (typeof window === "undefined") {
|
|
187
211
|
return {};
|
|
@@ -198,10 +222,11 @@ function getConnectedWalletId(networkType) {
|
|
|
198
222
|
const walletIds = getAllConnectedWalletIds();
|
|
199
223
|
return walletIds[networkType] || null;
|
|
200
224
|
}
|
|
201
|
-
var CONNECTED_WALLET_IDS_KEY;
|
|
225
|
+
var WALLET_ADDRESSES_KEY, CONNECTED_WALLET_IDS_KEY;
|
|
202
226
|
var init_wallet = __esm({
|
|
203
227
|
"src/utils/wallet.ts"() {
|
|
204
228
|
"use strict";
|
|
229
|
+
WALLET_ADDRESSES_KEY = "wallet_addresses_cache";
|
|
205
230
|
CONNECTED_WALLET_IDS_KEY = "connected_wallet_ids";
|
|
206
231
|
}
|
|
207
232
|
});
|
|
@@ -396,14 +421,21 @@ function getWalletByName(name, networkType) {
|
|
|
396
421
|
}
|
|
397
422
|
function restoreConnectedWallet(networkType) {
|
|
398
423
|
const savedWalletName = getConnectedWalletId(networkType);
|
|
399
|
-
if (!savedWalletName)
|
|
424
|
+
if (!savedWalletName) {
|
|
425
|
+
return null;
|
|
426
|
+
}
|
|
400
427
|
const wallet = getWalletByName(savedWalletName, networkType);
|
|
401
428
|
if (wallet) {
|
|
402
429
|
currentConnectedWallet = wallet;
|
|
403
|
-
|
|
430
|
+
if ((networkType === "solana" /* SOLANA */ || networkType === "svm" /* SVM */) && wallet.provider) {
|
|
431
|
+
const providerPublicKey = wallet.provider.publicKey?.toString();
|
|
432
|
+
const cachedAddress = getCachedWalletAddress(networkType);
|
|
433
|
+
if (providerPublicKey && cachedAddress && providerPublicKey !== cachedAddress) {
|
|
434
|
+
saveWalletAddress(networkType, providerPublicKey);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
404
437
|
return wallet;
|
|
405
438
|
}
|
|
406
|
-
console.warn(`\u26A0\uFE0F Could not find wallet with name: ${savedWalletName}`);
|
|
407
439
|
return null;
|
|
408
440
|
}
|
|
409
441
|
function getWalletProviderForPayment(networkType) {
|
|
@@ -708,8 +740,8 @@ async function makePayment(networkType, merchantId, endpoint = PROD_BACK_URL, ad
|
|
|
708
740
|
if (!solana.isConnected) {
|
|
709
741
|
await solana.connect();
|
|
710
742
|
}
|
|
711
|
-
|
|
712
|
-
|
|
743
|
+
const currentAddress = solana.publicKey?.toString();
|
|
744
|
+
if (expectedAddress && currentAddress) {
|
|
713
745
|
if (currentAddress !== expectedAddress) {
|
|
714
746
|
throw new Error(
|
|
715
747
|
`Wallet account mismatch: the current wallet account is ${currentAddress.slice(0, 8)}...\uFF0CBut the desired account is ${expectedAddress.slice(0, 8)}.... Please switch to the correct account in your wallet.`
|