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

@saberhq/solana-contrib

Package Overview
Dependencies
Maintainers
2
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saberhq/solana-contrib - npm Package Compare versions

Comparing version 1.11.0 to 1.11.1

40

dist/cjs/transaction/TransactionEnvelope.d.ts

@@ -1,3 +0,3 @@

import type { AccountMeta, Cluster, ConfirmOptions, PublicKey, RpcResponseAndContext, Signer, SimulatedTransactionResponse, TransactionInstruction } from "@solana/web3.js";
import { Transaction } from "@solana/web3.js";
import type { AccountMeta, Cluster, ConfirmOptions, RpcResponseAndContext, Signer, SimulatedTransactionResponse, TransactionInstruction } from "@solana/web3.js";
import { PublicKey, Transaction } from "@solana/web3.js";
import type { Provider } from "../interfaces";

@@ -17,2 +17,34 @@ import type { PendingTransaction } from "./PendingTransaction";

/**
* Stub of a recent blockhash that can be used to simulate transactions.
*/
export declare const RECENT_BLOCKHASH_STUB = "GfVcyD4kkTrj4bKc7WA9sZCin9JDbdT4Zkd3EittNR1W";
/**
* Builds a transaction with a fake `recentBlockhash` and `feePayer` for the purpose
* of simulating a sequence of instructions.
*
* @param cluster
* @param ixs
* @returns
*/
export declare const buildStubbedTransaction: (cluster: Cluster, ixs: TransactionInstruction[]) => Transaction;
/**
* Serializes a {@link Transaction} to base64 format without checking signatures.
* @param tx
* @returns
*/
export declare const serializeToBase64Unchecked: (tx: Transaction) => string;
/**
* Generates a link for inspecting the contents of a transaction.
*
* @returns URL
*/
export declare const generateInspectLinkFromBase64: (cluster: Cluster, base64TX: string) => string;
/**
* Generates a link for inspecting the contents of a transaction, not checking for
* or requiring valid signatures.
*
* @returns URL
*/
export declare const generateUncheckedInspectLink: (cluster: Cluster, tx: Transaction) => string;
/**
* Contains a Transaction that is being built.

@@ -22,3 +54,3 @@ */

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -36,3 +68,3 @@ readonly provider: Provider;

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -39,0 +71,0 @@ provider: Provider,

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionEnvelope = void 0;
exports.TransactionEnvelope = exports.generateUncheckedInspectLink = exports.generateInspectLinkFromBase64 = exports.serializeToBase64Unchecked = exports.buildStubbedTransaction = exports.RECENT_BLOCKHASH_STUB = void 0;
const tslib_1 = require("tslib");
const web3_js_1 = require("@solana/web3.js");
/**
* Stub of a recent blockhash that can be used to simulate transactions.
*/
exports.RECENT_BLOCKHASH_STUB = "GfVcyD4kkTrj4bKc7WA9sZCin9JDbdT4Zkd3EittNR1W";
/**
* Builds a transaction with a fake `recentBlockhash` and `feePayer` for the purpose
* of simulating a sequence of instructions.
*
* @param cluster
* @param ixs
* @returns
*/
const buildStubbedTransaction = (cluster, ixs) => {
const tx = new web3_js_1.Transaction();
tx.recentBlockhash = exports.RECENT_BLOCKHASH_STUB;
// random keys that have money in them
tx.feePayer =
cluster === "devnet"
? new web3_js_1.PublicKey("A2jaCHPzD6346348JoEym2KFGX9A7uRBw6AhCdX7gTWP")
: new web3_js_1.PublicKey("9u9iZBWqGsp5hXBxkVZtBTuLSGNAG9gEQLgpuVw39ASg");
tx.instructions = ixs;
return tx;
};
exports.buildStubbedTransaction = buildStubbedTransaction;
/**
* Serializes a {@link Transaction} to base64 format without checking signatures.
* @param tx
* @returns
*/
const serializeToBase64Unchecked = (tx) => tx
.serialize({
requireAllSignatures: false,
verifySignatures: false,
})
.toString("base64");
exports.serializeToBase64Unchecked = serializeToBase64Unchecked;
/**
* Generates a link for inspecting the contents of a transaction.
*
* @returns URL
*/
const generateInspectLinkFromBase64 = (cluster, base64TX) => {
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(base64TX)}`;
};
exports.generateInspectLinkFromBase64 = generateInspectLinkFromBase64;
/**
* Generates a link for inspecting the contents of a transaction, not checking for
* or requiring valid signatures.
*
* @returns URL
*/
const generateUncheckedInspectLink = (cluster, tx) => {
return (0, exports.generateInspectLinkFromBase64)(cluster, (0, exports.serializeToBase64Unchecked)(tx));
};
exports.generateUncheckedInspectLink = generateUncheckedInspectLink;
/**
* Contains a Transaction that is being built.

@@ -12,3 +67,3 @@ */

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -62,5 +117,5 @@ provider,

const t = this.build();
t.recentBlockhash = "EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k"; // Some stub
t.recentBlockhash = exports.RECENT_BLOCKHASH_STUB;
const str = t.serializeMessage().toString("base64");
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(str)}`;
return (0, exports.generateInspectLinkFromBase64)(cluster, str);
}

