New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solana/wallet-standard-wallet-adapter-base

Package Overview
Dependencies
Maintainers
15
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/wallet-standard-wallet-adapter-base - npm Package Compare versions

Comparing version 1.0.0-rc.1 to 1.0.0-rc.4

101

lib/cjs/adapter.js

@@ -40,5 +40,5 @@ "use strict";

const wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
const wallet_standard_util_1 = require("@solana/wallet-standard-util");
const web3_js_1 = require("@solana/web3.js");
const wallet_standard_util_1 = require("@solana/wallet-standard-util");
const util_1 = require("@wallet-standard/util");
const wallet_1 = require("@wallet-standard/wallet");
const bs58_1 = __importDefault(require("bs58"));

@@ -50,3 +50,3 @@ const transaction_js_1 = require("./transaction.js");

'standard:events' in wallet.features &&
'solana:signAndSendTransaction' in wallet.features);
('solana:signAndSendTransaction' in wallet.features || 'solana:signTransaction' in wallet.features));
}

@@ -99,4 +99,6 @@ exports.isWalletAdapterCompatibleWallet = isWalletAdapterCompatibleWallet;

__classPrivateFieldSet(this, _StandardWalletAdapter_wallet, wallet, "f");
const supportedTransactionVersions = wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions;
__classPrivateFieldSet(this, _StandardWalletAdapter_supportedTransactionVersions, (0, util_1.arraysEqual)(supportedTransactionVersions, ['legacy'])
const supportedTransactionVersions = 'solana:signAndSendTransaction' in wallet.features
? wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions
: wallet.features['solana:signTransaction'].supportedTransactionVersions;
__classPrivateFieldSet(this, _StandardWalletAdapter_supportedTransactionVersions, (0, wallet_1.arraysEqual)(supportedTransactionVersions, ['legacy'])
? null

@@ -192,6 +194,28 @@ : new Set(supportedTransactionVersions), "f");

try {
if (!__classPrivateFieldGet(this, _StandardWalletAdapter_account, "f"))
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new wallet_adapter_base_1.WalletNotConnectedError();
let feature;
if ('solana:signAndSendTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features) {
if (account.features.includes('solana:signAndSendTransaction')) {
feature = 'solana:signAndSendTransaction';
}
else if ('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features &&
account.features.includes('solana:signTransaction')) {
feature = 'solana:signTransaction';
}
else {
throw new wallet_adapter_base_1.WalletAccountError();
}
}
else if ('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features) {
if (!account.features.includes('solana:signTransaction'))
throw new wallet_adapter_base_1.WalletAccountError();
feature = 'solana:signTransaction';
}
else {
throw new wallet_adapter_base_1.WalletConfigError();
}
const chain = (0, wallet_standard_util_1.getChainForEndpoint)(connection.rpcEndpoint);
if (!__classPrivateFieldGet(this, _StandardWalletAdapter_account, "f").chains.includes(chain))
if (!account.chains.includes(chain))
throw new wallet_adapter_base_1.WalletSendTransactionError();

@@ -213,15 +237,30 @@ try {

}
const signatures = yield __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signAndSendTransaction'].signAndSendTransaction({
account: __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f"),
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: (0, wallet_standard_util_1.getCommitment)(sendOptions.preflightCommitment || connection.commitment),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58_1.default.encode(signatures[0].signature);
if (feature === 'solana:signAndSendTransaction') {
const [output] = yield __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signAndSendTransaction'].signAndSendTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: (0, wallet_standard_util_1.getCommitment)(sendOptions.preflightCommitment || connection.commitment),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58_1.default.encode(output.signature);
}
else {
const [output] = yield __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signTransaction'].signTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: (0, wallet_standard_util_1.getCommitment)(sendOptions.preflightCommitment || connection.commitment),
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return yield connection.sendRawTransaction(output.signedTransaction, Object.assign(Object.assign({}, sendOptions), { preflightCommitment: (0, wallet_standard_util_1.getCommitment)(sendOptions.preflightCommitment || connection.commitment) }));
}
}

@@ -269,7 +308,9 @@ catch (error) {

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new wallet_adapter_base_1.WalletNotConnectedError();
if (!('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new wallet_adapter_base_1.WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!(account === null || account === void 0 ? void 0 : account.features.includes('solana:signTransaction')))
throw new wallet_adapter_base_1.WalletSignTransactionError();
if (!account.features.includes('solana:signTransaction'))
throw new wallet_adapter_base_1.WalletAccountError();
try {

@@ -292,2 +333,4 @@ const signedTransactions = yield __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signTransaction'].signTransaction({

catch (error) {
if (error instanceof wallet_adapter_base_1.WalletError)
throw error;
throw new wallet_adapter_base_1.WalletSignTransactionError(error === null || error === void 0 ? void 0 : error.message, error);

@@ -304,6 +347,8 @@ }

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new wallet_adapter_base_1.WalletNotConnectedError();
if (!('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new wallet_adapter_base_1.WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!(account === null || account === void 0 ? void 0 : account.features.includes('solana:signTransaction')))
if (!account.features.includes('solana:signTransaction'))
throw new wallet_adapter_base_1.WalletSignTransactionError();

@@ -340,6 +385,8 @@ try {

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new wallet_adapter_base_1.WalletNotConnectedError();
if (!('standard:signMessage' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new wallet_adapter_base_1.WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!(account === null || account === void 0 ? void 0 : account.features.includes('standard:signMessage')))
if (!account.features.includes('standard:signMessage'))
throw new wallet_adapter_base_1.WalletSignMessageError();

@@ -346,0 +393,0 @@ try {

@@ -29,11 +29,11 @@ "use strict";

const wallet_adapter_base_1 = require("@solana/wallet-adapter-base");
const wallet_standard_chains_1 = require("@solana/wallet-standard-chains");
const wallet_standard_util_1 = require("@solana/wallet-standard-util");
const web3_js_1 = require("@solana/web3.js");
const app_1 = require("@wallet-standard/app");
const wallet_standard_chains_1 = require("@solana/wallet-standard-chains");
const wallet_standard_util_1 = require("@solana/wallet-standard-util");
const util_1 = require("@wallet-standard/util");
const wallet_1 = require("@wallet-standard/wallet");
const bs58_1 = __importDefault(require("bs58"));
const transaction_js_1 = require("./transaction.js");
/** TODO: docs */
class SolanaWalletAdapterWalletAccount extends util_1.ReadonlyWalletAccount {
class SolanaWalletAdapterWalletAccount extends wallet_1.ReadonlyWalletAccount {
constructor({ adapter, address, publicKey, chains, }) {

@@ -272,3 +272,3 @@ const features = ['solana:signAndSendTransaction'];

account.chains.includes(__classPrivateFieldGet(this, _SolanaWalletAdapterWallet_chain, "f")) ||
!(0, util_1.bytesEqual)(account.publicKey, publicKey)) {
!(0, wallet_1.bytesEqual)(account.publicKey, publicKey)) {
__classPrivateFieldSet(this, _SolanaWalletAdapterWallet_account, new SolanaWalletAdapterWalletAccount({

@@ -299,3 +299,3 @@ adapter: __classPrivateFieldGet(this, _SolanaWalletAdapterWallet_adapter, "f"),

throw new Error('unsupported transaction version');
if (transaction.version === 'legacy' && (0, util_1.arraysEqual)(__classPrivateFieldGet(this, _SolanaWalletAdapterWallet_supportedTransactionVersions, "f"), ['legacy']))
if (transaction.version === 'legacy' && (0, wallet_1.arraysEqual)(__classPrivateFieldGet(this, _SolanaWalletAdapterWallet_supportedTransactionVersions, "f"), ['legacy']))
return web3_js_1.Transaction.from(serializedTransaction);

@@ -306,3 +306,3 @@ return transaction;

function registerWalletAdapter(adapter, chain, endpoint, match = (wallet) => wallet.name === adapter.name) {
const { register, get, on } = (0, app_1.initialize)();
const { register, get, on } = (0, app_1.initializeWindowNavigatorWallets)();
const destructors = [];

@@ -309,0 +309,0 @@ function destroy() {

@@ -14,5 +14,5 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

import { BaseWalletAdapter, WalletAccountError, WalletConfigError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base';
import { getChainForEndpoint, getCommitment } from '@solana/wallet-standard-util';
import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
import { getChainForEndpoint, getCommitment } from '@solana/wallet-standard-util';
import { arraysEqual } from '@wallet-standard/util';
import { arraysEqual } from '@wallet-standard/wallet';
import bs58 from 'bs58';

@@ -24,3 +24,3 @@ import { isVersionedTransaction } from './transaction.js';

'standard:events' in wallet.features &&
'solana:signAndSendTransaction' in wallet.features);
('solana:signAndSendTransaction' in wallet.features || 'solana:signTransaction' in wallet.features));
}

@@ -72,3 +72,5 @@ /** TODO: docs */

__classPrivateFieldSet(this, _StandardWalletAdapter_wallet, wallet, "f");
const supportedTransactionVersions = wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions;
const supportedTransactionVersions = 'solana:signAndSendTransaction' in wallet.features
? wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions
: wallet.features['solana:signTransaction'].supportedTransactionVersions;
__classPrivateFieldSet(this, _StandardWalletAdapter_supportedTransactionVersions, arraysEqual(supportedTransactionVersions, ['legacy'])

@@ -160,6 +162,28 @@ ? null

try {
if (!__classPrivateFieldGet(this, _StandardWalletAdapter_account, "f"))
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new WalletNotConnectedError();
let feature;
if ('solana:signAndSendTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features) {
if (account.features.includes('solana:signAndSendTransaction')) {
feature = 'solana:signAndSendTransaction';
}
else if ('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features &&
account.features.includes('solana:signTransaction')) {
feature = 'solana:signTransaction';
}
else {
throw new WalletAccountError();
}
}
else if ('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features) {
if (!account.features.includes('solana:signTransaction'))
throw new WalletAccountError();
feature = 'solana:signTransaction';
}
else {
throw new WalletConfigError();
}
const chain = getChainForEndpoint(connection.rpcEndpoint);
if (!__classPrivateFieldGet(this, _StandardWalletAdapter_account, "f").chains.includes(chain))
if (!account.chains.includes(chain))
throw new WalletSendTransactionError();

@@ -181,15 +205,33 @@ try {

}
const signatures = await __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signAndSendTransaction'].signAndSendTransaction({
account: __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f"),
chain,
transaction: serializedTransaction,
options: {
if (feature === 'solana:signAndSendTransaction') {
const [output] = await __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signAndSendTransaction'].signAndSendTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: getCommitment(sendOptions.preflightCommitment || connection.commitment),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58.encode(output.signature);
}
else {
const [output] = await __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signTransaction'].signTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: getCommitment(sendOptions.preflightCommitment || connection.commitment),
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return await connection.sendRawTransaction(output.signedTransaction, {
...sendOptions,
preflightCommitment: getCommitment(sendOptions.preflightCommitment || connection.commitment),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58.encode(signatures[0].signature);
});
}
}

@@ -234,7 +276,9 @@ catch (error) {

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new WalletNotConnectedError();
if (!('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account?.features.includes('solana:signTransaction'))
throw new WalletSignTransactionError();
if (!account.features.includes('solana:signTransaction'))
throw new WalletAccountError();
try {

@@ -257,2 +301,4 @@ const signedTransactions = await __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features['solana:signTransaction'].signTransaction({

catch (error) {
if (error instanceof WalletError)
throw error;
throw new WalletSignTransactionError(error?.message, error);

@@ -267,6 +313,8 @@ }

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new WalletNotConnectedError();
if (!('solana:signTransaction' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account?.features.includes('solana:signTransaction'))
if (!account.features.includes('solana:signTransaction'))
throw new WalletSignTransactionError();

@@ -301,6 +349,8 @@ try {

try {
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account)
throw new WalletNotConnectedError();
if (!('standard:signMessage' in __classPrivateFieldGet(this, _StandardWalletAdapter_wallet, "f").features))
throw new WalletConfigError();
const account = __classPrivateFieldGet(this, _StandardWalletAdapter_account, "f");
if (!account?.features.includes('standard:signMessage'))
if (!account.features.includes('standard:signMessage'))
throw new WalletSignMessageError();

@@ -307,0 +357,0 @@ try {

@@ -14,7 +14,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

import { WalletReadyState } from '@solana/wallet-adapter-base';
import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
import { initialize } from '@wallet-standard/app';
import { isSolanaChain } from '@solana/wallet-standard-chains';
import { getEndpointForChain } from '@solana/wallet-standard-util';
import { arraysEqual, bytesEqual, ReadonlyWalletAccount } from '@wallet-standard/util';
import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
import { initializeWindowNavigatorWallets } from '@wallet-standard/app';
import { arraysEqual, bytesEqual, ReadonlyWalletAccount } from '@wallet-standard/wallet';
import bs58 from 'bs58';

@@ -286,3 +286,3 @@ import { isVersionedTransaction } from './transaction.js';

export function registerWalletAdapter(adapter, chain, endpoint, match = (wallet) => wallet.name === adapter.name) {
const { register, get, on } = initialize();
const { register, get, on } = initializeWindowNavigatorWallets();
const destructors = [];

@@ -289,0 +289,0 @@ function destroy() {

import type { SendTransactionOptions, SupportedTransactionVersions, WalletAdapter, WalletName } from '@solana/wallet-adapter-base';
import { BaseWalletAdapter, WalletReadyState } from '@solana/wallet-adapter-base';
import type { SolanaSignAndSendTransactionFeature, SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
import type { Wallet, WalletWithFeatures } from '@wallet-standard/base';
import type { ConnectFeature, DisconnectFeature, EventsFeature, SignMessageFeature } from '@wallet-standard/features';
import type { SolanaSignAndSendTransactionFeature, SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Wallet, WalletWithFeatures } from '@wallet-standard/base';
/** TODO: docs */
export declare type WalletAdapterCompatibleWallet = WalletWithFeatures<ConnectFeature & DisconnectFeature & EventsFeature & SolanaSignAndSendTransactionFeature & (SolanaSignTransactionFeature | SignMessageFeature)>;
export declare type WalletAdapterCompatibleWallet = WalletWithFeatures<ConnectFeature & EventsFeature & (SolanaSignAndSendTransactionFeature | SolanaSignTransactionFeature) & (DisconnectFeature | SignMessageFeature | never)>;
/** TODO: docs */

@@ -11,0 +11,0 @@ export declare function isWalletAdapterCompatibleWallet(wallet: Wallet): wallet is WalletAdapterCompatibleWallet;

import type { Adapter } from '@solana/wallet-adapter-base';
import type { ConnectFeature, DisconnectFeature, SignMessageFeature } from '@wallet-standard/features';
import type { SolanaChain } from '@solana/wallet-standard-chains';
import type { SolanaSignAndSendTransactionFeature, SolanaSignTransactionFeature } from '@solana/wallet-standard-features';
import type { Wallet } from '@wallet-standard/base';
import { ReadonlyWalletAccount } from '@wallet-standard/util';
import type { ConnectFeature, DisconnectFeature, SignMessageFeature } from '@wallet-standard/features';
import { ReadonlyWalletAccount } from '@wallet-standard/wallet';
/** TODO: docs */

@@ -8,0 +8,0 @@ export declare class SolanaWalletAdapterWalletAccount extends ReadonlyWalletAccount {

{
"name": "@solana/wallet-standard-wallet-adapter-base",
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.4",
"author": "Solana Maintainers <maintainers@solana.foundation>",
"repository": "https://github.com/solana-labs/wallet-standard",
"license": "Apache-2.0",
"engines": {
"node": ">=14"
},
"type": "module",

@@ -31,9 +34,9 @@ "sideEffects": false,

"@solana/wallet-adapter-base": "^0.9.17",
"@solana/wallet-standard-chains": "^1.0.0-rc.0",
"@solana/wallet-standard-features": "^1.0.0-rc.0",
"@solana/wallet-standard-util": "^1.0.0-rc.1",
"@wallet-standard/app": "^1.0.0-rc.0",
"@wallet-standard/base": "^1.0.0-rc.0",
"@wallet-standard/features": "^1.0.0-rc.0",
"@wallet-standard/util": "^1.0.0-rc.0"
"@solana/wallet-standard-chains": "1.0.0-rc.4",
"@solana/wallet-standard-features": "1.0.0-rc.4",
"@solana/wallet-standard-util": "1.0.0-rc.4",
"@wallet-standard/app": "^1.0.0-rc.1",
"@wallet-standard/base": "^1.0.0-rc.1",
"@wallet-standard/features": "^1.0.0-rc.1",
"@wallet-standard/wallet": "^1.0.0-rc.1"
},

@@ -40,0 +43,0 @@ "devDependencies": {

@@ -23,4 +23,10 @@ import type {

} from '@solana/wallet-adapter-base';
import type {
SolanaSignAndSendTransactionFeature,
SolanaSignTransactionFeature,
} from '@solana/wallet-standard-features';
import { getChainForEndpoint, getCommitment } from '@solana/wallet-standard-util';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import { PublicKey, Transaction, VersionedTransaction } from '@solana/web3.js';
import type { Wallet, WalletAccount, WalletWithFeatures } from '@wallet-standard/base';
import type {

@@ -33,9 +39,3 @@ ConnectFeature,

} from '@wallet-standard/features';
import type {
SolanaSignAndSendTransactionFeature,
SolanaSignTransactionFeature,
} from '@solana/wallet-standard-features';
import { getChainForEndpoint, getCommitment } from '@solana/wallet-standard-util';
import type { Wallet, WalletAccount, WalletWithFeatures } from '@wallet-standard/base';
import { arraysEqual } from '@wallet-standard/util';
import { arraysEqual } from '@wallet-standard/wallet';
import bs58 from 'bs58';

@@ -47,6 +47,5 @@ import { isVersionedTransaction } from './transaction.js';

ConnectFeature &
DisconnectFeature &
EventsFeature &
SolanaSignAndSendTransactionFeature &
(SolanaSignTransactionFeature | SignMessageFeature)
(SolanaSignAndSendTransactionFeature | SolanaSignTransactionFeature) &
(DisconnectFeature | SignMessageFeature | never)
>;

@@ -59,3 +58,3 @@

'standard:events' in wallet.features &&
'solana:signAndSendTransaction' in wallet.features
('solana:signAndSendTransaction' in wallet.features || 'solana:signTransaction' in wallet.features)
);

@@ -129,3 +128,5 @@ }

const supportedTransactionVersions =
wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions;
'solana:signAndSendTransaction' in wallet.features
? wallet.features['solana:signAndSendTransaction'].supportedTransactionVersions
: wallet.features['solana:signTransaction'].supportedTransactionVersions;
this.#supportedTransactionVersions = arraysEqual(supportedTransactionVersions, ['legacy'])

@@ -259,6 +260,26 @@ ? null

try {
if (!this.#account) throw new WalletNotConnectedError();
const account = this.#account;
if (!account) throw new WalletNotConnectedError();
let feature: 'solana:signAndSendTransaction' | 'solana:signTransaction';
if ('solana:signAndSendTransaction' in this.#wallet.features) {
if (account.features.includes('solana:signAndSendTransaction')) {
feature = 'solana:signAndSendTransaction';
} else if (
'solana:signTransaction' in this.#wallet.features &&
account.features.includes('solana:signTransaction')
) {
feature = 'solana:signTransaction';
} else {
throw new WalletAccountError();
}
} else if ('solana:signTransaction' in this.#wallet.features) {
if (!account.features.includes('solana:signTransaction')) throw new WalletAccountError();
feature = 'solana:signTransaction';
} else {
throw new WalletConfigError();
}
const chain = getChainForEndpoint(connection.rpcEndpoint);
if (!this.#account.chains.includes(chain)) throw new WalletSendTransactionError();
if (!account.chains.includes(chain)) throw new WalletSendTransactionError();

@@ -283,16 +304,42 @@ try {

const signatures = await this.#wallet.features['solana:signAndSendTransaction'].signAndSendTransaction({
account: this.#account,
chain,
transaction: serializedTransaction,
options: {
if (feature === 'solana:signAndSendTransaction') {
const [output] = await (this.#wallet.features as SolanaSignAndSendTransactionFeature)[
'solana:signAndSendTransaction'
].signAndSendTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: getCommitment(
sendOptions.preflightCommitment || connection.commitment
),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58.encode(output!.signature);
} else {
const [output] = await (this.#wallet.features as SolanaSignTransactionFeature)[
'solana:signTransaction'
].signTransaction({
account,
chain,
transaction: serializedTransaction,
options: {
preflightCommitment: getCommitment(
sendOptions.preflightCommitment || connection.commitment
),
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return await connection.sendRawTransaction(output!.signedTransaction, {
...sendOptions,
preflightCommitment: getCommitment(sendOptions.preflightCommitment || connection.commitment),
skipPreflight: sendOptions.skipPreflight,
maxRetries: sendOptions.maxRetries,
minContextSlot: sendOptions.minContextSlot,
},
});
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return bs58.encode(signatures[0]!.signature);
});
}
} catch (error: any) {

@@ -311,6 +358,8 @@ if (error instanceof WalletError) throw error;

try {
if (!('solana:signTransaction' in this.#wallet.features)) throw new WalletConfigError();
const account = this.#account;
if (!account?.features.includes('solana:signTransaction')) throw new WalletSignTransactionError();
if (!account) throw new WalletNotConnectedError();
if (!('solana:signTransaction' in this.#wallet.features)) throw new WalletConfigError();
if (!account.features.includes('solana:signTransaction')) throw new WalletAccountError();
try {

@@ -338,2 +387,3 @@ const signedTransactions = await this.#wallet.features['solana:signTransaction'].signTransaction({

} catch (error: any) {
if (error instanceof WalletError) throw error;
throw new WalletSignTransactionError(error?.message, error);

@@ -350,6 +400,8 @@ }

try {
if (!('solana:signTransaction' in this.#wallet.features)) throw new WalletConfigError();
const account = this.#account;
if (!account?.features.includes('solana:signTransaction')) throw new WalletSignTransactionError();
if (!account) throw new WalletNotConnectedError();
if (!('solana:signTransaction' in this.#wallet.features)) throw new WalletConfigError();
if (!account.features.includes('solana:signTransaction')) throw new WalletSignTransactionError();
try {

@@ -392,6 +444,8 @@ const signedTransactions = await this.#wallet.features['solana:signTransaction'].signTransaction(

try {
if (!('standard:signMessage' in this.#wallet.features)) throw new WalletConfigError();
const account = this.#account;
if (!account?.features.includes('standard:signMessage')) throw new WalletSignMessageError();
if (!account) throw new WalletNotConnectedError();
if (!('standard:signMessage' in this.#wallet.features)) throw new WalletConfigError();
if (!account.features.includes('standard:signMessage')) throw new WalletSignMessageError();
try {

@@ -398,0 +452,0 @@ const signedMessages = await this.#wallet.features['standard:signMessage'].signMessage({

import type { Adapter } from '@solana/wallet-adapter-base';
import { WalletReadyState } from '@solana/wallet-adapter-base';
import type { SolanaChain } from '@solana/wallet-standard-chains';
import { isSolanaChain } from '@solana/wallet-standard-chains';
import type {
SolanaSignAndSendTransactionFeature,
SolanaSignAndSendTransactionMethod,
SolanaSignAndSendTransactionOutput,
SolanaSignTransactionFeature,
SolanaSignTransactionMethod,
SolanaSignTransactionOutput,
SolanaTransactionVersion,
} from '@solana/wallet-standard-features';
import { getEndpointForChain } from '@solana/wallet-standard-util';
import { Connection, Transaction, VersionedTransaction } from '@solana/web3.js';
import { initialize } from '@wallet-standard/app';
import { initializeWindowNavigatorWallets } from '@wallet-standard/app';
import type { Wallet, WalletIcon } from '@wallet-standard/base';
import type {

@@ -18,16 +31,3 @@ ConnectFeature,

} from '@wallet-standard/features';
import type { SolanaChain } from '@solana/wallet-standard-chains';
import { isSolanaChain } from '@solana/wallet-standard-chains';
import type {
SolanaSignAndSendTransactionFeature,
SolanaSignAndSendTransactionMethod,
SolanaSignAndSendTransactionOutput,
SolanaSignTransactionFeature,
SolanaSignTransactionMethod,
SolanaSignTransactionOutput,
SolanaTransactionVersion,
} from '@solana/wallet-standard-features';
import { getEndpointForChain } from '@solana/wallet-standard-util';
import type { IconString, Wallet } from '@wallet-standard/base';
import { arraysEqual, bytesEqual, ReadonlyWalletAccount } from '@wallet-standard/util';
import { arraysEqual, bytesEqual, ReadonlyWalletAccount } from '@wallet-standard/wallet';
import bs58 from 'bs58';

@@ -90,3 +90,3 @@ import { isVersionedTransaction } from './transaction.js';

get icon() {
return this.#adapter.icon as IconString;
return this.#adapter.icon as WalletIcon;
}

@@ -376,3 +376,3 @@

): () => void {
const { register, get, on } = initialize();
const { register, get, on } = initializeWindowNavigatorWallets();
const destructors: (() => void)[] = [];

@@ -379,0 +379,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc