@streamflow/common 8.0.1-alpha.p287.54fe41f → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/solana/index.cjs +32 -149
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +17 -75
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/index.d.ts +17 -75
- package/dist/esm/solana/index.js +34 -145
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +3 -11
- package/dist/cjs/solana/rpc/index.cjs +0 -137
- package/dist/cjs/solana/rpc/index.cjs.map +0 -1
- package/dist/cjs/solana/rpc/index.d.cts +0 -113
- package/dist/esm/solana/rpc/index.d.ts +0 -113
- package/dist/esm/solana/rpc/index.js +0 -133
- package/dist/esm/solana/rpc/index.js.map +0 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var ContractError = class _ContractError extends Error {
|
|
|
31
31
|
* @param code extracted code from the error if managed to parse it
|
|
32
32
|
*/
|
|
33
33
|
constructor(error, code, description) {
|
|
34
|
-
super(error.message
|
|
34
|
+
super(error.message);
|
|
35
35
|
this.contractErrorCode = code ?? null;
|
|
36
36
|
this.description = description ?? null;
|
|
37
37
|
Object.setPrototypeOf(this, _ContractError.prototype);
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../types.ts","../../lib/assertions.ts","../../lib/utils.ts"],"names":["ICluster","IChain","BN"],"mappings":";;;;;;;;;;AAQY,IAAA,QAAA,qBAAAA,SAAL,KAAA;AACL,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,O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A,CAAA,GAAI,MAAO,CAAA,CAAC,CAAI,GAAA,MAAA,CAAO,CAAC,CAAA","file":"index.cjs","sourcesContent":["import { type TransactionInstruction } from \"@solana/web3.js\";\n\nexport interface ITransactionResult {\n ixs: TransactionInstruction[];\n txId: string;\n}\n\n// Utility types\nexport enum ICluster {\n Mainnet = \"mainnet\",\n Devnet = \"devnet\",\n Testnet = \"testnet\",\n Local = \"local\",\n}\n\nexport enum IChain {\n Solana = \"Solana\",\n Aptos = \"Aptos\",\n Ethereum = \"Ethereum\",\n BNB = \"BNB\",\n Polygon = \"Polygon\",\n Sui = \"Sui\",\n}\n\n/**\n * Error wrapper for calls made to the contract on chain\n */\nexport class ContractError extends Error {\n public contractErrorCode: string | null;\n\n public description: string | null;\n\n /**\n * Constructs the Error Wrapper\n * @param error Original error raised probably by the chain SDK\n * @param code extracted code from the error if managed to parse it\n */\n constructor(error: Error, code?: string | null, description?: string | null) {\n super(error.message); // Call the base class constructor with the error message\n this.contractErrorCode = code ?? null;\n this.description = description ?? null;\n // Copy properties from the original error\n Object.setPrototypeOf(this, ContractError.prototype);\n this.name = \"ContractError\"; // Set the name property\n this.stack = error.stack;\n }\n}\n","const prefix = \"Assertion failed\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const invariant: (condition: any, message?: string | (() => string)) => asserts condition = (\n condition,\n message,\n) => {\n if (condition) {\n return;\n }\n const provided: string | undefined = typeof message === \"function\" ? message() : message;\n const value: string = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n};\n","import BN from \"bn.js\";\n\nimport { ContractError } from \"../types.js\";\n\n/**\n * Used for conversion of token amounts to their Big Number representation.\n * Get Big Number representation in the smallest units from the same value in the highest units.\n * @param {number} value - Number of tokens you want to convert to its BN representation.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getBN = (value: number, decimals: number): BN => {\n const decimalPart = value - Math.trunc(value);\n const integerPart = new BN(Math.trunc(value));\n\n const decimalE = new BN(decimalPart * 1e9);\n\n const sum = integerPart.mul(new BN(1e9)).add(decimalE);\n const resultE = sum.mul(new BN(10).pow(new BN(decimals)));\n return resultE.div(new BN(1e9));\n};\n\n/**\n * Used for token amounts conversion from their Big Number representation to number.\n * Get value in the highest units from BN representation of the same value in the smallest units.\n * @param {BN} value - Big Number representation of value in the smallest units.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getNumberFromBN = (value: BN, decimals: number): number =>\n value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;\n\n/**\n * Used to make on chain calls to the contract and wrap raised errors if any\n * @param func function that interacts with the contract\n * @param callback callback that may be used to extract error code\n * @returns {T}\n */\nexport async function handleContractError<T>(\n func: () => Promise<T>,\n callback?: (err: Error) => string | null,\n): Promise<T> {\n try {\n return await func();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n if (err instanceof Error) {\n if (callback) {\n throw new ContractError(err, callback(err));\n }\n throw new ContractError(err);\n }\n throw err;\n }\n}\n\n/**\n * Pause async function execution for given amount of milliseconds\n * @param ms millisecond to sleep for\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport const divCeilN = (n: bigint, d: bigint): bigint => n / d + (n % d ? BigInt(1) : BigInt(0));\n"]}
|
|
@@ -4,7 +4,6 @@ var splToken = require('@solana/spl-token');
|
|
|
4
4
|
var web3_js = require('@solana/web3.js');
|
|
5
5
|
var bs58 = require('bs58');
|
|
6
6
|
require('bn.js');
|
|
7
|
-
var buffer = require('buffer');
|
|
8
7
|
|
|
9
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
|
|
@@ -58,12 +57,12 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
58
57
|
var require_eventemitter3 = __commonJS({
|
|
59
58
|
"../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js"(exports, module) {
|
|
60
59
|
var has = Object.prototype.hasOwnProperty;
|
|
61
|
-
var
|
|
60
|
+
var prefix = "~";
|
|
62
61
|
function Events() {
|
|
63
62
|
}
|
|
64
63
|
if (Object.create) {
|
|
65
64
|
Events.prototype = /* @__PURE__ */ Object.create(null);
|
|
66
|
-
if (!new Events().__proto__)
|
|
65
|
+
if (!new Events().__proto__) prefix = false;
|
|
67
66
|
}
|
|
68
67
|
function EE(fn, context, once) {
|
|
69
68
|
this.fn = fn;
|
|
@@ -74,7 +73,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
74
73
|
if (typeof fn !== "function") {
|
|
75
74
|
throw new TypeError("The listener must be a function");
|
|
76
75
|
}
|
|
77
|
-
var listener = new EE(fn, context || emitter, once), evt =
|
|
76
|
+
var listener = new EE(fn, context || emitter, once), evt = prefix ? prefix + event : event;
|
|
78
77
|
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
|
|
79
78
|
else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
|
|
80
79
|
else emitter._events[evt] = [emitter._events[evt], listener];
|
|
@@ -92,7 +91,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
92
91
|
var names = [], events, name;
|
|
93
92
|
if (this._eventsCount === 0) return names;
|
|
94
93
|
for (name in events = this._events) {
|
|
95
|
-
if (has.call(events, name)) names.push(
|
|
94
|
+
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
|
|
96
95
|
}
|
|
97
96
|
if (Object.getOwnPropertySymbols) {
|
|
98
97
|
return names.concat(Object.getOwnPropertySymbols(events));
|
|
@@ -100,7 +99,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
100
99
|
return names;
|
|
101
100
|
};
|
|
102
101
|
EventEmitter2.prototype.listeners = function listeners(event) {
|
|
103
|
-
var evt =
|
|
102
|
+
var evt = prefix ? prefix + event : event, handlers = this._events[evt];
|
|
104
103
|
if (!handlers) return [];
|
|
105
104
|
if (handlers.fn) return [handlers.fn];
|
|
106
105
|
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
|
|
@@ -109,13 +108,13 @@ var require_eventemitter3 = __commonJS({
|
|
|
109
108
|
return ee;
|
|
110
109
|
};
|
|
111
110
|
EventEmitter2.prototype.listenerCount = function listenerCount(event) {
|
|
112
|
-
var evt =
|
|
111
|
+
var evt = prefix ? prefix + event : event, listeners = this._events[evt];
|
|
113
112
|
if (!listeners) return 0;
|
|
114
113
|
if (listeners.fn) return 1;
|
|
115
114
|
return listeners.length;
|
|
116
115
|
};
|
|
117
116
|
EventEmitter2.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
|
|
118
|
-
var evt =
|
|
117
|
+
var evt = prefix ? prefix + event : event;
|
|
119
118
|
if (!this._events[evt]) return false;
|
|
120
119
|
var listeners = this._events[evt], len = arguments.length, args, i;
|
|
121
120
|
if (listeners.fn) {
|
|
@@ -172,7 +171,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
172
171
|
return addListener(this, event, fn, context, true);
|
|
173
172
|
};
|
|
174
173
|
EventEmitter2.prototype.removeListener = function removeListener(event, fn, context, once) {
|
|
175
|
-
var evt =
|
|
174
|
+
var evt = prefix ? prefix + event : event;
|
|
176
175
|
if (!this._events[evt]) return this;
|
|
177
176
|
if (!fn) {
|
|
178
177
|
clearEvent(this, evt);
|
|
@@ -197,7 +196,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
197
196
|
EventEmitter2.prototype.removeAllListeners = function removeAllListeners(event) {
|
|
198
197
|
var evt;
|
|
199
198
|
if (event) {
|
|
200
|
-
evt =
|
|
199
|
+
evt = prefix ? prefix + event : event;
|
|
201
200
|
if (this._events[evt]) clearEvent(this, evt);
|
|
202
201
|
} else {
|
|
203
202
|
this._events = new Events();
|
|
@@ -207,7 +206,7 @@ var require_eventemitter3 = __commonJS({
|
|
|
207
206
|
};
|
|
208
207
|
EventEmitter2.prototype.off = EventEmitter2.prototype.removeListener;
|
|
209
208
|
EventEmitter2.prototype.addListener = EventEmitter2.prototype.on;
|
|
210
|
-
EventEmitter2.prefixed =
|
|
209
|
+
EventEmitter2.prefixed = prefix;
|
|
211
210
|
EventEmitter2.EventEmitter = EventEmitter2;
|
|
212
211
|
if ("undefined" !== typeof module) {
|
|
213
212
|
module.exports = EventEmitter2;
|
|
@@ -245,6 +244,9 @@ var prepareWrappedAccount = async (connection, senderAddress, amount) => {
|
|
|
245
244
|
splToken.createSyncNativeInstruction(tokenAccount)
|
|
246
245
|
];
|
|
247
246
|
};
|
|
247
|
+
var pk = (address) => {
|
|
248
|
+
return typeof address === "string" ? new web3_js.PublicKey(address) : address;
|
|
249
|
+
};
|
|
248
250
|
|
|
249
251
|
// solana/types.ts
|
|
250
252
|
var TransactionFailedError = class _TransactionFailedError extends Error {
|
|
@@ -709,17 +711,6 @@ function sleep(ms) {
|
|
|
709
711
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
710
712
|
}
|
|
711
713
|
|
|
712
|
-
// lib/assertions.ts
|
|
713
|
-
var prefix = "Assertion failed";
|
|
714
|
-
var invariant = (condition, message) => {
|
|
715
|
-
if (condition) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
const provided = typeof message === "function" ? message() : message;
|
|
719
|
-
const value = provided ? `${prefix}: ${provided}` : prefix;
|
|
720
|
-
throw new Error(value);
|
|
721
|
-
};
|
|
722
|
-
|
|
723
714
|
// solana/utils.ts
|
|
724
715
|
var SIMULATE_TRIES = 3;
|
|
725
716
|
var buildSendThrottler = (sendRate, sendInterval = 1e3) => {
|
|
@@ -747,30 +738,20 @@ function isSignerKeypair(walletOrKeypair) {
|
|
|
747
738
|
function isTransactionVersioned(tx) {
|
|
748
739
|
return "message" in tx;
|
|
749
740
|
}
|
|
750
|
-
async function prepareTransaction(connection, ixs, payer, commitment, partialSigners) {
|
|
741
|
+
async function prepareTransaction(connection, ixs, payer, commitment, ...partialSigners) {
|
|
751
742
|
if (!payer) {
|
|
752
743
|
throw new Error("Payer public key is not provided!");
|
|
753
744
|
}
|
|
754
745
|
const { value: hash, context } = await connection.getLatestBlockhashAndContext(commitment);
|
|
755
|
-
return {
|
|
756
|
-
tx: createVersionedTransaction(ixs, payer, hash.blockhash, partialSigners),
|
|
757
|
-
hash,
|
|
758
|
-
context
|
|
759
|
-
};
|
|
760
|
-
}
|
|
761
|
-
function createVersionedTransaction(ixs, payer, recentBlockhash, partialSigners) {
|
|
762
|
-
invariant(payer, "Payer public key is not provided!");
|
|
763
746
|
const messageV0 = new web3_js.TransactionMessage({
|
|
764
747
|
payerKey: payer,
|
|
765
|
-
recentBlockhash,
|
|
748
|
+
recentBlockhash: hash.blockhash,
|
|
766
749
|
instructions: ixs
|
|
767
750
|
}).compileToV0Message();
|
|
768
751
|
const tx = new web3_js.VersionedTransaction(messageV0);
|
|
769
|
-
const signers = partialSigners
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
}
|
|
773
|
-
return tx;
|
|
752
|
+
const signers = partialSigners.filter((item) => !!item);
|
|
753
|
+
tx.sign(signers);
|
|
754
|
+
return { tx, context, hash };
|
|
774
755
|
}
|
|
775
756
|
async function signTransaction(invoker, tx) {
|
|
776
757
|
let signedTx;
|
|
@@ -786,18 +767,16 @@ async function signTransaction(invoker, tx) {
|
|
|
786
767
|
}
|
|
787
768
|
return signedTx;
|
|
788
769
|
}
|
|
789
|
-
async function signAndExecuteTransaction(connection, invoker, tx, confirmationParams,
|
|
770
|
+
async function signAndExecuteTransaction(connection, invoker, tx, confirmationParams, throttleParams) {
|
|
790
771
|
const signedTx = await signTransaction(invoker, tx);
|
|
791
|
-
return executeTransaction(connection, signedTx, confirmationParams,
|
|
772
|
+
return executeTransaction(connection, signedTx, confirmationParams, throttleParams);
|
|
792
773
|
}
|
|
793
|
-
async function executeTransaction(connection, tx, confirmationParams,
|
|
774
|
+
async function executeTransaction(connection, tx, confirmationParams, throttleParams) {
|
|
794
775
|
if (tx.signatures.length === 0) {
|
|
795
776
|
throw Error("Error with transaction parameters.");
|
|
796
777
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
}
|
|
800
|
-
return sendAndConfirmTransaction(connection, tx, confirmationParams, transactionExecutionParams);
|
|
778
|
+
await simulateTransaction(connection, tx);
|
|
779
|
+
return sendAndConfirmTransaction(connection, tx, confirmationParams, throttleParams);
|
|
801
780
|
}
|
|
802
781
|
async function executeMultipleTransactions(connection, txs, confirmationParams, { sendRate = 1, sendThrottler, ...throttlingParams }) {
|
|
803
782
|
if (!sendThrottler) {
|
|
@@ -964,7 +943,13 @@ async function generateCreateAtaBatchTx(connection, payer, paramsBatch, commitme
|
|
|
964
943
|
})
|
|
965
944
|
);
|
|
966
945
|
const { value: hash, context } = await connection.getLatestBlockhashAndContext({ commitment });
|
|
967
|
-
|
|
946
|
+
const messageV0 = new web3_js.TransactionMessage({
|
|
947
|
+
payerKey: payer,
|
|
948
|
+
recentBlockhash: hash.blockhash,
|
|
949
|
+
instructions: ixs
|
|
950
|
+
}).compileToV0Message();
|
|
951
|
+
const tx = new web3_js.VersionedTransaction(messageV0);
|
|
952
|
+
return { tx, hash, context };
|
|
968
953
|
}
|
|
969
954
|
async function createAtaBatch(connection, invoker, paramsBatch, commitment, rate) {
|
|
970
955
|
const { tx, hash, context } = await generateCreateAtaBatchTx(
|
|
@@ -994,10 +979,10 @@ async function checkOrCreateAtaBatch(connection, owners, mint, invoker, programI
|
|
|
994
979
|
}
|
|
995
980
|
function prepareBaseInstructions(connection, { computePrice, computeLimit }) {
|
|
996
981
|
const ixs = [];
|
|
997
|
-
if (computePrice
|
|
982
|
+
if (computePrice) {
|
|
998
983
|
ixs.push(web3_js.ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computePrice }));
|
|
999
984
|
}
|
|
1000
|
-
if (computeLimit
|
|
985
|
+
if (computeLimit) {
|
|
1001
986
|
ixs.push(web3_js.ComputeBudgetProgram.setComputeUnitLimit({ units: computeLimit }));
|
|
1002
987
|
}
|
|
1003
988
|
return ixs;
|
|
@@ -1023,102 +1008,6 @@ async function getMultipleAccountsInfoBatched(connection, pubKeys, commitment) {
|
|
|
1023
1008
|
const results = await Promise.all(batches);
|
|
1024
1009
|
return results.flat();
|
|
1025
1010
|
}
|
|
1026
|
-
function deserializeRawTransaction(serializedTx) {
|
|
1027
|
-
const txBuffer = buffer.Buffer.from(serializedTx, "base64");
|
|
1028
|
-
try {
|
|
1029
|
-
const tx = web3_js.Transaction.from(txBuffer);
|
|
1030
|
-
return resolveTransactionAccounts(tx);
|
|
1031
|
-
} catch (error) {
|
|
1032
|
-
try {
|
|
1033
|
-
const vtx = web3_js.VersionedTransaction.deserialize(txBuffer);
|
|
1034
|
-
return resolveTransactionAccounts(vtx);
|
|
1035
|
-
} catch (vError) {
|
|
1036
|
-
throw new Error("Failed to deserialize transaction: " + (vError instanceof Error ? vError.message : vError), {
|
|
1037
|
-
cause: vError
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
var resolveTransactionAccounts = (tx) => {
|
|
1043
|
-
if (tx instanceof web3_js.Transaction) {
|
|
1044
|
-
const message2 = tx.compileMessage();
|
|
1045
|
-
const accounts2 = message2.accountKeys;
|
|
1046
|
-
const writableAccounts2 = accounts2.filter((_, idx) => message2.isAccountWritable(idx));
|
|
1047
|
-
return {
|
|
1048
|
-
type: "legacy",
|
|
1049
|
-
transaction: tx,
|
|
1050
|
-
accounts: accounts2,
|
|
1051
|
-
writableAccounts: writableAccounts2
|
|
1052
|
-
};
|
|
1053
|
-
}
|
|
1054
|
-
const message = tx.message;
|
|
1055
|
-
const accounts = "staticAccountKeys" in message ? message.staticAccountKeys : message.accountKeys;
|
|
1056
|
-
const writableAccounts = accounts.filter((_, idx) => message.isAccountWritable(idx));
|
|
1057
|
-
return {
|
|
1058
|
-
type: "versioned",
|
|
1059
|
-
transaction: tx,
|
|
1060
|
-
accounts,
|
|
1061
|
-
writableAccounts
|
|
1062
|
-
};
|
|
1063
|
-
};
|
|
1064
|
-
var pk = (address) => {
|
|
1065
|
-
return typeof address === "string" ? new web3_js.PublicKey(address) : address;
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// solana/lib/estimate.ts
|
|
1069
|
-
var createTestTransaction = (ixs, payer, recentBlockhash, partialSigners) => {
|
|
1070
|
-
return createVersionedTransaction(ixs, payer, "11111111111111111111111111111111", partialSigners);
|
|
1071
|
-
};
|
|
1072
|
-
async function estimateComputeUnitPrice(estimate, testTx) {
|
|
1073
|
-
return estimate(resolveTransactionAccounts(testTx).writableAccounts);
|
|
1074
|
-
}
|
|
1075
|
-
async function createAndEstimateTransaction(createFn, extParams, select) {
|
|
1076
|
-
select = select ?? ((value) => value);
|
|
1077
|
-
const createResult = await createFn(extParams);
|
|
1078
|
-
const prepareIxs = select(createResult);
|
|
1079
|
-
const { computePrice, computeLimit } = extParams;
|
|
1080
|
-
const invoker = extParams.invoker.publicKey;
|
|
1081
|
-
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
1082
|
-
const testTx = createTestTransaction(prepareIxs, pk(invoker), void 0, void 0);
|
|
1083
|
-
const estimatedComputeLimit = typeof computeLimit === "function" ? await computeLimit(testTx) : computeLimit;
|
|
1084
|
-
if (typeof computePrice !== "function") {
|
|
1085
|
-
if (typeof computeLimit !== "function") {
|
|
1086
|
-
return createResult;
|
|
1087
|
-
}
|
|
1088
|
-
return createFn({
|
|
1089
|
-
...extParams,
|
|
1090
|
-
computeLimit: estimatedComputeLimit
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
const estimatedComputeUnitPrice = typeof computePrice === "function" ? await estimateComputeUnitPrice(computePrice, testTx) : (
|
|
1094
|
-
// unachievable because we don't execute estimation for constant or undefined priority fee
|
|
1095
|
-
computePrice
|
|
1096
|
-
);
|
|
1097
|
-
return createFn({
|
|
1098
|
-
...extParams,
|
|
1099
|
-
computePrice: estimatedComputeUnitPrice,
|
|
1100
|
-
computeLimit: estimatedComputeLimit
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
// solana/rpc/consume-limit-estimate/estimate.ts
|
|
1105
|
-
var estimateConsumeLimit = async (connection, tx, options = {}) => {
|
|
1106
|
-
const { multiplierPercent = 0.05 } = options;
|
|
1107
|
-
const simulationResults = await connection.simulateTransaction(tx, {
|
|
1108
|
-
sigVerify: false,
|
|
1109
|
-
replaceRecentBlockhash: true
|
|
1110
|
-
});
|
|
1111
|
-
return {
|
|
1112
|
-
unitsConsumed: simulationResults.value.unitsConsumed ? Math.ceil(simulationResults.value.unitsConsumed * (1 + multiplierPercent)) : simulationResults.value.unitsConsumed,
|
|
1113
|
-
data: simulationResults
|
|
1114
|
-
};
|
|
1115
|
-
};
|
|
1116
|
-
|
|
1117
|
-
// solana/lib/unwrap-auto-simulate-ext.ts
|
|
1118
|
-
var unwrapExecutionParams = ({ computeLimit, ...rest }, connection) => {
|
|
1119
|
-
const consumeLimitFn = computeLimit === "autoSimulate" ? (tx) => estimateConsumeLimit(connection, tx).then((limit) => limit.unitsConsumed ?? 0) : computeLimit;
|
|
1120
|
-
return { ...rest, computeLimit: consumeLimitFn, skipSimulation: computeLimit === "autoSimulate" };
|
|
1121
|
-
};
|
|
1122
1011
|
|
|
1123
1012
|
exports.TransactionFailedError = TransactionFailedError;
|
|
1124
1013
|
exports.ata = ata;
|
|
@@ -1126,12 +1015,8 @@ exports.ataBatchExist = ataBatchExist;
|
|
|
1126
1015
|
exports.buildSendThrottler = buildSendThrottler;
|
|
1127
1016
|
exports.checkOrCreateAtaBatch = checkOrCreateAtaBatch;
|
|
1128
1017
|
exports.confirmAndEnsureTransaction = confirmAndEnsureTransaction;
|
|
1129
|
-
exports.createAndEstimateTransaction = createAndEstimateTransaction;
|
|
1130
1018
|
exports.createAtaBatch = createAtaBatch;
|
|
1131
|
-
exports.createVersionedTransaction = createVersionedTransaction;
|
|
1132
|
-
exports.deserializeRawTransaction = deserializeRawTransaction;
|
|
1133
1019
|
exports.enrichAtaParams = enrichAtaParams;
|
|
1134
|
-
exports.estimateComputeUnitPrice = estimateComputeUnitPrice;
|
|
1135
1020
|
exports.executeMultipleTransactions = executeMultipleTransactions;
|
|
1136
1021
|
exports.executeTransaction = executeTransaction;
|
|
1137
1022
|
exports.generateCreateAtaBatchTx = generateCreateAtaBatchTx;
|
|
@@ -1146,11 +1031,9 @@ exports.pk = pk;
|
|
|
1146
1031
|
exports.prepareBaseInstructions = prepareBaseInstructions;
|
|
1147
1032
|
exports.prepareTransaction = prepareTransaction;
|
|
1148
1033
|
exports.prepareWrappedAccount = prepareWrappedAccount;
|
|
1149
|
-
exports.resolveTransactionAccounts = resolveTransactionAccounts;
|
|
1150
1034
|
exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
|
|
1151
1035
|
exports.signAndExecuteTransaction = signAndExecuteTransaction;
|
|
1152
1036
|
exports.signTransaction = signTransaction;
|
|
1153
1037
|
exports.simulateTransaction = simulateTransaction;
|
|
1154
|
-
exports.unwrapExecutionParams = unwrapExecutionParams;
|
|
1155
1038
|
//# sourceMappingURL=index.cjs.map
|
|
1156
1039
|
//# sourceMappingURL=index.cjs.map
|