@@ -67,0 +122,0 @@ /**

@@ -1,3 +0,3 @@

import type { AccountMeta, Cluster, ConfirmOptions, PublicKey, RpcResponseAndContext, Signer, SimulatedTransactionResponse, TransactionInstruction } from "@solana/web3.js";
import { Transaction } from "@solana/web3.js";
import type { AccountMeta, Cluster, ConfirmOptions, RpcResponseAndContext, Signer, SimulatedTransactionResponse, TransactionInstruction } from "@solana/web3.js";
import { PublicKey, Transaction } from "@solana/web3.js";
import type { Provider } from "../interfaces";

@@ -17,2 +17,34 @@ import type { PendingTransaction } from "./PendingTransaction";

/**
* Stub of a recent blockhash that can be used to simulate transactions.
*/
export declare const RECENT_BLOCKHASH_STUB = "GfVcyD4kkTrj4bKc7WA9sZCin9JDbdT4Zkd3EittNR1W";
/**
* Builds a transaction with a fake `recentBlockhash` and `feePayer` for the purpose
* of simulating a sequence of instructions.
*
* @param cluster
* @param ixs
* @returns
*/
export declare const buildStubbedTransaction: (cluster: Cluster, ixs: TransactionInstruction[]) => Transaction;
/**
* Serializes a {@link Transaction} to base64 format without checking signatures.
* @param tx
* @returns
*/
export declare const serializeToBase64Unchecked: (tx: Transaction) => string;
/**
* Generates a link for inspecting the contents of a transaction.
*
* @returns URL
*/
export declare const generateInspectLinkFromBase64: (cluster: Cluster, base64TX: string) => string;
/**
* Generates a link for inspecting the contents of a transaction, not checking for
* or requiring valid signatures.
*
* @returns URL
*/
export declare const generateUncheckedInspectLink: (cluster: Cluster, tx: Transaction) => string;
/**
* Contains a Transaction that is being built.

@@ -22,3 +54,3 @@ */

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -36,3 +68,3 @@ readonly provider: Provider;

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -39,0 +71,0 @@ provider: Provider,

