@xyo-network/xl1-protocol-sdk 1.12.1 → 1.12.2

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.
Files changed (45) hide show
  1. package/dist/neutral/config/Api.d.ts +3 -3
  2. package/dist/neutral/config/Api.d.ts.map +1 -1
  3. package/dist/neutral/config/App.d.ts +3 -3
  4. package/dist/neutral/config/App.d.ts.map +1 -1
  5. package/dist/neutral/config/Chain.d.ts +2 -2
  6. package/dist/neutral/config/Chain.d.ts.map +1 -1
  7. package/dist/neutral/config/Config.d.ts +19 -19
  8. package/dist/neutral/config/Config.d.ts.map +1 -1
  9. package/dist/neutral/config/Evm.d.ts +6 -6
  10. package/dist/neutral/config/Evm.d.ts.map +1 -1
  11. package/dist/neutral/config/Log.d.ts +2 -2
  12. package/dist/neutral/config/Log.d.ts.map +1 -1
  13. package/dist/neutral/config/Producer.d.ts +5 -5
  14. package/dist/neutral/config/Producer.d.ts.map +1 -1
  15. package/dist/neutral/config/Telemetry.d.ts +4 -4
  16. package/dist/neutral/config/Telemetry.d.ts.map +1 -1
  17. package/dist/neutral/config/UsageMeta.d.ts +4 -4
  18. package/dist/neutral/config/UsageMeta.d.ts.map +1 -1
  19. package/dist/neutral/config/storage/Storage.d.ts +3 -3
  20. package/dist/neutral/config/storage/Storage.d.ts.map +1 -1
  21. package/dist/neutral/config/storage/driver/Mongo.d.ts +2 -2
  22. package/dist/neutral/config/storage/driver/Mongo.d.ts.map +1 -1
  23. package/dist/neutral/index.mjs +22 -13
  24. package/dist/neutral/index.mjs.map +1 -1
  25. package/dist/neutral/transaction/signTransaction.d.ts +8 -1
  26. package/dist/neutral/transaction/signTransaction.d.ts.map +1 -1
  27. package/dist/neutral/transaction/spec/signTransaction.spec.d.ts +2 -0
  28. package/dist/neutral/transaction/spec/signTransaction.spec.d.ts.map +1 -0
  29. package/dist/neutral/validation/schema/Mnemonic.d.ts +1 -1
  30. package/dist/neutral/validation/schema/Mnemonic.d.ts.map +1 -1
  31. package/package.json +24 -22
  32. package/src/config/Api.ts +2 -1
  33. package/src/config/App.ts +2 -1
  34. package/src/config/Chain.ts +2 -1
  35. package/src/config/Config.ts +1 -1
  36. package/src/config/Evm.ts +2 -1
  37. package/src/config/Log.ts +2 -1
  38. package/src/config/Producer.ts +2 -1
  39. package/src/config/Telemetry.ts +2 -1
  40. package/src/config/UsageMeta.ts +1 -1
  41. package/src/config/storage/Storage.ts +2 -1
  42. package/src/config/storage/driver/Mongo.ts +2 -1
  43. package/src/transaction/signTransaction.ts +14 -2
  44. package/src/transaction/spec/signTransaction.spec.ts +46 -0
  45. package/src/validation/schema/Mnemonic.ts +1 -1
@@ -1,8 +1,8 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const ApiConfigZod: z.ZodObject<{
3
3
  host: z.ZodDefault<z.ZodString>;
4
4
  mnemonic: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
5
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
6
- }, z.z.core.$strip>;
5
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
6
+ }, z.core.$strip>;
7
7
  export type ApiConfig = z.infer<typeof ApiConfigZod>;
8
8
  //# sourceMappingURL=Api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../../src/config/Api.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAIvC,eAAO,MAAM,YAAY;;;;mBAkBvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../../src/config/Api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,eAAO,MAAM,YAAY;;;;iBAkBvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const AppConfigZod: z.ZodObject<{
3
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
4
- }, z.z.core.$strip>;
3
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
4
+ }, z.core.$strip>;
5
5
  export type AppConfig = z.infer<typeof AppConfigZod>;
6
6
  //# sourceMappingURL=App.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../src/config/App.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAEvC,eAAO,MAAM,YAAY;;mBAOvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../../src/config/App.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,YAAY;;iBAOvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -1,6 +1,6 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const ChainConfigZod: z.ZodObject<{
3
3
  id: z.ZodOptional<z.ZodString>;
4
- }, z.z.core.$strip>;
4
+ }, z.core.$strip>;
5
5
  export type ChainConfig = z.infer<typeof ChainConfigZod>;
6
6
  //# sourceMappingURL=Chain.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Chain.d.ts","sourceRoot":"","sources":["../../../src/config/Chain.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAEvC,eAAO,MAAM,cAAc;;mBAQzB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
