@xyo-network/xl1-protocol-sdk 1.29.5 → 1.29.7
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/neutral/index.mjs
CHANGED
|
@@ -5022,6 +5022,9 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5022
5022
|
get transactionValidationViewer() {
|
|
5023
5023
|
return this._transactionValidationViewer;
|
|
5024
5024
|
}
|
|
5025
|
+
get validateOnSubmit() {
|
|
5026
|
+
return this.params.validateOnSubmit ?? true;
|
|
5027
|
+
}
|
|
5025
5028
|
static async paramsHandler(params) {
|
|
5026
5029
|
return {
|
|
5027
5030
|
...await super.paramsHandler(params),
|
|
@@ -5175,19 +5178,36 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5175
5178
|
async submitTransactions(transactions) {
|
|
5176
5179
|
const headNumber = await this.finalizationViewer.headNumber();
|
|
5177
5180
|
const maxExp = headNumber + this.maxExpAhead;
|
|
5178
|
-
const
|
|
5181
|
+
const expValid = transactions.filter(([tx]) => {
|
|
5179
5182
|
if (tx.exp > maxExp) {
|
|
5180
5183
|
this.logger?.debug(`Rejecting transaction with exp ${tx.exp} exceeding max allowed ${maxExp}`);
|
|
5181
5184
|
return false;
|
|
5182
5185
|
}
|
|
5183
5186
|
return true;
|
|
5184
5187
|
});
|
|
5185
|
-
const
|
|
5186
|
-
|
|
5188
|
+
const hashedTransactions = await Promise.all(
|
|
5189
|
+
expValid.map(async ([tx, payloads]) => [
|
|
5187
5190
|
await PayloadBuilder21.addHashMeta(tx),
|
|
5188
5191
|
await PayloadBuilder21.addHashMeta(payloads)
|
|
5189
|
-
])
|
|
5190
|
-
|
|
5192
|
+
])
|
|
5193
|
+
);
|
|
5194
|
+
if (this.validateOnSubmit) {
|
|
5195
|
+
const validationResults = await Promise.all(
|
|
5196
|
+
hashedTransactions.map(async (tx) => this.transactionValidationViewer.validateTransaction(tx, { value: true, state: true }))
|
|
5197
|
+
);
|
|
5198
|
+
const failures = [];
|
|
5199
|
+
for (const [i, result] of validationResults.entries()) {
|
|
5200
|
+
if (!isSignedHydratedTransactionWithHashMeta(result)) {
|
|
5201
|
+
failures.push({ tx: hashedTransactions[i], errors: result });
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
if (failures.length > 0) {
|
|
5205
|
+
await Promise.all(failures.map((f) => this.routeRejectedTransaction(f.tx, f.errors)));
|
|
5206
|
+
const detail = failures.map((f) => `${f.tx[0]._hash}: ${f.errors.map((e) => e.message).join("; ")}`).join(" | ");
|
|
5207
|
+
throw new Error(`SimpleMempoolRunner: rejected ${failures.length} transaction(s) at admission: ${detail}`);
|
|
5208
|
+
}
|
|
5209
|
+
}
|
|
5210
|
+
const bundles = hashedTransactions.map((tx) => hydratedTransactionToPayloadBundle(tx));
|
|
5191
5211
|
const inserted = await this.pendingTransactionsArchivist.insert(bundles);
|
|
5192
5212
|
return inserted.map((p) => p._hash);
|
|
5193
5213
|
}
|