@helium/spl-utils
Advanced tools
Comparing version 0.6.11 to 0.6.12-next.0
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.proofArgsAndAccounts = exports.estimatePrioritizationFee = exports.getAssetProofBatch = exports.getAssetBatch = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0; | ||
exports.proofArgsAndAccounts = exports.withPriorityFees = exports.estimatePrioritizationFee = exports.getAssetProofBatch = exports.getAssetBatch = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0; | ||
__exportStar(require("./extendBorsh"), exports); | ||
@@ -36,4 +36,5 @@ __exportStar(require("./transaction"), exports); | ||
Object.defineProperty(exports, "estimatePrioritizationFee", { enumerable: true, get: function () { return priorityFees_1.estimatePrioritizationFee; } }); | ||
Object.defineProperty(exports, "withPriorityFees", { enumerable: true, get: function () { return priorityFees_1.withPriorityFees; } }); | ||
var proofArgsAndAccounts_1 = require("./proofArgsAndAccounts"); | ||
Object.defineProperty(exports, "proofArgsAndAccounts", { enumerable: true, get: function () { return proofArgsAndAccounts_1.proofArgsAndAccounts; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.proofArgsAndAccounts = exports.estimatePrioritizationFee = exports.getAssetProofBatch = exports.getAssetBatch = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0; | ||
exports.proofArgsAndAccounts = exports.withPriorityFees = exports.estimatePrioritizationFee = exports.getAssetProofBatch = exports.getAssetBatch = exports.searchAssets = exports.getAssetsByOwner = exports.getAssetProof = exports.getAssets = exports.getAsset = void 0; | ||
__exportStar(require("./extendBorsh"), exports); | ||
@@ -36,4 +36,5 @@ __exportStar(require("./transaction"), exports); | ||
Object.defineProperty(exports, "estimatePrioritizationFee", { enumerable: true, get: function () { return priorityFees_1.estimatePrioritizationFee; } }); | ||
Object.defineProperty(exports, "withPriorityFees", { enumerable: true, get: function () { return priorityFees_1.withPriorityFees; } }); | ||
var proofArgsAndAccounts_1 = require("./proofArgsAndAccounts"); | ||
Object.defineProperty(exports, "proofArgsAndAccounts", { enumerable: true, get: function () { return proofArgsAndAccounts_1.proofArgsAndAccounts; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.estimatePrioritizationFee = void 0; | ||
exports.withPriorityFees = exports.estimatePrioritizationFee = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
@@ -25,3 +25,3 @@ const MAX_RECENT_PRIORITY_FEE_ACCOUNTS = 128; | ||
*/ | ||
function estimatePrioritizationFee(connection, ixs) { | ||
function estimatePrioritizationFee(connection, ixs, basePriorityFee) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -40,3 +40,3 @@ const writableAccounts = ixs | ||
if (priorityFees.length < 1) { | ||
return 1; | ||
return Math.max(basePriorityFee || 0, 1); | ||
} | ||
@@ -67,6 +67,21 @@ // get max priority fee per slot (and sort by slot from old to new) | ||
2; | ||
return Math.max(1, Math.ceil(medianFee)); | ||
return Math.max(basePriorityFee || 1, Math.ceil(medianFee)); | ||
}); | ||
} | ||
exports.estimatePrioritizationFee = estimatePrioritizationFee; | ||
function withPriorityFees({ connection, computeUnits, instructions, basePriorityFee }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const estimate = yield estimatePrioritizationFee(connection, instructions, basePriorityFee); | ||
return [ | ||
web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ | ||
units: computeUnits, | ||
}), | ||
web3_js_1.ComputeBudgetProgram.setComputeUnitPrice({ | ||
microLamports: estimate, | ||
}), | ||
...instructions, | ||
]; | ||
}); | ||
} | ||
exports.withPriorityFees = withPriorityFees; | ||
//# sourceMappingURL=priorityFees.js.map |
@@ -9,4 +9,4 @@ export * from './extendBorsh'; | ||
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, getAssetBatch, getAssetProofBatch, } from './mplAssetAPI'; | ||
export { estimatePrioritizationFee } from "./priorityFees"; | ||
export { estimatePrioritizationFee, withPriorityFees } from "./priorityFees"; | ||
export { proofArgsAndAccounts } from './proofArgsAndAccounts'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { PublicKey, } from "@solana/web3.js"; | ||
import { ComputeBudgetProgram, PublicKey, } from "@solana/web3.js"; | ||
const MAX_RECENT_PRIORITY_FEE_ACCOUNTS = 128; | ||
@@ -12,3 +12,3 @@ // Borrowed with love from https://github.com/blockworks-foundation/mango-v4/blob/57a9835aa8f636b6d231ba2c4008bfe89cbf08ba/ts/client/src/client.ts#L4552 | ||
*/ | ||
export async function estimatePrioritizationFee(connection, ixs) { | ||
export async function estimatePrioritizationFee(connection, ixs, basePriorityFee) { | ||
const writableAccounts = ixs | ||
@@ -26,3 +26,3 @@ .map((x) => x.keys.filter((a) => a.isWritable).map((k) => k.pubkey)) | ||
if (priorityFees.length < 1) { | ||
return 1; | ||
return Math.max(basePriorityFee || 0, 1); | ||
} | ||
@@ -53,4 +53,16 @@ // get max priority fee per slot (and sort by slot from old to new) | ||
2; | ||
return Math.max(1, Math.ceil(medianFee)); | ||
return Math.max(basePriorityFee || 1, Math.ceil(medianFee)); | ||
} | ||
export async function withPriorityFees({ connection, computeUnits, instructions, basePriorityFee }) { | ||
const estimate = await estimatePrioritizationFee(connection, instructions, basePriorityFee); | ||
return [ | ||
ComputeBudgetProgram.setComputeUnitLimit({ | ||
units: computeUnits, | ||
}), | ||
ComputeBudgetProgram.setComputeUnitPrice({ | ||
microLamports: estimate, | ||
}), | ||
...instructions, | ||
]; | ||
} | ||
//# sourceMappingURL=priorityFees.js.map |
@@ -10,5 +10,5 @@ export * from './extendBorsh'; | ||
export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, getAssetBatch, getAssetProofBatch, } from './mplAssetAPI'; | ||
export { estimatePrioritizationFee } from "./priorityFees"; | ||
export { estimatePrioritizationFee, withPriorityFees } from "./priorityFees"; | ||
export { proofArgsAndAccounts } from './proofArgsAndAccounts'; | ||
export type { ProofArgsAndAccountsArgs } from './proofArgsAndAccounts'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -10,3 +10,9 @@ import { Connection, TransactionInstruction } from "@solana/web3.js"; | ||
*/ | ||
export declare function estimatePrioritizationFee(connection: Connection, ixs: TransactionInstruction[]): Promise<number>; | ||
export declare function estimatePrioritizationFee(connection: Connection, ixs: TransactionInstruction[], basePriorityFee?: number): Promise<number>; | ||
export declare function withPriorityFees({ connection, computeUnits, instructions, basePriorityFee }: { | ||
connection: Connection; | ||
computeUnits: number; | ||
instructions: TransactionInstruction[]; | ||
basePriorityFee?: number; | ||
}): Promise<TransactionInstruction[]>; | ||
//# sourceMappingURL=priorityFees.d.ts.map |
{ | ||
"name": "@helium/spl-utils", | ||
"version": "0.6.11", | ||
"version": "0.6.12-next.0+c50f3444", | ||
"description": "Utils shared across spl suite", | ||
@@ -35,5 +35,5 @@ "publishConfig": { | ||
"@coral-xyz/anchor": "^0.28.0", | ||
"@helium/account-fetch-cache": "^0.6.11", | ||
"@helium/account-fetch-cache": "^0.6.12-next.0+c50f3444", | ||
"@helium/address": "^4.10.2", | ||
"@helium/anchor-resolvers": "^0.6.11", | ||
"@helium/anchor-resolvers": "^0.6.12-next.0+c50f3444", | ||
"@metaplex-foundation/mpl-token-metadata": "^2.10.0", | ||
@@ -53,3 +53,3 @@ "@solana/spl-account-compression": "^0.1.7", | ||
}, | ||
"gitHead": "22c90e050346c1064f9cc9985488b6221b2bd71f" | ||
"gitHead": "c50f3444f532ba21711a1356a7b73999d9ee256b" | ||
} |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
401007
3683
1