@marinade.finance/web3js-common
Advanced tools
Comparing version 2.0.15 to 2.0.16
{ | ||
"name": "@marinade.finance/web3js-common", | ||
"version": "2.0.15", | ||
"version": "2.0.16", | ||
"description": "Web3 JS reusable utilities", | ||
@@ -25,2 +25,3 @@ "repository": { | ||
"@solana/web3.js": "^1.78.5", | ||
"@marinade.finance/ts-common": "2.0.16", | ||
"bn.js": "^5.2.1", | ||
@@ -32,2 +33,3 @@ "borsh": "^0.7.0", | ||
"@solana/web3.js": "^1.78.5", | ||
"@marinade.finance/ts-common": "2.0.16", | ||
"bn.js": "^5.2.1", | ||
@@ -34,0 +36,0 @@ "borsh": "^0.7.0", |
import { Connection, Transaction, VersionedTransactionResponse, SimulatedTransactionResponse, Keypair, Signer, TransactionInstruction, TransactionResponse, PublicKey } from '@solana/web3.js'; | ||
import { Wallet } from './wallet'; | ||
type LoggerStandIn = { | ||
debug: (data: any) => void; | ||
warn: (data: any) => void; | ||
}; | ||
import { LoggerPlaceholder } from '@marinade.finance/ts-common'; | ||
export declare function executeTx({ connection, transaction, signers, errMessage, simulate, printOnly, logger, }: { | ||
@@ -14,3 +11,3 @@ connection: Connection; | ||
printOnly?: boolean; | ||
logger?: LoggerStandIn; | ||
logger?: LoggerPlaceholder; | ||
}): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; | ||
@@ -42,3 +39,3 @@ export declare function executeTxSimple(connection: Connection, transaction: Transaction, signers?: (Wallet | Keypair | Signer)[]): Promise<VersionedTransactionResponse | SimulatedTransactionResponse | undefined>; | ||
printOnly?: boolean; | ||
logger?: LoggerStandIn; | ||
logger?: LoggerPlaceholder; | ||
exceedBudget?: boolean; | ||
@@ -52,4 +49,1 @@ }): Promise<VersionedTransactionResponse[] | SimulatedTransactionResponse[] | []>; | ||
export declare function debugStr(transaction: Transaction): string; | ||
export declare function logWarn(logger: LoggerStandIn | undefined, data: any): void; | ||
export declare function logDebug(logger: LoggerStandIn | undefined, data: any): void; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logDebug = exports.logWarn = exports.debugStr = exports.splitAndExecuteTx = exports.TRANSACTION_SAFE_SIZE = exports.filterSignersForInstruction = exports.isSimulatedTransactionResponse = exports.executeTxSimple = exports.executeTx = void 0; | ||
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"); | ||
@@ -8,2 +8,3 @@ const wallet_1 = require("./wallet"); | ||
const error_1 = require("./error"); | ||
const ts_common_1 = require("@marinade.finance/ts-common"); | ||
async function executeTx({ connection, transaction, signers = [], errMessage, simulate = false, printOnly = false, logger, }) { | ||
@@ -13,3 +14,3 @@ var _a, _b; | ||
if (printOnly) { | ||
console.log('Instructions (SPL Gov base64):'); | ||
(0, ts_common_1.logInfo)(logger, 'Instructions (SPL Gov base64):'); | ||
for (const ix of transaction.instructions) { | ||
@@ -41,5 +42,5 @@ console.log(' ' + (0, txToBase64_1.serializeInstructionToBase64)(ix)); | ||
if (simulate) { | ||
logWarn(logger, '[[Simulation mode]]'); | ||
(0, ts_common_1.logWarn)(logger, '[[Simulation mode]]'); | ||
result = (await connection.simulateTransaction(transaction)).value; | ||
logDebug(logger, result); | ||
(0, ts_common_1.logDebug)(logger, result); | ||
if (result.err) { | ||
@@ -82,4 +83,4 @@ throw new web3_js_1.SendTransactionError(result.err, result.logs || undefined); | ||
result = txRes; | ||
logDebug(logger, 'Transaction signature: ' + txSig); | ||
logDebug(logger, (_b = txRes.meta) === null || _b === void 0 ? void 0 : _b.logMessages); | ||
(0, ts_common_1.logDebug)(logger, 'Transaction signature: ' + txSig); | ||
(0, ts_common_1.logDebug)(logger, (_b = txRes.meta) === null || _b === void 0 ? void 0 : _b.logMessages); | ||
} | ||
@@ -94,3 +95,3 @@ } | ||
: undefined, | ||
transaction, | ||
transaction: (0, ts_common_1.isLevelEnabled)(logger, 'debug') ? transaction : undefined, | ||
}); | ||
@@ -211,3 +212,3 @@ } | ||
// ignore | ||
// logDebug(logger, 'Transaction size calculation failed: ' + e) | ||
(0, ts_common_1.logDebug)(logger, 'Transaction size calculation failed: ' + e); | ||
} | ||
@@ -250,3 +251,3 @@ if (txSize === undefined || | ||
executionCounter++; | ||
logDebug(logger, `Transaction ${executionCounter}/${transactions.length} ` + | ||
(0, ts_common_1.logDebug)(logger, `Transaction ${executionCounter}/${transactions.length} ` + | ||
`(${transaction.instructions.length} instructions) executed`); | ||
@@ -290,22 +291,2 @@ if (isSimulatedTransactionResponse(executeResult)) { | ||
exports.debugStr = debugStr; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function logWarn(logger, data) { | ||
if (logger !== undefined) { | ||
logger.warn(data); | ||
} | ||
else { | ||
console.log(data); | ||
} | ||
} | ||
exports.logWarn = logWarn; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function logDebug(logger, data) { | ||
if (logger !== undefined) { | ||
logger.debug(data); | ||
} | ||
else { | ||
console.debug(data); | ||
} | ||
} | ||
exports.logDebug = logDebug; | ||
//# sourceMappingURL=tx.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40434
5
5
608