@saberhq/solana-contrib
Advanced tools
Comparing version 1.12.53 to 1.12.54
import type { Blockhash, Commitment, ConfirmOptions, Connection, RpcResponseAndContext, SimulatedTransactionResponse, Transaction } from "@solana/web3.js"; | ||
import type { Broadcaster } from "."; | ||
import { PendingTransaction } from "."; | ||
import type { Broadcaster } from "./interfaces"; | ||
import { PendingTransaction } from "./transaction"; | ||
export interface BroadcastOptions extends ConfirmOptions { | ||
@@ -5,0 +5,0 @@ /** |
@@ -5,3 +5,6 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const _1 = require("."); | ||
const error_1 = require("./error"); | ||
const provider_1 = require("./provider"); | ||
const transaction_1 = require("./transaction"); | ||
const utils_1 = require("./utils"); | ||
const simulateTransactionWithCommitment_1 = require("./utils/simulateTransactionWithCommitment"); | ||
@@ -12,3 +15,3 @@ /** | ||
class SingleConnectionBroadcaster { | ||
constructor(sendConnection, opts = _1.DEFAULT_PROVIDER_OPTIONS) { | ||
constructor(sendConnection, opts = provider_1.DEFAULT_PROVIDER_OPTIONS) { | ||
this.sendConnection = sendConnection; | ||
@@ -39,7 +42,7 @@ this.opts = opts; | ||
if (printLogs) { | ||
return new _1.PendingTransaction(this.sendConnection, yield this.sendConnection.sendRawTransaction(rawTx, opts)); | ||
return new transaction_1.PendingTransaction(this.sendConnection, yield this.sendConnection.sendRawTransaction(rawTx, opts)); | ||
} | ||
return yield (0, _1.suppressConsoleErrorAsync)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.suppressConsoleErrorAsync)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
// hide the logs of TX errors if printLogs = false | ||
return new _1.PendingTransaction(this.sendConnection, yield this.sendConnection.sendRawTransaction(rawTx, opts)); | ||
return new transaction_1.PendingTransaction(this.sendConnection, yield this.sendConnection.sendRawTransaction(rawTx, opts)); | ||
})); | ||
@@ -71,3 +74,3 @@ }); | ||
class MultipleConnectionBroadcaster { | ||
constructor(connections, opts = _1.DEFAULT_PROVIDER_OPTIONS) { | ||
constructor(connections, opts = provider_1.DEFAULT_PROVIDER_OPTIONS) { | ||
this.connections = connections; | ||
@@ -80,4 +83,14 @@ this.opts = opts; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const result = yield Promise.any(this.connections.map((conn) => conn.getRecentBlockhash(commitment))); | ||
return result.blockhash; | ||
try { | ||
const result = yield Promise.any(this.connections.map((conn) => conn.getRecentBlockhash(commitment))); | ||
return result.blockhash; | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw (0, error_1.firstAggregateError)(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -87,5 +100,15 @@ } | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield Promise.any(this.connections.map((connection) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return new _1.PendingTransaction(connection, yield connection.sendRawTransaction(encoded, options)); | ||
}))); | ||
try { | ||
return yield Promise.any(this.connections.map((connection) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return new transaction_1.PendingTransaction(connection, yield connection.sendRawTransaction(encoded, options)); | ||
}))); | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw (0, error_1.firstAggregateError)(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -111,3 +134,3 @@ } | ||
} | ||
return yield (0, _1.suppressConsoleErrorAsync)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield (0, utils_1.suppressConsoleErrorAsync)(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
// hide the logs of TX errors if printLogs = false | ||
@@ -132,5 +155,15 @@ return yield this._sendRawTransaction(rawTx, opts); | ||
} | ||
return yield Promise.any(this.connections.map((connection) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield (0, simulateTransactionWithCommitment_1.simulateTransactionWithCommitment)(connection, tx, commitment); | ||
}))); | ||
try { | ||
return yield Promise.any(this.connections.map((connection) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return yield (0, simulateTransactionWithCommitment_1.simulateTransactionWithCommitment)(connection, tx, commitment); | ||
}))); | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw (0, error_1.firstAggregateError)(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -137,0 +170,0 @@ } |
import type { Blockhash, Commitment, ConfirmOptions, Connection, RpcResponseAndContext, SimulatedTransactionResponse, Transaction } from "@solana/web3.js"; | ||
import type { Broadcaster } from "."; | ||
import { PendingTransaction } from "."; | ||
import type { Broadcaster } from "./interfaces"; | ||
import { PendingTransaction } from "./transaction"; | ||
export interface BroadcastOptions extends ConfirmOptions { | ||
@@ -5,0 +5,0 @@ /** |
import { __awaiter, __rest } from "tslib"; | ||
import { DEFAULT_PROVIDER_OPTIONS, PendingTransaction, suppressConsoleErrorAsync, } from "."; | ||
import { firstAggregateError } from "./error"; | ||
import { DEFAULT_PROVIDER_OPTIONS } from "./provider"; | ||
import { PendingTransaction } from "./transaction"; | ||
import { suppressConsoleErrorAsync } from "./utils"; | ||
import { simulateTransactionWithCommitment } from "./utils/simulateTransactionWithCommitment"; | ||
@@ -72,4 +75,14 @@ /** | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const result = yield Promise.any(this.connections.map((conn) => conn.getRecentBlockhash(commitment))); | ||
return result.blockhash; | ||
try { | ||
const result = yield Promise.any(this.connections.map((conn) => conn.getRecentBlockhash(commitment))); | ||
return result.blockhash; | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -79,5 +92,15 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield Promise.any(this.connections.map((connection) => __awaiter(this, void 0, void 0, function* () { | ||
return new PendingTransaction(connection, yield connection.sendRawTransaction(encoded, options)); | ||
}))); | ||
try { | ||
return yield Promise.any(this.connections.map((connection) => __awaiter(this, void 0, void 0, function* () { | ||
return new PendingTransaction(connection, yield connection.sendRawTransaction(encoded, options)); | ||
}))); | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -123,5 +146,15 @@ } | ||
} | ||
return yield Promise.any(this.connections.map((connection) => __awaiter(this, void 0, void 0, function* () { | ||
return yield simulateTransactionWithCommitment(connection, tx, commitment); | ||
}))); | ||
try { | ||
return yield Promise.any(this.connections.map((connection) => __awaiter(this, void 0, void 0, function* () { | ||
return yield simulateTransactionWithCommitment(connection, tx, commitment); | ||
}))); | ||
} | ||
catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} | ||
else { | ||
throw e; | ||
} | ||
} | ||
}); | ||
@@ -128,0 +161,0 @@ } |
{ | ||
"name": "@saberhq/solana-contrib", | ||
"version": "1.12.53", | ||
"version": "1.12.54", | ||
"description": "Common types and libraries for Solana", | ||
@@ -45,3 +45,3 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
}, | ||
"gitHead": "27bd412a8bf627783d09aba117f8c87417d41d24", | ||
"gitHead": "72eed34db82df00b6de8f1e0966351a5a950b329", | ||
"publishConfig": { | ||
@@ -48,0 +48,0 @@ "access": "public" |
@@ -12,8 +12,7 @@ import type { | ||
import type { Broadcaster } from "."; | ||
import { | ||
DEFAULT_PROVIDER_OPTIONS, | ||
PendingTransaction, | ||
suppressConsoleErrorAsync, | ||
} from "."; | ||
import { firstAggregateError } from "./error"; | ||
import type { Broadcaster } from "./interfaces"; | ||
import { DEFAULT_PROVIDER_OPTIONS } from "./provider"; | ||
import { PendingTransaction } from "./transaction"; | ||
import { suppressConsoleErrorAsync } from "./utils"; | ||
import { simulateTransactionWithCommitment } from "./utils/simulateTransactionWithCommitment"; | ||
@@ -119,6 +118,14 @@ | ||
): Promise<Blockhash> { | ||
const result = await Promise.any( | ||
this.connections.map((conn) => conn.getRecentBlockhash(commitment)) | ||
); | ||
return result.blockhash; | ||
try { | ||
const result = await Promise.any( | ||
this.connections.map((conn) => conn.getRecentBlockhash(commitment)) | ||
); | ||
return result.blockhash; | ||
} catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
@@ -130,10 +137,18 @@ | ||
): Promise<PendingTransaction> { | ||
return await Promise.any( | ||
this.connections.map(async (connection) => { | ||
return new PendingTransaction( | ||
connection, | ||
await connection.sendRawTransaction(encoded, options) | ||
); | ||
}) | ||
); | ||
try { | ||
return await Promise.any( | ||
this.connections.map(async (connection) => { | ||
return new PendingTransaction( | ||
connection, | ||
await connection.sendRawTransaction(encoded, options) | ||
); | ||
}) | ||
); | ||
} catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
@@ -190,12 +205,20 @@ | ||
} | ||
return await Promise.any( | ||
this.connections.map(async (connection) => { | ||
return await simulateTransactionWithCommitment( | ||
connection, | ||
tx, | ||
commitment | ||
); | ||
}) | ||
); | ||
try { | ||
return await Promise.any( | ||
this.connections.map(async (connection) => { | ||
return await simulateTransactionWithCommitment( | ||
connection, | ||
tx, | ||
commitment | ||
); | ||
}) | ||
); | ||
} catch (e) { | ||
if (e instanceof AggregateError) { | ||
throw firstAggregateError(e); | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
} |
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
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
654098
215
9216