@saberhq/solana-contrib
Advanced tools
Comparing version 1.14.9 to 1.14.10
@@ -16,2 +16,6 @@ import type { BlockhashWithExpiryBlockHeight, Cluster, Connection, Finality, TransactionSignature } from "@solana/web3.js"; | ||
readonly useWebsocket?: boolean; | ||
/** | ||
* Max supported transaction version. Pass `undefined` to only support `legacy` transactions. | ||
*/ | ||
readonly maxSupportedTransactionVersion?: number; | ||
} | ||
@@ -36,3 +40,3 @@ /** | ||
*/ | ||
wait({ commitment, useWebsocket, ...retryOpts }?: TransactionWaitOptions): Promise<TransactionReceipt>; | ||
wait({ commitment, maxSupportedTransactionVersion, useWebsocket, ...retryOpts }?: TransactionWaitOptions): Promise<TransactionReceipt>; | ||
/** | ||
@@ -42,3 +46,3 @@ * Fetches the TransactionReceipt via polling. | ||
*/ | ||
pollForReceipt({ commitment, ...retryOpts }?: Omit<TransactionWaitOptions, "useWebsocket">): Promise<TransactionReceipt>; | ||
pollForReceipt({ commitment, maxSupportedTransactionVersion, ...retryOpts }?: Omit<TransactionWaitOptions, "useWebsocket">): Promise<TransactionReceipt>; | ||
/** | ||
@@ -45,0 +49,0 @@ * Awaits the confirmation of the transaction, via onSignature subscription. |
@@ -29,3 +29,3 @@ "use strict"; | ||
*/ | ||
async wait({ commitment = "confirmed", useWebsocket = true, ...retryOpts } = {}) { | ||
async wait({ commitment = "confirmed", maxSupportedTransactionVersion = 0, useWebsocket = true, ...retryOpts } = {}) { | ||
if (this._receipt) { | ||
@@ -36,5 +36,12 @@ return this._receipt; | ||
await this.confirm({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ commitment }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
} | ||
return await this.pollForReceipt({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
...retryOpts, | ||
}); | ||
} | ||
@@ -45,6 +52,7 @@ /** | ||
*/ | ||
async pollForReceipt({ commitment = "confirmed", ...retryOpts } = {}) { | ||
async pollForReceipt({ commitment = "confirmed", maxSupportedTransactionVersion = 0, ...retryOpts } = {}) { | ||
const receipt = await (0, promise_retry_1.default)(async (retry) => { | ||
const result = await this.connection.getTransaction(this.signature, { | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
@@ -51,0 +59,0 @@ if (!result) { |
@@ -1,2 +0,2 @@ | ||
import type { Cluster, TransactionResponse, TransactionSignature } from "@solana/web3.js"; | ||
import type { Cluster, TransactionResponse, TransactionSignature, VersionedTransactionResponse } from "@solana/web3.js"; | ||
import type { Event, EventParser } from "../interfaces.js"; | ||
@@ -28,3 +28,3 @@ import type { PromiseOrValue } from "../utils/misc.js"; | ||
*/ | ||
readonly response: TransactionResponse; | ||
readonly response: TransactionResponse | VersionedTransactionResponse; | ||
constructor( | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
response: TransactionResponse); | ||
response: TransactionResponse | VersionedTransactionResponse); | ||
/** | ||
@@ -41,0 +41,0 @@ * Gets the events associated with this transaction. |
@@ -0,1 +1,2 @@ | ||
import type { PublicKey } from "./publicKey"; | ||
export * from "@saberhq/option-utils"; | ||
@@ -21,2 +22,8 @@ /** | ||
export declare const valueAsPromise: <T>(awaitable: PromiseOrValue<T>) => Promise<T>; | ||
/** | ||
* Shortens a pubkey. | ||
* @param pubkey | ||
* @returns | ||
*/ | ||
export declare const formatPubkeyShort: (pubkey: PublicKey, leading?: number, trailing?: number) => string; | ||
//# sourceMappingURL=misc.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.valueAsPromise = exports.sleep = exports.suppressConsoleError = exports.suppressConsoleErrorAsync = void 0; | ||
exports.formatPubkeyShort = exports.valueAsPromise = exports.sleep = exports.suppressConsoleError = exports.suppressConsoleErrorAsync = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -59,2 +59,14 @@ tslib_1.__exportStar(require("@saberhq/option-utils"), exports); | ||
exports.valueAsPromise = valueAsPromise; | ||
/** | ||
* Shortens a pubkey. | ||
* @param pubkey | ||
* @returns | ||
*/ | ||
const formatPubkeyShort = (pubkey, leading = 7, trailing = 7) => { | ||
const str = pubkey.toString(); | ||
return str.length > 20 | ||
? `${str.substring(0, leading)}.....${str.substring(str.length - trailing, str.length)}` | ||
: str; | ||
}; | ||
exports.formatPubkeyShort = formatPubkeyShort; | ||
//# sourceMappingURL=misc.js.map |
@@ -16,2 +16,6 @@ import type { BlockhashWithExpiryBlockHeight, Cluster, Connection, Finality, TransactionSignature } from "@solana/web3.js"; | ||
readonly useWebsocket?: boolean; | ||
/** | ||
* Max supported transaction version. Pass `undefined` to only support `legacy` transactions. | ||
*/ | ||
readonly maxSupportedTransactionVersion?: number; | ||
} | ||
@@ -36,3 +40,3 @@ /** | ||
*/ | ||
wait({ commitment, useWebsocket, ...retryOpts }?: TransactionWaitOptions): Promise<TransactionReceipt>; | ||
wait({ commitment, maxSupportedTransactionVersion, useWebsocket, ...retryOpts }?: TransactionWaitOptions): Promise<TransactionReceipt>; | ||
/** | ||
@@ -42,3 +46,3 @@ * Fetches the TransactionReceipt via polling. | ||
*/ | ||
pollForReceipt({ commitment, ...retryOpts }?: Omit<TransactionWaitOptions, "useWebsocket">): Promise<TransactionReceipt>; | ||
pollForReceipt({ commitment, maxSupportedTransactionVersion, ...retryOpts }?: Omit<TransactionWaitOptions, "useWebsocket">): Promise<TransactionReceipt>; | ||
/** | ||
@@ -45,0 +49,0 @@ * Awaits the confirmation of the transaction, via onSignature subscription. |
@@ -25,3 +25,3 @@ import promiseRetry from "promise-retry"; | ||
*/ | ||
async wait({ commitment = "confirmed", useWebsocket = true, ...retryOpts } = {}) { | ||
async wait({ commitment = "confirmed", maxSupportedTransactionVersion = 0, useWebsocket = true, ...retryOpts } = {}) { | ||
if (this._receipt) { | ||
@@ -32,5 +32,12 @@ return this._receipt; | ||
await this.confirm({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ commitment }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
} | ||
return await this.pollForReceipt({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
...retryOpts, | ||
}); | ||
} | ||
@@ -41,6 +48,7 @@ /** | ||
*/ | ||
async pollForReceipt({ commitment = "confirmed", ...retryOpts } = {}) { | ||
async pollForReceipt({ commitment = "confirmed", maxSupportedTransactionVersion = 0, ...retryOpts } = {}) { | ||
const receipt = await promiseRetry(async (retry) => { | ||
const result = await this.connection.getTransaction(this.signature, { | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
@@ -47,0 +55,0 @@ if (!result) { |
@@ -1,2 +0,2 @@ | ||
import type { Cluster, TransactionResponse, TransactionSignature } from "@solana/web3.js"; | ||
import type { Cluster, TransactionResponse, TransactionSignature, VersionedTransactionResponse } from "@solana/web3.js"; | ||
import type { Event, EventParser } from "../interfaces.js"; | ||
@@ -28,3 +28,3 @@ import type { PromiseOrValue } from "../utils/misc.js"; | ||
*/ | ||
readonly response: TransactionResponse; | ||
readonly response: TransactionResponse | VersionedTransactionResponse; | ||
constructor( | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
response: TransactionResponse); | ||
response: TransactionResponse | VersionedTransactionResponse); | ||
/** | ||
@@ -41,0 +41,0 @@ * Gets the events associated with this transaction. |
@@ -0,1 +1,2 @@ | ||
import type { PublicKey } from "./publicKey"; | ||
export * from "@saberhq/option-utils"; | ||
@@ -21,2 +22,8 @@ /** | ||
export declare const valueAsPromise: <T>(awaitable: PromiseOrValue<T>) => Promise<T>; | ||
/** | ||
* Shortens a pubkey. | ||
* @param pubkey | ||
* @returns | ||
*/ | ||
export declare const formatPubkeyShort: (pubkey: PublicKey, leading?: number, trailing?: number) => string; | ||
//# sourceMappingURL=misc.d.ts.map |
@@ -51,2 +51,13 @@ export * from "@saberhq/option-utils"; | ||
}; | ||
/** | ||
* Shortens a pubkey. | ||
* @param pubkey | ||
* @returns | ||
*/ | ||
export const formatPubkeyShort = (pubkey, leading = 7, trailing = 7) => { | ||
const str = pubkey.toString(); | ||
return str.length > 20 | ||
? `${str.substring(0, leading)}.....${str.substring(str.length - trailing, str.length)}` | ||
: str; | ||
}; | ||
//# sourceMappingURL=misc.js.map |
{ | ||
"name": "@saberhq/solana-contrib", | ||
"version": "1.14.9", | ||
"version": "1.14.10", | ||
"description": "Common types and libraries for Solana", | ||
@@ -29,3 +29,3 @@ "homepage": "https://github.com/saber-hq/saber-common/tree/master/packages/solana-contrib#readme", | ||
"dependencies": { | ||
"@saberhq/option-utils": "^1.14.9", | ||
"@saberhq/option-utils": "^1.14.10", | ||
"@solana/buffer-layout": "^4.0.0", | ||
@@ -32,0 +32,0 @@ "@types/promise-retry": "^1.1.3", |
@@ -29,2 +29,6 @@ import type { | ||
readonly useWebsocket?: boolean; | ||
/** | ||
* Max supported transaction version. Pass `undefined` to only support `legacy` transactions. | ||
*/ | ||
readonly maxSupportedTransactionVersion?: number; | ||
} | ||
@@ -58,2 +62,3 @@ | ||
commitment = "confirmed", | ||
maxSupportedTransactionVersion = 0, | ||
useWebsocket = true, | ||
@@ -67,5 +72,12 @@ ...retryOpts | ||
await this.confirm({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ commitment }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
} | ||
return await this.pollForReceipt({ commitment, ...retryOpts }); | ||
return await this.pollForReceipt({ | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
...retryOpts, | ||
}); | ||
} | ||
@@ -79,2 +91,3 @@ | ||
commitment = "confirmed", | ||
maxSupportedTransactionVersion = 0, | ||
...retryOpts | ||
@@ -89,2 +102,3 @@ }: Omit< | ||
commitment, | ||
maxSupportedTransactionVersion, | ||
}); | ||
@@ -91,0 +105,0 @@ if (!result) { |
@@ -5,2 +5,3 @@ import type { | ||
TransactionSignature, | ||
VersionedTransactionResponse, | ||
} from "@solana/web3.js"; | ||
@@ -61,3 +62,3 @@ import { default as invariant } from "tiny-invariant"; | ||
*/ | ||
readonly response: TransactionResponse | ||
readonly response: TransactionResponse | VersionedTransactionResponse | ||
) {} | ||
@@ -64,0 +65,0 @@ |
@@ -0,1 +1,3 @@ | ||
import type { PublicKey } from "./publicKey"; | ||
export * from "@saberhq/option-utils"; | ||
@@ -63,1 +65,20 @@ | ||
}; | ||
/** | ||
* Shortens a pubkey. | ||
* @param pubkey | ||
* @returns | ||
*/ | ||
export const formatPubkeyShort = ( | ||
pubkey: PublicKey, | ||
leading = 7, | ||
trailing = 7 | ||
): string => { | ||
const str = pubkey.toString(); | ||
return str.length > 20 | ||
? `${str.substring(0, leading)}.....${str.substring( | ||
str.length - trailing, | ||
str.length | ||
)}` | ||
: str; | ||
}; |
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
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
856461
11180