@xyo-network/xl1-protocol 1.12.37 → 1.12.40

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.
@@ -0,0 +1,16 @@
1
+ import type { ShiftedBigIntConfig } from './ShiftedBigIntConfig.ts';
2
+ export declare class ShiftedBigInt {
3
+ static readonly defaultConfig: ShiftedBigIntConfig;
4
+ config: ShiftedBigIntConfig;
5
+ value: bigint;
6
+ constructor(value: bigint | ShiftedBigInt, config?: Partial<ShiftedBigIntConfig>);
7
+ get locale(): Intl.LocalesArgument;
8
+ get maxCharacters(): number;
9
+ get maxDecimal(): number;
10
+ get minDecimals(): number;
11
+ get places(): number;
12
+ toFullString(): string;
13
+ toShortString(): string;
14
+ toString(): string;
15
+ }
16
+ //# sourceMappingURL=ShiftedBigInt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShiftedBigInt.d.ts","sourceRoot":"","sources":["../../../src/amount/ShiftedBigInt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAGnE,qBAAa,aAAa;IACxB,MAAM,CAAC,QAAQ,CAAC,aAAa,EAAE,mBAAmB,CAMjD;IAED,MAAM,EAAE,mBAAmB,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;gBAGX,KAAK,EAAE,MAAM,GAAG,aAAa,EAC7B,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM;IAQ3C,IAAI,MAAM,IAAI,IAAI,CAAC,eAAe,CAEjC;IAED,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,WAAW,IAAI,MAAM,CAExB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,YAAY,IAAI,MAAM;IAWtB,aAAa,IAAI,MAAM;IAWvB,QAAQ,IAAI,MAAM;CAGnB"}
@@ -0,0 +1,8 @@
1
+ export interface ShiftedBigIntConfig {
2
+ locale: Intl.LocalesArgument;
3
+ maxCharacters: number;
4
+ maxDecimal: number;
5
+ minDecimals: number;
6
+ places: number;
7
+ }
8
+ //# sourceMappingURL=ShiftedBigIntConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShiftedBigIntConfig.d.ts","sourceRoot":"","sources":["../../../src/amount/ShiftedBigIntConfig.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,IAAI,CAAC,eAAe,CAAA;IAC5B,aAAa,EAAE,MAAM,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf"}
@@ -0,0 +1,34 @@
1
+ import { AttoXL1, FemtoXL1, MicroXL1, MilliXL1, NanoXL1, PicoXL1 } from '../xl1/index.ts';
2
+ import type { ShiftedBigIntConfig } from './ShiftedBigIntConfig.ts';
3
+ export interface XL1AmountInstance {
4
+ value: AttoXL1;
5
+ to(places: bigint | number): bigint;
6
+ milli: MilliXL1;
7
+ micro: MicroXL1;
8
+ nano: NanoXL1;
9
+ pico: PicoXL1;
10
+ femto: FemtoXL1;
11
+ atto: AttoXL1;
12
+ toString(places: number, config: Partial<ShiftedBigIntConfig>): string;
13
+ }
14
+ export declare class XL1Amount implements XL1AmountInstance {
15
+ value: AttoXL1;
16
+ private locale;
17
+ constructor(value: bigint, locale?: Intl.LocalesArgument);
18
+ static from(value: bigint, places?: bigint): XL1Amount;
19
+ static fromMilli(value: MilliXL1): XL1Amount;
20
+ static fromMicro(value: MicroXL1): XL1Amount;
21
+ static fromNano(value: NanoXL1): XL1Amount;
22
+ static fromPico(value: PicoXL1): XL1Amount;
23
+ static fromFemto(value: FemtoXL1): XL1Amount;
24
+ static fromAtto(value: AttoXL1): XL1Amount;
25
+ to(places?: number | bigint): bigint;
26
+ get milli(): MilliXL1;
27
+ get micro(): MicroXL1;
28
+ get nano(): NanoXL1;
29
+ get pico(): PicoXL1;
30
+ get femto(): FemtoXL1;
31
+ get atto(): AttoXL1;
32
+ toString(places?: number, config?: Partial<ShiftedBigIntConfig>): string;
33
+ }
34
+ //# sourceMappingURL=Xl1Amount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Xl1Amount.d.ts","sourceRoot":"","sources":["../../../src/amount/Xl1Amount.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EACxD,MAAM,iBAAiB,CAAA;AAExB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAKnE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,OAAO,CAAA;IAEd,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;IAEnC,KAAK,EAAE,QAAQ,CAAA;IAEf,KAAK,EAAE,QAAQ,CAAA;IAEf,IAAI,EAAE,OAAO,CAAA;IAEb,IAAI,EAAE,OAAO,CAAA;IAEb,KAAK,EAAE,QAAQ,CAAA;IAEf,IAAI,EAAE,OAAO,CAAA;IAEb,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAA;CACvE;AAED,qBAAa,SAAU,YAAW,iBAAiB;IACjD,KAAK,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,MAAM,CAAsB;gBAExB,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,IAAI,CAAC,eAAyB;IAKjE,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAE,MAAuB;IAK1D,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ;IAIhC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ;IAIhC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO;IAI9B,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO;IAI9B,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ;IAIhC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO;IAI9B,EAAE,CAAC,MAAM,GAAE,MAAM,GAAG,MAAuB;IAI3C,IAAI,KAAK,aAER;IAED,IAAI,KAAK,aAER;IAED,IAAI,IAAI,YAEP;IAED,IAAI,IAAI,YAEP;IAED,IAAI,KAAK,aAER;IAED,IAAI,IAAI,YAEP;IAED,QAAQ,CAAC,MAAM,GAAE,MAA+B,EAAE,MAAM,GAAE,OAAO,CAAC,mBAAmB,CAAM,GAAG,MAAM;CAcrG"}
@@ -0,0 +1,5 @@
1
+ export * from './ShiftedBigInt.ts';
2
+ export * from './splitOnDecimal.ts';
3
+ export * from './splitOnDecimalToString.ts';
4
+ export * from './Xl1Amount.ts';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/amount/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Xl1Amount.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Xl1Amount.spec.d.ts","sourceRoot":"","sources":["../../../../src/amount/specs/Xl1Amount.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const splitOnDecimal: (value: bigint, places?: number) => [bigint, bigint];
2
+ //# sourceMappingURL=splitOnDecimal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitOnDecimal.d.ts","sourceRoot":"","sources":["../../../src/amount/splitOnDecimal.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,eAAW,KAAG,CAAC,MAAM,EAAE,MAAM,CAI1E,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const splitOnDecimalToString: (value: bigint, places?: number, maxDecimal?: number, maxCharacters?: number, minDecimals?: number, locale?: Intl.LocalesArgument) => string;
2
+ //# sourceMappingURL=splitOnDecimalToString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splitOnDecimalToString.d.ts","sourceRoot":"","sources":["../../../src/amount/splitOnDecimalToString.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,sBAAsB,GACjC,OAAO,MAAM,EACb,eAAW,EACX,mBAAmB,EACnB,sBAAiB,EACjB,oBAAe,EACf,SAAQ,IAAI,CAAC,eAAyB,KACrC,MA2BF,CAAA"}
@@ -1,3 +1,4 @@
1
+ export * from './amount/index.ts';
1
2
  export * from './block/index.ts';