1
+ {"version":3,"file":"Chain.d.ts","sourceRoot":"","sources":["../../../src/config/Chain.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,cAAc;;iBAQzB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const Xl1CommonConfigSchema: z.ZodObject<{
3
3
  logLevel: z.ZodDefault<z.ZodEnum<{
4
4
  error: "error";
@@ -9,37 +9,37 @@ export declare const Xl1CommonConfigSchema: z.ZodObject<{
9
9
  trace: "trace";
10
10
  }>>;
11
11
  silent: z.ZodDefault<z.ZodBoolean>;
12
- }, z.z.core.$strip>;
12
+ }, z.core.$strip>;
13
13
  export declare const ConfigZod: z.ZodObject<{
14
14
  api: z.ZodDefault<z.ZodObject<{
15
15
  host: z.ZodDefault<z.ZodString>;
16
16
  mnemonic: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
17
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
18
- }, z.z.core.$strip>>;
17
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
18
+ }, z.core.$strip>>;
19
19
  app: z.ZodDefault<z.ZodObject<{
20
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
21
- }, z.z.core.$strip>>;
20
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
21
+ }, z.core.$strip>>;
22
22
  chain: z.ZodDefault<z.ZodObject<{
23
23
  id: z.ZodOptional<z.ZodString>;
24
- }, z.z.core.$strip>>;
24
+ }, z.core.$strip>>;
25
25
  evm: z.ZodDefault<z.ZodObject<{
26
26
  chainId: z.ZodOptional<z.ZodString>;
27
27
  infura: z.ZodOptional<z.ZodObject<{
28
28
  projectId: z.ZodOptional<z.ZodString>;
29
29
  projectSecret: z.ZodOptional<z.ZodString>;
30
- }, z.z.core.$strip>>;
30
+ }, z.core.$strip>>;
31
31
  jsonRpc: z.ZodOptional<z.ZodObject<{
32
32
  url: z.ZodOptional<z.ZodURL>;
33
- }, z.z.core.$strip>>;
34
- }, z.z.core.$strip>>;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strip>>;
35
35
  producer: z.ZodDefault<z.ZodObject<{
36
36
  disableIntentRedeclaration: z.ZodOptional<z.ZodBoolean>;
37
- healthCheckPort: z.ZodOptional<z.z.ZodCoercedNumber<unknown>>;
38
- minStake: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
37
+ healthCheckPort: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
38
+ minStake: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
39
39
  mnemonic: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
40
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
40
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
41
41
  rewardAddress: z.ZodOptional<z.ZodString>;
42
- }, z.z.core.$strip>>;
42
+ }, z.core.$strip>>;
43
43
  storage: z.ZodDefault<z.ZodObject<{
44
44
  mongo: z.ZodOptional<z.ZodObject<{
45
45
  connectionString: z.ZodOptional<z.ZodString>;
@@ -47,14 +47,14 @@ export declare const ConfigZod: z.ZodObject<{
47
47
  domain: z.ZodOptional<z.ZodString>;
48
48
  password: z.ZodOptional<z.ZodString>;
49
49
  username: z.ZodOptional<z.ZodString>;
50
- }, z.z.core.$strip>>;
50
+ }, z.core.$strip>>;
51
51
  root: z.ZodOptional<z.ZodString>;
52
- }, z.z.core.$strip>>;
52
+ }, z.core.$strip>>;
53
53
  telemetry: z.ZodDefault<z.ZodObject<{
54
54
  otel: z.ZodOptional<z.ZodObject<{
55
55
  otlpEndpoint: z.ZodOptional<z.ZodURL>;
56
- }, z.z.core.$strip>>;
57
- }, z.z.core.$strip>>;
56
+ }, z.core.$strip>>;
57
+ }, z.core.$strip>>;
58
58
  logLevel: z.ZodDefault<z.ZodEnum<{
59
59
  error: "error";
60
60
  warn: "warn";
@@ -64,7 +64,7 @@ export declare const ConfigZod: z.ZodObject<{
64
64
  trace: "trace";
65
65
  }>>;
66
66
  silent: z.ZodDefault<z.ZodBoolean>;
67
- }, z.z.core.$strip>;
67
+ }, z.core.$strip>;
68
68
  export type Config = z.infer<typeof ConfigZod>;
69
69
  export declare const getDefaultConfig: () => Config;
70
70
  //# sourceMappingURL=Config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAWnB,eAAO,MAAM,qBAAqB;;;;;;;;;;mBAAmF,CAAA;AAErH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBASpB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAE9C,eAAO,MAAM,gBAAgB,QAAO,MAA6B,CAAA"}
1
+ {"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../../src/config/Config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAWxB,eAAO,MAAM,qBAAqB;;;;;;;;;;iBAAmF,CAAA;AAErH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBASpB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAA;AAE9C,eAAO,MAAM,gBAAgB,QAAO,MAA6B,CAAA"}
@@ -1,20 +1,20 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const EvmInfuraConfigZod: z.ZodObject<{
3
3
  projectId: z.ZodOptional<z.ZodString>;
4
4
  projectSecret: z.ZodOptional<z.ZodString>;
5
- }, z.z.core.$strip>;
5
+ }, z.core.$strip>;
6
6
  export declare const EvmJsonRpcConfigZod: z.ZodObject<{
7
7
  url: z.ZodOptional<z.ZodURL>;
8
- }, z.z.core.$strip>;
8
+ }, z.core.$strip>;
9
9
  export declare const EvmConfigZod: z.ZodObject<{
10
10
  chainId: z.ZodOptional<z.ZodString>;
11
11
  infura: z.ZodOptional<z.ZodObject<{
12
12
  projectId: z.ZodOptional<z.ZodString>;
13
13
  projectSecret: z.ZodOptional<z.ZodString>;
14
- }, z.z.core.$strip>>;
14
+ }, z.core.$strip>>;
15
15
  jsonRpc: z.ZodOptional<z.ZodObject<{
16
16
  url: z.ZodOptional<z.ZodURL>;
17
- }, z.z.core.$strip>>;
18
- }, z.z.core.$strip>;
17
+ }, z.core.$strip>>;
18
+ }, z.core.$strip>;
19
19
  export type EvmConfig = z.infer<typeof EvmConfigZod>;
