@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.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { s as SolanaProviderLike, U as WalletMeta, f as DetectedWallet, M as WalletId, t as SolanaWalletInterface } from './manager-
|
|
2
|
-
export { W as WagmiBridge, C as WagmiConnector, V as WalletSnapshot, a4 as useWalletConnectConnect, a5 as useWalletExternalDisconnect, a6 as useWalletInfo, a7 as useWireDetectionIntoManager, a8 as walletManager } from './manager-
|
|
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 { s as SolanaProviderLike, U as WalletMeta, f as DetectedWallet, M as WalletId, t as SolanaWalletInterface } from './manager-DHCXknCG.cjs';
|
|
2
|
+
export { W as WagmiBridge, C as WagmiConnector, V as WalletSnapshot, a4 as useWalletConnectConnect, a5 as useWalletExternalDisconnect, a6 as useWalletInfo, a7 as useWireDetectionIntoManager, a8 as walletManager } from './manager-DHCXknCG.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-CWNTV5Wq.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 { s as SolanaProviderLike, U as WalletMeta, f as DetectedWallet, M as WalletId, t as SolanaWalletInterface } from './manager-
|
|
2
|
-
export { W as WagmiBridge, C as WagmiConnector, V as WalletSnapshot, a4 as useWalletConnectConnect, a5 as useWalletExternalDisconnect, a6 as useWalletInfo, a7 as useWireDetectionIntoManager, a8 as walletManager } from './manager-
|
|
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 { s as SolanaProviderLike, U as WalletMeta, f as DetectedWallet, M as WalletId, t as SolanaWalletInterface } from './manager-Dtmjibzl.js';
|
|
2
|
+
export { W as WagmiBridge, C as WagmiConnector, V as WalletSnapshot, a4 as useWalletConnectConnect, a5 as useWalletExternalDisconnect, a6 as useWalletInfo, a7 as useWireDetectionIntoManager, a8 as walletManager } from './manager-Dtmjibzl.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-CaQQECVe.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.6";
|
|
228
228
|
API_ROOT = "https://bv-staging-api.trustware.io";
|
|
229
229
|
API_PREFIX = "/api";
|
|
230
230
|
WALLETCONNECT_PROJECT_ID = "72ea74c400f5111d43aea638d7d83a24";
|
|
@@ -1372,6 +1372,7 @@ var init_metadata = __esm({
|
|
|
1372
1372
|
"rainbow",
|
|
1373
1373
|
"phantom-evm",
|
|
1374
1374
|
"phantom-solana",
|
|
1375
|
+
"metamask-solana",
|
|
1375
1376
|
"solflare",
|
|
1376
1377
|
"okx",
|
|
1377
1378
|
"brave",
|
|
@@ -1451,6 +1452,15 @@ var init_metadata = __esm({
|
|
|
1451
1452
|
ios: "https://apps.apple.com/app/phantom-crypto-wallet/id1598432977",
|
|
1452
1453
|
deepLink: (url) => `phantom://browse/${encodeURIComponent(url)}`
|
|
1453
1454
|
},
|
|
1455
|
+
{
|
|
1456
|
+
id: "metamask-solana",
|
|
1457
|
+
name: "MetaMask (Solana)",
|
|
1458
|
+
category: "injected",
|
|
1459
|
+
ecosystem: "solana",
|
|
1460
|
+
logo: `${ASSETS_BASE_URL}/assets/wallets/metamask.svg`,
|
|
1461
|
+
emoji: "\u{1F98A}",
|
|
1462
|
+
homepage: "https://metamask.io/"
|
|
1463
|
+
},
|
|
1454
1464
|
{
|
|
1455
1465
|
id: "solflare",
|
|
1456
1466
|
name: "Solflare",
|
|
@@ -3647,6 +3657,134 @@ var init_sdkRpc = __esm({
|
|
|
3647
3657
|
});
|
|
3648
3658
|
|
|
3649
3659
|
// src/wallets/solana.ts
|
|
3660
|
+
function encodeBase58(bytes) {
|
|
3661
|
+
const digits = [0];
|
|
3662
|
+
for (const byte of bytes) {
|
|
3663
|
+
let carry = byte;
|
|
3664
|
+
for (let i = 0; i < digits.length; i++) {
|
|
3665
|
+
carry += digits[i] << 8;
|
|
3666
|
+
digits[i] = carry % 58;
|
|
3667
|
+
carry = carry / 58 | 0;
|
|
3668
|
+
}
|
|
3669
|
+
while (carry > 0) {
|
|
3670
|
+
digits.push(carry % 58);
|
|
3671
|
+
carry = carry / 58 | 0;
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
let result = "";
|
|
3675
|
+
for (let i = 0; i < bytes.length && bytes[i] === 0; i++) {
|
|
3676
|
+
result += "1";
|
|
3677
|
+
}
|
|
3678
|
+
for (let i = digits.length - 1; i >= 0; i--) {
|
|
3679
|
+
result += BASE58_ALPHABET[digits[i]];
|
|
3680
|
+
}
|
|
3681
|
+
return result;
|
|
3682
|
+
}
|
|
3683
|
+
function collectWalletStandardWallets() {
|
|
3684
|
+
if (typeof window === "undefined") return [];
|
|
3685
|
+
const collected = [];
|
|
3686
|
+
const api = {
|
|
3687
|
+
register(...wallets) {
|
|
3688
|
+
collected.push(...wallets);
|
|
3689
|
+
return () => {
|
|
3690
|
+
};
|
|
3691
|
+
}
|
|
3692
|
+
};
|
|
3693
|
+
try {
|
|
3694
|
+
window.dispatchEvent(
|
|
3695
|
+
Object.assign(
|
|
3696
|
+
new Event("wallet-standard:app-ready", { bubbles: false }),
|
|
3697
|
+
{
|
|
3698
|
+
detail: api
|
|
3699
|
+
}
|
|
3700
|
+
)
|
|
3701
|
+
);
|
|
3702
|
+
} catch {
|
|
3703
|
+
}
|
|
3704
|
+
return collected;
|
|
3705
|
+
}
|
|
3706
|
+
function walletStandardToSolanaProvider(wallet) {
|
|
3707
|
+
let currentAccount = wallet.accounts[0] ?? null;
|
|
3708
|
+
const provider = {
|
|
3709
|
+
get isConnected() {
|
|
3710
|
+
return !!currentAccount;
|
|
3711
|
+
},
|
|
3712
|
+
get publicKey() {
|
|
3713
|
+
if (!currentAccount) return void 0;
|
|
3714
|
+
const addr = currentAccount.address;
|
|
3715
|
+
return { toString: () => addr };
|
|
3716
|
+
},
|
|
3717
|
+
async connect() {
|
|
3718
|
+
const feature = wallet.features["standard:connect"];
|
|
3719
|
+
if (!feature?.connect)
|
|
3720
|
+
throw new Error("Wallet Standard connect not available");
|
|
3721
|
+
const result = await feature.connect({ silent: false });
|
|
3722
|
+
currentAccount = result.accounts[0] ?? null;
|
|
3723
|
+
if (!currentAccount)
|
|
3724
|
+
throw new Error("No Solana account returned from MetaMask");
|
|
3725
|
+
return { publicKey: { toString: () => currentAccount.address } };
|
|
3726
|
+
},
|
|
3727
|
+
async disconnect() {
|
|
3728
|
+
const feature = wallet.features["standard:disconnect"];
|
|
3729
|
+
await feature?.disconnect?.();
|
|
3730
|
+
currentAccount = null;
|
|
3731
|
+
},
|
|
3732
|
+
async signAndSendTransaction(transaction, options) {
|
|
3733
|
+
const feature = wallet.features["solana:signAndSendTransaction"];
|
|
3734
|
+
if (!feature?.signAndSendTransaction || !currentAccount) {
|
|
3735
|
+
throw new Error("signAndSendTransaction not available");
|
|
3736
|
+
}
|
|
3737
|
+
const txBytes = transaction.serialize();
|
|
3738
|
+
const results = await feature.signAndSendTransaction({
|
|
3739
|
+
account: currentAccount,
|
|
3740
|
+
transaction: txBytes,
|
|
3741
|
+
chain: SOLANA_MAINNET_CHAIN,
|
|
3742
|
+
options
|
|
3743
|
+
});
|
|
3744
|
+
const sig = results[0]?.signature;
|
|
3745
|
+
if (!sig) throw new Error("No signature returned");
|
|
3746
|
+
return typeof sig === "string" ? sig : encodeBase58(sig);
|
|
3747
|
+
},
|
|
3748
|
+
async signTransaction(transaction) {
|
|
3749
|
+
const feature = wallet.features["solana:signTransaction"];
|
|
3750
|
+
if (!feature?.signTransaction || !currentAccount) {
|
|
3751
|
+
throw new Error("signTransaction not available");
|
|
3752
|
+
}
|
|
3753
|
+
const txBytes = transaction.serialize();
|
|
3754
|
+
const results = await feature.signTransaction({
|
|
3755
|
+
account: currentAccount,
|
|
3756
|
+
transaction: txBytes,
|
|
3757
|
+
chain: SOLANA_MAINNET_CHAIN
|
|
3758
|
+
});
|
|
3759
|
+
const signed = results[0]?.signedTransaction;
|
|
3760
|
+
if (!signed) throw new Error("No signed transaction returned");
|
|
3761
|
+
return { serialize: () => signed };
|
|
3762
|
+
},
|
|
3763
|
+
on() {
|
|
3764
|
+
},
|
|
3765
|
+
off() {
|
|
3766
|
+
},
|
|
3767
|
+
removeListener() {
|
|
3768
|
+
}
|
|
3769
|
+
};
|
|
3770
|
+
return provider;
|
|
3771
|
+
}
|
|
3772
|
+
function detectMetaMaskSolanaWallet(wallets) {
|
|
3773
|
+
const meta = wallets.find((w) => w.id === "metamask-solana");
|
|
3774
|
+
if (!meta) return [];
|
|
3775
|
+
const standardWallets = collectWalletStandardWallets();
|
|
3776
|
+
const mmWallet = standardWallets.find(
|
|
3777
|
+
(w) => w.name.toLowerCase().includes("metamask") && w.chains.some((c) => c.startsWith("solana:"))
|
|
3778
|
+
);
|
|
3779
|
+
if (!mmWallet) return [];
|
|
3780
|
+
return [
|
|
3781
|
+
{
|
|
3782
|
+
meta,
|
|
3783
|
+
provider: walletStandardToSolanaProvider(mmWallet),
|
|
3784
|
+
via: "solana-window"
|
|
3785
|
+
}
|
|
3786
|
+
];
|
|
3787
|
+
}
|
|
3650
3788
|
function getPublicKeyString(provider) {
|
|
3651
3789
|
const publicKey = provider?.publicKey;
|
|
3652
3790
|
if (!publicKey) return null;
|
|
@@ -3708,12 +3846,13 @@ function getSolanaProviders() {
|
|
|
3708
3846
|
}
|
|
3709
3847
|
function detectSolanaWallets(wallets) {
|
|
3710
3848
|
const providers = getSolanaProviders();
|
|
3711
|
-
|
|
3849
|
+
const windowDetected = SOLANA_WALLET_IDS.flatMap((walletId) => {
|
|
3712
3850
|
const provider = providers[walletId];
|
|
3713
3851
|
const meta = wallets.find((item) => item.id === walletId);
|
|
3714
3852
|
if (!provider || !meta) return [];
|
|
3715
3853
|
return [{ meta, provider, via: "solana-window" }];
|
|
3716
3854
|
});
|
|
3855
|
+
return [...windowDetected, ...detectMetaMaskSolanaWallet(wallets)];
|
|
3717
3856
|
}
|
|
3718
3857
|
function bindSolanaProviderEvents(provider, handlers) {
|
|
3719
3858
|
const onConnect = () => handlers.onConnect?.();
|
|
@@ -3778,7 +3917,7 @@ function toSolanaWalletInterface(provider) {
|
|
|
3778
3917
|
}
|
|
3779
3918
|
};
|
|
3780
3919
|
}
|
|
3781
|
-
var SOLANA_WALLET_IDS;
|
|
3920
|
+
var SOLANA_WALLET_IDS, SOLANA_MAINNET_CHAIN, BASE58_ALPHABET;
|
|
3782
3921
|
var init_solana = __esm({
|
|
3783
3922
|
"src/wallets/solana.ts"() {
|
|
3784
3923
|
"use strict";
|
|
@@ -3788,6 +3927,8 @@ var init_solana = __esm({
|
|
|
3788
3927
|
"solflare",
|
|
3789
3928
|
"backpack"
|
|
3790
3929
|
];
|
|
3930
|
+
SOLANA_MAINNET_CHAIN = "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp";
|
|
3931
|
+
BASE58_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
3791
3932
|
}
|
|
3792
3933
|
});
|
|
3793
3934
|
|