@xyo-network/xl1-validation 4.0.11 → 4.0.12

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.
Files changed (43) hide show
  1. package/dist/neutral/index.d.ts +1 -3
  2. package/dist/neutral/index.d.ts.map +1 -1
  3. package/dist/neutral/index.mjs +2 -509
  4. package/dist/neutral/index.mjs.map +4 -4
  5. package/package.json +14 -20
  6. package/dist/neutral/block/index.d.ts +0 -2
  7. package/dist/neutral/block/index.d.ts.map +0 -1
  8. package/dist/neutral/block/validators/BlockCumulativeBalanceValidator.d.ts +0 -7
  9. package/dist/neutral/block/validators/BlockCumulativeBalanceValidator.d.ts.map +0 -1
  10. package/dist/neutral/block/validators/index.d.ts +0 -2
  11. package/dist/neutral/block/validators/index.d.ts.map +0 -1
  12. package/dist/neutral/boundwitness/index.d.ts +0 -2
  13. package/dist/neutral/boundwitness/index.d.ts.map +0 -1
  14. package/dist/neutral/boundwitness/validators/BoundWitnessReferences.d.ts +0 -5
  15. package/dist/neutral/boundwitness/validators/BoundWitnessReferences.d.ts.map +0 -1
  16. package/dist/neutral/boundwitness/validators/BoundWitnessSignatures.d.ts +0 -4
  17. package/dist/neutral/boundwitness/validators/BoundWitnessSignatures.d.ts.map +0 -1
  18. package/dist/neutral/boundwitness/validators/index.d.ts +0 -3
  19. package/dist/neutral/boundwitness/validators/index.d.ts.map +0 -1
  20. package/dist/neutral/transaction/index.d.ts +0 -3
  21. package/dist/neutral/transaction/index.d.ts.map +0 -1
  22. package/dist/neutral/transaction/validateTransaction.d.ts +0 -4
  23. package/dist/neutral/transaction/validateTransaction.d.ts.map +0 -1
  24. package/dist/neutral/transaction/validators/SignerAuthorization.d.ts +0 -48
  25. package/dist/neutral/transaction/validators/SignerAuthorization.d.ts.map +0 -1
  26. package/dist/neutral/transaction/validators/TransactionBoundWitnessValidator.d.ts +0 -18
  27. package/dist/neutral/transaction/validators/TransactionBoundWitnessValidator.d.ts.map +0 -1
  28. package/dist/neutral/transaction/validators/TransactionDurationValidator.d.ts +0 -4
  29. package/dist/neutral/transaction/validators/TransactionDurationValidator.d.ts.map +0 -1
  30. package/dist/neutral/transaction/validators/TransactionElevationValidator.d.ts +0 -4
  31. package/dist/neutral/transaction/validators/TransactionElevationValidator.d.ts.map +0 -1
  32. package/dist/neutral/transaction/validators/TransactionFromValidator.d.ts +0 -4
  33. package/dist/neutral/transaction/validators/TransactionFromValidator.d.ts.map +0 -1
  34. package/dist/neutral/transaction/validators/TransactionGasValidator.d.ts +0 -4
  35. package/dist/neutral/transaction/validators/TransactionGasValidator.d.ts.map +0 -1
  36. package/dist/neutral/transaction/validators/TransactionJsonSchemaValidator.d.ts +0 -4
  37. package/dist/neutral/transaction/validators/TransactionJsonSchemaValidator.d.ts.map +0 -1
  38. package/dist/neutral/transaction/validators/TransactionProtocolValidator.d.ts +0 -4
  39. package/dist/neutral/transaction/validators/TransactionProtocolValidator.d.ts.map +0 -1
  40. package/dist/neutral/transaction/validators/TransactionTransfersValidator.d.ts +0 -17
  41. package/dist/neutral/transaction/validators/TransactionTransfersValidator.d.ts.map +0 -1
  42. package/dist/neutral/transaction/validators/index.d.ts +0 -10
  43. package/dist/neutral/transaction/validators/index.d.ts.map +0 -1
