Socket
Socket
Sign inDemoInstall

@solana/wallet-adapter-base

Package Overview
Dependencies
Maintainers
14
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 0.9.16 to 0.9.17

57

lib/cjs/signer.js

@@ -31,17 +31,39 @@ "use strict";

try {
try {
const { signers } = options, sendOptions = __rest(options, ["signers"]);
transaction = yield this.prepareTransaction(transaction, connection, sendOptions);
(signers === null || signers === void 0 ? void 0 : signers.length) && transaction.partialSign(...signers);
transaction = yield this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return yield connection.sendRawTransaction(rawTransaction, sendOptions);
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new errors_js_1.WalletSendTransactionError(`Sending versioned transactions isn't supported by this wallet`);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new errors_js_1.WalletSendTransactionError(`Sending transaction version ${version} isn't supported by this wallet`);
try {
transaction = yield this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return yield connection.sendRawTransaction(rawTransaction, options);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof errors_js_1.WalletSignTransactionError) {
emit = false;
throw error;
}
throw new errors_js_1.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
}
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof errors_js_1.WalletSignTransactionError) {
emit = false;
throw error;
else {
try {
const { signers } = options, sendOptions = __rest(options, ["signers"]);
transaction = yield this.prepareTransaction(transaction, connection, sendOptions);
(signers === null || signers === void 0 ? void 0 : signers.length) && transaction.partialSign(...signers);
transaction = yield this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return yield connection.sendRawTransaction(rawTransaction, sendOptions);
}
throw new errors_js_1.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof errors_js_1.WalletSignTransactionError) {
emit = false;
throw error;
}
throw new errors_js_1.WalletSendTransactionError(error === null || error === void 0 ? void 0 : error.message, error);
}
}

@@ -59,2 +81,11 @@ }

return __awaiter(this, void 0, void 0, function* () {
for (const transaction of transactions) {
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new errors_js_1.WalletSignTransactionError(`Signing versioned transactions isn't supported by this wallet`);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new errors_js_1.WalletSignTransactionError(`Signing transaction version ${version} isn't supported by this wallet`);
}
}
const signedTransactions = [];

@@ -61,0 +92,0 @@ for (const transaction of transactions) {

@@ -7,17 +7,39 @@ import { BaseWalletAdapter } from './adapter.js';

try {
try {
const { signers, ...sendOptions } = options;
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
signers?.length && transaction.partialSign(...signers);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, sendOptions);
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new WalletSendTransactionError(`Sending versioned transactions isn't supported by this wallet`);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new WalletSendTransactionError(`Sending transaction version ${version} isn't supported by this wallet`);
try {
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, options);
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
}
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
else {
try {
const { signers, ...sendOptions } = options;
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
signers?.length && transaction.partialSign(...signers);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, sendOptions);
}
throw new WalletSendTransactionError(error?.message, error);
catch (error) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
}

@@ -33,2 +55,11 @@ }

async signAllTransactions(transactions) {
for (const transaction of transactions) {
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new WalletSignTransactionError(`Signing versioned transactions isn't supported by this wallet`);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new WalletSignTransactionError(`Signing transaction version ${version} isn't supported by this wallet`);
}
}
const signedTransactions = [];

