@xyo-network/xl1-protocol-sdk 1.12.0 → 1.12.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 +274 -144
- package/dist/neutral/index.mjs.map +1 -1
- package/package.json +21 -21
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,69 +1,97 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
1
4
|
// src/block/hydrateBlock.ts
|
|
2
5
|
import { filterAs } from "@xylabs/array";
|
|
3
6
|
import { assertEx } from "@xylabs/assert";
|
|
4
|
-
import {
|
|
5
|
-
asTransactionBoundWitnessWithStorageMeta,
|
|
6
|
-
isBlockBoundWitnessWithStorageMeta,
|
|
7
|
-
isTransactionBoundWitnessWithStorageMeta
|
|
8
|
-
} from "@xyo-network/xl1-protocol";
|
|
7
|
+
import { asTransactionBoundWitnessWithStorageMeta, isBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
9
8
|
function allHashesPresent(hashes, payloads) {
|
|
10
9
|
const payloadHashes = new Set(payloads.map((p) => p._hash));
|
|
11
10
|
return hashes.every((hash) => payloadHashes.has(hash));
|
|
12
11
|
}
|
|
13
|
-
|
|
12
|
+
__name(allHashesPresent, "allHashesPresent");
|
|
13
|
+
var tryHydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth = 1) => {
|
|
14
14
|
assertEx(maxDepth >= 0, () => "maxDepth must be greater than or equal to 0");
|
|
15
|
-
const bw = (await archivist.get([
|
|
15
|
+
const bw = (await archivist.get([
|
|
16
|
+
hash
|
|
17
|
+
])).find(isBlockBoundWitnessWithStorageMeta);
|
|
16
18
|
if (!bw) return void 0;
|
|
17
|
-
if (maxDepth === 0) return [
|
|
19
|
+
if (maxDepth === 0) return [
|
|
20
|
+
bw,
|
|
21
|
+
[]
|
|
22
|
+
];
|
|
18
23
|
const blkPayloads = await archivist.get(bw.payload_hashes);
|
|
19
|
-
if (maxDepth === 1) return [
|
|
24
|
+
if (maxDepth === 1) return [
|
|
25
|
+
bw,
|
|
26
|
+
blkPayloads
|
|
27
|
+
];
|
|
20
28
|
const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta);
|
|
21
29
|
const transactionsPayloadHashes = transactions.flatMap((tx) => tx.payload_hashes);
|
|
22
30
|
const transactionsPayloads = await archivist.get(transactionsPayloadHashes);
|
|
23
|
-
const allPayloadsHashes = new Set([
|
|
24
|
-
|
|
31
|
+
const allPayloadsHashes = new Set([
|
|
32
|
+
...blkPayloads,
|
|
33
|
+
...transactionsPayloads
|
|
34
|
+
].flatMap((p) => p._hash));
|
|
35
|
+
const allPayloads = await archivist.get([
|
|
36
|
+
...allPayloadsHashes
|
|
37
|
+
]);
|
|
25
38
|
const allPayloadsFiltered = allPayloads.filter((p) => allPayloadsHashes.has(p._hash));
|
|
26
|
-
return [
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
return [
|
|
40
|
+
bw,
|
|
41
|
+
allPayloadsFiltered
|
|
42
|
+
];
|
|
43
|
+
}, "tryHydrateBlock");
|
|
44
|
+
var hydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth = 1, minDepth = maxDepth) => {
|
|
29
45
|
assertEx(maxDepth >= 0, () => "maxDepth must be greater than or equal to 0");
|
|
30
46
|
assertEx(minDepth >= 0, () => "minDepth must be greater than or equal to 0");
|
|
31
47
|
assertEx(maxDepth >= minDepth, () => "maxDepth must be greater than or equal to minDepth");
|
|
32
|
-
const bw = assertEx(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
48
|
+
const bw = assertEx((await archivist.get([
|
|
49
|
+
hash
|
|
50
|
+
])).find(isBlockBoundWitnessWithStorageMeta), () => `block ${hash} not found`);
|
|
51
|
+
if (maxDepth === 0) return [
|
|
52
|
+
bw,
|
|
53
|
+
[]
|
|
54
|
+
];
|
|
37
55
|
const blkPayloads = await archivist.get(bw.payload_hashes);
|
|
38
56
|
if (minDepth === 1) assertEx(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`);
|
|
39
|
-
if (maxDepth === 1) return [
|
|
57
|
+
if (maxDepth === 1) return [
|
|
58
|
+
bw,
|
|
59
|
+
blkPayloads
|
|
60
|
+
];
|
|
40
61
|
const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta);
|
|
41
62
|
const transactionsPayloadHashes = transactions.flatMap((tx) => tx.payload_hashes);
|
|
42
63
|
const transactionsPayloads = await archivist.get(transactionsPayloadHashes);
|
|
43
64
|
assertEx(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`);
|
|
44
|
-
const allPayloadsHashes = new Set([
|
|
45
|
-
|
|
65
|
+
const allPayloadsHashes = new Set([
|
|
66
|
+
...blkPayloads,
|
|
67
|
+
...transactionsPayloads
|
|
68
|
+
].flatMap((p) => p._hash));
|
|
69
|
+
const allPayloads = await archivist.get([
|
|
70
|
+
...allPayloadsHashes
|
|
71
|
+
]);
|
|
46
72
|
const allPayloadsFiltered = allPayloads.filter((p) => allPayloadsHashes.has(p._hash));
|
|
47
|
-
if (maxDepth === 2) assertEx(allHashesPresent(
|
|
48
|
-
|
|
73
|
+
if (maxDepth === 2) assertEx(allHashesPresent([
|
|
74
|
+
...allPayloadsHashes
|
|
75
|
+
], allPayloadsFiltered), () => `Unable to find all payloads for transactions in block ${hash}`);
|
|
76
|
+
return [
|
|
77
|
+
bw,
|
|
49
78
|
allPayloadsFiltered
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var flattenHydratedBlock = (hydratedBlock) => {
|
|
79
|
+
];
|
|
80
|
+
}, "hydrateBlock");
|
|
81
|
+
var flattenHydratedBlock = /* @__PURE__ */ __name((hydratedBlock) => {
|
|
54
82
|
const [blk, blkPayloads] = hydratedBlock;
|
|
55
|
-
return [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
83
|
+
return [
|
|
84
|
+
...blkPayloads,
|
|
85
|
+
blk
|
|
86
|
+
];
|
|
87
|
+
}, "flattenHydratedBlock");
|
|
88
|
+
var flattenHydratedBlocks = /* @__PURE__ */ __name((hydratedBlocks) => hydratedBlocks.flatMap((blk) => flattenHydratedBlock(blk)), "flattenHydratedBlocks");
|
|
89
|
+
var transactionsFromHydratedBlock = /* @__PURE__ */ __name((block) => {
|
|
59
90
|
return filterAs(block[1], asTransactionBoundWitnessWithStorageMeta);
|
|
60
|
-
};
|
|
61
|
-
var blockPayloadsFromHydratedBlock = (block) => {
|
|
62
|
-
return block[0].payload_hashes.map((hash) => assertEx(
|
|
63
|
-
|
|
64
|
-
() => `missing payload ${hash}`
|
|
65
|
-
)).filter((x) => !isTransactionBoundWitnessWithStorageMeta(x));
|
|
66
|
-
};
|
|
91
|
+
}, "transactionsFromHydratedBlock");
|
|
92
|
+
var blockPayloadsFromHydratedBlock = /* @__PURE__ */ __name((block) => {
|
|
93
|
+
return block[0].payload_hashes.map((hash) => assertEx(block[1].find((p) => p._hash === hash), () => `missing payload ${hash}`)).filter((x) => !isTransactionBoundWitnessWithStorageMeta(x));
|
|
94
|
+
}, "blockPayloadsFromHydratedBlock");
|
|
67
95
|
|
|
68
96
|
// src/block/primitives/balanceStepSummaryFromRange.ts
|
|
69
97
|
import { assertEx as assertEx2 } from "@xylabs/assert";
|
|
@@ -72,12 +100,9 @@ import { isAnyPayload } from "@xyo-network/payload-model";
|
|
|
72
100
|
import { StepSizes as StepSizes3 } from "@xyo-network/xl1-protocol";
|
|
73
101
|
|
|
74
102
|
// src/payload/netBalancesForPayloads.ts
|
|
75
|
-
import {
|
|
76
|
-
hexToBigInt,
|
|
77
|
-
toAddress
|
|
78
|
-
} from "@xylabs/hex";
|
|
103
|
+
import { hexToBigInt, toAddress } from "@xylabs/hex";
|
|
79
104
|
import { isTransfer } from "@xyo-network/xl1-protocol";
|
|
80
|
-
var netBalancesForPayloads = (payloads) => {
|
|
105
|
+
var netBalancesForPayloads = /* @__PURE__ */ __name((payloads) => {
|
|
81
106
|
const balances = {};
|
|
82
107
|
for (const payload of payloads) {
|
|
83
108
|
if (isTransfer(payload)) {
|
|
@@ -89,21 +114,18 @@ var netBalancesForPayloads = (payloads) => {
|
|
|
89
114
|
}
|
|
90
115
|
}
|
|
91
116
|
return balances;
|
|
92
|
-
};
|
|
117
|
+
}, "netBalancesForPayloads");
|
|
93
118
|
|
|
94
119
|
// src/SignedBigInt.ts
|
|
95
|
-
import {
|
|
96
|
-
hexToBigInt as hexToBigInt2,
|
|
97
|
-
toHex
|
|
98
|
-
} from "@xylabs/hex";
|
|
120
|
+
import { hexToBigInt as hexToBigInt2, toHex } from "@xylabs/hex";
|
|
99
121
|
import { isObject } from "@xylabs/object";
|
|
100
|
-
var isNegativeBigInt = (value) => {
|
|
122
|
+
var isNegativeBigInt = /* @__PURE__ */ __name((value) => {
|
|
101
123
|
return isObject(value) && "negative" in value && typeof value.negative === "string";
|
|
102
|
-
};
|
|
103
|
-
var isPositiveBigInt = (value) => {
|
|
124
|
+
}, "isNegativeBigInt");
|
|
125
|
+
var isPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
104
126
|
return isObject(value) && "positive" in value && typeof value.positive === "string";
|
|
105
|
-
};
|
|
106
|
-
var parseSignedBigInt = (value) => {
|
|
127
|
+
}, "isPositiveBigInt");
|
|
128
|
+
var parseSignedBigInt = /* @__PURE__ */ __name((value) => {
|
|
107
129
|
if (isNegativeBigInt(value)) {
|
|
108
130
|
return -hexToBigInt2(value.negative);
|
|
109
131
|
} else if (isPositiveBigInt(value)) {
|
|
@@ -111,22 +133,32 @@ var parseSignedBigInt = (value) => {
|
|
|
111
133
|
} else {
|
|
112
134
|
throw new Error("Invalid balance type");
|
|
113
135
|
}
|
|
114
|
-
};
|
|
115
|
-
var toSignedBigInt = (value) => {
|
|
116
|
-
return value < 0n ? {
|
|
117
|
-
|
|
118
|
-
|
|
136
|
+
}, "parseSignedBigInt");
|
|
137
|
+
var toSignedBigInt = /* @__PURE__ */ __name((value) => {
|
|
138
|
+
return value < 0n ? {
|
|
139
|
+
negative: toHex(-value)
|
|
140
|
+
} : {
|
|
141
|
+
positive: toHex(value)
|
|
142
|
+
};
|
|
143
|
+
}, "toSignedBigInt");
|
|
144
|
+
var toPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
119
145
|
if (isNegativeBigInt(value)) {
|
|
120
|
-
return {
|
|
146
|
+
return {
|
|
147
|
+
positive: toHex(0n)
|
|
148
|
+
};
|
|
121
149
|
}
|
|
122
150
|
if (isPositiveBigInt(value)) {
|
|
123
|
-
return {
|
|
151
|
+
return {
|
|
152
|
+
positive: value.positive
|
|
153
|
+
};
|
|
124
154
|
}
|
|
125
155
|
if (typeof value === "bigint") {
|
|
126
|
-
return {
|
|
156
|
+
return {
|
|
157
|
+
positive: toHex(value)
|
|
158
|
+
};
|
|
127
159
|
}
|
|
128
160
|
throw new Error("Invalid value for positive big int");
|
|
129
|
-
};
|
|
161
|
+
}, "toPositiveBigInt");
|
|
130
162
|
|
|
131
163
|
// src/block/primitives/frames/calculateFramesFromRange.ts
|
|
132
164
|
import { stepSize } from "@xyo-network/xl1-protocol";
|
|
@@ -137,23 +169,38 @@ function calculateFramesFromRange(range, step) {
|
|
|
137
169
|
const remaining = [];
|
|
138
170
|
if (start !== range[0]) {
|
|
139
171
|
start += size;
|
|
140
|
-
remaining.push([
|
|
172
|
+
remaining.push([
|
|
173
|
+
range[0],
|
|
174
|
+
Math.min(start - 1, range[1])
|
|
175
|
+
]);
|
|
141
176
|
}
|
|
142
177
|
for (let i = start; i <= range[1]; i += size) {
|
|
143
178
|
if (i + size - 1 <= range[1]) {
|
|
144
|
-
fitted.push([
|
|
179
|
+
fitted.push([
|
|
180
|
+
i,
|
|
181
|
+
Math.min(i + size - 1, range[1])
|
|
182
|
+
]);
|
|
145
183
|
} else {
|
|
146
|
-
remaining.push([
|
|
184
|
+
remaining.push([
|
|
185
|
+
i,
|
|
186
|
+
range[1]
|
|
187
|
+
]);
|
|
147
188
|
}
|
|
148
189
|
}
|
|
149
|
-
return [
|
|
190
|
+
return [
|
|
191
|
+
fitted,
|
|
192
|
+
remaining
|
|
193
|
+
];
|
|
150
194
|
}
|
|
195
|
+
__name(calculateFramesFromRange, "calculateFramesFromRange");
|
|
151
196
|
|
|
152
197
|
// src/block/primitives/frames/deepCalculateFramesFromRange.ts
|
|
153
198
|
import { StepSizes } from "@xyo-network/xl1-protocol";
|
|
154
199
|
function deepCalculateFramesFromRange(range, startingStep = StepSizes.length - 1) {
|
|
155
200
|
const fitted = [];
|
|
156
|
-
let remaining = [
|
|
201
|
+
let remaining = [
|
|
202
|
+
range
|
|
203
|
+
];
|
|
157
204
|
for (let step = startingStep; step >= 0; step--) {
|
|
158
205
|
const newRemaining = [];
|
|
159
206
|
for (const range2 of remaining) {
|
|
@@ -165,19 +212,27 @@ function deepCalculateFramesFromRange(range, startingStep = StepSizes.length - 1
|
|
|
165
212
|
}
|
|
166
213
|
for (const range2 of remaining) {
|
|
167
214
|
for (let i = range2[0]; i <= range2[1]; i++) {
|
|
168
|
-
fitted.push([
|
|
215
|
+
fitted.push([
|
|
216
|
+
i,
|
|
217
|
+
i
|
|
218
|
+
]);
|
|
169
219
|
}
|
|
170
220
|
}
|
|
171
221
|
return fitted.toSorted((a, b) => a[0] - b[0]);
|
|
172
222
|
}
|
|
223
|
+
__name(deepCalculateFramesFromRange, "deepCalculateFramesFromRange");
|
|
173
224
|
|
|
174
225
|
// src/block/primitives/hashFromBlockNumber.ts
|
|
175
226
|
import { asHash } from "@xylabs/hex";
|
|
176
227
|
import { toSafeJsonString } from "@xylabs/object";
|
|
177
228
|
import { asBlockBoundWitnessWithStorageMeta, StepSizes as StepSizes2 } from "@xyo-network/xl1-protocol";
|
|
178
229
|
async function hashFromBlockNumber(context, blockNumber) {
|
|
179
|
-
const result = await context.chainArchivist.get([
|
|
180
|
-
|
|
230
|
+
const result = await context.chainArchivist.get([
|
|
231
|
+
context.head
|
|
232
|
+
]);
|
|
233
|
+
let currentBlock = asBlockBoundWitnessWithStorageMeta(result.at(0), () => `Head block not found for hash: ${context.head}`, {
|
|
234
|
+
required: true
|
|
235
|
+
});
|
|
181
236
|
while (currentBlock.block > blockNumber) {
|
|
182
237
|
let jumpHash = currentBlock.previous;
|
|
183
238
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
@@ -191,7 +246,9 @@ async function hashFromBlockNumber(context, blockNumber) {
|
|
|
191
246
|
const [newBlock] = await context.chainArchivist.get([
|
|
192
247
|
asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`)
|
|
193
248
|
]);
|
|
194
|
-
currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, {
|
|
249
|
+
currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, {
|
|
250
|
+
required: true
|
|
251
|
+
});
|
|
195
252
|
if (currentBlock.block === blockNumber) {
|
|
196
253
|
break;
|
|
197
254
|
}
|
|
@@ -201,6 +258,7 @@ async function hashFromBlockNumber(context, blockNumber) {
|
|
|
201
258
|
}
|
|
202
259
|
return currentBlock._hash;
|
|
203
260
|
}
|
|
261
|
+
__name(hashFromBlockNumber, "hashFromBlockNumber");
|
|
204
262
|
|
|
205
263
|
// src/block/primitives/payloads.ts
|
|
206
264
|
import { AsObjectFactory } from "@xylabs/object";
|
|
@@ -209,9 +267,9 @@ var StepSummarySchema = "network.xyo.step.summary";
|
|
|
209
267
|
var BalancesStepSummarySchema = "network.xyo.step.summary.balances";
|
|
210
268
|
var isBalancesStepSummary = isPayloadOfSchemaType(BalancesStepSummarySchema);
|
|
211
269
|
var asBalancesStepSummary = AsObjectFactory.create(isBalancesStepSummary);
|
|
212
|
-
var isBalancesStepSummaryWithStorageMeta = (value) => {
|
|
270
|
+
var isBalancesStepSummaryWithStorageMeta = /* @__PURE__ */ __name((value) => {
|
|
213
271
|
return isBalancesStepSummary(value) && isStorageMeta(value);
|
|
214
|
-
};
|
|
272
|
+
}, "isBalancesStepSummaryWithStorageMeta");
|
|
215
273
|
var asBalancesStepSummaryWithStorageMeta = AsObjectFactory.create(isBalancesStepSummaryWithStorageMeta);
|
|
216
274
|
|
|
217
275
|
// src/block/primitives/balanceStepSummaryFromRange.ts
|
|
@@ -235,15 +293,14 @@ async function balanceStepSummaryFromRange(context, range) {
|
|
|
235
293
|
} else {
|
|
236
294
|
const step = StepSizes3.indexOf(frameSize);
|
|
237
295
|
assertEx2(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes3.join(", ")}`);
|
|
238
|
-
const [summaryResult] = await context.summaryRepository.get([
|
|
296
|
+
const [summaryResult] = await context.summaryRepository.get([
|
|
297
|
+
frameHeadHash
|
|
298
|
+
]);
|
|
239
299
|
if (isAnyPayload(summaryResult)) {
|
|
240
300
|
result = summaryResult;
|
|
241
301
|
} else {
|
|
242
302
|
const subRanges = deepCalculateFramesFromRange(range, step - 1);
|
|
243
|
-
const promises = subRanges.map((subRange) => balanceStepSummaryFromRange(
|
|
244
|
-
context,
|
|
245
|
-
subRange
|
|
246
|
-
));
|
|
303
|
+
const promises = subRanges.map((subRange) => balanceStepSummaryFromRange(context, subRange));
|
|
247
304
|
const subResults = await Promise.all(promises);
|
|
248
305
|
const bigIntBalances = {};
|
|
249
306
|
for (const subResult of subResults) {
|
|
@@ -261,22 +318,32 @@ async function balanceStepSummaryFromRange(context, range) {
|
|
|
261
318
|
stepSize: frameSize,
|
|
262
319
|
balances
|
|
263
320
|
};
|
|
264
|
-
await context.summaryRepository.insert([
|
|
321
|
+
await context.summaryRepository.insert([
|
|
322
|
+
result
|
|
323
|
+
]);
|
|
265
324
|
}
|
|
266
325
|
}
|
|
267
326
|
const finalResult = await PayloadBuilder.addStorageMeta(result);
|
|
268
327
|
return finalResult;
|
|
269
328
|
}
|
|
329
|
+
__name(balanceStepSummaryFromRange, "balanceStepSummaryFromRange");
|
|
270
330
|
|
|
271
331
|
// src/block/primitives/balanceSummary.ts
|
|
272
332
|
import { asAddress } from "@xylabs/hex";
|
|
273
333
|
import { isDefined } from "@xylabs/typeof";
|
|
274
334
|
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2 } from "@xyo-network/xl1-protocol";
|
|
275
335
|
async function balanceSummary(context) {
|
|
276
|
-
const headResult = await context.chainArchivist.get([
|
|
277
|
-
|
|
336
|
+
const headResult = await context.chainArchivist.get([
|
|
337
|
+
context.head
|
|
338
|
+
]);
|
|
339
|
+
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult.at(0), () => `Head block not found for hash: ${context.head}`, {
|
|
340
|
+
required: true
|
|
341
|
+
});
|
|
278
342
|
const rangeStart = isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0;
|
|
279
|
-
const ranges = deepCalculateFramesFromRange([
|
|
343
|
+
const ranges = deepCalculateFramesFromRange([
|
|
344
|
+
rangeStart,
|
|
345
|
+
headBoundWitness.block
|
|
346
|
+
]);
|
|
280
347
|
const summaries = await Promise.all(ranges.map((range) => balanceStepSummaryFromRange(context, range)));
|
|
281
348
|
const balances = {};
|
|
282
349
|
for (let summary of summaries) {
|
|
@@ -287,6 +354,7 @@ async function balanceSummary(context) {
|
|
|
287
354
|
}
|
|
288
355
|
return balances;
|
|
289
356
|
}
|
|
357
|
+
__name(balanceSummary, "balanceSummary");
|
|
290
358
|
|
|
291
359
|
// src/config/Config.ts
|
|
292
360
|
import z11 from "zod";
|
|
@@ -295,25 +363,30 @@ import z11 from "zod";
|
|
|
295
363
|
import z2, { globalRegistry } from "zod";
|
|
296
364
|
|
|
297
365
|
// src/validation/lib/isLocalhost.ts
|
|
298
|
-
var isLocalhost = (hostname) => {
|
|
366
|
+
var isLocalhost = /* @__PURE__ */ __name((hostname) => {
|
|
299
367
|
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname.endsWith(".localhost");
|
|
300
|
-
};
|
|
368
|
+
}, "isLocalhost");
|
|
301
369
|
|
|
302
370
|
// src/validation/lib/getUrl.ts
|
|
303
|
-
var getUrl = (host, port) => {
|
|
371
|
+
var getUrl = /* @__PURE__ */ __name((host, port) => {
|
|
304
372
|
const scheme = isLocalhost(host) ? "http" : "https";
|
|
305
373
|
return `${scheme}://${host}:${port}`;
|
|
306
|
-
};
|
|
374
|
+
}, "getUrl");
|
|
307
375
|
|
|
308
376
|
// src/validation/schema/Address.ts
|
|
309
377
|
var TODO = true;
|
|
310
378
|
|
|
311
379
|
// src/validation/schema/Mnemonic.ts
|
|
312
380
|
import { z } from "zod";
|
|
313
|
-
var MnemonicStringZod = z.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
381
|
+
var MnemonicStringZod = z.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine((s) => [
|
|
382
|
+
12,
|
|
383
|
+
15,
|
|
384
|
+
18,
|
|
385
|
+
21,
|
|
386
|
+
24
|
|
387
|
+
].includes(s.split(" ").length), {
|
|
388
|
+
message: "Mnemonic must contain 12, 15, 18, 21, or 24 words."
|
|
389
|
+
}).describe("BIP-39 mnemonic string");
|
|
317
390
|
|
|
318
391
|
// src/config/Api.ts
|
|
319
392
|
var ApiConfigZod = z2.object({
|
|
@@ -451,10 +524,10 @@ var ProducerConfigZod = z7.object({
|
|
|
451
524
|
// src/config/storage/driver/Mongo.ts
|
|
452
525
|
import { isDefined as isDefined2, isUndefined } from "@xylabs/typeof";
|
|
453
526
|
import z8, { globalRegistry as globalRegistry7 } from "zod";
|
|
454
|
-
var hasMongoConfig = (config) => {
|
|
527
|
+
var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
455
528
|
if (isUndefined(config)) return false;
|
|
456
529
|
return isDefined2(config.connectionString) && isDefined2(config.database) && isDefined2(config.domain) && isDefined2(config.password) && isDefined2(config.username);
|
|
457
|
-
};
|
|
530
|
+
}, "hasMongoConfig");
|
|
458
531
|
var MongoConfigZod = z8.object({
|
|
459
532
|
// TODO: Create from other arguments
|
|
460
533
|
connectionString: z8.string().min(1).optional().register(globalRegistry7, {
|
|
@@ -511,7 +584,9 @@ var TelemetryConfigZod = z10.object({
|
|
|
511
584
|
}).describe("Telemetry configuration options");
|
|
512
585
|
|
|
513
586
|
// src/config/Config.ts
|
|
514
|
-
var Xl1CommonConfigSchema = z11.object({
|
|
587
|
+
var Xl1CommonConfigSchema = z11.object({
|
|
588
|
+
...LogConfigZod.shape
|
|
589
|
+
}).describe("XL1 common configuration options");
|
|
515
590
|
var ConfigZod = z11.object({
|
|
516
591
|
...Xl1CommonConfigSchema.shape,
|
|
517
592
|
api: ApiConfigZod.default(ApiConfigZod.parse({})).describe("Configuration for the API node"),
|
|
@@ -522,7 +597,7 @@ var ConfigZod = z11.object({
|
|
|
522
597
|
storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe("Configuration for the storage"),
|
|
523
598
|
telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe("Configuration for telemetry")
|
|
524
599
|
});
|
|
525
|
-
var getDefaultConfig = () => ConfigZod.parse({});
|
|
600
|
+
var getDefaultConfig = /* @__PURE__ */ __name(() => ConfigZod.parse({}), "getDefaultConfig");
|
|
526
601
|
|
|
527
602
|
// src/config/UsageMeta.ts
|
|
528
603
|
import z12 from "zod";
|
|
@@ -535,7 +610,12 @@ var JSONSchemaMetaSchema = z12.object({
|
|
|
535
610
|
deprecated: z12.boolean().optional()
|
|
536
611
|
}).catchall(z12.unknown());
|
|
537
612
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
538
|
-
var ChoicesSchema = z12.array(z12.union([
|
|
613
|
+
var ChoicesSchema = z12.array(z12.union([
|
|
614
|
+
z12.string(),
|
|
615
|
+
z12.number(),
|
|
616
|
+
z12.literal(true),
|
|
617
|
+
z12.undefined()
|
|
618
|
+
])).readonly();
|
|
539
619
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
540
620
|
choices: ChoicesSchema.optional(),
|
|
541
621
|
default: z12.unknown().optional(),
|
|
@@ -554,6 +634,7 @@ var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
|
554
634
|
function isUsageMeta(v) {
|
|
555
635
|
return UsageMetaSchema.safeParse(v).success;
|
|
556
636
|
}
|
|
637
|
+
__name(isUsageMeta, "isUsageMeta");
|
|
557
638
|
|
|
558
639
|
// src/transaction/buildTransaction.ts
|
|
559
640
|
import { assertEx as assertEx3 } from "@xylabs/assert";
|
|
@@ -588,9 +669,20 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
588
669
|
if (script.length > 0) {
|
|
589
670
|
fields.script = script;
|
|
590
671
|
}
|
|
591
|
-
const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({
|
|
592
|
-
|
|
672
|
+
const [tx, txPayloads] = await new BoundWitnessBuilder().fields(fields).meta({
|
|
673
|
+
$signatures: []
|
|
674
|
+
}).payloads([
|
|
675
|
+
...onChainPayloads,
|
|
676
|
+
...offChainPayloads
|
|
677
|
+
]).signers(Array.isArray(signer) ? signer : [
|
|
678
|
+
signer
|
|
679
|
+
]).build();
|
|
680
|
+
return [
|
|
681
|
+
await PayloadBuilder2.addStorageMeta(tx),
|
|
682
|
+
await PayloadBuilder2.addStorageMeta(txPayloads)
|
|
683
|
+
];
|
|
593
684
|
}
|
|
685
|
+
__name(buildTransaction, "buildTransaction");
|
|
594
686
|
|
|
595
687
|
// src/transaction/buildUnsignedTransaction.ts
|
|
596
688
|
import { toHex as toHex3 } from "@xylabs/hex";
|
|
@@ -621,9 +713,18 @@ async function buildUnsignedTransaction(chain, onChainPayloads, offChainPayloads
|
|
|
621
713
|
if (script.length > 0) {
|
|
622
714
|
fields.script = script;
|
|
623
715
|
}
|
|
624
|
-
const [tx, txPayloads] = await new BoundWitnessBuilder2().fields(fields).meta({
|
|
625
|
-
|
|
716
|
+
const [tx, txPayloads] = await new BoundWitnessBuilder2().fields(fields).meta({
|
|
717
|
+
$signatures: []
|
|
718
|
+
}).payloads([
|
|
719
|
+
...onChainPayloads,
|
|
720
|
+
...offChainPayloads
|
|
721
|
+
]).build();
|
|
722
|
+
return [
|
|
723
|
+
await PayloadBuilder3.addStorageMeta(tx),
|
|
724
|
+
await PayloadBuilder3.addStorageMeta(txPayloads)
|
|
725
|
+
];
|
|
626
726
|
}
|
|
727
|
+
__name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
627
728
|
|
|
628
729
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
629
730
|
import { delay } from "@xylabs/delay";
|
|
@@ -631,7 +732,7 @@ import { isDefined as isDefined3 } from "@xylabs/typeof";
|
|
|
631
732
|
import { PayloadBuilder as PayloadBuilder4 } from "@xyo-network/payload-builder";
|
|
632
733
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
633
734
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
634
|
-
var confirmSubmittedTransaction = async (viewer, transaction, options) => {
|
|
735
|
+
var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, transaction, options) => {
|
|
635
736
|
const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {};
|
|
636
737
|
const txBWHash = await PayloadBuilder4.hash(transaction);
|
|
637
738
|
options?.logger?.log("\u{1F680} confirming transaction:", txBWHash, "\n");
|
|
@@ -652,32 +753,27 @@ var confirmSubmittedTransaction = async (viewer, transaction, options) => {
|
|
|
652
753
|
}
|
|
653
754
|
}
|
|
654
755
|
}
|
|
655
|
-
};
|
|
756
|
+
}, "confirmSubmittedTransaction");
|
|
656
757
|
|
|
657
758
|
// src/transaction/hydrateTransaction.ts
|
|
658
759
|
import { assertEx as assertEx4 } from "@xylabs/assert";
|
|
659
760
|
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
660
761
|
import { isAllowedBlockPayload, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
661
|
-
var tryHydrateTransaction = async (archivist, hash) => {
|
|
662
|
-
return await tryHydrateTypedBoundWitness(
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
var hydrateTransaction = async (archivist, hash) => {
|
|
669
|
-
return await hydrateTypedBoundWitness(
|
|
670
|
-
archivist,
|
|
671
|
-
hash,
|
|
672
|
-
isSignedTransactionBoundWitnessWithStorageMeta
|
|
673
|
-
);
|
|
674
|
-
};
|
|
675
|
-
var flattenHydratedTransaction = (hydratedTransaction) => {
|
|
762
|
+
var tryHydrateTransaction = /* @__PURE__ */ __name(async (archivist, hash) => {
|
|
763
|
+
return await tryHydrateTypedBoundWitness(archivist, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
764
|
+
}, "tryHydrateTransaction");
|
|
765
|
+
var hydrateTransaction = /* @__PURE__ */ __name(async (archivist, hash) => {
|
|
766
|
+
return await hydrateTypedBoundWitness(archivist, hash, isSignedTransactionBoundWitnessWithStorageMeta);
|
|
767
|
+
}, "hydrateTransaction");
|
|
768
|
+
var flattenHydratedTransaction = /* @__PURE__ */ __name((hydratedTransaction) => {
|
|
676
769
|
const [tx, txPayloads] = hydratedTransaction;
|
|
677
|
-
return [
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
770
|
+
return [
|
|
771
|
+
...txPayloads,
|
|
772
|
+
tx
|
|
773
|
+
];
|
|
774
|
+
}, "flattenHydratedTransaction");
|
|
775
|
+
var flattenHydratedTransactions = /* @__PURE__ */ __name((hydratedTransactions) => hydratedTransactions.flatMap((tx) => flattenHydratedTransaction(tx)), "flattenHydratedTransactions");
|
|
776
|
+
var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async (archivist, hash) => {
|
|
681
777
|
const hydratedTransaction = await tryHydrateTransaction(archivist, hash);
|
|
682
778
|
if (!hydratedTransaction) {
|
|
683
779
|
return void 0;
|
|
@@ -695,13 +791,16 @@ var tryHydrateElevatedTransaction = async (archivist, hash) => {
|
|
|
695
791
|
}
|
|
696
792
|
}
|
|
697
793
|
if (opCodes.length === elevatedPayloads.length) {
|
|
698
|
-
return [
|
|
794
|
+
return [
|
|
795
|
+
transaction,
|
|
796
|
+
elevatedPayloads
|
|
797
|
+
];
|
|
699
798
|
}
|
|
700
799
|
return void 0;
|
|
701
|
-
};
|
|
702
|
-
var hydrateElevatedTransaction = async (archivist, hash) => {
|
|
800
|
+
}, "tryHydrateElevatedTransaction");
|
|
801
|
+
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (archivist, hash) => {
|
|
703
802
|
return assertEx4(await tryHydrateElevatedTransaction(archivist, hash), () => "Hydration failed");
|
|
704
|
-
};
|
|
803
|
+
}, "hydrateElevatedTransaction");
|
|
705
804
|
|
|
706
805
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
707
806
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
@@ -711,6 +810,7 @@ function transactionBlockByteCount([transaction, payloads]) {
|
|
|
711
810
|
const cleanPayloads = PayloadBuilder5.omitStorageMeta(payloads);
|
|
712
811
|
return cleanPayloads.reduce((acc, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes;
|
|
713
812
|
}
|
|
813
|
+
__name(transactionBlockByteCount, "transactionBlockByteCount");
|
|
714
814
|
|
|
715
815
|
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
716
816
|
import { asHash as asHash2 } from "@xylabs/hex";
|
|
@@ -721,65 +821,77 @@ function crackOperation(operation) {
|
|
|
721
821
|
if (parts.length < 2) {
|
|
722
822
|
throw new Error(`Invalid operation format: ${operation}`);
|
|
723
823
|
}
|
|
724
|
-
return [
|
|
824
|
+
return [
|
|
825
|
+
parts[0],
|
|
826
|
+
parts.slice(1)
|
|
827
|
+
];
|
|
725
828
|
}
|
|
829
|
+
__name(crackOperation, "crackOperation");
|
|
726
830
|
function crackOperations(operations) {
|
|
727
831
|
return operations.map((op) => crackOperation(op));
|
|
728
832
|
}
|
|
833
|
+
__name(crackOperations, "crackOperations");
|
|
729
834
|
|
|
730
835
|
// src/transaction/primitives/transactionElevatedPayloads.ts
|
|
731
836
|
function transactionElevatedPayloadHashes(transaction) {
|
|
732
837
|
const elevateOperations = crackOperations(transaction.script ?? []).filter((op) => op[0] === "elevate");
|
|
733
838
|
return elevateOperations.map((op) => asHash2(op[1][0], true));
|
|
734
839
|
}
|
|
840
|
+
__name(transactionElevatedPayloadHashes, "transactionElevatedPayloadHashes");
|
|
735
841
|
function transactionElevatedPayloads([transaction, payloads]) {
|
|
736
842
|
const hashes = transactionElevatedPayloadHashes(transaction);
|
|
737
843
|
const elevatedPayloads = payloads.filter((payload) => hashes.includes(payload._hash));
|
|
738
844
|
return elevatedPayloads;
|
|
739
845
|
}
|
|
846
|
+
__name(transactionElevatedPayloads, "transactionElevatedPayloads");
|
|
740
847
|
|
|
741
848
|
// src/transaction/primitives/transactionRequiredGas.ts
|
|
742
849
|
import { AttoXL1, TransactionGasCosts } from "@xyo-network/xl1-protocol";
|
|
743
850
|
function transactionBytesRequiredGas([transaction, payloads]) {
|
|
744
|
-
const transactionBlockBytes = transactionBlockByteCount([
|
|
851
|
+
const transactionBlockBytes = transactionBlockByteCount([
|
|
852
|
+
transaction,
|
|
853
|
+
payloads
|
|
854
|
+
]);
|
|
745
855
|
return AttoXL1(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes));
|
|
746
856
|
}
|
|
857
|
+
__name(transactionBytesRequiredGas, "transactionBytesRequiredGas");
|
|
747
858
|
function transactionRequiredGas(hydratedTransaction) {
|
|
748
859
|
const elevatedPayloads = transactionElevatedPayloads(hydratedTransaction);
|
|
749
860
|
const hashes = elevatedPayloads.length + 1;
|
|
750
861
|
const signatures = hydratedTransaction[0].addresses.length;
|
|
751
862
|
return AttoXL1(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads.length));
|
|
752
863
|
}
|
|
864
|
+
__name(transactionRequiredGas, "transactionRequiredGas");
|
|
753
865
|
|
|
754
866
|
// src/transaction/script.ts
|
|
755
867
|
import { filterAs as filterAs2 } from "@xylabs/array";
|
|
756
868
|
import { assertEx as assertEx5 } from "@xylabs/assert";
|
|
757
869
|
import { asHash as asHash3 } from "@xylabs/hex";
|
|
758
870
|
import { isAllowedBlockPayloadWithHashStorageMeta } from "@xyo-network/xl1-protocol";
|
|
759
|
-
var tryExtractElevatedHashesFromScript = (strings) => {
|
|
871
|
+
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
760
872
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
761
873
|
return filterAs2(hashes, (h) => asHash3(h));
|
|
762
|
-
};
|
|
763
|
-
var extractElevatedHashesFromScript = (strings) => {
|
|
874
|
+
}, "tryExtractElevatedHashesFromScript");
|
|
875
|
+
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
764
876
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
765
877
|
const filtered = filterAs2(hashes, (h) => asHash3(h));
|
|
766
878
|
assertEx5(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
767
879
|
return filtered;
|
|
768
|
-
};
|
|
769
|
-
var tryExtractElevatedHashes = (tx) => {
|
|
880
|
+
}, "extractElevatedHashesFromScript");
|
|
881
|
+
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
770
882
|
const [bw, payloads] = tx;
|
|
771
883
|
const { script } = bw;
|
|
772
884
|
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
773
885
|
return payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashStorageMeta);
|
|
774
|
-
};
|
|
775
|
-
var extractElevatedHashes = (tx) => {
|
|
886
|
+
}, "tryExtractElevatedHashes");
|
|
887
|
+
var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
776
888
|
const [bw, payloads] = tx;
|
|
777
889
|
const { script } = bw;
|
|
778
890
|
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
779
891
|
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashStorageMeta);
|
|
780
892
|
assertEx5(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
781
893
|
return filtered;
|
|
782
|
-
};
|
|
894
|
+
}, "extractElevatedHashes");
|
|
783
895
|
|
|
784
896
|
// src/transaction/signTransaction.ts
|
|
785
897
|
import { toArrayBuffer } from "@xylabs/arraybuffer";
|
|
@@ -789,31 +901,49 @@ import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/payload-builder"
|
|
|
789
901
|
async function signTransaction(tx, account) {
|
|
790
902
|
assertEx6(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
791
903
|
const signedTx = structuredClone(tx);
|
|
792
|
-
signedTx.addresses = [
|
|
793
|
-
|
|
904
|
+
signedTx.addresses = [
|
|
905
|
+
account.address
|
|
906
|
+
];
|
|
907
|
+
signedTx.previous_hashes = [
|
|
908
|
+
account.previousHash ?? null
|
|
909
|
+
];
|
|
794
910
|
const hash = await PayloadBuilder6.hash(signedTx);
|
|
795
911
|
const hashBytes = toArrayBuffer(hash);
|
|
796
912
|
const [signature] = await account.sign(hashBytes);
|
|
797
|
-
signedTx.$signatures = [
|
|
913
|
+
signedTx.$signatures = [
|
|
914
|
+
hexFromArrayBuffer(signature)
|
|
915
|
+
];
|
|
798
916
|
return signedTx;
|
|
799
917
|
}
|
|
918
|
+
__name(signTransaction, "signTransaction");
|
|
800
919
|
|
|
801
920
|
// src/wallet/generateXyoBaseWalletFromPhrase.ts
|
|
802
921
|
import { HDWallet } from "@xyo-network/wallet";
|
|
803
922
|
|
|
804
923
|
// src/wallet/paths.ts
|
|
805
924
|
var WALLET_COMPLIANCE = "44'";
|
|
806
|
-
var COIN_TYPES = {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
var
|
|
925
|
+
var COIN_TYPES = {
|
|
926
|
+
Ethereum: "60'"
|
|
927
|
+
};
|
|
928
|
+
var ACCOUNT_TYPE = {
|
|
929
|
+
GANACHE: "0'",
|
|
930
|
+
XYO: "0'"
|
|
931
|
+
};
|
|
932
|
+
var CHANGE_ADDRESS = {
|
|
933
|
+
META_MASK: "0",
|
|
934
|
+
XYO: "0"
|
|
935
|
+
};
|
|
936
|
+
var ADDRESS_INDEX = {
|
|
937
|
+
META_MASK: "0",
|
|
938
|
+
XYO: "0"
|
|
939
|
+
};
|
|
810
940
|
var DEFAULT_WALLET_PATH = `m/${WALLET_COMPLIANCE}/${COIN_TYPES.Ethereum}/${ACCOUNT_TYPE.XYO}/${CHANGE_ADDRESS.XYO}`;
|
|
811
941
|
|
|
812
942
|
// src/wallet/generateXyoBaseWalletFromPhrase.ts
|
|
813
|
-
var generateXyoBaseWalletFromPhrase = (walletPhrase) => {
|
|
943
|
+
var generateXyoBaseWalletFromPhrase = /* @__PURE__ */ __name((walletPhrase) => {
|
|
814
944
|
const wallet = HDWallet.fromPhrase(walletPhrase, DEFAULT_WALLET_PATH);
|
|
815
945
|
return wallet;
|
|
816
|
-
};
|
|
946
|
+
}, "generateXyoBaseWalletFromPhrase");
|
|
817
947
|
export {
|
|
818
948
|
ACCOUNT_TYPE,
|
|
819
949
|
ADDRESS_INDEX,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/block/hydrateBlock.ts","../../src/block/primitives/balanceStepSummaryFromRange.ts","../../src/payload/netBalancesForPayloads.ts","../../src/SignedBigInt.ts","../../src/block/primitives/frames/calculateFramesFromRange.ts","../../src/block/primitives/frames/deepCalculateFramesFromRange.ts","../../src/block/primitives/hashFromBlockNumber.ts","../../src/block/primitives/payloads.ts","../../src/block/primitives/balanceSummary.ts","../../src/config/Config.ts","../../src/config/Api.ts","../../src/validation/lib/isLocalhost.ts","../../src/validation/lib/getUrl.ts","../../src/validation/schema/Address.ts","../../src/validation/schema/Mnemonic.ts","../../src/config/App.ts","../../src/config/Chain.ts","../../src/config/Evm.ts","../../src/config/Log.ts","../../src/config/Producer.ts","../../src/config/storage/driver/Mongo.ts","../../src/config/storage/Storage.ts","../../src/config/Telemetry.ts","../../src/config/UsageMeta.ts","../../src/transaction/buildTransaction.ts","../../src/transaction/buildUnsignedTransaction.ts","../../src/transaction/confirmSubmittedTransaction.ts","../../src/transaction/hydrateTransaction.ts","../../src/transaction/primitives/transactionBlockByteCount.ts","../../src/transaction/primitives/transactionElevatedPayloads.ts","../../src/transaction/primitives/transactionOperations.ts","../../src/transaction/primitives/transactionRequiredGas.ts","../../src/transaction/script.ts","../../src/transaction/signTransaction.ts","../../src/wallet/generateXyoBaseWalletFromPhrase.ts","../../src/wallet/paths.ts"],"sourcesContent":["import { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport type { HydratedBlock, TransactionBoundWitness } from '@xyo-network/xl1-protocol'\nimport {\n asTransactionBoundWitnessWithStorageMeta, isBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta,\n} from '@xyo-network/xl1-protocol'\n\nexport function allHashesPresent(hashes: Hash[], payloads: WithStorageMeta<Payload>[]): boolean {\n const payloadHashes = new Set(payloads.map(p => p._hash))\n return hashes.every(hash => payloadHashes.has(hash))\n}\n\nexport const tryHydrateBlock = async (\n archivist: ReadArchivist,\n hash: Hash,\n maxDepth: number = 1,\n): Promise<HydratedBlock | undefined> => {\n assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')\n const bw = (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta)\n if (!bw) return undefined\n if (maxDepth === 0) return [bw, []]\n const blkPayloads = await archivist.get(bw.payload_hashes)\n if (maxDepth === 1) return [bw, blkPayloads]\n const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)\n const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)\n const transactionsPayloads = await archivist.get(transactionsPayloadHashes)\n const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))\n const allPayloads = await archivist.get([...allPayloadsHashes])\n const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))\n return [bw, allPayloadsFiltered]\n}\n\nexport const hydrateBlock = async (\n archivist: ReadArchivist,\n hash: Hash,\n maxDepth: number = 1,\n minDepth = maxDepth,\n): Promise<HydratedBlock> => {\n assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')\n assertEx(minDepth >= 0, () => 'minDepth must be greater than or equal to 0')\n assertEx(maxDepth >= minDepth, () => 'maxDepth must be greater than or equal to minDepth')\n const bw = assertEx(\n (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta),\n () => `block ${hash} not found`,\n )\n if (maxDepth === 0) return [bw, []]\n const blkPayloads = await archivist.get(bw.payload_hashes)\n if (minDepth === 1) assertEx(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`)\n if (maxDepth === 1) return [bw, blkPayloads]\n const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)\n const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)\n const transactionsPayloads = await archivist.get(transactionsPayloadHashes)\n assertEx(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`)\n const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))\n const allPayloads = await archivist.get([...allPayloadsHashes])\n const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))\n if (maxDepth === 2) assertEx(allHashesPresent(\n [...allPayloadsHashes],\n allPayloadsFiltered,\n ), () => `Unable to find all payloads for transactions in block ${hash}`)\n return [bw, allPayloadsFiltered]\n}\n\nexport const flattenHydratedBlock = (hydratedBlock: HydratedBlock): WithStorageMeta<Payload>[] => {\n const [blk, blkPayloads] = hydratedBlock\n return [...blkPayloads, blk]\n}\n\nexport const flattenHydratedBlocks = (hydratedBlocks: HydratedBlock[]): WithStorageMeta<Payload>[] =>\n hydratedBlocks.flatMap(blk => flattenHydratedBlock(blk))\n\nexport const transactionsFromHydratedBlock = (block: HydratedBlock): WithStorageMeta<TransactionBoundWitness>[] => {\n return filterAs(block[1], asTransactionBoundWitnessWithStorageMeta)\n}\n\nexport const blockPayloadsFromHydratedBlock = (block: HydratedBlock): WithStorageMeta<Payload>[] => {\n return block[0].payload_hashes.map(hash => assertEx(\n block[1].find(p => p._hash === hash),\n () => `missing payload ${hash}`,\n )).filter(x => !isTransactionBoundWitnessWithStorageMeta(x))\n}\n","import { assertEx } from '@xylabs/assert'\nimport { type Address } from '@xylabs/hex'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isAnyPayload } from '@xyo-network/payload-model'\nimport { StepSizes } from '@xyo-network/xl1-protocol'\n\nimport { netBalancesForPayloads } from '../../payload/index.ts'\nimport {\n parseSignedBigInt, type SignedBigInt, toSignedBigInt,\n} from '../../SignedBigInt.ts'\nimport { hydrateBlock } from '../hydrateBlock.ts'\nimport type { BlockNumberRange } from './frames/index.ts'\nimport { deepCalculateFramesFromRange } from './frames/index.ts'\nimport { hashFromBlockNumber } from './hashFromBlockNumber.ts'\nimport type { BalanceStepSummaryContext } from './model.ts'\nimport { type BalancesStepSummary, BalancesStepSummarySchema } from './payloads.ts'\n\nexport async function balanceStepSummaryFromRange(\n context: BalanceStepSummaryContext,\n range: BlockNumberRange,\n): Promise<WithStorageMeta<BalancesStepSummary>> {\n // console.log(`balanceStepSummaryFromRange: head=${head}, range=${range[0]}-${range[1]}`)\n const frameHeadHash = await hashFromBlockNumber(context, range[1])\n const frameSize = range[1] - range[0] + 1\n\n let result: BalancesStepSummary | undefined = undefined\n\n if (frameSize === 1) {\n const hash = await hashFromBlockNumber(context, range[0])\n const [, payloads] = await hydrateBlock(context.chainArchivist, hash)\n const balances: Record<Address, SignedBigInt> = {}\n for (const [address, balance] of Object.entries(netBalancesForPayloads(payloads))) {\n balances[address as Address] = toSignedBigInt(balance)\n }\n result = {\n schema: BalancesStepSummarySchema, hash: context.head, stepSize: -1, balances,\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const step = (StepSizes as any).indexOf(frameSize)\n assertEx(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes.join(', ')}`)\n\n const [summaryResult] = await context.summaryRepository.get([frameHeadHash])\n if (isAnyPayload(summaryResult)) {\n result = summaryResult as WithStorageMeta<BalancesStepSummary>\n } else {\n // We do not have it, so lets build it\n const subRanges = deepCalculateFramesFromRange(range, step - 1)\n const promises = subRanges.map(subRange => balanceStepSummaryFromRange(\n context,\n subRange,\n ))\n const subResults = await Promise.all(promises)\n\n // add them all up\n const bigIntBalances: Record<Address, bigint> = {}\n for (const subResult of subResults) {\n for (const [address, balance] of Object.entries(subResult.balances)) {\n bigIntBalances[address as Address] = (bigIntBalances[address as Address] ?? 0n) + parseSignedBigInt(balance)\n }\n }\n\n const balances: Record<Address, SignedBigInt> = {}\n for (const [address, balance] of Object.entries(bigIntBalances)) {\n balances[address as Address] = toSignedBigInt(balance)\n }\n\n result = {\n schema: BalancesStepSummarySchema, hash: frameHeadHash, stepSize: frameSize, balances,\n }\n\n await context.summaryRepository.insert([result])\n }\n }\n // console.log(`balanceStepSummaryFromRange-result: head=${head}, range=${range[0]}-${range[1]}: ${toSafeJsonString(result, 10)}`)\n const finalResult = await PayloadBuilder.addStorageMeta(result)\n return finalResult\n}\n","import {\n type Address, type Hex, hexToBigInt, toAddress,\n} from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isTransfer } from '@xyo-network/xl1-protocol'\n\nexport const netBalancesForPayloads = (payloads: Payload[]) => {\n const balances: Record<Address, bigint> = {}\n for (const payload of payloads) {\n if (isTransfer(payload)) {\n const { from } = payload\n for (let [address, amount] of Object.entries(payload.transfers) as [Address, Hex][]) {\n balances[toAddress(address)] = (balances[toAddress(address)] ?? 0n) + hexToBigInt(amount)\n balances[toAddress(from)] = (balances[toAddress(from)] ?? 0n) - hexToBigInt(amount)\n }\n }\n }\n return balances\n}\n","import {\n type Hex,\n hexToBigInt,\n toHex,\n} from '@xylabs/hex'\nimport { isObject } from '@xylabs/object'\n\nexport interface NegativeBigInt {\n negative: Hex\n}\n\nexport interface PositiveBigInt {\n positive: Hex\n}\n\nexport type SignedBigInt = NegativeBigInt | PositiveBigInt\n\nexport const isNegativeBigInt = (value: unknown): value is NegativeBigInt => {\n return isObject(value) && 'negative' in value && typeof value.negative === 'string'\n}\n\nexport const isPositiveBigInt = (value: unknown): value is PositiveBigInt => {\n return isObject(value) && 'positive' in value && typeof value.positive === 'string'\n}\n\nexport const parseSignedBigInt = (value: SignedBigInt): bigint => {\n if (isNegativeBigInt(value)) {\n return -hexToBigInt(value.negative)\n } else if (isPositiveBigInt(value)) {\n return hexToBigInt(value.positive)\n } else {\n throw new Error('Invalid balance type')\n }\n}\n\nexport const toSignedBigInt = (value: bigint): SignedBigInt => {\n return value < 0n ? { negative: toHex(-value) } : { positive: toHex(value) }\n}\n\nexport const toPositiveBigInt = (value: unknown): PositiveBigInt => {\n if (isNegativeBigInt(value)) {\n return { positive: toHex(0n) }\n }\n if (isPositiveBigInt(value)) {\n return { positive: value.positive }\n }\n if (typeof value === 'bigint') {\n return { positive: toHex(value) }\n }\n throw new Error('Invalid value for positive big int')\n}\n","import { stepSize } from '@xyo-network/xl1-protocol'\n\nimport type { BlockNumberRange } from './BlockNumberRange.ts'\n\nexport function calculateFramesFromRange(range: BlockNumberRange, step: number): [\n // ranges of fitted frames\n BlockNumberRange[],\n // ranges of remaining blocks\n BlockNumberRange[]] {\n const size = stepSize(step)\n let start = (Math.trunc(range[0] / size)) * size\n const fitted: BlockNumberRange[] = []\n const remaining: BlockNumberRange[] = []\n\n // if the start is not aligned with the range, add a remaining block\n if (start !== range[0]) {\n start += size\n remaining.push([range[0], Math.min(start - 1, range[1])])\n }\n\n for (let i = start; i <= range[1]; i += size) {\n if ((i + size - 1) <= range[1]) {\n fitted.push([i, Math.min(i + size - 1, range[1])])\n } else {\n remaining.push([i, range[1]])\n }\n }\n return [fitted, remaining]\n}\n","import { StepSizes } from '@xyo-network/xl1-protocol'\n\nimport type { BlockNumberRange } from './BlockNumberRange.ts'\nimport { calculateFramesFromRange } from './calculateFramesFromRange.ts'\n\nexport function deepCalculateFramesFromRange(range: BlockNumberRange, startingStep = StepSizes.length - 1): BlockNumberRange[] {\n const fitted: BlockNumberRange[] = []\n let remaining: BlockNumberRange[] = [range]\n\n for (let step = startingStep; step >= 0; step--) {\n const newRemaining: BlockNumberRange[] = []\n for (const range of remaining) {\n const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range, step)\n fitted.push(...newFittedFrames)\n newRemaining.push(...newRemainingFrames)\n }\n remaining = newRemaining\n }\n\n for (const range of remaining) {\n for (let i = range[0]; i <= range[1]; i++) {\n fitted.push([i, i]) // Add individual frames for remaining ranges\n }\n }\n\n return fitted.toSorted((a, b) => a[0] - b[0]) // Sort by start of range\n}\n","import { asHash, type Hash } from '@xylabs/hex'\nimport { toSafeJsonString } from '@xylabs/object'\nimport { asBlockBoundWitnessWithStorageMeta, StepSizes } from '@xyo-network/xl1-protocol'\n\nimport type { ChainContext } from './model.ts'\n\nexport async function hashFromBlockNumber(context: ChainContext, blockNumber: number): Promise<Hash> {\n const result = await context.chainArchivist.get([context.head])\n let currentBlock = asBlockBoundWitnessWithStorageMeta(result.at(0), () => `Head block not found for hash: ${context.head}`, { required: true })\n while (currentBlock.block > blockNumber) {\n let jumpHash: Hash | null = currentBlock.previous\n let jumpBlockNumber = currentBlock.block - 1\n for (const [step, stepSize] of StepSizes.entries()) {\n const possibleJumpBlockNumber = currentBlock.block - stepSize\n if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {\n jumpBlockNumber = possibleJumpBlockNumber\n jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`)\n }\n }\n const [newBlock] = await context.chainArchivist.get([\n asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`)])\n currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, { required: true })\n if (currentBlock.block === blockNumber) {\n break\n }\n if (currentBlock.block < blockNumber) {\n throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${context.head}.`)\n }\n }\n return currentBlock._hash\n}\n","import type { Address, Hash } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type {\n Payload, Schema, WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { SignedBigInt } from '../../SignedBigInt.ts'\n\nexport const StepSummarySchema: Schema = 'network.xyo.step.summary'\nexport type StepSummarySchema = typeof StepSummarySchema\n\nexport interface StepSummaryFields {\n hash: Hash // the stepHash - the hash of the last block in the step frame\n stepSize: number // the stepSize in blocks\n}\n\nexport interface ChainWindow {\n depth: number // number of blocks the window covers, including the head\n head: Hash // the head of the chain\n}\n\nexport type StepSummary<TAdditionalFields extends EmptyObject | void = void,\n TSchema extends Schema | void = void> = Payload<TAdditionalFields extends void ? StepSummaryFields : TAdditionalFields & StepSummaryFields,\n TSchema extends void ? StepSummarySchema : TSchema>\n\nexport const BalancesStepSummarySchema: Schema = 'network.xyo.step.summary.balances'\nexport type BalancesStepSummarySchema = typeof BalancesStepSummarySchema\n\nexport type BalancesStepSummary = StepSummary<{\n balances: Record<Address, SignedBigInt>\n}, BalancesStepSummarySchema>\n\n/**\n * Identity function for determining if an object is an BalancesStepSummary\n */\nexport const isBalancesStepSummary = isPayloadOfSchemaType<BalancesStepSummary>(BalancesStepSummarySchema)\nexport const asBalancesStepSummary = AsObjectFactory.create<BalancesStepSummary>(isBalancesStepSummary)\n\n/**\n * Identity function for determining if an object is an BalancesStepSummary with Storage Meta\n */\nexport const isBalancesStepSummaryWithStorageMeta = (value: unknown): value is WithStorageMeta<BalancesStepSummary> => {\n return isBalancesStepSummary(value) && isStorageMeta(value)\n}\nexport const asBalancesStepSummaryWithStorageMeta = AsObjectFactory.create<WithStorageMeta<BalancesStepSummary>>(isBalancesStepSummaryWithStorageMeta)\n","import type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport { asBlockBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'\n\nimport { parseSignedBigInt } from '../../SignedBigInt.ts'\nimport { balanceStepSummaryFromRange } from './balanceStepSummaryFromRange.ts'\nimport { deepCalculateFramesFromRange } from './frames/index.ts'\nimport type { BalanceStepSummaryContext } from './model.ts'\n\nexport async function balanceSummary(\n context: BalanceStepSummaryContext,\n): Promise<Partial<Record<Address, bigint>>> {\n const headResult = await context.chainArchivist.get([context.head])\n const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult.at(0), () => `Head block not found for hash: ${context.head}`, { required: true })\n const rangeStart = isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0\n const ranges = deepCalculateFramesFromRange([rangeStart, headBoundWitness.block])\n const summaries = await Promise.all(ranges.map(range => balanceStepSummaryFromRange(context, range)))\n const balances: Partial<Record<Address, bigint>> = {}\n for (let summary of summaries) {\n for (const [address, balance] of Object.entries(summary.balances)) {\n const validAddress = asAddress(address, () => `Invalid address: ${address}`)\n balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance)\n }\n }\n return balances\n}\n","import z from 'zod'\n\nimport { ApiConfigZod } from './Api.ts'\nimport { AppConfigZod } from './App.ts'\nimport { ChainConfigZod } from './Chain.ts'\nimport { EvmConfigZod } from './Evm.ts'\nimport { LogConfigZod } from './Log.ts'\nimport { ProducerConfigZod } from './Producer.ts'\nimport { StorageConfigZod } from './storage/index.ts'\nimport { TelemetryConfigZod } from './Telemetry.ts'\n\nexport const Xl1CommonConfigSchema = z.object({ ...LogConfigZod.shape }).describe('XL1 common configuration options')\n\nexport const ConfigZod = z.object({\n ...Xl1CommonConfigSchema.shape,\n api: ApiConfigZod.default(ApiConfigZod.parse({})).describe('Configuration for the API node'),\n app: AppConfigZod.default(AppConfigZod.parse({})).describe('Configuration for the application'),\n chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),\n evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),\n producer: ProducerConfigZod.default(ProducerConfigZod.parse({})).describe('Configuration for the producer'),\n storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),\n telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),\n})\n\nexport type Config = z.infer<typeof ConfigZod>\n\nexport const getDefaultConfig = (): Config => ConfigZod.parse({})\n","import z, { globalRegistry } from 'zod'\n\nimport { MnemonicStringZod } from '../validation/index.ts'\n\nexport const ApiConfigZod = z.object({\n host: z.string().default('localhost').register(globalRegistry, {\n default: 'localhost',\n description: 'Host for the API',\n title: 'api.host',\n type: 'string',\n }),\n mnemonic: MnemonicStringZod.optional().register(globalRegistry, {\n description: 'Mnemonic for the API wallet',\n title: 'api.mnemonic',\n type: 'string',\n }),\n port: z.coerce.number().default(8080).register(globalRegistry, {\n default: 8080,\n description: 'Port for the API',\n title: 'api.port',\n type: 'number',\n }),\n})\n\nexport type ApiConfig = z.infer<typeof ApiConfigZod>\n","export const isLocalhost = (hostname: string): boolean => {\n return (\n hostname === 'localhost'\n || hostname === '127.0.0.1'\n || hostname === '::1' // IPv6 localhost\n || hostname.endsWith('.localhost')\n )\n}\n","import { isLocalhost } from './isLocalhost.ts'\n\nexport const getUrl = (host: string, port: number): string => {\n const scheme = isLocalhost(host) ? 'http' : 'https'\n return `${scheme}://${host}:${port}`\n}\n","export const TODO = true\n","import { z } from 'zod'\n\n/**\n * Validates a single string containing a BIP-39 mnemonic.\n *\n * • Trims leading/trailing whitespace.\n * • Collapses any run of whitespace (spaces, tabs, new-lines) to a single space.\n * • Splits on spaces → array of words.\n * • Checks that the word-count is 12, 15, 18, 21, or 24.\n *\n */\nexport const MnemonicStringZod = z\n .string()\n .transform(s => s.trim().replaceAll(/\\s+/g, ' ')) // normalize spacing\n .refine(\n s => [12, 15, 18, 21, 24].includes(s.split(' ').length),\n { message: 'Mnemonic must contain 12, 15, 18, 21, or 24 words.' },\n ).describe('BIP-39 mnemonic string')\n\nexport type MnemonicString = z.infer<typeof MnemonicStringZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const AppConfigZod = z.object({\n port: z.coerce.number().default(3000).register(globalRegistry, {\n default: 3000,\n description: 'Port for the application',\n title: 'app.port',\n type: 'number',\n }),\n})\n\nexport type AppConfig = z.infer<typeof AppConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const ChainConfigZod = z.object({\n id: z.string().optional()\n .register(globalRegistry, {\n description:\n 'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',\n title: 'chain.id',\n type: 'string',\n }),\n})\n\nexport type ChainConfig = z.infer<typeof ChainConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const EvmInfuraConfigZod = z.object({\n projectId: z.string().optional().register(globalRegistry, {\n description: 'Infura project ID',\n title: 'evm.infura.projectId',\n type: 'string',\n }),\n projectSecret: z.string().optional().register(globalRegistry, {\n description: 'Infura project secret',\n title: 'evm.infura.projectSecret',\n type: 'string',\n }),\n})\n\nexport const EvmJsonRpcConfigZod = z.object({\n url: z.url().optional().register(globalRegistry, {\n description: 'JSON-RPC URL',\n title: 'evm.jsonRpc.url',\n type: 'string',\n }),\n})\n\nexport const EvmConfigZod = z.object({\n chainId: z.string().optional().register(globalRegistry, {\n description: 'EVM chain ID',\n title: 'evm.chainId',\n type: 'string',\n }),\n infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),\n jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),\n})\n\nexport type EvmConfig = z.infer<typeof EvmConfigZod>\n","import type { LogLevelKey } from '@xylabs/logger'\nimport { LogLevel } from '@xylabs/logger'\nimport z, { globalRegistry } from 'zod'\nconst LogLevels = Object.keys(LogLevel) as [LogLevelKey, ...LogLevelKey[]]\n\nexport const LogConfigZod = z.object({\n logLevel: z.enum(LogLevels).default('info').register(globalRegistry, {\n choices: LogLevels,\n default: 'info',\n description: 'Desired process verbosity',\n title: 'logLevel',\n type: 'string',\n }),\n silent: z.boolean().default(false).register(globalRegistry, {\n default: false,\n description: 'Whether to run in silent mode',\n title: 'silent',\n type: 'boolean',\n }),\n})\n\nexport type LogConfig = z.infer<typeof LogConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nimport { MnemonicStringZod } from '../validation/index.ts'\n\nexport const ProducerConfigZod = z.object({\n disableIntentRedeclaration: z.boolean().optional().register(globalRegistry, {\n description: 'Should the producer skip redeclaring their intent to continue producing blocks',\n title: 'producer.disableIntentRedeclaration',\n type: 'boolean',\n }),\n // TODO: Port schema\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: 'Port for the Producer health checks',\n title: 'producer.healthCheckPort',\n type: 'number',\n }),\n // TODO: BigInt schema\n minStake: z.coerce.number().default(1).register(globalRegistry, {\n description: 'Minimum stake required to be a Producer',\n title: 'producer.minStake',\n type: 'number',\n }),\n mnemonic: MnemonicStringZod.optional().register(globalRegistry, {\n description: 'Mnemonic for the Producer wallet',\n title: 'producer.mnemonic',\n type: 'string',\n }),\n // TODO: Port schema\n port: z.coerce.number().default(8081).register(globalRegistry, {\n default: 8081,\n description: 'Port for the Producer',\n title: 'producer.port',\n type: 'number',\n }),\n // TODO: Address schema\n rewardAddress: z.string().optional().register(globalRegistry, {\n description: 'Address to receive block rewards',\n title: 'producer.rewardAddress',\n type: 'string',\n }),\n})\n\nexport type ProducerConfig = z.infer<typeof ProducerConfigZod>\n","import { isDefined, isUndefined } from '@xylabs/typeof'\nimport z, { globalRegistry } from 'zod'\n\n/**\n * Checks if the provided MongoDB configuration contains all necessary fields\n * for establishing a connection.\n * @param config MongoDB configuration object\n * @returns True if the configuration contains all necessary fields for\n * establishing a connection\n */\nexport const hasMongoConfig = (config?: MongoConfig): config is Required<MongoConfig> => {\n if (isUndefined(config)) return false\n return (\n isDefined(config.connectionString)\n && isDefined(config.database)\n && isDefined(config.domain)\n && isDefined(config.password)\n && isDefined(config.username)\n )\n}\n\nexport const MongoConfigZod = z.object({\n // TODO: Create from other arguments\n connectionString: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB connection string',\n title: 'storage.mongo.connectionString',\n type: 'string',\n }),\n database: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB database name',\n title: 'storage.mongo.database',\n type: 'string',\n }),\n domain: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB domain',\n title: 'storage.mongo.domain',\n type: 'string',\n }),\n password: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB password',\n title: 'storage.mongo.password',\n type: 'string',\n }),\n username: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB username',\n title: 'storage.mongo.username',\n type: 'string',\n }),\n})\n\nexport type MongoConfig = z.infer<typeof MongoConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nimport { MongoConfigZod } from './driver/index.ts'\n\nexport const StorageConfigZod = z.object({\n mongo: MongoConfigZod.optional().describe('Configuration for the MongoD storage driver'),\n root: z.string().optional().register(globalRegistry, {\n description: 'Root directory for local storage',\n title: 'storage.root',\n type: 'string',\n }),\n}).describe('Storage configuration options')\n\nexport type StorageConfig = z.infer<typeof StorageConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const OpenTelemetryConfigZod = z.object({\n // OpenTelemetry options\n otlpEndpoint: z.url().optional().register(globalRegistry, {\n description: 'OTLP endpoint for exporting telemetry data',\n title: 'telemetry.otel.otlpEndpoint',\n type: 'string',\n }),\n})\n\nexport const TelemetryConfigZod = z.object({\n // OpenTelemetry configuration\n otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),\n}).describe('Telemetry configuration options')\n\nexport type TelemetryConfig = z.infer<typeof TelemetryConfigZod>\n","import z from 'zod'\n\nconst DescriptionSchema = z.string()\nconst TitleSchema = z.string()\n\nexport const JSONSchemaMetaSchema = z\n .object({\n id: z.string().optional(),\n title: TitleSchema.optional(),\n description: DescriptionSchema.optional(),\n deprecated: z.boolean().optional(),\n })\n .catchall(z.unknown()) // allow arbitrary extra keys\n\nexport const GlobalMetaSchema = JSONSchemaMetaSchema.extend({})\n\nconst ChoicesSchema = z\n .array(z.union([z.string(), z.number(), z.literal(true), z.undefined()]))\n .readonly()\n\nexport const UsageMetaSchema = GlobalMetaSchema.extend({\n choices: ChoicesSchema.optional(),\n default: z.unknown().optional(),\n description: DescriptionSchema,\n group: z.string().optional(),\n hidden: z.boolean().optional(),\n title: TitleSchema,\n type: z.union([\n z.literal('array'),\n z.literal('count'),\n z.literal('boolean'),\n z.literal('number'),\n z.literal('string'),\n ]),\n})\n\nexport type UsageMeta = z.infer<typeof UsageMetaSchema>\n\nexport function isUsageMeta(v: unknown): v is UsageMeta {\n return UsageMetaSchema.safeParse(v).success\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n Chain,\n ExecutableFields,\n FromFields,\n SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,\n} from '@xyo-network/xl1-protocol'\nimport { defaultTransactionFees } from '@xyo-network/xl1-protocol'\n\nexport async function buildTransaction(\n chain: Chain,\n onChainPayloads: AllowedBlockPayload[],\n offChainPayloads: Payload[],\n signer: AccountInstance | AccountInstance[],\n nbf: number,\n exp: number,\n from?: Address,\n fees: TransactionFeesBigInt = defaultTransactionFees,\n): Promise<SignedHydratedTransactionWithStorageMeta> {\n if (from === undefined && Array.isArray(signer)) {\n throw new Error('from is required when signer is an array')\n }\n\n const txBoundWitnessFields: TransactionBoundWitnessFields = {\n chain,\n fees: {\n base: toHex(fees.base),\n gasLimit: toHex(fees.gasLimit),\n gasPrice: toHex(fees.gasPrice),\n priority: toHex(fees.priority),\n },\n nbf,\n exp,\n }\n\n const elevatedHashes = await PayloadBuilder.hashes(onChainPayloads)\n const script: string[] = []\n for (const elevatedHash of elevatedHashes) {\n script.push(`elevate|${elevatedHash}`)\n }\n\n const fields: TransactionBoundWitnessFields & FromFields & Partial<ExecutableFields> = {\n ...txBoundWitnessFields,\n from: from ?? (Array.isArray(signer) ? assertEx(signer.at(0)?.address) : signer.address),\n }\n\n if (script.length > 0) {\n fields.script = script\n }\n\n const [tx, txPayloads] = await new BoundWitnessBuilder<TransactionBoundWitness>()\n .fields(fields)\n .meta({ $signatures: [] })\n .payloads([...onChainPayloads, ...offChainPayloads])\n .signers(Array.isArray(signer) ? signer : [signer])\n .build()\n\n return [await PayloadBuilder.addStorageMeta(tx), await PayloadBuilder.addStorageMeta(txPayloads)]\n}\n","import type { Address } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n Chain,\n ExecutableFields,\n FromFields,\n SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,\n} from '@xyo-network/xl1-protocol'\nimport { defaultTransactionFees } from '@xyo-network/xl1-protocol'\n\nexport async function buildUnsignedTransaction(\n chain: Chain,\n onChainPayloads: AllowedBlockPayload[],\n offChainPayloads: Payload[],\n nbf: number,\n exp: number,\n from: Address,\n fees: TransactionFeesBigInt = defaultTransactionFees,\n): Promise<SignedHydratedTransactionWithStorageMeta> {\n const txBoundWitnessFields: TransactionBoundWitnessFields = {\n chain,\n fees: {\n base: toHex(fees.base),\n gasLimit: toHex(fees.gasLimit),\n gasPrice: toHex(fees.gasPrice),\n priority: toHex(fees.priority),\n },\n nbf,\n exp,\n }\n\n const elevatedHashes = await PayloadBuilder.hashes(onChainPayloads)\n const script: string[] = []\n for (const elevatedHash of elevatedHashes) {\n script.push(`elevate|${elevatedHash}`)\n }\n\n const fields: TransactionBoundWitnessFields & FromFields & Partial<ExecutableFields> = {\n ...txBoundWitnessFields,\n from,\n }\n\n if (script.length > 0) {\n fields.script = script\n }\n\n const [tx, txPayloads] = await new BoundWitnessBuilder<TransactionBoundWitness>()\n .fields(fields)\n .meta({ $signatures: [] })\n .payloads([...onChainPayloads, ...offChainPayloads])\n .build()\n\n return [await PayloadBuilder.addStorageMeta(tx), await PayloadBuilder.addStorageMeta(txPayloads)]\n}\n","import { delay } from '@xylabs/delay'\nimport type { Logger } from '@xylabs/logger'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type {\n SignedHydratedTransaction, TransactionBoundWitness, XyoViewer,\n} from '@xyo-network/xl1-protocol'\n\nconst DEFAULT_CONFIRMATION_ATTEMPTS = 20\nconst DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1000 // milliseconds\n\nexport type ConfirmSubmittedTransactionOptions = {\n /**\n * Number of attempts to confirm the transaction.\n * Defaults to 20.\n */\n attempts?: number\n /**\n * Delay in milliseconds between confirmation attempts.\n * Defaults to 1000 (1 second).\n */\n delay?: number\n /**\n * Optional logger instance for logging progress.\n */\n logger?: Logger\n}\n\n/**\n * Confirms a submitted transaction by checking if it has been included in the blockchain.\n * @param viewer The viewer\n * @param transaction The transaction to confirm\n * @param options Options for confirmation\n * @returns The confirmed transaction or throws an error if not confirmed\n */\nexport const confirmSubmittedTransaction = async (\n viewer: XyoViewer,\n transaction: Signed<TransactionBoundWitness>,\n options?: ConfirmSubmittedTransactionOptions,\n): Promise<SignedHydratedTransaction> => {\n const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {}\n const txBWHash = await PayloadBuilder.hash(transaction)\n options?.logger?.log('🚀 confirming transaction:', txBWHash, '\\n')\n let attempts = 0\n while (true) {\n const tx = await viewer.transactionByHash(txBWHash) ?? undefined\n if (isDefined(tx)) {\n options?.logger?.log('✅ Transaction confirmed:', txBWHash, '\\n')\n return tx\n } else {\n attempts++\n if (attempts > maxAttempts) {\n options?.logger?.error(`⚠️ Transaction not confirmed after ${maxAttempts} attempts`)\n throw new Error(`Transaction ${txBWHash} not confirmed after ${maxAttempts} attempts`)\n } else {\n options?.logger?.log(`🔄 Transaction not confirmed yet, attempt ${attempts}. Retrying...`, '\\n')\n await delay(attemptDelay)\n }\n }\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\nimport { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from '@xyo-network/archivist-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n SignedHydratedTransaction, SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness,\n} from '@xyo-network/xl1-protocol'\nimport { isAllowedBlockPayload, isSignedTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'\n\nexport const tryHydrateTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {\n return (await tryHydrateTypedBoundWitness<TransactionBoundWitness>(\n archivist,\n hash,\n isSignedTransactionBoundWitnessWithStorageMeta,\n )) as SignedHydratedTransactionWithStorageMeta | undefined\n}\n\nexport const hydrateTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransaction> => {\n return await hydrateTypedBoundWitness<TransactionBoundWitness>(\n archivist,\n hash,\n isSignedTransactionBoundWitnessWithStorageMeta,\n ) as SignedHydratedTransaction\n}\n\nexport const flattenHydratedTransaction = (hydratedTransaction: SignedHydratedTransaction): Payload[] => {\n const [tx, txPayloads] = hydratedTransaction\n return [...txPayloads, tx]\n}\n\nexport const flattenHydratedTransactions = (hydratedTransactions: SignedHydratedTransaction[]): Payload[] =>\n hydratedTransactions.flatMap(tx => flattenHydratedTransaction(tx))\n\nexport const tryHydrateElevatedTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {\n const hydratedTransaction = await tryHydrateTransaction(archivist, hash)\n if (!hydratedTransaction) {\n return undefined\n }\n const [transaction, payloads] = hydratedTransaction\n const opCodes = (transaction.script ?? []).filter(operation => operation.startsWith('elevate|'))\n const elevatedPayloads: WithStorageMeta<AllowedBlockPayload>[] = []\n for (const opCode of opCodes) {\n const [code, hash] = opCode.split('|')\n if (code === 'elevated') {\n const elevatedPayload = payloads.find(payload => payload._hash === hash)\n if (isAllowedBlockPayload(elevatedPayload)) {\n elevatedPayloads.push(elevatedPayload)\n }\n }\n }\n if (opCodes.length === elevatedPayloads.length) {\n return [transaction, elevatedPayloads]\n }\n return undefined\n}\n\nexport const hydrateElevatedTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransaction> => {\n return assertEx(await tryHydrateElevatedTransaction(archivist, hash), () => 'Hydration failed')\n}\n","import { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'\n\n/** The number of bytes that a transaction and its payloads will take up in a block */\nexport function transactionBlockByteCount([transaction, payloads]: SignedHydratedTransaction): number {\n const cleanTransaction = PayloadBuilder.omitStorageMeta(transaction)\n const transactionBytes = JSON.stringify(cleanTransaction).length\n const cleanPayloads = PayloadBuilder.omitStorageMeta(payloads)\n return cleanPayloads.reduce((acc: number, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes\n}\n","import { asHash, type Hash } from '@xylabs/hex'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\nimport type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\nimport { crackOperations } from './transactionOperations.ts'\n\nexport function transactionElevatedPayloadHashes(transaction: TransactionBoundWitness): Hash[] {\n const elevateOperations = crackOperations(transaction.script ?? []).filter(op => op[0] === 'elevate')\n return elevateOperations.map(op => asHash(op[1][0], true))\n}\n\nexport function transactionElevatedPayloads([transaction, payloads]: SignedHydratedTransactionWithStorageMeta): WithHashStorageMeta<Payload>[] {\n const hashes = transactionElevatedPayloadHashes(transaction)\n const elevatedPayloads = payloads.filter(payload => hashes.includes(payload._hash))\n return elevatedPayloads\n}\n","export function crackOperation(operation: string): [string, string[]] {\n const parts = operation.split('|')\n if (parts.length < 2) {\n throw new Error(`Invalid operation format: ${operation}`)\n }\n return [parts[0], parts.slice(1)]\n}\n\nexport function crackOperations(operations: string[]): [string, string[]][] {\n return operations.map(op => crackOperation(op))\n}\n","import type { SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'\nimport { AttoXL1, TransactionGasCosts } from '@xyo-network/xl1-protocol'\n\nimport { transactionBlockByteCount } from './transactionBlockByteCount.ts'\nimport { transactionElevatedPayloads } from './transactionElevatedPayloads.ts'\n\n/** The required gas for the byte storage on the block chain for a transaction */\nexport function transactionBytesRequiredGas([transaction, payloads]: SignedHydratedTransactionWithStorageMeta): AttoXL1 {\n const transactionBlockBytes = transactionBlockByteCount([transaction, payloads])\n return AttoXL1(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes))\n}\n\nexport function transactionRequiredGas(hydratedTransaction: SignedHydratedTransactionWithStorageMeta): AttoXL1 {\n const elevatedPayloads = transactionElevatedPayloads(hydratedTransaction)\n const hashes = elevatedPayloads.length + 1 /* for transaction itself */\n const signatures = hydratedTransaction[0].addresses.length\n return AttoXL1(transactionBytesRequiredGas(hydratedTransaction)\n + TransactionGasCosts.hashValidation * BigInt(hashes)\n + TransactionGasCosts.signatureValidation * BigInt(signatures)\n + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads.length))\n}\n","import { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { asHash, type Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type { AllowedBlockPayload, HydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'\nimport { isAllowedBlockPayloadWithHashStorageMeta } from '@xyo-network/xl1-protocol'\n\nexport const tryExtractElevatedHashesFromScript = (strings: string[]): Hash[] => {\n const hashes = strings\n .filter(str => str.startsWith('elevate|'))\n .map(str => str.split('|')[1])\n return filterAs(hashes, h => asHash(h))\n}\n\nexport const extractElevatedHashesFromScript = (strings: string[]): Hash[] => {\n const hashes = strings\n .filter(str => str.startsWith('elevate|'))\n .map(str => str.split('|')[1])\n const filtered = filterAs(hashes, h => asHash(h))\n assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')\n return filtered\n}\n\nexport const tryExtractElevatedHashes = (tx: HydratedTransactionWithStorageMeta): WithStorageMeta<AllowedBlockPayload>[] => {\n const [bw, payloads] = tx\n const { script } = bw\n const hashes = script ? tryExtractElevatedHashesFromScript(script) : []\n return payloads\n .filter(p => hashes.includes(p._hash))\n .filter(isAllowedBlockPayloadWithHashStorageMeta)\n}\n\nexport const extractElevatedHashes = (tx: HydratedTransactionWithStorageMeta): WithStorageMeta<AllowedBlockPayload>[] => {\n const [bw, payloads] = tx\n const { script } = bw\n const hashes = script ? tryExtractElevatedHashesFromScript(script) : []\n const filtered = payloads\n .filter(p => hashes.includes(p._hash))\n .filter(isAllowedBlockPayloadWithHashStorageMeta)\n assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')\n return filtered\n}\n","import { toArrayBuffer } from '@xylabs/arraybuffer'\nimport { assertEx } from '@xylabs/assert'\nimport { hexFromArrayBuffer } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { TransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\nexport async function signTransaction(tx: TransactionBoundWitness, account: AccountInstance) {\n assertEx(tx.from === account.address, () => 'Signer address does not match transaction from address')\n const signedTx = structuredClone(tx)\n signedTx.addresses = [account.address]\n signedTx.previous_hashes = [account.previousHash ?? null]\n const hash = await PayloadBuilder.hash(signedTx)\n const hashBytes = toArrayBuffer(hash)\n const [signature] = await account.sign(hashBytes)\n signedTx.$signatures = [hexFromArrayBuffer(signature)]\n return signedTx\n}\n","import { HDWallet } from '@xyo-network/wallet'\n\nimport { DEFAULT_WALLET_PATH } from './paths.ts'\n\n/**\n * Initializes a wallet to the default XYO path from a mnemonic phrase\n * @param walletPhrase The mnemonic phrase for the wallet\n * @returns A wallet initialized to the default XYO path using the provided phrase\n */\nexport const generateXyoBaseWalletFromPhrase = (walletPhrase: string) => {\n const wallet = HDWallet.fromPhrase(walletPhrase, DEFAULT_WALLET_PATH)\n return wallet\n}\n","export const WALLET_COMPLIANCE = '44\\'' as const\n\nexport const COIN_TYPES = { Ethereum: '60\\'' } as const\n\nexport const ACCOUNT_TYPE = { GANACHE: '0\\'', XYO: '0\\'' } as const\n\nexport const CHANGE_ADDRESS = { META_MASK: '0', XYO: '0' } as const\n\nexport const ADDRESS_INDEX = { META_MASK: '0', XYO: '0' } as const\n\nexport const DEFAULT_WALLET_PATH = `m/${WALLET_COMPLIANCE}/${COIN_TYPES.Ethereum}/${ACCOUNT_TYPE.XYO}/${CHANGE_ADDRESS.XYO}`\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AAKzB;AAAA,EACE;AAAA,EAA0C;AAAA,EAAoC;AAAA,OACzE;AAEA,SAAS,iBAAiB,QAAgB,UAA+C;AAC9F,QAAM,gBAAgB,IAAI,IAAI,SAAS,IAAI,OAAK,EAAE,KAAK,CAAC;AACxD,SAAO,OAAO,MAAM,UAAQ,cAAc,IAAI,IAAI,CAAC;AACrD;AAEO,IAAM,kBAAkB,OAC7B,WACA,MACA,WAAmB,MACoB;AACvC,WAAS,YAAY,GAAG,MAAM,6CAA6C;AAC3E,QAAM,MAAM,MAAM,UAAU,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,kCAAkC;AAChF,MAAI,CAAC,GAAI,QAAO;AAChB,MAAI,aAAa,EAAG,QAAO,CAAC,IAAI,CAAC,CAAC;AAClC,QAAM,cAAc,MAAM,UAAU,IAAI,GAAG,cAAc;AACzD,MAAI,aAAa,EAAG,QAAO,CAAC,IAAI,WAAW;AAC3C,QAAM,eAAe,YAAY,OAAO,wCAAwC;AAChF,QAAM,4BAA4B,aAAa,QAAQ,QAAM,GAAG,cAAc;AAC9E,QAAM,uBAAuB,MAAM,UAAU,IAAI,yBAAyB;AAC1E,QAAM,oBAAoB,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,oBAAoB,EAAE,QAAQ,OAAK,EAAE,KAAK,CAAC;AACjG,QAAM,cAAc,MAAM,UAAU,IAAI,CAAC,GAAG,iBAAiB,CAAC;AAC9D,QAAM,sBAAsB,YAAY,OAAO,OAAK,kBAAkB,IAAI,EAAE,KAAK,CA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K,KAAM;AAElD,IAAM,iBAAiB,EAAE,WAAW,KAAK,KAAK,IAAI;AAElD,IAAM,gBAAgB,EAAE,WAAW,KAAK,KAAK,IAAI;AAEjD,IAAM,sBAAsB,KAAK,iBAAiB,IAAI,WAAW,QAAQ,IAAI,aAAa,GAAG,IAAI,eAAe,GAAG;;;ADDnH,IAAM,kCAAkC,CAAC,iBAAyB;AACvE,QAAM,SAAS,SAAS,WAAW,cAAc,mBAAmB;AACpE,SAAO;AACT;","names":["assertEx","StepSizes","hexToBigInt","range","StepSizes","stepSize","StepSizes","assertEx","asBlockBoundWitnessWithStorageMeta","asBlockBoundWitnessWithStorageMeta","z","z","z","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","globalRegistry","isDefined","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","globalRegistry","z","z","assertEx","toHex","PayloadBuilder","toHex","BoundWitnessBuilder","PayloadBuilder","defaultTransactionFees","isDefined","PayloadBuilder","assertEx","hash","PayloadBuilder","asHash","asHash","filterAs","assertEx","asHash","assertEx","PayloadBuilder"]}
|
|
1
|
+
{"version":3,"sources":["../../src/block/hydrateBlock.ts","../../src/block/primitives/balanceStepSummaryFromRange.ts","../../src/payload/netBalancesForPayloads.ts","../../src/SignedBigInt.ts","../../src/block/primitives/frames/calculateFramesFromRange.ts","../../src/block/primitives/frames/deepCalculateFramesFromRange.ts","../../src/block/primitives/hashFromBlockNumber.ts","../../src/block/primitives/payloads.ts","../../src/block/primitives/balanceSummary.ts","../../src/config/Config.ts","../../src/config/Api.ts","../../src/validation/lib/isLocalhost.ts","../../src/validation/lib/getUrl.ts","../../src/validation/schema/Address.ts","../../src/validation/schema/Mnemonic.ts","../../src/config/App.ts","../../src/config/Chain.ts","../../src/config/Evm.ts","../../src/config/Log.ts","../../src/config/Producer.ts","../../src/config/storage/driver/Mongo.ts","../../src/config/storage/Storage.ts","../../src/config/Telemetry.ts","../../src/config/UsageMeta.ts","../../src/transaction/buildTransaction.ts","../../src/transaction/buildUnsignedTransaction.ts","../../src/transaction/confirmSubmittedTransaction.ts","../../src/transaction/hydrateTransaction.ts","../../src/transaction/primitives/transactionBlockByteCount.ts","../../src/transaction/primitives/transactionElevatedPayloads.ts","../../src/transaction/primitives/transactionOperations.ts","../../src/transaction/primitives/transactionRequiredGas.ts","../../src/transaction/script.ts","../../src/transaction/signTransaction.ts","../../src/wallet/generateXyoBaseWalletFromPhrase.ts","../../src/wallet/paths.ts"],"sourcesContent":["import { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport type { HydratedBlock, TransactionBoundWitness } from '@xyo-network/xl1-protocol'\nimport {\n asTransactionBoundWitnessWithStorageMeta, isBlockBoundWitnessWithStorageMeta, isTransactionBoundWitnessWithStorageMeta,\n} from '@xyo-network/xl1-protocol'\n\nexport function allHashesPresent(hashes: Hash[], payloads: WithStorageMeta<Payload>[]): boolean {\n const payloadHashes = new Set(payloads.map(p => p._hash))\n return hashes.every(hash => payloadHashes.has(hash))\n}\n\nexport const tryHydrateBlock = async (\n archivist: ReadArchivist,\n hash: Hash,\n maxDepth: number = 1,\n): Promise<HydratedBlock | undefined> => {\n assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')\n const bw = (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta)\n if (!bw) return undefined\n if (maxDepth === 0) return [bw, []]\n const blkPayloads = await archivist.get(bw.payload_hashes)\n if (maxDepth === 1) return [bw, blkPayloads]\n const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)\n const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)\n const transactionsPayloads = await archivist.get(transactionsPayloadHashes)\n const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))\n const allPayloads = await archivist.get([...allPayloadsHashes])\n const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))\n return [bw, allPayloadsFiltered]\n}\n\nexport const hydrateBlock = async (\n archivist: ReadArchivist,\n hash: Hash,\n maxDepth: number = 1,\n minDepth = maxDepth,\n): Promise<HydratedBlock> => {\n assertEx(maxDepth >= 0, () => 'maxDepth must be greater than or equal to 0')\n assertEx(minDepth >= 0, () => 'minDepth must be greater than or equal to 0')\n assertEx(maxDepth >= minDepth, () => 'maxDepth must be greater than or equal to minDepth')\n const bw = assertEx(\n (await archivist.get([hash])).find(isBlockBoundWitnessWithStorageMeta),\n () => `block ${hash} not found`,\n )\n if (maxDepth === 0) return [bw, []]\n const blkPayloads = await archivist.get(bw.payload_hashes)\n if (minDepth === 1) assertEx(allHashesPresent(bw.payload_hashes, blkPayloads), () => `Unable to find all payloads for block ${hash}`)\n if (maxDepth === 1) return [bw, blkPayloads]\n const transactions = blkPayloads.filter(isTransactionBoundWitnessWithStorageMeta)\n const transactionsPayloadHashes = transactions.flatMap(tx => tx.payload_hashes)\n const transactionsPayloads = await archivist.get(transactionsPayloadHashes)\n assertEx(allHashesPresent(transactionsPayloadHashes, transactionsPayloads), () => `Unable to find all payloads for transactions in block ${hash}`)\n const allPayloadsHashes = new Set([...blkPayloads, ...transactionsPayloads].flatMap(p => p._hash))\n const allPayloads = await archivist.get([...allPayloadsHashes])\n const allPayloadsFiltered = allPayloads.filter(p => allPayloadsHashes.has(p._hash))\n if (maxDepth === 2) assertEx(allHashesPresent(\n [...allPayloadsHashes],\n allPayloadsFiltered,\n ), () => `Unable to find all payloads for transactions in block ${hash}`)\n return [bw, allPayloadsFiltered]\n}\n\nexport const flattenHydratedBlock = (hydratedBlock: HydratedBlock): WithStorageMeta<Payload>[] => {\n const [blk, blkPayloads] = hydratedBlock\n return [...blkPayloads, blk]\n}\n\nexport const flattenHydratedBlocks = (hydratedBlocks: HydratedBlock[]): WithStorageMeta<Payload>[] =>\n hydratedBlocks.flatMap(blk => flattenHydratedBlock(blk))\n\nexport const transactionsFromHydratedBlock = (block: HydratedBlock): WithStorageMeta<TransactionBoundWitness>[] => {\n return filterAs(block[1], asTransactionBoundWitnessWithStorageMeta)\n}\n\nexport const blockPayloadsFromHydratedBlock = (block: HydratedBlock): WithStorageMeta<Payload>[] => {\n return block[0].payload_hashes.map(hash => assertEx(\n block[1].find(p => p._hash === hash),\n () => `missing payload ${hash}`,\n )).filter(x => !isTransactionBoundWitnessWithStorageMeta(x))\n}\n","import { assertEx } from '@xylabs/assert'\nimport { type Address } from '@xylabs/hex'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport { isAnyPayload } from '@xyo-network/payload-model'\nimport { StepSizes } from '@xyo-network/xl1-protocol'\n\nimport { netBalancesForPayloads } from '../../payload/index.ts'\nimport {\n parseSignedBigInt, type SignedBigInt, toSignedBigInt,\n} from '../../SignedBigInt.ts'\nimport { hydrateBlock } from '../hydrateBlock.ts'\nimport type { BlockNumberRange } from './frames/index.ts'\nimport { deepCalculateFramesFromRange } from './frames/index.ts'\nimport { hashFromBlockNumber } from './hashFromBlockNumber.ts'\nimport type { BalanceStepSummaryContext } from './model.ts'\nimport { type BalancesStepSummary, BalancesStepSummarySchema } from './payloads.ts'\n\nexport async function balanceStepSummaryFromRange(\n context: BalanceStepSummaryContext,\n range: BlockNumberRange,\n): Promise<WithStorageMeta<BalancesStepSummary>> {\n // console.log(`balanceStepSummaryFromRange: head=${head}, range=${range[0]}-${range[1]}`)\n const frameHeadHash = await hashFromBlockNumber(context, range[1])\n const frameSize = range[1] - range[0] + 1\n\n let result: BalancesStepSummary | undefined = undefined\n\n if (frameSize === 1) {\n const hash = await hashFromBlockNumber(context, range[0])\n const [, payloads] = await hydrateBlock(context.chainArchivist, hash)\n const balances: Record<Address, SignedBigInt> = {}\n for (const [address, balance] of Object.entries(netBalancesForPayloads(payloads))) {\n balances[address as Address] = toSignedBigInt(balance)\n }\n result = {\n schema: BalancesStepSummarySchema, hash: context.head, stepSize: -1, balances,\n }\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const step = (StepSizes as any).indexOf(frameSize)\n assertEx(step !== -1, () => `Invalid step size: ${frameSize}. Must be one of ${StepSizes.join(', ')}`)\n\n const [summaryResult] = await context.summaryRepository.get([frameHeadHash])\n if (isAnyPayload(summaryResult)) {\n result = summaryResult as WithStorageMeta<BalancesStepSummary>\n } else {\n // We do not have it, so lets build it\n const subRanges = deepCalculateFramesFromRange(range, step - 1)\n const promises = subRanges.map(subRange => balanceStepSummaryFromRange(\n context,\n subRange,\n ))\n const subResults = await Promise.all(promises)\n\n // add them all up\n const bigIntBalances: Record<Address, bigint> = {}\n for (const subResult of subResults) {\n for (const [address, balance] of Object.entries(subResult.balances)) {\n bigIntBalances[address as Address] = (bigIntBalances[address as Address] ?? 0n) + parseSignedBigInt(balance)\n }\n }\n\n const balances: Record<Address, SignedBigInt> = {}\n for (const [address, balance] of Object.entries(bigIntBalances)) {\n balances[address as Address] = toSignedBigInt(balance)\n }\n\n result = {\n schema: BalancesStepSummarySchema, hash: frameHeadHash, stepSize: frameSize, balances,\n }\n\n await context.summaryRepository.insert([result])\n }\n }\n // console.log(`balanceStepSummaryFromRange-result: head=${head}, range=${range[0]}-${range[1]}: ${toSafeJsonString(result, 10)}`)\n const finalResult = await PayloadBuilder.addStorageMeta(result)\n return finalResult\n}\n","import {\n type Address, type Hex, hexToBigInt, toAddress,\n} from '@xylabs/hex'\nimport type { Payload } from '@xyo-network/payload-model'\nimport { isTransfer } from '@xyo-network/xl1-protocol'\n\nexport const netBalancesForPayloads = (payloads: Payload[]) => {\n const balances: Record<Address, bigint> = {}\n for (const payload of payloads) {\n if (isTransfer(payload)) {\n const { from } = payload\n for (let [address, amount] of Object.entries(payload.transfers) as [Address, Hex][]) {\n balances[toAddress(address)] = (balances[toAddress(address)] ?? 0n) + hexToBigInt(amount)\n balances[toAddress(from)] = (balances[toAddress(from)] ?? 0n) - hexToBigInt(amount)\n }\n }\n }\n return balances\n}\n","import {\n type Hex,\n hexToBigInt,\n toHex,\n} from '@xylabs/hex'\nimport { isObject } from '@xylabs/object'\n\nexport interface NegativeBigInt {\n negative: Hex\n}\n\nexport interface PositiveBigInt {\n positive: Hex\n}\n\nexport type SignedBigInt = NegativeBigInt | PositiveBigInt\n\nexport const isNegativeBigInt = (value: unknown): value is NegativeBigInt => {\n return isObject(value) && 'negative' in value && typeof value.negative === 'string'\n}\n\nexport const isPositiveBigInt = (value: unknown): value is PositiveBigInt => {\n return isObject(value) && 'positive' in value && typeof value.positive === 'string'\n}\n\nexport const parseSignedBigInt = (value: SignedBigInt): bigint => {\n if (isNegativeBigInt(value)) {\n return -hexToBigInt(value.negative)\n } else if (isPositiveBigInt(value)) {\n return hexToBigInt(value.positive)\n } else {\n throw new Error('Invalid balance type')\n }\n}\n\nexport const toSignedBigInt = (value: bigint): SignedBigInt => {\n return value < 0n ? { negative: toHex(-value) } : { positive: toHex(value) }\n}\n\nexport const toPositiveBigInt = (value: unknown): PositiveBigInt => {\n if (isNegativeBigInt(value)) {\n return { positive: toHex(0n) }\n }\n if (isPositiveBigInt(value)) {\n return { positive: value.positive }\n }\n if (typeof value === 'bigint') {\n return { positive: toHex(value) }\n }\n throw new Error('Invalid value for positive big int')\n}\n","import { stepSize } from '@xyo-network/xl1-protocol'\n\nimport type { BlockNumberRange } from './BlockNumberRange.ts'\n\nexport function calculateFramesFromRange(range: BlockNumberRange, step: number): [\n // ranges of fitted frames\n BlockNumberRange[],\n // ranges of remaining blocks\n BlockNumberRange[]] {\n const size = stepSize(step)\n let start = (Math.trunc(range[0] / size)) * size\n const fitted: BlockNumberRange[] = []\n const remaining: BlockNumberRange[] = []\n\n // if the start is not aligned with the range, add a remaining block\n if (start !== range[0]) {\n start += size\n remaining.push([range[0], Math.min(start - 1, range[1])])\n }\n\n for (let i = start; i <= range[1]; i += size) {\n if ((i + size - 1) <= range[1]) {\n fitted.push([i, Math.min(i + size - 1, range[1])])\n } else {\n remaining.push([i, range[1]])\n }\n }\n return [fitted, remaining]\n}\n","import { StepSizes } from '@xyo-network/xl1-protocol'\n\nimport type { BlockNumberRange } from './BlockNumberRange.ts'\nimport { calculateFramesFromRange } from './calculateFramesFromRange.ts'\n\nexport function deepCalculateFramesFromRange(range: BlockNumberRange, startingStep = StepSizes.length - 1): BlockNumberRange[] {\n const fitted: BlockNumberRange[] = []\n let remaining: BlockNumberRange[] = [range]\n\n for (let step = startingStep; step >= 0; step--) {\n const newRemaining: BlockNumberRange[] = []\n for (const range of remaining) {\n const [newFittedFrames, newRemainingFrames] = calculateFramesFromRange(range, step)\n fitted.push(...newFittedFrames)\n newRemaining.push(...newRemainingFrames)\n }\n remaining = newRemaining\n }\n\n for (const range of remaining) {\n for (let i = range[0]; i <= range[1]; i++) {\n fitted.push([i, i]) // Add individual frames for remaining ranges\n }\n }\n\n return fitted.toSorted((a, b) => a[0] - b[0]) // Sort by start of range\n}\n","import { asHash, type Hash } from '@xylabs/hex'\nimport { toSafeJsonString } from '@xylabs/object'\nimport { asBlockBoundWitnessWithStorageMeta, StepSizes } from '@xyo-network/xl1-protocol'\n\nimport type { ChainContext } from './model.ts'\n\nexport async function hashFromBlockNumber(context: ChainContext, blockNumber: number): Promise<Hash> {\n const result = await context.chainArchivist.get([context.head])\n let currentBlock = asBlockBoundWitnessWithStorageMeta(result.at(0), () => `Head block not found for hash: ${context.head}`, { required: true })\n while (currentBlock.block > blockNumber) {\n let jumpHash: Hash | null = currentBlock.previous\n let jumpBlockNumber = currentBlock.block - 1\n for (const [step, stepSize] of StepSizes.entries()) {\n const possibleJumpBlockNumber = currentBlock.block - stepSize\n if (possibleJumpBlockNumber >= blockNumber && possibleJumpBlockNumber <= jumpBlockNumber) {\n jumpBlockNumber = possibleJumpBlockNumber\n jumpHash = asHash(currentBlock.step_hashes.at(step), () => `Step hash not found for step ${step} in block ${currentBlock.block}`)\n }\n }\n const [newBlock] = await context.chainArchivist.get([\n asHash(jumpHash, () => `Jump hash not found for block number [${blockNumber}]: ${jumpBlockNumber} ${toSafeJsonString(currentBlock, 10)}`)])\n currentBlock = asBlockBoundWitnessWithStorageMeta(newBlock, () => `Block not found for hash: ${jumpHash}`, { required: true })\n if (currentBlock.block === blockNumber) {\n break\n }\n if (currentBlock.block < blockNumber) {\n throw new Error(`Block number ${blockNumber} is not a valid step block number for block ${context.head}.`)\n }\n }\n return currentBlock._hash\n}\n","import type { Address, Hash } from '@xylabs/hex'\nimport type { EmptyObject } from '@xylabs/object'\nimport { AsObjectFactory } from '@xylabs/object'\nimport type {\n Payload, Schema, WithStorageMeta,\n} from '@xyo-network/payload-model'\nimport { isPayloadOfSchemaType, isStorageMeta } from '@xyo-network/payload-model'\n\nimport type { SignedBigInt } from '../../SignedBigInt.ts'\n\nexport const StepSummarySchema: Schema = 'network.xyo.step.summary'\nexport type StepSummarySchema = typeof StepSummarySchema\n\nexport interface StepSummaryFields {\n hash: Hash // the stepHash - the hash of the last block in the step frame\n stepSize: number // the stepSize in blocks\n}\n\nexport interface ChainWindow {\n depth: number // number of blocks the window covers, including the head\n head: Hash // the head of the chain\n}\n\nexport type StepSummary<TAdditionalFields extends EmptyObject | void = void,\n TSchema extends Schema | void = void> = Payload<TAdditionalFields extends void ? StepSummaryFields : TAdditionalFields & StepSummaryFields,\n TSchema extends void ? StepSummarySchema : TSchema>\n\nexport const BalancesStepSummarySchema: Schema = 'network.xyo.step.summary.balances'\nexport type BalancesStepSummarySchema = typeof BalancesStepSummarySchema\n\nexport type BalancesStepSummary = StepSummary<{\n balances: Record<Address, SignedBigInt>\n}, BalancesStepSummarySchema>\n\n/**\n * Identity function for determining if an object is an BalancesStepSummary\n */\nexport const isBalancesStepSummary = isPayloadOfSchemaType<BalancesStepSummary>(BalancesStepSummarySchema)\nexport const asBalancesStepSummary = AsObjectFactory.create<BalancesStepSummary>(isBalancesStepSummary)\n\n/**\n * Identity function for determining if an object is an BalancesStepSummary with Storage Meta\n */\nexport const isBalancesStepSummaryWithStorageMeta = (value: unknown): value is WithStorageMeta<BalancesStepSummary> => {\n return isBalancesStepSummary(value) && isStorageMeta(value)\n}\nexport const asBalancesStepSummaryWithStorageMeta = AsObjectFactory.create<WithStorageMeta<BalancesStepSummary>>(isBalancesStepSummaryWithStorageMeta)\n","import type { Address } from '@xylabs/hex'\nimport { asAddress } from '@xylabs/hex'\nimport { isDefined } from '@xylabs/typeof'\nimport { asBlockBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'\n\nimport { parseSignedBigInt } from '../../SignedBigInt.ts'\nimport { balanceStepSummaryFromRange } from './balanceStepSummaryFromRange.ts'\nimport { deepCalculateFramesFromRange } from './frames/index.ts'\nimport type { BalanceStepSummaryContext } from './model.ts'\n\nexport async function balanceSummary(\n context: BalanceStepSummaryContext,\n): Promise<Partial<Record<Address, bigint>>> {\n const headResult = await context.chainArchivist.get([context.head])\n const headBoundWitness = asBlockBoundWitnessWithStorageMeta(headResult.at(0), () => `Head block not found for hash: ${context.head}`, { required: true })\n const rangeStart = isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0\n const ranges = deepCalculateFramesFromRange([rangeStart, headBoundWitness.block])\n const summaries = await Promise.all(ranges.map(range => balanceStepSummaryFromRange(context, range)))\n const balances: Partial<Record<Address, bigint>> = {}\n for (let summary of summaries) {\n for (const [address, balance] of Object.entries(summary.balances)) {\n const validAddress = asAddress(address, () => `Invalid address: ${address}`)\n balances[validAddress] = (balances[validAddress] ?? 0n) + parseSignedBigInt(balance)\n }\n }\n return balances\n}\n","import z from 'zod'\n\nimport { ApiConfigZod } from './Api.ts'\nimport { AppConfigZod } from './App.ts'\nimport { ChainConfigZod } from './Chain.ts'\nimport { EvmConfigZod } from './Evm.ts'\nimport { LogConfigZod } from './Log.ts'\nimport { ProducerConfigZod } from './Producer.ts'\nimport { StorageConfigZod } from './storage/index.ts'\nimport { TelemetryConfigZod } from './Telemetry.ts'\n\nexport const Xl1CommonConfigSchema = z.object({ ...LogConfigZod.shape }).describe('XL1 common configuration options')\n\nexport const ConfigZod = z.object({\n ...Xl1CommonConfigSchema.shape,\n api: ApiConfigZod.default(ApiConfigZod.parse({})).describe('Configuration for the API node'),\n app: AppConfigZod.default(AppConfigZod.parse({})).describe('Configuration for the application'),\n chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe('Configuration for the chain'),\n evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe('Configuration for EVM-backed services'),\n producer: ProducerConfigZod.default(ProducerConfigZod.parse({})).describe('Configuration for the producer'),\n storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe('Configuration for the storage'),\n telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe('Configuration for telemetry'),\n})\n\nexport type Config = z.infer<typeof ConfigZod>\n\nexport const getDefaultConfig = (): Config => ConfigZod.parse({})\n","import z, { globalRegistry } from 'zod'\n\nimport { MnemonicStringZod } from '../validation/index.ts'\n\nexport const ApiConfigZod = z.object({\n host: z.string().default('localhost').register(globalRegistry, {\n default: 'localhost',\n description: 'Host for the API',\n title: 'api.host',\n type: 'string',\n }),\n mnemonic: MnemonicStringZod.optional().register(globalRegistry, {\n description: 'Mnemonic for the API wallet',\n title: 'api.mnemonic',\n type: 'string',\n }),\n port: z.coerce.number().default(8080).register(globalRegistry, {\n default: 8080,\n description: 'Port for the API',\n title: 'api.port',\n type: 'number',\n }),\n})\n\nexport type ApiConfig = z.infer<typeof ApiConfigZod>\n","export const isLocalhost = (hostname: string): boolean => {\n return (\n hostname === 'localhost'\n || hostname === '127.0.0.1'\n || hostname === '::1' // IPv6 localhost\n || hostname.endsWith('.localhost')\n )\n}\n","import { isLocalhost } from './isLocalhost.ts'\n\nexport const getUrl = (host: string, port: number): string => {\n const scheme = isLocalhost(host) ? 'http' : 'https'\n return `${scheme}://${host}:${port}`\n}\n","export const TODO = true\n","import { z } from 'zod'\n\n/**\n * Validates a single string containing a BIP-39 mnemonic.\n *\n * • Trims leading/trailing whitespace.\n * • Collapses any run of whitespace (spaces, tabs, new-lines) to a single space.\n * • Splits on spaces → array of words.\n * • Checks that the word-count is 12, 15, 18, 21, or 24.\n *\n */\nexport const MnemonicStringZod = z\n .string()\n .transform(s => s.trim().replaceAll(/\\s+/g, ' ')) // normalize spacing\n .refine(\n s => [12, 15, 18, 21, 24].includes(s.split(' ').length),\n { message: 'Mnemonic must contain 12, 15, 18, 21, or 24 words.' },\n ).describe('BIP-39 mnemonic string')\n\nexport type MnemonicString = z.infer<typeof MnemonicStringZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const AppConfigZod = z.object({\n port: z.coerce.number().default(3000).register(globalRegistry, {\n default: 3000,\n description: 'Port for the application',\n title: 'app.port',\n type: 'number',\n }),\n})\n\nexport type AppConfig = z.infer<typeof AppConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const ChainConfigZod = z.object({\n id: z.string().optional()\n .register(globalRegistry, {\n description:\n 'The unique identifier for the chain. Should be the staking contract address for contract-backed chains.',\n title: 'chain.id',\n type: 'string',\n }),\n})\n\nexport type ChainConfig = z.infer<typeof ChainConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const EvmInfuraConfigZod = z.object({\n projectId: z.string().optional().register(globalRegistry, {\n description: 'Infura project ID',\n title: 'evm.infura.projectId',\n type: 'string',\n }),\n projectSecret: z.string().optional().register(globalRegistry, {\n description: 'Infura project secret',\n title: 'evm.infura.projectSecret',\n type: 'string',\n }),\n})\n\nexport const EvmJsonRpcConfigZod = z.object({\n url: z.url().optional().register(globalRegistry, {\n description: 'JSON-RPC URL',\n title: 'evm.jsonRpc.url',\n type: 'string',\n }),\n})\n\nexport const EvmConfigZod = z.object({\n chainId: z.string().optional().register(globalRegistry, {\n description: 'EVM chain ID',\n title: 'evm.chainId',\n type: 'string',\n }),\n infura: EvmInfuraConfigZod.optional().describe('Infura Provider configuration'),\n jsonRpc: EvmJsonRpcConfigZod.optional().describe('JSON-RPC Provider configuration'),\n})\n\nexport type EvmConfig = z.infer<typeof EvmConfigZod>\n","import type { LogLevelKey } from '@xylabs/logger'\nimport { LogLevel } from '@xylabs/logger'\nimport z, { globalRegistry } from 'zod'\nconst LogLevels = Object.keys(LogLevel) as [LogLevelKey, ...LogLevelKey[]]\n\nexport const LogConfigZod = z.object({\n logLevel: z.enum(LogLevels).default('info').register(globalRegistry, {\n choices: LogLevels,\n default: 'info',\n description: 'Desired process verbosity',\n title: 'logLevel',\n type: 'string',\n }),\n silent: z.boolean().default(false).register(globalRegistry, {\n default: false,\n description: 'Whether to run in silent mode',\n title: 'silent',\n type: 'boolean',\n }),\n})\n\nexport type LogConfig = z.infer<typeof LogConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nimport { MnemonicStringZod } from '../validation/index.ts'\n\nexport const ProducerConfigZod = z.object({\n disableIntentRedeclaration: z.boolean().optional().register(globalRegistry, {\n description: 'Should the producer skip redeclaring their intent to continue producing blocks',\n title: 'producer.disableIntentRedeclaration',\n type: 'boolean',\n }),\n // TODO: Port schema\n healthCheckPort: z.coerce.number().optional().register(globalRegistry, {\n description: 'Port for the Producer health checks',\n title: 'producer.healthCheckPort',\n type: 'number',\n }),\n // TODO: BigInt schema\n minStake: z.coerce.number().default(1).register(globalRegistry, {\n description: 'Minimum stake required to be a Producer',\n title: 'producer.minStake',\n type: 'number',\n }),\n mnemonic: MnemonicStringZod.optional().register(globalRegistry, {\n description: 'Mnemonic for the Producer wallet',\n title: 'producer.mnemonic',\n type: 'string',\n }),\n // TODO: Port schema\n port: z.coerce.number().default(8081).register(globalRegistry, {\n default: 8081,\n description: 'Port for the Producer',\n title: 'producer.port',\n type: 'number',\n }),\n // TODO: Address schema\n rewardAddress: z.string().optional().register(globalRegistry, {\n description: 'Address to receive block rewards',\n title: 'producer.rewardAddress',\n type: 'string',\n }),\n})\n\nexport type ProducerConfig = z.infer<typeof ProducerConfigZod>\n","import { isDefined, isUndefined } from '@xylabs/typeof'\nimport z, { globalRegistry } from 'zod'\n\n/**\n * Checks if the provided MongoDB configuration contains all necessary fields\n * for establishing a connection.\n * @param config MongoDB configuration object\n * @returns True if the configuration contains all necessary fields for\n * establishing a connection\n */\nexport const hasMongoConfig = (config?: MongoConfig): config is Required<MongoConfig> => {\n if (isUndefined(config)) return false\n return (\n isDefined(config.connectionString)\n && isDefined(config.database)\n && isDefined(config.domain)\n && isDefined(config.password)\n && isDefined(config.username)\n )\n}\n\nexport const MongoConfigZod = z.object({\n // TODO: Create from other arguments\n connectionString: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB connection string',\n title: 'storage.mongo.connectionString',\n type: 'string',\n }),\n database: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB database name',\n title: 'storage.mongo.database',\n type: 'string',\n }),\n domain: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB domain',\n title: 'storage.mongo.domain',\n type: 'string',\n }),\n password: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB password',\n title: 'storage.mongo.password',\n type: 'string',\n }),\n username: z.string().min(1).optional().register(globalRegistry, {\n description: 'MongoDB username',\n title: 'storage.mongo.username',\n type: 'string',\n }),\n})\n\nexport type MongoConfig = z.infer<typeof MongoConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nimport { MongoConfigZod } from './driver/index.ts'\n\nexport const StorageConfigZod = z.object({\n mongo: MongoConfigZod.optional().describe('Configuration for the MongoD storage driver'),\n root: z.string().optional().register(globalRegistry, {\n description: 'Root directory for local storage',\n title: 'storage.root',\n type: 'string',\n }),\n}).describe('Storage configuration options')\n\nexport type StorageConfig = z.infer<typeof StorageConfigZod>\n","import z, { globalRegistry } from 'zod'\n\nexport const OpenTelemetryConfigZod = z.object({\n // OpenTelemetry options\n otlpEndpoint: z.url().optional().register(globalRegistry, {\n description: 'OTLP endpoint for exporting telemetry data',\n title: 'telemetry.otel.otlpEndpoint',\n type: 'string',\n }),\n})\n\nexport const TelemetryConfigZod = z.object({\n // OpenTelemetry configuration\n otel: OpenTelemetryConfigZod.optional().describe('OpenTelemetry configuration'),\n}).describe('Telemetry configuration options')\n\nexport type TelemetryConfig = z.infer<typeof TelemetryConfigZod>\n","import z from 'zod'\n\nconst DescriptionSchema = z.string()\nconst TitleSchema = z.string()\n\nexport const JSONSchemaMetaSchema = z\n .object({\n id: z.string().optional(),\n title: TitleSchema.optional(),\n description: DescriptionSchema.optional(),\n deprecated: z.boolean().optional(),\n })\n .catchall(z.unknown()) // allow arbitrary extra keys\n\nexport const GlobalMetaSchema = JSONSchemaMetaSchema.extend({})\n\nconst ChoicesSchema = z\n .array(z.union([z.string(), z.number(), z.literal(true), z.undefined()]))\n .readonly()\n\nexport const UsageMetaSchema = GlobalMetaSchema.extend({\n choices: ChoicesSchema.optional(),\n default: z.unknown().optional(),\n description: DescriptionSchema,\n group: z.string().optional(),\n hidden: z.boolean().optional(),\n title: TitleSchema,\n type: z.union([\n z.literal('array'),\n z.literal('count'),\n z.literal('boolean'),\n z.literal('number'),\n z.literal('string'),\n ]),\n})\n\nexport type UsageMeta = z.infer<typeof UsageMetaSchema>\n\nexport function isUsageMeta(v: unknown): v is UsageMeta {\n return UsageMetaSchema.safeParse(v).success\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Address } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n Chain,\n ExecutableFields,\n FromFields,\n SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,\n} from '@xyo-network/xl1-protocol'\nimport { defaultTransactionFees } from '@xyo-network/xl1-protocol'\n\nexport async function buildTransaction(\n chain: Chain,\n onChainPayloads: AllowedBlockPayload[],\n offChainPayloads: Payload[],\n signer: AccountInstance | AccountInstance[],\n nbf: number,\n exp: number,\n from?: Address,\n fees: TransactionFeesBigInt = defaultTransactionFees,\n): Promise<SignedHydratedTransactionWithStorageMeta> {\n if (from === undefined && Array.isArray(signer)) {\n throw new Error('from is required when signer is an array')\n }\n\n const txBoundWitnessFields: TransactionBoundWitnessFields = {\n chain,\n fees: {\n base: toHex(fees.base),\n gasLimit: toHex(fees.gasLimit),\n gasPrice: toHex(fees.gasPrice),\n priority: toHex(fees.priority),\n },\n nbf,\n exp,\n }\n\n const elevatedHashes = await PayloadBuilder.hashes(onChainPayloads)\n const script: string[] = []\n for (const elevatedHash of elevatedHashes) {\n script.push(`elevate|${elevatedHash}`)\n }\n\n const fields: TransactionBoundWitnessFields & FromFields & Partial<ExecutableFields> = {\n ...txBoundWitnessFields,\n from: from ?? (Array.isArray(signer) ? assertEx(signer.at(0)?.address) : signer.address),\n }\n\n if (script.length > 0) {\n fields.script = script\n }\n\n const [tx, txPayloads] = await new BoundWitnessBuilder<TransactionBoundWitness>()\n .fields(fields)\n .meta({ $signatures: [] })\n .payloads([...onChainPayloads, ...offChainPayloads])\n .signers(Array.isArray(signer) ? signer : [signer])\n .build()\n\n return [await PayloadBuilder.addStorageMeta(tx), await PayloadBuilder.addStorageMeta(txPayloads)]\n}\n","import type { Address } from '@xylabs/hex'\nimport { toHex } from '@xylabs/hex'\nimport { BoundWitnessBuilder } from '@xyo-network/boundwitness-builder'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { Payload } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n Chain,\n ExecutableFields,\n FromFields,\n SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness, TransactionBoundWitnessFields, TransactionFeesBigInt,\n} from '@xyo-network/xl1-protocol'\nimport { defaultTransactionFees } from '@xyo-network/xl1-protocol'\n\nexport async function buildUnsignedTransaction(\n chain: Chain,\n onChainPayloads: AllowedBlockPayload[],\n offChainPayloads: Payload[],\n nbf: number,\n exp: number,\n from: Address,\n fees: TransactionFeesBigInt = defaultTransactionFees,\n): Promise<SignedHydratedTransactionWithStorageMeta> {\n const txBoundWitnessFields: TransactionBoundWitnessFields = {\n chain,\n fees: {\n base: toHex(fees.base),\n gasLimit: toHex(fees.gasLimit),\n gasPrice: toHex(fees.gasPrice),\n priority: toHex(fees.priority),\n },\n nbf,\n exp,\n }\n\n const elevatedHashes = await PayloadBuilder.hashes(onChainPayloads)\n const script: string[] = []\n for (const elevatedHash of elevatedHashes) {\n script.push(`elevate|${elevatedHash}`)\n }\n\n const fields: TransactionBoundWitnessFields & FromFields & Partial<ExecutableFields> = {\n ...txBoundWitnessFields,\n from,\n }\n\n if (script.length > 0) {\n fields.script = script\n }\n\n const [tx, txPayloads] = await new BoundWitnessBuilder<TransactionBoundWitness>()\n .fields(fields)\n .meta({ $signatures: [] })\n .payloads([...onChainPayloads, ...offChainPayloads])\n .build()\n\n return [await PayloadBuilder.addStorageMeta(tx), await PayloadBuilder.addStorageMeta(txPayloads)]\n}\n","import { delay } from '@xylabs/delay'\nimport type { Logger } from '@xylabs/logger'\nimport { isDefined } from '@xylabs/typeof'\nimport type { Signed } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type {\n SignedHydratedTransaction, TransactionBoundWitness, XyoViewer,\n} from '@xyo-network/xl1-protocol'\n\nconst DEFAULT_CONFIRMATION_ATTEMPTS = 20\nconst DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1000 // milliseconds\n\nexport type ConfirmSubmittedTransactionOptions = {\n /**\n * Number of attempts to confirm the transaction.\n * Defaults to 20.\n */\n attempts?: number\n /**\n * Delay in milliseconds between confirmation attempts.\n * Defaults to 1000 (1 second).\n */\n delay?: number\n /**\n * Optional logger instance for logging progress.\n */\n logger?: Logger\n}\n\n/**\n * Confirms a submitted transaction by checking if it has been included in the blockchain.\n * @param viewer The viewer\n * @param transaction The transaction to confirm\n * @param options Options for confirmation\n * @returns The confirmed transaction or throws an error if not confirmed\n */\nexport const confirmSubmittedTransaction = async (\n viewer: XyoViewer,\n transaction: Signed<TransactionBoundWitness>,\n options?: ConfirmSubmittedTransactionOptions,\n): Promise<SignedHydratedTransaction> => {\n const { attempts: maxAttempts = DEFAULT_CONFIRMATION_ATTEMPTS, delay: attemptDelay = DEFAULT_DELAY_BETWEEN_ATTEMPTS } = options || {}\n const txBWHash = await PayloadBuilder.hash(transaction)\n options?.logger?.log('🚀 confirming transaction:', txBWHash, '\\n')\n let attempts = 0\n while (true) {\n const tx = await viewer.transactionByHash(txBWHash) ?? undefined\n if (isDefined(tx)) {\n options?.logger?.log('✅ Transaction confirmed:', txBWHash, '\\n')\n return tx\n } else {\n attempts++\n if (attempts > maxAttempts) {\n options?.logger?.error(`⚠️ Transaction not confirmed after ${maxAttempts} attempts`)\n throw new Error(`Transaction ${txBWHash} not confirmed after ${maxAttempts} attempts`)\n } else {\n options?.logger?.log(`🔄 Transaction not confirmed yet, attempt ${attempts}. Retrying...`, '\\n')\n await delay(attemptDelay)\n }\n }\n }\n}\n","import { assertEx } from '@xylabs/assert'\nimport type { Hash } from '@xylabs/hex'\nimport type { ReadArchivist } from '@xyo-network/archivist-model'\nimport { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from '@xyo-network/archivist-model'\nimport type { Payload, WithStorageMeta } from '@xyo-network/payload-model'\nimport type {\n AllowedBlockPayload,\n SignedHydratedTransaction, SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness,\n} from '@xyo-network/xl1-protocol'\nimport { isAllowedBlockPayload, isSignedTransactionBoundWitnessWithStorageMeta } from '@xyo-network/xl1-protocol'\n\nexport const tryHydrateTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {\n return (await tryHydrateTypedBoundWitness<TransactionBoundWitness>(\n archivist,\n hash,\n isSignedTransactionBoundWitnessWithStorageMeta,\n )) as SignedHydratedTransactionWithStorageMeta | undefined\n}\n\nexport const hydrateTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransaction> => {\n return await hydrateTypedBoundWitness<TransactionBoundWitness>(\n archivist,\n hash,\n isSignedTransactionBoundWitnessWithStorageMeta,\n ) as SignedHydratedTransaction\n}\n\nexport const flattenHydratedTransaction = (hydratedTransaction: SignedHydratedTransaction): Payload[] => {\n const [tx, txPayloads] = hydratedTransaction\n return [...txPayloads, tx]\n}\n\nexport const flattenHydratedTransactions = (hydratedTransactions: SignedHydratedTransaction[]): Payload[] =>\n hydratedTransactions.flatMap(tx => flattenHydratedTransaction(tx))\n\nexport const tryHydrateElevatedTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransactionWithStorageMeta | undefined> => {\n const hydratedTransaction = await tryHydrateTransaction(archivist, hash)\n if (!hydratedTransaction) {\n return undefined\n }\n const [transaction, payloads] = hydratedTransaction\n const opCodes = (transaction.script ?? []).filter(operation => operation.startsWith('elevate|'))\n const elevatedPayloads: WithStorageMeta<AllowedBlockPayload>[] = []\n for (const opCode of opCodes) {\n const [code, hash] = opCode.split('|')\n if (code === 'elevated') {\n const elevatedPayload = payloads.find(payload => payload._hash === hash)\n if (isAllowedBlockPayload(elevatedPayload)) {\n elevatedPayloads.push(elevatedPayload)\n }\n }\n }\n if (opCodes.length === elevatedPayloads.length) {\n return [transaction, elevatedPayloads]\n }\n return undefined\n}\n\nexport const hydrateElevatedTransaction = async (\n archivist: ReadArchivist,\n hash: Hash,\n): Promise<SignedHydratedTransaction> => {\n return assertEx(await tryHydrateElevatedTransaction(archivist, hash), () => 'Hydration failed')\n}\n","import { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { SignedHydratedTransaction } from '@xyo-network/xl1-protocol'\n\n/** The number of bytes that a transaction and its payloads will take up in a block */\nexport function transactionBlockByteCount([transaction, payloads]: SignedHydratedTransaction): number {\n const cleanTransaction = PayloadBuilder.omitStorageMeta(transaction)\n const transactionBytes = JSON.stringify(cleanTransaction).length\n const cleanPayloads = PayloadBuilder.omitStorageMeta(payloads)\n return cleanPayloads.reduce((acc: number, payload) => acc + JSON.stringify(payload).length, 0) + transactionBytes\n}\n","import { asHash, type Hash } from '@xylabs/hex'\nimport type { Payload, WithHashStorageMeta } from '@xyo-network/payload-model'\nimport type { SignedHydratedTransactionWithStorageMeta, TransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\nimport { crackOperations } from './transactionOperations.ts'\n\nexport function transactionElevatedPayloadHashes(transaction: TransactionBoundWitness): Hash[] {\n const elevateOperations = crackOperations(transaction.script ?? []).filter(op => op[0] === 'elevate')\n return elevateOperations.map(op => asHash(op[1][0], true))\n}\n\nexport function transactionElevatedPayloads([transaction, payloads]: SignedHydratedTransactionWithStorageMeta): WithHashStorageMeta<Payload>[] {\n const hashes = transactionElevatedPayloadHashes(transaction)\n const elevatedPayloads = payloads.filter(payload => hashes.includes(payload._hash))\n return elevatedPayloads\n}\n","export function crackOperation(operation: string): [string, string[]] {\n const parts = operation.split('|')\n if (parts.length < 2) {\n throw new Error(`Invalid operation format: ${operation}`)\n }\n return [parts[0], parts.slice(1)]\n}\n\nexport function crackOperations(operations: string[]): [string, string[]][] {\n return operations.map(op => crackOperation(op))\n}\n","import type { SignedHydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'\nimport { AttoXL1, TransactionGasCosts } from '@xyo-network/xl1-protocol'\n\nimport { transactionBlockByteCount } from './transactionBlockByteCount.ts'\nimport { transactionElevatedPayloads } from './transactionElevatedPayloads.ts'\n\n/** The required gas for the byte storage on the block chain for a transaction */\nexport function transactionBytesRequiredGas([transaction, payloads]: SignedHydratedTransactionWithStorageMeta): AttoXL1 {\n const transactionBlockBytes = transactionBlockByteCount([transaction, payloads])\n return AttoXL1(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes))\n}\n\nexport function transactionRequiredGas(hydratedTransaction: SignedHydratedTransactionWithStorageMeta): AttoXL1 {\n const elevatedPayloads = transactionElevatedPayloads(hydratedTransaction)\n const hashes = elevatedPayloads.length + 1 /* for transaction itself */\n const signatures = hydratedTransaction[0].addresses.length\n return AttoXL1(transactionBytesRequiredGas(hydratedTransaction)\n + TransactionGasCosts.hashValidation * BigInt(hashes)\n + TransactionGasCosts.signatureValidation * BigInt(signatures)\n + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads.length))\n}\n","import { filterAs } from '@xylabs/array'\nimport { assertEx } from '@xylabs/assert'\nimport { asHash, type Hash } from '@xylabs/hex'\nimport type { WithStorageMeta } from '@xyo-network/payload-model'\nimport type { AllowedBlockPayload, HydratedTransactionWithStorageMeta } from '@xyo-network/xl1-protocol'\nimport { isAllowedBlockPayloadWithHashStorageMeta } from '@xyo-network/xl1-protocol'\n\nexport const tryExtractElevatedHashesFromScript = (strings: string[]): Hash[] => {\n const hashes = strings\n .filter(str => str.startsWith('elevate|'))\n .map(str => str.split('|')[1])\n return filterAs(hashes, h => asHash(h))\n}\n\nexport const extractElevatedHashesFromScript = (strings: string[]): Hash[] => {\n const hashes = strings\n .filter(str => str.startsWith('elevate|'))\n .map(str => str.split('|')[1])\n const filtered = filterAs(hashes, h => asHash(h))\n assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')\n return filtered\n}\n\nexport const tryExtractElevatedHashes = (tx: HydratedTransactionWithStorageMeta): WithStorageMeta<AllowedBlockPayload>[] => {\n const [bw, payloads] = tx\n const { script } = bw\n const hashes = script ? tryExtractElevatedHashesFromScript(script) : []\n return payloads\n .filter(p => hashes.includes(p._hash))\n .filter(isAllowedBlockPayloadWithHashStorageMeta)\n}\n\nexport const extractElevatedHashes = (tx: HydratedTransactionWithStorageMeta): WithStorageMeta<AllowedBlockPayload>[] => {\n const [bw, payloads] = tx\n const { script } = bw\n const hashes = script ? tryExtractElevatedHashesFromScript(script) : []\n const filtered = payloads\n .filter(p => hashes.includes(p._hash))\n .filter(isAllowedBlockPayloadWithHashStorageMeta)\n assertEx(filtered.length === hashes.length, () => 'Invalid elevated hashes')\n return filtered\n}\n","import { toArrayBuffer } from '@xylabs/arraybuffer'\nimport { assertEx } from '@xylabs/assert'\nimport { hexFromArrayBuffer } from '@xylabs/hex'\nimport type { AccountInstance } from '@xyo-network/account-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { TransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\nexport async function signTransaction(tx: TransactionBoundWitness, account: AccountInstance) {\n assertEx(tx.from === account.address, () => 'Signer address does not match transaction from address')\n const signedTx = structuredClone(tx)\n signedTx.addresses = [account.address]\n signedTx.previous_hashes = [account.previousHash ?? null]\n const hash = await PayloadBuilder.hash(signedTx)\n const hashBytes = toArrayBuffer(hash)\n const [signature] = await account.sign(hashBytes)\n signedTx.$signatures = [hexFromArrayBuffer(signature)]\n return signedTx\n}\n","import { HDWallet } from '@xyo-network/wallet'\n\nimport { DEFAULT_WALLET_PATH } from './paths.ts'\n\n/**\n * Initializes a wallet to the default XYO path from a mnemonic phrase\n * @param walletPhrase The mnemonic phrase for the wallet\n * @returns A wallet initialized to the default XYO path using the provided phrase\n */\nexport const generateXyoBaseWalletFromPhrase = (walletPhrase: string) => {\n const wallet = HDWallet.fromPhrase(walletPhrase, DEFAULT_WALLET_PATH)\n return wallet\n}\n","export const WALLET_COMPLIANCE = '44\\'' as const\n\nexport const COIN_TYPES = { Ethereum: '60\\'' } as const\n\nexport const ACCOUNT_TYPE = { GANACHE: '0\\'', XYO: '0\\'' } as const\n\nexport const CHANGE_ADDRESS = { META_MASK: '0', XYO: '0' } as const\n\nexport const ADDRESS_INDEX = { META_MASK: '0', XYO: '0' } as const\n\nexport const DEFAULT_WALLET_PATH = `m/${WALLET_COMPLIANCE}/${COIN_TYPES.Ethereum}/${ACCOUNT_TYPE.XYO}/${CHANGE_ADDRESS.XYO}`\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,gBAAgB;AAKzB,SACEC,0CAA0CC,oCAAoCC,gDACzE;AAEA,SAASC,iBAAiBC,QAAgBC,UAAoC;AACnF,QAAMC,gBAAgB,IAAIC,IAAIF,SAASG,IAAIC,CAAAA,MAAKA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AA,IAAa,MAAMb,QAAQc,KAAKH,SAAAA;AACvCP,WAASW,cAAc;IAACC,mBAAmBH,SAAAA;;AAC3C,SAAOT;AACT;AAVsBN;;;ACPtB,SAASmB,gBAAgB;;;ACAlB,IAAMC,oBAAoB;AAE1B,IAAMC,aAAa;EAAEC,UAAU;AAAO;AAEtC,IAAMC,eAAe;EAAEC,SAAS;EAAOC,KAAK;AAAM;AAElD,IAAMC,iBAAiB;EAAEC,WAAW;EAAKF,KAAK;AAAI;AAElD,IAAMG,gBAAgB;EAAED,WAAW;EAAKF,KAAK;AAAI;AAEjD,IAAMI,sBAAsB,KAAKT,iBAAAA,IAAqBC,WAAWC,QAAQ,IAAIC,aAAaE,GAAG,IAAIC,eAAeD,GAAG;;;ADDnH,IAAMK,kCAAkC,wBAACC,iBAAAA;AAC9C,QAAMC,SAASC,SAASC,WAAWH,cAAcI,mBAAAA;AACjD,SAAOH;AACT,GAH+C;","names":["filterAs","assertEx","asTransactionBoundWitnessWithStorageMeta","isBlockBoundWitnessWithStorageMeta","isTransactionBoundWitnessWithStorageMeta","allHashesPresent","hashes","payloads","payloadHashes","Set","map","p","_hash","every","hash","has","tryHydrateBlock","archivist","maxDepth","assertEx","bw","get","find","isBlockBoundWitnessWithStorageMeta","undefined","blkPayloads","payload_hashes","transactions","filter","isTransactionBoundWitnessWithStorageMeta","transactionsPayloadHashes","flatMap","tx","transactionsPayloads","allPayloadsHashes","allPayloads","allPayloadsFiltered","hydrateBlock","minDepth","flattenHydratedBlock","hydratedBlock","blk","flattenHydratedBlocks","hydratedBlocks","transactionsFromHydratedBlock","block","filterAs","asTransactionBoundWitnessWithStorageMeta","blockPayloadsFromHydratedBlock","x","assertEx","PayloadBuilder","isAnyPayload","StepSizes","hexToBigInt","toAddress","isTransfer","netBalancesForPayloads","payloads","balances","payload","isTransfer","from","address","amount","Object","entries","transfers","toAddress","hexToBigInt","hexToBigInt","toHex","isObject","isNegativeBigInt","value","isObject","negative","isPositiveBigInt","positive","parseSignedBigInt","hexToBigInt","Error","toSignedBigInt","toHex","toPositiveBigInt","stepSize","calculateFramesFromRange","range","step","size","stepSize","start","Math","trunc","fitted","remaining","push","min","i","StepSizes","deepCalculateFramesFromRange","range","startingStep","StepSizes","length","fitted","remaining","step","newRemaining","newFittedFrames","newRemainingFrames","calculateFramesFromRange","push","i","toSorted","a","b","asHash","toSafeJsonString","asBlockBoundWitnessWithStorageMeta","StepSizes","hashFromBlockNumber","context","blockNumber","result","chainArchivist","get","head","currentBlock","asBlockBoundWitnessWithStorageMeta","at","required","block","jumpHash","previous","jumpBlockNumber","step","stepSize","StepSizes","entries","possibleJumpBlockNumber","asHash","step_hashes","newBlock","toSafeJsonString","Error","_hash","AsObjectFactory","isPayloadOfSchemaType","isStorageMeta","StepSummarySchema","BalancesStepSummarySchema","isBalancesStepSummary","isPayloadOfSchemaType","asBalancesStepSummary","AsObjectFactory","create","isBalancesStepSummaryWithStorageMeta","value","isStorageMeta","asBalancesStepSummaryWithStorageMeta","balanceStepSummaryFromRange","context","range","frameHeadHash","hashFromBlockNumber","frameSize","result","undefined","hash","payloads","hydrateBlock","chainArchivist","balances","address","balance","Object","entries","netBalancesForPayloads","toSignedBigInt","schema","BalancesStepSummarySchema","head","stepSize","step","StepSizes","indexOf","assertEx","join","summaryResult","summaryRepository","get","isAnyPayload","subRanges","deepCalculateFramesFromRange","promises","map","subRange","subResults","Promise","all","bigIntBalances","subResult","parseSignedBigInt","insert","finalResult","PayloadBuilder","addStorageMeta","asAddress","isDefined","asBlockBoundWitnessWithStorageMeta","balanceSummary","context","headResult","chainArchivist","get","head","headBoundWitness","asBlockBoundWitnessWithStorageMeta","at","required","rangeStart","isDefined","windowSize","Math","max","block","ranges","deepCalculateFramesFromRange","summaries","Promise","all","map","range","balanceStepSummaryFromRange","balances","summary","address","balance","Object","entries","validAddress","asAddress","parseSignedBigInt","z","z","globalRegistry","isLocalhost","hostname","endsWith","getUrl","host","port","scheme","isLocalhost","TODO","z","MnemonicStringZod","string","transform","s","trim","replaceAll","refine","includes","split","length","message","describe","ApiConfigZod","z","object","host","string","default","register","globalRegistry","description","title","type","mnemonic","MnemonicStringZod","optional","port","coerce","number","z","globalRegistry","AppConfigZod","object","port","coerce","number","default","register","description","title","type","z","globalRegistry","ChainConfigZod","object","id","string","optional","register","description","title","type","z","globalRegistry","EvmInfuraConfigZod","object","projectId","string","optional","register","description","title","type","projectSecret","EvmJsonRpcConfigZod","url","EvmConfigZod","chainId","infura","describe","jsonRpc","LogLevel","z","globalRegistry","LogLevels","Object","keys","LogConfigZod","object","logLevel","enum","default","register","choices","description","title","type","silent","boolean","z","globalRegistry","ProducerConfigZod","z","object","disableIntentRedeclaration","boolean","optional","register","globalRegistry","description","title","type","healthCheckPort","coerce","number","minStake","default","mnemonic","MnemonicStringZod","port","rewardAddress","string","isDefined","isUndefined","z","globalRegistry","hasMongoConfig","config","isUndefined","isDefined","connectionString","database","domain","password","username","MongoConfigZod","z","object","string","min","optional","register","globalRegistry","description","title","type","z","globalRegistry","StorageConfigZod","z","object","mongo","MongoConfigZod","optional","describe","root","string","register","globalRegistry","description","title","type","z","globalRegistry","OpenTelemetryConfigZod","object","otlpEndpoint","url","optional","register","description","title","type","TelemetryConfigZod","otel","describe","Xl1CommonConfigSchema","z","object","LogConfigZod","shape","describe","ConfigZod","api","ApiConfigZod","default","parse","app","AppConfigZod","chain","ChainConfigZod","evm","EvmConfigZod","producer","ProducerConfigZod","storage","StorageConfigZod","telemetry","TelemetryConfigZod","getDefaultConfig","z","DescriptionSchema","z","string","TitleSchema","JSONSchemaMetaSchema","object","id","optional","title","description","deprecated","boolean","catchall","unknown","GlobalMetaSchema","extend","ChoicesSchema","array","union","number","literal","undefined","readonly","UsageMetaSchema","choices","default","group","hidden","type","isUsageMeta","v","safeParse","success","assertEx","toHex","BoundWitnessBuilder","PayloadBuilder","defaultTransactionFees","buildTransaction","chain","onChainPayloads","offChainPayloads","signer","nbf","exp","from","fees","defaultTransactionFees","undefined","Array","isArray","Error","txBoundWitnessFields","base","toHex","gasLimit","gasPrice","priority","elevatedHashes","PayloadBuilder","hashes","script","elevatedHash","push","fields","assertEx","at","address","length","tx","txPayloads","BoundWitnessBuilder","meta","$signatures","payloads","signers","build","addStorageMeta","toHex","BoundWitnessBuilder","PayloadBuilder","defaultTransactionFees","buildUnsignedTransaction","chain","onChainPayloads","offChainPayloads","nbf","exp","from","fees","defaultTransactionFees","txBoundWitnessFields","base","toHex","gasLimit","gasPrice","priority","elevatedHashes","PayloadBuilder","hashes","script","elevatedHash","push","fields","length","tx","txPayloads","BoundWitnessBuilder","meta","$signatures","payloads","build","addStorageMeta","delay","isDefined","PayloadBuilder","DEFAULT_CONFIRMATION_ATTEMPTS","DEFAULT_DELAY_BETWEEN_ATTEMPTS","confirmSubmittedTransaction","viewer","transaction","options","attempts","maxAttempts","delay","attemptDelay","txBWHash","PayloadBuilder","hash","logger","log","tx","transactionByHash","undefined","isDefined","error","Error","assertEx","hydrateTypedBoundWitness","tryHydrateTypedBoundWitness","isAllowedBlockPayload","isSignedTransactionBoundWitnessWithStorageMeta","tryHydrateTransaction","archivist","hash","tryHydrateTypedBoundWitness","isSignedTransactionBoundWitnessWithStorageMeta","hydrateTransaction","hydrateTypedBoundWitness","flattenHydratedTransaction","hydratedTransaction","tx","txPayloads","flattenHydratedTransactions","hydratedTransactions","flatMap","tryHydrateElevatedTransaction","undefined","transaction","payloads","opCodes","script","filter","operation","startsWith","elevatedPayloads","opCode","code","split","elevatedPayload","find","payload","_hash","isAllowedBlockPayload","push","length","hydrateElevatedTransaction","assertEx","PayloadBuilder","transactionBlockByteCount","transaction","payloads","cleanTransaction","PayloadBuilder","omitStorageMeta","transactionBytes","JSON","stringify","length","cleanPayloads","reduce","acc","payload","asHash","crackOperation","operation","parts","split","length","Error","slice","crackOperations","operations","map","op","transactionElevatedPayloadHashes","transaction","elevateOperations","crackOperations","script","filter","op","map","asHash","transactionElevatedPayloads","payloads","hashes","elevatedPayloads","payload","includes","_hash","AttoXL1","TransactionGasCosts","transactionBytesRequiredGas","transaction","payloads","transactionBlockBytes","transactionBlockByteCount","AttoXL1","TransactionGasCosts","characterStorage","BigInt","transactionRequiredGas","hydratedTransaction","elevatedPayloads","transactionElevatedPayloads","hashes","length","signatures","addresses","hashValidation","signatureValidation","payloadValidation","filterAs","assertEx","asHash","isAllowedBlockPayloadWithHashStorageMeta","tryExtractElevatedHashesFromScript","strings","hashes","filter","str","startsWith","map","split","filterAs","h","asHash","extractElevatedHashesFromScript","filtered","assertEx","length","tryExtractElevatedHashes","tx","bw","payloads","script","p","includes","_hash","isAllowedBlockPayloadWithHashStorageMeta","extractElevatedHashes","toArrayBuffer","assertEx","hexFromArrayBuffer","PayloadBuilder","signTransaction","tx","account","assertEx","from","address","signedTx","structuredClone","addresses","previous_hashes","previousHash","hash","PayloadBuilder","hashBytes","toArrayBuffer","signature","sign","$signatures","hexFromArrayBuffer","HDWallet","WALLET_COMPLIANCE","COIN_TYPES","Ethereum","ACCOUNT_TYPE","GANACHE","XYO","CHANGE_ADDRESS","META_MASK","ADDRESS_INDEX","DEFAULT_WALLET_PATH","generateXyoBaseWalletFromPhrase","walletPhrase","wallet","HDWallet","fromPhrase","DEFAULT_WALLET_PATH"]}
|
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-protocol-sdk",
|
|
4
|
-
"version": "1.12.
|
|
4
|
+
"version": "1.12.1",
|
|
5
5
|
"description": "XYO Layer One SDK Protocol",
|
|
6
6
|
"homepage": "https://xylabs.com",
|
|
7
7
|
"bugs": {
|
|
@@ -36,30 +36,30 @@
|
|
|
36
36
|
"src"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@xylabs/array": "~5.0.
|
|
40
|
-
"@xylabs/arraybuffer": "~5.0.
|
|
41
|
-
"@xylabs/assert": "~5.0.
|
|
42
|
-
"@xylabs/delay": "~5.0.
|
|
43
|
-
"@xylabs/hex": "~5.0.
|
|
44
|
-
"@xylabs/logger": "~5.0.
|
|
45
|
-
"@xylabs/object": "~5.0.
|
|
46
|
-
"@xylabs/promise": "~5.0.
|
|
47
|
-
"@xylabs/typeof": "~5.0.
|
|
48
|
-
"@xyo-network/account-model": "~5.0.
|
|
49
|
-
"@xyo-network/archivist-model": "~5.0.
|
|
50
|
-
"@xyo-network/boundwitness-builder": "~5.0.
|
|
51
|
-
"@xyo-network/boundwitness-model": "~5.0.
|
|
52
|
-
"@xyo-network/payload-builder": "~5.0.
|
|
53
|
-
"@xyo-network/payload-model": "~5.0.
|
|
54
|
-
"@xyo-network/wallet": "~5.0.
|
|
55
|
-
"@xyo-network/wallet-model": "~5.0.
|
|
56
|
-
"@xyo-network/xl1-protocol": "~1.10.
|
|
39
|
+
"@xylabs/array": "~5.0.8",
|
|
40
|
+
"@xylabs/arraybuffer": "~5.0.8",
|
|
41
|
+
"@xylabs/assert": "~5.0.8",
|
|
42
|
+
"@xylabs/delay": "~5.0.8",
|
|
43
|
+
"@xylabs/hex": "~5.0.8",
|
|
44
|
+
"@xylabs/logger": "~5.0.8",
|
|
45
|
+
"@xylabs/object": "~5.0.8",
|
|
46
|
+
"@xylabs/promise": "~5.0.8",
|
|
47
|
+
"@xylabs/typeof": "~5.0.8",
|
|
48
|
+
"@xyo-network/account-model": "~5.0.5",
|
|
49
|
+
"@xyo-network/archivist-model": "~5.0.5",
|
|
50
|
+
"@xyo-network/boundwitness-builder": "~5.0.5",
|
|
51
|
+
"@xyo-network/boundwitness-model": "~5.0.5",
|
|
52
|
+
"@xyo-network/payload-builder": "~5.0.5",
|
|
53
|
+
"@xyo-network/payload-model": "~5.0.5",
|
|
54
|
+
"@xyo-network/wallet": "~5.0.5",
|
|
55
|
+
"@xyo-network/wallet-model": "~5.0.5",
|
|
56
|
+
"@xyo-network/xl1-protocol": "~1.10.13",
|
|
57
57
|
"zod": "~4.0.17"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "~24.2.1",
|
|
61
|
-
"@xylabs/ts-scripts-yarn3": "~7.1.
|
|
62
|
-
"@xylabs/tsconfig": "~7.1.
|
|
61
|
+
"@xylabs/ts-scripts-yarn3": "~7.1.2",
|
|
62
|
+
"@xylabs/tsconfig": "~7.1.2",
|
|
63
63
|
"typescript": "~5.9.2",
|
|
64
64
|
"vitest": "~3.2.4"
|
|
65
65
|
},
|