@trustware/sdk-staging 1.1.9-staging.5 → 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 +532 -91
- 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 +784 -341
- 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 +532 -91
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +750 -307
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/constants.cjs
CHANGED
|
@@ -30,7 +30,7 @@ __export(constants_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(constants_exports);
|
|
32
32
|
var SDK_NAME = "@trustware/sdk";
|
|
33
|
-
var SDK_VERSION = "1.1.9-staging.
|
|
33
|
+
var SDK_VERSION = "1.1.9-staging.6";
|
|
34
34
|
var API_ROOT = "https://bv-staging-api.trustware.io";
|
|
35
35
|
var GTM_ID = "GTM-TZDGNCXB";
|
|
36
36
|
var API_PREFIX = "/api";
|
package/dist/constants.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, y as TrustwareTheme, N as WalletIdentity, a0 as walletManager, G as WalletAddressResolution, a3 as buildRoute, a4 as buildDepositAddress, a5 as submitReceipt, a6 as getStatus, a7 as pollStatus } from './manager-
|
|
1
|
+
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, y as TrustwareTheme, N as WalletIdentity, a0 as walletManager, G as WalletAddressResolution, a3 as buildRoute, a4 as buildDepositAddress, a5 as submitReceipt, a6 as getStatus, a7 as pollStatus } from './manager-BMO1O-cW.js';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.js';
|
|
3
3
|
import { T as Token } from './types-BJY9r-mz.js';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, y as TrustwareTheme, N as WalletIdentity, a0 as walletManager, G as WalletAddressResolution, a3 as buildRoute, a4 as buildDepositAddress, a5 as submitReceipt, a6 as getStatus, a7 as pollStatus } from './manager-
|
|
1
|
+
import { B as BuildRouteResult, b as Transaction, T as TrustwareConfigOptions, W as WalletInterFaceAPI, m as ResolvedTrustwareConfig, y as TrustwareTheme, N as WalletIdentity, a0 as walletManager, G as WalletAddressResolution, a3 as buildRoute, a4 as buildDepositAddress, a5 as submitReceipt, a6 as getStatus, a7 as pollStatus } from './manager-BZwbtOyf.cjs';
|
|
2
2
|
import { C as ChainDef, c as ChainType, G as GetBalancesOptions, B as BalanceRow, a as BalanceStreamOptions, W as WalletAddressBalanceWrapper } from './blockchain-BxAFzp0s.cjs';
|
|
3
3
|
import { T as Token } from './types-DX3HtFcn.cjs';
|
|
4
4
|
|
package/dist/core.cjs
CHANGED
|
@@ -75,7 +75,7 @@ var init_constants = __esm({
|
|
|
75
75
|
"src/constants.ts"() {
|
|
76
76
|
"use strict";
|
|
77
77
|
SDK_NAME = "@trustware/sdk";
|
|
78
|
-
SDK_VERSION = "1.1.9-staging.
|
|
78
|
+
SDK_VERSION = "1.1.9-staging.6";
|
|
79
79
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
80
80
|
API_PREFIX = "/api";
|
|
81
81
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -2470,7 +2470,7 @@ var init_walletconnect = __esm({
|
|
|
2470
2470
|
solanaMainnet = {
|
|
2471
2471
|
id: 900,
|
|
2472
2472
|
chainNamespace: "solana",
|
|
2473
|
-
caipNetworkId: "solana:
|
|
2473
|
+
caipNetworkId: "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
2474
2474
|
name: "Solana Mainnet",
|
|
2475
2475
|
nativeCurrency: {
|
|
2476
2476
|
name: "Solana",
|
|
@@ -3348,8 +3348,62 @@ function getChainMeta(chainId) {
|
|
|
3348
3348
|
rpcUrls: chain.rpcUrls.default.http
|
|
3349
3349
|
};
|
|
3350
3350
|
}
|
|
3351
|
-
|
|
3351
|
+
function extractSolanaAddress(connector) {
|
|
3352
|
+
const caipAccount = connector.provider.session?.namespaces?.solana?.accounts?.[0];
|
|
3353
|
+
if (!caipAccount) return null;
|
|
3354
|
+
return caipAccount.split(":")[2] ?? null;
|
|
3355
|
+
}
|
|
3356
|
+
function buildWalletConnectSolanaProvider(connector) {
|
|
3357
|
+
return {
|
|
3358
|
+
get publicKey() {
|
|
3359
|
+
const address = extractSolanaAddress(connector);
|
|
3360
|
+
return address ? { toString: () => address } : void 0;
|
|
3361
|
+
},
|
|
3362
|
+
async connect() {
|
|
3363
|
+
const address = extractSolanaAddress(connector);
|
|
3364
|
+
if (!address) {
|
|
3365
|
+
throw new Error(
|
|
3366
|
+
"This wallet did not approve a Solana account over WalletConnect."
|
|
3367
|
+
);
|
|
3368
|
+
}
|
|
3369
|
+
return { publicKey: { toString: () => address } };
|
|
3370
|
+
},
|
|
3371
|
+
async disconnect() {
|
|
3372
|
+
},
|
|
3373
|
+
async signTransaction(transaction) {
|
|
3374
|
+
const tx = transaction;
|
|
3375
|
+
const rawBytes = "version" in tx ? tx.serialize() : tx.serialize({
|
|
3376
|
+
requireAllSignatures: false,
|
|
3377
|
+
verifySignatures: false
|
|
3378
|
+
});
|
|
3379
|
+
const result = await connector.provider.request(
|
|
3380
|
+
{
|
|
3381
|
+
method: "solana_signTransaction",
|
|
3382
|
+
params: { transaction: encodeBase64(rawBytes) }
|
|
3383
|
+
},
|
|
3384
|
+
solanaMainnet.caipNetworkId
|
|
3385
|
+
);
|
|
3386
|
+
if (!result.transaction) {
|
|
3387
|
+
throw new Error(
|
|
3388
|
+
"WalletConnect wallet did not return a signed Solana transaction."
|
|
3389
|
+
);
|
|
3390
|
+
}
|
|
3391
|
+
const signedBytes = decodeBase64(result.transaction);
|
|
3392
|
+
return { serialize: () => signedBytes };
|
|
3393
|
+
},
|
|
3394
|
+
on() {
|
|
3395
|
+
},
|
|
3396
|
+
off() {
|
|
3397
|
+
},
|
|
3398
|
+
removeListener() {
|
|
3399
|
+
}
|
|
3400
|
+
};
|
|
3401
|
+
}
|
|
3402
|
+
async function buildWalletConnectAPI(walletCfg, ecosystem = "evm") {
|
|
3352
3403
|
const connector = await getUniversalConnector(walletCfg);
|
|
3404
|
+
if (ecosystem === "solana") {
|
|
3405
|
+
return toSolanaWalletInterface(buildWalletConnectSolanaProvider(connector));
|
|
3406
|
+
}
|
|
3353
3407
|
const provider = connector.provider;
|
|
3354
3408
|
const api = {
|
|
3355
3409
|
ecosystem: "evm",
|
|
@@ -3559,44 +3613,39 @@ var init_manager = __esm({
|
|
|
3559
3613
|
this.emit();
|
|
3560
3614
|
}
|
|
3561
3615
|
}
|
|
3562
|
-
async connectWalletConnect(walletCfg) {
|
|
3563
|
-
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet) {
|
|
3616
|
+
async connectWalletConnect(walletCfg, ecosystem = "evm") {
|
|
3617
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect" && this._wallet && this._wallet.ecosystem === ecosystem) {
|
|
3564
3618
|
this.emit();
|
|
3565
3619
|
return { error: null, api: this._wallet };
|
|
3566
3620
|
}
|
|
3621
|
+
if (this._connectedVia === "walletconnect" && this._wallet) {
|
|
3622
|
+
await this._wallet.disconnect?.().catch(() => {
|
|
3623
|
+
});
|
|
3624
|
+
resetUniversalConnector();
|
|
3625
|
+
}
|
|
3567
3626
|
this._status = "connecting";
|
|
3568
3627
|
this.clearConnectedState();
|
|
3569
3628
|
this.emit();
|
|
3570
3629
|
try {
|
|
3571
3630
|
const connector = await getUniversalConnector(walletCfg);
|
|
3572
3631
|
await connector.connect();
|
|
3573
|
-
const api = await buildWalletConnectAPI(walletCfg);
|
|
3632
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3633
|
+
try {
|
|
3634
|
+
await api.getAddress();
|
|
3635
|
+
} catch {
|
|
3636
|
+
await api.disconnect?.().catch(() => {
|
|
3637
|
+
});
|
|
3638
|
+
resetUniversalConnector();
|
|
3639
|
+
throw new Error(
|
|
3640
|
+
`This wallet did not approve a${ecosystem === "evm" ? "n" : ""} ${ecosystem === "evm" ? "EVM" : "Solana"} account over WalletConnect.`
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3574
3643
|
this._wallet = api;
|
|
3575
3644
|
this._connectedVia = "walletconnect";
|
|
3576
3645
|
this._connectedWalletId = "walletconnect";
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
if (accounts.length === 0) {
|
|
3581
|
-
this.fullReset();
|
|
3582
|
-
this.triggerExternalDisconnect();
|
|
3583
|
-
this.emit();
|
|
3584
|
-
return;
|
|
3585
|
-
}
|
|
3586
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3587
|
-
this.emit();
|
|
3588
|
-
},
|
|
3589
|
-
onChainChanged: () => {
|
|
3590
|
-
void this.syncIdentityFromWallet("walletconnect");
|
|
3591
|
-
this.emit();
|
|
3592
|
-
},
|
|
3593
|
-
onDisconnect: () => {
|
|
3594
|
-
this.fullReset();
|
|
3595
|
-
resetUniversalConnector();
|
|
3596
|
-
this.triggerExternalDisconnect();
|
|
3597
|
-
this.emit();
|
|
3598
|
-
}
|
|
3599
|
-
});
|
|
3646
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3647
|
+
connector.provider
|
|
3648
|
+
);
|
|
3600
3649
|
await this.syncIdentityFromWallet("walletconnect");
|
|
3601
3650
|
this._status = "connected";
|
|
3602
3651
|
this._error = null;
|
|
@@ -3611,6 +3660,100 @@ var init_manager = __esm({
|
|
|
3611
3660
|
return { error: message, api: null };
|
|
3612
3661
|
}
|
|
3613
3662
|
}
|
|
3663
|
+
bindWalletConnectProviderEvents(provider) {
|
|
3664
|
+
return bindWalletConnectEvents(provider, {
|
|
3665
|
+
onAccountsChanged: (accounts) => {
|
|
3666
|
+
if (accounts.length === 0) {
|
|
3667
|
+
this.fullReset();
|
|
3668
|
+
this.triggerExternalDisconnect();
|
|
3669
|
+
this.emit();
|
|
3670
|
+
return;
|
|
3671
|
+
}
|
|
3672
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3673
|
+
this.emit();
|
|
3674
|
+
},
|
|
3675
|
+
onChainChanged: () => {
|
|
3676
|
+
void this.syncIdentityFromWallet("walletconnect");
|
|
3677
|
+
this.emit();
|
|
3678
|
+
},
|
|
3679
|
+
onDisconnect: () => {
|
|
3680
|
+
this.fullReset();
|
|
3681
|
+
resetUniversalConnector();
|
|
3682
|
+
this.triggerExternalDisconnect();
|
|
3683
|
+
this.emit();
|
|
3684
|
+
}
|
|
3685
|
+
});
|
|
3686
|
+
}
|
|
3687
|
+
// WalletConnect's own SignClient auto-restores the last persisted session
|
|
3688
|
+
// from storage on every init — including after a fresh page load — but
|
|
3689
|
+
// that restoration happens silently inside the library. Nothing calls back
|
|
3690
|
+
// into our code for it. On mobile, backgrounding the tab to approve in a
|
|
3691
|
+
// wallet app can cause the OS to reload the page before the original
|
|
3692
|
+
// connect() promise ever resolves, so the connect flow that triggered the
|
|
3693
|
+
// approval never gets to record it as "connected" here — even though
|
|
3694
|
+
// WalletConnect itself already has a live, approved session sitting in
|
|
3695
|
+
// storage. Call this on mount to pick that back up.
|
|
3696
|
+
async restoreWalletConnectSession(walletCfg) {
|
|
3697
|
+
if (this._status === "connected" && this._connectedVia === "walletconnect") {
|
|
3698
|
+
return this._wallet?.ecosystem === "solana" ? "solana" : "evm";
|
|
3699
|
+
}
|
|
3700
|
+
if (typeof window === "undefined") return null;
|
|
3701
|
+
try {
|
|
3702
|
+
if (!Object.keys(window.localStorage).some((key) => key.startsWith("wc@2"))) {
|
|
3703
|
+
return null;
|
|
3704
|
+
}
|
|
3705
|
+
} catch {
|
|
3706
|
+
}
|
|
3707
|
+
let connector;
|
|
3708
|
+
try {
|
|
3709
|
+
connector = await getUniversalConnector(walletCfg);
|
|
3710
|
+
} catch (e2) {
|
|
3711
|
+
console.warn(
|
|
3712
|
+
"[Trustware SDK] Failed to restore WalletConnect session:",
|
|
3713
|
+
e2
|
|
3714
|
+
);
|
|
3715
|
+
return null;
|
|
3716
|
+
}
|
|
3717
|
+
const session = connector.provider.session;
|
|
3718
|
+
if (!session) return null;
|
|
3719
|
+
const ecosystem = session.namespaces?.solana?.accounts?.length ? "solana" : session.namespaces?.eip155?.accounts?.length ? "evm" : null;
|
|
3720
|
+
if (!ecosystem) return null;
|
|
3721
|
+
try {
|
|
3722
|
+
const api = await buildWalletConnectAPI(walletCfg, ecosystem);
|
|
3723
|
+
this._wallet = api;
|
|
3724
|
+
this._connectedVia = "walletconnect";
|
|
3725
|
+
this._connectedWalletId = "walletconnect";
|
|
3726
|
+
this._providerCleanup = this.bindWalletConnectProviderEvents(
|
|
3727
|
+
connector.provider
|
|
3728
|
+
);
|
|
3729
|
+
await this.syncIdentityFromWallet("walletconnect");
|
|
3730
|
+
this._status = "connected";
|
|
3731
|
+
this._error = null;
|
|
3732
|
+
this.emit();
|
|
3733
|
+
return ecosystem;
|
|
3734
|
+
} catch {
|
|
3735
|
+
return null;
|
|
3736
|
+
}
|
|
3737
|
+
}
|
|
3738
|
+
// Forcibly abandon an in-progress connect() call the caller has decided is
|
|
3739
|
+
// stuck (e.g. the UI's own connect timeout elapsed with no response).
|
|
3740
|
+
// There's no clean way to cancel a pending WalletConnect pairing proposal
|
|
3741
|
+
// from this side, so this tears down the whole connector — the next
|
|
3742
|
+
// connect attempt starts against a brand new SignClient/pairing instead of
|
|
3743
|
+
// racing the abandoned one, which would otherwise risk reproducing the
|
|
3744
|
+
// "No matching key. proposal" class of error a real retry needs to avoid.
|
|
3745
|
+
cancelWalletConnectAttempt() {
|
|
3746
|
+
if (this._connectedVia === "walletconnect" && this._status === "connected") {
|
|
3747
|
+
return;
|
|
3748
|
+
}
|
|
3749
|
+
resetUniversalConnector();
|
|
3750
|
+
if (this._status === "connecting") {
|
|
3751
|
+
this.clearConnectedState();
|
|
3752
|
+
this._status = "idle";
|
|
3753
|
+
this._error = null;
|
|
3754
|
+
this.emit();
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3614
3757
|
async disconnect(wagmi) {
|
|
3615
3758
|
if (wagmi && this._connectedVia === "extension") {
|
|
3616
3759
|
await wagmi.disconnect().catch(() => {
|