@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.mjs
CHANGED
|
@@ -173,6 +173,30 @@ function getWalletDisplayName(networkType) {
|
|
|
173
173
|
return "Unknown Wallet";
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
+
function getAllWalletAddresses() {
|
|
177
|
+
if (typeof window === "undefined") {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
const cached = localStorage.getItem(WALLET_ADDRESSES_KEY);
|
|
182
|
+
return cached ? JSON.parse(cached) : {};
|
|
183
|
+
} catch (error) {
|
|
184
|
+
console.error("Failed to parse wallet addresses cache:", error);
|
|
185
|
+
return {};
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function saveWalletAddress(networkType, address) {
|
|
189
|
+
if (typeof window === "undefined") {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const addresses = getAllWalletAddresses();
|
|
193
|
+
addresses[networkType] = address;
|
|
194
|
+
localStorage.setItem(WALLET_ADDRESSES_KEY, JSON.stringify(addresses));
|
|
195
|
+
}
|
|
196
|
+
function getCachedWalletAddress(networkType) {
|
|
197
|
+
const addresses = getAllWalletAddresses();
|
|
198
|
+
return addresses[networkType] || null;
|
|
199
|
+
}
|
|
176
200
|
function getAllConnectedWalletIds() {
|
|
177
201
|
if (typeof window === "undefined") {
|
|
178
202
|
return {};
|
|
@@ -189,10 +213,11 @@ function getConnectedWalletId(networkType) {
|
|
|
189
213
|
const walletIds = getAllConnectedWalletIds();
|
|
190
214
|
return walletIds[networkType] || null;
|
|
191
215
|
}
|
|
192
|
-
var CONNECTED_WALLET_IDS_KEY;
|
|
216
|
+
var WALLET_ADDRESSES_KEY, CONNECTED_WALLET_IDS_KEY;
|
|
193
217
|
var init_wallet = __esm({
|
|
194
218
|
"src/utils/wallet.ts"() {
|
|
195
219
|
"use strict";
|
|
220
|
+
WALLET_ADDRESSES_KEY = "wallet_addresses_cache";
|
|
196
221
|
CONNECTED_WALLET_IDS_KEY = "connected_wallet_ids";
|
|
197
222
|
}
|
|
198
223
|
});
|
|
@@ -360,14 +385,21 @@ function getWalletByName(name, networkType) {
|
|
|
360
385
|
}
|
|
361
386
|
function restoreConnectedWallet(networkType) {
|
|
362
387
|
const savedWalletName = getConnectedWalletId(networkType);
|
|
363
|
-
if (!savedWalletName)
|
|
388
|
+
if (!savedWalletName) {
|
|
389
|
+
return null;
|
|
390
|
+
}
|
|
364
391
|
const wallet = getWalletByName(savedWalletName, networkType);
|
|
365
392
|
if (wallet) {
|
|
366
393
|
currentConnectedWallet = wallet;
|
|
367
|
-
|
|
394
|
+
if ((networkType === "solana" /* SOLANA */ || networkType === "svm" /* SVM */) && wallet.provider) {
|
|
395
|
+
const providerPublicKey = wallet.provider.publicKey?.toString();
|
|
396
|
+
const cachedAddress = getCachedWalletAddress(networkType);
|
|
397
|
+
if (providerPublicKey && cachedAddress && providerPublicKey !== cachedAddress) {
|
|
398
|
+
saveWalletAddress(networkType, providerPublicKey);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
368
401
|
return wallet;
|
|
369
402
|
}
|
|
370
|
-
console.warn(`\u26A0\uFE0F Could not find wallet with name: ${savedWalletName}`);
|
|
371
403
|
return null;
|
|
372
404
|
}
|
|
373
405
|
function getWalletProviderForPayment(networkType) {
|
|
@@ -672,8 +704,8 @@ async function makePayment(networkType, merchantId, endpoint = PROD_BACK_URL, ad
|
|
|
672
704
|
if (!solana.isConnected) {
|
|
673
705
|
await solana.connect();
|
|
674
706
|
}
|
|
675
|
-
|
|
676
|
-
|
|
707
|
+
const currentAddress = solana.publicKey?.toString();
|
|
708
|
+
if (expectedAddress && currentAddress) {
|
|
677
709
|
if (currentAddress !== expectedAddress) {
|
|
678
710
|
throw new Error(
|
|
679
711
|
`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.`
|