@trustware/sdk-staging 1.1.8-staging.5 → 1.1.8-staging.7
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-BcoaMbJ6.d.cts → core-BUe031hU.d.cts} +1 -1
- package/dist/{core-BqqBQ5nF.d.ts → core-DnrIv4h8.d.ts} +1 -1
- package/dist/core.cjs +1063 -22
- 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 +1063 -22
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-srLQtIzU.d.cts → detect-DlbgTrkm.d.cts} +1 -1
- package/dist/{detect-F6garpnf.d.ts → detect-MWKHLhn9.d.ts} +1 -1
- package/dist/index.cjs +3170 -1483
- 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 +3160 -1472
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-BWmNEeZb.d.cts → manager-DKVW7zeh.d.cts} +6 -13
- package/dist/{manager-BojJyYIt.d.ts → manager-aOd3vkF9.d.ts} +6 -13
- package/dist/smart-account.cjs +4 -15
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.d.cts +24 -24
- package/dist/smart-account.d.ts +24 -24
- package/dist/smart-account.mjs +4 -15
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +147 -17
- package/dist/wallet.cjs.map +1 -1
- package/dist/wallet.d.cts +3 -3
- package/dist/wallet.d.ts +3 -3
- package/dist/wallet.mjs +147 -17
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +2785 -1082
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +2779 -1076
- package/dist/widget.mjs.map +1 -1
- package/package.json +2 -1
package/dist/wallet.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { W as WagmiBridge,
|
|
3
|
-
export { a as autoDetectWallet, b as buildDetectedWalletFromProvider, c as connectDetectedWallet, d as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, e as useIsMobile, f as useWagmi, g as useWalletDetection } from './detect-
|
|
1
|
+
import { r as SolanaProviderLike, Q as WalletMeta, e as DetectedWallet, L as WalletId, s as SolanaWalletInterface } from './manager-DKVW7zeh.cjs';
|
|
2
|
+
export { W as WagmiBridge, A as WagmiConnector, U as WalletSnapshot, a3 as useWalletConnectConnect, a4 as useWalletExternalDisconnect, a5 as useWalletInfo, a6 as useWireDetectionIntoManager, a7 as walletManager } from './manager-DKVW7zeh.cjs';
|
|
3
|
+
export { a as autoDetectWallet, b as buildDetectedWalletFromProvider, c as connectDetectedWallet, d as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, e as useIsMobile, f as useWagmi, g as useWalletDetection } from './detect-DlbgTrkm.cjs';
|
|
4
4
|
import './blockchain-BONedEsU.cjs';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
package/dist/wallet.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { W as WagmiBridge,
|
|
3
|
-
export { a as autoDetectWallet, b as buildDetectedWalletFromProvider, c as connectDetectedWallet, d as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, e as useIsMobile, f as useWagmi, g as useWalletDetection } from './detect-
|
|
1
|
+
import { r as SolanaProviderLike, Q as WalletMeta, e as DetectedWallet, L as WalletId, s as SolanaWalletInterface } from './manager-aOd3vkF9.js';
|
|
2
|
+
export { W as WagmiBridge, A as WagmiConnector, U as WalletSnapshot, a3 as useWalletConnectConnect, a4 as useWalletExternalDisconnect, a5 as useWalletInfo, a6 as useWireDetectionIntoManager, a7 as walletManager } from './manager-aOd3vkF9.js';
|
|
3
|
+
export { a as autoDetectWallet, b as buildDetectedWalletFromProvider, c as connectDetectedWallet, d as createWalletConnectEntry, t as toWalletInterfaceFromDetected, u as useEIP1193, e as useIsMobile, f as useWagmi, g as useWalletDetection } from './detect-MWKHLhn9.js';
|
|
4
4
|
import './blockchain-BONedEsU.js';
|
|
5
5
|
|
|
6
6
|
type SolanaEventHandlers = {
|
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.8-staging.
|
|
227
|
+
SDK_VERSION = "1.1.8-staging.7";
|
|
228
228
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
229
229
|
API_PREFIX = "/api";
|
|
230
230
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -233,20 +233,12 @@ var init_constants = __esm({
|
|
|
233
233
|
});
|
|
234
234
|
|
|
235
235
|
// src/config/defaults.ts
|
|
236
|
-
var DEFAULT_SLIPPAGE, DEFAULT_AUTO_DETECT_PROVIDER,
|
|
236
|
+
var DEFAULT_SLIPPAGE, DEFAULT_AUTO_DETECT_PROVIDER, DEFAULT_MESSAGES;
|
|
237
237
|
var init_defaults = __esm({
|
|
238
238
|
"src/config/defaults.ts"() {
|
|
239
239
|
"use strict";
|
|
240
240
|
DEFAULT_SLIPPAGE = 1;
|
|
241
241
|
DEFAULT_AUTO_DETECT_PROVIDER = false;
|
|
242
|
-
DEFAULT_THEME = {
|
|
243
|
-
primaryColor: "#4F46E5",
|
|
244
|
-
secondaryColor: "#6366F1",
|
|
245
|
-
backgroundColor: "#FFFFFF",
|
|
246
|
-
textColor: "#111827",
|
|
247
|
-
borderColor: "#E5E7EB",
|
|
248
|
-
radius: 8
|
|
249
|
-
};
|
|
250
242
|
DEFAULT_MESSAGES = {
|
|
251
243
|
title: "Trustware SDK",
|
|
252
244
|
description: "Seamlessly bridge assets across chains with Trustware."
|
|
@@ -306,10 +298,7 @@ var init_store = __esm({
|
|
|
306
298
|
...this._cfg,
|
|
307
299
|
...patch,
|
|
308
300
|
routes: { ...this._cfg.routes, ...patch.routes ?? {} },
|
|
309
|
-
theme:
|
|
310
|
-
...this._cfg.theme,
|
|
311
|
-
...patch.theme ?? {}
|
|
312
|
-
},
|
|
301
|
+
theme: patch.theme ?? this._cfg.theme,
|
|
313
302
|
messages: {
|
|
314
303
|
...this._cfg.messages,
|
|
315
304
|
...patch.messages ?? {}
|
|
@@ -1372,6 +1361,7 @@ var init_metadata = __esm({
|
|
|
1372
1361
|
"rainbow",
|
|
1373
1362
|
"phantom-evm",
|
|
1374
1363
|
"phantom-solana",
|
|
1364
|
+
"metamask-solana",
|
|
1375
1365
|
"solflare",
|
|
1376
1366
|
"okx",
|
|
1377
1367
|
"brave",
|
|
@@ -1451,6 +1441,15 @@ var init_metadata = __esm({
|
|
|
1451
1441
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1452
1442
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
1453
1443
|
},
|
|
1444
|
+
{
|
|
1445
|
+
id: "metamask-solana",
|
|
1446
|
+
name: "MetaMask (Solana)",
|
|
1447
|
+
category: "injected",
|
|
1448
|
+
ecosystem: "solana",
|
|
1449
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1450
|
+
emoji: "\u{1F98A}",
|
|
1451
|
+
homepage: "https://metamask.io/"
|
|
1452
|
+
},
|
|
1454
1453
|
{
|
|
1455
1454
|
id: "solflare",
|
|
1456
1455
|
name: "Solflare",
|
|
@@ -3426,7 +3425,7 @@ function resolveConfig(input) {
|
|
|
3426
3425
|
...input.routes.options
|
|
3427
3426
|
}
|
|
3428
3427
|
};
|
|
3429
|
-
const theme =
|
|
3428
|
+
const theme = input.theme ?? "system";
|
|
3430
3429
|
const messages = deepMerge(DEFAULT_MESSAGES, input.messages);
|
|
3431
3430
|
const retry = {
|
|
3432
3431
|
autoRetry: input.retry?.autoRetry ?? DEFAULT_RETRY_CONFIG.autoRetry,
|
|
@@ -3647,6 +3646,134 @@ var init_sdkRpc = __esm({
|
|
|
3647
3646
|
});
|
|
3648
3647
|
|
|
3649
3648
|
// src/wallets/solana.ts
|
|
3649
|
+
function encodeBase58(bytes) {
|
|
3650
|
+
const digits = [0];
|
|
3651
|
+
for (const byte of bytes) {
|
|
3652
|
+
let carry = byte;
|
|
3653
|
+
for (let i = 0; i < digits.length; i++) {
|
|
3654
|
+
carry += digits[i] << 8;
|
|
3655
|
+
digits[i] = carry % 58;
|
|
3656
|
+
carry = carry / 58 | 0;
|
|
3657
|
+
}
|
|
3658
|
+
while (carry > 0) {
|
|
3659
|
+
digits.push(carry % 58);
|
|
3660
|
+
carry = carry / 58 | 0;
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
let result = "";
|
|
3664
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
3665
|
+
result += "1";
|
|
3666
|
+
}
|
|
3667
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
3668
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
3669
|
+
}
|
|
3670
|
+
return result;
|
|
3671
|
+
}
|
|
3672
|
+
function collectWalletStandardWallets() {
|
|
3673
|
+
if (typeof window === "undefined") return [];
|
|
3674
|
+
const collected = [];
|
|
3675
|
+
const api = {
|
|
3676
|
+
register(...wallets) {
|
|
3677
|
+
collected.push(...wallets);
|
|
3678
|
+
return () => {
|
|
3679
|
+
};
|
|
3680
|
+
}
|
|
3681
|
+
};
|
|
3682
|
+
try {
|
|
3683
|
+
window.dispatchEvent(
|
|
3684
|
+
Object.assign(
|
|
3685
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
3686
|
+
{
|
|
3687
|
+
detail: api
|
|
3688
|
+
}
|
|
3689
|
+
)
|
|
3690
|
+
);
|
|
3691
|
+
} catch {
|
|
3692
|
+
}
|
|
3693
|
+
return collected;
|
|
3694
|
+
}
|
|
3695
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
3696
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
3697
|
+
const provider = {
|
|
3698
|
+
get isConnected() {
|
|
3699
|
+
return !!currentAccount;
|
|
3700
|
+
},
|
|
3701
|
+
get publicKey() {
|
|
3702
|
+
if (!currentAccount) return void 0;
|
|
3703
|
+
const addr = currentAccount.address;
|
|
3704
|
+
return { toString: () => addr };
|
|
3705
|
+
},
|
|
3706
|
+
async connect() {
|
|
3707
|
+
const feature = wallet.features["standard:connect"];
|
|
3708
|
+
if (!feature?.connect)
|
|
3709
|
+
throw new Error("Wallet Standard connect not available");
|
|
3710
|
+
const result = await feature.connect({ silent: false });
|
|
3711
|
+
currentAccount = result.accounts[0] ?? null;
|
|
3712
|
+
if (!currentAccount)
|
|
3713
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
3714
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
3715
|
+
},
|
|
3716
|
+
async disconnect() {
|
|
3717
|
+
const feature = wallet.features["standard:disconnect"];
|
|
3718
|
+
await feature?.disconnect?.();
|
|
3719
|
+
currentAccount = null;
|
|
3720
|
+
},
|
|
3721
|
+
async signAndSendTransaction(transaction, options) {
|
|
3722
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
3723
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
3724
|
+
throw new Error("signAndSendTransaction not available");
|
|
3725
|
+
}
|
|
3726
|
+
const txBytes = transaction.serialize();
|
|
3727
|
+
const results = await feature.signAndSendTransaction({
|
|
3728
|
+
account: currentAccount,
|
|
3729
|
+
transaction: txBytes,
|
|
3730
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
3731
|
+
options
|
|
3732
|
+
});
|
|
3733
|
+
const sig = results[0]?.signature;
|
|
3734
|
+
if (!sig) throw new Error("No signature returned");
|
|
3735
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
3736
|
+
},
|
|
3737
|
+
async signTransaction(transaction) {
|
|
3738
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
3739
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
3740
|
+
throw new Error("signTransaction not available");
|
|
3741
|
+
}
|
|
3742
|
+
const txBytes = transaction.serialize();
|
|
3743
|
+
const results = await feature.signTransaction({
|
|
3744
|
+
account: currentAccount,
|
|
3745
|
+
transaction: txBytes,
|
|
3746
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
3747
|
+
});
|
|
3748
|
+
const signed = results[0]?.signedTransaction;
|
|
3749
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
3750
|
+
return { serialize: () => signed };
|
|
3751
|
+
},
|
|
3752
|
+
on() {
|
|
3753
|
+
},
|
|
3754
|
+
off() {
|
|
3755
|
+
},
|
|
3756
|
+
removeListener() {
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
return provider;
|
|
3760
|
+
}
|
|
3761
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
3762
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
3763
|
+
if (!meta) return [];
|
|
3764
|
+
const standardWallets = collectWalletStandardWallets();
|
|
3765
|
+
const mmWallet = standardWallets.find(
|
|
3766
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
3767
|
+
);
|
|
3768
|
+
if (!mmWallet) return [];
|
|
3769
|
+
return [
|
|
3770
|
+
{
|
|
3771
|
+
meta,
|
|
3772
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
3773
|
+
via: "solana-window"
|
|
3774
|
+
}
|
|
3775
|
+
];
|
|
3776
|
+
}
|
|
3650
3777
|
function getPublicKeyString(provider) {
|
|
3651
3778
|
const publicKey = provider?.publicKey;
|
|
3652
3779
|
if (!publicKey) return null;
|
|
@@ -3708,12 +3835,13 @@ function getSolanaProviders() {
|
|
|
3708
3835
|
}
|
|
3709
3836
|
function detectSolanaWallets(wallets) {
|
|
3710
3837
|
const providers = getSolanaProviders();
|
|
3711
|
-
|
|
3838
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
3712
3839
|
const provider = providers[walletId];
|
|
3713
3840
|
const meta = wallets.find((item) => item.id === walletId);
|
|
3714
3841
|
if (!provider || !meta) return [];
|
|
3715
3842
|
return [{ meta, provider, via: "solana-window" }];
|
|
3716
3843
|
});
|
|
3844
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
3717
3845
|
}
|
|
3718
3846
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
3719
3847
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -3778,7 +3906,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
3778
3906
|
}
|
|
3779
3907
|
};
|
|
3780
3908
|
}
|
|
3781
|
-
var SOLANA_WALLET_IDS;
|
|
3909
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
3782
3910
|
var init_solana = __esm({
|
|
3783
3911
|
"src/wallets/solana.ts"() {
|
|
3784
3912
|
"use strict";
|
|
@@ -3788,6 +3916,8 @@ var init_solana = __esm({
|
|
|
3788
3916
|
"solflare",
|
|
3789
3917
|
"backpack"
|
|
3790
3918
|
];
|
|
3919
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
3920
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3791
3921
|
}
|
|
3792
3922
|
});
|
|
3793
3923
|
|