20
20
  //# sourceMappingURL=Evm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Evm.d.ts","sourceRoot":"","sources":["../../../src/config/Evm.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAEvC,eAAO,MAAM,kBAAkB;;;mBAW7B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;mBAM9B,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;mBAQvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"Evm.d.ts","sourceRoot":"","sources":["../../../src/config/Evm.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,kBAAkB;;;iBAW7B,CAAA;AAEF,eAAO,MAAM,mBAAmB;;iBAM9B,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;iBAQvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const LogConfigZod: z.ZodObject<{
3
3
  logLevel: z.ZodDefault<z.ZodEnum<{
4
4
  error: "error";
@@ -9,6 +9,6 @@ export declare const LogConfigZod: z.ZodObject<{
9
9
  trace: "trace";
10
10
  }>>;
11
11
  silent: z.ZodDefault<z.ZodBoolean>;
12
- }, z.z.core.$strip>;
12
+ }, z.core.$strip>;
13
13
  export type LogConfig = z.infer<typeof LogConfigZod>;
14
14
  //# sourceMappingURL=Log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Log.d.ts","sourceRoot":"","sources":["../../../src/config/Log.ts"],"names":[],"mappings":"AAEA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAGvC,eAAO,MAAM,YAAY;;;;;;;;;;mBAcvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
1
+ {"version":3,"file":"Log.d.ts","sourceRoot":"","sources":["../../../src/config/Log.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAGxB,eAAO,MAAM,YAAY;;;;;;;;;;iBAcvB,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
@@ -1,11 +1,11 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const ProducerConfigZod: z.ZodObject<{
3
3
  disableIntentRedeclaration: z.ZodOptional<z.ZodBoolean>;
4
- healthCheckPort: z.ZodOptional<z.z.ZodCoercedNumber<unknown>>;
5
- minStake: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
4
+ healthCheckPort: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
5
+ minStake: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
6
6
  mnemonic: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
7
- port: z.ZodDefault<z.z.ZodCoercedNumber<unknown>>;
7
+ port: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
8
8
  rewardAddress: z.ZodOptional<z.ZodString>;
9
- }, z.z.core.$strip>;
9
+ }, z.core.$strip>;
10
10
  export type ProducerConfig = z.infer<typeof ProducerConfigZod>;
11
11
  //# sourceMappingURL=Producer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Producer.d.ts","sourceRoot":"","sources":["../../../src/config/Producer.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAIvC,eAAO,MAAM,iBAAiB;;;;;;;mBAoC5B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"Producer.d.ts","sourceRoot":"","sources":["../../../src/config/Producer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,eAAO,MAAM,iBAAiB;;;;;;;iBAoC5B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
@@ -1,11 +1,11 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const OpenTelemetryConfigZod: z.ZodObject<{
3
3
  otlpEndpoint: z.ZodOptional<z.ZodURL>;
4
- }, z.z.core.$strip>;
4
+ }, z.core.$strip>;
5
5
  export declare const TelemetryConfigZod: z.ZodObject<{
6
6
  otel: z.ZodOptional<z.ZodObject<{
7
7
  otlpEndpoint: z.ZodOptional<z.ZodURL>;
8
- }, z.z.core.$strip>>;
9
- }, z.z.core.$strip>;
8
+ }, z.core.$strip>>;
9
+ }, z.core.$strip>;
10
10
  export type TelemetryConfig = z.infer<typeof TelemetryConfigZod>;
11
11
  //# sourceMappingURL=Telemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Telemetry.d.ts","sourceRoot":"","sources":["../../../src/config/Telemetry.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAEvC,eAAO,MAAM,sBAAsB;;mBAOjC,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;mBAGe,CAAA;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
