@xyo-network/xl1-protocol-sdk 1.29.4 → 1.29.6
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 +27 -6
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/simple/client/SimpleXyoClient.d.ts +3 -2
- package/dist/neutral/simple/client/SimpleXyoClient.d.ts.map +1 -1
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts +12 -0
- package/dist/neutral/simple/mempool/SimpleMempoolRunner.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/neutral/index.mjs
CHANGED
|
@@ -4522,11 +4522,13 @@ SimpleChainContractViewer = __decorateClass([
|
|
|
4522
4522
|
|
|
4523
4523
|
// src/simple/client/SimpleXyoClient.ts
|
|
4524
4524
|
var SimpleXyoClient = class {
|
|
4525
|
+
dataLakes;
|
|
4525
4526
|
gateways;
|
|
4526
4527
|
permissions;
|
|
4527
|
-
constructor(gateways, permissions) {
|
|
4528
|
+
constructor(gateways, permissions, dataLakes) {
|
|
4528
4529
|
this.gateways = gateways;
|
|
4529
4530
|
this.permissions = permissions;
|
|
4531
|
+
this.dataLakes = dataLakes;
|
|
4530
4532
|
}
|
|
4531
4533
|
};
|
|
4532
4534
|
|
|
@@ -5020,6 +5022,9 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5020
5022
|
get transactionValidationViewer() {
|
|
5021
5023
|
return this._transactionValidationViewer;
|
|
5022
5024
|
}
|
|
5025
|
+
get validateOnSubmit() {
|
|
5026
|
+
return this.params.validateOnSubmit ?? true;
|
|
5027
|
+
}
|
|
5023
5028
|
static async paramsHandler(params) {
|
|
5024
5029
|
return {
|
|
5025
5030
|
...await super.paramsHandler(params),
|
|
@@ -5173,19 +5178,35 @@ var SimpleMempoolRunner = class extends AbstractCreatableProvider {
|
|
|
5173
5178
|
async submitTransactions(transactions) {
|
|
5174
5179
|
const headNumber = await this.finalizationViewer.headNumber();
|
|
5175
5180
|
const maxExp = headNumber + this.maxExpAhead;
|
|
5176
|
-
const
|
|
5181
|
+
const expValid = transactions.filter(([tx]) => {
|
|
5177
5182
|
if (tx.exp > maxExp) {
|
|
5178
5183
|
this.logger?.debug(`Rejecting transaction with exp ${tx.exp} exceeding max allowed ${maxExp}`);
|
|
5179
5184
|
return false;
|
|
5180
5185
|
}
|
|
5181
5186
|
return true;
|
|
5182
5187
|
});
|
|
5183
|
-
const
|
|
5184
|
-
|
|
5188
|
+
const hashedTransactions = await Promise.all(
|
|
5189
|
+
expValid.map(async ([tx, payloads]) => [
|
|
5185
5190
|
await PayloadBuilder21.addHashMeta(tx),
|
|
5186
5191
|
await PayloadBuilder21.addHashMeta(payloads)
|
|
5187
|
-
])
|
|
5188
|
-
|
|
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({ hash: hashedTransactions[i][0]._hash, errors: result });
|
|
5202
|
+
}
|
|
5203
|
+
}
|
|
5204
|
+
if (failures.length > 0) {
|
|
5205
|
+
const detail = failures.map((f) => `${f.hash}: ${f.errors.map((e) => e.message).join("; ")}`).join(" | ");
|
|
5206
|
+
throw new Error(`SimpleMempoolRunner: rejected ${failures.length} transaction(s) at admission: ${detail}`);
|
|
5207
|
+
}
|
|
5208
|
+
}
|
|
5209
|
+
const bundles = hashedTransactions.map((tx) => hydratedTransactionToPayloadBundle(tx));
|
|
5189
5210
|
const inserted = await this.pendingTransactionsArchivist.insert(bundles);
|
|
5190
5211
|
return inserted.map((p) => p._hash);
|
|
5191
5212
|
}
|