@@ -1,4 +1,2 @@
1
- export * from './block/index.ts';
2
- export * from './boundwitness/index.ts';
3
- export * from './transaction/index.ts';
1
+ export * from '@xyo-network/xl1-protocol/validation';
4
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,wBAAwB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,cAAc,sCAAsC,CAAA"}
@@ -1,510 +1,3 @@
1
- // src/block/validators/BlockCumulativeBalanceValidator.ts
2
- import { hexToBigInt } from "@ariestools/sdk";
3
- import {
4
- HydratedBlockStateValidationError,
5
- isTransactionBoundWitnessWithHashMeta,
6
- isTransfer,
7
- XYO_ZERO_ADDRESS
8
- } from "@xyo-network/xl1-protocol-lib";
9
- function maxTransactionFeeCost(tx) {
10
- const {
11
- base,
12
- gasLimit,
13
- priority
14
- } = tx.fees;
15
- return hexToBigInt(base) + hexToBigInt(priority) + hexToBigInt(gasLimit);
16
- }
17
- function accumulateTransferOutflows(payload, txPayloadHashes, outflows) {
18
- if (!txPayloadHashes.has(payload._hash) || !isTransfer(payload)) return;
19
- const { from } = payload;
20
- for (const [to, amount] of Object.entries(payload.transfers)) {
21
- if (to !== from) {
22
- outflows[from] = (outflows[from] ?? 0n) + hexToBigInt(amount);
23
- }
24
- }
25
- }
26
- function accumulateOutflows(transactions, payloads) {
27
- const outflows = {};
28
- for (const tx of transactions) {
29
- const feeCost = maxTransactionFeeCost(tx);
30
- const feePayer = tx.from;
31
- outflows[feePayer] = (outflows[feePayer] ?? 0n) + feeCost;
32
- const txPayloadHashes = new Set(tx.payload_hashes);
33
- for (const payload of payloads) {
34
- accumulateTransferOutflows(payload, txPayloadHashes, outflows);
35
- }
36
- }
37
- return outflows;
38
- }
39
- function BlockCumulativeBalanceValidatorFactory() {
40
- return async (context, hydratedBlock) => {
41
- const [blockBw, payloads] = hydratedBlock;
42
- const transactions = payloads.filter(isTransactionBoundWitnessWithHashMeta);
43
- if (transactions.length === 0) return [];
44
- const outflows = accumulateOutflows(transactions, payloads);
45
- const addresses = Object.keys(outflows);
46
- if (addresses.length === 0) return [];
47
- const balances = await context.accountBalance.accountBalances(addresses);
48
- const chainId = await context.chainIdAtBlockNumber(blockBw.block);
49
- const errors = [];
50
- for (const address of addresses) {
51
- if (address === XYO_ZERO_ADDRESS) continue;
52
- const balance = balances[address] ?? 0n;
53
- const totalOutflow = outflows[address];
54
- if (totalOutflow > balance) {
55
- errors.push(new HydratedBlockStateValidationError(
56
- blockBw._hash,
57
- chainId,
58
- hydratedBlock,
59
- `Cumulative outflow for address ${address} exceeds available balance: outflow ${totalOutflow} > balance ${balance}`
60
- ));
61
- }
62
- }
63
- return errors;
64
- };
65
- }
66
-
67
- // src/boundwitness/validators/BoundWitnessReferences.ts
68
- import { ZERO_HASH } from "@ariestools/sdk";
69
- import { isAnyPayload } from "@xyo-network/sdk";
70
- import { HydratedBoundWitnessValidationError } from "@xyo-network/xl1-protocol-lib";
71
- function getPayloadsFromPayloadArray(payloads, hashes) {
72
- return hashes.map((hash) => payloads.find((payload) => payload._hash === hash || payload._dataHash === hash));
73
- }
74
- var BoundWitnessReferencesValidator = (allowedSchemas) => ([bw, payloadSet]) => {
75
- const errors = [];
76
- try {
77
- const payloads = getPayloadsFromPayloadArray(payloadSet, bw.payload_hashes);
78
- if (payloads.length !== bw.payload_hashes.length) {
79
- errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "unable to locate payloads"));
80
- }
81
- for (const payload of payloads) {
82
- if (isAnyPayload(payload)) {
83
- const payloadHashIndex = bw.payload_hashes.indexOf(payload._hash);
84
- const payloadDataHashIndex = bw.payload_hashes.indexOf(payload._dataHash);
85
- const payloadIndex = Math.max(payloadHashIndex, payloadDataHashIndex);
86
- if (payloadIndex === -1) {
87
- errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "payload hash not found"));
88
- }
89
- const declaredSchema = bw.payload_schemas[payloadIndex];
90
- if (declaredSchema !== payload.schema) {
91
- errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "mismatched schema"));
92
- }
93
- if (allowedSchemas && !allowedSchemas.includes(payload.schema)) {
94
- errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `disallowed schema [${payload.schema}]`));
95
- }
96
- } else {
97
- errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "invalid payload"));
98
- }
99
- }
100
- } catch (ex) {
101
- const error2 = new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `validation excepted: ${String(ex)}`, ex);
102
- errors.push(error2);
103
- }
104
- return errors;
105
- };
106
-
107
- // src/boundwitness/validators/BoundWitnessSignatures.ts
108
- import { toArrayBuffer, ZERO_HASH as ZERO_HASH2 } from "@ariestools/sdk";
109
- import { BoundWitnessBuilder, BoundWitnessValidator } from "@xyo-network/sdk";
110
- import { BoundWitnessValidationError } from "@xyo-network/xl1-protocol-lib";
111
- var BoundWitnessSignaturesValidator = async (bw) => {
112
- const errors = [];
113
- try {
114
- const dataHash = await BoundWitnessBuilder.dataHash(bw);
115
- const results = await Promise.all(bw.addresses.map(async (address, index) => {
116
- return [address, await BoundWitnessValidator.validateSignature(
117
- toArrayBuffer(dataHash),
118
- address,
119
- toArrayBuffer(bw.$signatures[index] ?? void 0)
120
- )];
121
- }));
122
- for (const [, bwErrors] of results) {
123
- for (const bwError of bwErrors) {
124
- errors.push(new BoundWitnessValidationError(bw?._hash ?? ZERO_HASH2, bw, "validation errors", bwError));
125
- }
126
- }
127
- } catch (ex) {
128
- errors.push(new BoundWitnessValidationError(bw?._hash ?? ZERO_HASH2, bw, "validation excepted", ex));
129
- }
130
- return errors;
131
- };
132
-
133
- // src/transaction/validateTransaction.ts
134
- import { ZERO_HASH as ZERO_HASH10 } from "@ariestools/sdk";
135
- import { asHashMeta } from "@xyo-network/sdk";
136
- import { HydratedTransactionValidationError as HydratedTransactionValidationError9, isTransactionBoundWitness } from "@xyo-network/xl1-protocol-lib";
137
-
138
- // src/transaction/validators/SignerAuthorization.ts
139
- import { XyoAddressZod } from "@xyo-network/sdk";
140
- import { z } from "zod";
141
-
142
- // src/transaction/validators/TransactionTransfersValidator.ts
143
- import { isDefined, isUndefined } from "@ariestools/sdk";
144
- import {
145
- derivedReceiveAddress,
146
- elevatedPayloads,
147
- HydratedTransactionValidationError,
148
- isTransfer as isTransfer2,
149
- rewardAddressFromStepIdentity
150
- } from "@xyo-network/xl1-protocol-lib";
151
- var SelfSignerValidator = (signer, signee) => signer === signee;
152
- var CompletedStepRewardAddressValidatorFactory = (allowedSigners) => (signer, signee, context) => {
153
- const step = context?.step;
154
- if (isDefined(step)) {
155
- const contextAddress = rewardAddressFromStepIdentity(step);
156
- return allowedSigners.includes(signer) && signee === contextAddress;
157
- }
158
- return false;
159
- };
160
- var DerivedReceiveAddressValidatorFactory = (allowedSigners, allowedScope) => (signer, signee, context) => {
161
- const { address, scope } = context ?? {};
162
- if (scope !== allowedScope) {
163
- return false;
164
- }
165
- if (isDefined(address)) {
166
- const derivedAddress = derivedReceiveAddress(address, scope);
167
- return allowedSigners.includes(signer) && signee === derivedAddress;
168
- }
169
- return false;
170
- };
171
- function TransactionTransfersValidatorFactory(signerValidators = [SelfSignerValidator]) {
172
- return async (context, hydratedTx) => {
173
- const errors = [];
174
- const signer = hydratedTx[0].from;
175
- try {
176
- const payloads = elevatedPayloads(hydratedTx);
177
- const transfers = payloads.filter(isTransfer2);
178
- for (const transfer of transfers) {
179
- if (isUndefined(signerValidators.find((v) => v(signer, transfer.from, transfer.context)))) {
180
- errors.push(new HydratedTransactionValidationError(
181
- hydratedTx[0]._hash,
182
- hydratedTx,
183
- `transfer from address ${transfer.from} is not authorized by signer ${signer}`
184
- ));
185
- }
186
- }
187
- } catch (ex) {
188
- errors.push(new HydratedTransactionValidationError(hydratedTx[0]._hash, hydratedTx, "validation excepted", ex));
189
- }
190
- return await Promise.resolve(errors);
191
- };
192
- }
193
-
194
- // src/transaction/validators/SignerAuthorization.ts
195
- var CompletedStepRewardAuthorizationZod = z.object({
196
- type: z.literal("completedStepReward"),
197
- signers: z.array(XyoAddressZod)
198
- }).describe("Authorizes signers for completed-step-reward addresses");
199
- var DerivedReceiveAuthorizationZod = z.object({
200
- type: z.literal("derivedReceive"),
201
- scope: z.string(),
202
- signers: z.array(XyoAddressZod)
203
- }).describe("Authorizes signers for derived-receive addresses within a scope");
204
- var SignerAuthorizationZod = z.discriminatedUnion("type", [
205
- CompletedStepRewardAuthorizationZod,
206
- DerivedReceiveAuthorizationZod
207
- ]);
208
- function signerValidatorFromAuthorization(authorization) {
209
- switch (authorization.type) {
210
- case "completedStepReward": {
211
- return CompletedStepRewardAddressValidatorFactory(authorization.signers);
212
- }
213
- case "derivedReceive": {
214
- return DerivedReceiveAddressValidatorFactory(authorization.signers, authorization.scope);
215
- }
216
- }
217
- }
218
- function signerValidatorsFromAuthorizations(authorizations = []) {
219
- return [SelfSignerValidator, ...authorizations.map(signerValidatorFromAuthorization)];
220
- }
221
-
222
- // src/transaction/validators/TransactionBoundWitnessValidator.ts
223
- import { ZERO_HASH as ZERO_HASH3 } from "@ariestools/sdk";
224
- import { BoundWitnessValidator as BoundWitnessValidator2 } from "@xyo-network/sdk";
225
- import { HydratedTransactionValidationError as HydratedTransactionValidationError2 } from "@xyo-network/xl1-protocol-lib";
226
- var error = (tx, message) => new HydratedTransactionValidationError2(tx?.[0]?._hash ?? ZERO_HASH3, tx, message);
227
- var checkSignaturesShape = (tx) => {
228
- const bw = tx[0];
229
- if (bw.$signatures === void 0) {
230
- return Array.isArray(bw.signatures) ? [error(tx, "BoundWitness has `signatures` but expected `$signatures` (signatures must be in the meta-prefixed `$signatures` key)")] : [error(tx, "BoundWitness is missing `$signatures`")];
231
- }
232
- return [];
233
- };
234
- var TransactionBoundWitnessValidator = async (context, tx) => {
235
- try {
236
- const shapeErrors = checkSignaturesShape(tx);
237
- if (shapeErrors.length > 0) return shapeErrors;
238
- const bwValidator = new BoundWitnessValidator2(tx[0]);
239
- const bwErrors = await bwValidator.validate();
240
- return bwErrors.map((e) => error(tx, `BoundWitness validation: ${e.message}`));
241
- } catch (ex) {
242
- return [error(tx, `Failed TransactionBoundWitnessValidator: ${String(ex)}`)];
243
- }
244
- };
245
-
246
- // src/transaction/validators/TransactionDurationValidator.ts
247
- import { ZERO_HASH as ZERO_HASH4 } from "@ariestools/sdk";
248
- import { HydratedTransactionValidationError as HydratedTransactionValidationError3 } from "@xyo-network/xl1-protocol-lib";
249
- var TransactionDurationValidator = (context, tx) => {
250
- const errors = [];
251
- try {
252
- const { exp, nbf } = tx[0];
253
- if (nbf < 0) errors.push(new HydratedTransactionValidationError3(tx?.[0]?._hash ?? ZERO_HASH4, tx, "Transaction nbf must be positive"));
254
- if (exp < 0) errors.push(new HydratedTransactionValidationError3(tx?.[0]?._hash ?? ZERO_HASH4, tx, "Transaction exp must be positive"));
255
- if (exp <= nbf) errors.push(new HydratedTransactionValidationError3(tx?.[0]?._hash ?? ZERO_HASH4, tx, "Transaction exp must greater than nbf"));
256
- if (exp - nbf > 1e4) errors.push(new HydratedTransactionValidationError3(
257
- tx?.[0]?._hash ?? ZERO_HASH4,
258
- tx,
259
- "Transaction exp must not be too far in the future"
260
- ));
261
- } catch (ex) {
262
- errors.push(new HydratedTransactionValidationError3(
263
- tx?.[0]?._hash ?? ZERO_HASH4,
264
- tx,
265
- `Failed TransactionDurationValidator: ${String(ex)}`,
266
- ex
267
- ));
268
- }
269
- return errors;
270
- };
271
-
272
- // src/transaction/validators/TransactionElevationValidator.ts
273
- import { ZERO_HASH as ZERO_HASH5 } from "@ariestools/sdk";
274
- import { extractElevatedHashes, HydratedTransactionValidationError as HydratedTransactionValidationError4 } from "@xyo-network/xl1-protocol-lib";
275
- var TransactionElevationValidator = (context, tx) => {
276
- const errors = [];
277
- try {
278
- try {
279
- extractElevatedHashes(tx);
280
- } catch {
281
- errors.push(new HydratedTransactionValidationError4(tx?.[0]?._hash ?? ZERO_HASH5, tx, "Hydrated transaction does not include all script hashes"));
282
- }
283
- } catch (ex) {
284
- errors.push(new HydratedTransactionValidationError4(
285
- tx?.[0]?._hash ?? ZERO_HASH5,
286
- tx,
287
- `Failed TransactionElevationValidator: ${String(ex)}`,
288
- ex
289
- ));
290
- }
291
- return errors;
292
- };
293
-
294
- // src/transaction/validators/TransactionFromValidator.ts
295
- import { ZERO_HASH as ZERO_HASH6 } from "@ariestools/sdk";
296
- import { addressesContains, asXyoAddress } from "@xyo-network/sdk";
297
- import { HydratedTransactionValidationError as HydratedTransactionValidationError5 } from "@xyo-network/xl1-protocol-lib";
298
- var TransactionFromValidator = (context, tx) => {
299
- const errors = [];
300
- try {
301
- const from = asXyoAddress(tx[0].from);
302
- if (from === void 0) errors.push(new HydratedTransactionValidationError5(
303
- tx?.[0]?._hash ?? ZERO_HASH6,
304
- tx,
305
- "Transaction from is not a valid address"
306
- ));
307
- else if (!addressesContains(tx[0], from)) errors.push(new HydratedTransactionValidationError5(
308
- tx?.[0]?._hash ?? ZERO_HASH6,
309
- tx,
310
- "Transaction from address must be listed in addresses"
311
- ));
312
- } catch (ex) {
313
- errors.push(new HydratedTransactionValidationError5(
314
- tx?.[0]?._hash ?? ZERO_HASH6,
315
- tx,
316
- `Failed TransactionFromValidator: ${String(ex)}`,
317
- ex
318
- ));
319
- }
320
- return errors;
321
- };
322
-
323
- // src/transaction/validators/TransactionGasValidator.ts
324
- import { hexToBigInt as hexToBigInt2, ZERO_HASH as ZERO_HASH7 } from "@ariestools/sdk";
325
- import {
326
- AttoXL1,
327
- HydratedTransactionValidationError as HydratedTransactionValidationError6,
328
- minTransactionFees
329
- } from "@xyo-network/xl1-protocol-lib";
330
- var TransactionGasValidator = (context, tx) => {
331
- const errors = [];
332
- try {
333
- if (tx?.[0].fees === void 0) {
334
- errors.push(new HydratedTransactionValidationError6(
335
- tx?.[0]?._hash ?? ZERO_HASH7,
336
- tx,
337
- "Missing fees"
338
- ));
339
- } else {
340
- const {
341
- base,
342
- gasLimit,
343
- gasPrice,
344
- priority
345
- } = parseFees(tx[0].fees);
346
- if (base === void 0) errors.push(new HydratedTransactionValidationError6(
347
- tx?.[0]?._hash ?? ZERO_HASH7,
348
- tx,
349
- "fees.base must be defined and a valid number"
350
- ));
351
- else if (base < minTransactionFees.base) errors.push(new HydratedTransactionValidationError6(
352
- tx?.[0]?._hash ?? ZERO_HASH7,
353
- tx,
354
- `fees.base must be >= ${minTransactionFees.base}`
355
- ));
356
- if (gasLimit === void 0) errors.push(new HydratedTransactionValidationError6(
357
- tx?.[0]?._hash ?? ZERO_HASH7,
358
- tx,
359
- "fees.gasLimit must be defined and a valid number"
360
- ));
361
- else if (gasLimit < minTransactionFees.gasLimit) errors.push(new HydratedTransactionValidationError6(
362
- tx?.[0]?._hash ?? ZERO_HASH7,
363
- tx,
364
- `fees.gasLimit must be >= ${minTransactionFees.gasLimit}`
365
- ));
366
- if (gasPrice === void 0) errors.push(
367
- new HydratedTransactionValidationError6(
368
- tx?.[0]?._hash ?? ZERO_HASH7,
369
- tx,
370
- "fees.gasPrice must be defined and a valid number"
371
- )
372
- );
373
- else if (gasPrice < minTransactionFees.gasPrice) errors.push(new HydratedTransactionValidationError6(
374
- tx?.[0]?._hash ?? ZERO_HASH7,
375
- tx,
376
- `fees.gasPrice must be >= ${minTransactionFees.gasPrice}`
377
- ));
378
- if (priority === void 0) errors.push(new HydratedTransactionValidationError6(
379
- tx?.[0]?._hash ?? ZERO_HASH7,
380
- tx,
381
- "fees.priority must be defined and a valid number"
382
- ));
383
- else if (priority < minTransactionFees.priority) errors.push(new HydratedTransactionValidationError6(
384
- tx?.[0]?._hash ?? ZERO_HASH7,
385
- tx,
386
- `fees.priority must be >= ${minTransactionFees.priority}`
387
- ));
388
- }
389
- } catch (ex) {
390
- errors.push(new HydratedTransactionValidationError6(
391
- tx?.[0]?._hash ?? ZERO_HASH7,
392
- tx,
393
- `Failed TransactionGasValidator: ${String(ex)}`,
394
- ex
395
- ));
396
- }
397
- return errors;
398
- };
399
- var parseFees = (fees) => {
400
- const ret = {};
401
- const {
402
- base,
403
- gasLimit,
404
- gasPrice,
405
- priority
406
- } = fees;
407
- if (base !== void 0) ret.base = AttoXL1(hexToBigInt2(base));
408
- if (gasLimit !== void 0) ret.gasLimit = AttoXL1(hexToBigInt2(gasLimit));
409
- if (gasPrice !== void 0) ret.gasPrice = AttoXL1(hexToBigInt2(gasPrice));
410
- if (priority !== void 0) ret.priority = AttoXL1(hexToBigInt2(priority));
411
- return ret;
412
- };
413
-
414
- // src/transaction/validators/TransactionJsonSchemaValidator.ts
415
- import { ZERO_HASH as ZERO_HASH8 } from "@ariestools/sdk";
416
- import { PayloadBuilder } from "@xyo-network/sdk";
417
- import { HydratedTransactionValidationError as HydratedTransactionValidationError7 } from "@xyo-network/xl1-protocol-lib";
418
- import { TransactionBoundWitnessJsonSchema } from "@xyo-network/xl1-schema";
419
- import { Ajv } from "ajv";
420
- var ajv = new Ajv({ allErrors: true, strict: true });
421
- var validate;
422
- var TransactionJsonSchemaValidator = (context, tx) => {
423
- const errors = [];
424
- try {
425
- validate ??= ajv.compile(TransactionBoundWitnessJsonSchema);
426
- if (!validate(PayloadBuilder.omitStorageMeta(tx[0]))) {
427
- const error2 = new HydratedTransactionValidationError7(
428
- tx?.[0]?._hash ?? ZERO_HASH8,
429
- tx,
430
- `failed JSON schema validation: ${ajv.errorsText(validate.errors, { separator: "\n" })}`,
431
- validate.errors
432
- );
433
- errors.push(error2);
434
- }
435
- } catch (ex) {
436
- errors.push(new HydratedTransactionValidationError7(tx?.[0]?._hash ?? ZERO_HASH8, tx, "validation excepted", ex));
437
- }
438
- return errors;
439
- };
440
-
441
- // src/transaction/validators/TransactionProtocolValidator.ts
442
- import { ZERO_HASH as ZERO_HASH9 } from "@ariestools/sdk";
443
- import { HydratedTransactionValidationError as HydratedTransactionValidationError8 } from "@xyo-network/xl1-protocol-lib";
444
- var TransactionProtocolValidator = async (context, tx) => {
445
- const errors = [];
446
- try {
447
- if (context?.chainId !== void 0 && tx[0].chain !== context.chainId) {
448
- errors.push(new HydratedTransactionValidationError8(tx?.[0]?._hash ?? ZERO_HASH9, tx, `invalid chain id [${context.chainId}, ${tx[0].chain}]`));
449
- }
450
- } catch (ex) {
451
- errors.push(new HydratedTransactionValidationError8(tx?.[0]?._hash ?? ZERO_HASH9, tx, "validation excepted", ex));
452
- }
453
- return await Promise.resolve(errors);
454
- };
455
-
456
- // src/transaction/validateTransaction.ts
457
- var validateTransaction = async (context, tx, additionalValidators) => {
458
- try {
459
- if (!isTransactionBoundWitness(tx[0])) {
460
- const castTx = tx.at(0);
461
- return [new HydratedTransactionValidationError9(
462
- asHashMeta(castTx)?._hash ?? ZERO_HASH10,
463
- tx,
464
- "failed isTransactionBoundWitness identity check"
465
- )];
466
- }
467
- const validators = [
468
- TransactionProtocolValidator,
469
- TransactionDurationValidator,
470
- TransactionFromValidator,
471
- TransactionGasValidator,
472
- TransactionElevationValidator,
473
- TransactionBoundWitnessValidator,
474
- ...additionalValidators ?? []
475
- ];
476
- const validationResults = await Promise.all(validators.map(async (v) => v(context, tx)));
477
- return validationResults.flat();
478
- } catch (ex) {
479
- const castTx = tx?.[0];
480
- return [new HydratedTransactionValidationError9(
481
- castTx?._hash ?? ZERO_HASH10,
482
- tx,
483
- "Failed TransactionGasValidator: " + ex.message,
484
- ex
485
- )];
486
- }
487
- };
488
- export {
489
- BlockCumulativeBalanceValidatorFactory,
490
- BoundWitnessReferencesValidator,
491
- BoundWitnessSignaturesValidator,
492
- CompletedStepRewardAddressValidatorFactory,
493
- CompletedStepRewardAuthorizationZod,
494
- DerivedReceiveAddressValidatorFactory,
495
- DerivedReceiveAuthorizationZod,
496
- SelfSignerValidator,
497
- SignerAuthorizationZod,
498
- TransactionBoundWitnessValidator,
499
- TransactionDurationValidator,
500
- TransactionElevationValidator,
501
- TransactionFromValidator,
502
- TransactionGasValidator,
503
- TransactionJsonSchemaValidator,
504
- TransactionProtocolValidator,
505
- TransactionTransfersValidatorFactory,
506
- accumulateOutflows,
507
- signerValidatorsFromAuthorizations,
508
- validateTransaction
509
- };
1
+ // src/index.ts
2
+ export * from "@xyo-network/xl1-protocol/validation";
510
3
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/block/validators/BlockCumulativeBalanceValidator.ts", "../../src/boundwitness/validators/BoundWitnessReferences.ts", "../../src/boundwitness/validators/BoundWitnessSignatures.ts", "../../src/transaction/validateTransaction.ts", "../../src/transaction/validators/SignerAuthorization.ts", "../../src/transaction/validators/TransactionTransfersValidator.ts", "../../src/transaction/validators/TransactionBoundWitnessValidator.ts", "../../src/transaction/validators/TransactionDurationValidator.ts", "../../src/transaction/validators/TransactionElevationValidator.ts", "../../src/transaction/validators/TransactionFromValidator.ts", "../../src/transaction/validators/TransactionGasValidator.ts", "../../src/transaction/validators/TransactionJsonSchemaValidator.ts", "../../src/transaction/validators/TransactionProtocolValidator.ts"],
4
- "sourcesContent": ["import { type Hex, hexToBigInt } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk'\nimport type {\n HydratedBlockStateValidationFunction,\n HydratedBlockWithHashMeta,\n TransactionBoundWitnessWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n HydratedBlockStateValidationError,\n isTransactionBoundWitnessWithHashMeta,\n isTransfer,\n XYO_ZERO_ADDRESS,\n} from '@xyo-network/xl1-protocol-lib'\n\n/** Compute the maximum fee commitment for a transaction (base + priority + gasLimit). */\nfunction maxTransactionFeeCost(tx: TransactionBoundWitnessWithHashMeta): bigint {\n const {\n base, gasLimit, priority,\n } = tx.fees\n return hexToBigInt(base) + hexToBigInt(priority) + hexToBigInt(gasLimit)\n}\n\nfunction accumulateTransferOutflows(\n payload: HydratedBlockWithHashMeta[1][number],\n txPayloadHashes: Set<string>,\n outflows: Record<XyoAddress, bigint>,\n): void {\n if (!txPayloadHashes.has(payload._hash) || !isTransfer(payload)) return\n const { from } = payload\n for (const [to, amount] of Object.entries(payload.transfers) as [XyoAddress, Hex][]) {\n if (to !== from) {\n outflows[from] = (outflows[from] ?? 0n) + hexToBigInt(amount)\n }\n }\n}\n\n/** Accumulate outflows per address from fees and transfers in the given transactions. */\nexport function accumulateOutflows(\n transactions: TransactionBoundWitnessWithHashMeta[],\n payloads: HydratedBlockWithHashMeta[1],\n): Record<XyoAddress, bigint> {\n const outflows: Record<XyoAddress, bigint> = {}\n\n for (const tx of transactions) {\n // Fee cost charged to the transaction sender\n const feeCost = maxTransactionFeeCost(tx)\n const feePayer = tx.from\n outflows[feePayer] = (outflows[feePayer] ?? 0n) + feeCost\n\n // Find transfer payloads belonging to this transaction\n const txPayloadHashes = new Set(tx.payload_hashes)\n for (const payload of payloads) {\n accumulateTransferOutflows(payload, txPayloadHashes, outflows)\n }\n }\n\n return outflows\n}\n\n/** Creates a block state validator that checks cumulative outflows per address do not exceed pre-block balances. */\nexport function BlockCumulativeBalanceValidatorFactory(): HydratedBlockStateValidationFunction {\n return async (context, hydratedBlock) => {\n const [blockBw, payloads] = hydratedBlock\n\n // Find all transactions in the block\n const transactions = payloads.filter(isTransactionBoundWitnessWithHashMeta)\n\n if (transactions.length === 0) return []\n\n const outflows = accumulateOutflows(transactions, payloads)\n\n // Query pre-block balances for all addresses with outflows\n const addresses = Object.keys(outflows) as XyoAddress[]\n if (addresses.length === 0) return []\n\n const balances = await context.accountBalance.accountBalances(addresses)\n\n // Check each address\n const chainId = await context.chainIdAtBlockNumber(blockBw.block)\n const errors: HydratedBlockStateValidationError[] = []\n for (const address of addresses) {\n if (address === XYO_ZERO_ADDRESS) continue // Skip zero address as it's used for burn transactions and doesn't have a balance\n // TODO: Add specific validation for block reward transfer\n const balance = balances[address] ?? 0n\n const totalOutflow = outflows[address]\n if (totalOutflow > balance) {\n errors.push(new HydratedBlockStateValidationError(\n blockBw._hash,\n chainId,\n hydratedBlock,\n `Cumulative outflow for address ${address} exceeds available balance: outflow ${totalOutflow} > balance ${balance}`,\n ))\n }\n }\n\n return errors\n }\n}\n", "import type { Hash, Promisable } from '@ariestools/sdk'\nimport { ZERO_HASH } from '@ariestools/sdk'\nimport type {\n BoundWitness,\n Payload,\n Schema,\n WithHashMeta,\n} from '@xyo-network/sdk'\nimport { isAnyPayload } from '@xyo-network/sdk'\nimport type { HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedBoundWitnessValidationError } from '@xyo-network/xl1-protocol-lib'\n\nfunction getPayloadsFromPayloadArray(payloads: WithHashMeta<Payload>[], hashes: Hash[]): (WithHashMeta<Payload> | undefined)[] {\n return hashes.map(hash => payloads.find(payload => payload._hash === hash || payload._dataHash === hash))\n}\n\n/** Creates a validator that checks all payload references in a BoundWitness are present, have matching schemas, and optionally conform to an allowed schema list. */\nexport const BoundWitnessReferencesValidator\n\n = <T extends BoundWitness = BoundWitness>(allowedSchemas?: Schema[]): HydratedBoundWitnessValidationFunction<T> => (\n [bw, payloadSet]: HydratedBoundWitnessWithHashMeta<T>,\n // eslint-disable-next-line complexity\n ): Promisable<HydratedBoundWitnessValidationError[]> => {\n const errors: HydratedBoundWitnessValidationError[] = []\n try {\n const payloads = getPayloadsFromPayloadArray(payloadSet, bw.payload_hashes)\n if (payloads.length !== bw.payload_hashes.length) {\n errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], 'unable to locate payloads'))\n }\n\n // check if payloads are valid and if their schemas match the declared schemas\n for (const payload of payloads) {\n if (isAnyPayload(payload)) {\n const payloadHashIndex = bw.payload_hashes.indexOf(payload._hash)\n const payloadDataHashIndex = bw.payload_hashes.indexOf(payload._dataHash)\n const payloadIndex = Math.max(payloadHashIndex, payloadDataHashIndex)\n if (payloadIndex === -1) {\n errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], 'payload hash not found'))\n }\n\n const declaredSchema = bw.payload_schemas[payloadIndex]\n if (declaredSchema !== payload.schema) {\n errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], 'mismatched schema'))\n }\n\n if (allowedSchemas && !allowedSchemas.includes(payload.schema)) {\n errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `disallowed schema [${payload.schema}]`))\n }\n } else {\n errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], 'invalid payload'))\n }\n }\n } catch (ex) {\n const error = new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `validation excepted: ${String(ex)}`, ex)\n errors.push(error)\n }\n return errors\n }\n", "import { toArrayBuffer, ZERO_HASH } from '@ariestools/sdk'\nimport type {\n BoundWitness, WithStorageMeta, XyoAddress,\n} from '@xyo-network/sdk'\nimport { BoundWitnessBuilder, BoundWitnessValidator } from '@xyo-network/sdk'\nimport type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib'\nimport { BoundWitnessValidationError } from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that all signatures on a BoundWitness are cryptographically valid for their corresponding addresses. */\nexport const BoundWitnessSignaturesValidator: BoundWitnessValidationFunction = async (\n bw: BoundWitness,\n) => {\n const errors: BoundWitnessValidationError[] = []\n try {\n const dataHash = await BoundWitnessBuilder.dataHash(bw)\n const results: [XyoAddress, Error[]][] = await Promise.all(bw.addresses.map(async (address, index) => {\n return [address, await BoundWitnessValidator.validateSignature(\n toArrayBuffer(dataHash),\n address,\n toArrayBuffer(bw.$signatures[index] ?? undefined),\n )]\n }))\n for (const [, bwErrors] of results) {\n for (const bwError of bwErrors) {\n errors.push(new BoundWitnessValidationError((bw as WithStorageMeta<BoundWitness>)?._hash ?? ZERO_HASH, bw, 'validation errors', bwError))\n }\n }\n } catch (ex) {\n errors.push(new BoundWitnessValidationError((bw as WithStorageMeta<BoundWitness>)?._hash ?? ZERO_HASH, bw, 'validation excepted', ex))\n }\n return errors\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport { asHashMeta } from '@xyo-network/sdk'\nimport type {\n HydratedTransactionValidationFunction,\n HydratedTransactionValidationFunctionContext,\n HydratedTransactionWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError, isTransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'\n\nimport {\n TransactionBoundWitnessValidator,\n TransactionDurationValidator,\n TransactionElevationValidator, TransactionFromValidator, TransactionGasValidator, TransactionProtocolValidator,\n} from './validators/index.ts'\n\n/** Validates a hydrated transaction using built-in validators plus any additional validators provided. */\nexport const validateTransaction: HydratedTransactionValidationFunction = async (\n context: HydratedTransactionValidationFunctionContext,\n tx: HydratedTransactionWithHashMeta,\n additionalValidators?: HydratedTransactionValidationFunction[],\n): Promise<HydratedTransactionValidationError[]> => {\n try {\n if (!isTransactionBoundWitness(tx[0])) {\n const castTx = tx.at(0)\n return [new HydratedTransactionValidationError(\n asHashMeta(castTx)?._hash ?? ZERO_HASH,\n tx,\n 'failed isTransactionBoundWitness identity check',\n )]\n }\n\n const validators: HydratedTransactionValidationFunction<HydratedTransactionValidationFunctionContext>[] = [\n TransactionProtocolValidator,\n TransactionDurationValidator,\n TransactionFromValidator,\n TransactionGasValidator,\n TransactionElevationValidator,\n TransactionBoundWitnessValidator,\n ...(additionalValidators ?? []),\n ]\n const validationResults = await Promise.all(validators.map(async v => v(context, tx)))\n return validationResults.flat()\n } catch (ex) {\n const castTx = tx?.[0]\n return [new HydratedTransactionValidationError(\n castTx?._hash ?? ZERO_HASH,\n tx,\n 'Failed TransactionGasValidator: ' + (ex as Error).message,\n ex,\n )]\n }\n}\n", "import { XyoAddressZod } from '@xyo-network/sdk'\nimport { z } from 'zod'\n\nimport type { SignerValidator } from './TransactionTransfersValidator.ts'\nimport {\n CompletedStepRewardAddressValidatorFactory, DerivedReceiveAddressValidatorFactory, SelfSignerValidator,\n} from './TransactionTransfersValidator.ts'\n\n/** Authorizes the listed signers to sign for completed-step-reward addresses. */\nexport const CompletedStepRewardAuthorizationZod = z.object({\n type: z.literal('completedStepReward'),\n signers: z.array(XyoAddressZod),\n}).describe('Authorizes signers for completed-step-reward addresses')\n\n/** Authorizes the listed signers to sign for derived-receive addresses within a scope. */\nexport const DerivedReceiveAuthorizationZod = z.object({\n type: z.literal('derivedReceive'),\n scope: z.string(),\n signers: z.array(XyoAddressZod),\n}).describe('Authorizes signers for derived-receive addresses within a scope')\n\n/** A single signer authorization, discriminated by `type` (the deriving-function selector). */\nexport const SignerAuthorizationZod = z.discriminatedUnion('type', [\n CompletedStepRewardAuthorizationZod,\n DerivedReceiveAuthorizationZod,\n])\n\nexport type CompletedStepRewardAuthorization = z.infer<typeof CompletedStepRewardAuthorizationZod>\nexport type DerivedReceiveAuthorization = z.infer<typeof DerivedReceiveAuthorizationZod>\nexport type SignerAuthorization = z.infer<typeof SignerAuthorizationZod>\n\n/**\n * Registry mapping an authorization `type` to the SignerValidator factory that enforces it.\n * The exhaustive switch keeps each variant's params type-safe; add a new address family by\n * adding a union variant above and a case here.\n */\nfunction signerValidatorFromAuthorization(authorization: SignerAuthorization): SignerValidator {\n switch (authorization.type) {\n case 'completedStepReward': {\n return CompletedStepRewardAddressValidatorFactory(authorization.signers)\n }\n case 'derivedReceive': {\n return DerivedReceiveAddressValidatorFactory(authorization.signers, authorization.scope)\n }\n }\n}\n\n/**\n * Builds the `SignerValidator[]` consumed by `TransactionTransfersValidatorFactory` from a list\n * of authorizations. `SelfSignerValidator` is ALWAYS included so ordinary self-transfers pass;\n * an empty `authorizations` list therefore means \"self only\" \u2014 deny-all for reward/escrow families.\n */\nexport function signerValidatorsFromAuthorizations(authorizations: SignerAuthorization[] = []): SignerValidator[] {\n return [SelfSignerValidator, ...authorizations.map(signerValidatorFromAuthorization)]\n}\n", "import { isDefined, isUndefined } from '@ariestools/sdk'\nimport type { XyoAddress } from '@xyo-network/sdk'\nimport type {\n HydratedTransactionValidationFunction, StepIdentity,\n Transfer,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n derivedReceiveAddress,\n elevatedPayloads,\n HydratedTransactionValidationError,\n isTransfer,\n rewardAddressFromStepIdentity,\n} from '@xyo-network/xl1-protocol-lib'\n\n/** Function type that checks whether a signer is authorized to sign for a given signee address. */\nexport type SignerValidator = (signer: XyoAddress, signee: XyoAddress, context?: { address?: XyoAddress; scope?: string; step?: StepIdentity }) => boolean\n\n/** A signer validator that only allows an address to sign for itself. */\nexport const SelfSignerValidator: SignerValidator = (signer: XyoAddress, signee: XyoAddress) => signer === signee\n\n/** Creates a signer validator that authorizes specified signers to sign for completed step reward addresses. */\nexport const CompletedStepRewardAddressValidatorFactory = (allowedSigners: XyoAddress[]): SignerValidator => (\n signer: XyoAddress,\n signee: XyoAddress,\n context?: { step?: StepIdentity },\n) => {\n const step = context?.step\n if (isDefined(step)) {\n const contextAddress = rewardAddressFromStepIdentity(step)\n return allowedSigners.includes(signer) && signee === contextAddress\n }\n return false\n}\n\n/** Creates a signer validator that authorizes specified signers to sign for derived receive addresses within a given scope. */\nexport const DerivedReceiveAddressValidatorFactory = (allowedSigners: XyoAddress[], allowedScope: string): SignerValidator => (\n signer: XyoAddress,\n signee: XyoAddress,\n context?: { address?: XyoAddress; scope?: string },\n) => {\n const { address, scope } = context ?? {}\n if (scope !== allowedScope) {\n return false\n }\n if (isDefined(address)) {\n const derivedAddress = derivedReceiveAddress(address, scope)\n return allowedSigners.includes(signer) && signee === derivedAddress\n }\n return false\n}\n\n/** Creates a transaction validator that checks all transfers are authorized by the transaction signer. */\nexport function TransactionTransfersValidatorFactory(\n signerValidators: SignerValidator[] = [SelfSignerValidator],\n): HydratedTransactionValidationFunction {\n return async (\n context,\n hydratedTx,\n ) => {\n const errors: HydratedTransactionValidationError[] = []\n const signer = hydratedTx[0].from\n try {\n const payloads = elevatedPayloads(hydratedTx)\n const transfers = payloads.filter(isTransfer) as Transfer[]\n for (const transfer of transfers) {\n if (isUndefined(signerValidators.find(v => v(signer, transfer.from, transfer.context)))) {\n errors.push(new HydratedTransactionValidationError(\n hydratedTx[0]._hash,\n hydratedTx,\n `transfer from address ${transfer.from} is not authorized by signer ${signer}`,\n ))\n }\n }\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(hydratedTx[0]._hash, hydratedTx, 'validation excepted', ex))\n }\n return await Promise.resolve(errors)\n }\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport { BoundWitnessValidator } from '@xyo-network/sdk'\nimport type { HydratedTransactionValidationFunction, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\n\nconst error = (tx: HydratedTransactionWithHashMeta, message: string): HydratedTransactionValidationError =>\n new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, message)\n\n// Friendly pre-check for the wallet bug we want to surface clearly: signatures\n// emitted under `signatures` instead of `$signatures`. The downstream\n// BoundWitnessValidator would also catch the missing/mismatched signatures,\n// but its message (\"Length mismatch: address/signature\", \"Missing signature\n// [<address>]\") doesn't hint at the actual root cause.\nconst checkSignaturesShape = (tx: HydratedTransactionWithHashMeta): HydratedTransactionValidationError[] => {\n const bw = tx[0] as unknown as Record<string, unknown>\n if (bw.$signatures === undefined) {\n return Array.isArray(bw.signatures)\n ? [error(tx, 'BoundWitness has `signatures` but expected `$signatures` (signatures must be in the meta-prefixed `$signatures` key)')]\n : [error(tx, 'BoundWitness is missing `$signatures`')]\n }\n return []\n}\n\n/**\n * Validates the transaction's BoundWitness wholistically by delegating to\n * `BoundWitnessValidator.validate()`. This covers:\n * - signatures: length matches addresses, every signature is cryptographically\n * valid for its corresponding address against the BW data hash\n * - addresses: uniqueness\n * - array length parity: payload_hashes vs payload_schemas\n * - schemas: per-schema name validators\n * - top-level schema check\n * - PayloadValidator.schemaName check\n *\n * Also emits a friendly diagnostic when the common wallet bug of\n * `signatures` vs `$signatures` is detected, so the failure points at the\n * actual root cause instead of buried length/missing-signature errors.\n */\nexport const TransactionBoundWitnessValidator: HydratedTransactionValidationFunction = async (\n context,\n tx,\n) => {\n try {\n const shapeErrors = checkSignaturesShape(tx)\n if (shapeErrors.length > 0) return shapeErrors\n const bwValidator = new BoundWitnessValidator(tx[0])\n const bwErrors = await bwValidator.validate()\n return bwErrors.map(e => error(tx, `BoundWitness validation: ${e.message}`))\n } catch (ex) {\n return [error(tx, `Failed TransactionBoundWitnessValidator: ${String(ex)}`)]\n }\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that transaction timing fields (nbf and exp) are positive, correctly ordered, and within allowed duration limits. */\nexport const TransactionDurationValidator: HydratedTransactionValidationFunction = (\n context,\n tx,\n// eslint-disable-next-line complexity\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n const { exp, nbf } = tx[0]\n if (nbf < 0) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'Transaction nbf must be positive'))\n\n if (exp < 0) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'Transaction exp must be positive'))\n if (exp <= nbf) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'Transaction exp must greater than nbf'))\n if (exp - nbf > 10_000) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'Transaction exp must not be too far in the future',\n ))\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `Failed TransactionDurationValidator: ${String(ex)}`,\n ex,\n ))\n }\n\n return errors\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'\nimport { extractElevatedHashes, HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that a hydrated transaction includes all required elevated script hashes. */\nexport const TransactionElevationValidator: HydratedTransactionValidationFunction = (\n context,\n tx,\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n try {\n extractElevatedHashes(tx)\n } catch {\n errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'Hydrated transaction does not include all script hashes'))\n }\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `Failed TransactionElevationValidator: ${String(ex)}`,\n ex,\n ))\n }\n return errors\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport { addressesContains, asXyoAddress } from '@xyo-network/sdk'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that the transaction's from field is a valid address and is included in the BoundWitness addresses. */\nexport const TransactionFromValidator: HydratedTransactionValidationFunction = (\n context,\n tx,\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n const from = asXyoAddress(tx[0].from)\n if (from === undefined)errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'Transaction from is not a valid address',\n ))\n else if (!addressesContains(tx[0], from)) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'Transaction from address must be listed in addresses',\n ))\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `Failed TransactionFromValidator: ${String(ex)}`,\n ex,\n ))\n }\n return errors\n}\n", "import { hexToBigInt, ZERO_HASH } from '@ariestools/sdk'\nimport type {\n HydratedTransactionValidationFunction,\n TransactionFeesBigInt, TransactionFeesHex,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n AttoXL1,\n HydratedTransactionValidationError,\n minTransactionFees,\n} from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that transaction fee fields (base, gasLimit, gasPrice, priority) are present and meet minimum requirements. */\nexport const TransactionGasValidator: HydratedTransactionValidationFunction = (\n context,\n tx,\n// eslint-disable-next-line complexity\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n if (tx?.[0].fees === undefined) {\n errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'Missing fees',\n ))\n } else {\n const {\n base, gasLimit, gasPrice, priority,\n } = parseFees(tx[0].fees)\n\n if (base === undefined) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'fees.base must be defined and a valid number',\n ))\n else if (base < minTransactionFees.base) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `fees.base must be >= ${minTransactionFees.base}`,\n ))\n\n if (gasLimit === undefined) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'fees.gasLimit must be defined and a valid number',\n ))\n else if (gasLimit < minTransactionFees.gasLimit) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `fees.gasLimit must be >= ${minTransactionFees.gasLimit}`,\n ))\n\n if (gasPrice === undefined) errors.push(\n new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'fees.gasPrice must be defined and a valid number',\n ),\n )\n else if (gasPrice < minTransactionFees.gasPrice) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `fees.gasPrice must be >= ${minTransactionFees.gasPrice}`,\n ))\n\n if (priority === undefined) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n 'fees.priority must be defined and a valid number',\n ))\n else if (priority < minTransactionFees.priority) errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `fees.priority must be >= ${minTransactionFees.priority}`,\n ))\n }\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `Failed TransactionGasValidator: ${String(ex)}`,\n ex,\n ))\n }\n return errors\n}\n\nconst parseFees = (fees: TransactionFeesHex): Partial<TransactionFeesBigInt> => {\n const ret: Partial<TransactionFeesBigInt> = {}\n const {\n base, gasLimit, gasPrice, priority,\n } = fees\n if (base !== undefined) ret.base = AttoXL1(hexToBigInt(base))\n if (gasLimit !== undefined) ret.gasLimit = AttoXL1(hexToBigInt(gasLimit))\n if (gasPrice !== undefined) ret.gasPrice = AttoXL1(hexToBigInt(gasPrice))\n if (priority !== undefined) ret.priority = AttoXL1(hexToBigInt(priority))\n return ret\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport { PayloadBuilder } from '@xyo-network/sdk'\nimport type { HydratedTransactionValidationFunction, TransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\nimport { TransactionBoundWitnessJsonSchema } from '@xyo-network/xl1-schema'\nimport type { ValidateFunction } from 'ajv'\nimport { Ajv } from 'ajv'\n\nconst ajv = new Ajv({ allErrors: true, strict: true })\n\nlet validate: ValidateFunction<TransactionBoundWitness> | undefined\n\n/** Validates a transaction against the TransactionBoundWitness JSON schema using AJV. */\nexport const TransactionJsonSchemaValidator: HydratedTransactionValidationFunction = (\n context,\n tx,\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n validate ??= ajv.compile(TransactionBoundWitnessJsonSchema)\n if (!validate(PayloadBuilder.omitStorageMeta(tx[0]))) {\n const error = new HydratedTransactionValidationError(\n tx?.[0]?._hash ?? ZERO_HASH,\n tx,\n `failed JSON schema validation: ${ajv.errorsText(validate.errors, { separator: '\\n' })}`,\n validate.errors,\n )\n errors.push(error)\n }\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'validation excepted', ex))\n }\n return errors\n}\n", "import { ZERO_HASH } from '@ariestools/sdk'\nimport type {\n ChainId,\n HydratedTransactionValidationFunction,\n} from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\n\n/** Validates that the transaction's chain ID matches the expected chain ID from the validation context. */\nexport const TransactionProtocolValidator: HydratedTransactionValidationFunction = async (\n context: { chainId?: ChainId },\n tx,\n) => {\n const errors: HydratedTransactionValidationError[] = []\n try {\n if (context?.chainId !== undefined && tx[0].chain !== context.chainId) {\n errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, `invalid chain id [${context.chainId}, ${tx[0].chain}]`))\n }\n } catch (ex) {\n errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH, tx, 'validation excepted', ex))\n }\n return await Promise.resolve(errors)\n}\n"],
5
- "mappings": ";AAAA,SAAmB,mBAAmB;AAOtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,sBAAsB,IAAiD;AAC9E,QAAM;AAAA,IACJ;AAAA,IAAM;AAAA,IAAU;AAAA,EAClB,IAAI,GAAG;AACP,SAAO,YAAY,IAAI,IAAI,YAAY,QAAQ,IAAI,YAAY,QAAQ;AACzE;AAEA,SAAS,2BACP,SACA,iBACA,UACM;AACN,MAAI,CAAC,gBAAgB,IAAI,QAAQ,KAAK,KAAK,CAAC,WAAW,OAAO,EAAG;AACjE,QAAM,EAAE,KAAK,IAAI;AACjB,aAAW,CAAC,IAAI,MAAM,KAAK,OAAO,QAAQ,QAAQ,SAAS,GAA0B;AACnF,QAAI,OAAO,MAAM;AACf,eAAS,IAAI,KAAK,SAAS,IAAI,KAAK,MAAM,YAAY,MAAM;AAAA,IAC9D;AAAA,EACF;AACF;AAGO,SAAS,mBACd,cACA,UAC4B;AAC5B,QAAM,WAAuC,CAAC;AAE9C,aAAW,MAAM,cAAc;AAE7B,UAAM,UAAU,sBAAsB,EAAE;AACxC,UAAM,WAAW,GAAG;AACpB,aAAS,QAAQ,KAAK,SAAS,QAAQ,KAAK,MAAM;AAGlD,UAAM,kBAAkB,IAAI,IAAI,GAAG,cAAc;AACjD,eAAW,WAAW,UAAU;AAC9B,iCAA2B,SAAS,iBAAiB,QAAQ;AAAA,IAC/D;AAAA,EACF;AAEA,SAAO;AACT;AAGO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K,CAAC,GAAG,SAASD,YAAW,IAAI,qBAAqB,QAAQ,OAAO,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC;AAAA,IAC9I;AAAA,EACF,SAAS,IAAI;AACX,WAAO,KAAK,IAAIC,oCAAmC,KAAK,CAAC,GAAG,SAASD,YAAW,IAAI,uBAAuB,EAAE,CAAC;AAAA,EAChH;AACA,SAAO,MAAM,QAAQ,QAAQ,MAAM;AACrC;;;ATLO,IAAM,sBAA6D,OACxE,SACA,IACA,yBACkD;AAClD,MAAI;AACF,QAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,GAAG;AACrC,YAAM,SAAS,GAAG,GAAG,CAAC;AACtB,aAAO,CAAC,IAAIE;AAAA,QACV,WAAW,MAAM,GAAG,SAASC;AAAA,QAC7B;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAEA,UAAM,aAAoG;AAAA,MACxG;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAI,wBAAwB,CAAC;AAAA,IAC/B;AACA,UAAM,oBAAoB,MAAM,QAAQ,IAAI,WAAW,IAAI,OAAM,MAAK,EAAE,SAAS,EAAE,CAAC,CAAC;AACrF,WAAO,kBAAkB,KAAK;AAAA,EAChC,SAAS,IAAI;AACX,UAAM,SAAS,KAAK,CAAC;AACrB,WAAO,CAAC,IAAID;AAAA,MACV,QAAQ,SAASC;AAAA,MACjB;AAAA,MACA,qCAAsC,GAAa;AAAA,MACnD;AAAA,IACF,CAAC;AAAA,EACH;AACF;",
6
- "names": ["error", "ZERO_HASH", "ZERO_HASH", "HydratedTransactionValidationError", "isTransfer", "ZERO_HASH", "BoundWitnessValidator", "HydratedTransactionValidationError", "ZERO_HASH", "HydratedTransactionValidationError", "ZERO_HASH", "HydratedTransactionValidationError", "ZERO_HASH", "HydratedTransactionValidationError", "hexToBigInt", "ZERO_HASH", "HydratedTransactionValidationError", "ZERO_HASH", "HydratedTransactionValidationError", "error", "ZERO_HASH", "HydratedTransactionValidationError", "HydratedTransactionValidationError", "ZERO_HASH"]
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["// Compatibility shim: this package re-exports from @xyo-network/xl1-protocol.\nexport * from '@xyo-network/xl1-protocol/validation'\n"],
5
+ "mappings": ";AACA,cAAc;",
6
+ "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/xl1-validation",
3
- "version": "4.0.11",
3
+ "version": "4.0.12",
4
4
  "description": "XYO Layer One SDK Validation",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -34,11 +34,11 @@