2
3
  export * from './chain/index.ts';
3
4
  export * from './constants/index.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,oBAAoB,CAAA;AAClC,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA;AACnC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA"}
@@ -1,3 +1,280 @@
1
+ // src/amount/splitOnDecimal.ts
2
+ var splitOnDecimal = (value, places = 18) => {
3
+ const whole = value / BigInt(10 ** places);
4
+ const decimal = value % BigInt(10 ** places);
5
+ return [whole, decimal];
6
+ };
7
+
8
+ // src/amount/splitOnDecimalToString.ts
9
+ var splitOnDecimalToString = (value, places = 18, maxDecimal = places, maxCharacters = 9, minDecimals = 1, locale = "en-US") => {
10
+ const [whole, decimal] = splitOnDecimal(value, places);
11
+ if (whole === 0n && decimal < 10 ** maxDecimal && decimal !== 0n) return "< 0.".padEnd(maxDecimal + 5, "0") + "1";
12
+ const wholeCharacters = whole.toString(10).length;
13
+ const calcMaxDecimalCharacters = maxCharacters === -1 ? places : wholeCharacters > maxCharacters ? 0 : maxCharacters - wholeCharacters;
14
+ const maxDecimalCharacters = Math.min(maxDecimal, calcMaxDecimalCharacters);
15
+ const formattedWhole = new Intl.NumberFormat(locale, {
16
+ maximumFractionDigits: 0,
17
+ useGrouping: true
18
+ }).format(whole);
19
+ const decimalSeparator = new Intl.NumberFormat(locale).formatToParts(1.1).find((part) => part.type === "decimal")?.value ?? ".";
20
+ let paddedDecimal = decimal.toString().padStart(places, "0").slice(0, maxDecimalCharacters);
21
+ while (paddedDecimal.length > minDecimals && paddedDecimal.endsWith("0")) {
22
+ paddedDecimal = paddedDecimal.slice(0, -1);
23
+ }
24
+ return `${formattedWhole}${paddedDecimal.length > 0 ? decimalSeparator : ""}${paddedDecimal}`;
25
+ };
26
+
27
+ // src/amount/ShiftedBigInt.ts
28
+ var ShiftedBigInt = class _ShiftedBigInt {
29
+ static defaultConfig = {
30
+ places: 18,
31
+ maxDecimal: 18,
32
+ maxCharacters: 9,
33
+ minDecimals: 1,
34
+ locale: "en-US"
35
+ };
36
+ config;
37
+ value;
38
+ constructor(value, config = {}) {
39
+ this.value = typeof value === "bigint" ? value : value.value;
40
+ this.config = {
41
+ ..._ShiftedBigInt.defaultConfig,
42
+ ...typeof value === "bigint" ? {} : value.config,
43
+ ...config
44
+ };
45
+ }
46
+ get locale() {
47
+ return this.config.locale ?? "en-US";
48
+ }
49
+ get maxCharacters() {
50
+ return this.config.maxCharacters ?? 9;
51
+ }
52
+ get maxDecimal() {
53
+ return this.config.maxDecimal ?? this.places;
54
+ }
55
+ get minDecimals() {
56
+ return this.config.minDecimals ?? 1;
57
+ }
58
+ get places() {
59
+ return this.config.places ?? 18;
60
+ }
61
+ toFullString() {
62
+ return splitOnDecimalToString(
63
+ this.value,
64
+ this.places,
65
+ this.places,
66
+ Infinity,
67
+ this.places,
68
+ this.locale
69
+ );
70
+ }
71
+ toShortString() {
72
+ return splitOnDecimalToString(
73
+ this.value,
74
+ this.places,
75
+ this.maxDecimal,
76
+ this.maxCharacters,
77
+ this.minDecimals,
78
+ this.locale
79
+ );
80
+ }
81
+ toString() {
82
+ return this.toFullString();
83
+ }
84
+ };
85
+
86
+ // src/amount/Xl1Amount.ts
87
+ import { assertEx } from "@xylabs/assert";
88
+
89
+ // src/xl1/isXL1Factory.ts
90
+ import * as z from "zod";
91
+
92
+ // src/xl1/xl1MaxValue.ts
93
+ var xl1MaxValue = (places) => 10n ** (32n - places) - 1n;
94
+
95
+ // src/xl1/isXL1Factory.ts
96
+ var isXL1Factory = (places) => (val) => {
97
+ if (typeof val !== "bigint") return false;
98
+ return val >= 0n && val <= xl1MaxValue(places);
99
+ };
100
+ var XL1ZodFactory = (places, name) => {
101
+ const is = isXL1Factory(places);
102
+ const message = `Invalid value for ${name}, must be between 0 and ${xl1MaxValue(places)}`;
103
+ return z.bigint().refine(
104
+ (x) => {
105
+ const result = is(x);
106
+ return result;
107
+ },
108
+ { message }
109
+ );
110
+ };
111
+ var XL1TransformZodFactory = (places, name) => {
112
+ const is = isXL1Factory(places);
113
+ const message = `Invalid value for ${name}, must be between 0 and ${xl1MaxValue(places)}`;
114
+ return z.union([z.bigint(), z.number(), z.string(), z.boolean()]).transform((val) => BigInt(val)).refine(
115
+ (x) => {
116
+ const result = is(x);
117
+ return result;
118
+ },
119
+ { message }
120
+ );
121
+ };
122
+ var asXL1Factory = (places) => {
123
+ const zod = XL1ZodFactory(places, "local");
124
+ return (val) => {
125
+ const result = zod.safeParse(val);
126
+ if (result.success) {
127
+ return result.data;
128
+ }
129
+ throw result.error;
130
+ };
131
+ };
132
+ var toXL1Factory = (places) => {
133
+ const zod = XL1TransformZodFactory(places, "local");
134
+ return (val) => {
135
+ const result = zod.safeParse(val);
136
+ return result.success ? result.data : void 0;
137
+ };
138
+ };
139
+
140
+ // src/xl1/XL1Units.ts
141
+ var XL1Places = {
142
+ xl1: 18n,
143
+ milli: 15n,
144
+ micro: 12n,
145
+ nano: 9n,
146
+ pico: 6n,
147
+ femto: 3n,
148
+ atto: 0n
149
+ };
150
+ var AttoXL1ConvertFactor = {
151
+ xl1: 10n ** XL1Places.xl1,
152
+ milli: 10n ** XL1Places.milli,
153
+ micro: 10n ** XL1Places.micro,
154
+ nano: 10n ** XL1Places.nano,
155
+ pico: 10n ** XL1Places.pico,
156
+ femto: 10n ** XL1Places.femto,
157
+ atto: 10n ** XL1Places.atto
158
+ };
159
+
160
+ // src/xl1/AttoXL1.ts
161
+ var AttoXL1MaxValue = xl1MaxValue(XL1Places.atto);
162
+ var isAttoXL1 = isXL1Factory(XL1Places.atto);
163
+ var asAttoXL1 = asXL1Factory(XL1Places.atto);
164
+ var toAttoXL1 = toXL1Factory(XL1Places.atto);
165
+ var AttoXL1 = asAttoXL1;
166
+
167
+ // src/xl1/FemtoXL1.ts
168
+ var FemtoXL1MaxValue = xl1MaxValue(XL1Places.femto);
169
+ var isFemtoXL1 = isXL1Factory(XL1Places.femto);
170
+ var asFemtoXL1 = asXL1Factory(XL1Places.femto);
171
+ var toFemtoXL1 = toXL1Factory(XL1Places.femto);
172
+ var FemtoXL1 = asFemtoXL1;
173
+
174
+ // src/xl1/MicroXL1.ts
175
+ var MicroXL1MaxValue = xl1MaxValue(XL1Places.micro);
176
+ var isMicroXL1 = isXL1Factory(XL1Places.micro);
177
+ var asMicroXL1 = asXL1Factory(XL1Places.micro);
178
+ var toMicroXL1 = toXL1Factory(XL1Places.micro);
179
+ var MicroXL1 = asMicroXL1;
180
+
181
+ // src/xl1/MilliXL1.ts
182
+ var MilliXL1MaxValue = xl1MaxValue(XL1Places.milli);
183
+ var isMilliXL1 = isXL1Factory(XL1Places.milli);
184
+ var asMilliXL1 = asXL1Factory(XL1Places.milli);
185
+ var toMilliXL1 = toXL1Factory(XL1Places.milli);
186
+ var MilliXL1 = asMilliXL1;
187
+
188
+ // src/xl1/NanoXL1.ts
189
+ var NanoXL1MaxValue = xl1MaxValue(XL1Places.nano);
190
+ var isNanoXL1 = isXL1Factory(XL1Places.nano);
191
+ var asNanoXL1 = asXL1Factory(XL1Places.nano);
192
+ var toNanoXL1 = toXL1Factory(XL1Places.nano);
193
+ var NanoXL1 = asNanoXL1;
194
+
195
+ // src/xl1/PicoXL1.ts
196
+ var PicoXL1MaxValue = xl1MaxValue(XL1Places.pico);
197
+ var isPicoXL1 = isXL1Factory(XL1Places.pico);
198
+ var asPicoXL1 = asXL1Factory(XL1Places.pico);
199
+ var toPicoXL1 = toXL1Factory(XL1Places.pico);
200
+ var PicoXL1 = asPicoXL1;
201
+
202
+ // src/xl1/XL1.ts
203
+ var XL1MaxValue = xl1MaxValue(XL1Places.xl1);
204
+ var isXL1 = isXL1Factory(XL1Places.xl1);
205
+ var asXL1 = asXL1Factory(XL1Places.xl1);
206
+ var toXL1 = toXL1Factory(XL1Places.xl1);
207
+ var XL1 = asXL1;
208
+
209
+ // src/amount/Xl1Amount.ts
210
+ var MAX_XL1_AMOUNT = 2n ** BigInt(256) - 1n;
211
+ var allowedPlaces = Object.values(XL1Places);
212
+ var XL1Amount = class _XL1Amount {
213
+ value;
214
+ locale;
215
+ constructor(value, locale = "en-US") {
216
+ this.locale = locale;
217
+ this.value = AttoXL1(value > MAX_XL1_AMOUNT ? MAX_XL1_AMOUNT : value < 0n ? 0n : value);
218
+ }
219
+ static from(value, places = XL1Places.atto) {
220
+ assertEx(allowedPlaces.includes(places), () => `Invalid conversion places (${places} not in ${allowedPlaces})`);
221
+ return new _XL1Amount(value * 10n ** BigInt(places));
222
+ }
223
+ static fromMilli(value) {
224
+ return this.from(value, XL1Places.milli);
225
+ }
226
+ static fromMicro(value) {
227
+ return this.from(value, XL1Places.micro);
228
+ }
229
+ static fromNano(value) {
230
+ return this.from(value, XL1Places.nano);
231
+ }
232
+ static fromPico(value) {
233
+ return this.from(value, XL1Places.pico);
234
+ }
235
+ static fromFemto(value) {
236
+ return this.from(value, XL1Places.femto);
237
+ }
238
+ static fromAtto(value) {
239
+ return this.from(value, XL1Places.atto);
240
+ }
241
+ to(places = XL1Places.atto) {
242
+ return this.value / 10n ** BigInt(places);
243
+ }
244
+ get milli() {
245
+ return MilliXL1(this.to(XL1Places.milli));
246
+ }
247
+ get micro() {
248
+ return MicroXL1(this.to(XL1Places.micro));
249
+ }
250
+ get nano() {
251
+ return NanoXL1(this.to(XL1Places.nano));
252
+ }
253
+ get pico() {
254
+ return PicoXL1(this.to(XL1Places.pico));
255
+ }
256
+ get femto() {
257
+ return FemtoXL1(this.to(XL1Places.femto));
258
+ }
259
+ get atto() {
260
+ return AttoXL1(this.to(XL1Places.atto));
261
+ }
262
+ toString(places = Number(XL1Places.atto), config = {}) {
263
+ assertEx(allowedPlaces.includes(BigInt(places)), () => `Invalid conversion places (${places} not in ${allowedPlaces})`);
264
+ return new ShiftedBigInt(
265
+ this.value,
266
+ {
267
+ places,
268
+ locale: this.locale,
269
+ maxDecimal: places,
270
+ minDecimals: 0,
271
+ maxCharacters: places,
272
+ ...config
273
+ }
274
+ ).toShortString();
275
+ }
276
+ };
277
+
1
278
  // src/block/AllowedBlockPayload.ts