1
+ {"version":3,"file":"Telemetry.d.ts","sourceRoot":"","sources":["../../../src/config/Telemetry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,eAAO,MAAM,sBAAsB;;iBAOjC,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;iBAGe,CAAA;AAE9C,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA"}
@@ -1,16 +1,16 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const JSONSchemaMetaSchema: z.ZodObject<{
3
3
  id: z.ZodOptional<z.ZodString>;
4
4
  title: z.ZodOptional<z.ZodString>;
5
5
  description: z.ZodOptional<z.ZodString>;
6
6
  deprecated: z.ZodOptional<z.ZodBoolean>;
7
- }, z.z.core.$catchall<z.ZodUnknown>>;
7
+ }, z.core.$catchall<z.ZodUnknown>>;
8
8
  export declare const GlobalMetaSchema: z.ZodObject<{
9
9
  id: z.ZodOptional<z.ZodString>;
10
10
  title: z.ZodOptional<z.ZodString>;
11
11
  description: z.ZodOptional<z.ZodString>;
12
12
  deprecated: z.ZodOptional<z.ZodBoolean>;
13
- }, z.z.core.$catchall<z.ZodUnknown>>;
13
+ }, z.core.$catchall<z.ZodUnknown>>;
14
14
  export declare const UsageMetaSchema: z.ZodObject<{
15
15
  id: z.ZodOptional<z.ZodString>;
16
16
  deprecated: z.ZodOptional<z.ZodBoolean>;
@@ -21,7 +21,7 @@ export declare const UsageMetaSchema: z.ZodObject<{
21
21
  hidden: z.ZodOptional<z.ZodBoolean>;
22
22
  title: z.ZodString;
23
23
  type: z.ZodUnion<readonly [z.ZodLiteral<"array">, z.ZodLiteral<"count">, z.ZodLiteral<"boolean">, z.ZodLiteral<"number">, z.ZodLiteral<"string">]>;
24
- }, z.z.core.$catchall<z.ZodUnknown>>;
24
+ }, z.core.$catchall<z.ZodUnknown>>;
25
25
  export type UsageMeta = z.infer<typeof UsageMetaSchema>;
26
26
  export declare function isUsageMeta(v: unknown): v is UsageMeta;
27
27
  //# sourceMappingURL=UsageMeta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UsageMeta.d.ts","sourceRoot":"","sources":["../../../src/config/UsageMeta.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,eAAO,MAAM,oBAAoB;;;;;oCAOT,CAAA;AAExB,eAAO,MAAM,gBAAgB;;;;;oCAAkC,CAAA;AAM/D,eAAO,MAAM,eAAe;;;;;;;;;;oCAc1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,SAAS,CAEtD"}
1
+ {"version":3,"file":"UsageMeta.d.ts","sourceRoot":"","sources":["../../../src/config/UsageMeta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAKxB,eAAO,MAAM,oBAAoB;;;;;kCAOT,CAAA;AAExB,eAAO,MAAM,gBAAgB;;;;;kCAAkC,CAAA;AAM/D,eAAO,MAAM,eAAe;;;;;;;;;;kCAc1B,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAEvD,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,SAAS,CAEtD"}
@@ -1,4 +1,4 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  export declare const StorageConfigZod: z.ZodObject<{
3
3
  mongo: z.ZodOptional<z.ZodObject<{
4
4
  connectionString: z.ZodOptional<z.ZodString>;
@@ -6,8 +6,8 @@ export declare const StorageConfigZod: z.ZodObject<{
6
6
  domain: z.ZodOptional<z.ZodString>;
7
7
  password: z.ZodOptional<z.ZodString>;
8
8
  username: z.ZodOptional<z.ZodString>;
9
- }, z.z.core.$strip>>;
9
+ }, z.core.$strip>>;
10
10
  root: z.ZodOptional<z.ZodString>;
11
- }, z.z.core.$strip>;
11
+ }, z.core.$strip>;
12
12
  export type StorageConfig = z.infer<typeof StorageConfigZod>;
13
13
  //# sourceMappingURL=Storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../../../src/config/storage/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAIvC,eAAO,MAAM,gBAAgB;;;;;;;;;mBAOe,CAAA;AAE5C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
1
+ {"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../../../../src/config/storage/Storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAIxB,eAAO,MAAM,gBAAgB;;;;;;;;;iBAOe,CAAA;AAE5C,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
@@ -1,4 +1,4 @@
1
- import z from 'zod';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * Checks if the provided MongoDB configuration contains all necessary fields
4
4
  * for establishing a connection.
@@ -13,6 +13,6 @@ export declare const MongoConfigZod: z.ZodObject<{
13
13
  domain: z.ZodOptional<z.ZodString>;
14
14
  password: z.ZodOptional<z.ZodString>;
15
15
  username: z.ZodOptional<z.ZodString>;
16
- }, z.z.core.$strip>;
16
+ }, z.core.$strip>;
17
17
  export type MongoConfig = z.infer<typeof MongoConfigZod>;
18
18
  //# sourceMappingURL=Mongo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Mongo.d.ts","sourceRoot":"","sources":["../../../../../src/config/storage/driver/Mongo.ts"],"names":[],"mappings":"AACA,OAAO,CAAqB,MAAM,KAAK,CAAA;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,KAAG,MAAM,IAAI,QAAQ,CAAC,WAAW,CASnF,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;mBA2BzB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