34
34
  "README.md"
35
35
  ],
36
36
  "dependencies": {
37
- "@xyo-network/xl1-protocol-lib": "~4.0.11",
38
- "@xyo-network/xl1-schema": "~4.0.11"
37
+ "@xyo-network/xl1-protocol": "~4.0.12"
39
38
  },
40
39
  "devDependencies": {
41
- "@ariestools/sdk": "~7.0.8",
40
+ "@ariestools/sdk": "~8.0.3",
41
+ "@ariestools/threads": "~8.0.3",
42
42
  "@bitauth/libauth": "~3.0.0",
43
43
  "@metamask/providers": "~22.1.1",
44
44
  "@noble/post-quantum": "~0.6.1",
@@ -46,12 +46,10 @@
46
46
  "@opentelemetry/sdk-trace-base": "~2.9.0",
47
47
  "@scure/base": "~2.2.0",
48
48
  "@scure/bip39": "~2.2.0",
49
- "@xylabs/geo": "~7.0.8",
50
- "@xylabs/threads": "~7.0.8",
51
- "@xylabs/toolchain": "~8.6.2",
52
- "@xylabs/tsconfig": "~8.6.2",
53
- "@xyo-network/sdk": "~7.0.8",
54
- "@xyo-network/sdk-protocol": "~7.0.13",
49
+ "@xylabs/toolchain": "~8.6.10",
50
+ "@xylabs/tsconfig": "~8.6.10",
51
+ "@xyo-network/sdk": "~7.0.11",
52
+ "@xyo-network/sdk-protocol": "~7.0.15",
55
53
  "ajv": "~8.20.0",
56
54
  "async-mutex": "~0.5.0",
57
55
  "debug": "~4.4.3",
@@ -59,16 +57,14 @@
59
57
  "ethers": "~6.17.0",
60
58
  "hash-wasm": "~4.12.0",
61
59
  "idb": "~8.0.3",
62
- "lru-cache": "~11.5.1",
63
60
  "observable-fns": "~0.6.1",
64
61
  "typescript": "~6.0.3",
65
- "vite": "~8.1.3",
66
- "vitest": "~4.1.9",
67
62
  "webextension-polyfill": "~0.12.0",
68
63
  "zod": "~4.4.3"
69
64
  },
