@trustware/sdk-staging 1.1.9-staging.3 → 1.1.9-staging.6
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/constants.cjs +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/{core-CwT8Wd1x.d.ts → core-2oZuxC1J.d.ts} +1 -1
- package/dist/{core-Dy_rZl5y.d.cts → core-BTPkApRH.d.cts} +1 -1
- package/dist/core.cjs +172 -29
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.mjs +172 -29
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-d2PUaxE_.d.ts → detect-B8xXLwHK.d.ts} +1 -1
- package/dist/{detect-DVpECOTa.d.cts → detect-C8xpZRrL.d.cts} +1 -1
- package/dist/index.cjs +1712 -616
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +1863 -765
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-xFiq0SHr.d.ts → manager-BMO1O-cW.d.ts} +7 -2
- package/dist/{manager-B5aklGtm.d.cts → manager-BZwbtOyf.d.cts} +7 -2
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/wallet.cjs +196 -37
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +6 -4
- package/dist/wallet.d.ts +6 -4
- package/dist/wallet.mjs +194 -37
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +1712 -616
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +1829 -731
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as SolanaProviderLike, Q as WalletMeta, h as DetectedWallet, M as WalletId, v as SolanaWalletInterface } from './manager-
|
|
2
|
-
export { A as WagmiBridge, C as WagmiConnector, a1 as WalletSnapshot, a2 as useWalletConnectConnect, Z as useWalletExternalDisconnect, _ as useWalletInfo, $ as useWireDetectionIntoManager, a0 as walletManager } from './manager-
|
|
3
|
-
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-
|
|
1
|
+
import { u as SolanaProviderLike, Q as WalletMeta, h as DetectedWallet, M as WalletId, v as SolanaWalletInterface } from './manager-BZwbtOyf.cjs';
|
|
2
|
+
export { A as WagmiBridge, C as WagmiConnector, a1 as WalletSnapshot, a2 as useWalletConnectConnect, Z as useWalletExternalDisconnect, _ as useWalletInfo, $ as useWireDetectionIntoManager, a0 as walletManager } from './manager-BZwbtOyf.cjs';
|
|
3
|
+
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-C8xpZRrL.cjs';
|
|
4
4
|
import './blockchain-BxAFzp0s.cjs';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
|
@@ -8,6 +8,8 @@ type SolanaEventHandlers = {
|
|
|
8
8
|
onAccountChanged?: () => void;
|
|
9
9
|
onDisconnect?: () => void;
|
|
10
10
|
};
|
|
11
|
+
declare function decodeBase64(serializedTransaction: string): Uint8Array<ArrayBuffer>;
|
|
12
|
+
declare function encodeBase64(bytes: Uint8Array): string;
|
|
11
13
|
declare function getSolanaProviders(): Partial<Record<WalletId, SolanaProviderLike>>;
|
|
12
14
|
declare function detectSolanaWallets(wallets: WalletMeta[]): DetectedWallet[];
|
|
13
15
|
declare function bindSolanaProviderEvents(provider: SolanaProviderLike, handlers: SolanaEventHandlers): () => void;
|
|
@@ -35,4 +37,4 @@ declare function formatWalletConnectDeepLink(wcUri: string): string;
|
|
|
35
37
|
*/
|
|
36
38
|
declare function formatWalletConnectDeepLinkForWallet(walletId: string, wcUri: string): string;
|
|
37
39
|
|
|
38
|
-
export { POPULAR_ORDER, WALLETS, bindSolanaProviderEvents, detectSolanaWallets, formatDeepLink, formatWalletConnectDeepLink, formatWalletConnectDeepLinkForWallet, getSolanaProviders, toSolanaWalletInterface };
|
|
40
|
+
export { POPULAR_ORDER, WALLETS, bindSolanaProviderEvents, decodeBase64, detectSolanaWallets, encodeBase64, formatDeepLink, formatWalletConnectDeepLink, formatWalletConnectDeepLinkForWallet, getSolanaProviders, toSolanaWalletInterface };
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as SolanaProviderLike, Q as WalletMeta, h as DetectedWallet, M as WalletId, v as SolanaWalletInterface } from './manager-
|
|
2
|
-
export { A as WagmiBridge, C as WagmiConnector, a1 as WalletSnapshot, a2 as useWalletConnectConnect, Z as useWalletExternalDisconnect, _ as useWalletInfo, $ as useWireDetectionIntoManager, a0 as walletManager } from './manager-
|
|
3
|
-
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-
|
|
1
|
+
import { u as SolanaProviderLike, Q as WalletMeta, h as DetectedWallet, M as WalletId, v as SolanaWalletInterface } from './manager-BMO1O-cW.js';
|
|
2
|
+
export { A as WagmiBridge, C as WagmiConnector, a1 as WalletSnapshot, a2 as useWalletConnectConnect, Z as useWalletExternalDisconnect, _ as useWalletInfo, $ as useWireDetectionIntoManager, a0 as walletManager } from './manager-BMO1O-cW.js';
|
|
3
|
+
export { d as autoDetectWallet, e as buildDetectedWalletFromProvider, c as connectDetectedWallet, f as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, g as useIsMobile, a as useWagmi, b as useWalletDetection } from './detect-B8xXLwHK.js';
|
|
4
4
|
import './blockchain-BxAFzp0s.js';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
|
@@ -8,6 +8,8 @@ type SolanaEventHandlers = {
|
|
|
8
8
|
onAccountChanged?: () => void;
|
|
9
9
|
onDisconnect?: () => void;
|
|
10
10
|
};
|
|
11
|
+
declare function decodeBase64(serializedTransaction: string): Uint8Array<ArrayBuffer>;
|
|
12
|
+
declare function encodeBase64(bytes: Uint8Array): string;
|
|
11
13
|
declare function getSolanaProviders(): Partial<Record<WalletId, SolanaProviderLike>>;
|
|
12
14
|
declare function detectSolanaWallets(wallets: WalletMeta[]): DetectedWallet[];
|
|
13
15
|
declare function bindSolanaProviderEvents(provider: SolanaProviderLike, handlers: SolanaEventHandlers): () => void;
|
|
@@ -35,4 +37,4 @@ declare function formatWalletConnectDeepLink(wcUri: string): string;
|
|
|
35
37
|
*/
|
|
36
38
|
declare function formatWalletConnectDeepLinkForWallet(walletId: string, wcUri: string): string;
|
|
37
39
|
|
|
38
|
-
export { POPULAR_ORDER, WALLETS, bindSolanaProviderEvents, detectSolanaWallets, formatDeepLink, formatWalletConnectDeepLink, formatWalletConnectDeepLinkForWallet, getSolanaProviders, toSolanaWalletInterface };
|
|
40
|
+
export { POPULAR_ORDER, WALLETS, bindSolanaProviderEvents, decodeBase64, detectSolanaWallets, encodeBase64, formatDeepLink, formatWalletConnectDeepLink, formatWalletConnectDeepLinkForWallet, getSolanaProviders, toSolanaWalletInterface };
|
package/dist/wallet.mjs
CHANGED
|
@@ -224,7 +224,7 @@ var init_constants = __esm({
|
|
|
224
224
|
"src/constants.ts"() {
|
|
225
225
|
"use strict";
|
|
226
226
|
SDK_NAME = "@trustware/sdk";
|
|
227
|
-
SDK_VERSION = "1.1.9-staging.
|
|
227
|
+
SDK_VERSION = "1.1.9-staging.6";
|
|
228
228
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
229
229
|
API_PREFIX = "/api";
|
|
230
230
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -1314,21 +1314,28 @@ function formatDeepLink(id, currentUrl) {
|
|
|
1314
1314
|
const enc = encodeURIComponent(currentUrl);
|
|
1315
1315
|
switch (id) {
|
|
1316
1316
|
// EVM
|
|
1317
|
+
// MetaMask's dapp browser also exposes its Wallet Standard Solana
|
|
1318
|
+
// provider in the same session, so "metamask-solana" reuses this link.
|
|
1317
1319
|
case "metamask":
|
|
1320
|
+
case "metamask-solana":
|
|
1318
1321
|
return `metamask://dapp/${currentUrl}`;
|
|
1319
1322
|
case "coinbase":
|
|
1320
1323
|
return `coinbase://wallet/dapp?url=${enc}`;
|
|
1321
1324
|
case "rainbow":
|
|
1322
|
-
return `rainbow
|
|
1325
|
+
return `https://rainbow.me/dapp?url=${enc}`;
|
|
1323
1326
|
case "trust":
|
|
1324
1327
|
return `https://link.trustwallet.com/open_url?coin_id=60&url=${enc}`;
|
|
1325
1328
|
case "okx":
|
|
1326
1329
|
return `okx://wallet/dapp/url?dappUrl=${enc}`;
|
|
1327
1330
|
// Solana
|
|
1331
|
+
// Phantom is one app with one in-app browser — browsing there injects
|
|
1332
|
+
// both window.ethereum and window.phantom.solana, so "phantom-evm"
|
|
1333
|
+
// reuses the same browse link as "phantom-solana".
|
|
1328
1334
|
case "phantom-solana":
|
|
1329
|
-
|
|
1335
|
+
case "phantom-evm":
|
|
1336
|
+
return `https://phantom.app/ul/browse/${enc}?ref=${enc}`;
|
|
1330
1337
|
case "solflare":
|
|
1331
|
-
return `solflare
|
|
1338
|
+
return `https://solflare.com/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1332
1339
|
case "backpack":
|
|
1333
1340
|
return `https://backpack.app/ul/v1/browse/${enc}?ref=${enc}`;
|
|
1334
1341
|
// No confirmed deep link scheme
|
|
@@ -1477,8 +1484,10 @@ var init_metadata = __esm({
|
|
|
1477
1484
|
homepage: "https://phantom.app/",
|
|
1478
1485
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1479
1486
|
android: "https://play.google.com/store/apps/details?id=app.phantom",
|
|
1480
|
-
detectFlags: ["isPhantom"]
|
|
1481
|
-
//
|
|
1487
|
+
detectFlags: ["isPhantom"],
|
|
1488
|
+
// Same app/in-app browser as "phantom-solana" — browsing there injects
|
|
1489
|
+
// window.ethereum too.
|
|
1490
|
+
deepLink: (url) => formatDeepLink("phantom-evm", url) ?? ""
|
|
1482
1491
|
},
|
|
1483
1492
|
{
|
|
1484
1493
|
id: "phantom-solana",
|
|
@@ -1526,8 +1535,10 @@ var init_metadata = __esm({
|
|
|
1526
1535
|
emoji: "\u{1F98A}",
|
|
1527
1536
|
homepage: "https://metamask.io/",
|
|
1528
1537
|
ios: "https://apps.apple.com/app/metamask/id1438144202",
|
|
1529
|
-
android: "https://play.google.com/store/apps/details?id=io.metamask"
|
|
1530
|
-
//
|
|
1538
|
+
android: "https://play.google.com/store/apps/details?id=io.metamask",
|
|
1539
|
+
// Same app/in-app browser as "metamask" — its Wallet Standard Solana
|
|
1540
|
+
// provider is exposed in that same browse session.
|
|
1541
|
+
deepLink: (url) => formatDeepLink("metamask-solana", url) ?? ""
|
|
1531
1542
|
},
|
|
1532
1543
|
// ── Extension/desktop only — hidden on mobile ─────────────────────────────
|
|
1533
1544
|
{
|
|
@@ -2050,7 +2061,7 @@ var init_walletconnect = __esm({
|
|
|
2050
2061
|
solanaMainnet = {
|
|
2051
2062
|
id: 900,
|
|
2052
2063
|
chainNamespace: "solana",
|
|
2053
|
-
caipNetworkId: "solana:
|
|
2064
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2054
2065
|
name: "Solana Mainnet",
|
|
2055
2066
|
nativeCurrency: {
|
|
2056
2067
|
name: "Solana",
|
|
@@ -2929,8 +2940,62 @@ function getChainMeta(chainId) {
|
|
|
2929
2940
|
rpcUrls: chain.rpcUrls.default.http
|
|
2930
2941
|
};
|
|
2931
2942
|
}
|
|
2932
|
-
|
|
2943
|
+
function extractSolanaAddress(connector) {
|
|
2944
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
2945
|
+
if (!caipAccount) return null;
|
|
2946
|
+
return caipAccount.split(":")[2] ?? null;
|
|
2947
|
+
}
|
|
2948
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
2949
|
+
return {
|
|
2950
|
+
get publicKey() {
|
|
2951
|
+
const address = extractSolanaAddress(connector);
|
|
2952
|
+
return address ? { toString: () => address } : void 0;
|
|
2953
|
+
},
|
|
2954
|
+
async connect() {
|
|
2955
|
+
const address = extractSolanaAddress(connector);
|
|
2956
|
+
if (!address) {
|
|
2957
|
+
throw new Error(
|
|
2958
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
2959
|
+
);
|
|
2960
|
+
}
|
|
2961
|
+
return { publicKey: { toString: () => address } };
|
|
2962
|
+
},
|
|
2963
|
+
async disconnect() {
|
|
2964
|
+
},
|
|
2965
|
+
async signTransaction(transaction) {
|
|
2966
|
+
const tx = transaction;
|
|
2967
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
2968
|
+
requireAllSignatures: false,
|
|
2969
|
+
verifySignatures: false
|
|
2970
|
+
});
|
|
2971
|
+
const result = await connector.provider.request(
|
|
2972
|
+
{
|
|
2973
|
+
method: "solana_signTransaction",
|
|
2974
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
2975
|
+
},
|
|
2976
|
+
solanaMainnet.caipNetworkId
|
|
2977
|
+
);
|
|
2978
|
+
if (!result.transaction) {
|
|
2979
|
+
throw new Error(
|
|
2980
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
2981
|
+
);
|
|
2982
|
+
}
|
|
2983
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
2984
|
+
return { serialize: () => signedBytes };
|
|
2985
|
+
},
|
|
2986
|
+
on() {
|
|
2987
|
+
},
|
|
2988
|
+
off() {
|
|
2989
|
+
},
|
|
2990
|
+
removeListener() {
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
}
|
|
2994
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
2933
2995
|
const connector = await getUniversalConnector(walletCfg);
|
|
2996
|
+
if (ecosystem === "solana") {
|
|
2997
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
2998
|
+
}
|
|
2934
2999
|
const provider = connector.provider;
|
|
2935
3000
|
const api = {
|
|
2936
3001
|
ecosystem: "evm",
|
|
@@ -3006,7 +3071,7 @@ function useWireDetectionIntoManager() {
|
|
|
3006
3071
|
function useWalletConnectConnect(walletCfg) {
|
|
3007
3072
|
const cfgRef = { current: walletCfg };
|
|
3008
3073
|
return useCallback(
|
|
3009
|
-
() => walletManager.connectWalletConnect(cfgRef.current),
|
|
3074
|
+
(ecosystem) => walletManager.connectWalletConnect(cfgRef.current, ecosystem),
|
|
3010
3075
|
[]
|
|
3011
3076
|
);
|
|
3012
3077
|
}
|
|
@@ -3026,6 +3091,7 @@ function useWalletInfo(wagmi) {
|
|
|
3026
3091
|
connectedVia: snapshot.connectedVia,
|
|
3027
3092
|
walletType: snapshot.walletType,
|
|
3028
3093
|
status: snapshot.status,
|
|
3094
|
+
detected: snapshot.detected,
|
|
3029
3095
|
disconnect
|
|
3030
3096
|
};
|
|
3031
3097
|
}
|
|
@@ -3177,44 +3243,39 @@ var init_manager = __esm({
|
|
|
3177
3243
|
this.emit();
|
|
3178
3244
|
}
|
|
3179
3245
|
}
|
|
3180
|
-
async connectWalletConnect(walletCfg) {
|
|
3181
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
3246
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
3247
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
3182
3248
|
this.emit();
|
|
3183
3249
|
return { error: null, api: this._wallet };
|
|
3184
3250
|
}
|
|
3251
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
3252
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
3253
|
+
});
|
|
3254
|
+
resetUniversalConnector();
|
|
3255
|
+
}
|
|
3185
3256
|
this._status = "connecting";
|
|
3186
3257
|
this.clearConnectedState();
|
|
3187
3258
|
this.emit();
|
|
3188
3259
|
try {
|
|
3189
3260
|
const connector = await getUniversalConnector(walletCfg);
|
|
3190
3261
|
await connector.connect();
|
|
3191
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
3262
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3263
|
+
try {
|
|
3264
|
+
await api.getAddress();
|
|
3265
|
+
} catch {
|
|
3266
|
+
await api.disconnect?.().catch(() => {
|
|
3267
|
+
});
|
|
3268
|
+
resetUniversalConnector();
|
|
3269
|
+
throw new Error(
|
|
3270
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
3271
|
+
);
|
|
3272
|
+
}
|
|
3192
3273
|
this._wallet = api;
|
|
3193
3274
|
this._connectedVia = "walletconnect";
|
|
3194
3275
|
this._connectedWalletId = "walletconnect";
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
if (accounts.length === 0) {
|
|
3199
|
-
this.fullReset();
|
|
3200
|
-
this.triggerExternalDisconnect();
|
|
3201
|
-
this.emit();
|
|
3202
|
-
return;
|
|
3203
|
-
}
|
|
3204
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3205
|
-
this.emit();
|
|
3206
|
-
},
|
|
3207
|
-
onChainChanged: () => {
|
|
3208
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3209
|
-
this.emit();
|
|
3210
|
-
},
|
|
3211
|
-
onDisconnect: () => {
|
|
3212
|
-
this.fullReset();
|
|
3213
|
-
resetUniversalConnector();
|
|
3214
|
-
this.triggerExternalDisconnect();
|
|
3215
|
-
this.emit();
|
|
3216
|
-
}
|
|
3217
|
-
});
|
|
3276
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3277
|
+
connector.provider
|
|
3278
|
+
);
|
|
3218
3279
|
await this.syncIdentityFromWallet("walletconnect");
|
|
3219
3280
|
this._status = "connected";
|
|
3220
3281
|
this._error = null;
|
|
@@ -3229,6 +3290,100 @@ var init_manager = __esm({
|
|
|
3229
3290
|
return { error: message, api: null };
|
|
3230
3291
|
}
|
|
3231
3292
|
}
|
|
3293
|
+
bindWalletConnectProviderEvents(provider) {
|
|
3294
|
+
return bindWalletConnectEvents(provider, {
|
|
3295
|
+
onAccountsChanged: (accounts) => {
|
|
3296
|
+
if (accounts.length === 0) {
|
|
3297
|
+
this.fullReset();
|
|
3298
|
+
this.triggerExternalDisconnect();
|
|
3299
|
+
this.emit();
|
|
3300
|
+
return;
|
|
3301
|
+
}
|
|
3302
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3303
|
+
this.emit();
|
|
3304
|
+
},
|
|
3305
|
+
onChainChanged: () => {
|
|
3306
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3307
|
+
this.emit();
|
|
3308
|
+
},
|
|
3309
|
+
onDisconnect: () => {
|
|
3310
|
+
this.fullReset();
|
|
3311
|
+
resetUniversalConnector();
|
|
3312
|
+
this.triggerExternalDisconnect();
|
|
3313
|
+
this.emit();
|
|
3314
|
+
}
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
3318
|
+
// from storage on every init — including after a fresh page load — but
|
|
3319
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
3320
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
3321
|
+
// wallet app can cause the OS to reload the page before the original
|
|
3322
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
3323
|
+
// approval never gets to record it as "connected" here — even though
|
|
3324
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
3325
|
+
// storage. Call this on mount to pick that back up.
|
|
3326
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
3327
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
3328
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
3329
|
+
}
|
|
3330
|
+
if (typeof window === "undefined") return null;
|
|
3331
|
+
try {
|
|
3332
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
3333
|
+
return null;
|
|
3334
|
+
}
|
|
3335
|
+
} catch {
|
|
3336
|
+
}
|
|
3337
|
+
let connector;
|
|
3338
|
+
try {
|
|
3339
|
+
connector = await getUniversalConnector(walletCfg);
|
|
3340
|
+
} catch (e2) {
|
|
3341
|
+
console.warn(
|
|
3342
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
3343
|
+
e2
|
|
3344
|
+
);
|
|
3345
|
+
return null;
|
|
3346
|
+
}
|
|
3347
|
+
const session = connector.provider.session;
|
|
3348
|
+
if (!session) return null;
|
|
3349
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
3350
|
+
if (!ecosystem) return null;
|
|
3351
|
+
try {
|
|
3352
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3353
|
+
this._wallet = api;
|
|
3354
|
+
this._connectedVia = "walletconnect";
|
|
3355
|
+
this._connectedWalletId = "walletconnect";
|
|
3356
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3357
|
+
connector.provider
|
|
3358
|
+
);
|
|
3359
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
3360
|
+
this._status = "connected";
|
|
3361
|
+
this._error = null;
|
|
3362
|
+
this.emit();
|
|
3363
|
+
return ecosystem;
|
|
3364
|
+
} catch {
|
|
3365
|
+
return null;
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
3369
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
3370
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
3371
|
+
// from this side, so this tears down the whole connector — the next
|
|
3372
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
3373
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
3374
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
3375
|
+
cancelWalletConnectAttempt() {
|
|
3376
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
3377
|
+
return;
|
|
3378
|
+
}
|
|
3379
|
+
resetUniversalConnector();
|
|
3380
|
+
if (this._status === "connecting") {
|
|
3381
|
+
this.clearConnectedState();
|
|
3382
|
+
this._status = "idle";
|
|
3383
|
+
this._error = null;
|
|
3384
|
+
this.emit();
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3232
3387
|
async disconnect(wagmi) {
|
|
3233
3388
|
if (wagmi && this._connectedVia === "extension") {
|
|
3234
3389
|
await wagmi.disconnect().catch(() => {
|
|
@@ -4095,7 +4250,9 @@ export {
|
|
|
4095
4250
|
buildDetectedWalletFromProvider,
|
|
4096
4251
|
connectDetectedWallet,
|
|
4097
4252
|
createWalletConnectEntry,
|
|
4253
|
+
decodeBase64,
|
|
4098
4254
|
detectSolanaWallets,
|
|
4255
|
+
encodeBase64,
|
|
4099
4256
|
formatDeepLink,
|
|
4100
4257
|
formatWalletConnectDeepLink,
|
|
4101
4258
|
formatWalletConnectDeepLinkForWallet,
|