1
+ {"version":3,"file":"Mongo.d.ts","sourceRoot":"","sources":["../../../../../src/config/storage/driver/Mongo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,KAAG,MAAM,IAAI,QAAQ,CAAC,WAAW,CASnF,CAAA;AAED,eAAO,MAAM,cAAc;;;;;;iBA2BzB,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
@@ -357,10 +357,11 @@ async function balanceSummary(context) {
357
357
  __name(balanceSummary, "balanceSummary");
358
358
 
359
359
  // src/config/Config.ts
360
- import z11 from "zod";
360
+ import * as z11 from "zod";
361
361
 
362
362
  // src/config/Api.ts
363
- import z2, { globalRegistry } from "zod";
363
+ import { globalRegistry } from "zod";
364
+ import * as z2 from "zod";
364
365
 
365
366
  // src/validation/lib/isLocalhost.ts
366
367
  var isLocalhost = /* @__PURE__ */ __name((hostname) => {
@@ -377,7 +378,7 @@ var getUrl = /* @__PURE__ */ __name((host, port) => {
377
378
  var TODO = true;
378
379
 
379
380
  // src/validation/schema/Mnemonic.ts
380
- import { z } from "zod";
381
+ import * as z from "zod";
381
382
  var MnemonicStringZod = z.string().transform((s) => s.trim().replaceAll(/\s+/g, " ")).refine((s) => [
382
383
  12,
383
384
  15,
@@ -410,7 +411,8 @@ var ApiConfigZod = z2.object({
410
411
  });
411
412
 
412
413
  // src/config/App.ts
413
- import z3, { globalRegistry as globalRegistry2 } from "zod";
414
+ import { globalRegistry as globalRegistry2 } from "zod";
415
+ import * as z3 from "zod";
414
416
  var AppConfigZod = z3.object({
415
417
  port: z3.coerce.number().default(3e3).register(globalRegistry2, {
416
418
  default: 3e3,
@@ -421,7 +423,8 @@ var AppConfigZod = z3.object({
421
423
  });
422
424
 
423
425
  // src/config/Chain.ts
424
- import z4, { globalRegistry as globalRegistry3 } from "zod";
426
+ import { globalRegistry as globalRegistry3 } from "zod";
427
+ import * as z4 from "zod";
425
428
  var ChainConfigZod = z4.object({
426
429
  id: z4.string().optional().register(globalRegistry3, {
427
430
  description: "The unique identifier for the chain. Should be the staking contract address for contract-backed chains.",
@@ -431,7 +434,8 @@ var ChainConfigZod = z4.object({
431
434
  });
432
435
 
433
436
  // src/config/Evm.ts
434
- import z5, { globalRegistry as globalRegistry4 } from "zod";
437
+ import { globalRegistry as globalRegistry4 } from "zod";
438
+ import * as z5 from "zod";
435
439
  var EvmInfuraConfigZod = z5.object({
436
440
  projectId: z5.string().optional().register(globalRegistry4, {
437
441
  description: "Infura project ID",
@@ -463,7 +467,8 @@ var EvmConfigZod = z5.object({
463
467
 
464
468
  // src/config/Log.ts
465
469
  import { LogLevel } from "@xylabs/logger";
466
- import z6, { globalRegistry as globalRegistry5 } from "zod";
470
+ import { globalRegistry as globalRegistry5 } from "zod";
471
+ import * as z6 from "zod";
467
472
  var LogLevels = Object.keys(LogLevel);
468
473
  var LogConfigZod = z6.object({
469
474
  logLevel: z6.enum(LogLevels).default("info").register(globalRegistry5, {
@@ -482,7 +487,8 @@ var LogConfigZod = z6.object({
482
487
  });
483
488
 
484
489
  // src/config/Producer.ts
485
- import z7, { globalRegistry as globalRegistry6 } from "zod";
490
+ import { globalRegistry as globalRegistry6 } from "zod";
491
+ import * as z7 from "zod";
486
492
  var ProducerConfigZod = z7.object({
487
493
  disableIntentRedeclaration: z7.boolean().optional().register(globalRegistry6, {
488
494
  description: "Should the producer skip redeclaring their intent to continue producing blocks",
@@ -523,7 +529,8 @@ var ProducerConfigZod = z7.object({
523
529
 
524
530
  // src/config/storage/driver/Mongo.ts
525
531
  import { isDefined as isDefined2, isUndefined } from "@xylabs/typeof";
526
- import z8, { globalRegistry as globalRegistry7 } from "zod";
532
+ import { globalRegistry as globalRegistry7 } from "zod";
533
+ import * as z8 from "zod";
527
534
  var hasMongoConfig = /* @__PURE__ */ __name((config) => {
528
535
  if (isUndefined(config)) return false;
529
536
  return isDefined2(config.connectionString) && isDefined2(config.database) && isDefined2(config.domain) && isDefined2(config.password) && isDefined2(config.username);
@@ -558,7 +565,8 @@ var MongoConfigZod = z8.object({
558
565
  });
559
566
 
560
567
  // src/config/storage/Storage.ts
561
- import z9, { globalRegistry as globalRegistry8 } from "zod";
568
+ import { globalRegistry as globalRegistry8 } from "zod";
569
+ import * as z9 from "zod";
562
570
  var StorageConfigZod = z9.object({
563
571
  mongo: MongoConfigZod.optional().describe("Configuration for the MongoD storage driver"),
564
572
  root: z9.string().optional().register(globalRegistry8, {
@@ -569,7 +577,8 @@ var StorageConfigZod = z9.object({
569
577
  }).describe("Storage configuration options");
570
578
 
571
579
  // src/config/Telemetry.ts
572
- import z10, { globalRegistry as globalRegistry9 } from "zod";
580
+ import { globalRegistry as globalRegistry9 } from "zod";
581
+ import * as z10 from "zod";
573
582
  var OpenTelemetryConfigZod = z10.object({
574
583
  // OpenTelemetry options
575
584
  otlpEndpoint: z10.url().optional().register(globalRegistry9, {
@@ -600,7 +609,7 @@ var ConfigZod = z11.object({
600
609
  var getDefaultConfig = /* @__PURE__ */ __name(() => ConfigZod.parse({}), "getDefaultConfig");
601
610
 
602
611
  // src/config/UsageMeta.ts
603
- import z12 from "zod";
612
+ import * as z12 from "zod";
604
613
  var DescriptionSchema = z12.string();
605
614
  var TitleSchema = z12.string();
606
615
  var JSONSchemaMetaSchema = z12.object({
@@ -907,7 +916,7 @@ async function signTransaction(tx, account) {
907
916
  signedTx.previous_hashes = [
908
917
  account.previousHash ?? null
909
918
  ];
910
- const hash = await PayloadBuilder6.hash(signedTx);
919
+ const hash = await PayloadBuilder6.dataHash(signedTx);
911
920
  const hashBytes = toArrayBuffer(hash);
912
921
  const [signature] = await account.sign(hashBytes);
913
922
  signedTx.$signatures = [
@@ -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,SAASA,gBAAgB;AACzB,SAASC,gBAAgB;AAKzB,SACEC,0CAA0CC,oCAAoCC,gDACzE;AAEA,SAASC,iBAAiBC,QAAgBC,UAAoC;AACnF,QAAMC,gBAAgB,IAAIC,IAAIF,SAASG,IAAIC,CAAAA,MAAKA,EAAEC,KAAK,CAAA;AACvD,SAAON,OAAOO,MAAMC,CAAAA,SAAQN,cAAcO,IAAID,IAAAA,CAAAA;AAChD;AAHgBT;AAKT,IAAMW,kBAAkB,8BAC7BC,WACAH,MACAI,WAAmB,MAAC;AAEpBC,WAASD,YAAY,GAAG,MAAM,6CAAA;AAC9B,QAAME,MAAM,MAAMH,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,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"]}
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 * as 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 { globalRegistry } from 'zod'\nimport * as z 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 * as 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 { globalRegistry } from 'zod'\nimport * as z 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 * as 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 type { Unsigned } from '@xyo-network/boundwitness-model'\nimport { PayloadBuilder } from '@xyo-network/payload-builder'\nimport type { TransactionBoundWitness } from '@xyo-network/xl1-protocol'\n\n/**\n * Signs an unsigned transaction with the provided account.\n * @param tx The transaction to sign\n * @param account The account to sign the transaction with\n * @returns The signed transaction\n */\nexport async function signTransaction(tx: Unsigned<TransactionBoundWitness>, account: AccountInstance) {\n assertEx(tx.from === account.address, () => 'Signer address does not match transaction from address')\n // Clone tx to prevent modifying original\n const signedTx = structuredClone(tx)\n // Update dynamic fields based on account\n signedTx.addresses = [account.address]\n signedTx.previous_hashes = [account.previousHash ?? null]\n // Calculate tx hash and sign it\n const hash = await PayloadBuilder.dataHash(signedTx)\n const hashBytes = toArrayBuffer(hash)\n const [signature] = await account.sign(hashBytes)\n // Append the signatures to the transaction\n signedTx.$signatures = [hexFromArrayBuffer(signature)]\n // Return the signed transaction\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":";;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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","globalRegistry","z","isLocalhost","hostname","endsWith","getUrl","host","port","scheme","isLocalhost","TODO","z","MnemonicStringZod","string","transform","s","trim","replaceAll","refine","includes","split","length","message","describe","ApiConfigZod","object","host","string","default","register","globalRegistry","description","title","type","mnemonic","MnemonicStringZod","optional","port","coerce","number","globalRegistry","z","AppConfigZod","object","port","coerce","number","default","register","description","title","type","globalRegistry","z","ChainConfigZod","object","id","string","optional","register","description","title","type","globalRegistry","z","EvmInfuraConfigZod","object","projectId","string","optional","register","description","title","type","projectSecret","EvmJsonRpcConfigZod","url","EvmConfigZod","chainId","infura","describe","jsonRpc","LogLevel","globalRegistry","z","LogLevels","Object","keys","LogConfigZod","object","logLevel","enum","default","register","choices","description","title","type","silent","boolean","globalRegistry","z","ProducerConfigZod","object","disableIntentRedeclaration","boolean","optional","register","globalRegistry","description","title","type","healthCheckPort","coerce","number","minStake","default","mnemonic","MnemonicStringZod","port","rewardAddress","string","isDefined","isUndefined","globalRegistry","z","hasMongoConfig","config","isUndefined","isDefined","connectionString","database","domain","password","username","MongoConfigZod","object","string","min","optional","register","globalRegistry","description","title","type","globalRegistry","z","StorageConfigZod","object","mongo","MongoConfigZod","optional","describe","root","string","register","globalRegistry","description","title","type","globalRegistry","z","OpenTelemetryConfigZod","object","otlpEndpoint","url","optional","register","description","title","type","TelemetryConfigZod","otel","describe","Xl1CommonConfigSchema","object","LogConfigZod","shape","describe","ConfigZod","api","ApiConfigZod","default","parse","app","AppConfigZod","chain","ChainConfigZod","evm","EvmConfigZod","producer","ProducerConfigZod","storage","StorageConfigZod","telemetry","TelemetryConfigZod","getDefaultConfig","z","DescriptionSchema","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","dataHash","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"]}
@@ -1,4 +1,11 @@
1
1
  import type { AccountInstance } from '@xyo-network/account-model';
2
+ import type { Unsigned } from '@xyo-network/boundwitness-model';
2
3
  import type { TransactionBoundWitness } from '@xyo-network/xl1-protocol';
3
- export declare function signTransaction(tx: TransactionBoundWitness, account: AccountInstance): Promise<TransactionBoundWitness>;
4
+ /**
5
+ * Signs an unsigned transaction with the provided account.
6
+ * @param tx The transaction to sign
7
+ * @param account The account to sign the transaction with
8
+ * @returns The signed transaction
9
+ */
10
+ export declare function signTransaction(tx: Unsigned<TransactionBoundWitness>, account: AccountInstance): Promise<Unsigned<TransactionBoundWitness>>;
4
11
  //# sourceMappingURL=signTransaction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/signTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAEjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE,wBAAsB,eAAe,CAAC,EAAE,EAAE,uBAAuB,EAAE,OAAO,EAAE,eAAe,oCAU1F"}
1
+ {"version":3,"file":"signTransaction.d.ts","sourceRoot":"","sources":["../../../src/transaction/signTransaction.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAA;AAE/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,EAAE,EAAE,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,EAAE,eAAe,8CAepG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=signTransaction.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signTransaction.spec.d.ts","sourceRoot":"","sources":["../../../../src/transaction/spec/signTransaction.spec.ts"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import * as z from 'zod';
2
2
  /**
3
3
  * Validates a single string containing a BIP-39 mnemonic.
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Mnemonic.d.ts","sourceRoot":"","sources":["../../../../src/validation/schema/Mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,wDAMQ,CAAA;AAEtC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"Mnemonic.d.ts","sourceRoot":"","sources":["../../../../src/validation/schema/Mnemonic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,wDAMQ,CAAA;AAEtC,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
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.1",
4
+ "version": "1.12.2",
5
5
  "description": "XYO Layer One SDK Protocol",
6
6
  "homepage": "https://xylabs.com",
7
7
  "bugs": {
@@ -36,30 +36,32 @@
36
36
  "src"
37
37
  ],
38
38
  "dependencies": {
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",
39
+ "@xylabs/array": "~5.0.10",
40
+ "@xylabs/arraybuffer": "~5.0.10",
41
+ "@xylabs/assert": "~5.0.10",
42
+ "@xylabs/delay": "~5.0.10",
43
+ "@xylabs/hex": "~5.0.10",
44
+ "@xylabs/logger": "~5.0.10",
45
+ "@xylabs/object": "~5.0.10",
46
+ "@xylabs/promise": "~5.0.10",
47
+ "@xylabs/typeof": "~5.0.10",
48
+ "@xyo-network/account-model": "~5.0.7",
49
+ "@xyo-network/archivist-model": "~5.0.7",
50
+ "@xyo-network/boundwitness-builder": "~5.0.7",
51
+ "@xyo-network/boundwitness-model": "~5.0.7",
52
+ "@xyo-network/payload-builder": "~5.0.7",
53
+ "@xyo-network/payload-model": "~5.0.7",
54
+ "@xyo-network/wallet": "~5.0.7",
55
+ "@xyo-network/wallet-model": "~5.0.7",
56
+ "@xyo-network/xl1-protocol": "~1.10.15",
57
57
  "zod": "~4.0.17"
58
58
  },
59
59
  "devDependencies": {
60
- "@types/node": "~24.2.1",
61
- "@xylabs/ts-scripts-yarn3": "~7.1.2",
62
- "@xylabs/tsconfig": "~7.1.2",
60
+ "@types/node": "~24.3.0",
61
+ "@xylabs/ts-scripts-yarn3": "~7.1.3",
62
+ "@xylabs/tsconfig": "~7.1.3",
63
+ "@xyo-network/account": "~5.0.7",
64
+ "@xyo-network/boundwitness-validator": "~5.0.7",
63
65
  "typescript": "~5.9.2",
64
66
  "vitest": "~3.2.4"
65
67
  },
package/src/config/Api.ts CHANGED
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  import { MnemonicStringZod } from '../validation/index.ts'
4
5
 
package/src/config/App.ts CHANGED
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  export const AppConfigZod = z.object({
4
5
  port: z.coerce.number().default(3000).register(globalRegistry, {
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  export const ChainConfigZod = z.object({
4
5
  id: z.string().optional()
@@ -1,4 +1,4 @@
1
- import z from 'zod'
1
+ import * as z from 'zod'
2
2
 
3
3
  import { ApiConfigZod } from './Api.ts'
4
4
  import { AppConfigZod } from './App.ts'
package/src/config/Evm.ts CHANGED
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  export const EvmInfuraConfigZod = z.object({
4
5
  projectId: z.string().optional().register(globalRegistry, {
package/src/config/Log.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { LogLevelKey } from '@xylabs/logger'
2
2
  import { LogLevel } from '@xylabs/logger'
3
- import z, { globalRegistry } from 'zod'
3
+ import { globalRegistry } from 'zod'
4
+ import * as z from 'zod'
4
5
  const LogLevels = Object.keys(LogLevel) as [LogLevelKey, ...LogLevelKey[]]
5
6
 
6
7
  export const LogConfigZod = z.object({
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  import { MnemonicStringZod } from '../validation/index.ts'
4
5
 
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  export const OpenTelemetryConfigZod = z.object({
4
5
  // OpenTelemetry options
@@ -1,4 +1,4 @@
1
- import z from 'zod'
1
+ import * as z from 'zod'
2
2
 
3
3
  const DescriptionSchema = z.string()
4
4
  const TitleSchema = z.string()
@@ -1,4 +1,5 @@
1
- import z, { globalRegistry } from 'zod'
1
+ import { globalRegistry } from 'zod'
2
+ import * as z from 'zod'
2
3
 
3
4
  import { MongoConfigZod } from './driver/index.ts'
4
5
 
@@ -1,5 +1,6 @@
1
1
  import { isDefined, isUndefined } from '@xylabs/typeof'
2
- import z, { globalRegistry } from 'zod'
2
+ import { globalRegistry } from 'zod'
3
+ import * as z from 'zod'
3
4
 
4
5
  /**
5
6
  * Checks if the provided MongoDB configuration contains all necessary fields
@@ -2,17 +2,29 @@ import { toArrayBuffer } from '@xylabs/arraybuffer'
2
2
  import { assertEx } from '@xylabs/assert'
3
3
  import { hexFromArrayBuffer } from '@xylabs/hex'
4
4
  import type { AccountInstance } from '@xyo-network/account-model'
5
+ import type { Unsigned } from '@xyo-network/boundwitness-model'
5
6
  import { PayloadBuilder } from '@xyo-network/payload-builder'
6
7
  import type { TransactionBoundWitness } from '@xyo-network/xl1-protocol'
7
8
 
8
- export async function signTransaction(tx: TransactionBoundWitness, account: AccountInstance) {
9
+ /**
10
+ * Signs an unsigned transaction with the provided account.
11
+ * @param tx The transaction to sign
12
+ * @param account The account to sign the transaction with
13
+ * @returns The signed transaction
14
+ */
15
+ export async function signTransaction(tx: Unsigned<TransactionBoundWitness>, account: AccountInstance) {
9
16
  assertEx(tx.from === account.address, () => 'Signer address does not match transaction from address')
17
+ // Clone tx to prevent modifying original
10
18
  const signedTx = structuredClone(tx)
19
+ // Update dynamic fields based on account
11
20
  signedTx.addresses = [account.address]
12
21
  signedTx.previous_hashes = [account.previousHash ?? null]
13
- const hash = await PayloadBuilder.hash(signedTx)
22
+ // Calculate tx hash and sign it
23
+ const hash = await PayloadBuilder.dataHash(signedTx)
14
24
  const hashBytes = toArrayBuffer(hash)
15
25
  const [signature] = await account.sign(hashBytes)
26
+ // Append the signatures to the transaction
16
27
  signedTx.$signatures = [hexFromArrayBuffer(signature)]
28
+ // Return the signed transaction
17
29
  return signedTx
18
30
  }
@@ -0,0 +1,46 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ import { Account } from '@xyo-network/account'
3
+ import { BoundWitnessValidator } from '@xyo-network/boundwitness-validator'
4
+ import type { TransactionBoundWitness } from '@xyo-network/xl1-protocol'
5
+ import {
6
+ describe, expect, it,
7
+ } from 'vitest'
8
+
9
+ import { signTransaction } from '../signTransaction.ts'
10
+
11
+ describe('signTransaction', () => {
12
+ it('successfully signs transaction', async () => {
13
+ const bw = {
14
+ $signatures: [],
15
+ addresses: [],
16
+ chain: '0000000000000000000000000000000000000000',
17
+ exp: 1001,
18
+ fees: {
19
+ base: 'e8d4a51000',
20
+ gasLimit: '038d7ea4c68000',
21
+ gasPrice: '02540be400',
22
+ priority: '00',
23
+ },
24
+ nbf: 1,
25
+ payload_hashes: [
26
+ '34e5eadb2ccfc7005e224bfa6c3d10c32087d63238005efeaef9c67a85ed6fa2',
27
+ 'eb28b0213854d3b5f255806c2261e568fabcef8afa8b7d7f504bee35d9bce917',
28
+ ],
29
+ payload_schemas: [
30
+ 'network.xyo.hash',
31
+ 'network.xyo.id',
32
+ ],
33
+ previous_hashes: [],
34
+ schema: 'network.xyo.boundwitness',
35
+ script: [
36
+ 'elevate|34e5eadb2ccfc7005e224bfa6c3d10c32087d63238005efeaef9c67a85ed6fa2',
37
+ ],
38
+ } as any as TransactionBoundWitness
39
+ const account = await Account.random()
40
+ bw.from = account.address
41
+ const signed = await signTransaction(bw, account)
42
+ expect(signed).toBeDefined()
43
+ const validationErrors = await new BoundWitnessValidator(signed).validate()
44
+ expect(validationErrors.length).toBe(0)
45
+ })
46
+ })
@@ -1,4 +1,4 @@
1
- import { z } from 'zod'
1
+ import * as z from 'zod'
2
2
 
3
3
  /**
4
4
  * Validates a single string containing a BIP-39 mnemonic.