import { __awaiter } from "tslib";
import { Transaction } from "@solana/web3.js";
import { PublicKey, Transaction } from "@solana/web3.js";
/**
* Stub of a recent blockhash that can be used to simulate transactions.
*/
export const RECENT_BLOCKHASH_STUB = "GfVcyD4kkTrj4bKc7WA9sZCin9JDbdT4Zkd3EittNR1W";
/**
* Builds a transaction with a fake `recentBlockhash` and `feePayer` for the purpose
* of simulating a sequence of instructions.
*
* @param cluster
* @param ixs
* @returns
*/
export const buildStubbedTransaction = (cluster, ixs) => {
const tx = new Transaction();
tx.recentBlockhash = RECENT_BLOCKHASH_STUB;
// random keys that have money in them
tx.feePayer =
cluster === "devnet"
? new PublicKey("A2jaCHPzD6346348JoEym2KFGX9A7uRBw6AhCdX7gTWP")
: new PublicKey("9u9iZBWqGsp5hXBxkVZtBTuLSGNAG9gEQLgpuVw39ASg");
tx.instructions = ixs;
return tx;
};
/**
* Serializes a {@link Transaction} to base64 format without checking signatures.
* @param tx
* @returns
*/
export const serializeToBase64Unchecked = (tx) => tx
.serialize({
requireAllSignatures: false,
verifySignatures: false,
})
.toString("base64");
/**
* Generates a link for inspecting the contents of a transaction.
*
* @returns URL
*/
export const generateInspectLinkFromBase64 = (cluster, base64TX) => {
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(base64TX)}`;
};
/**
* Generates a link for inspecting the contents of a transaction, not checking for
* or requiring valid signatures.
*
* @returns URL
*/
export const generateUncheckedInspectLink = (cluster, tx) => {
return generateInspectLinkFromBase64(cluster, serializeToBase64Unchecked(tx));
};
/**
* Contains a Transaction that is being built.

@@ -9,3 +60,3 @@ */

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/

@@ -59,5 +110,5 @@ provider,

const t = this.build();
t.recentBlockhash = "EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k"; // Some stub
t.recentBlockhash = RECENT_BLOCKHASH_STUB;
const str = t.serializeMessage().toString("base64");
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(str)}`;
return generateInspectLinkFromBase64(cluster, str);
}