70
65
  "peerDependencies": {
71
- "@ariestools/sdk": "^7.0.8",
66
+ "@ariestools/sdk": "^8.0.3",
67
+ "@ariestools/threads": "^8.0.3",
72
68
  "@bitauth/libauth": "^3.0.0",
73
69
  "@metamask/providers": "^22.1.1",
74
70
  "@noble/post-quantum": "^0.6.1",
@@ -76,17 +72,14 @@
76
72
  "@opentelemetry/sdk-trace-base": "^2.9.0",
77
73
  "@scure/base": "^2.2.0",
78
74
  "@scure/bip39": "^2.2.0",
79
- "@xylabs/geo": "^7.0.8",
80
- "@xylabs/threads": "^7.0.8",
81
- "@xyo-network/sdk": "^7.0.8",
82
- "@xyo-network/sdk-protocol": "^7.0.13",
75
+ "@xyo-network/sdk": "^7.0.11",
76
+ "@xyo-network/sdk-protocol": "^7.0.15",
83
77
  "ajv": "^8.20.0",
84
78
  "async-mutex": "^0.5.0",
85
79
  "debug": "^4.4.3",
86
80
  "ethers": "^6.17.0",
87
81
  "hash-wasm": "^4.12.0",
88
82
  "idb": "^8.0.3",
89
- "lru-cache": "^11.5.1",
90
83
  "observable-fns": "^0.6.1",
91
84
  "webextension-polyfill": "^0.12.0",
92
85
  "zod": "^4.4.3"
@@ -97,5 +90,6 @@
97
90
  "engineStrict": true,
98
91
  "publishConfig": {
99
92
  "access": "public"
100
- }
93
+ },
94
+ "deprecated": "Use @xyo-network/xl1-protocol/validation instead. Replace @xyo-network/xl1-validation with @xyo-network/xl1-protocol/validation. This package is a compatibility shim only and will not receive further updates."
101
95
  }
