Socket
Socket
Sign inDemoInstall

@marinade.finance/web3js-common

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@marinade.finance/web3js-common - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

2

package.json
{
"name": "@marinade.finance/web3js-common",
"version": "2.0.2",
"version": "2.0.3",
"description": "Web3 JS reusable utilities",

@@ -5,0 +5,0 @@ "repository": {

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

import { Connection, Transaction, VersionedTransactionResponse, SimulatedTransactionResponse, Keypair, Signer, TransactionInstruction, PublicKey } from '@solana/web3.js';
import { Connection, Transaction, VersionedTransactionResponse, SimulatedTransactionResponse, Keypair, Signer, TransactionInstruction, TransactionResponse, PublicKey } from '@solana/web3.js';
import { Wallet } from './wallet';

@@ -18,2 +18,8 @@ type LoggerStandIn = {

/**
* Type guard for TransactionResponse and SimulatedTransactionResponse. It does not accept `undefined` as a valid input.
*
* @returns true if the input is a SimulatedTransactionResponse, false if it is a TransactionResponse, throws an error if it is undefined
*/
export declare function isSimulatedTransactionResponse(response: TransactionResponse | VersionedTransactionResponse | SimulatedTransactionResponse | undefined): response is SimulatedTransactionResponse;
/**
* @returns signers that are required for the provided instructions

@@ -28,3 +34,3 @@ */

*/
export declare function splitAndExecuteTx({ connection, transaction, errMessage, signers, feePayer, simulate, printOnly, logger, }: {
export declare function splitAndExecuteTx({ connection, transaction, errMessage, signers, feePayer, simulate, printOnly, logger, exceedBudget, }: {
connection: Connection;

@@ -38,2 +44,3 @@ transaction: Transaction;

logger?: LoggerStandIn;
exceedBudget?: boolean;
}): Promise<VersionedTransactionResponse[] | SimulatedTransactionResponse[] | []>;

@@ -40,0 +47,0 @@ /**

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.logDebug = exports.logWarn = exports.debugStr = exports.splitAndExecuteTx = exports.TRANSACTION_SAFE_SIZE = exports.filterSignersForInstruction = exports.executeTxSimple = exports.executeTx = void 0;
exports.logDebug = exports.logWarn = exports.debugStr = exports.splitAndExecuteTx = exports.TRANSACTION_SAFE_SIZE = exports.filterSignersForInstruction = exports.isSimulatedTransactionResponse = exports.executeTxSimple = exports.executeTx = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -12,3 +12,3 @@ const wallet_1 = require("./wallet");

if (printOnly) {
console.log('Instructions:');
console.log('Instructions (SPL Gov base64):');
for (const ix of transaction.instructions) {

@@ -22,5 +22,9 @@ console.log(' ' + (0, txToBase64_1.serializeInstructionToBase64)(ix));

const currentBlockhash = await connection.getLatestBlockhash();
transaction.lastValidBlockHeight = currentBlockhash.lastValidBlockHeight;
transaction.recentBlockhash = currentBlockhash.blockhash;
transaction.feePayer = (_a = transaction.feePayer) !== null && _a !== void 0 ? _a : signers[0].publicKey;
if (transaction.recentBlockhash === undefined ||
transaction.recentBlockhash === undefined ||
transaction.feePayer === undefined) {
transaction.lastValidBlockHeight = currentBlockhash.lastValidBlockHeight;
transaction.recentBlockhash = currentBlockhash.blockhash;
transaction.feePayer = (_a = transaction.feePayer) !== null && _a !== void 0 ? _a : signers[0].publicKey;
}
for (const signer of signers) {

@@ -118,2 +122,3 @@ if ((0, wallet_1.instanceOfWallet)(signer)) {

}
exports.isSimulatedTransactionResponse = isSimulatedTransactionResponse;
/**

@@ -137,3 +142,10 @@ * @returns signers that are required for the provided instructions

}
exports.TRANSACTION_SAFE_SIZE = 1280 - 40 - 8;
exports.TRANSACTION_SAFE_SIZE = 1280 - 40 - 8 - 1; // 1231
async function addComputeBudgetIx(exceedBudget, tx) {
if (exceedBudget) {
tx.add(web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({
units: 1000000,
}));
}
}
/**

@@ -144,3 +156,3 @@ * Split tx into multiple transactions if it exceeds the transaction size limit.

*/
async function splitAndExecuteTx({ connection, transaction, errMessage, signers = [], feePayer, simulate = false, printOnly = false, logger, }) {
async function splitAndExecuteTx({ connection, transaction, errMessage, signers = [], feePayer, simulate = false, printOnly = false, logger, exceedBudget = false, }) {
const result = [];

@@ -183,4 +195,5 @@ // only to print in base64

}
let checkingTransaction = await getTransaction(feePayerDefined, blockhash);
let lastValidTransaction = await getTransaction(feePayerDefined, blockhash);
let checkingTransaction = await getTransaction(feePayerDefined, blockhash);
addComputeBudgetIx(exceedBudget, checkingTransaction);
for (const ix of transaction.instructions) {

@@ -190,7 +203,15 @@ checkingTransaction.add(ix);

const signaturesSize = filteredSigners.length * 64;
const txSize = checkingTransaction.serialize({
verifySignatures: false,
requireAllSignatures: false,
}).byteLength;
if (txSize + signaturesSize > exports.TRANSACTION_SAFE_SIZE) {
let txSize = undefined;
try {
txSize = checkingTransaction.serialize({
verifySignatures: false,
requireAllSignatures: false,
}).byteLength;
}
catch (e) {
// ignore
logDebug(logger, 'Transaction size calculation failed: ' + e);
}
if (txSize === undefined ||
txSize + signaturesSize > exports.TRANSACTION_SAFE_SIZE) {
// size was elapsed, need to split

@@ -200,2 +221,4 @@ transactions.push(lastValidTransaction);

checkingTransaction = await getTransaction(feePayerDefined, blockhash);
addComputeBudgetIx(exceedBudget, checkingTransaction);
checkingTransaction.add(ix);
}

@@ -207,3 +230,3 @@ lastValidTransaction = checkingTransaction;

}
// sign all transactions with fee payer
// sign all transactions with fee payer at once
if ((0, wallet_1.instanceOfWallet)(feePayerSigner)) {

@@ -270,3 +293,3 @@ // partial signing by this call

function logWarn(logger, data) {
if (logger) {
if (logger !== undefined) {
logger.warn(data);

@@ -281,3 +304,3 @@ }

function logDebug(logger, data) {
if (logger) {
if (logger !== undefined) {
logger.debug(data);

@@ -284,0 +307,0 @@ }

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