@@ -64,0 +115,0 @@ /**

6

package.json
{
"name": "@saberhq/solana-contrib",
"version": "1.11.0",
"version": "1.11.1",
"description": "Common types and libraries for Solana",

@@ -36,3 +36,3 @@ "author": "Ian Macalinao <ian@saber.so>",

"@solana/web3.js": "^1.31.0",
"@types/node": "^16.11.13"
"@types/node": "^16.11.14"
},

@@ -42,3 +42,3 @@ "peerDependencies": {

},
"gitHead": "d8f8ead7a857ecfcc0b6ba00f67ac3e289843247",
"gitHead": "074eaa338a2c096bb0d54f5da4deb0b5df7b8f71",
"publishConfig": {

@@ -45,0 +45,0 @@ "access": "public"

@@ -20,4 +20,4 @@ import type {

constructor(
public readonly sendConnection: Connection,
public readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
readonly sendConnection: Connection,
readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
) {}

@@ -24,0 +24,0 @@

@@ -41,4 +41,4 @@ import type {

constructor(
public readonly connection: Connection,
public readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
readonly connection: Connection,
readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
) {}

@@ -71,5 +71,5 @@

constructor(
public readonly wallet: Wallet,
public readonly broadcaster: Broadcaster,
public readonly preflightCommitment: Commitment = "recent"
readonly wallet: Wallet,
readonly broadcaster: Broadcaster,
readonly preflightCommitment: Commitment = "recent"
) {}

@@ -156,3 +156,3 @@

export class SolanaProvider extends SolanaReadonlyProvider implements Provider {
public readonly signer: TransactionSigner;
readonly signer: TransactionSigner;

@@ -166,6 +166,6 @@ /**

constructor(
public override readonly connection: Connection,
public readonly broadcaster: Broadcaster,
public readonly wallet: Wallet,
public override readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
override readonly connection: Connection,
readonly broadcaster: Broadcaster,
readonly wallet: Wallet,
override readonly opts: ConfirmOptions = DEFAULT_PROVIDER_OPTIONS
) {

@@ -306,3 +306,3 @@ super(connection, opts);

export class SolanaAugmentedProvider implements AugmentedProvider {
constructor(public readonly provider: Provider) {}
constructor(readonly provider: Provider) {}

@@ -309,0 +309,0 @@ get connection(): Connection {

@@ -18,4 +18,4 @@ import type {

constructor(
public readonly connection: Connection,
public readonly signature: TransactionSignature
readonly connection: Connection,
readonly signature: TransactionSignature
) {}

@@ -22,0 +22,0 @@

@@ -5,3 +5,2 @@ import type {

ConfirmOptions,
PublicKey,
RpcResponseAndContext,

@@ -12,3 +11,3 @@ Signer,

} from "@solana/web3.js";
import { Transaction } from "@solana/web3.js";
import { PublicKey, Transaction } from "@solana/web3.js";

@@ -29,2 +28,72 @@ import type { Provider } from "../interfaces";

/**
* Stub of a recent blockhash that can be used to simulate transactions.
*/
export const RECENT_BLOCKHASH_STUB =
"GfVcyD4kkTrj4bKc7WA9sZCin9JDbdT4Zkd3EittNR1W";
/**
* Builds a transaction with a fake `recentBlockhash` and `feePayer` for the purpose
* of simulating a sequence of instructions.
*
* @param cluster
* @param ixs
* @returns
*/
export const buildStubbedTransaction = (
cluster: Cluster,
ixs: TransactionInstruction[]
): Transaction => {
const tx = new Transaction();
tx.recentBlockhash = RECENT_BLOCKHASH_STUB;
// random keys that have money in them
tx.feePayer =
cluster === "devnet"
? new PublicKey("A2jaCHPzD6346348JoEym2KFGX9A7uRBw6AhCdX7gTWP")
: new PublicKey("9u9iZBWqGsp5hXBxkVZtBTuLSGNAG9gEQLgpuVw39ASg");
tx.instructions = ixs;
return tx;
};
/**
* Serializes a {@link Transaction} to base64 format without checking signatures.
* @param tx
* @returns
*/
export const serializeToBase64Unchecked = (tx: Transaction): string =>
tx
.serialize({
requireAllSignatures: false,
verifySignatures: false,
})
.toString("base64");
/**
* Generates a link for inspecting the contents of a transaction.
*
* @returns URL
*/
export const generateInspectLinkFromBase64 = (
cluster: Cluster,
base64TX: string
): string => {
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(
base64TX
)}`;
};
/**
* Generates a link for inspecting the contents of a transaction, not checking for
* or requiring valid signatures.
*
* @returns URL
*/
export const generateUncheckedInspectLink = (
cluster: Cluster,
tx: Transaction
): string => {
return generateInspectLinkFromBase64(cluster, serializeToBase64Unchecked(tx));
};
/**
* Contains a Transaction that is being built.

@@ -35,13 +104,13 @@ */

/**
* Provider that will be sending the transaction.
* Provider that will be sending the transaction as the fee payer.
*/
public readonly provider: Provider,
readonly provider: Provider,
/**
* Instructions associated with the transaction.
*/
public readonly instructions: TransactionInstruction[],
readonly instructions: TransactionInstruction[],
/**
* Optional signers of the transaction.
*/
public readonly signers: Signer[] = []
readonly signers: Signer[] = []
) {}

@@ -90,7 +159,5 @@

const t = this.build();
t.recentBlockhash = "EETubP5AKHgjPAhzPAFcb8BAY1hMH639CWCFTqi3hq1k"; // Some stub
t.recentBlockhash = RECENT_BLOCKHASH_STUB;
const str = t.serializeMessage().toString("base64");
return `https://explorer.solana.com/tx/inspector?cluster=${cluster}&message=${encodeURIComponent(
str
)}`;
return generateInspectLinkFromBase64(cluster, str);
}

@@ -97,0 +164,0 @@

@@ -17,7 +17,7 @@ import type {

*/
public readonly signature: TransactionSignature,
readonly signature: TransactionSignature,
/**
* Raw response from web3.js
*/
public readonly response: TransactionResponse
readonly response: TransactionResponse
) {}

@@ -28,3 +28,3 @@

*/
public getEvents<E extends Event>(eventParser: EventParser<E>): readonly E[] {
getEvents<E extends Event>(eventParser: EventParser<E>): readonly E[] {
const logs = this.response.meta?.logMessages;

@@ -40,3 +40,3 @@ if (logs && logs.length > 0) {

*/
public printLogs(): void {
printLogs(): void {
console.log(this.response.meta?.logMessages?.join("\n"));

@@ -49,3 +49,3 @@ }

*/
public get computeUnits(): number {
get computeUnits(): number {
const logs = this.response.meta?.logMessages;

@@ -52,0 +52,0 @@ invariant(logs, "no logs");

@@ -16,3 +16,3 @@ import type {

export class SignerWallet implements Wallet {
constructor(public readonly signer: Signer) {}
constructor(readonly signer: Signer) {}

@@ -19,0 +19,0 @@ get publicKey(): PublicKey {

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

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

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