@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/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
import './manager-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-BTPkApRH.cjs';
|
|
2
|
+
import './manager-BZwbtOyf.cjs';
|
|
3
3
|
import './blockchain-BxAFzp0s.cjs';
|
|
4
4
|
import './types-DX3HtFcn.cjs';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as Trustware, a as TrustwareCore } from './core-
|
|
2
|
-
import './manager-
|
|
1
|
+
export { T as Trustware, a as TrustwareCore } from './core-2oZuxC1J.js';
|
|
2
|
+
import './manager-BMO1O-cW.js';
|
|
3
3
|
import './blockchain-BxAFzp0s.js';
|
|
4
4
|
import './types-BJY9r-mz.js';
|
package/dist/core.mjs
CHANGED
|
@@ -53,7 +53,7 @@ var init_constants = __esm({
|
|
|
53
53
|
"src/constants.ts"() {
|
|
54
54
|
"use strict";
|
|
55
55
|
SDK_NAME = "@trustware/sdk";
|
|
56
|
-
SDK_VERSION = "1.1.9-staging.
|
|
56
|
+
SDK_VERSION = "1.1.9-staging.6";
|
|
57
57
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
58
58
|
API_PREFIX = "/api";
|
|
59
59
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -2448,7 +2448,7 @@ var init_walletconnect = __esm({
|
|
|
2448
2448
|
solanaMainnet = {
|
|
2449
2449
|
id: 900,
|
|
2450
2450
|
chainNamespace: "solana",
|
|
2451
|
-
caipNetworkId: "solana:
|
|
2451
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2452
2452
|
name: "Solana Mainnet",
|
|
2453
2453
|
nativeCurrency: {
|
|
2454
2454
|
name: "Solana",
|
|
@@ -3327,8 +3327,62 @@ function getChainMeta(chainId) {
|
|
|
3327
3327
|
rpcUrls: chain.rpcUrls.default.http
|
|
3328
3328
|
};
|
|
3329
3329
|
}
|
|
3330
|
-
|
|
3330
|
+
function extractSolanaAddress(connector) {
|
|
3331
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
3332
|
+
if (!caipAccount) return null;
|
|
3333
|
+
return caipAccount.split(":")[2] ?? null;
|
|
3334
|
+
}
|
|
3335
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
3336
|
+
return {
|
|
3337
|
+
get publicKey() {
|
|
3338
|
+
const address = extractSolanaAddress(connector);
|
|
3339
|
+
return address ? { toString: () => address } : void 0;
|
|
3340
|
+
},
|
|
3341
|
+
async connect() {
|
|
3342
|
+
const address = extractSolanaAddress(connector);
|
|
3343
|
+
if (!address) {
|
|
3344
|
+
throw new Error(
|
|
3345
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
3346
|
+
);
|
|
3347
|
+
}
|
|
3348
|
+
return { publicKey: { toString: () => address } };
|
|
3349
|
+
},
|
|
3350
|
+
async disconnect() {
|
|
3351
|
+
},
|
|
3352
|
+
async signTransaction(transaction) {
|
|
3353
|
+
const tx = transaction;
|
|
3354
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
3355
|
+
requireAllSignatures: false,
|
|
3356
|
+
verifySignatures: false
|
|
3357
|
+
});
|
|
3358
|
+
const result = await connector.provider.request(
|
|
3359
|
+
{
|
|
3360
|
+
method: "solana_signTransaction",
|
|
3361
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
3362
|
+
},
|
|
3363
|
+
solanaMainnet.caipNetworkId
|
|
3364
|
+
);
|
|
3365
|
+
if (!result.transaction) {
|
|
3366
|
+
throw new Error(
|
|
3367
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
3368
|
+
);
|
|
3369
|
+
}
|
|
3370
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
3371
|
+
return { serialize: () => signedBytes };
|
|
3372
|
+
},
|
|
3373
|
+
on() {
|
|
3374
|
+
},
|
|
3375
|
+
off() {
|
|
3376
|
+
},
|
|
3377
|
+
removeListener() {
|
|
3378
|
+
}
|
|
3379
|
+
};
|
|
3380
|
+
}
|
|
3381
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
3331
3382
|
const connector = await getUniversalConnector(walletCfg);
|
|
3383
|
+
if (ecosystem === "solana") {
|
|
3384
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
3385
|
+
}
|
|
3332
3386
|
const provider = connector.provider;
|
|
3333
3387
|
const api = {
|
|
3334
3388
|
ecosystem: "evm",
|
|
@@ -3537,44 +3591,39 @@ var init_manager = __esm({
|
|
|
3537
3591
|
this.emit();
|
|
3538
3592
|
}
|
|
3539
3593
|
}
|
|
3540
|
-
async connectWalletConnect(walletCfg) {
|
|
3541
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
3594
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
3595
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
3542
3596
|
this.emit();
|
|
3543
3597
|
return { error: null, api: this._wallet };
|
|
3544
3598
|
}
|
|
3599
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
3600
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
3601
|
+
});
|
|
3602
|
+
resetUniversalConnector();
|
|
3603
|
+
}
|
|
3545
3604
|
this._status = "connecting";
|
|
3546
3605
|
this.clearConnectedState();
|
|
3547
3606
|
this.emit();
|
|
3548
3607
|
try {
|
|
3549
3608
|
const connector = await getUniversalConnector(walletCfg);
|
|
3550
3609
|
await connector.connect();
|
|
3551
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
3610
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3611
|
+
try {
|
|
3612
|
+
await api.getAddress();
|
|
3613
|
+
} catch {
|
|
3614
|
+
await api.disconnect?.().catch(() => {
|
|
3615
|
+
});
|
|
3616
|
+
resetUniversalConnector();
|
|
3617
|
+
throw new Error(
|
|
3618
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
3619
|
+
);
|
|
3620
|
+
}
|
|
3552
3621
|
this._wallet = api;
|
|
3553
3622
|
this._connectedVia = "walletconnect";
|
|
3554
3623
|
this._connectedWalletId = "walletconnect";
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
if (accounts.length === 0) {
|
|
3559
|
-
this.fullReset();
|
|
3560
|
-
this.triggerExternalDisconnect();
|
|
3561
|
-
this.emit();
|
|
3562
|
-
return;
|
|
3563
|
-
}
|
|
3564
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3565
|
-
this.emit();
|
|
3566
|
-
},
|
|
3567
|
-
onChainChanged: () => {
|
|
3568
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3569
|
-
this.emit();
|
|
3570
|
-
},
|
|
3571
|
-
onDisconnect: () => {
|
|
3572
|
-
this.fullReset();
|
|
3573
|
-
resetUniversalConnector();
|
|
3574
|
-
this.triggerExternalDisconnect();
|
|
3575
|
-
this.emit();
|
|
3576
|
-
}
|
|
3577
|
-
});
|
|
3624
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3625
|
+
connector.provider
|
|
3626
|
+
);
|
|
3578
3627
|
await this.syncIdentityFromWallet("walletconnect");
|
|
3579
3628
|
this._status = "connected";
|
|
3580
3629
|
this._error = null;
|
|
@@ -3589,6 +3638,100 @@ var init_manager = __esm({
|
|
|
3589
3638
|
return { error: message, api: null };
|
|
3590
3639
|
}
|
|
3591
3640
|
}
|
|
3641
|
+
bindWalletConnectProviderEvents(provider) {
|
|
3642
|
+
return bindWalletConnectEvents(provider, {
|
|
3643
|
+
onAccountsChanged: (accounts) => {
|
|
3644
|
+
if (accounts.length === 0) {
|
|
3645
|
+
this.fullReset();
|
|
3646
|
+
this.triggerExternalDisconnect();
|
|
3647
|
+
this.emit();
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3651
|
+
this.emit();
|
|
3652
|
+
},
|
|
3653
|
+
onChainChanged: () => {
|
|
3654
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3655
|
+
this.emit();
|
|
3656
|
+
},
|
|
3657
|
+
onDisconnect: () => {
|
|
3658
|
+
this.fullReset();
|
|
3659
|
+
resetUniversalConnector();
|
|
3660
|
+
this.triggerExternalDisconnect();
|
|
3661
|
+
this.emit();
|
|
3662
|
+
}
|
|
3663
|
+
});
|
|
3664
|
+
}
|
|
3665
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
3666
|
+
// from storage on every init — including after a fresh page load — but
|
|
3667
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
3668
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
3669
|
+
// wallet app can cause the OS to reload the page before the original
|
|
3670
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
3671
|
+
// approval never gets to record it as "connected" here — even though
|
|
3672
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
3673
|
+
// storage. Call this on mount to pick that back up.
|
|
3674
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
3675
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
3676
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
3677
|
+
}
|
|
3678
|
+
if (typeof window === "undefined") return null;
|
|
3679
|
+
try {
|
|
3680
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
3681
|
+
return null;
|
|
3682
|
+
}
|
|
3683
|
+
} catch {
|
|
3684
|
+
}
|
|
3685
|
+
let connector;
|
|
3686
|
+
try {
|
|
3687
|
+
connector = await getUniversalConnector(walletCfg);
|
|
3688
|
+
} catch (e2) {
|
|
3689
|
+
console.warn(
|
|
3690
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
3691
|
+
e2
|
|
3692
|
+
);
|
|
3693
|
+
return null;
|
|
3694
|
+
}
|
|
3695
|
+
const session = connector.provider.session;
|
|
3696
|
+
if (!session) return null;
|
|
3697
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
3698
|
+
if (!ecosystem) return null;
|
|
3699
|
+
try {
|
|
3700
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3701
|
+
this._wallet = api;
|
|
3702
|
+
this._connectedVia = "walletconnect";
|
|
3703
|
+
this._connectedWalletId = "walletconnect";
|
|
3704
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3705
|
+
connector.provider
|
|
3706
|
+
);
|
|
3707
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
3708
|
+
this._status = "connected";
|
|
3709
|
+
this._error = null;
|
|
3710
|
+
this.emit();
|
|
3711
|
+
return ecosystem;
|
|
3712
|
+
} catch {
|
|
3713
|
+
return null;
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3716
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
3717
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
3718
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
3719
|
+
// from this side, so this tears down the whole connector — the next
|
|
3720
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
3721
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
3722
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
3723
|
+
cancelWalletConnectAttempt() {
|
|
3724
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
resetUniversalConnector();
|
|
3728
|
+
if (this._status === "connecting") {
|
|
3729
|
+
this.clearConnectedState();
|
|
3730
|
+
this._status = "idle";
|
|
3731
|
+
this._error = null;
|
|
3732
|
+
this.emit();
|
|
3733
|
+
}
|
|
3734
|
+
}
|
|
3592
3735
|
async disconnect(wagmi) {
|
|
3593
3736
|
if (wagmi && this._connectedVia === "extension") {
|
|
3594
3737
|
await wagmi.disconnect().catch(() => {
|