@@ -1,2 +0,0 @@
1
- export * from './validators/index.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/block/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
@@ -1,7 +0,0 @@
1
- import type { XyoAddress } from '@xyo-network/sdk';
2
- import type { HydratedBlockStateValidationFunction, HydratedBlockWithHashMeta, TransactionBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol-lib';
3
- /** Accumulate outflows per address from fees and transfers in the given transactions. */
4
- export declare function accumulateOutflows(transactions: TransactionBoundWitnessWithHashMeta[], payloads: HydratedBlockWithHashMeta[1]): Record<XyoAddress, bigint>;
5
- /** Creates a block state validator that checks cumulative outflows per address do not exceed pre-block balances. */
6
- export declare function BlockCumulativeBalanceValidatorFactory(): HydratedBlockStateValidationFunction;
7
- //# sourceMappingURL=BlockCumulativeBalanceValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BlockCumulativeBalanceValidator.d.ts","sourceRoot":"","sources":["../../../../src/block/validators/BlockCumulativeBalanceValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EACV,oCAAoC,EACpC,yBAAyB,EACzB,mCAAmC,EACpC,MAAM,+BAA+B,CAAA;AA8BtC,yFAAyF;AACzF,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,mCAAmC,EAAE,EACnD,QAAQ,EAAE,yBAAyB,CAAC,CAAC,CAAC,GACrC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAiB5B;AAED,oHAAoH;AACpH,wBAAgB,sCAAsC,IAAI,oCAAoC,CAqC7F"}
@@ -1,2 +0,0 @@
1
- export * from './BlockCumulativeBalanceValidator.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/block/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './validators/index.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/boundwitness/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { BoundWitness, Schema } from '@xyo-network/sdk';
2
- import type { HydratedBoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib';
3
- /** Creates a validator that checks all payload references in a BoundWitness are present, have matching schemas, and optionally conform to an allowed schema list. */
4
- export declare const BoundWitnessReferencesValidator: <T extends BoundWitness = BoundWitness>(allowedSchemas?: Schema[]) => HydratedBoundWitnessValidationFunction<T>;
5
- //# sourceMappingURL=BoundWitnessReferences.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BoundWitnessReferences.d.ts","sourceRoot":"","sources":["../../../../src/boundwitness/validators/BoundWitnessReferences.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEZ,MAAM,EAEP,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,sCAAsC,EAAoC,MAAM,+BAA+B,CAAA;AAO7H,qKAAqK;AACrK,eAAO,MAAM,+BAA+B,GAEvC,CAAC,SAAS,YAAY,GAAG,YAAY,EAAE,iBAAiB,MAAM,EAAE,KAAG,sCAAsC,CAAC,CAAC,CAsC7G,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that all signatures on a BoundWitness are cryptographically valid for their corresponding addresses. */
3
- export declare const BoundWitnessSignaturesValidator: BoundWitnessValidationFunction;
4
- //# sourceMappingURL=BoundWitnessSignatures.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BoundWitnessSignatures.d.ts","sourceRoot":"","sources":["../../../../src/boundwitness/validators/BoundWitnessSignatures.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAA;AAGnF,qHAAqH;AACrH,eAAO,MAAM,+BAA+B,EAAE,8BAsB7C,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './BoundWitnessReferences.ts';
2
- export * from './BoundWitnessSignatures.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/boundwitness/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,6BAA6B,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './validateTransaction.ts';
2
- export * from './validators/index.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transaction/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates a hydrated transaction using built-in validators plus any additional validators provided. */
3
- export declare const validateTransaction: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=validateTransaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validateTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/validateTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,qCAAqC,EAGtC,MAAM,+BAA+B,CAAA;AAStC,0GAA0G;AAC1G,eAAO,MAAM,mBAAmB,EAAE,qCAmCjC,CAAA"}
@@ -1,48 +0,0 @@
1
- import { z } from 'zod';
2
- import type { SignerValidator } from './TransactionTransfersValidator.ts';
3
- /** Authorizes the listed signers to sign for completed-step-reward addresses. */
4
- export declare const CompletedStepRewardAuthorizationZod: z.ZodObject<{
5
- type: z.ZodLiteral<"completedStepReward">;
6
- signers: z.ZodArray<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<Lowercase<string> & {
7
- readonly __hex: true;
8
- } & {
9
- readonly __address: true;
10
- }, string>>, import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<import("@xyo-network/sdk").XyoQuantAddress, string>>]>>;
11
- }, z.core.$strip>;
12
- /** Authorizes the listed signers to sign for derived-receive addresses within a scope. */
13
- export declare const DerivedReceiveAuthorizationZod: z.ZodObject<{
14
- type: z.ZodLiteral<"derivedReceive">;
15
- scope: z.ZodString;
16
- signers: z.ZodArray<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<Lowercase<string> & {
17
- readonly __hex: true;
18
- } & {
19
- readonly __address: true;
20
- }, string>>, import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<import("@xyo-network/sdk").XyoQuantAddress, string>>]>>;
21
- }, z.core.$strip>;
22
- /** A single signer authorization, discriminated by `type` (the deriving-function selector). */
23
- export declare const SignerAuthorizationZod: z.ZodDiscriminatedUnion<[z.ZodObject<{
24
- type: z.ZodLiteral<"completedStepReward">;
25
- signers: z.ZodArray<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<Lowercase<string> & {
26
- readonly __hex: true;
27
- } & {
28
- readonly __address: true;
29
- }, string>>, import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<import("@xyo-network/sdk").XyoQuantAddress, string>>]>>;
30
- }, z.core.$strip>, z.ZodObject<{
31
- type: z.ZodLiteral<"derivedReceive">;
32
- scope: z.ZodString;
33
- signers: z.ZodArray<import("zod/mini").ZodMiniUnion<readonly [import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<Lowercase<string> & {
34
- readonly __hex: true;
35
- } & {
36
- readonly __address: true;
37
- }, string>>, import("zod/mini").ZodMiniPipe<import("zod/mini").ZodMiniString<string>, import("zod/mini").ZodMiniTransform<import("@xyo-network/sdk").XyoQuantAddress, string>>]>>;
38
- }, z.core.$strip>], "type">;
39
- export type CompletedStepRewardAuthorization = z.infer<typeof CompletedStepRewardAuthorizationZod>;
40
- export type DerivedReceiveAuthorization = z.infer<typeof DerivedReceiveAuthorizationZod>;
41
- export type SignerAuthorization = z.infer<typeof SignerAuthorizationZod>;
42
- /**
43
- * Builds the `SignerValidator[]` consumed by `TransactionTransfersValidatorFactory` from a list
44
- * of authorizations. `SelfSignerValidator` is ALWAYS included so ordinary self-transfers pass;
45
- * an empty `authorizations` list therefore means "self only" — deny-all for reward/escrow families.
46
- */
47
- export declare function signerValidatorsFromAuthorizations(authorizations?: SignerAuthorization[]): SignerValidator[];
48
- //# sourceMappingURL=SignerAuthorization.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SignerAuthorization.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/SignerAuthorization.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAA;AAKzE,iFAAiF;AACjF,eAAO,MAAM,mCAAmC;;;;;;;iBAGqB,CAAA;AAErE,0FAA0F;AAC1F,eAAO,MAAM,8BAA8B;;;;;;;;iBAImC,CAAA;AAE9E,+FAA+F;AAC/F,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;2BAGjC,CAAA;AAEF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;AAClG,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAA;AACxF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAkBxE;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,cAAc,GAAE,mBAAmB,EAAO,GAAG,eAAe,EAAE,CAEhH"}
@@ -1,18 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /**
3
- * Validates the transaction's BoundWitness wholistically by delegating to
4
- * `BoundWitnessValidator.validate()`. This covers:
5
- * - signatures: length matches addresses, every signature is cryptographically
6
- * valid for its corresponding address against the BW data hash
7
- * - addresses: uniqueness
8
- * - array length parity: payload_hashes vs payload_schemas
9
- * - schemas: per-schema name validators
10
- * - top-level schema check
11
- * - PayloadValidator.schemaName check
12
- *
13
- * Also emits a friendly diagnostic when the common wallet bug of
14
- * `signatures` vs `$signatures` is detected, so the failure points at the
15
- * actual root cause instead of buried length/missing-signature errors.
16
- */
17
- export declare const TransactionBoundWitnessValidator: HydratedTransactionValidationFunction;
18
- //# sourceMappingURL=TransactionBoundWitnessValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionBoundWitnessValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionBoundWitnessValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAAmC,MAAM,+BAA+B,CAAA;AAqB3H;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gCAAgC,EAAE,qCAa9C,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that transaction timing fields (nbf and exp) are positive, correctly ordered, and within allowed duration limits. */
3
- export declare const TransactionDurationValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionDurationValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionDurationValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionDurationValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAA;AAG1F,kIAAkI;AAClI,eAAO,MAAM,4BAA4B,EAAE,qCA2B1C,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that a hydrated transaction includes all required elevated script hashes. */
3
- export declare const TransactionElevationValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionElevationValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionElevationValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionElevationValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAA;AAG1F,0FAA0F;AAC1F,eAAO,MAAM,6BAA6B,EAAE,qCAoB3C,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that the transaction's from field is a valid address and is included in the BoundWitness addresses. */
3
- export declare const TransactionFromValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionFromValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionFromValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionFromValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,+BAA+B,CAAA;AAG1F,oHAAoH;AACpH,eAAO,MAAM,wBAAwB,EAAE,qCA0BtC,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that transaction fee fields (base, gasLimit, gasPrice, priority) are present and meet minimum requirements. */
3
- export declare const TransactionGasValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionGasValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionGasValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionGasValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qCAAqC,EAEtC,MAAM,+BAA+B,CAAA;AAOtC,4HAA4H;AAC5H,eAAO,MAAM,uBAAuB,EAAE,qCAyErC,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates a transaction against the TransactionBoundWitness JSON schema using AJV. */
3
- export declare const TransactionJsonSchemaValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionJsonSchemaValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionJsonSchemaValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionJsonSchemaValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAA2B,MAAM,+BAA+B,CAAA;AAUnH,yFAAyF;AACzF,eAAO,MAAM,8BAA8B,EAAE,qCAoB5C,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
2
- /** Validates that the transaction's chain ID matches the expected chain ID from the validation context. */
3
- export declare const TransactionProtocolValidator: HydratedTransactionValidationFunction;
4
- //# sourceMappingURL=TransactionProtocolValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionProtocolValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionProtocolValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,qCAAqC,EACtC,MAAM,+BAA+B,CAAA;AAGtC,2GAA2G;AAC3G,eAAO,MAAM,4BAA4B,EAAE,qCAa1C,CAAA"}
@@ -1,17 +0,0 @@
1
- import type { XyoAddress } from '@xyo-network/sdk';
2
- import type { HydratedTransactionValidationFunction, StepIdentity } from '@xyo-network/xl1-protocol-lib';
3
- /** Function type that checks whether a signer is authorized to sign for a given signee address. */
4
- export type SignerValidator = (signer: XyoAddress, signee: XyoAddress, context?: {
5
- address?: XyoAddress;
6
- scope?: string;
7
- step?: StepIdentity;
8
- }) => boolean;
9
- /** A signer validator that only allows an address to sign for itself. */
10
- export declare const SelfSignerValidator: SignerValidator;
11
- /** Creates a signer validator that authorizes specified signers to sign for completed step reward addresses. */
12
- export declare const CompletedStepRewardAddressValidatorFactory: (allowedSigners: XyoAddress[]) => SignerValidator;
13
- /** Creates a signer validator that authorizes specified signers to sign for derived receive addresses within a given scope. */
14
- export declare const DerivedReceiveAddressValidatorFactory: (allowedSigners: XyoAddress[], allowedScope: string) => SignerValidator;
15
- /** Creates a transaction validator that checks all transfers are authorized by the transaction signer. */
16
- export declare function TransactionTransfersValidatorFactory(signerValidators?: SignerValidator[]): HydratedTransactionValidationFunction;
17
- //# sourceMappingURL=TransactionTransfersValidator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TransactionTransfersValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionTransfersValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EACV,qCAAqC,EAAE,YAAY,EAEpD,MAAM,+BAA+B,CAAA;AAStC,mGAAmG;AACnG,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,UAAU,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,KAAK,OAAO,CAAA;AAE1J,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,EAAE,eAA+E,CAAA;AAEjH,gHAAgH;AAChH,eAAO,MAAM,0CAA0C,GAAI,gBAAgB,UAAU,EAAE,KAAG,eAWzF,CAAA;AAED,+HAA+H;AAC/H,eAAO,MAAM,qCAAqC,GAAI,gBAAgB,UAAU,EAAE,EAAE,cAAc,MAAM,KAAG,eAc1G,CAAA;AAED,0GAA0G;AAC1G,wBAAgB,oCAAoC,CAClD,gBAAgB,GAAE,eAAe,EAA0B,GAC1D,qCAAqC,CAwBvC"}
@@ -1,10 +0,0 @@
1
- export * from './SignerAuthorization.ts';
2
- export * from './TransactionBoundWitnessValidator.ts';
3
- export * from './TransactionDurationValidator.ts';
4
- export * from './TransactionElevationValidator.ts';
5
- export * from './TransactionFromValidator.ts';
6
- export * from './TransactionGasValidator.ts';
7
- export * from './TransactionJsonSchemaValidator.ts';
8
- export * from './TransactionProtocolValidator.ts';
9
- export * from './TransactionTransfersValidator.ts';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,uCAAuC,CAAA;AACrD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA;AAClD,cAAc,+BAA+B,CAAA;AAC7C,cAAc,8BAA8B,CAAA;AAC5C,cAAc,qCAAqC,CAAA;AACnD,cAAc,mCAAmC,CAAA;AACjD,cAAc,oCAAoC,CAAA"}