@xyo-network/xl1-validation 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +156 -94
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +18 -18
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/boundwitness/validators/BoundWitnessReferences.ts
|
|
5
2
|
import { ZERO_HASH } from "@xylabs/sdk-js";
|
|
6
3
|
import { isAnyPayload } from "@xyo-network/payload-model";
|
|
@@ -8,16 +5,12 @@ import { HydratedBoundWitnessValidationError } from "@xyo-network/xl1-protocol";
|
|
|
8
5
|
function getPayloadsFromPayloadArray(payloads, hashes) {
|
|
9
6
|
return hashes.map((hash) => payloads.find((payload) => payload._hash === hash || payload._dataHash === hash));
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
var BoundWitnessReferencesValidator = /* @__PURE__ */ __name((allowedSchemas) => ([bw, payloadSet]) => {
|
|
8
|
+
var BoundWitnessReferencesValidator = (allowedSchemas) => ([bw, payloadSet]) => {
|
|
13
9
|
const errors = [];
|
|
14
10
|
try {
|
|
15
11
|
const payloads = getPayloadsFromPayloadArray(payloadSet, bw.payload_hashes);
|
|
16
12
|
if (payloads.length !== bw.payload_hashes.length) {
|
|
17
|
-
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
18
|
-
bw,
|
|
19
|
-
payloadSet
|
|
20
|
-
], "unable to locate payloads"));
|
|
13
|
+
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "unable to locate payloads"));
|
|
21
14
|
}
|
|
22
15
|
for (let payload of payloads) {
|
|
23
16
|
if (isAnyPayload(payload)) {
|
|
@@ -25,41 +18,26 @@ var BoundWitnessReferencesValidator = /* @__PURE__ */ __name((allowedSchemas) =>
|
|
|
25
18
|
const payloadDataHashIndex = bw.payload_hashes.indexOf(payload._dataHash);
|
|
26
19
|
const payloadIndex = Math.max(payloadHashIndex, payloadDataHashIndex);
|
|
27
20
|
if (payloadIndex === -1) {
|
|
28
|
-
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
29
|
-
bw,
|
|
30
|
-
payloadSet
|
|
31
|
-
], "payload hash not found"));
|
|
21
|
+
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "payload hash not found"));
|
|
32
22
|
}
|
|
33
23
|
const declaredSchema = bw.payload_schemas[payloadIndex];
|
|
34
24
|
if (declaredSchema !== payload.schema) {
|
|
35
|
-
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
36
|
-
bw,
|
|
37
|
-
payloadSet
|
|
38
|
-
], "mismatched schema"));
|
|
25
|
+
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "mismatched schema"));
|
|
39
26
|
}
|
|
40
27
|
if (allowedSchemas && !allowedSchemas.includes(payload.schema)) {
|
|
41
|
-
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
42
|
-
bw,
|
|
43
|
-
payloadSet
|
|
44
|
-
], `disallowed schema [${payload.schema}]`));
|
|
28
|
+
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `disallowed schema [${payload.schema}]`));
|
|
45
29
|
}
|
|
46
30
|
} else {
|
|
47
|
-
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
48
|
-
bw,
|
|
49
|
-
payloadSet
|
|
50
|
-
], "invalid payload"));
|
|
31
|
+
errors.push(new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], "invalid payload"));
|
|
51
32
|
}
|
|
52
33
|
}
|
|
53
34
|
} catch (ex) {
|
|
54
|
-
const error = new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [
|
|
55
|
-
bw,
|
|
56
|
-
payloadSet
|
|
57
|
-
], `validation excepted: ${ex}`);
|
|
35
|
+
const error = new HydratedBoundWitnessValidationError(bw?._hash ?? ZERO_HASH, [bw, payloadSet], `validation excepted: ${ex}`);
|
|
58
36
|
error.cause = ex;
|
|
59
37
|
errors.push(error);
|
|
60
38
|
}
|
|
61
39
|
return errors;
|
|
62
|
-
}
|
|
40
|
+
};
|
|
63
41
|
|
|
64
42
|
// src/boundwitness/validators/BoundWitnessSignatures.ts
|
|
65
43
|
import { ZERO_HASH as ZERO_HASH2 } from "@xylabs/sdk-js";
|
|
@@ -67,15 +45,16 @@ import { toArrayBuffer } from "@xylabs/sdk-js";
|
|
|
67
45
|
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
68
46
|
import { BoundWitnessValidator } from "@xyo-network/boundwitness-validator";
|
|
69
47
|
import { BoundWitnessValidationError } from "@xyo-network/xl1-protocol";
|
|
70
|
-
var BoundWitnessSignaturesValidator =
|
|
48
|
+
var BoundWitnessSignaturesValidator = async (bw) => {
|
|
71
49
|
const errors = [];
|
|
72
50
|
try {
|
|
73
51
|
const dataHash = await BoundWitnessBuilder.dataHash(bw);
|
|
74
52
|
const results = await Promise.all(bw.addresses.map(async (address, index) => {
|
|
75
|
-
return [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
53
|
+
return [address, await BoundWitnessValidator.validateSignature(
|
|
54
|
+
toArrayBuffer(dataHash),
|
|
55
|
+
toArrayBuffer(address),
|
|
56
|
+
toArrayBuffer(bw.$signatures[index] ?? void 0)
|
|
57
|
+
)];
|
|
79
58
|
}));
|
|
80
59
|
for (const [, bwErrors] of results) {
|
|
81
60
|
for (const bwError of bwErrors) {
|
|
@@ -86,7 +65,7 @@ var BoundWitnessSignaturesValidator = /* @__PURE__ */ __name(async (bw) => {
|
|
|
86
65
|
errors.push(new BoundWitnessValidationError(bw?._hash ?? ZERO_HASH2, bw, "validation excepted", ex));
|
|
87
66
|
}
|
|
88
67
|
return errors;
|
|
89
|
-
}
|
|
68
|
+
};
|
|
90
69
|
|
|
91
70
|
// src/transaction/validateTransaction.ts
|
|
92
71
|
import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
@@ -94,25 +73,34 @@ import { isTransactionBoundWitness } from "@xyo-network/xl1-protocol";
|
|
|
94
73
|
// src/transaction/validators/TransactionDurationValidator.ts
|
|
95
74
|
import { ZERO_HASH as ZERO_HASH3 } from "@xylabs/sdk-js";
|
|
96
75
|
import { HydratedTransactionValidationError } from "@xyo-network/xl1-protocol";
|
|
97
|
-
var TransactionDurationValidator =
|
|
76
|
+
var TransactionDurationValidator = (tx) => {
|
|
98
77
|
const errors = [];
|
|
99
78
|
try {
|
|
100
79
|
const { exp, nbf } = tx[0];
|
|
101
80
|
if (nbf < 0) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH3, tx, "Transaction nbf must be positive"));
|
|
102
81
|
if (exp < 0) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH3, tx, "Transaction exp must be positive"));
|
|
103
82
|
if (exp <= nbf) errors.push(new HydratedTransactionValidationError(tx?.[0]?._hash ?? ZERO_HASH3, tx, "Transaction exp must greater than nbf"));
|
|
104
|
-
if (exp - nbf > 1e4) errors.push(new HydratedTransactionValidationError(
|
|
83
|
+
if (exp - nbf > 1e4) errors.push(new HydratedTransactionValidationError(
|
|
84
|
+
tx?.[0]?._hash ?? ZERO_HASH3,
|
|
85
|
+
tx,
|
|
86
|
+
"Transaction exp must not be too far in the future"
|
|
87
|
+
));
|
|
105
88
|
} catch (ex) {
|
|
106
|
-
errors.push(new HydratedTransactionValidationError(
|
|
89
|
+
errors.push(new HydratedTransactionValidationError(
|
|
90
|
+
tx?.[0]?._hash ?? ZERO_HASH3,
|
|
91
|
+
tx,
|
|
92
|
+
`Failed TransactionDurationValidator: ${ex}`,
|
|
93
|
+
ex
|
|
94
|
+
));
|
|
107
95
|
}
|
|
108
96
|
return errors;
|
|
109
|
-
}
|
|
97
|
+
};
|
|
110
98
|
|
|
111
99
|
// src/transaction/validators/TransactionElevationValidator.ts
|
|
112
100
|
import { ZERO_HASH as ZERO_HASH4 } from "@xylabs/sdk-js";
|
|
113
101
|
import { HydratedTransactionValidationError as HydratedTransactionValidationError2 } from "@xyo-network/xl1-protocol";
|
|
114
102
|
import { extractElevatedHashes } from "@xyo-network/xl1-protocol-sdk";
|
|
115
|
-
var TransactionElevationValidator =
|
|
103
|
+
var TransactionElevationValidator = (tx) => {
|
|
116
104
|
const errors = [];
|
|
117
105
|
try {
|
|
118
106
|
try {
|
|
@@ -121,60 +109,135 @@ var TransactionElevationValidator = /* @__PURE__ */ __name((tx) => {
|
|
|
121
109
|
errors.push(new HydratedTransactionValidationError2(tx?.[0]?._hash ?? ZERO_HASH4, tx, "Hydrated transaction does not include all script hashes"));
|
|
122
110
|
}
|
|
123
111
|
} catch (ex) {
|
|
124
|
-
errors.push(new HydratedTransactionValidationError2(
|
|
112
|
+
errors.push(new HydratedTransactionValidationError2(
|
|
113
|
+
tx?.[0]?._hash ?? ZERO_HASH4,
|
|
114
|
+
tx,
|
|
115
|
+
`Failed TransactionElevationValidator: ${ex}`,
|
|
116
|
+
ex
|
|
117
|
+
));
|
|
125
118
|
}
|
|
126
119
|
return errors;
|
|
127
|
-
}
|
|
120
|
+
};
|
|
128
121
|
|
|
129
122
|
// src/transaction/validators/TransactionFromValidator.ts
|
|
130
123
|
import { asAddress, ZERO_HASH as ZERO_HASH5 } from "@xylabs/sdk-js";
|
|
131
124
|
import { addressesContains } from "@xyo-network/boundwitness-validator";
|
|
132
125
|
import { HydratedTransactionValidationError as HydratedTransactionValidationError3 } from "@xyo-network/xl1-protocol";
|
|
133
|
-
var TransactionFromValidator =
|
|
126
|
+
var TransactionFromValidator = (tx) => {
|
|
134
127
|
const errors = [];
|
|
135
128
|
try {
|
|
136
129
|
const from = asAddress(tx[0].from);
|
|
137
|
-
if (from === void 0) errors.push(new HydratedTransactionValidationError3(
|
|
138
|
-
|
|
130
|
+
if (from === void 0) errors.push(new HydratedTransactionValidationError3(
|
|
131
|
+
tx?.[0]?._hash ?? ZERO_HASH5,
|
|
132
|
+
tx,
|
|
133
|
+
"Transaction from is not a valid address"
|
|
134
|
+
));
|
|
135
|
+
else if (!addressesContains(tx[0], from)) errors.push(new HydratedTransactionValidationError3(
|
|
136
|
+
tx?.[0]?._hash ?? ZERO_HASH5,
|
|
137
|
+
tx,
|
|
138
|
+
"Transaction from address must be listed in addresses"
|
|
139
|
+
));
|
|
139
140
|
} catch (ex) {
|
|
140
|
-
errors.push(new HydratedTransactionValidationError3(
|
|
141
|
+
errors.push(new HydratedTransactionValidationError3(
|
|
142
|
+
tx?.[0]?._hash ?? ZERO_HASH5,
|
|
143
|
+
tx,
|
|
144
|
+
`Failed TransactionFromValidator: ${ex}`,
|
|
145
|
+
ex
|
|
146
|
+
));
|
|
141
147
|
}
|
|
142
148
|
return errors;
|
|
143
|
-
}
|
|
149
|
+
};
|
|
144
150
|
|
|
145
151
|
// src/transaction/validators/TransactionGasValidator.ts
|
|
146
152
|
import { hexToBigInt, ZERO_HASH as ZERO_HASH6 } from "@xylabs/sdk-js";
|
|
147
|
-
import {
|
|
148
|
-
|
|
153
|
+
import {
|
|
154
|
+
AttoXL1,
|
|
155
|
+
HydratedTransactionValidationError as HydratedTransactionValidationError4,
|
|
156
|
+
minTransactionFees
|
|
157
|
+
} from "@xyo-network/xl1-protocol";
|
|
158
|
+
var TransactionGasValidator = (tx) => {
|
|
149
159
|
const errors = [];
|
|
150
160
|
try {
|
|
151
161
|
if (tx?.[0].fees === void 0) {
|
|
152
|
-
errors.push(new HydratedTransactionValidationError4(
|
|
162
|
+
errors.push(new HydratedTransactionValidationError4(
|
|
163
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
164
|
+
tx,
|
|
165
|
+
"Missing fees"
|
|
166
|
+
));
|
|
153
167
|
} else {
|
|
154
|
-
const {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
168
|
+
const {
|
|
169
|
+
base,
|
|
170
|
+
gasLimit,
|
|
171
|
+
gasPrice,
|
|
172
|
+
priority
|
|
173
|
+
} = parseFees(tx[0].fees);
|
|
174
|
+
if (base === void 0) errors.push(new HydratedTransactionValidationError4(
|
|
175
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
176
|
+
tx,
|
|
177
|
+
"fees.base must be defined and a valid number"
|
|
178
|
+
));
|
|
179
|
+
else if (base < minTransactionFees.base) errors.push(new HydratedTransactionValidationError4(
|
|
180
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
181
|
+
tx,
|
|
182
|
+
`fees.base must be >= ${minTransactionFees.base}`
|
|
183
|
+
));
|
|
184
|
+
if (gasLimit === void 0) errors.push(new HydratedTransactionValidationError4(
|
|
185
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
186
|
+
tx,
|
|
187
|
+
"fees.gasLimit must be defined and a valid number"
|
|
188
|
+
));
|
|
189
|
+
else if (gasLimit < minTransactionFees.gasLimit) errors.push(new HydratedTransactionValidationError4(
|
|
190
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
191
|
+
tx,
|
|
192
|
+
`fees.gasLimit must be >= ${minTransactionFees.gasLimit}`
|
|
193
|
+
));
|
|
194
|
+
if (gasPrice === void 0) errors.push(
|
|
195
|
+
new HydratedTransactionValidationError4(
|
|
196
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
197
|
+
tx,
|
|
198
|
+
"fees.gasPrice must be defined and a valid number"
|
|
199
|
+
)
|
|
200
|
+
);
|
|
201
|
+
else if (gasPrice < minTransactionFees.gasPrice) errors.push(new HydratedTransactionValidationError4(
|
|
202
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
203
|
+
tx,
|
|
204
|
+
`fees.gasPrice must be >= ${minTransactionFees.gasPrice}`
|
|
205
|
+
));
|
|
206
|
+
if (priority === void 0) errors.push(new HydratedTransactionValidationError4(
|
|
207
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
208
|
+
tx,
|
|
209
|
+
"fees.priority must be defined and a valid number"
|
|
210
|
+
));
|
|
211
|
+
else if (priority < minTransactionFees.priority) errors.push(new HydratedTransactionValidationError4(
|
|
212
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
213
|
+
tx,
|
|
214
|
+
`fees.priority must be >= ${minTransactionFees.priority}`
|
|
215
|
+
));
|
|
163
216
|
}
|
|
164
217
|
} catch (ex) {
|
|
165
|
-
errors.push(new HydratedTransactionValidationError4(
|
|
218
|
+
errors.push(new HydratedTransactionValidationError4(
|
|
219
|
+
tx?.[0]?._hash ?? ZERO_HASH6,
|
|
220
|
+
tx,
|
|
221
|
+
`Failed TransactionGasValidator: ${ex}`,
|
|
222
|
+
ex
|
|
223
|
+
));
|
|
166
224
|
}
|
|
167
225
|
return errors;
|
|
168
|
-
}
|
|
169
|
-
var parseFees =
|
|
226
|
+
};
|
|
227
|
+
var parseFees = (fees) => {
|
|
170
228
|
const ret = {};
|
|
171
|
-
const {
|
|
229
|
+
const {
|
|
230
|
+
base,
|
|
231
|
+
gasLimit,
|
|
232
|
+
gasPrice,
|
|
233
|
+
priority
|
|
234
|
+
} = fees;
|
|
172
235
|
if (base !== void 0) ret.base = AttoXL1(hexToBigInt(base));
|
|
173
236
|
if (gasLimit !== void 0) ret.gasLimit = AttoXL1(hexToBigInt(gasLimit));
|
|
174
237
|
if (gasPrice !== void 0) ret.gasPrice = AttoXL1(hexToBigInt(gasPrice));
|
|
175
238
|
if (priority !== void 0) ret.priority = AttoXL1(hexToBigInt(priority));
|
|
176
239
|
return ret;
|
|
177
|
-
}
|
|
240
|
+
};
|
|
178
241
|
|
|
179
242
|
// src/transaction/validators/TransactionJsonSchemaValidator.ts
|
|
180
243
|
import { ZERO_HASH as ZERO_HASH7 } from "@xylabs/sdk-js";
|
|
@@ -182,19 +245,18 @@ import { PayloadBuilder } from "@xyo-network/payload-builder";
|
|
|
182
245
|
import { HydratedTransactionValidationError as HydratedTransactionValidationError5 } from "@xyo-network/xl1-protocol";
|
|
183
246
|
import { TransactionBoundWitnessJsonSchema } from "@xyo-network/xl1-schema";
|
|
184
247
|
import { Ajv } from "ajv";
|
|
185
|
-
var ajv = new Ajv({
|
|
186
|
-
allErrors: true,
|
|
187
|
-
strict: true
|
|
188
|
-
});
|
|
248
|
+
var ajv = new Ajv({ allErrors: true, strict: true });
|
|
189
249
|
var validate;
|
|
190
|
-
var TransactionJsonSchemaValidator =
|
|
250
|
+
var TransactionJsonSchemaValidator = (tx) => {
|
|
191
251
|
const errors = [];
|
|
192
252
|
try {
|
|
193
253
|
if (validate === void 0) validate = ajv.compile(TransactionBoundWitnessJsonSchema);
|
|
194
254
|
if (!validate(PayloadBuilder.omitStorageMeta(tx[0]))) {
|
|
195
|
-
const error = new HydratedTransactionValidationError5(
|
|
196
|
-
|
|
197
|
-
|
|
255
|
+
const error = new HydratedTransactionValidationError5(
|
|
256
|
+
tx?.[0]?._hash ?? ZERO_HASH7,
|
|
257
|
+
tx,
|
|
258
|
+
`failed JSON schema validation: ${ajv.errorsText(validate.errors, { separator: "\n" })}`
|
|
259
|
+
);
|
|
198
260
|
error.cause = validate.errors;
|
|
199
261
|
errors.push(error);
|
|
200
262
|
}
|
|
@@ -202,12 +264,12 @@ var TransactionJsonSchemaValidator = /* @__PURE__ */ __name((tx) => {
|
|
|
202
264
|
errors.push(new HydratedTransactionValidationError5(tx?.[0]?._hash ?? ZERO_HASH7, tx, "validation excepted", ex));
|
|
203
265
|
}
|
|
204
266
|
return errors;
|
|
205
|
-
}
|
|
267
|
+
};
|
|
206
268
|
|
|
207
269
|
// src/transaction/validators/TransactionProtocolValidator.ts
|
|
208
270
|
import { ZERO_HASH as ZERO_HASH8 } from "@xylabs/sdk-js";
|
|
209
271
|
import { HydratedTransactionValidationError as HydratedTransactionValidationError6 } from "@xyo-network/xl1-protocol";
|
|
210
|
-
var TransactionProtocolValidator =
|
|
272
|
+
var TransactionProtocolValidator = async (tx, context) => {
|
|
211
273
|
const errors = [];
|
|
212
274
|
try {
|
|
213
275
|
if (context?.chainId !== void 0 && tx[0].chain !== context.chainId) {
|
|
@@ -217,14 +279,18 @@ var TransactionProtocolValidator = /* @__PURE__ */ __name(async (tx, context) =>
|
|
|
217
279
|
errors.push(new HydratedTransactionValidationError6(tx?.[0]?._hash ?? ZERO_HASH8, tx, "validation excepted", ex));
|
|
218
280
|
}
|
|
219
281
|
return await Promise.resolve(errors);
|
|
220
|
-
}
|
|
282
|
+
};
|
|
221
283
|
|
|
222
284
|
// src/transaction/validators/TransactionTransfersValidator.ts
|
|
223
285
|
import { isDefined, isUndefined } from "@xylabs/sdk-js";
|
|
224
286
|
import { HydratedTransactionValidationError as HydratedTransactionValidationError7, isTransfer } from "@xyo-network/xl1-protocol";
|
|
225
|
-
import {
|
|
226
|
-
|
|
227
|
-
|
|
287
|
+
import {
|
|
288
|
+
completedStepRewardAddress,
|
|
289
|
+
derivedReceiveAddress,
|
|
290
|
+
elevatedPayloads
|
|
291
|
+
} from "@xyo-network/xl1-protocol-sdk";
|
|
292
|
+
var SelfSignerValidator = (signer, signee) => signer === signee;
|
|
293
|
+
var CompletedStepRewardAddressValidatorFactory = (allowedSigners) => (signer, signee, context) => {
|
|
228
294
|
const step = context?.step;
|
|
229
295
|
if (isDefined(step)) {
|
|
230
296
|
const contextAddress = completedStepRewardAddress(step);
|
|
@@ -232,8 +298,8 @@ var CompletedStepRewardAddressValidatorFactory = /* @__PURE__ */ __name((allowed
|
|
|
232
298
|
} else {
|
|
233
299
|
return false;
|
|
234
300
|
}
|
|
235
|
-
}
|
|
236
|
-
var DerivedReceiveAddressValidatorFactory =
|
|
301
|
+
};
|
|
302
|
+
var DerivedReceiveAddressValidatorFactory = (allowedSigners, allowedScope) => (signer, signee, context) => {
|
|
237
303
|
const { address, scope } = context ?? {};
|
|
238
304
|
if (scope !== allowedScope) {
|
|
239
305
|
return false;
|
|
@@ -244,10 +310,8 @@ var DerivedReceiveAddressValidatorFactory = /* @__PURE__ */ __name((allowedSigne
|
|
|
244
310
|
} else {
|
|
245
311
|
return false;
|
|
246
312
|
}
|
|
247
|
-
}
|
|
248
|
-
function TransactionTransfersValidatorFactory(signerValidators = [
|
|
249
|
-
SelfSignerValidator
|
|
250
|
-
]) {
|
|
313
|
+
};
|
|
314
|
+
function TransactionTransfersValidatorFactory(signerValidators = [SelfSignerValidator]) {
|
|
251
315
|
return async (hydratedTx) => {
|
|
252
316
|
const errors = [];
|
|
253
317
|
const signer = hydratedTx[0].from;
|
|
@@ -256,7 +320,11 @@ function TransactionTransfersValidatorFactory(signerValidators = [
|
|
|
256
320
|
const transfers = payloads.filter(isTransfer);
|
|
257
321
|
for (const transfer of transfers) {
|
|
258
322
|
if (isUndefined(signerValidators.find((v) => v(signer, transfer.from, transfer.context)))) {
|
|
259
|
-
errors.push(new HydratedTransactionValidationError7(
|
|
323
|
+
errors.push(new HydratedTransactionValidationError7(
|
|
324
|
+
hydratedTx[0]._hash,
|
|
325
|
+
hydratedTx,
|
|
326
|
+
`transfer from address ${transfer.from} is not authorized by signer ${signer}`
|
|
327
|
+
));
|
|
260
328
|
}
|
|
261
329
|
}
|
|
262
330
|
} catch (ex) {
|
|
@@ -265,15 +333,12 @@ function TransactionTransfersValidatorFactory(signerValidators = [
|
|
|
265
333
|
return await Promise.resolve(errors);
|
|
266
334
|
};
|
|
267
335
|
}
|
|
268
|
-
__name(TransactionTransfersValidatorFactory, "TransactionTransfersValidatorFactory");
|
|
269
336
|
|
|
270
337
|
// src/transaction/validateTransaction.ts
|
|
271
338
|
async function validateTransaction(tx, context, additionalValidators = []) {
|
|
272
339
|
try {
|
|
273
340
|
if (!isTransactionBoundWitness(tx[0])) {
|
|
274
|
-
return [
|
|
275
|
-
new Error("failed isTransactionBoundWitness identity check")
|
|
276
|
-
];
|
|
341
|
+
return [new Error("failed isTransactionBoundWitness identity check")];
|
|
277
342
|
}
|
|
278
343
|
const validators = [
|
|
279
344
|
TransactionProtocolValidator,
|
|
@@ -285,12 +350,9 @@ async function validateTransaction(tx, context, additionalValidators = []) {
|
|
|
285
350
|
];
|
|
286
351
|
return (await Promise.all(validators.map((v) => v(tx, context)))).flat();
|
|
287
352
|
} catch (ex) {
|
|
288
|
-
return [
|
|
289
|
-
new Error(`Failed TransactionGasValidator: ${ex}`)
|
|
290
|
-
];
|
|
353
|
+
return [new Error(`Failed TransactionGasValidator: ${ex}`)];
|
|
291
354
|
}
|
|
292
355
|
}
|
|
293
|
-
__name(validateTransaction, "validateTransaction");
|
|
294
356
|
export {
|
|
295
357
|
BoundWitnessReferencesValidator,
|
|
296
358
|
BoundWitnessSignaturesValidator,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../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 type { Hash, Promisable } from '@xylabs/sdk-js'\nimport { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type {\n Payload,\n Schema,\n WithHashMeta,\n} from '@xyo-network/payload-model'\nimport { isAnyPayload } from '@xyo-network/payload-model'\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\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 { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol'\nimport { BoundWitnessValidationError } from '@xyo-network/xl1-protocol'\n\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 ChainId, HydratedTransactionValidationFunction,\n HydratedTransactionWithHashMeta,\n StepIdentity,\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\nexport type ValidateTransactionContext = {\n chainId?: ChainId\n step?: StepIdentity\n}\n\nexport async function validateTransaction(\n tx: HydratedTransactionWithHashMeta,\n context?: ValidateTransactionContext,\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<ValidateTransactionContext>[] = [\n TransactionProtocolValidator,\n TransactionDurationValidator,\n TransactionFromValidator,\n TransactionGasValidator,\n TransactionElevationValidator,\n ...additionalValidators,\n ]\n return (await Promise.all(validators.map(v => v(tx, context)))).flat()\n } catch (ex) {\n return [(new Error(`Failed TransactionGasValidator: ${ex}`))]\n }\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { HydratedTransactionValidationFunction, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionDurationValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\nimport { extractElevatedHashes } from '@xyo-network/xl1-protocol-sdk'\n\nexport const TransactionElevationValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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/boundwitness-validator'\nimport type { HydratedTransactionValidationFunction, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionFromValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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 HydratedTransactionWithHashMeta,\n TransactionFeesBigInt, TransactionFeesHex,\n} from '@xyo-network/xl1-protocol'\nimport {\n AttoXL1,\n HydratedTransactionValidationError,\n minTransactionFees,\n} from '@xyo-network/xl1-protocol'\n\nexport const TransactionGasValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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/payload-builder'\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\nexport const TransactionJsonSchemaValidator: HydratedTransactionValidationFunction = (\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 HydratedTransactionWithHashMeta,\n} from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionProtocolValidator: HydratedTransactionValidationFunction = async (\n tx: HydratedTransactionWithHashMeta,\n context?: { chainId?: ChainId },\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\nexport type SignerValidator = (signer: Address, signee: Address, context?: { address?: Address; scope?: string; step?: StepIdentity }) => boolean\n\nexport type SignerMapping = Map<Address, Address[]>\n\nexport const SelfSignerValidator: SignerValidator = (signer: Address, signee: Address) => signer === signee\n\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\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\nexport function TransactionTransfersValidatorFactory(\n signerValidators: SignerValidator[] = [SelfSignerValidator],\n): HydratedTransactionValidationFunction<{ step?: StepIdentity }> {\n return async (\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":";;;;AACA,SAASA,iBAAiB;AAO1B,SAASC,oBAAoB;AAE7B,SAASC,2CAA2C;AAEpD,SAASC,4BAA4BC,UAAmCC,QAAc;AACpF,SAAOA,OAAOC,IAAIC,CAAAA,SAAQH,SAASI,KAAKC,CAAAA,YAAWA,QAAQC,UAAUH,QAAQE,QAAQE,cAAcJ,IAAAA,CAAAA;AACrG;AAFSJ;AAIF,IAAMS,kCAET,wBAAwCC,mBAAyE,CACjH,CAACC,IAAIC,UAAAA,MAAgD;AAGrD,QAAMC,SAAgD,CAAA;AACtD,MAAI;AACF,UAAMZ,WAAWD,4BAA4BY,YAAYD,GAAGG,cAAc;AAC1E,QAAIb,SAASc,WAAWJ,GAAGG,eAAeC,QAAQ;AAChDF,aAAOG,KAAK,IAAIC,oCAAoCN,IAAIJ,SAASW,WAAW;QAACP;QAAIC;SAAa,2BAAA,CAA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AO;QAAC,IAAII,MAAM,iDAAA;;IACpB;AAEA,UAAMC,aAAkF;MACtFC;MACAC;MACAC;MACAC;MACAC;SACGR;;AAEL,YAAQ,MAAMS,QAAQC,IAAIP,WAAWQ,IAAIC,CAAAA,MAAKA,EAAEd,IAAIC,OAAAA,CAAAA,CAAAA,GAAYc,KAAI;EACtE,SAASC,IAAI;AACX,WAAO;MAAE,IAAIZ,MAAM,mCAAmCY,EAAAA,EAAI;;EAC5D;AACF;AAtBsBjB;","names":["ZERO_HASH","isAnyPayload","HydratedBoundWitnessValidationError","getPayloadsFromPayloadArray","payloads","hashes","map","hash","find","payload","_hash","_dataHash","BoundWitnessReferencesValidator","allowedSchemas","bw","payloadSet","errors","payload_hashes","length","push","HydratedBoundWitnessValidationError","ZERO_HASH","isAnyPayload","payloadHashIndex","indexOf","payloadDataHashIndex","payloadIndex","Math","max","declaredSchema","payload_schemas","schema","includes","ex","error","cause","ZERO_HASH","toArrayBuffer","BoundWitnessBuilder","BoundWitnessValidator","BoundWitnessValidationError","BoundWitnessSignaturesValidator","bw","errors","dataHash","BoundWitnessBuilder","results","Promise","all","addresses","map","address","index","BoundWitnessValidator","validateSignature","toArrayBuffer","$signatures","undefined","bwErrors","bwError","push","BoundWitnessValidationError","_hash","ZERO_HASH","ex","isTransactionBoundWitness","ZERO_HASH","HydratedTransactionValidationError","TransactionDurationValidator","tx","errors","exp","nbf","push","HydratedTransactionValidationError","_hash","ZERO_HASH","ex","ZERO_HASH","HydratedTransactionValidationError","extractElevatedHashes","TransactionElevationValidator","tx","errors","extractElevatedHashes","push","HydratedTransactionValidationError","_hash","ZERO_HASH","ex","asAddress","ZERO_HASH","addressesContains","HydratedTransactionValidationError","TransactionFromValidator","tx","errors","from","asAddress","undefined","push","HydratedTransactionValidationError","_hash","ZERO_HASH","addressesContains","ex","hexToBigInt","ZERO_HASH","AttoXL1","HydratedTransactionValidationError","minTransactionFees","TransactionGasValidator","tx","errors","fees","undefined","push","HydratedTransactionValidationError","_hash","ZERO_HASH","base","gasLimit","gasPrice","priority","parseFees","minTransactionFees","ex","ret","AttoXL1","hexToBigInt","ZERO_HASH","PayloadBuilder","HydratedTransactionValidationError","TransactionBoundWitnessJsonSchema","Ajv","ajv","Ajv","allErrors","strict","validate","TransactionJsonSchemaValidator","tx","errors","undefined","compile","TransactionBoundWitnessJsonSchema","PayloadBuilder","omitStorageMeta","error","HydratedTransactionValidationError","_hash","ZERO_HASH","errorsText","separator","cause","push","ex","ZERO_HASH","HydratedTransactionValidationError","TransactionProtocolValidator","tx","context","errors","chainId","undefined","chain","push","HydratedTransactionValidationError","_hash","ZERO_HASH","ex","Promise","resolve","isDefined","isUndefined","HydratedTransactionValidationError","isTransfer","completedStepRewardAddress","derivedReceiveAddress","elevatedPayloads","SelfSignerValidator","signer","signee","CompletedStepRewardAddressValidatorFactory","allowedSigners","context","step","isDefined","contextAddress","completedStepRewardAddress","includes","DerivedReceiveAddressValidatorFactory","allowedScope","address","scope","derivedAddress","derivedReceiveAddress","TransactionTransfersValidatorFactory","signerValidators","hydratedTx","errors","from","payloads","elevatedPayloads","transfers","filter","isTransfer","transfer","isUndefined","find","v","push","HydratedTransactionValidationError","_hash","ex","Promise","resolve","validateTransaction","tx","context","additionalValidators","isTransactionBoundWitness","Error","validators","TransactionProtocolValidator","TransactionDurationValidator","TransactionFromValidator","TransactionGasValidator","TransactionElevationValidator","Promise","all","map","v","flat","ex"]}
|
|
1
|
+
{"version":3,"sources":["../../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 type { Hash, Promisable } from '@xylabs/sdk-js'\nimport { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type {\n Payload,\n Schema,\n WithHashMeta,\n} from '@xyo-network/payload-model'\nimport { isAnyPayload } from '@xyo-network/payload-model'\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\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 { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type { BoundWitnessValidationFunction } from '@xyo-network/xl1-protocol'\nimport { BoundWitnessValidationError } from '@xyo-network/xl1-protocol'\n\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 ChainId, HydratedTransactionValidationFunction,\n HydratedTransactionWithHashMeta,\n StepIdentity,\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\nexport type ValidateTransactionContext = {\n chainId?: ChainId\n step?: StepIdentity\n}\n\nexport async function validateTransaction(\n tx: HydratedTransactionWithHashMeta,\n context?: ValidateTransactionContext,\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<ValidateTransactionContext>[] = [\n TransactionProtocolValidator,\n TransactionDurationValidator,\n TransactionFromValidator,\n TransactionGasValidator,\n TransactionElevationValidator,\n ...additionalValidators,\n ]\n return (await Promise.all(validators.map(v => v(tx, context)))).flat()\n } catch (ex) {\n return [(new Error(`Failed TransactionGasValidator: ${ex}`))]\n }\n}\n","import { ZERO_HASH } from '@xylabs/sdk-js'\nimport type { HydratedTransactionValidationFunction, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionDurationValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\nimport { extractElevatedHashes } from '@xyo-network/xl1-protocol-sdk'\n\nexport const TransactionElevationValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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/boundwitness-validator'\nimport type { HydratedTransactionValidationFunction, HydratedTransactionWithHashMeta } from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionFromValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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 HydratedTransactionWithHashMeta,\n TransactionFeesBigInt, TransactionFeesHex,\n} from '@xyo-network/xl1-protocol'\nimport {\n AttoXL1,\n HydratedTransactionValidationError,\n minTransactionFees,\n} from '@xyo-network/xl1-protocol'\n\nexport const TransactionGasValidator: HydratedTransactionValidationFunction = (\n tx: HydratedTransactionWithHashMeta,\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/payload-builder'\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\nexport const TransactionJsonSchemaValidator: HydratedTransactionValidationFunction = (\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 HydratedTransactionWithHashMeta,\n} from '@xyo-network/xl1-protocol'\nimport { HydratedTransactionValidationError } from '@xyo-network/xl1-protocol'\n\nexport const TransactionProtocolValidator: HydratedTransactionValidationFunction = async (\n tx: HydratedTransactionWithHashMeta,\n context?: { chainId?: ChainId },\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\nexport type SignerValidator = (signer: Address, signee: Address, context?: { address?: Address; scope?: string; step?: StepIdentity }) => boolean\n\nexport type SignerMapping = Map<Address, Address[]>\n\nexport const SelfSignerValidator: SignerValidator = (signer: Address, signee: Address) => signer === signee\n\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\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\nexport function TransactionTransfersValidatorFactory(\n signerValidators: SignerValidator[] = [SelfSignerValidator],\n): HydratedTransactionValidationFunction<{ step?: StepIdentity }> {\n return async (\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":";AACA,SAAS,iBAAiB;AAO1B,SAAS,oBAAoB;AAE7B,SAAS,2CAA2C;AAEpD,SAAS,4BAA4B,UAAmC,QAAuD;AAC7H,SAAO,OAAO,IAAI,UAAQ,SAAS,KAAK,aAAW,QAAQ,UAAU,QAAQ,QAAQ,cAAc,IAAI,CAAC;AAC1G;AAEO,IAAM,kCAET,CAAwC,mBAAyE,CACjH,CAAC,IAAI,UAAU,MAEuC;AACtD,QAAM,SAAgD,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AChH;AACA,WAAO,MAAM,QAAQ,QAAQ,MAAM;AAAA,EACrC;AACF;;;APxDA,eAAsB,oBACpB,IACA,SACA,uBAAgE,CAAC,GACjE;AACA,MAAI;AACF,QAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,GAAG;AACrC,aAAO,CAAC,IAAI,MAAM,iDAAiD,CAAC;AAAA,IACtE;AAEA,UAAM,aAAkF;AAAA,MACtF;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL;AACA,YAAQ,MAAM,QAAQ,IAAI,WAAW,IAAI,OAAK,EAAE,IAAI,OAAO,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","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","ZERO_HASH","HydratedTransactionValidationError","HydratedTransactionValidationError"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json.schemastore.org/package.json",
|
|
3
3
|
"name": "@xyo-network/xl1-validation",
|
|
4
|
-
"version": "1.18.
|
|
4
|
+
"version": "1.18.1",
|
|
5
5
|
"description": "XYO Layer One SDK Validation",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -39,30 +39,30 @@
|
|
|
39
39
|
"!**/*.test.*"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@xylabs/sdk-js": "~5.0.
|
|
43
|
-
"@xyo-network/boundwitness-builder": "~5.2.
|
|
44
|
-
"@xyo-network/boundwitness-model": "~5.2.
|
|
45
|
-
"@xyo-network/boundwitness-validator": "~5.2.
|
|
46
|
-
"@xyo-network/payload-builder": "~5.2.
|
|
47
|
-
"@xyo-network/payload-model": "~5.2.
|
|
48
|
-
"@xyo-network/xl1-protocol": "~1.
|
|
49
|
-
"@xyo-network/xl1-protocol-sdk": "~1.18.
|
|
50
|
-
"@xyo-network/xl1-schema": "~1.18.
|
|
42
|
+
"@xylabs/sdk-js": "~5.0.61",
|
|
43
|
+
"@xyo-network/boundwitness-builder": "~5.2.19",
|
|
44
|
+
"@xyo-network/boundwitness-model": "~5.2.19",
|
|
45
|
+
"@xyo-network/boundwitness-validator": "~5.2.19",
|
|
46
|
+
"@xyo-network/payload-builder": "~5.2.19",
|
|
47
|
+
"@xyo-network/payload-model": "~5.2.19",
|
|
48
|
+
"@xyo-network/xl1-protocol": "~1.18.1",
|
|
49
|
+
"@xyo-network/xl1-protocol-sdk": "~1.18.1",
|
|
50
|
+
"@xyo-network/xl1-schema": "~1.18.1",
|
|
51
51
|
"ajv": "~8.17.1"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@types/node": "~25.0.
|
|
55
|
-
"@xylabs/sdk-js": "~5.0.
|
|
54
|
+
"@types/node": "~25.0.3",
|
|
55
|
+
"@xylabs/sdk-js": "~5.0.61",
|
|
56
56
|
"@xylabs/ts-scripts-yarn3": "~7.2.32",
|
|
57
57
|
"@xylabs/tsconfig": "~7.2.32",
|
|
58
|
-
"@xyo-network/account": "~5.2.
|
|
59
|
-
"@xyo-network/account-model": "~5.2.
|
|
60
|
-
"@xyo-network/archivist-memory": "~5.2.
|
|
61
|
-
"@xyo-network/archivist-model": "~5.2.
|
|
62
|
-
"@xyo-network/wallet": "~5.2.
|
|
58
|
+
"@xyo-network/account": "~5.2.19",
|
|
59
|
+
"@xyo-network/account-model": "~5.2.19",
|
|
60
|
+
"@xyo-network/archivist-memory": "~5.2.19",
|
|
61
|
+
"@xyo-network/archivist-model": "~5.2.19",
|
|
62
|
+
"@xyo-network/wallet": "~5.2.19",
|
|
63
63
|
"eslint": "^9.39.2",
|
|
64
64
|
"typescript": "~5.9.3",
|
|
65
|
-
"vitest": "~4.0.
|
|
65
|
+
"vitest": "~4.0.16"
|
|
66
66
|
},
|
|
67
67
|
"engines": {
|
|
68
68
|
"node": ">=22.3 <23"
|