@xyo-network/xl1-validation 1.25.33 → 1.26.2
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/block/validators/BlockCumulativeBalanceValidator.d.ts +1 -1
- package/dist/neutral/block/validators/BlockCumulativeBalanceValidator.d.ts.map +1 -1
- package/dist/neutral/boundwitness/validators/BoundWitnessReferences.d.ts +1 -1
- package/dist/neutral/boundwitness/validators/BoundWitnessReferences.d.ts.map +1 -1
- package/dist/neutral/boundwitness/validators/BoundWitnessSignatures.d.ts +1 -1
- package/dist/neutral/boundwitness/validators/BoundWitnessSignatures.d.ts.map +1 -1
- package/dist/neutral/index.mjs +11 -11
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/transaction/validateTransaction.d.ts +1 -1
- package/dist/neutral/transaction/validateTransaction.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionDurationValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionDurationValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionElevationValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionElevationValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionFromValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionFromValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionGasValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionGasValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionJsonSchemaValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionJsonSchemaValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionProtocolValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionProtocolValidator.d.ts.map +1 -1
- package/dist/neutral/transaction/validators/TransactionTransfersValidator.d.ts +1 -1
- package/dist/neutral/transaction/validators/TransactionTransfersValidator.d.ts.map +1 -1
- package/package.json +6 -4
- package/src/block/validators/BlockCumulativeBalanceValidator.ts +2 -2
- package/src/boundwitness/validators/BoundWitnessReferences.ts +2 -2
- package/src/boundwitness/validators/BoundWitnessSignatures.ts +2 -2
- package/src/transaction/validateTransaction.ts +2 -2
- package/src/transaction/validators/TransactionDurationValidator.ts +2 -2
- package/src/transaction/validators/TransactionElevationValidator.ts +2 -2
- package/src/transaction/validators/TransactionFromValidator.ts +2 -2
- package/src/transaction/validators/TransactionGasValidator.ts +2 -2
- package/src/transaction/validators/TransactionJsonSchemaValidator.ts +2 -2
- package/src/transaction/validators/TransactionProtocolValidator.ts +2 -2
- package/src/transaction/validators/TransactionTransfersValidator.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HydratedBlockStateValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedBlockStateValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Creates a block state validator that checks cumulative outflows per address do not exceed pre-block balances. */
|
|
3
3
|
export declare function BlockCumulativeBalanceValidatorFactory(): HydratedBlockStateValidationFunction;
|
|
4
4
|
//# sourceMappingURL=BlockCumulativeBalanceValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockCumulativeBalanceValidator.d.ts","sourceRoot":"","sources":["../../../../src/block/validators/BlockCumulativeBalanceValidator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oCAAoC,EAErC,MAAM,
|
|
1
|
+
{"version":3,"file":"BlockCumulativeBalanceValidator.d.ts","sourceRoot":"","sources":["../../../../src/block/validators/BlockCumulativeBalanceValidator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oCAAoC,EAErC,MAAM,+BAA+B,CAAA;AAetC,oHAAoH;AACpH,wBAAgB,sCAAsC,IAAI,oCAAoC,CAqD7F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BoundWitness, Schema } from '@xyo-network/sdk-js';
|
|
2
|
-
import type { HydratedBoundWitnessValidationFunction } from '@xyo-network/xl1-protocol';
|
|
2
|
+
import type { HydratedBoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
3
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
4
|
export declare const BoundWitnessReferencesValidator: <T extends BoundWitness = BoundWitness>(allowedSchemas?: Schema[]) => HydratedBoundWitnessValidationFunction<T>;
|
|
5
5
|
//# sourceMappingURL=BoundWitnessReferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,qBAAqB,CAAA;AAE5B,OAAO,KAAK,EAAE,sCAAsC,EAAoC,MAAM,
|
|
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,qBAAqB,CAAA;AAE5B,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,CAuC7G,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that all signatures on a BoundWitness are cryptographically valid for their corresponding addresses. */
|
|
3
3
|
export declare const BoundWitnessSignaturesValidator: BoundWitnessValidationFunction;
|
|
4
4
|
//# sourceMappingURL=BoundWitnessSignatures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BoundWitnessSignatures.d.ts","sourceRoot":"","sources":["../../../../src/boundwitness/validators/BoundWitnessSignatures.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"BoundWitnessSignatures.d.ts","sourceRoot":"","sources":["../../../../src/boundwitness/validators/BoundWitnessSignatures.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,+BAA+B,CAAA;AAGnF,qHAAqH;AACrH,eAAO,MAAM,+BAA+B,EAAE,8BAsB7C,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
HydratedBlockStateValidationError,
|
|
7
7
|
isTransactionBoundWitnessWithHashMeta,
|
|
8
8
|
isTransfer
|
|
9
|
-
} from "@xyo-network/xl1-protocol";
|
|
9
|
+
} from "@xyo-network/xl1-protocol-lib";
|
|
10
10
|
function transactionFeeCost(tx) {
|
|
11
11
|
const {
|
|
12
12
|
base,
|
|
@@ -59,7 +59,7 @@ function BlockCumulativeBalanceValidatorFactory() {
|
|
|
59
59
|
// src/boundwitness/validators/BoundWitnessReferences.ts
|
|
60
60
|
import { ZERO_HASH } from "@xylabs/sdk-js";
|
|
61
61
|
import { isAnyPayload } from "@xyo-network/sdk-js";
|
|
62
|
-
import { HydratedBoundWitnessValidationError } from "@xyo-network/xl1-protocol";
|
|
62
|
+
import { HydratedBoundWitnessValidationError } from "@xyo-network/xl1-protocol-lib";
|
|
63
63
|
function getPayloadsFromPayloadArray(payloads, hashes) {
|
|
64
64
|
return hashes.map((hash) => payloads.find((payload) => payload._hash === hash || payload._dataHash === hash));
|
|
65
65
|
}
|
|
@@ -101,7 +101,7 @@ var BoundWitnessReferencesValidator = (allowedSchemas) => ([bw, payloadSet]) =>
|
|
|
101
101
|
import { ZERO_HASH as ZERO_HASH2 } from "@xylabs/sdk-js";
|
|
102
102
|
import { toArrayBuffer } from "@xylabs/sdk-js";
|
|
103
103
|
import { BoundWitnessBuilder, BoundWitnessValidator } from "@xyo-network/sdk-js";
|
|
104
|
-
import { BoundWitnessValidationError } from "@xyo-network/xl1-protocol";
|
|
104
|
+
import { BoundWitnessValidationError } from "@xyo-network/xl1-protocol-lib";
|
|
105
105
|
var BoundWitnessSignaturesValidator = async (bw) => {
|
|
106
106
|
const errors = [];
|
|
107
107
|
try {
|
|
@@ -125,11 +125,11 @@ var BoundWitnessSignaturesValidator = async (bw) => {
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
// src/transaction/validateTransaction.ts
|
|
128
|
-
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
128
|
+
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol-lib";
|
|
129
129
|
|
|
130
130
|
// src/transaction/validators/TransactionDurationValidator.ts
|
|
131
131
|
import { ZERO_HASH as ZERO_HASH3 } from "@xylabs/sdk-js";
|
|
132
|
-
import { HydratedTransactionValidationError } from "@xyo-network/xl1-protocol";
|
|
132
|
+
import { HydratedTransactionValidationError } from "@xyo-network/xl1-protocol-lib";
|
|
133
133
|
var TransactionDurationValidator = (context, tx) => {
|
|
134
134
|
const errors = [];
|
|
135
135
|
try {
|
|
@@ -155,7 +155,7 @@ var TransactionDurationValidator = (context, tx) => {
|
|
|
155
155
|
|
|
156
156
|
// src/transaction/validators/TransactionElevationValidator.ts
|
|
157
157
|
import { ZERO_HASH as ZERO_HASH4 } from "@xylabs/sdk-js";
|
|
158
|
-
import { HydratedTransactionValidationError as HydratedTransactionValidationError2 } from "@xyo-network/xl1-protocol";
|
|
158
|
+
import { HydratedTransactionValidationError as HydratedTransactionValidationError2 } from "@xyo-network/xl1-protocol-lib";
|
|
159
159
|
import { extractElevatedHashes } from "@xyo-network/xl1-protocol-sdk";
|
|
160
160
|
var TransactionElevationValidator = (context, tx) => {
|
|
161
161
|
const errors = [];
|
|
@@ -179,7 +179,7 @@ var TransactionElevationValidator = (context, tx) => {
|
|
|
179
179
|
// src/transaction/validators/TransactionFromValidator.ts
|
|
180
180
|
import { asAddress, ZERO_HASH as ZERO_HASH5 } from "@xylabs/sdk-js";
|
|
181
181
|
import { addressesContains } from "@xyo-network/sdk-js";
|
|
182
|
-
import { HydratedTransactionValidationError as HydratedTransactionValidationError3 } from "@xyo-network/xl1-protocol";
|
|
182
|
+
import { HydratedTransactionValidationError as HydratedTransactionValidationError3 } from "@xyo-network/xl1-protocol-lib";
|
|
183
183
|
var TransactionFromValidator = (context, tx) => {
|
|
184
184
|
const errors = [];
|
|
185
185
|
try {
|
|
@@ -211,7 +211,7 @@ import {
|
|
|
211
211
|
AttoXL1,
|
|
212
212
|
HydratedTransactionValidationError as HydratedTransactionValidationError4,
|
|
213
213
|
minTransactionFees
|
|
214
|
-
} from "@xyo-network/xl1-protocol";
|
|
214
|
+
} from "@xyo-network/xl1-protocol-lib";
|
|
215
215
|
var TransactionGasValidator = (context, tx) => {
|
|
216
216
|
const errors = [];
|
|
217
217
|
try {
|
|
@@ -299,7 +299,7 @@ var parseFees = (fees) => {
|
|
|
299
299
|
// src/transaction/validators/TransactionJsonSchemaValidator.ts
|
|
300
300
|
import { ZERO_HASH as ZERO_HASH7 } from "@xylabs/sdk-js";
|
|
301
301
|
import { PayloadBuilder } from "@xyo-network/sdk-js";
|
|
302
|
-
import { HydratedTransactionValidationError as HydratedTransactionValidationError5 } from "@xyo-network/xl1-protocol";
|
|
302
|
+
import { HydratedTransactionValidationError as HydratedTransactionValidationError5 } from "@xyo-network/xl1-protocol-lib";
|
|
303
303
|
import { TransactionBoundWitnessJsonSchema } from "@xyo-network/xl1-schema";
|
|
304
304
|
import { Ajv } from "ajv";
|
|
305
305
|
var ajv = new Ajv({ allErrors: true, strict: true });
|
|
@@ -325,7 +325,7 @@ var TransactionJsonSchemaValidator = (context, tx) => {
|
|
|
325
325
|
|
|
326
326
|
// src/transaction/validators/TransactionProtocolValidator.ts
|
|
327
327
|
import { ZERO_HASH as ZERO_HASH8 } from "@xylabs/sdk-js";
|
|
328
|
-
import { HydratedTransactionValidationError as HydratedTransactionValidationError6 } from "@xyo-network/xl1-protocol";
|
|
328
|
+
import { HydratedTransactionValidationError as HydratedTransactionValidationError6 } from "@xyo-network/xl1-protocol-lib";
|
|
329
329
|
var TransactionProtocolValidator = async (context, tx) => {
|
|
330
330
|
const errors = [];
|
|
331
331
|
try {
|
|
@@ -340,7 +340,7 @@ var TransactionProtocolValidator = async (context, tx) => {
|
|
|
340
340
|
|
|
341
341
|
// src/transaction/validators/TransactionTransfersValidator.ts
|
|
342
342
|
import { isDefined, isUndefined } from "@xylabs/sdk-js";
|
|
343
|
-
import { HydratedTransactionValidationError as HydratedTransactionValidationError7, isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol";
|
|
343
|
+
import { HydratedTransactionValidationError as HydratedTransactionValidationError7, isTransfer as isTransfer2 } from "@xyo-network/xl1-protocol-lib";
|
|
344
344
|
import {
|
|
345
345
|
completedStepRewardAddress,
|
|
346
346
|
derivedReceiveAddress,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/block/validators/BlockCumulativeBalanceValidator.ts","../../src/boundwitness/validators/BoundWitnessReferences.ts","../../src/boundwitness/validators/BoundWitnessSignatures.ts","../../src/transaction/validateTransaction.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","../../src/transaction/validators/TransactionTransfersValidator.ts"],"sourcesContent":["import {\n type Address, type Hex, hexToBigInt,\n} from '@xylabs/sdk-js'\nimport type {\n HydratedBlockStateValidationFunction,\n TransactionBoundWitnessWithHashMeta,\n} from '@xyo-network/xl1-protocol'\nimport {\n HydratedBlockStateValidationError,\n isTransactionBoundWitnessWithHashMeta,\n isTransfer,\n} from '@xyo-network/xl1-protocol'\n\n/** Compute the maximum fee commitment for a transaction (base + priority + gasLimit * gasPrice). */\nfunction transactionFeeCost(tx: TransactionBoundWitnessWithHashMeta): bigint {\n const {\n base, gasLimit, gasPrice, priority,\n } = tx.fees\n return hexToBigInt(base) + hexToBigInt(priority) + (hexToBigInt(gasLimit) * hexToBigInt(gasPrice))\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 // Accumulate outflows per address\n const outflows: Record<Address, bigint> = {}\n\n for (const tx of transactions) {\n // Fee cost charged to the transaction sender\n const feeCost = transactionFeeCost(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 if (!txPayloadHashes.has(payload._hash) || !isTransfer(payload)) continue\n const { from } = payload\n for (const amount of Object.values(payload.transfers) as Hex[]) {\n outflows[from] = (outflows[from] ?? 0n) + hexToBigInt(amount)\n }\n }\n }\n\n // Query pre-block balances for all addresses with outflows\n const addresses = Object.keys(outflows) as Address[]\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 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 '@xylabs/sdk-js'\nimport { ZERO_HASH } from '@xylabs/sdk-js'\nimport type {\n BoundWitness,\n Payload,\n Schema,\n WithHashMeta,\n} from '@xyo-network/sdk-js'\nimport { isAnyPayload } from '@xyo-network/sdk-js'\nimport type { HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedBoundWitnessValidationError } from '@xyo-network/xl1-protocol'\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 (let 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: ${ex}`)\n error.cause = ex\n errors.push(error)\n }\n return errors\n }\n","import { type Address, ZERO_HASH } from '@xylabs/sdk-js'\nimport { toArrayBuffer } from '@xylabs/sdk-js'\nimport type { BoundWitness, WithStorageMeta } from '@xyo-network/sdk-js'\nimport { BoundWitnessBuilder, BoundWitnessValidator } from '@xyo-network/sdk-js'\nimport type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol'\nimport { BoundWitnessValidationError } from '@xyo-network/xl1-protocol'\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: [Address, Error[]][] = await Promise.all(bw.addresses.map(async (address, index) => {\n return [address, await BoundWitnessValidator.validateSignature(\n toArrayBuffer(dataHash),\n toArrayBuffer(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 type {\n HydratedTransactionValidationFunction,\n HydratedTransactionValidationFunctionContext,\n HydratedTransactionWithHashMeta,\n} from '@xyo-network/xl1-protocol'\nimport { isTransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\nimport {\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 async function validateTransaction(\n context: HydratedTransactionValidationFunctionContext,\n tx: HydratedTransactionWithHashMeta,\n additionalValidators?: HydratedTransactionValidationFunction[],\n) {\n try {\n if (!isTransactionBoundWitness(tx[0])) {\n return [new Error('failed isTransactionBoundWitness identity check')]\n }\n\n const validators: HydratedTransactionValidationFunction<HydratedTransactionValidationFunctionContext>[] = [\n TransactionProtocolValidator,\n TransactionDurationValidator,\n TransactionFromValidator,\n TransactionGasValidator,\n TransactionElevationValidator,\n ...(additionalValidators ?? []),\n ]\n return (await Promise.all(validators.map(v => v(context, tx)))).flat()\n } catch (ex) {\n return [(new Error(`Failed TransactionGasValidator: ${ex}`))]\n }\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\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: ${ex}`,\n ex,\n ))\n }\n\n return errors\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\nimport { extractElevatedHashes } from '@xyo-network/xl1-protocol-sdk'\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: ${ex}`,\n ex,\n ))\n }\n return errors\n}\n","import { asAddress, ZERO_HASH } from '@xylabs/sdk-js'\nimport { addressesContains } from '@xyo-network/sdk-js'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\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 = asAddress(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: ${ex}`,\n ex,\n ))\n }\n return errors\n}\n","import { hexToBigInt, ZERO_HASH } from '@xylabs/sdk-js'\nimport type {\n HydratedTransactionValidationFunction,\n TransactionFeesBigInt, TransactionFeesHex,\n} from '@xyo-network/xl1-protocol'\nimport {\n AttoXL1,\n HydratedTransactionValidationError,\n minTransactionFees,\n} from '@xyo-network/xl1-protocol'\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: ${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 '@xylabs/sdk-js'\nimport { PayloadBuilder } from '@xyo-network/sdk-js'\nimport type { HydratedTransactionValidationFunction, TransactionBoundWitness } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\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 if (validate === undefined) 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 )\n error.cause = validate.errors\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 '@xylabs/sdk-js'\nimport type {\n ChainId,\n HydratedTransactionValidationFunction,\n} from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\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","import type { Address } from '@xylabs/sdk-js'\nimport { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport type {\n HydratedTransactionValidationFunction, StepIdentity,\n Transfer,\n} from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError, isTransfer } from '@xyo-network/xl1-protocol'\nimport {\n completedStepRewardAddress, derivedReceiveAddress, elevatedPayloads,\n} from '@xyo-network/xl1-protocol-sdk'\n\n/** Function type that checks whether a signer is authorized to sign for a given signee address. */\nexport type SignerValidator = (signer: Address, signee: Address, context?: { address?: Address; scope?: string; step?: StepIdentity }) => boolean\n\n/** Maps addresses to their list of authorized signer addresses. */\nexport type SignerMapping = Map<Address, Address[]>\n\n/** A signer validator that only allows an address to sign for itself. */\nexport const SelfSignerValidator: SignerValidator = (signer: Address, signee: Address) => signer === signee\n\n/** Creates a signer validator that authorizes specified signers to sign for completed step reward addresses. */\nexport const CompletedStepRewardAddressValidatorFactory = (allowedSigners: Address[]): SignerValidator => (\n signer: Address,\n signee: Address,\n context?: { step?: StepIdentity },\n) => {\n const step = context?.step\n if (isDefined(step)) {\n const contextAddress = completedStepRewardAddress(step)\n return allowedSigners.includes(signer) && signee === contextAddress\n } else {\n return false\n }\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: Address[], allowedScope: string): SignerValidator => (\n signer: Address,\n signee: Address,\n context?: { address?: Address; 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 } else {\n return false\n }\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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_HASH","HydratedTransactionValidationError","hexToBigInt","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","HydratedTransactionValidationError","isTransfer"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/validators/BlockCumulativeBalanceValidator.ts","../../src/boundwitness/validators/BoundWitnessReferences.ts","../../src/boundwitness/validators/BoundWitnessSignatures.ts","../../src/transaction/validateTransaction.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","../../src/transaction/validators/TransactionTransfersValidator.ts"],"sourcesContent":["import {\n type Address, type Hex, hexToBigInt,\n} from '@xylabs/sdk-js'\nimport type {\n HydratedBlockStateValidationFunction,\n TransactionBoundWitnessWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport {\n HydratedBlockStateValidationError,\n isTransactionBoundWitnessWithHashMeta,\n isTransfer,\n} from '@xyo-network/xl1-protocol-lib'\n\n/** Compute the maximum fee commitment for a transaction (base + priority + gasLimit * gasPrice). */\nfunction transactionFeeCost(tx: TransactionBoundWitnessWithHashMeta): bigint {\n const {\n base, gasLimit, gasPrice, priority,\n } = tx.fees\n return hexToBigInt(base) + hexToBigInt(priority) + (hexToBigInt(gasLimit) * hexToBigInt(gasPrice))\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 // Accumulate outflows per address\n const outflows: Record<Address, bigint> = {}\n\n for (const tx of transactions) {\n // Fee cost charged to the transaction sender\n const feeCost = transactionFeeCost(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 if (!txPayloadHashes.has(payload._hash) || !isTransfer(payload)) continue\n const { from } = payload\n for (const amount of Object.values(payload.transfers) as Hex[]) {\n outflows[from] = (outflows[from] ?? 0n) + hexToBigInt(amount)\n }\n }\n }\n\n // Query pre-block balances for all addresses with outflows\n const addresses = Object.keys(outflows) as Address[]\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 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 '@xylabs/sdk-js'\nimport { ZERO_HASH } from '@xylabs/sdk-js'\nimport type {\n BoundWitness,\n Payload,\n Schema,\n WithHashMeta,\n} from '@xyo-network/sdk-js'\nimport { isAnyPayload } from '@xyo-network/sdk-js'\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 (let 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: ${ex}`)\n error.cause = ex\n errors.push(error)\n }\n return errors\n }\n","import { type Address, ZERO_HASH } from '@xylabs/sdk-js'\nimport { toArrayBuffer } from '@xylabs/sdk-js'\nimport type { BoundWitness, WithStorageMeta } from '@xyo-network/sdk-js'\nimport { BoundWitnessBuilder, BoundWitnessValidator } from '@xyo-network/sdk-js'\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: [Address, Error[]][] = await Promise.all(bw.addresses.map(async (address, index) => {\n return [address, await BoundWitnessValidator.validateSignature(\n toArrayBuffer(dataHash),\n toArrayBuffer(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 type {\n HydratedTransactionValidationFunction,\n HydratedTransactionValidationFunctionContext,\n HydratedTransactionWithHashMeta,\n} from '@xyo-network/xl1-protocol-lib'\nimport { isTransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'\n\nimport {\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 async function validateTransaction(\n context: HydratedTransactionValidationFunctionContext,\n tx: HydratedTransactionWithHashMeta,\n additionalValidators?: HydratedTransactionValidationFunction[],\n) {\n try {\n if (!isTransactionBoundWitness(tx[0])) {\n return [new Error('failed isTransactionBoundWitness identity check')]\n }\n\n const validators: HydratedTransactionValidationFunction<HydratedTransactionValidationFunctionContext>[] = [\n TransactionProtocolValidator,\n TransactionDurationValidator,\n TransactionFromValidator,\n TransactionGasValidator,\n TransactionElevationValidator,\n ...(additionalValidators ?? []),\n ]\n return (await Promise.all(validators.map(v => v(context, tx)))).flat()\n } catch (ex) {\n return [(new Error(`Failed TransactionGasValidator: ${ex}`))]\n }\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\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: ${ex}`,\n ex,\n ))\n }\n\n return errors\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'\nimport { extractElevatedHashes } from '@xyo-network/xl1-protocol-sdk'\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: ${ex}`,\n ex,\n ))\n }\n return errors\n}\n","import { asAddress, ZERO_HASH } from '@xylabs/sdk-js'\nimport { addressesContains } from '@xyo-network/sdk-js'\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 = asAddress(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: ${ex}`,\n ex,\n ))\n }\n return errors\n}\n","import { hexToBigInt, ZERO_HASH } from '@xylabs/sdk-js'\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: ${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 '@xylabs/sdk-js'\nimport { PayloadBuilder } from '@xyo-network/sdk-js'\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 if (validate === undefined) 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 )\n error.cause = validate.errors\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 '@xylabs/sdk-js'\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","import type { Address } from '@xylabs/sdk-js'\nimport { isDefined, isUndefined } from '@xylabs/sdk-js'\nimport type {\n HydratedTransactionValidationFunction, StepIdentity,\n Transfer,\n} from '@xyo-network/xl1-protocol-lib'\nimport { HydratedTransactionValidationError, isTransfer } from '@xyo-network/xl1-protocol-lib'\nimport {\n completedStepRewardAddress, derivedReceiveAddress, elevatedPayloads,\n} from '@xyo-network/xl1-protocol-sdk'\n\n/** Function type that checks whether a signer is authorized to sign for a given signee address. */\nexport type SignerValidator = (signer: Address, signee: Address, context?: { address?: Address; scope?: string; step?: StepIdentity }) => boolean\n\n/** Maps addresses to their list of authorized signer addresses. */\nexport type SignerMapping = Map<Address, Address[]>\n\n/** A signer validator that only allows an address to sign for itself. */\nexport const SelfSignerValidator: SignerValidator = (signer: Address, signee: Address) => signer === signee\n\n/** Creates a signer validator that authorizes specified signers to sign for completed step reward addresses. */\nexport const CompletedStepRewardAddressValidatorFactory = (allowedSigners: Address[]): SignerValidator => (\n signer: Address,\n signee: Address,\n context?: { step?: StepIdentity },\n) => {\n const step = context?.step\n if (isDefined(step)) {\n const contextAddress = completedStepRewardAddress(step)\n return allowedSigners.includes(signer) && signee === contextAddress\n } else {\n return false\n }\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: Address[], allowedScope: string): SignerValidator => (\n signer: Address,\n signee: Address,\n context?: { address?: Address; 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 } else {\n return false\n }\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"],"mappings":";AAAA;AAAA,EAC0B;AAAA,OACnB;AAKP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,mBAAmB,IAAiD;AAC3E,QAAM;AAAA,IACJ;AAAA,IAAM;AAAA,IAAU;AAAA,IAAU;AAAA,EAC5B,IAAI,GAAG;AACP,SAAO,YAAY,IAAI,IAAI,YAAY,QAAQ,IAAK,YAAY,QAAQ,IAAI,YAAY,QAAQ;AAClG;AAGO,SAAS,yCAA+E;AAC7F,SAAO,OAAO,SAAS,kBAAkB;AACvC,UAAM,CAAC,SAAS,QAAQ,IAAI;AAG5B,UAAM,eAAe,SAAS,OA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,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF,SAAS,IAAI;AACX,aAAO,KAAK,IAAIA,oCAAmC,WAAW,CAAC,EAAE,OAAO,YAAY,uBAAuB,EAAE,CAAC;AAAA,IAChH;AACA,WAAO,MAAM,QAAQ,QAAQ,MAAM;AAAA,EACrC;AACF;;;APnEA,eAAsB,oBACpB,SACA,IACA,sBACA;AACA,MAAI;AACF,QAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,GAAG;AACrC,aAAO,CAAC,IAAI,MAAM,iDAAiD,CAAC;AAAA,IACtE;AAEA,UAAM,aAAoG;AAAA,MACxG;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAI,wBAAwB,CAAC;AAAA,IAC/B;AACA,YAAQ,MAAM,QAAQ,IAAI,WAAW,IAAI,OAAK,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,KAAK;AAAA,EACvE,SAAS,IAAI;AACX,WAAO,CAAE,IAAI,MAAM,mCAAmC,EAAE,EAAE,CAAE;AAAA,EAC9D;AACF;","names":["ZERO_HASH","ZERO_HASH","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","hexToBigInt","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","HydratedTransactionValidationError","isTransfer"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction, HydratedTransactionValidationFunctionContext, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction, HydratedTransactionValidationFunctionContext, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates a hydrated transaction using built-in validators plus any additional validators provided. */
|
|
3
3
|
export declare function validateTransaction(context: HydratedTransactionValidationFunctionContext, tx: HydratedTransactionWithHashMeta, additionalValidators?: HydratedTransactionValidationFunction[]): Promise<Error[]>;
|
|
4
4
|
//# sourceMappingURL=validateTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/validateTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EACrC,4CAA4C,EAC5C,+BAA+B,EAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"validateTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/validateTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EACrC,4CAA4C,EAC5C,+BAA+B,EAChC,MAAM,+BAA+B,CAAA;AAQtC,0GAA0G;AAC1G,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,4CAA4C,EACrD,EAAE,EAAE,+BAA+B,EACnC,oBAAoB,CAAC,EAAE,qCAAqC,EAAE,oBAmB/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that transaction timing fields (nbf and exp) are positive, correctly ordered, and within allowed duration limits. */
|
|
3
3
|
export declare const TransactionDurationValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionDurationValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionDurationValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionDurationValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,
|
|
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 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that a hydrated transaction includes all required elevated script hashes. */
|
|
3
3
|
export declare const TransactionElevationValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionElevationValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionElevationValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionElevationValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,
|
|
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;AAI1F,0FAA0F;AAC1F,eAAO,MAAM,6BAA6B,EAAE,qCAoB3C,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that the transaction's from field is a valid address and is included in the BoundWitness addresses. */
|
|
3
3
|
export declare const TransactionFromValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionFromValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionFromValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionFromValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,
|
|
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 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that transaction fee fields (base, gasLimit, gasPrice, priority) are present and meet minimum requirements. */
|
|
3
3
|
export declare const TransactionGasValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionGasValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionGasValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionGasValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,qCAAqC,EAEtC,MAAM,
|
|
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 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates a transaction against the TransactionBoundWitness JSON schema using AJV. */
|
|
3
3
|
export declare const TransactionJsonSchemaValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionJsonSchemaValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionJsonSchemaValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionJsonSchemaValidator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qCAAqC,EAA2B,MAAM,
|
|
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 +1,4 @@
|
|
|
1
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol';
|
|
1
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib';
|
|
2
2
|
/** Validates that the transaction's chain ID matches the expected chain ID from the validation context. */
|
|
3
3
|
export declare const TransactionProtocolValidator: HydratedTransactionValidationFunction;
|
|
4
4
|
//# sourceMappingURL=TransactionProtocolValidator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionProtocolValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionProtocolValidator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,qCAAqC,EACtC,MAAM,
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import type { Address } from '@xylabs/sdk-js';
|
|
2
|
-
import type { HydratedTransactionValidationFunction, StepIdentity } from '@xyo-network/xl1-protocol';
|
|
2
|
+
import type { HydratedTransactionValidationFunction, StepIdentity } from '@xyo-network/xl1-protocol-lib';
|
|
3
3
|
/** Function type that checks whether a signer is authorized to sign for a given signee address. */
|
|
4
4
|
export type SignerValidator = (signer: Address, signee: Address, context?: {
|
|
5
5
|
address?: Address;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionTransfersValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionTransfersValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EACV,qCAAqC,EAAE,YAAY,EAEpD,MAAM,
|
|
1
|
+
{"version":3,"file":"TransactionTransfersValidator.d.ts","sourceRoot":"","sources":["../../../../src/transaction/validators/TransactionTransfersValidator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,KAAK,EACV,qCAAqC,EAAE,YAAY,EAEpD,MAAM,+BAA+B,CAAA;AAMtC,mGAAmG;AACnG,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,KAAK,OAAO,CAAA;AAEjJ,mEAAmE;AACnE,MAAM,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAA;AAEnD,yEAAyE;AACzE,eAAO,MAAM,mBAAmB,EAAE,eAAyE,CAAA;AAE3G,gHAAgH;AAChH,eAAO,MAAM,0CAA0C,GAAI,gBAAgB,OAAO,EAAE,KAAG,eAYtF,CAAA;AAED,+HAA+H;AAC/H,eAAO,MAAM,qCAAqC,GAAI,gBAAgB,OAAO,EAAE,EAAE,cAAc,MAAM,KAAG,eAevG,CAAA;AAED,0GAA0G;AAC1G,wBAAgB,oCAAoC,CAClD,gBAAgB,GAAE,eAAe,EAA0B,GAC1D,qCAAqC,CAwBvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/xl1-validation",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.2",
|
|
4
4
|
"description": "XYO Layer One SDK Validation",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
"!**/*.test.*"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@xyo-network/xl1-protocol": "~1.
|
|
42
|
-
"@xyo-network/xl1-protocol-sdk": "~1.
|
|
43
|
-
"@xyo-network/xl1-schema": "~1.
|
|
41
|
+
"@xyo-network/xl1-protocol-lib": "~1.26.2",
|
|
42
|
+
"@xyo-network/xl1-protocol-sdk": "~1.26.2",
|
|
43
|
+
"@xyo-network/xl1-schema": "~1.26.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
+
"@opentelemetry/api": "^1.9.0",
|
|
46
47
|
"@types/node": "^25.5.0",
|
|
47
48
|
"@xylabs/sdk-js": "^5.0.86",
|
|
48
49
|
"@xylabs/ts-scripts-yarn3": "~7.4.25",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
"zod": "~4.3.6"
|
|
57
58
|
},
|
|
58
59
|
"peerDependencies": {
|
|
60
|
+
"@opentelemetry/api": "^1",
|
|
59
61
|
"@xylabs/sdk-js": "^5",
|
|
60
62
|
"@xyo-network/sdk-js": "^5",
|
|
61
63
|
"ajv": "^8",
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
import type {
|
|
5
5
|
HydratedBlockStateValidationFunction,
|
|
6
6
|
TransactionBoundWitnessWithHashMeta,
|
|
7
|
-
} from '@xyo-network/xl1-protocol'
|
|
7
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
8
8
|
import {
|
|
9
9
|
HydratedBlockStateValidationError,
|
|
10
10
|
isTransactionBoundWitnessWithHashMeta,
|
|
11
11
|
isTransfer,
|
|
12
|
-
} from '@xyo-network/xl1-protocol'
|
|
12
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
13
13
|
|
|
14
14
|
/** Compute the maximum fee commitment for a transaction (base + priority + gasLimit * gasPrice). */
|
|
15
15
|
function transactionFeeCost(tx: TransactionBoundWitnessWithHashMeta): bigint {
|
|
@@ -7,8 +7,8 @@ import type {
|
|
|
7
7
|
WithHashMeta,
|
|
8
8
|
} from '@xyo-network/sdk-js'
|
|
9
9
|
import { isAnyPayload } from '@xyo-network/sdk-js'
|
|
10
|
-
import type { HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol'
|
|
11
|
-
import { HydratedBoundWitnessValidationError } from '@xyo-network/xl1-protocol'
|
|
10
|
+
import type { HydratedBoundWitnessValidationFunction, HydratedBoundWitnessWithHashMeta } from '@xyo-network/xl1-protocol-lib'
|
|
11
|
+
import { HydratedBoundWitnessValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
12
12
|
|
|
13
13
|
function getPayloadsFromPayloadArray(payloads: WithHashMeta<Payload>[], hashes: Hash[]): (WithHashMeta<Payload> | undefined)[] {
|
|
14
14
|
return hashes.map(hash => payloads.find(payload => payload._hash === hash || payload._dataHash === hash))
|
|
@@ -2,8 +2,8 @@ import { type Address, ZERO_HASH } from '@xylabs/sdk-js'
|
|
|
2
2
|
import { toArrayBuffer } from '@xylabs/sdk-js'
|
|
3
3
|
import type { BoundWitness, WithStorageMeta } from '@xyo-network/sdk-js'
|
|
4
4
|
import { BoundWitnessBuilder, BoundWitnessValidator } from '@xyo-network/sdk-js'
|
|
5
|
-
import type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol'
|
|
6
|
-
import { BoundWitnessValidationError } from '@xyo-network/xl1-protocol'
|
|
5
|
+
import type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol-lib'
|
|
6
|
+
import { BoundWitnessValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
7
7
|
|
|
8
8
|
/** Validates that all signatures on a BoundWitness are cryptographically valid for their corresponding addresses. */
|
|
9
9
|
export const BoundWitnessSignaturesValidator: BoundWitnessValidationFunction = async (
|
|
@@ -2,8 +2,8 @@ import type {
|
|
|
2
2
|
HydratedTransactionValidationFunction,
|
|
3
3
|
HydratedTransactionValidationFunctionContext,
|
|
4
4
|
HydratedTransactionWithHashMeta,
|
|
5
|
-
} from '@xyo-network/xl1-protocol'
|
|
6
|
-
import { isTransactionBoundWitness } from '@xyo-network/xl1-protocol'
|
|
5
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
6
|
+
import { isTransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
TransactionDurationValidator,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZERO_HASH } from '@xylabs/sdk-js'
|
|
2
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'
|
|
3
|
-
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'
|
|
2
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'
|
|
3
|
+
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
4
4
|
|
|
5
5
|
/** Validates that transaction timing fields (nbf and exp) are positive, correctly ordered, and within allowed duration limits. */
|
|
6
6
|
export const TransactionDurationValidator: HydratedTransactionValidationFunction = (
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ZERO_HASH } from '@xylabs/sdk-js'
|
|
2
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'
|
|
3
|
-
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'
|
|
2
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'
|
|
3
|
+
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
4
4
|
import { extractElevatedHashes } from '@xyo-network/xl1-protocol-sdk'
|
|
5
5
|
|
|
6
6
|
/** Validates that a hydrated transaction includes all required elevated script hashes. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { asAddress, ZERO_HASH } from '@xylabs/sdk-js'
|
|
2
2
|
import { addressesContains } from '@xyo-network/sdk-js'
|
|
3
|
-
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol'
|
|
4
|
-
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { HydratedTransactionValidationFunction } from '@xyo-network/xl1-protocol-lib'
|
|
4
|
+
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
5
5
|
|
|
6
6
|
/** Validates that the transaction's from field is a valid address and is included in the BoundWitness addresses. */
|
|
7
7
|
export const TransactionFromValidator: HydratedTransactionValidationFunction = (
|
|
@@ -2,12 +2,12 @@ import { hexToBigInt, ZERO_HASH } from '@xylabs/sdk-js'
|
|
|
2
2
|
import type {
|
|
3
3
|
HydratedTransactionValidationFunction,
|
|
4
4
|
TransactionFeesBigInt, TransactionFeesHex,
|
|
5
|
-
} from '@xyo-network/xl1-protocol'
|
|
5
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
6
6
|
import {
|
|
7
7
|
AttoXL1,
|
|
8
8
|
HydratedTransactionValidationError,
|
|
9
9
|
minTransactionFees,
|
|
10
|
-
} from '@xyo-network/xl1-protocol'
|
|
10
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
11
11
|
|
|
12
12
|
/** Validates that transaction fee fields (base, gasLimit, gasPrice, priority) are present and meet minimum requirements. */
|
|
13
13
|
export const TransactionGasValidator: HydratedTransactionValidationFunction = (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZERO_HASH } from '@xylabs/sdk-js'
|
|
2
2
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
3
|
-
import type { HydratedTransactionValidationFunction, TransactionBoundWitness } from '@xyo-network/xl1-protocol'
|
|
4
|
-
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'
|
|
3
|
+
import type { HydratedTransactionValidationFunction, TransactionBoundWitness } from '@xyo-network/xl1-protocol-lib'
|
|
4
|
+
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
5
5
|
import { TransactionBoundWitnessJsonSchema } from '@xyo-network/xl1-schema'
|
|
6
6
|
import type { ValidateFunction } from 'ajv'
|
|
7
7
|
import { Ajv } from 'ajv'
|
|
@@ -2,8 +2,8 @@ import { ZERO_HASH } from '@xylabs/sdk-js'
|
|
|
2
2
|
import type {
|
|
3
3
|
ChainId,
|
|
4
4
|
HydratedTransactionValidationFunction,
|
|
5
|
-
} from '@xyo-network/xl1-protocol'
|
|
6
|
-
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'
|
|
5
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
6
|
+
import { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol-lib'
|
|
7
7
|
|
|
8
8
|
/** Validates that the transaction's chain ID matches the expected chain ID from the validation context. */
|
|
9
9
|
export const TransactionProtocolValidator: HydratedTransactionValidationFunction = async (
|
|
@@ -3,8 +3,8 @@ import { isDefined, isUndefined } from '@xylabs/sdk-js'
|
|
|
3
3
|
import type {
|
|
4
4
|
HydratedTransactionValidationFunction, StepIdentity,
|
|
5
5
|
Transfer,
|
|
6
|
-
} from '@xyo-network/xl1-protocol'
|
|
7
|
-
import { HydratedTransactionValidationError, isTransfer } from '@xyo-network/xl1-protocol'
|
|
6
|
+
} from '@xyo-network/xl1-protocol-lib'
|
|
7
|
+
import { HydratedTransactionValidationError, isTransfer } from '@xyo-network/xl1-protocol-lib'
|
|
8
8
|
import {
|
|
9
9
|
completedStepRewardAddress, derivedReceiveAddress, elevatedPayloads,
|
|
10
10
|
} from '@xyo-network/xl1-protocol-sdk'
|