@trustware/sdk-staging 1.1.8-staging.4 → 1.1.8-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-DrWK6PT3.d.ts → core-BPYlJrNb.d.ts} +1 -1
- package/dist/{core-B9PJ0mUX.d.cts → core-CJMf4PvV.d.cts} +1 -1
- package/dist/core.cjs +1 -1
- 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 +1 -1
- package/dist/core.mjs.map +1 -1
- package/dist/{detect-Dn7A-Svt.d.cts → detect-CWNTV5Wq.d.cts} +1 -1
- package/dist/{detect-BLE9aPwJ.d.ts → detect-CaQQECVe.d.ts} +1 -1
- package/dist/index.cjs +643 -169
- 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 +670 -196
- package/dist/index.mjs.map +1 -1
- package/dist/{manager-C85ARoxD.d.cts → manager-DHCXknCG.d.cts} +8 -1
- package/dist/{manager-PBjHXKjh.d.ts → manager-Dtmjibzl.d.ts} +8 -1
- package/dist/smart-account.cjs +1 -1
- package/dist/smart-account.cjs.map +1 -1
- package/dist/smart-account.mjs +1 -1
- package/dist/smart-account.mjs.map +1 -1
- package/dist/wallet.cjs +144 -3
- 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 +144 -3
- package/dist/wallet.mjs.map +1 -1
- package/dist/widget.cjs +643 -169
- package/dist/widget.cjs.map +1 -1
- package/dist/widget.mjs +670 -196
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/wallet.cjs
CHANGED
|
@@ -250,7 +250,7 @@ var init_constants = __esm({
|
|
|
250
250
|
"src/constants.ts"() {
|
|
251
251
|
"use strict";
|
|
252
252
|
SDK_NAME = "@trustware/sdk";
|
|
253
|
-
SDK_VERSION = "1.1.8-staging.
|
|
253
|
+
SDK_VERSION = "1.1.8-staging.6";
|
|
254
254
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
255
255
|
API_PREFIX = "/api";
|
|
256
256
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -1398,6 +1398,7 @@ var init_metadata = __esm({
|
|
|
1398
1398
|
"rainbow",
|
|
1399
1399
|
"phantom-evm",
|
|
1400
1400
|
"phantom-solana",
|
|
1401
|
+
"metamask-solana",
|
|
1401
1402
|
"solflare",
|
|
1402
1403
|
"okx",
|
|
1403
1404
|
"brave",
|
|
@@ -1477,6 +1478,15 @@ var init_metadata = __esm({
|
|
|
1477
1478
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1478
1479
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
1479
1480
|
},
|
|
1481
|
+
{
|
|
1482
|
+
id: "metamask-solana",
|
|
1483
|
+
name: "MetaMask (Solana)",
|
|
1484
|
+
category: "injected",
|
|
1485
|
+
ecosystem: "solana",
|
|
1486
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1487
|
+
emoji: "\u{1F98A}",
|
|
1488
|
+
homepage: "https://metamask.io/"
|
|
1489
|
+
},
|
|
1480
1490
|
{
|
|
1481
1491
|
id: "solflare",
|
|
1482
1492
|
name: "Solflare",
|
|
@@ -3673,6 +3683,134 @@ var init_sdkRpc = __esm({
|
|
|
3673
3683
|
});
|
|
3674
3684
|
|
|
3675
3685
|
// src/wallets/solana.ts
|
|
3686
|
+
function encodeBase58(bytes) {
|
|
3687
|
+
const digits = [0];
|
|
3688
|
+
for (const byte of bytes) {
|
|
3689
|
+
let carry = byte;
|
|
3690
|
+
for (let i = 0; i < digits.length; i++) {
|
|
3691
|
+
carry += digits[i] << 8;
|
|
3692
|
+
digits[i] = carry % 58;
|
|
3693
|
+
carry = carry / 58 | 0;
|
|
3694
|
+
}
|
|
3695
|
+
while (carry > 0) {
|
|
3696
|
+
digits.push(carry % 58);
|
|
3697
|
+
carry = carry / 58 | 0;
|
|
3698
|
+
}
|
|
3699
|
+
}
|
|
3700
|
+
let result = "";
|
|
3701
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
3702
|
+
result += "1";
|
|
3703
|
+
}
|
|
3704
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
3705
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
3706
|
+
}
|
|
3707
|
+
return result;
|
|
3708
|
+
}
|
|
3709
|
+
function collectWalletStandardWallets() {
|
|
3710
|
+
if (typeof window === "undefined") return [];
|
|
3711
|
+
const collected = [];
|
|
3712
|
+
const api = {
|
|
3713
|
+
register(...wallets) {
|
|
3714
|
+
collected.push(...wallets);
|
|
3715
|
+
return () => {
|
|
3716
|
+
};
|
|
3717
|
+
}
|
|
3718
|
+
};
|
|
3719
|
+
try {
|
|
3720
|
+
window.dispatchEvent(
|
|
3721
|
+
Object.assign(
|
|
3722
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
3723
|
+
{
|
|
3724
|
+
detail: api
|
|
3725
|
+
}
|
|
3726
|
+
)
|
|
3727
|
+
);
|
|
3728
|
+
} catch {
|
|
3729
|
+
}
|
|
3730
|
+
return collected;
|
|
3731
|
+
}
|
|
3732
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
3733
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
3734
|
+
const provider = {
|
|
3735
|
+
get isConnected() {
|
|
3736
|
+
return !!currentAccount;
|
|
3737
|
+
},
|
|
3738
|
+
get publicKey() {
|
|
3739
|
+
if (!currentAccount) return void 0;
|
|
3740
|
+
const addr = currentAccount.address;
|
|
3741
|
+
return { toString: () => addr };
|
|
3742
|
+
},
|
|
3743
|
+
async connect() {
|
|
3744
|
+
const feature = wallet.features["standard:connect"];
|
|
3745
|
+
if (!feature?.connect)
|
|
3746
|
+
throw new Error("Wallet Standard connect not available");
|
|
3747
|
+
const result = await feature.connect({ silent: false });
|
|
3748
|
+
currentAccount = result.accounts[0] ?? null;
|
|
3749
|
+
if (!currentAccount)
|
|
3750
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
3751
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
3752
|
+
},
|
|
3753
|
+
async disconnect() {
|
|
3754
|
+
const feature = wallet.features["standard:disconnect"];
|
|
3755
|
+
await feature?.disconnect?.();
|
|
3756
|
+
currentAccount = null;
|
|
3757
|
+
},
|
|
3758
|
+
async signAndSendTransaction(transaction, options) {
|
|
3759
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
3760
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
3761
|
+
throw new Error("signAndSendTransaction not available");
|
|
3762
|
+
}
|
|
3763
|
+
const txBytes = transaction.serialize();
|
|
3764
|
+
const results = await feature.signAndSendTransaction({
|
|
3765
|
+
account: currentAccount,
|
|
3766
|
+
transaction: txBytes,
|
|
3767
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
3768
|
+
options
|
|
3769
|
+
});
|
|
3770
|
+
const sig = results[0]?.signature;
|
|
3771
|
+
if (!sig) throw new Error("No signature returned");
|
|
3772
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
3773
|
+
},
|
|
3774
|
+
async signTransaction(transaction) {
|
|
3775
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
3776
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
3777
|
+
throw new Error("signTransaction not available");
|
|
3778
|
+
}
|
|
3779
|
+
const txBytes = transaction.serialize();
|
|
3780
|
+
const results = await feature.signTransaction({
|
|
3781
|
+
account: currentAccount,
|
|
3782
|
+
transaction: txBytes,
|
|
3783
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
3784
|
+
});
|
|
3785
|
+
const signed = results[0]?.signedTransaction;
|
|
3786
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
3787
|
+
return { serialize: () => signed };
|
|
3788
|
+
},
|
|
3789
|
+
on() {
|
|
3790
|
+
},
|
|
3791
|
+
off() {
|
|
3792
|
+
},
|
|
3793
|
+
removeListener() {
|
|
3794
|
+
}
|
|
3795
|
+
};
|
|
3796
|
+
return provider;
|
|
3797
|
+
}
|
|
3798
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
3799
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
3800
|
+
if (!meta) return [];
|
|
3801
|
+
const standardWallets = collectWalletStandardWallets();
|
|
3802
|
+
const mmWallet = standardWallets.find(
|
|
3803
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
3804
|
+
);
|
|
3805
|
+
if (!mmWallet) return [];
|
|
3806
|
+
return [
|
|
3807
|
+
{
|
|
3808
|
+
meta,
|
|
3809
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
3810
|
+
via: "solana-window"
|
|
3811
|
+
}
|
|
3812
|
+
];
|
|
3813
|
+
}
|
|
3676
3814
|
function getPublicKeyString(provider) {
|
|
3677
3815
|
const publicKey = provider?.publicKey;
|
|
3678
3816
|
if (!publicKey) return null;
|
|
@@ -3734,12 +3872,13 @@ function getSolanaProviders() {
|
|
|
3734
3872
|
}
|
|
3735
3873
|
function detectSolanaWallets(wallets) {
|
|
3736
3874
|
const providers = getSolanaProviders();
|
|
3737
|
-
|
|
3875
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
3738
3876
|
const provider = providers[walletId];
|
|
3739
3877
|
const meta = wallets.find((item) => item.id === walletId);
|
|
3740
3878
|
if (!provider || !meta) return [];
|
|
3741
3879
|
return [{ meta, provider, via: "solana-window" }];
|
|
3742
3880
|
});
|
|
3881
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
3743
3882
|
}
|
|
3744
3883
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
3745
3884
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -3804,7 +3943,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
3804
3943
|
}
|
|
3805
3944
|
};
|
|
3806
3945
|
}
|
|
3807
|
-
var SOLANA_WALLET_IDS;
|
|
3946
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
3808
3947
|
var init_solana = __esm({
|
|
3809
3948
|
"src/wallets/solana.ts"() {
|
|
3810
3949
|
"use strict";
|
|
@@ -3814,6 +3953,8 @@ var init_solana = __esm({
|
|
|
3814
3953
|
"solflare",
|
|
3815
3954
|
"backpack"
|
|
3816
3955
|
];
|
|
3956
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
3957
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3817
3958
|
}
|
|
3818
3959
|
});
|
|
3819
3960
|
|