2
279
  import { BoundWitnessSchema } from "@xyo-network/boundwitness-model";
3
280
  import { isHashStorageMeta as isHashStorageMeta2, isSchema } from "@xyo-network/payload-model";
@@ -193,128 +470,6 @@ var asTransactionBoundWitnessWithHashStorageMeta = AsObjectFactory16.create(isTr
193
470
  import { isHex } from "@xylabs/hex";
194
471
  import { AsObjectFactory as AsObjectFactory17 } from "@xylabs/object";
195
472
  import { isObject } from "@xylabs/typeof";
196
-
197
- // src/xl1/isXL1Factory.ts
198
- import * as z from "zod";
199
-
200
- // src/xl1/xl1MaxValue.ts
201
- var xl1MaxValue = (places) => 10n ** (32n - places) - 1n;
202
-
203
- // src/xl1/isXL1Factory.ts
204
- var isXL1Factory = (places) => (val) => {
205
- if (typeof val !== "bigint") return false;
206
- return val >= 0n && val <= xl1MaxValue(places);
207
- };
208
- var XL1ZodFactory = (places, name) => {
209
- const is = isXL1Factory(places);
210
- const message = `Invalid value for ${name}, must be between 0 and ${xl1MaxValue(places)}`;
211
- return z.bigint().refine(
212
- (x) => {
213
- const result = is(x);
214
- return result;
215
- },
216
- { message }
217
- );
218
- };
219
- var XL1TransformZodFactory = (places, name) => {
220
- const is = isXL1Factory(places);
221
- const message = `Invalid value for ${name}, must be between 0 and ${xl1MaxValue(places)}`;
222
- return z.union([z.bigint(), z.number(), z.string(), z.boolean()]).transform((val) => BigInt(val)).refine(
223
- (x) => {
224
- const result = is(x);
225
- return result;
226
- },
227
- { message }
228
- );
229
- };
230
- var asXL1Factory = (places) => {
231
- const zod = XL1ZodFactory(places, "local");
232
- return (val) => {
233
- const result = zod.safeParse(val);
234
- if (result.success) {
235
- return result.data;
236
- }
237
- throw result.error;
238
- };
239
- };
240
- var toXL1Factory = (places) => {
241
- const zod = XL1TransformZodFactory(places, "local");
242
- return (val) => {
243
- const result = zod.safeParse(val);
244
- return result.success ? result.data : void 0;
245
- };
246
- };
247
-
248
- // src/xl1/XL1Units.ts
249
- var XL1Places = {
250
- xl1: 18n,
251
- milli: 15n,
252
- micro: 12n,
253
- nano: 9n,
254
- pico: 6n,
255
- femto: 3n,
256
- atto: 0n
257
- };
258
- var AttoXL1ConvertFactor = {
259
- xl1: 10n ** XL1Places.xl1,
260
- milli: 10n ** XL1Places.milli,
261
- micro: 10n ** XL1Places.micro,
262
- nano: 10n ** XL1Places.nano,
263
- pico: 10n ** XL1Places.pico,
264
- femto: 10n ** XL1Places.femto,
265
- atto: 10n ** XL1Places.atto
266
- };
267
-
268
- // src/xl1/AttoXL1.ts
269
- var AttoXL1MaxValue = xl1MaxValue(XL1Places.atto);
270
- var isAttoXL1 = isXL1Factory(XL1Places.atto);
271
- var asAttoXL1 = asXL1Factory(XL1Places.atto);
272
- var toAttoXL1 = toXL1Factory(XL1Places.atto);
273
- var AttoXL1 = asAttoXL1;
274
-
275
- // src/xl1/FemtoXL1.ts
276
- var FemtoXL1MaxValue = xl1MaxValue(XL1Places.femto);
277
- var isFemtoXL1 = isXL1Factory(XL1Places.femto);
278
- var asFemtoXL1 = asXL1Factory(XL1Places.femto);
279
- var toFemtoXL1 = toXL1Factory(XL1Places.femto);
280
- var FemtoXL1 = asFemtoXL1;
281
-
282
- // src/xl1/MicroXL1.ts
283
- var MicroXL1MaxValue = xl1MaxValue(XL1Places.micro);
284
- var isMicroXL1 = isXL1Factory(XL1Places.micro);
285
- var asMicroXL1 = asXL1Factory(XL1Places.micro);
286
- var toMicroXL1 = toXL1Factory(XL1Places.micro);
287
- var MicroXL1 = asMicroXL1;
288
-
289
- // src/xl1/MilliXL1.ts
290
- var MilliXL1MaxValue = xl1MaxValue(XL1Places.milli);
291
- var isMilliXL1 = isXL1Factory(XL1Places.milli);
292
- var asMilliXL1 = asXL1Factory(XL1Places.milli);
293
- var toMilliXL1 = toXL1Factory(XL1Places.milli);
294
- var MilliXL1 = asMilliXL1;
295
-
296
- // src/xl1/NanoXL1.ts
297
- var NanoXL1MaxValue = xl1MaxValue(XL1Places.nano);
298
- var isNanoXL1 = isXL1Factory(XL1Places.nano);
299
- var asNanoXL1 = asXL1Factory(XL1Places.nano);
300
- var toNanoXL1 = toXL1Factory(XL1Places.nano);
301
- var NanoXL1 = asNanoXL1;
302
-
303
- // src/xl1/PicoXL1.ts
304
- var PicoXL1MaxValue = xl1MaxValue(XL1Places.pico);
305
- var isPicoXL1 = isXL1Factory(XL1Places.pico);
306
- var asPicoXL1 = asXL1Factory(XL1Places.pico);
307
- var toPicoXL1 = toXL1Factory(XL1Places.pico);
308
- var PicoXL1 = asPicoXL1;
309
-
310
- // src/xl1/XL1.ts
311
- var XL1MaxValue = xl1MaxValue(XL1Places.xl1);
312
- var isXL1 = isXL1Factory(XL1Places.xl1);
313
- var asXL1 = asXL1Factory(XL1Places.xl1);
314
- var toXL1 = toXL1Factory(XL1Places.xl1);
315
- var XL1 = asXL1;
316
-
317
- // src/transaction/TransactionFeesFields.ts
318
473
  var isTransactionFeesBigInt = (value) => {
319
474
  if (!isObject(value)) {
320
475
  return false;
@@ -644,6 +799,7 @@ export {
644
799
  NetworkStatusSchema,
645
800
  PicoXL1,
646
801
  PicoXL1MaxValue,
802
+ ShiftedBigInt,
647
803
  StepCompleteSchema,
648
804
  StepRewardFractions,
649
805
  StepSizes,
@@ -652,6 +808,7 @@ export {
652
808
  TransferSchema,
653
809
  ValidationError,
654
810
  XL1,
811
+ XL1Amount,
655
812
  XL1MaxValue,
656
813
  XL1Places,
657
814
  XL1_PROTOCOL_VERSION,
@@ -766,6 +923,8 @@ export {
766
923
  isValidationError,
767
924
  isXL1,
768
925
  minTransactionFees,
926
+ splitOnDecimal,
927
+ splitOnDecimalToString,
769
928
  stepSize,
770
929
  toAttoXL1,
771
930
  toFemtoXL1,