@@ -35,0 +66,0 @@ for (const transaction of transactions) {

import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';
import EventEmitter from 'eventemitter3';
import type { WalletError } from './errors.js';
import type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './types.js';
export { EventEmitter };

@@ -25,5 +26,6 @@ export interface WalletAdapterEvents {

connected: boolean;
supportedTransactionVersions: SupportedTransactionVersions;
connect(): Promise<void>;
disconnect(): Promise<void>;
sendTransaction(transaction: Transaction, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
}

@@ -59,4 +61,4 @@ export declare type WalletAdapter<Name extends string = string> = WalletAdapterProps<Name> & EventEmitter<WalletAdapterEvents>;

}
export declare abstract class BaseWalletAdapter extends EventEmitter<WalletAdapterEvents> implements WalletAdapter {
abstract name: WalletName;
export declare abstract class BaseWalletAdapter<Name extends string = string> extends EventEmitter<WalletAdapterEvents> implements WalletAdapter<Name> {
abstract name: WalletName<Name>;
abstract url: string;

@@ -67,6 +69,7 @@ abstract icon: string;

abstract connecting: boolean;
abstract supportedTransactionVersions: SupportedTransactionVersions;
get connected(): boolean;
abstract connect(): Promise<void>;
abstract disconnect(): Promise<void>;
abstract sendTransaction(transaction: Transaction, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
abstract sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
protected prepareTransaction(transaction: Transaction, connection: Connection, options?: SendOptions): Promise<Transaction>;

@@ -73,0 +76,0 @@ }

@@ -1,21 +0,22 @@

import type { Connection, Transaction, TransactionSignature } from '@solana/web3.js';
import type { SendTransactionOptions, WalletAdapter } from './adapter.js';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import type { SendTransactionOptions, WalletAdapter, WalletAdapterProps } from './adapter.js';
import { BaseWalletAdapter } from './adapter.js';
export interface SignerWalletAdapterProps {
signTransaction(transaction: Transaction): Promise<Transaction>;
signAllTransactions(transaction: Transaction[]): Promise<Transaction[]>;
import type { TransactionOrVersionedTransaction } from './types.js';
export interface SignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transaction: T): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transactions: T[]): Promise<T[]>;
}
export declare type SignerWalletAdapter = WalletAdapter & SignerWalletAdapterProps;
export declare abstract class BaseSignerWalletAdapter extends BaseWalletAdapter implements SignerWalletAdapter {
sendTransaction(transaction: Transaction, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
abstract signTransaction(transaction: Transaction): Promise<Transaction>;
signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>;
export declare type SignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & SignerWalletAdapterProps<Name>;
export declare abstract class BaseSignerWalletAdapter<Name extends string = string> extends BaseWalletAdapter<Name> implements SignerWalletAdapter<Name> {
sendTransaction(transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>, connection: Connection, options?: SendTransactionOptions): Promise<TransactionSignature>;
abstract signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transaction: T): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(transactions: T[]): Promise<T[]>;
}
export interface MessageSignerWalletAdapterProps {
export interface MessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export declare type MessageSignerWalletAdapter = WalletAdapter & MessageSignerWalletAdapterProps;
export declare abstract class BaseMessageSignerWalletAdapter extends BaseSignerWalletAdapter implements MessageSignerWalletAdapter {
export declare type MessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & MessageSignerWalletAdapterProps<Name>;
export declare abstract class BaseMessageSignerWalletAdapter<Name extends string = string> extends BaseSignerWalletAdapter<Name> implements MessageSignerWalletAdapter<Name> {
abstract signMessage(message: Uint8Array): Promise<Uint8Array>;
}
//# sourceMappingURL=signer.d.ts.map

@@ -0,1 +1,2 @@

import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
import type { WalletAdapter } from './adapter.js';

@@ -9,2 +10,4 @@ import type { MessageSignerWalletAdapter, SignerWalletAdapter } from './signer.js';

}
export declare type SupportedTransactionVersions = Set<TransactionVersion> | null;
export declare type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null ? Transaction : Transaction | VersionedTransaction;
//# sourceMappingURL=types.d.ts.map
{
"name": "@solana/wallet-adapter-base",
"version": "0.9.16",
"version": "0.9.17",
"author": "Solana Maintainers <maintainers@solana.foundation>",

@@ -29,3 +29,3 @@ "repository": "https://github.com/solana-labs/wallet-adapter",

"peerDependencies": {
"@solana/web3.js": "^1.50.1"
"@solana/web3.js": "^1.61.0"
},

@@ -36,3 +36,3 @@ "dependencies": {

"devDependencies": {
"@solana/web3.js": "^1.50.1",
"@solana/web3.js": "^1.61.0",
"@types/node-fetch": "^2.6.2",

@@ -39,0 +39,0 @@ "shx": "^0.3.4"

@@ -5,2 +5,3 @@ import type { Connection, PublicKey, SendOptions, Signer, Transaction, TransactionSignature } from '@solana/web3.js';

import { WalletNotConnectedError } from './errors.js';
import type { SupportedTransactionVersions, TransactionOrVersionedTransaction } from './types.js';

@@ -32,7 +33,9 @@ export { EventEmitter };

connected: boolean;
supportedTransactionVersions: SupportedTransactionVersions;
connect(): Promise<void>;
disconnect(): Promise<void>;
sendTransaction(
transaction: Transaction,
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,

@@ -74,4 +77,7 @@ options?: SendTransactionOptions

export abstract class BaseWalletAdapter extends EventEmitter<WalletAdapterEvents> implements WalletAdapter {
abstract name: WalletName;
export abstract class BaseWalletAdapter<Name extends string = string>
extends EventEmitter<WalletAdapterEvents>
implements WalletAdapter<Name>
{
abstract name: WalletName<Name>;
abstract url: string;

@@ -82,2 +88,3 @@ abstract icon: string;

abstract connecting: boolean;
abstract supportedTransactionVersions: SupportedTransactionVersions;

@@ -90,4 +97,5 @@ get connected() {

abstract disconnect(): Promise<void>;
abstract sendTransaction(
transaction: Transaction,
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,

@@ -94,0 +102,0 @@ options?: SendTransactionOptions

@@ -1,16 +0,24 @@

import type { Connection, Transaction, TransactionSignature } from '@solana/web3.js';
import type { SendTransactionOptions, WalletAdapter } from './adapter.js';
import type { Connection, TransactionSignature } from '@solana/web3.js';
import type { SendTransactionOptions, WalletAdapter, WalletAdapterProps } from './adapter.js';
import { BaseWalletAdapter } from './adapter.js';
import { WalletSendTransactionError, WalletSignTransactionError } from './errors.js';
import type { TransactionOrVersionedTransaction } from './types.js';
export interface SignerWalletAdapterProps {
signTransaction(transaction: Transaction): Promise<Transaction>;
signAllTransactions(transaction: Transaction[]): Promise<Transaction[]>;
export interface SignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transaction: T
): Promise<T>;
signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transactions: T[]
): Promise<T[]>;
}
export type SignerWalletAdapter = WalletAdapter & SignerWalletAdapterProps;
export type SignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> & SignerWalletAdapterProps<Name>;
export abstract class BaseSignerWalletAdapter extends BaseWalletAdapter implements SignerWalletAdapter {
export abstract class BaseSignerWalletAdapter<Name extends string = string>
extends BaseWalletAdapter<Name>
implements SignerWalletAdapter<Name>
{
async sendTransaction(
transaction: Transaction,
transaction: TransactionOrVersionedTransaction<this['supportedTransactionVersions']>,
connection: Connection,

@@ -21,21 +29,49 @@ options: SendTransactionOptions = {}

try {
try {
const { signers, ...sendOptions } = options;
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new WalletSendTransactionError(
`Sending versioned transactions isn't supported by this wallet`
);
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new WalletSendTransactionError(
`Sending transaction version ${version} isn't supported by this wallet`
);
signers?.length && transaction.partialSign(...signers);
try {
transaction = await this.signTransaction(transaction);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, options);
} catch (error: any) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
} else {
try {
const { signers, ...sendOptions } = options;
return await connection.sendRawTransaction(rawTransaction, sendOptions);
} catch (error: any) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
transaction = await this.prepareTransaction(transaction, connection, sendOptions);
signers?.length && transaction.partialSign(...signers);
transaction = await this.signTransaction(transaction);
const rawTransaction = transaction.serialize();
return await connection.sendRawTransaction(rawTransaction, sendOptions);
} catch (error: any) {
// If the error was thrown by `signTransaction`, rethrow it and don't emit a duplicate event
if (error instanceof WalletSignTransactionError) {
emit = false;
throw error;
}
throw new WalletSendTransactionError(error?.message, error);
}
throw new WalletSendTransactionError(error?.message, error);
}

@@ -50,7 +86,26 @@ } catch (error: any) {

abstract signTransaction(transaction: Transaction): Promise<Transaction>;
abstract signTransaction<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transaction: T
): Promise<T>;
async signAllTransactions(transactions: Transaction[]): Promise<Transaction[]> {
const signedTransactions: Transaction[] = [];
async signAllTransactions<T extends TransactionOrVersionedTransaction<this['supportedTransactionVersions']>>(
transactions: T[]
): Promise<T[]> {
for (const transaction of transactions) {
if ('message' in transaction) {
if (!this.supportedTransactionVersions)
throw new WalletSignTransactionError(
`Signing versioned transactions isn't supported by this wallet`
);
const { version } = transaction.message;
if (!this.supportedTransactionVersions.has(version))
throw new WalletSignTransactionError(
`Signing transaction version ${version} isn't supported by this wallet`
);
}
}
const signedTransactions: T[] = [];
for (const transaction of transactions) {
signedTransactions.push(await this.signTransaction(transaction));

@@ -62,13 +117,14 @@ }

export interface MessageSignerWalletAdapterProps {
export interface MessageSignerWalletAdapterProps<Name extends string = string> extends WalletAdapterProps<Name> {
signMessage(message: Uint8Array): Promise<Uint8Array>;
}
export type MessageSignerWalletAdapter = WalletAdapter & MessageSignerWalletAdapterProps;
export type MessageSignerWalletAdapter<Name extends string = string> = WalletAdapter<Name> &
MessageSignerWalletAdapterProps<Name>;
export abstract class BaseMessageSignerWalletAdapter
extends BaseSignerWalletAdapter
implements MessageSignerWalletAdapter
export abstract class BaseMessageSignerWalletAdapter<Name extends string = string>
extends BaseSignerWalletAdapter<Name>
implements MessageSignerWalletAdapter<Name>
{
abstract signMessage(message: Uint8Array): Promise<Uint8Array>;
}

@@ -0,1 +1,2 @@

import type { Transaction, TransactionVersion, VersionedTransaction } from '@solana/web3.js';
import type { WalletAdapter } from './adapter.js';

@@ -11,1 +12,7 @@ import type { MessageSignerWalletAdapter, SignerWalletAdapter } from './signer.js';

}
export type SupportedTransactionVersions = Set<TransactionVersion> | null;
export type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null
? Transaction
: Transaction | VersionedTransaction;

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

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