@xyo-network/xl1-protocol-sdk 1.15.8 → 1.15.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/balances/balancesStepSummaryFromRange.d.ts +2 -2
- package/dist/neutral/block/primitives/balances/balancesStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/block/primitives/blockFromBlockNumber.d.ts +2 -2
- package/dist/neutral/block/primitives/blockFromBlockNumber.d.ts.map +1 -1
- package/dist/neutral/block/primitives/frames/calculateFramesFromRange.d.ts +4 -4
- package/dist/neutral/block/primitives/frames/calculateFramesFromRange.d.ts.map +1 -1
- package/dist/neutral/block/primitives/frames/deepCalculateFramesFromRange.d.ts +2 -2
- package/dist/neutral/block/primitives/frames/deepCalculateFramesFromRange.d.ts.map +1 -1
- package/dist/neutral/block/primitives/frames/index.d.ts +0 -1
- package/dist/neutral/block/primitives/frames/index.d.ts.map +1 -1
- package/dist/neutral/block/primitives/hashFromBlockNumber.d.ts +2 -1
- package/dist/neutral/block/primitives/hashFromBlockNumber.d.ts.map +1 -1
- package/dist/neutral/block/primitives/transfers/transfersStepSummaryFromRange.d.ts +2 -2
- package/dist/neutral/block/primitives/transfers/transfersStepSummaryFromRange.d.ts.map +1 -1
- package/dist/neutral/config/Config.d.ts +16 -0
- package/dist/neutral/config/Config.d.ts.map +1 -1
- package/dist/neutral/config/RewardRedemptionApi.d.ts +8 -0
- package/dist/neutral/config/RewardRedemptionApi.d.ts.map +1 -0
- package/dist/neutral/config/Validation.d.ts +14 -0
- package/dist/neutral/config/Validation.d.ts.map +1 -0
- package/dist/neutral/constants.d.ts +3 -0
- package/dist/neutral/constants.d.ts.map +1 -0
- package/dist/neutral/index.d.ts +2 -1
- package/dist/neutral/index.d.ts.map +1 -1
- package/dist/neutral/index.mjs +119 -202
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/neutral/multipliers.d.ts +6 -0
- package/dist/neutral/multipliers.d.ts.map +1 -0
- package/dist/neutral/time/primitives/xl1BlockNumberToEthBlockNumber.d.ts +2 -1
- package/dist/neutral/time/primitives/xl1BlockNumberToEthBlockNumber.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/block/primitives/balances/balancesStepSummaryFromRange.ts +2 -2
- package/src/block/primitives/balances/balancesSummary.ts +3 -3
- package/src/block/primitives/blockFromBlockNumber.ts +5 -2
- package/src/block/primitives/frames/calculateFramesFromRange.ts +10 -11
- package/src/block/primitives/frames/deepCalculateFramesFromRange.ts +5 -5
- package/src/block/primitives/frames/index.ts +0 -1
- package/src/block/primitives/frames/spec/calculateFramesFromRange.spec.ts +10 -7
- package/src/block/primitives/frames/spec/deepCalculateFramesFromRange.spec.ts +10 -10
- package/src/block/primitives/hashFromBlockNumber.ts +2 -1
- package/src/block/primitives/transfers/transfersStepSummaryFromRange.ts +3 -2
- package/src/block/primitives/transfers/transfersSummary.ts +3 -3
- package/src/config/Config.ts +4 -0
- package/src/config/RewardRedemptionApi.ts +26 -0
- package/src/config/Validation.ts +19 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +2 -1
- package/src/multipliers.ts +14 -0
- package/src/time/primitives/xl1BlockNumberToEthBlockNumber.ts +2 -1
- package/dist/neutral/block/primitives/frames/BlockNumberRange.d.ts +0 -2
- package/dist/neutral/block/primitives/frames/BlockNumberRange.d.ts.map +0 -1
- package/dist/neutral/steps/index.d.ts +0 -2
- package/dist/neutral/steps/index.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/addressStakeWeight.d.ts +0 -4
- package/dist/neutral/steps/primitives/addressStakeWeight.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/claimedRewards.d.ts +0 -3
- package/dist/neutral/steps/primitives/claimedRewards.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/index.d.ts +0 -7
- package/dist/neutral/steps/primitives/index.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/stakersAsOfBlock.d.ts +0 -4
- package/dist/neutral/steps/primitives/stakersAsOfBlock.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/startingStakes.d.ts +0 -4
- package/dist/neutral/steps/primitives/startingStakes.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/totalStakeWeight.d.ts +0 -4
- package/dist/neutral/steps/primitives/totalStakeWeight.d.ts.map +0 -1
- package/dist/neutral/steps/primitives/unclaimedRewards.d.ts +0 -4
- package/dist/neutral/steps/primitives/unclaimedRewards.d.ts.map +0 -1
- package/src/block/primitives/frames/BlockNumberRange.ts +0 -1
- package/src/steps/index.ts +0 -1
- package/src/steps/primitives/addressStakeWeight.ts +0 -51
- package/src/steps/primitives/claimedRewards.ts +0 -5
- package/src/steps/primitives/index.ts +0 -6
- package/src/steps/primitives/stakersAsOfBlock.ts +0 -18
- package/src/steps/primitives/startingStakes.ts +0 -30
- package/src/steps/primitives/totalStakeWeight.ts +0 -35
- package/src/steps/primitives/unclaimedRewards.ts +0 -6
package/dist/neutral/index.mjs
CHANGED
|
@@ -126,7 +126,7 @@ var toPositiveBigInt = /* @__PURE__ */ __name((value) => {
|
|
|
126
126
|
}, "toPositiveBigInt");
|
|
127
127
|
|
|
128
128
|
// src/block/primitives/frames/calculateFramesFromRange.ts
|
|
129
|
-
import { stepSize } from "@xyo-network/xl1-protocol";
|
|
129
|
+
import { asXL1BlockNumber, stepSize } from "@xyo-network/xl1-protocol";
|
|
130
130
|
function calculateFramesFromRange(range, step) {
|
|
131
131
|
const size = stepSize(step);
|
|
132
132
|
let start = Math.trunc(range[0] / size) * size;
|
|
@@ -136,18 +136,18 @@ function calculateFramesFromRange(range, step) {
|
|
|
136
136
|
start += size;
|
|
137
137
|
remaining.push([
|
|
138
138
|
range[0],
|
|
139
|
-
Math.min(start - 1, range[1])
|
|
139
|
+
asXL1BlockNumber(Math.min(start - 1, range[1]))
|
|
140
140
|
]);
|
|
141
141
|
}
|
|
142
142
|
for (let i = start; i <= range[1]; i += size) {
|
|
143
143
|
if (i + size - 1 <= range[1]) {
|
|
144
144
|
fitted.push([
|
|
145
|
-
i,
|
|
146
|
-
Math.min(i + size - 1, range[1])
|
|
145
|
+
asXL1BlockNumber(i),
|
|
146
|
+
asXL1BlockNumber(Math.min(i + size - 1, range[1]))
|
|
147
147
|
]);
|
|
148
148
|
} else {
|
|
149
149
|
remaining.push([
|
|
150
|
-
i,
|
|
150
|
+
asXL1BlockNumber(i),
|
|
151
151
|
range[1]
|
|
152
152
|
]);
|
|
153
153
|
}
|
|
@@ -197,6 +197,9 @@ async function blockFromBlockNumber(context, blockNumber) {
|
|
|
197
197
|
let currentBlock = asBlockBoundWitnessWithStorageMeta(result, () => `Head block not found for hash: ${head}`, {
|
|
198
198
|
required: true
|
|
199
199
|
});
|
|
200
|
+
if (currentBlock.block < blockNumber) {
|
|
201
|
+
throw new Error(`Error: Block number ${blockNumber} is greater than head ${currentBlock.block}.`);
|
|
202
|
+
}
|
|
200
203
|
while (currentBlock.block > blockNumber) {
|
|
201
204
|
let jumpHash = currentBlock.previous;
|
|
202
205
|
let jumpBlockNumber = currentBlock.block - 1;
|
|
@@ -315,7 +318,7 @@ __name(balancesStepSummaryFromRange, "balancesStepSummaryFromRange");
|
|
|
315
318
|
import { asAddress } from "@xylabs/hex";
|
|
316
319
|
import { spanRootAsync } from "@xylabs/telemetry";
|
|
317
320
|
import { isDefined } from "@xylabs/typeof";
|
|
318
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2 } from "@xyo-network/xl1-protocol";
|
|
321
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta2, asXL1BlockNumber as asXL1BlockNumber2 } from "@xyo-network/xl1-protocol";
|
|
319
322
|
async function balancesSummary(context) {
|
|
320
323
|
return await spanRootAsync("balanceSummary", async () => {
|
|
321
324
|
const head = await context.head();
|
|
@@ -323,10 +326,10 @@ async function balancesSummary(context) {
|
|
|
323
326
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta2(headResult, () => `Head block not found for hash: ${context.head}`, {
|
|
324
327
|
required: true
|
|
325
328
|
});
|
|
326
|
-
const rangeStart = isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0;
|
|
329
|
+
const rangeStart = asXL1BlockNumber2(isDefined(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0);
|
|
327
330
|
const ranges = deepCalculateFramesFromRange([
|
|
328
331
|
rangeStart,
|
|
329
|
-
headBoundWitness.block
|
|
332
|
+
asXL1BlockNumber2(headBoundWitness.block)
|
|
330
333
|
]);
|
|
331
334
|
const summaries = await Promise.all(ranges.map((range) => balancesStepSummaryFromRange(context, range)));
|
|
332
335
|
const balances = {};
|
|
@@ -422,7 +425,7 @@ __name(transfersStepSummaryFromRange, "transfersStepSummaryFromRange");
|
|
|
422
425
|
import { asAddress as asAddress2 } from "@xylabs/hex";
|
|
423
426
|
import { spanRootAsync as spanRootAsync2 } from "@xylabs/telemetry";
|
|
424
427
|
import { isDefined as isDefined2 } from "@xylabs/typeof";
|
|
425
|
-
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3 } from "@xyo-network/xl1-protocol";
|
|
428
|
+
import { asBlockBoundWitnessWithStorageMeta as asBlockBoundWitnessWithStorageMeta3, asXL1BlockNumber as asXL1BlockNumber3 } from "@xyo-network/xl1-protocol";
|
|
426
429
|
async function transfersSummary(context) {
|
|
427
430
|
return await spanRootAsync2("transferSummary", async () => {
|
|
428
431
|
const head = await context.head();
|
|
@@ -430,10 +433,10 @@ async function transfersSummary(context) {
|
|
|
430
433
|
const headBoundWitness = asBlockBoundWitnessWithStorageMeta3(headResult, () => `Head block not found for hash: ${context.head}`, {
|
|
431
434
|
required: true
|
|
432
435
|
});
|
|
433
|
-
const rangeStart = isDefined2(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0;
|
|
436
|
+
const rangeStart = asXL1BlockNumber3(isDefined2(context.windowSize) ? Math.max(headBoundWitness.block - context.windowSize + 1, 0) : 0);
|
|
434
437
|
const ranges = deepCalculateFramesFromRange([
|
|
435
438
|
rangeStart,
|
|
436
|
-
headBoundWitness.block
|
|
439
|
+
asXL1BlockNumber3(headBoundWitness.block)
|
|
437
440
|
]);
|
|
438
441
|
const summaries = await Promise.all(ranges.map((range) => transfersStepSummaryFromRange(context, range)));
|
|
439
442
|
const transfers = {};
|
|
@@ -553,7 +556,7 @@ var tryHydrateBlock = /* @__PURE__ */ __name(async (archivist, hash, maxDepth =
|
|
|
553
556
|
}, "tryHydrateBlock");
|
|
554
557
|
|
|
555
558
|
// src/config/Config.ts
|
|
556
|
-
import * as
|
|
559
|
+
import * as z14 from "zod";
|
|
557
560
|
|
|
558
561
|
// src/config/Api.ts
|
|
559
562
|
import { globalRegistry } from "zod";
|
|
@@ -762,37 +765,60 @@ var ProducerConfigZod = z8.object({
|
|
|
762
765
|
})
|
|
763
766
|
});
|
|
764
767
|
|
|
765
|
-
// src/config/
|
|
766
|
-
import { isDefined as isDefined4, isUndefined } from "@xylabs/typeof";
|
|
768
|
+
// src/config/RewardRedemptionApi.ts
|
|
767
769
|
import { globalRegistry as globalRegistry8 } from "zod";
|
|
768
770
|
import * as z9 from "zod";
|
|
771
|
+
var RewardRedemptionApiConfigZod = z9.object({
|
|
772
|
+
host: z9.string().default("localhost").register(globalRegistry8, {
|
|
773
|
+
default: "localhost",
|
|
774
|
+
description: "Host for the Redemption API",
|
|
775
|
+
title: "redemption.host",
|
|
776
|
+
type: "string"
|
|
777
|
+
}),
|
|
778
|
+
mnemonic: MnemonicStringZod.optional().register(globalRegistry8, {
|
|
779
|
+
description: "Mnemonic for the Redemption API wallet",
|
|
780
|
+
title: "redemption.mnemonic",
|
|
781
|
+
type: "string"
|
|
782
|
+
}),
|
|
783
|
+
port: z9.coerce.number().default(8082).register(globalRegistry8, {
|
|
784
|
+
default: 8082,
|
|
785
|
+
description: "Port for the Redemption API",
|
|
786
|
+
title: "redemption.port",
|
|
787
|
+
type: "number"
|
|
788
|
+
})
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
// src/config/storage/driver/Mongo.ts
|
|
792
|
+
import { isDefined as isDefined4, isUndefined } from "@xylabs/typeof";
|
|
793
|
+
import { globalRegistry as globalRegistry9 } from "zod";
|
|
794
|
+
import * as z10 from "zod";
|
|
769
795
|
var hasMongoConfig = /* @__PURE__ */ __name((config) => {
|
|
770
796
|
if (isUndefined(config)) return false;
|
|
771
797
|
return isDefined4(config.connectionString) && isDefined4(config.database) && isDefined4(config.domain) && isDefined4(config.password) && isDefined4(config.username);
|
|
772
798
|
}, "hasMongoConfig");
|
|
773
|
-
var MongoConfigZod =
|
|
799
|
+
var MongoConfigZod = z10.object({
|
|
774
800
|
// TODO: Create from other arguments
|
|
775
|
-
connectionString:
|
|
801
|
+
connectionString: z10.string().min(1).optional().register(globalRegistry9, {
|
|
776
802
|
description: "MongoDB connection string",
|
|
777
803
|
title: "storage.mongo.connectionString",
|
|
778
804
|
type: "string"
|
|
779
805
|
}),
|
|
780
|
-
database:
|
|
806
|
+
database: z10.string().min(1).optional().register(globalRegistry9, {
|
|
781
807
|
description: "MongoDB database name",
|
|
782
808
|
title: "storage.mongo.database",
|
|
783
809
|
type: "string"
|
|
784
810
|
}),
|
|
785
|
-
domain:
|
|
811
|
+
domain: z10.string().min(1).optional().register(globalRegistry9, {
|
|
786
812
|
description: "MongoDB domain",
|
|
787
813
|
title: "storage.mongo.domain",
|
|
788
814
|
type: "string"
|
|
789
815
|
}),
|
|
790
|
-
password:
|
|
816
|
+
password: z10.string().min(1).optional().register(globalRegistry9, {
|
|
791
817
|
description: "MongoDB password",
|
|
792
818
|
title: "storage.mongo.password",
|
|
793
819
|
type: "string"
|
|
794
820
|
}),
|
|
795
|
-
username:
|
|
821
|
+
username: z10.string().min(1).optional().register(globalRegistry9, {
|
|
796
822
|
description: "MongoDB username",
|
|
797
823
|
title: "storage.mongo.username",
|
|
798
824
|
type: "string"
|
|
@@ -800,11 +826,11 @@ var MongoConfigZod = z9.object({
|
|
|
800
826
|
});
|
|
801
827
|
|
|
802
828
|
// src/config/storage/Storage.ts
|
|
803
|
-
import { globalRegistry as
|
|
804
|
-
import * as
|
|
805
|
-
var StorageConfigZod =
|
|
829
|
+
import { globalRegistry as globalRegistry10 } from "zod";
|
|
830
|
+
import * as z11 from "zod";
|
|
831
|
+
var StorageConfigZod = z11.object({
|
|
806
832
|
mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
|
|
807
|
-
root:
|
|
833
|
+
root: z11.string().optional().register(globalRegistry10, {
|
|
808
834
|
description: "Root directory for local storage",
|
|
809
835
|
title: "storage.root",
|
|
810
836
|
type: "string"
|
|
@@ -812,26 +838,43 @@ var StorageConfigZod = z10.object({
|
|
|
812
838
|
}).describe("Storage configuration options");
|
|
813
839
|
|
|
814
840
|
// src/config/Telemetry.ts
|
|
815
|
-
import { globalRegistry as
|
|
816
|
-
import * as
|
|
817
|
-
var OpenTelemetryConfigZod =
|
|
841
|
+
import { globalRegistry as globalRegistry11 } from "zod";
|
|
842
|
+
import * as z12 from "zod";
|
|
843
|
+
var OpenTelemetryConfigZod = z12.object({
|
|
818
844
|
// OpenTelemetry options
|
|
819
|
-
otlpEndpoint:
|
|
845
|
+
otlpEndpoint: z12.url().optional().register(globalRegistry11, {
|
|
820
846
|
description: "OTLP endpoint for exporting telemetry data",
|
|
821
847
|
title: "telemetry.otel.otlpEndpoint",
|
|
822
848
|
type: "string"
|
|
823
849
|
})
|
|
824
850
|
});
|
|
825
|
-
var TelemetryConfigZod =
|
|
851
|
+
var TelemetryConfigZod = z12.object({
|
|
826
852
|
// OpenTelemetry configuration
|
|
827
853
|
otel: OpenTelemetryConfigZod.optional().describe("OpenTelemetry configuration")
|
|
828
854
|
}).describe("Telemetry configuration options");
|
|
829
855
|
|
|
856
|
+
// src/config/Validation.ts
|
|
857
|
+
import { AddressZod as AddressZod2, asAddress as asAddress4 } from "@xylabs/hex";
|
|
858
|
+
import { globalRegistry as globalRegistry12 } from "zod";
|
|
859
|
+
import * as z13 from "zod";
|
|
860
|
+
var ValidationConfigZod = z13.object({
|
|
861
|
+
allowedRewardRedeemers: z13.preprocess((val) => {
|
|
862
|
+
if (typeof val === "string") {
|
|
863
|
+
return val.split(",").map((s) => asAddress4(s.trim()));
|
|
864
|
+
}
|
|
865
|
+
return val;
|
|
866
|
+
}, z13.array(AddressZod2).optional().register(globalRegistry12, {
|
|
867
|
+
description: "List of allowed reward redeemer addresses, if undefined anyone can participate",
|
|
868
|
+
title: "allowedRewardRedeemers",
|
|
869
|
+
type: "array"
|
|
870
|
+
}))
|
|
871
|
+
});
|
|
872
|
+
|
|
830
873
|
// src/config/Config.ts
|
|
831
|
-
var Xl1CommonConfigSchema =
|
|
874
|
+
var Xl1CommonConfigSchema = z14.object({
|
|
832
875
|
...LogConfigZod.shape
|
|
833
876
|
}).describe("XL1 common configuration options");
|
|
834
|
-
var ConfigZod =
|
|
877
|
+
var ConfigZod = z14.object({
|
|
835
878
|
...Xl1CommonConfigSchema.shape,
|
|
836
879
|
api: ApiConfigZod.default(ApiConfigZod.parse({})).describe("Configuration for the API node"),
|
|
837
880
|
app: AppConfigZod.default(AppConfigZod.parse({})).describe("Configuration for the application"),
|
|
@@ -839,41 +882,43 @@ var ConfigZod = z12.object({
|
|
|
839
882
|
chain: ChainConfigZod.default(ChainConfigZod.parse({})).describe("Configuration for the chain"),
|
|
840
883
|
evm: EvmConfigZod.default(EvmConfigZod.parse({})).describe("Configuration for EVM-backed services"),
|
|
841
884
|
producer: ProducerConfigZod.default(ProducerConfigZod.parse({})).describe("Configuration for the producer"),
|
|
885
|
+
rewardRedemptionApi: RewardRedemptionApiConfigZod.default(RewardRedemptionApiConfigZod.parse({})).describe("Configuration for the rewards redemption API"),
|
|
842
886
|
storage: StorageConfigZod.default(StorageConfigZod.parse({})).describe("Configuration for the storage"),
|
|
843
|
-
telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe("Configuration for telemetry")
|
|
887
|
+
telemetry: TelemetryConfigZod.default(TelemetryConfigZod.parse({})).describe("Configuration for telemetry"),
|
|
888
|
+
validation: ValidationConfigZod.default(ValidationConfigZod.parse({})).describe("Configuration for validation")
|
|
844
889
|
});
|
|
845
890
|
var getDefaultConfig = /* @__PURE__ */ __name(() => ConfigZod.parse({}), "getDefaultConfig");
|
|
846
891
|
|
|
847
892
|
// src/config/UsageMeta.ts
|
|
848
|
-
import * as
|
|
849
|
-
var DescriptionSchema =
|
|
850
|
-
var TitleSchema =
|
|
851
|
-
var JSONSchemaMetaSchema =
|
|
852
|
-
id:
|
|
893
|
+
import * as z15 from "zod";
|
|
894
|
+
var DescriptionSchema = z15.string();
|
|
895
|
+
var TitleSchema = z15.string();
|
|
896
|
+
var JSONSchemaMetaSchema = z15.object({
|
|
897
|
+
id: z15.string().optional(),
|
|
853
898
|
title: TitleSchema.optional(),
|
|
854
899
|
description: DescriptionSchema.optional(),
|
|
855
|
-
deprecated:
|
|
856
|
-
}).catchall(
|
|
900
|
+
deprecated: z15.boolean().optional()
|
|
901
|
+
}).catchall(z15.unknown());
|
|
857
902
|
var GlobalMetaSchema = JSONSchemaMetaSchema.extend({});
|
|
858
|
-
var ChoicesSchema =
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
903
|
+
var ChoicesSchema = z15.array(z15.union([
|
|
904
|
+
z15.string(),
|
|
905
|
+
z15.number(),
|
|
906
|
+
z15.literal(true),
|
|
907
|
+
z15.undefined()
|
|
863
908
|
])).readonly();
|
|
864
909
|
var UsageMetaSchema = GlobalMetaSchema.extend({
|
|
865
910
|
choices: ChoicesSchema.optional(),
|
|
866
|
-
default:
|
|
911
|
+
default: z15.unknown().optional(),
|
|
867
912
|
description: DescriptionSchema,
|
|
868
|
-
group:
|
|
869
|
-
hidden:
|
|
913
|
+
group: z15.string().optional(),
|
|
914
|
+
hidden: z15.boolean().optional(),
|
|
870
915
|
title: TitleSchema,
|
|
871
|
-
type:
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
916
|
+
type: z15.union([
|
|
917
|
+
z15.literal("array"),
|
|
918
|
+
z15.literal("count"),
|
|
919
|
+
z15.literal("boolean"),
|
|
920
|
+
z15.literal("number"),
|
|
921
|
+
z15.literal("string")
|
|
877
922
|
])
|
|
878
923
|
});
|
|
879
924
|
function isUsageMeta(v) {
|
|
@@ -881,6 +926,10 @@ function isUsageMeta(v) {
|
|
|
881
926
|
}
|
|
882
927
|
__name(isUsageMeta, "isUsageMeta");
|
|
883
928
|
|
|
929
|
+
// src/constants.ts
|
|
930
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH = 1760572800;
|
|
931
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK = 107496;
|
|
932
|
+
|
|
884
933
|
// src/model/StakeEvents.ts
|
|
885
934
|
var StakeEventNames = [
|
|
886
935
|
"StakeAdded",
|
|
@@ -888,149 +937,17 @@ var StakeEventNames = [
|
|
|
888
937
|
"StakeWithdrawn"
|
|
889
938
|
];
|
|
890
939
|
|
|
891
|
-
// src/
|
|
892
|
-
import {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
});
|
|
903
|
-
for (let i = 0; i < accountStakeCount; i++) {
|
|
904
|
-
try {
|
|
905
|
-
const stake = await stakeContract.getStake(`0x${by}`, i, {
|
|
906
|
-
blockTag: startEthBlock - 1
|
|
907
|
-
});
|
|
908
|
-
accountStakes.push(stake);
|
|
909
|
-
} catch {
|
|
910
|
-
break;
|
|
911
|
-
}
|
|
912
|
-
}
|
|
913
|
-
const ethStakedAddress = toAddress2(staked, {
|
|
914
|
-
prefix: false
|
|
915
|
-
}).toLowerCase();
|
|
916
|
-
const networkStakes = accountStakes.filter((s) => s.staked.toLowerCase() === ethStakedAddress);
|
|
917
|
-
let totalStake = 0n;
|
|
918
|
-
for (const stake of networkStakes) {
|
|
919
|
-
totalStake += stake.amount;
|
|
920
|
-
}
|
|
921
|
-
let totalWeight = 0n;
|
|
922
|
-
let addIndex = 0;
|
|
923
|
-
let removeIndex = 0;
|
|
924
|
-
for (let i = startEthBlock; i <= endEthBlock; i++) {
|
|
925
|
-
while (addIndex < stakeAddedEvents.length && stakeAddedEvents[addIndex]?.blockNumber === i) {
|
|
926
|
-
totalStake += stakeAddedEvents[addIndex].args.amount;
|
|
927
|
-
addIndex++;
|
|
928
|
-
}
|
|
929
|
-
while (removeIndex < stakeRemovedEvents.length && stakeRemovedEvents[removeIndex]?.blockNumber === i) {
|
|
930
|
-
totalStake -= stakeRemovedEvents[removeIndex].args.amount;
|
|
931
|
-
removeIndex++;
|
|
932
|
-
}
|
|
933
|
-
totalWeight += totalStake;
|
|
934
|
-
}
|
|
935
|
-
return totalWeight;
|
|
936
|
-
}
|
|
937
|
-
__name(addressStakeWeight, "addressStakeWeight");
|
|
938
|
-
|
|
939
|
-
// src/steps/primitives/claimedRewards.ts
|
|
940
|
-
function claimedRewards(_address) {
|
|
941
|
-
return 0n;
|
|
942
|
-
}
|
|
943
|
-
__name(claimedRewards, "claimedRewards");
|
|
944
|
-
|
|
945
|
-
// src/steps/primitives/stakersAsOfBlock.ts
|
|
946
|
-
import { toAddress as toAddress4 } from "@xylabs/hex";
|
|
947
|
-
|
|
948
|
-
// src/steps/primitives/startingStakes.ts
|
|
949
|
-
import { toAddress as toAddress3 } from "@xylabs/hex";
|
|
950
|
-
import { XYO_NETWORK_STAKING_ADDRESS as XYO_NETWORK_STAKING_ADDRESS2 } from "@xyo-network/xl1-protocol";
|
|
951
|
-
async function startingStakes(stakeContract, staked, ethBlock) {
|
|
952
|
-
const stakeAddedFilter = stakeContract.filters.StakeAdded(toAddress3(XYO_NETWORK_STAKING_ADDRESS2, {
|
|
953
|
-
prefix: true
|
|
954
|
-
}));
|
|
955
|
-
const stakeAddedEvents = await stakeContract.queryFilter(stakeAddedFilter, 0, ethBlock);
|
|
956
|
-
const stakeRemovedFilter = stakeContract.filters.StakeRemoved(`0x${XYO_NETWORK_STAKING_ADDRESS2}`);
|
|
957
|
-
const stakeRemovedEvents = await stakeContract.queryFilter(stakeRemovedFilter, 0, ethBlock);
|
|
958
|
-
const stakes = {};
|
|
959
|
-
for (const event of stakeAddedEvents) {
|
|
960
|
-
const by = toAddress3(event.args.by.toLowerCase(), {
|
|
961
|
-
prefix: false
|
|
962
|
-
});
|
|
963
|
-
stakes[by] = (stakes[by] ?? 0n) + event.args.amount;
|
|
964
|
-
}
|
|
965
|
-
for (const event of stakeRemovedEvents) {
|
|
966
|
-
const by = toAddress3(event.args.by.toLowerCase(), {
|
|
967
|
-
prefix: false
|
|
968
|
-
});
|
|
969
|
-
stakes[by] = (stakes[by] ?? 0n) - event.args.amount;
|
|
970
|
-
}
|
|
971
|
-
const filteredStakes = {};
|
|
972
|
-
for (const [address, amount] of Object.entries(stakes)) {
|
|
973
|
-
if (amount > 0n) {
|
|
974
|
-
filteredStakes[address] = amount;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
return filteredStakes;
|
|
978
|
-
}
|
|
979
|
-
__name(startingStakes, "startingStakes");
|
|
980
|
-
|
|
981
|
-
// src/steps/primitives/stakersAsOfBlock.ts
|
|
982
|
-
async function stakersAsOfBlock(stakeContract, staked, ethBlock) {
|
|
983
|
-
const stakes = await startingStakes(stakeContract, staked, ethBlock);
|
|
984
|
-
let results = [];
|
|
985
|
-
for (const [address, amount] of Object.entries(stakes)) {
|
|
986
|
-
if (amount > 0n) {
|
|
987
|
-
results.push(toAddress4(address, {
|
|
988
|
-
prefix: false
|
|
989
|
-
}));
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
return results;
|
|
993
|
-
}
|
|
994
|
-
__name(stakersAsOfBlock, "stakersAsOfBlock");
|
|
995
|
-
|
|
996
|
-
// src/steps/primitives/totalStakeWeight.ts
|
|
997
|
-
import { toAddress as toAddress5 } from "@xylabs/hex";
|
|
998
|
-
import { XYO_NETWORK_STAKING_ADDRESS as XYO_NETWORK_STAKING_ADDRESS3 } from "@xyo-network/xl1-protocol";
|
|
999
|
-
async function totalStakeWeight(stakeContract, staked, startEthBlock, endEthBlock) {
|
|
1000
|
-
const stakeAddedFilter = stakeContract.filters.StakeAdded(`0x${XYO_NETWORK_STAKING_ADDRESS3}`);
|
|
1001
|
-
const stakeAddedEvents = await stakeContract.queryFilter(stakeAddedFilter, startEthBlock, endEthBlock);
|
|
1002
|
-
const stakeRemovedFilter = stakeContract.filters.StakeRemoved(`0x${XYO_NETWORK_STAKING_ADDRESS3}`);
|
|
1003
|
-
const stakeRemovedEvents = await stakeContract.queryFilter(stakeRemovedFilter, startEthBlock, endEthBlock);
|
|
1004
|
-
const stakes = await startingStakes(stakeContract, staked, startEthBlock);
|
|
1005
|
-
let totalWeight = 0n;
|
|
1006
|
-
let addIndex = 0;
|
|
1007
|
-
let removeIndex = 0;
|
|
1008
|
-
for (let i = startEthBlock; i <= endEthBlock; i++) {
|
|
1009
|
-
while (addIndex < stakeAddedEvents.length && stakeAddedEvents[addIndex]?.blockNumber === i) {
|
|
1010
|
-
const by = toAddress5(stakeAddedEvents[addIndex].args.by.toLowerCase(), {
|
|
1011
|
-
prefix: false
|
|
1012
|
-
});
|
|
1013
|
-
stakes[by] = (stakes[by] ?? 0n) + stakeAddedEvents[addIndex].args.amount;
|
|
1014
|
-
addIndex++;
|
|
1015
|
-
}
|
|
1016
|
-
while (removeIndex < stakeRemovedEvents.length && stakeRemovedEvents[removeIndex]?.blockNumber === i) {
|
|
1017
|
-
const by = toAddress5(stakeAddedEvents[addIndex].args.by.toLowerCase(), {
|
|
1018
|
-
prefix: false
|
|
1019
|
-
});
|
|
1020
|
-
stakes[by] = (stakes[by] ?? 0n) - stakeRemovedEvents[addIndex].args.amount;
|
|
1021
|
-
removeIndex++;
|
|
1022
|
-
}
|
|
1023
|
-
totalWeight += Object.values(stakes).reduce((a, b) => a + b, 0n);
|
|
1024
|
-
}
|
|
1025
|
-
return totalWeight;
|
|
1026
|
-
}
|
|
1027
|
-
__name(totalStakeWeight, "totalStakeWeight");
|
|
1028
|
-
|
|
1029
|
-
// src/steps/primitives/unclaimedRewards.ts
|
|
1030
|
-
function unclaimedRewards(_address) {
|
|
1031
|
-
throw new Error("Method not implemented.");
|
|
1032
|
-
}
|
|
1033
|
-
__name(unclaimedRewards, "unclaimedRewards");
|
|
940
|
+
// src/multipliers.ts
|
|
941
|
+
import { asAttoXL1 } from "@xyo-network/xl1-protocol";
|
|
942
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS = asAttoXL1(1105508843867301885042548n);
|
|
943
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS = asAttoXL1(100000000000000000000000000n);
|
|
944
|
+
var XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS = XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS + XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS;
|
|
945
|
+
var RewardMultipliers = {
|
|
946
|
+
[`0|${XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK}`]: [
|
|
947
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS,
|
|
948
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS
|
|
949
|
+
]
|
|
950
|
+
};
|
|
1034
951
|
|
|
1035
952
|
// src/time/primitives/xl1BlockNumberToEthBlockNumber.ts
|
|
1036
953
|
import { assertEx as assertEx6 } from "@xylabs/assert";
|
|
@@ -1380,14 +1297,19 @@ export {
|
|
|
1380
1297
|
GlobalMetaSchema,
|
|
1381
1298
|
JSONSchemaMetaSchema,
|
|
1382
1299
|
MnemonicStringZod,
|
|
1300
|
+
RewardMultipliers,
|
|
1383
1301
|
StakeEventNames,
|
|
1384
1302
|
StepSummarySchema,
|
|
1385
1303
|
TODO,
|
|
1386
1304
|
TransfersStepSummarySchema,
|
|
1387
1305
|
UsageMetaSchema,
|
|
1388
1306
|
WALLET_COMPLIANCE,
|
|
1307
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_EPOCH,
|
|
1308
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_END_XL1_BLOCK,
|
|
1309
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_BONUS_REWARDS,
|
|
1310
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_EARNED_REWARDS,
|
|
1311
|
+
XL1_NETWORK_STAKING_GENESIS_PERIOD_TOTAL_REWARDS,
|
|
1389
1312
|
Xl1CommonConfigSchema,
|
|
1390
|
-
addressStakeWeight,
|
|
1391
1313
|
allHashesPresent,
|
|
1392
1314
|
asBalancesStepSummary,
|
|
1393
1315
|
asBalancesStepSummaryWithStorageMeta,
|
|
@@ -1400,7 +1322,6 @@ export {
|
|
|
1400
1322
|
buildTransaction,
|
|
1401
1323
|
buildUnsignedTransaction,
|
|
1402
1324
|
calculateFramesFromRange,
|
|
1403
|
-
claimedRewards,
|
|
1404
1325
|
confirmSubmittedTransaction,
|
|
1405
1326
|
crackOperation,
|
|
1406
1327
|
crackOperations,
|
|
@@ -1433,11 +1354,8 @@ export {
|
|
|
1433
1354
|
parseSignedBigInt,
|
|
1434
1355
|
readPayloadMapFromStore,
|
|
1435
1356
|
signTransaction,
|
|
1436
|
-
stakersAsOfBlock,
|
|
1437
|
-
startingStakes,
|
|
1438
1357
|
toPositiveBigInt,
|
|
1439
1358
|
toSignedBigInt,
|
|
1440
|
-
totalStakeWeight,
|
|
1441
1359
|
transactionBlockByteCount,
|
|
1442
1360
|
transactionBytesRequiredGas,
|
|
1443
1361
|
transactionElevatedPayloadHashes,
|
|
@@ -1451,7 +1369,6 @@ export {
|
|
|
1451
1369
|
tryHydrateBlock,
|
|
1452
1370
|
tryHydrateElevatedTransaction,
|
|
1453
1371
|
tryHydrateTransaction,
|
|
1454
|
-
unclaimedRewards,
|
|
1455
1372
|
xl1BlockNumberToEthBlockNumber
|
|
1456
1373
|
};
|
|
1457
1374
|
//# sourceMappingURL=index.mjs.map
|