@xyo-network/xl1-protocol-sdk 1.16.9 → 1.16.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/block/primitives/frames/calculateFramesFromRange.d.ts.map +1 -1
- package/dist/neutral/block/primitives/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +3 -15
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/Producer.d.ts +1 -5
- package/dist/neutral/config/Producer.d.ts.map +1 -1
- package/dist/neutral/config/Validation.d.ts +2 -10
- package/dist/neutral/config/Validation.d.ts.map +1 -1
- package/dist/neutral/index.mjs +278 -48
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/model/ChainContext/ChainStakeContext.d.ts +4 -5
- package/dist/neutral/model/ChainContext/ChainStakeContext.d.ts.map +1 -1
- package/dist/neutral/model/index.d.ts +0 -2
- package/dist/neutral/model/index.d.ts.map +1 -1
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts +2 -4
- package/dist/neutral/payloads/netBalancesForPayloads.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/balances/balancesSummary.d.ts.map +1 -1
- package/dist/neutral/primitives/summary/transfers/transfersSummary.d.ts.map +1 -1
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts +17 -0
- package/dist/neutral/simple/accountBalance/SimpleAccountBalanceViewer.d.ts.map +1 -0
- package/dist/neutral/simple/accountBalance/index.d.ts +2 -0
- package/dist/neutral/simple/accountBalance/index.d.ts.map +1 -0
- package/dist/neutral/simple/gateway/SimpleXyoGatewayRunner.d.ts.map +1 -1
- package/dist/neutral/simple/index.d.ts +2 -0
- package/dist/neutral/simple/index.d.ts.map +1 -1
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts +15 -0
- package/dist/neutral/simple/timesync/SimpleTimeSyncViewer.d.ts.map +1 -0
- package/dist/neutral/simple/timesync/index.d.ts +2 -0
- package/dist/neutral/simple/timesync/index.d.ts.map +1 -0
- package/dist/neutral/viewers/AccountBalance.d.ts +4 -8
- package/dist/neutral/viewers/AccountBalance.d.ts.map +1 -1
- package/dist/neutral/viewers/Block.d.ts +5 -3
- package/dist/neutral/viewers/Block.d.ts.map +1 -1
- package/dist/neutral/viewers/Stake.d.ts +21 -1
- package/dist/neutral/viewers/Stake.d.ts.map +1 -1
- package/dist/neutral/{model → viewers}/StakeEvents.d.ts +1 -1
- package/dist/neutral/viewers/StakeEvents.d.ts.map +1 -0
- package/dist/neutral/viewers/TimeSync.d.ts +1 -2
- package/dist/neutral/viewers/TimeSync.d.ts.map +1 -1
- package/dist/neutral/viewers/index.d.ts +1 -0
- package/dist/neutral/viewers/index.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/block/primitives/blockFromBlockNumber.ts +1 -1
- package/src/block/primitives/frames/calculateFramesFromRange.ts +3 -2
- package/src/block/primitives/transfers/transfersSummary.ts +4 -1
- package/src/model/ChainContext/ChainStakeContext.ts +6 -5
- package/src/model/index.ts +0 -2
- package/src/primitives/step/stepBlockRange.ts +1 -1
- package/src/primitives/step/stepTransferIndex.ts +1 -1
- package/src/primitives/summary/balances/balancesSummary.ts +4 -1
- package/src/primitives/summary/transfers/transfersSummary.ts +4 -1
- package/src/simple/accountBalance/SimpleAccountBalanceViewer.ts +124 -0
- package/src/simple/accountBalance/index.ts +1 -0
- package/src/simple/gateway/SimpleXyoGatewayRunner.ts +1 -2
- package/src/simple/index.ts +2 -0
- package/src/simple/timesync/SimpleTimeSyncViewer.ts +94 -0
- package/src/simple/timesync/index.ts +1 -0
- package/src/viewers/AccountBalance.ts +4 -8
- package/src/viewers/Block.ts +5 -3
- package/src/viewers/Stake.ts +24 -2
- package/src/{model → viewers}/StakeEvents.ts +1 -1
- package/src/viewers/TimeSync.ts +1 -2
- package/src/viewers/index.ts +1 -0
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts +0 -17
- package/dist/neutral/model/ChainStake/ChainStakeRead.d.ts.map +0 -1
- package/dist/neutral/model/ChainStake/ChainStakeStatic.d.ts +0 -7
- package/dist/neutral/model/ChainStake/ChainStakeStatic.d.ts.map +0 -1
- package/dist/neutral/model/ChainStake/ChainStakeWrite.d.ts +0 -6
- package/dist/neutral/model/ChainStake/ChainStakeWrite.d.ts.map +0 -1
- package/dist/neutral/model/ChainStake/index.d.ts +0 -4
- package/dist/neutral/model/ChainStake/index.d.ts.map +0 -1
- package/dist/neutral/model/StakeEvents.d.ts.map +0 -1
- package/src/model/ChainStake/ChainStakeRead.ts +0 -18
- package/src/model/ChainStake/ChainStakeStatic.ts +0 -7
- package/src/model/ChainStake/ChainStakeWrite.ts +0 -5
- package/src/model/ChainStake/index.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/calculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAG9D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG;IAE5E,aAAa,EAAE;IAEf,aAAa,EAAE;CAAC,
|
|
1
|
+
{"version":3,"file":"calculateFramesFromRange.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/frames/calculateFramesFromRange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAG9D,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG;IAE5E,aAAa,EAAE;IAEf,aAAa,EAAE;CAAC,CAqBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfersSummary.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/transfers/transfersSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAQhD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAM1E,wBAAsB,gBAAgB,CACpC,eAAe,EAAE,2BAA2B,GAC3C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"transfersSummary.d.ts","sourceRoot":"","sources":["../../../../../src/block/primitives/transfers/transfersSummary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAQhD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAA;AAM1E,wBAAsB,gBAAgB,CACpC,eAAe,EAAE,2BAA2B,GAC3C,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAwBrE;AAED,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,UAEzE"}
|
|
@@ -45,11 +45,7 @@ export declare const ConfigZod: z.ZodObject<{
|
|
|
45
45
|
port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
46
46
|
}, z.core.$strip>>;
|
|
47
47
|
producer: z.ZodDefault<z.ZodObject<{
|
|
48
|
-
allowlist: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.
|
|
49
|
-
readonly __address: true;
|
|
50
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
51
|
-
readonly __address: true;
|
|
52
|
-
}>, unknown>>>>>;
|
|
48
|
+
allowlist: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
53
49
|
disableIntentRedeclaration: z.ZodOptional<z.ZodBoolean>;
|
|
54
50
|
healthCheckPort: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
55
51
|
heartbeatInterval: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -80,16 +76,8 @@ export declare const ConfigZod: z.ZodObject<{
|
|
|
80
76
|
}, z.core.$strip>>;
|
|
81
77
|
}, z.core.$strip>>;
|
|
82
78
|
validation: z.ZodDefault<z.ZodObject<{
|
|
83
|
-
allowedRewardRedeemers: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.
|
|
84
|
-
|
|
85
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
86
|
-
readonly __address: true;
|
|
87
|
-
}>, unknown>>>>>;
|
|
88
|
-
allowedRewardEscrowAccountSigners: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
89
|
-
readonly __address: true;
|
|
90
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
91
|
-
readonly __address: true;
|
|
92
|
-
}>, unknown>>>>>;
|
|
79
|
+
allowedRewardRedeemers: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
80
|
+
allowedRewardEscrowAccountSigners: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
93
81
|
}, z.core.$strip>>;
|
|
94
82
|
logLevel: z.ZodDefault<z.ZodEnum<{
|
|
95
83
|
info: "info";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAexB,eAAO,MAAM,qBAAqB;;;;;;;;;;iBAAmF,CAAA;AAErH,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAexB,eAAO,MAAM,qBAAqB;;;;;;;;;;iBAAmF,CAAA;AAErH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAapB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAE9C,eAAO,MAAM,gBAAgB,QAAO,MAA6B,CAAA"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
export declare const ProducerConfigZod: z.ZodObject<{
|
|
3
|
-
allowlist: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.
|
|
4
|
-
readonly __address: true;
|
|
5
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
6
|
-
readonly __address: true;
|
|
7
|
-
}>, unknown>>>>>;
|
|
3
|
+
allowlist: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
8
4
|
disableIntentRedeclaration: z.ZodOptional<z.ZodBoolean>;
|
|
9
5
|
healthCheckPort: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
10
6
|
heartbeatInterval: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Producer.d.ts","sourceRoot":"","sources":["../../../src/config/Producer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"Producer.d.ts","sourceRoot":"","sources":["../../../src/config/Producer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,eAAO,MAAM,iBAAiB;;;;;;;;;iBAoD5B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
export declare const ValidationConfigZod: z.ZodObject<{
|
|
3
|
-
allowedRewardRedeemers: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.
|
|
4
|
-
|
|
5
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
6
|
-
readonly __address: true;
|
|
7
|
-
}>, unknown>>>>>;
|
|
8
|
-
allowedRewardEscrowAccountSigners: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodType<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
9
|
-
readonly __address: true;
|
|
10
|
-
}>, unknown, z.core.$ZodTypeInternals<import("@xylabs/typeof").Brand<import("@xylabs/hex").Hex, {
|
|
11
|
-
readonly __address: true;
|
|
12
|
-
}>, unknown>>>>>;
|
|
3
|
+
allowedRewardRedeemers: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
4
|
+
allowedRewardEscrowAccountSigners: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/hex").Address, string>>>>>;
|
|
13
5
|
}, z.core.$strip>;
|
|
14
6
|
export type ValidationConfig = z.infer<typeof ValidationConfigZod>;
|
|
15
7
|
//# sourceMappingURL=Validation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Validation.d.ts","sourceRoot":"","sources":["../../../src/config/Validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"Validation.d.ts","sourceRoot":"","sources":["../../../src/config/Validation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,mBAAmB;;;iBAqB9B,CAAA;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
|
package/dist/neutral/index.mjs
CHANGED
|
@@ -227,13 +227,6 @@ async function withContextCacheResponse(context, name, key, func, options) {
|
|
|
227
227
|
}
|
|
228
228
|
__name(withContextCacheResponse, "withContextCacheResponse");
|
|
229
229
|
|
|
230
|
-
// src/model/StakeEvents.ts
|
|
231
|
-
var StakeEventNames = [
|
|
232
|
-
"StakeAdded",
|
|
233
|
-
"StakeRemoved",
|
|
234
|
-
"StakeWithdrawn"
|
|
235
|
-
];
|
|
236
|
-
|
|
237
230
|
// src/block/primitives/blockFromBlockNumber.ts
|
|
238
231
|
async function blockFromBlockNumber(context, blockNumber) {
|
|
239
232
|
const cacheKey = `${blockNumber}`;
|
|
@@ -244,7 +237,7 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
244
237
|
required: true
|
|
245
238
|
});
|
|
246
239
|
if (currentBlock.block < blockNumber) {
|
|
247
|
-
throw new Error(`
|
|
240
|
+
throw new Error(`Block number ${blockNumber} is greater than head ${currentBlock.block}.`);
|
|
248
241
|
}
|
|
249
242
|
while (currentBlock.block > blockNumber) {
|
|
250
243
|
let jumpHash = currentBlock.previous;
|
|
@@ -289,12 +282,18 @@ function calculateFramesFromRange(range, step) {
|
|
|
289
282
|
for (let i = start; i <= range[1]; i += size) {
|
|
290
283
|
if (i + size - 1 <= range[1]) {
|
|
291
284
|
fitted.push([
|
|
292
|
-
asXL1BlockNumber(i,
|
|
293
|
-
|
|
285
|
+
asXL1BlockNumber(i, {
|
|
286
|
+
name: "calculateFramesFromRange A"
|
|
287
|
+
}),
|
|
288
|
+
asXL1BlockNumber(Math.min(i + size - 1, range[1]), {
|
|
289
|
+
name: "calculateFramesFromRange B"
|
|
290
|
+
})
|
|
294
291
|
]);
|
|
295
292
|
} else {
|
|
296
293
|
remaining.push([
|
|
297
|
-
asXL1BlockNumber(i,
|
|
294
|
+
asXL1BlockNumber(i, {
|
|
295
|
+
name: "calculateFramesFromRange C"
|
|
296
|
+
}),
|
|
298
297
|
range[1]
|
|
299
298
|
]);
|
|
300
299
|
}
|
|
@@ -502,7 +501,9 @@ async function transfersSummary(transferContext) {
|
|
|
502
501
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange([
|
|
503
502
|
rangeStart,
|
|
504
503
|
headBoundWitness.block
|
|
505
|
-
],
|
|
504
|
+
], {
|
|
505
|
+
name: "transfersSummary"
|
|
506
|
+
}));
|
|
506
507
|
const summaries = await Promise.all(ranges.map((range) => transfersStepSummaryFromRange(transferContext, range)));
|
|
507
508
|
const transfers = {};
|
|
508
509
|
for (let summary of summaries) {
|
|
@@ -1226,7 +1227,9 @@ function stepBlockRange({ block, step }) {
|
|
|
1226
1227
|
return asXL1BlockRange2([
|
|
1227
1228
|
start,
|
|
1228
1229
|
start + stepSize2 - 1
|
|
1229
|
-
],
|
|
1230
|
+
], {
|
|
1231
|
+
name: "stepBlockRange"
|
|
1232
|
+
});
|
|
1230
1233
|
}
|
|
1231
1234
|
__name(stepBlockRange, "stepBlockRange");
|
|
1232
1235
|
|
|
@@ -1245,7 +1248,7 @@ function stepTransferIndex(block, step) {
|
|
|
1245
1248
|
rewardTransferCount++;
|
|
1246
1249
|
}
|
|
1247
1250
|
}
|
|
1248
|
-
assertEx5(rewardTransferIndex >= 0, () => `
|
|
1251
|
+
assertEx5(rewardTransferIndex >= 0, () => `Could not find step size for step ${step} at block ${block}`);
|
|
1249
1252
|
return [
|
|
1250
1253
|
rewardTransferIndex,
|
|
1251
1254
|
rewardTransferCount
|
|
@@ -1331,7 +1334,9 @@ async function balancesSummary(context) {
|
|
|
1331
1334
|
const ranges = deepCalculateFramesFromRange(asXL1BlockRange3([
|
|
1332
1335
|
rangeStart,
|
|
1333
1336
|
headBoundWitness.block
|
|
1334
|
-
],
|
|
1337
|
+
], {
|
|
1338
|
+
name: "balancesSummary"
|
|
1339
|
+
}));
|
|
1335
1340
|
const summaries = await Promise.all(ranges.map((range) => balancesStepSummaryFromRange(context, range)));
|
|
1336
1341
|
const balances = {};
|
|
1337
1342
|
for (let summary of summaries) {
|
|
@@ -1390,6 +1395,119 @@ var asChainIndexingServiceState = AsObjectFactory6.create(isChainIndexingService
|
|
|
1390
1395
|
var isChainIndexingServiceStateWithStorageMeta = /* @__PURE__ */ __name((value) => isChainIndexingServiceState(value) && isStorageMeta3(value), "isChainIndexingServiceStateWithStorageMeta");
|
|
1391
1396
|
var asChainIndexingServiceStateWithStorageMeta = AsObjectFactory6.create(isChainIndexingServiceStateWithStorageMeta);
|
|
1392
1397
|
|
|
1398
|
+
// src/simple/accountBalance/SimpleAccountBalanceViewer.ts
|
|
1399
|
+
import { assertEx as assertEx7 } from "@xylabs/assert";
|
|
1400
|
+
import { exists } from "@xylabs/exists";
|
|
1401
|
+
import { spanRootAsync as spanRootAsync3 } from "@xylabs/telemetry";
|
|
1402
|
+
import { isDefined as isDefined8 } from "@xylabs/typeof";
|
|
1403
|
+
import { asRange, asXL1BlockNumber as asXL1BlockNumber4, asXL1BlockRange as asXL1BlockRange4, AttoXL1, StepSizes as StepSizes8, TransferSchema } from "@xyo-network/xl1-protocol";
|
|
1404
|
+
var SimpleAccountBalanceViewer = class {
|
|
1405
|
+
static {
|
|
1406
|
+
__name(this, "SimpleAccountBalanceViewer");
|
|
1407
|
+
}
|
|
1408
|
+
blockViewer;
|
|
1409
|
+
context;
|
|
1410
|
+
transferContext;
|
|
1411
|
+
constructor(context, transferContext, blockViewer) {
|
|
1412
|
+
this.context = context;
|
|
1413
|
+
this.transferContext = transferContext;
|
|
1414
|
+
this.blockViewer = blockViewer;
|
|
1415
|
+
}
|
|
1416
|
+
async accountBalance(address, headOrRange) {
|
|
1417
|
+
const balances = await this.accountBalances([
|
|
1418
|
+
address
|
|
1419
|
+
], headOrRange);
|
|
1420
|
+
return balances[address] ?? AttoXL1(0n);
|
|
1421
|
+
}
|
|
1422
|
+
async accountBalanceHistory(address, headOrRange) {
|
|
1423
|
+
const range = asRange(headOrRange);
|
|
1424
|
+
const startingRange = asXL1BlockRange4(range ?? [
|
|
1425
|
+
0,
|
|
1426
|
+
await this.blockViewer.currentBlockNumber()
|
|
1427
|
+
], true);
|
|
1428
|
+
const blockNumbers = await this.distillTransferHistory(address, startingRange);
|
|
1429
|
+
const blocks = (await Promise.all(blockNumbers.map(async (bn) => await this.blockViewer.blockByNumber(bn)))).filter(exists);
|
|
1430
|
+
const result = [];
|
|
1431
|
+
for (const block of blocks) {
|
|
1432
|
+
const transferIndexes = block[0].payload_schemas.map((schema, index) => schema === TransferSchema ? index : void 0).filter(exists);
|
|
1433
|
+
const transfers = transferIndexes.map((index) => {
|
|
1434
|
+
const hash = block[0].payload_hashes[index];
|
|
1435
|
+
return assertEx7(block[1].find((p) => p._hash === hash), () => `Error: Could not find Transfer with hash ${hash} in block ${block[0]._hash}`);
|
|
1436
|
+
}).filter(exists).filter((t) => t.from === address || isDefined8(t.transfers[address]));
|
|
1437
|
+
if (transfers.length === 0) {
|
|
1438
|
+
continue;
|
|
1439
|
+
}
|
|
1440
|
+
const pairs = transfers.map((transfer) => {
|
|
1441
|
+
return [
|
|
1442
|
+
block[0],
|
|
1443
|
+
transfer
|
|
1444
|
+
];
|
|
1445
|
+
});
|
|
1446
|
+
result.push(...pairs.map(([block2, transfer]) => [
|
|
1447
|
+
block2,
|
|
1448
|
+
null,
|
|
1449
|
+
transfer
|
|
1450
|
+
]));
|
|
1451
|
+
}
|
|
1452
|
+
return result;
|
|
1453
|
+
}
|
|
1454
|
+
async accountBalances(address, _headOrRange) {
|
|
1455
|
+
return await spanRootAsync3("balances", async () => {
|
|
1456
|
+
const summary = await balancesSummary(this.context);
|
|
1457
|
+
const result = {};
|
|
1458
|
+
for (const addr of address) {
|
|
1459
|
+
const summaryBalance = summary[addr] ?? 0n;
|
|
1460
|
+
result[addr] = AttoXL1(summaryBalance < 0n ? 0n : summaryBalance);
|
|
1461
|
+
}
|
|
1462
|
+
return result;
|
|
1463
|
+
});
|
|
1464
|
+
}
|
|
1465
|
+
accountBalancesHistories(_addresses, _rangeOrHash) {
|
|
1466
|
+
throw new Error("Method not implemented.");
|
|
1467
|
+
}
|
|
1468
|
+
async distillTransferHistory(address, range, max = 50) {
|
|
1469
|
+
if (range[1] - range[0] <= StepSizes8[0] || max <= 1) {
|
|
1470
|
+
return Array.from({
|
|
1471
|
+
length: range[1] - range[0] + 1
|
|
1472
|
+
}, (_, i) => range[1] - i).slice(0, max).map((n) => asXL1BlockNumber4(n, true));
|
|
1473
|
+
}
|
|
1474
|
+
const frames = deepCalculateFramesFromRange(asXL1BlockRange4(range, true));
|
|
1475
|
+
const transferSummaryPairs = await Promise.all(frames.map(async (frame) => {
|
|
1476
|
+
return [
|
|
1477
|
+
frame,
|
|
1478
|
+
await transfersStepSummaryFromRange(this.transferContext, frame)
|
|
1479
|
+
];
|
|
1480
|
+
}));
|
|
1481
|
+
const filteredTransferSummaryPairs = transferSummaryPairs.filter(([_, summary]) => Object.keys(summary.transfers).includes(address));
|
|
1482
|
+
const sortedTransferSummaryPairs = filteredTransferSummaryPairs.toSorted((a, b) => {
|
|
1483
|
+
return b[0][1] - a[0][1];
|
|
1484
|
+
});
|
|
1485
|
+
const resultBlockNumbers = /* @__PURE__ */ new Set();
|
|
1486
|
+
for (const [frame] of sortedTransferSummaryPairs) {
|
|
1487
|
+
if (frame[1] - frame[0] + 1 > StepSizes8[0]) {
|
|
1488
|
+
const values = await this.distillTransferHistory(address, asXL1BlockRange4([
|
|
1489
|
+
frame[0],
|
|
1490
|
+
frame[1] - 1
|
|
1491
|
+
], true), max - resultBlockNumbers.size);
|
|
1492
|
+
for (const value of values) {
|
|
1493
|
+
resultBlockNumbers.add(value);
|
|
1494
|
+
}
|
|
1495
|
+
resultBlockNumbers.add(frame[1]);
|
|
1496
|
+
} else {
|
|
1497
|
+
for (let i = frame[0]; i <= frame[1]; i++) {
|
|
1498
|
+
resultBlockNumbers.add(i);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
if (resultBlockNumbers.size >= max) {
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
return [
|
|
1506
|
+
...resultBlockNumbers
|
|
1507
|
+
].toSorted((a, b) => b - a).slice(0, max);
|
|
1508
|
+
}
|
|
1509
|
+
};
|
|
1510
|
+
|
|
1393
1511
|
// src/simple/client/SimpleXyoClient.ts
|
|
1394
1512
|
var SimpleXyoClient = class {
|
|
1395
1513
|
static {
|
|
@@ -1508,14 +1626,14 @@ var SimpleXyoGateway = class {
|
|
|
1508
1626
|
};
|
|
1509
1627
|
|
|
1510
1628
|
// src/simple/gateway/SimpleXyoGatewayRunner.ts
|
|
1511
|
-
import { assertEx as
|
|
1629
|
+
import { assertEx as assertEx12 } from "@xylabs/assert";
|
|
1512
1630
|
import { BigIntToJsonZod } from "@xylabs/hex";
|
|
1513
|
-
import { isDefined as
|
|
1631
|
+
import { isDefined as isDefined10 } from "@xylabs/typeof";
|
|
1514
1632
|
import { PayloadBuilder as PayloadBuilder10 } from "@xyo-network/payload-builder";
|
|
1515
|
-
import { TransferSchema } from "@xyo-network/xl1-protocol";
|
|
1633
|
+
import { TransferSchema as TransferSchema2 } from "@xyo-network/xl1-protocol";
|
|
1516
1634
|
|
|
1517
1635
|
// src/transaction/buildTransaction.ts
|
|
1518
|
-
import { assertEx as
|
|
1636
|
+
import { assertEx as assertEx8 } from "@xylabs/assert";
|
|
1519
1637
|
import { toHex as toHex2 } from "@xylabs/hex";
|
|
1520
1638
|
import { BoundWitnessBuilder } from "@xyo-network/boundwitness-builder";
|
|
1521
1639
|
import { PayloadBuilder as PayloadBuilder5 } from "@xyo-network/payload-builder";
|
|
@@ -1542,7 +1660,7 @@ async function buildTransaction(chain, onChainPayloads, offChainPayloads, signer
|
|
|
1542
1660
|
}
|
|
1543
1661
|
const fields = {
|
|
1544
1662
|
...txBoundWitnessFields,
|
|
1545
|
-
from: from ?? (Array.isArray(signer) ?
|
|
1663
|
+
from: from ?? (Array.isArray(signer) ? assertEx8(signer.at(0)?.address) : signer.address)
|
|
1546
1664
|
};
|
|
1547
1665
|
if (script.length > 0) {
|
|
1548
1666
|
fields.script = script;
|
|
@@ -1606,7 +1724,7 @@ __name(buildUnsignedTransaction, "buildUnsignedTransaction");
|
|
|
1606
1724
|
|
|
1607
1725
|
// src/transaction/confirmSubmittedTransaction.ts
|
|
1608
1726
|
import { delay } from "@xylabs/delay";
|
|
1609
|
-
import { isDefined as
|
|
1727
|
+
import { isDefined as isDefined9 } from "@xylabs/typeof";
|
|
1610
1728
|
import { PayloadBuilder as PayloadBuilder7 } from "@xyo-network/payload-builder";
|
|
1611
1729
|
var DEFAULT_CONFIRMATION_ATTEMPTS = 20;
|
|
1612
1730
|
var DEFAULT_DELAY_BETWEEN_ATTEMPTS = 1e3;
|
|
@@ -1617,7 +1735,7 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, transact
|
|
|
1617
1735
|
let attempts = 0;
|
|
1618
1736
|
while (true) {
|
|
1619
1737
|
const tx = await viewer.transactionByHash(txBWHash) ?? void 0;
|
|
1620
|
-
if (
|
|
1738
|
+
if (isDefined9(tx)) {
|
|
1621
1739
|
options?.logger?.log("\u2705 Transaction confirmed:", txBWHash, "\n");
|
|
1622
1740
|
return tx;
|
|
1623
1741
|
} else {
|
|
@@ -1634,7 +1752,7 @@ var confirmSubmittedTransaction = /* @__PURE__ */ __name(async (viewer, transact
|
|
|
1634
1752
|
}, "confirmSubmittedTransaction");
|
|
1635
1753
|
|
|
1636
1754
|
// src/transaction/hydrateTransaction.ts
|
|
1637
|
-
import { assertEx as
|
|
1755
|
+
import { assertEx as assertEx9 } from "@xylabs/assert";
|
|
1638
1756
|
import { hydrateTypedBoundWitness, tryHydrateTypedBoundWitness } from "@xyo-network/archivist-model";
|
|
1639
1757
|
import { isAllowedBlockPayload as isAllowedBlockPayload2, isSignedTransactionBoundWitnessWithStorageMeta } from "@xyo-network/xl1-protocol";
|
|
1640
1758
|
var tryHydrateTransaction = /* @__PURE__ */ __name(async ({ chainMap }, hash) => {
|
|
@@ -1693,7 +1811,7 @@ var tryHydrateElevatedTransaction = /* @__PURE__ */ __name(async ({ chainMap },
|
|
|
1693
1811
|
return void 0;
|
|
1694
1812
|
}, "tryHydrateElevatedTransaction");
|
|
1695
1813
|
var hydrateElevatedTransaction = /* @__PURE__ */ __name(async (context, hash) => {
|
|
1696
|
-
return
|
|
1814
|
+
return assertEx9(await tryHydrateElevatedTransaction(context, hash), () => "Hydration failed");
|
|
1697
1815
|
}, "hydrateElevatedTransaction");
|
|
1698
1816
|
|
|
1699
1817
|
// src/transaction/primitives/transactionBlockByteCount.ts
|
|
@@ -1740,26 +1858,26 @@ function transactionElevatedPayloads([transaction, payloads]) {
|
|
|
1740
1858
|
__name(transactionElevatedPayloads, "transactionElevatedPayloads");
|
|
1741
1859
|
|
|
1742
1860
|
// src/transaction/primitives/transactionRequiredGas.ts
|
|
1743
|
-
import { AttoXL1, TransactionGasCosts } from "@xyo-network/xl1-protocol";
|
|
1861
|
+
import { AttoXL1 as AttoXL12, TransactionGasCosts } from "@xyo-network/xl1-protocol";
|
|
1744
1862
|
function transactionBytesRequiredGas([transaction, payloads]) {
|
|
1745
1863
|
const transactionBlockBytes = transactionBlockByteCount([
|
|
1746
1864
|
transaction,
|
|
1747
1865
|
payloads
|
|
1748
1866
|
]);
|
|
1749
|
-
return
|
|
1867
|
+
return AttoXL12(TransactionGasCosts.characterStorage * BigInt(transactionBlockBytes));
|
|
1750
1868
|
}
|
|
1751
1869
|
__name(transactionBytesRequiredGas, "transactionBytesRequiredGas");
|
|
1752
1870
|
function transactionRequiredGas(hydratedTransaction) {
|
|
1753
1871
|
const elevatedPayloads2 = transactionElevatedPayloads(hydratedTransaction);
|
|
1754
1872
|
const hashes = elevatedPayloads2.length + 1;
|
|
1755
1873
|
const signatures = hydratedTransaction[0].addresses.length;
|
|
1756
|
-
return
|
|
1874
|
+
return AttoXL12(transactionBytesRequiredGas(hydratedTransaction) + TransactionGasCosts.hashValidation * BigInt(hashes) + TransactionGasCosts.signatureValidation * BigInt(signatures) + TransactionGasCosts.payloadValidation * BigInt(elevatedPayloads2.length));
|
|
1757
1875
|
}
|
|
1758
1876
|
__name(transactionRequiredGas, "transactionRequiredGas");
|
|
1759
1877
|
|
|
1760
1878
|
// src/transaction/script.ts
|
|
1761
1879
|
import { filterAs as filterAs2 } from "@xylabs/array";
|
|
1762
|
-
import { assertEx as
|
|
1880
|
+
import { assertEx as assertEx10 } from "@xylabs/assert";
|
|
1763
1881
|
import { asHash as asHash4 } from "@xylabs/hex";
|
|
1764
1882
|
import { isAllowedBlockPayloadWithHashMeta } from "@xyo-network/xl1-protocol";
|
|
1765
1883
|
var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
@@ -1769,7 +1887,7 @@ var tryExtractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
|
1769
1887
|
var extractElevatedHashesFromScript = /* @__PURE__ */ __name((strings) => {
|
|
1770
1888
|
const hashes = strings.filter((str) => str.startsWith("elevate|")).map((str) => str.split("|")[1]);
|
|
1771
1889
|
const filtered = filterAs2(hashes, (h) => asHash4(h));
|
|
1772
|
-
|
|
1890
|
+
assertEx10(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
1773
1891
|
return filtered;
|
|
1774
1892
|
}, "extractElevatedHashesFromScript");
|
|
1775
1893
|
var tryExtractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
@@ -1783,17 +1901,17 @@ var extractElevatedHashes = /* @__PURE__ */ __name((tx) => {
|
|
|
1783
1901
|
const { script } = bw;
|
|
1784
1902
|
const hashes = script ? tryExtractElevatedHashesFromScript(script) : [];
|
|
1785
1903
|
const filtered = payloads.filter((p) => hashes.includes(p._hash)).filter(isAllowedBlockPayloadWithHashMeta);
|
|
1786
|
-
|
|
1904
|
+
assertEx10(filtered.length === hashes.length, () => "Invalid elevated hashes");
|
|
1787
1905
|
return filtered;
|
|
1788
1906
|
}, "extractElevatedHashes");
|
|
1789
1907
|
|
|
1790
1908
|
// src/transaction/signTransaction.ts
|
|
1791
1909
|
import { toArrayBuffer } from "@xylabs/arraybuffer";
|
|
1792
|
-
import { assertEx as
|
|
1910
|
+
import { assertEx as assertEx11 } from "@xylabs/assert";
|
|
1793
1911
|
import { hexFromArrayBuffer } from "@xylabs/hex";
|
|
1794
1912
|
import { PayloadBuilder as PayloadBuilder9 } from "@xyo-network/payload-builder";
|
|
1795
1913
|
async function signTransaction(tx, account) {
|
|
1796
|
-
|
|
1914
|
+
assertEx11(tx.from === account.address, () => "Signer address does not match transaction from address");
|
|
1797
1915
|
const signedTx = structuredClone(tx);
|
|
1798
1916
|
signedTx.addresses = [
|
|
1799
1917
|
account.address
|
|
@@ -1838,24 +1956,24 @@ var SimpleXyoGatewayRunner = class {
|
|
|
1838
1956
|
return this._dataLakes.length - 1;
|
|
1839
1957
|
}
|
|
1840
1958
|
async addPayloadsToChain(onChain, offChain, options) {
|
|
1841
|
-
const viewer =
|
|
1959
|
+
const viewer = assertEx12(this.connectionInstance.viewer, () => "No viewer available on connection");
|
|
1842
1960
|
const { nbf, exp, chain, fees } = options ?? {};
|
|
1843
|
-
const resolvedChainId =
|
|
1844
|
-
const resolvedNbf =
|
|
1845
|
-
const resolvedExp =
|
|
1961
|
+
const resolvedChainId = isDefined10(chain) ? chain : await viewer.chainId();
|
|
1962
|
+
const resolvedNbf = isDefined10(nbf) ? nbf : await viewer?.currentBlockNumber();
|
|
1963
|
+
const resolvedExp = isDefined10(exp) ? exp : resolvedNbf + 10;
|
|
1846
1964
|
const tx = await buildUnsignedTransaction(resolvedChainId, onChain, offChain, resolvedNbf, resolvedExp, await (await this.signer()).address(), fees);
|
|
1847
1965
|
return await this.addTransactionToChain(tx);
|
|
1848
1966
|
}
|
|
1849
1967
|
async addTransactionToChain(tx) {
|
|
1850
1968
|
const connection = await this.gateway.connection();
|
|
1851
1969
|
const signer = await this.gateway.signer();
|
|
1852
|
-
const runner =
|
|
1970
|
+
const runner = assertEx12(connection.runner, () => "No runner available on connection");
|
|
1853
1971
|
const signedTx = await signer.signTransaction(tx);
|
|
1854
1972
|
await this.addPayloadsToDataLakes(signedTx[1]);
|
|
1855
1973
|
return [
|
|
1856
1974
|
await runner.broadcastTransaction([
|
|
1857
|
-
|
|
1858
|
-
|
|
1975
|
+
signedTx[0],
|
|
1976
|
+
signedTx[1]
|
|
1859
1977
|
]),
|
|
1860
1978
|
signedTx
|
|
1861
1979
|
];
|
|
@@ -1879,7 +1997,7 @@ var SimpleXyoGatewayRunner = class {
|
|
|
1879
1997
|
BigIntToJsonZod.parse(amount)
|
|
1880
1998
|
]));
|
|
1881
1999
|
const transfer = new PayloadBuilder10({
|
|
1882
|
-
schema:
|
|
2000
|
+
schema: TransferSchema2
|
|
1883
2001
|
}).fields({
|
|
1884
2002
|
from,
|
|
1885
2003
|
transfers: hexTransfers,
|
|
@@ -1976,7 +2094,7 @@ var SimpleXyoNetwork = class {
|
|
|
1976
2094
|
};
|
|
1977
2095
|
|
|
1978
2096
|
// src/simple/permissions/SimpleXyoPermissions.ts
|
|
1979
|
-
import { assertEx as
|
|
2097
|
+
import { assertEx as assertEx13 } from "@xylabs/assert";
|
|
1980
2098
|
var SimpleXyoPermissions = class {
|
|
1981
2099
|
static {
|
|
1982
2100
|
__name(this, "SimpleXyoPermissions");
|
|
@@ -1988,7 +2106,7 @@ var SimpleXyoPermissions = class {
|
|
|
1988
2106
|
this.invoker = store.invoker;
|
|
1989
2107
|
}
|
|
1990
2108
|
get store() {
|
|
1991
|
-
return
|
|
2109
|
+
return assertEx13(this._store, () => "Store must be defined to get permissions");
|
|
1992
2110
|
}
|
|
1993
2111
|
async getPermissions() {
|
|
1994
2112
|
return await this.store.getPermissions();
|
|
@@ -2046,7 +2164,7 @@ var SimpleXyoPermissions = class {
|
|
|
2046
2164
|
};
|
|
2047
2165
|
|
|
2048
2166
|
// src/simple/permissions/store/MemoryPermissions.ts
|
|
2049
|
-
import { assertEx as
|
|
2167
|
+
import { assertEx as assertEx14 } from "@xylabs/assert";
|
|
2050
2168
|
var MemoryPermissionsStore = class {
|
|
2051
2169
|
static {
|
|
2052
2170
|
__name(this, "MemoryPermissionsStore");
|
|
@@ -2057,7 +2175,7 @@ var MemoryPermissionsStore = class {
|
|
|
2057
2175
|
this._invoker = invoker;
|
|
2058
2176
|
}
|
|
2059
2177
|
get invoker() {
|
|
2060
|
-
return
|
|
2178
|
+
return assertEx14(this._invoker, () => "Invoker must be defined to get permissions");
|
|
2061
2179
|
}
|
|
2062
2180
|
async getPermissions() {
|
|
2063
2181
|
await Promise.resolve();
|
|
@@ -2122,19 +2240,129 @@ var SimpleXyoSigner = class {
|
|
|
2122
2240
|
}
|
|
2123
2241
|
};
|
|
2124
2242
|
|
|
2243
|
+
// src/simple/timesync/SimpleTimeSyncViewer.ts
|
|
2244
|
+
import { assertEx as assertEx15 } from "@xylabs/assert";
|
|
2245
|
+
import { asHash as asHash5 } from "@xylabs/hex";
|
|
2246
|
+
import { isDefined as isDefined11 } from "@xylabs/typeof";
|
|
2247
|
+
import { asTimePayload, asXL1BlockNumber as asXL1BlockNumber5, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
2248
|
+
var SimpleTimeSyncViewer = class {
|
|
2249
|
+
static {
|
|
2250
|
+
__name(this, "SimpleTimeSyncViewer");
|
|
2251
|
+
}
|
|
2252
|
+
blockViewer;
|
|
2253
|
+
ethProvider;
|
|
2254
|
+
constructor(blockViewer, ethProvider) {
|
|
2255
|
+
this.blockViewer = blockViewer;
|
|
2256
|
+
this.ethProvider = ethProvider;
|
|
2257
|
+
}
|
|
2258
|
+
async convertTime(fromDomain, toDomain, from) {
|
|
2259
|
+
switch (fromDomain) {
|
|
2260
|
+
case "xl1": {
|
|
2261
|
+
const [block, payloads] = assertEx15(await this.blockViewer.blockByNumber(asXL1BlockNumber5(from, true)), () => "Block not found");
|
|
2262
|
+
const timeSchemaIndex = block.payload_schemas.indexOf(TimeSchema);
|
|
2263
|
+
const hash = timeSchemaIndex === -1 ? void 0 : block.payload_hashes[timeSchemaIndex];
|
|
2264
|
+
const timePayload = asTimePayload(isDefined11(hash) ? payloads.find((p) => p._hash === hash) : void 0);
|
|
2265
|
+
if (timePayload === void 0) return 0;
|
|
2266
|
+
switch (toDomain) {
|
|
2267
|
+
case "xl1": {
|
|
2268
|
+
return timePayload.xl1 ?? 0;
|
|
2269
|
+
}
|
|
2270
|
+
case "epoch": {
|
|
2271
|
+
return timePayload.epoch ?? 0;
|
|
2272
|
+
}
|
|
2273
|
+
case "ethereum": {
|
|
2274
|
+
return timePayload.ethereum ?? 0;
|
|
2275
|
+
}
|
|
2276
|
+
default: {
|
|
2277
|
+
throw new Error(`Unsupported to toDomain: ${toDomain}`);
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
default: {
|
|
2282
|
+
throw new Error(`Unsupported from fromDomain: ${fromDomain}`);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
async currentTime(domain) {
|
|
2287
|
+
switch (domain) {
|
|
2288
|
+
case "xl1": {
|
|
2289
|
+
return [
|
|
2290
|
+
"xl1",
|
|
2291
|
+
(await this.blockViewer.currentBlock())?.[0].block ?? -1
|
|
2292
|
+
];
|
|
2293
|
+
}
|
|
2294
|
+
case "epoch": {
|
|
2295
|
+
return [
|
|
2296
|
+
"epoch",
|
|
2297
|
+
Date.now()
|
|
2298
|
+
];
|
|
2299
|
+
}
|
|
2300
|
+
case "ethereum": {
|
|
2301
|
+
return [
|
|
2302
|
+
"ethereum",
|
|
2303
|
+
await this.ethProvider?.getBlockNumber() ?? 0
|
|
2304
|
+
];
|
|
2305
|
+
}
|
|
2306
|
+
default: {
|
|
2307
|
+
throw new Error(`Unknown time domain: ${domain}`);
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
async currentTimeAndHash(domain) {
|
|
2312
|
+
switch (domain) {
|
|
2313
|
+
case "xl1": {
|
|
2314
|
+
const [head] = await this.blockViewer.currentBlock();
|
|
2315
|
+
return [
|
|
2316
|
+
head.block,
|
|
2317
|
+
head._hash
|
|
2318
|
+
];
|
|
2319
|
+
}
|
|
2320
|
+
case "epoch": {
|
|
2321
|
+
return [
|
|
2322
|
+
Date.now(),
|
|
2323
|
+
null
|
|
2324
|
+
];
|
|
2325
|
+
}
|
|
2326
|
+
case "ethereum": {
|
|
2327
|
+
const provider = assertEx15(this.ethProvider, () => "Ethereum provider not configured");
|
|
2328
|
+
const blockNumber = await provider.getBlockNumber() ?? 0;
|
|
2329
|
+
const block = await provider.getBlock(blockNumber);
|
|
2330
|
+
const blockHash = asHash5(assertEx15(block?.hash, () => "Block hash not found"), true);
|
|
2331
|
+
return [
|
|
2332
|
+
blockNumber,
|
|
2333
|
+
blockHash
|
|
2334
|
+
];
|
|
2335
|
+
}
|
|
2336
|
+
default: {
|
|
2337
|
+
throw new Error(`Unknown time domain: ${domain}`);
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
currentTimePayload() {
|
|
2342
|
+
throw new Error("Method not implemented.");
|
|
2343
|
+
}
|
|
2344
|
+
};
|
|
2345
|
+
|
|
2125
2346
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
2126
|
-
import { assertEx as
|
|
2127
|
-
import { asTimePayload, TimeSchema } from "@xyo-network/xl1-protocol";
|
|
2347
|
+
import { assertEx as assertEx16 } from "@xylabs/assert";
|
|
2348
|
+
import { asTimePayload as asTimePayload2, TimeSchema as TimeSchema2 } from "@xyo-network/xl1-protocol";
|
|
2128
2349
|
async function xl1BlockNumberToEthBlockNumber(context, xl1BlockNumber) {
|
|
2129
2350
|
const blockHash = await hashFromBlockNumber(context, xl1BlockNumber);
|
|
2130
2351
|
const hydratedBlock = await hydrateBlock(context.store, blockHash);
|
|
2131
|
-
const timePayload =
|
|
2352
|
+
const timePayload = asTimePayload2(hydratedBlock[1].find((p) => p.schema === TimeSchema2), {
|
|
2132
2353
|
required: true
|
|
2133
2354
|
});
|
|
2134
|
-
return
|
|
2355
|
+
return assertEx16(timePayload.ethereum, () => "No ethereum timestamp found on block");
|
|
2135
2356
|
}
|
|
2136
2357
|
__name(xl1BlockNumberToEthBlockNumber, "xl1BlockNumberToEthBlockNumber");
|
|
2137
2358
|
|
|
2359
|
+
// src/viewers/StakeEvents.ts
|
|
2360
|
+
var StakeEventNames = [
|
|
2361
|
+
"StakeAdded",
|
|
2362
|
+
"StakeRemoved",
|
|
2363
|
+
"StakeWithdrawn"
|
|
2364
|
+
];
|
|
2365
|
+
|
|
2138
2366
|
// src/wallet/generateXyoBaseWalletFromPhrase.ts
|
|
2139
2367
|
import { HDWallet } from "@xyo-network/wallet";
|
|
2140
2368
|
|
|
@@ -2186,8 +2414,10 @@ export {
|
|
|
2186
2414
|
MemoryPermissionsStore,
|
|
2187
2415
|
MnemonicStringZod,
|
|
2188
2416
|
RewardMultipliers,
|
|
2417
|
+
SimpleAccountBalanceViewer,
|
|
2189
2418
|
SimpleDataLakeRunner,
|
|
2190
2419
|
SimpleDataLakeViewer,
|
|
2420
|
+
SimpleTimeSyncViewer,
|
|
2191
2421
|
SimpleXyoClient,
|
|
2192
2422
|
SimpleXyoGateway,
|
|
2193
2423
|
SimpleXyoGatewayRunner,
|