@proto-kit/common 0.1.1-develop.186 → 0.1.1-develop.188

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 (74) hide show
  1. package/package.json +2 -2
  2. package/test/zkProgrammable/ZkProgrammable.test.ts +0 -1
  3. package/dist/Constants.d.ts +0 -4
  4. package/dist/Constants.d.ts.map +0 -1
  5. package/dist/Constants.js +0 -3
  6. package/dist/config/ConfigurationAggregator.d.ts +0 -10
  7. package/dist/config/ConfigurationAggregator.d.ts.map +0 -1
  8. package/dist/config/ConfigurationAggregator.js +0 -35
  9. package/dist/config/ConfigurationReceiver.d.ts +0 -25
  10. package/dist/config/ConfigurationReceiver.d.ts.map +0 -1
  11. package/dist/config/ConfigurationReceiver.js +0 -36
  12. package/dist/config/types.d.ts +0 -2
  13. package/dist/config/types.d.ts.map +0 -1
  14. package/dist/config/types.js +0 -1
  15. package/dist/model/MethodPublicInput.d.ts +0 -51
  16. package/dist/model/MethodPublicInput.d.ts.map +0 -1
  17. package/dist/model/MethodPublicInput.js +0 -11
  18. package/dist/model/Option.d.ts +0 -89
  19. package/dist/model/Option.d.ts.map +0 -1
  20. package/dist/model/Option.js +0 -86
  21. package/dist/model/Path.d.ts +0 -31
  22. package/dist/model/Path.d.ts.map +0 -1
  23. package/dist/model/Path.js +0 -44
  24. package/dist/model/StateTransition.d.ts +0 -85
  25. package/dist/model/StateTransition.d.ts.map +0 -1
  26. package/dist/model/StateTransition.js +0 -58
  27. package/dist/model/StateTransitionProvableBatch.d.ts +0 -56
  28. package/dist/model/StateTransitionProvableBatch.d.ts.map +0 -1
  29. package/dist/model/StateTransitionProvableBatch.js +0 -20
  30. package/dist/prover/block/BlockProver.d.ts +0 -199
  31. package/dist/prover/block/BlockProver.d.ts.map +0 -1
  32. package/dist/prover/block/BlockProver.js +0 -119
  33. package/dist/prover/block/BlockScopedModule.d.ts +0 -3
  34. package/dist/prover/block/BlockScopedModule.d.ts.map +0 -1
  35. package/dist/prover/block/BlockScopedModule.js +0 -6
  36. package/dist/prover/statetransition/StateTransitionProver.d.ts +0 -92
  37. package/dist/prover/statetransition/StateTransitionProver.d.ts.map +0 -1
  38. package/dist/prover/statetransition/StateTransitionProver.js +0 -127
  39. package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +0 -16
  40. package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +0 -1
  41. package/dist/prover/statetransition/StateTransitionWitnessProvider.js +0 -17
  42. package/dist/src/model/Option.d.ts +0 -158
  43. package/dist/src/model/Option.d.ts.map +0 -1
  44. package/dist/src/model/Option.js +0 -53
  45. package/dist/src/model/Path.d.ts +0 -35
  46. package/dist/src/model/Path.d.ts.map +0 -1
  47. package/dist/src/model/Path.js +0 -51
  48. package/dist/src/model/StateTransition.d.ts +0 -201
  49. package/dist/src/model/StateTransition.d.ts.map +0 -1
  50. package/dist/src/model/StateTransition.js +0 -43
  51. package/dist/src/utils/PrefixedHashList.d.ts +0 -15
  52. package/dist/src/utils/PrefixedHashList.d.ts.map +0 -1
  53. package/dist/src/utils/PrefixedHashList.js +0 -28
  54. package/dist/src/utils/ProvableHashList.d.ts +0 -30
  55. package/dist/src/utils/ProvableHashList.d.ts.map +0 -1
  56. package/dist/src/utils/ProvableHashList.js +0 -43
  57. package/dist/utils/PrefixedHashList.d.ts +0 -14
  58. package/dist/utils/PrefixedHashList.d.ts.map +0 -1
  59. package/dist/utils/PrefixedHashList.js +0 -12
  60. package/dist/utils/PrefixedProvableHashList.d.ts +0 -8
  61. package/dist/utils/PrefixedProvableHashList.d.ts.map +0 -1
  62. package/dist/utils/PrefixedProvableHashList.js +0 -12
  63. package/dist/utils/ProvableHashList.d.ts +0 -26
  64. package/dist/utils/ProvableHashList.d.ts.map +0 -1
  65. package/dist/utils/ProvableHashList.js +0 -35
  66. package/dist/utils/Utils.d.ts +0 -22
  67. package/dist/utils/Utils.d.ts.map +0 -1
  68. package/dist/utils/Utils.js +0 -41
  69. package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts +0 -26
  70. package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts.map +0 -1
  71. package/dist/utils/merkletree/MemoryMerkleTreeStorage.js +0 -79
  72. package/dist/utils/merkletree/RollupMerkleTree.d.ts +0 -143
  73. package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +0 -1
  74. package/dist/utils/merkletree/RollupMerkleTree.js +0 -246
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "license": "MIT",
4
4
  "private": false,
5
5
  "type": "module",
6
- "version": "0.1.1-develop.186+0f36686",
6
+ "version": "0.1.1-develop.188+21e286f",
7
7
  "scripts": {
8
8
  "build": "tsc -p tsconfig.json",
9
9
  "dev": "tsc -p tsconfig.json --watch",
@@ -30,5 +30,5 @@
30
30
  "@jest/globals": "^29.5.0",
31
31
  "@types/lodash": "^4.14.194"
32
32
  },
33
- "gitHead": "0f3668667d29ddeb4fd6aaff1d510c4da9a7743c"
33
+ "gitHead": "21e286fd130d04358a81e49507f3bcbbfcb6799d"
34
34
  }
@@ -17,7 +17,6 @@ import {
17
17
  ZkProgrammable,
18
18
  } from "../../src/zkProgrammable/ZkProgrammable";
19
19
  import { ProvableMethodExecutionContext } from "../../src/zkProgrammable/ProvableMethodExecutionContext";
20
- import { Pickles } from "snarkyjs/dist/node/snarky";
21
20
 
22
21
  const appChainMock: AreProofsEnabled = {
23
22
  areProofsEnabled: false,
@@ -1,4 +0,0 @@
1
- export declare const constants: {
2
- stateTransitionProverBatchSize: number;
3
- };
4
- //# sourceMappingURL=Constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Constants.d.ts","sourceRoot":"","sources":["../src/Constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;CAErB,CAAC"}
package/dist/Constants.js DELETED
@@ -1,3 +0,0 @@
1
- export const constants = {
2
- stateTransitionProverBatchSize: 8,
3
- };
@@ -1,10 +0,0 @@
1
- import { ComponentConfig, Components, RemoveUndefinedKeys, UninitializedComponentConfig } from "./types";
2
- /**
3
- * In this context, a "Component" is just a way of generalizing Modules,
4
- * because they don't have to be modules, they can be any configurable unit
5
- */
6
- export declare abstract class ConfigurationAggregator<Comps extends Components> {
7
- protected applyConfig(modules: Comps, currentConfig: UninitializedComponentConfig<ComponentConfig<Comps>>, config: RemoveUndefinedKeys<ComponentConfig<Comps>>): ComponentConfig<Comps>;
8
- abstract configure(config: RemoveUndefinedKeys<ComponentConfig<Comps>>): void;
9
- }
10
- //# sourceMappingURL=ConfigurationAggregator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigurationAggregator.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,KAAK,SAAS,UAAU;IACpE,SAAS,CAAC,WAAW,CACnB,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EACnE,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,eAAe,CAAC,KAAK,CAAC;aAgCT,SAAS,CACvB,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,IAAI;CACR"}
@@ -1,35 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any,guard-for-in,@typescript-eslint/no-unsafe-member-access,max-len,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/consistent-type-assertions */
2
- import merge from "lodash/merge";
3
- /**
4
- * In this context, a "Component" is just a way of generalizing Modules,
5
- * because they don't have to be modules, they can be any configurable unit
6
- */
7
- export class ConfigurationAggregator {
8
- applyConfig(modules, currentConfig, config) {
9
- const nextConfig = {};
10
- for (const key in config) {
11
- // Set config to module
12
- if (currentConfig[key] === undefined) {
13
- // Initialize config with merge between config and defaultConfig
14
- // eslint-disable-next-line prefer-destructuring,putout/putout
15
- const defaultConfig = modules[key].defaultConfig;
16
- const newConfig = config[key];
17
- for (const configKey in newConfig) {
18
- defaultConfig[configKey] = newConfig[configKey];
19
- }
20
- // The result of that is always a valid Required<Config> since FlipOptional<Config> requires the exact opposite of Config
21
- modules[key].config = defaultConfig;
22
- nextConfig[key] = defaultConfig;
23
- }
24
- else {
25
- // Append/overwrite to existing config
26
- const newConfig = config[key];
27
- const moduleConfig = currentConfig[key];
28
- merge(moduleConfig, newConfig);
29
- modules[key].config = moduleConfig;
30
- nextConfig[key] = moduleConfig;
31
- }
32
- }
33
- return nextConfig;
34
- }
35
- }
@@ -1,25 +0,0 @@
1
- import type { FlipOptional } from "./types";
2
- /**
3
- * Configs:
4
- *
5
- * A property that accepts undefined, is an optional argument.
6
- * That means that you will have to provide it via defaultConfig() and it will
7
- * be non-undefined via this.config. This is used by devs to indicate
8
- * configurability but not necessary explicit definition.
9
- * I.e. when the default arguments will work most of the time
10
- *
11
- * If devs want a property that can be undefined, they should use null instead
12
- *
13
- */
14
- export declare abstract class ConfigurationReceiver<Config> {
15
- private currentConfig?;
16
- /**
17
- * Retrieves the configured config object.
18
- * This is only available in instance methods like start(), using this in
19
- * the constructor will throw an Exception
20
- */
21
- get config(): Required<Config>;
22
- set config(config: Required<Config>);
23
- abstract get defaultConfig(): FlipOptional<Config>;
24
- }
25
- //# sourceMappingURL=ConfigurationReceiver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ConfigurationReceiver.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationReceiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5C;;;;;;;;;;;GAWG;AACH,8BAAsB,qBAAqB,CAAC,MAAM;IAChD,OAAO,CAAC,aAAa,CAAC,CAA+B;IAErD;;;;OAIG;IACH,IAAW,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,CAOpC;IAED,IAAW,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAEzC;IAED,aAAoB,aAAa,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;CAC3D"}
@@ -1,36 +0,0 @@
1
- const errors = {
2
- configNotSet: (name) => new Error(`RuntimeModule (${name}) config has not been set!`),
3
- };
4
- /**
5
- * Configs:
6
- *
7
- * A property that accepts undefined, is an optional argument.
8
- * That means that you will have to provide it via defaultConfig() and it will
9
- * be non-undefined via this.config. This is used by devs to indicate
10
- * configurability but not necessary explicit definition.
11
- * I.e. when the default arguments will work most of the time
12
- *
13
- * If devs want a property that can be undefined, they should use null instead
14
- *
15
- */
16
- export class ConfigurationReceiver {
17
- constructor() {
18
- this.currentConfig = undefined;
19
- }
20
- /**
21
- * Retrieves the configured config object.
22
- * This is only available in instance methods like start(), using this in
23
- * the constructor will throw an Exception
24
- */
25
- get config() {
26
- if (this.currentConfig === undefined) {
27
- // eslint-disable-next-line no-warning-comments
28
- // TODO Check properly, Config could also be void
29
- throw errors.configNotSet(this.constructor.name);
30
- }
31
- return this.currentConfig;
32
- }
33
- set config(config) {
34
- this.currentConfig = config;
35
- }
36
- }
@@ -1,2 +0,0 @@
1
- export type TypedClassConstructor<Type> = new (...args: any[]) => Type;
2
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,51 +0,0 @@
1
- import { Bool, Field } from "snarkyjs";
2
- declare const MethodPublicInput_base: (new (value: {
3
- stateTransitionsHash: Field;
4
- status: Bool;
5
- transactionHash: Field;
6
- }) => {
7
- stateTransitionsHash: Field;
8
- status: Bool;
9
- transactionHash: Field;
10
- }) & {
11
- _isStruct: true;
12
- } & import("snarkyjs/dist/node/snarky").ProvablePure<{
13
- stateTransitionsHash: Field;
14
- status: Bool;
15
- transactionHash: Field;
16
- }> & {
17
- toInput: (x: {
18
- stateTransitionsHash: Field;
19
- status: Bool;
20
- transactionHash: Field;
21
- }) => {
22
- fields?: Field[] | undefined;
23
- packed?: [Field, number][] | undefined;
24
- };
25
- toJSON: (x: {
26
- stateTransitionsHash: Field;
27
- status: Bool;
28
- transactionHash: Field;
29
- }) => {
30
- stateTransitionsHash: string;
31
- status: boolean;
32
- transactionHash: string;
33
- };
34
- fromJSON: (x: {
35
- stateTransitionsHash: string;
36
- status: boolean;
37
- transactionHash: string;
38
- }) => {
39
- stateTransitionsHash: Field;
40
- status: Bool;
41
- transactionHash: Field;
42
- };
43
- };
44
- /**
45
- * Public input used to link in-circuit execution with
46
- * the proof's public input.
47
- */
48
- export declare class MethodPublicInput extends MethodPublicInput_base {
49
- }
50
- export {};
51
- //# sourceMappingURL=MethodPublicInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MethodPublicInput.d.ts","sourceRoot":"","sources":["../../src/model/MethodPublicInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG"}
@@ -1,11 +0,0 @@
1
- import { Bool, Field, Struct } from "snarkyjs";
2
- /**
3
- * Public input used to link in-circuit execution with
4
- * the proof's public input.
5
- */
6
- export class MethodPublicInput extends Struct({
7
- stateTransitionsHash: Field,
8
- status: Bool,
9
- transactionHash: Field,
10
- }) {
11
- }
@@ -1,89 +0,0 @@
1
- import { Bool, Field, type FlexibleProvablePure } from "snarkyjs";
2
- declare const ProvableOption_base: (new (value: {
3
- isSome: Bool;
4
- value: Field;
5
- }) => {
6
- isSome: Bool;
7
- value: Field;
8
- }) & {
9
- _isStruct: true;
10
- } & import("snarkyjs/dist/node/snarky").ProvablePure<{
11
- isSome: Bool;
12
- value: Field;
13
- }> & {
14
- toInput: (x: {
15
- isSome: Bool;
16
- value: Field;
17
- }) => {
18
- fields?: Field[] | undefined;
19
- packed?: [Field, number][] | undefined;
20
- };
21
- toJSON: (x: {
22
- isSome: Bool;
23
- value: Field;
24
- }) => {
25
- isSome: boolean;
26
- value: string;
27
- };
28
- fromJSON: (x: {
29
- isSome: boolean;
30
- value: string;
31
- }) => {
32
- isSome: Bool;
33
- value: Field;
34
- };
35
- };
36
- export declare class ProvableOption extends ProvableOption_base {
37
- toSome(): this;
38
- }
39
- /**
40
- * Option facilitating in-circuit values that may or may not exist.
41
- */
42
- export declare class Option<Value> {
43
- isSome: Bool;
44
- value: Value;
45
- valueType: FlexibleProvablePure<Value>;
46
- /**
47
- * Creates a new Option from the provided parameters
48
- *
49
- * @param isSome
50
- * @param value
51
- * @param valueType
52
- * @returns New option from the provided parameters.
53
- */
54
- static from<Value>(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
55
- /**
56
- * Creates a new Option from the provided parameters
57
- *
58
- * @param value
59
- * @param valueType
60
- * @returns New option from the provided parameters.
61
- */
62
- static fromValue<Value>(value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
63
- /**
64
- * @returns Empty / none option
65
- */
66
- static none(): Option<Field>;
67
- static dummyValueFields<Value>(valueType: FlexibleProvablePure<Value>): Field[];
68
- /**
69
- * Computes a dummy value for the given value type.
70
- *
71
- * @param valueType - Value type to generate the dummy value for
72
- * @returns Dummy value for the given value type
73
- */
74
- static dummyValue<Value>(valueType: FlexibleProvablePure<Value>): Value;
75
- isForcedSome: Bool;
76
- constructor(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>);
77
- clone(): Option<Value>;
78
- forceSome(): void;
79
- /**
80
- * @returns Tree representation of the current value
81
- */
82
- get treeValue(): Field;
83
- /**
84
- * @returns Provable representation of the current option.
85
- */
86
- toProvable(): ProvableOption;
87
- }
88
- export {};
89
- //# sourceMappingURL=Option.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Option.d.ts","sourceRoot":"","sources":["../../src/model/Option.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EAEJ,KAAK,EACL,KAAK,oBAAoB,EAG1B,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,qBAAa,cAAe,SAAQ,mBAGlC;IACO,MAAM;CAId;AAED;;GAEG;AACH,qBAAa,MAAM,CAAC,KAAK;IA+Dd,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAhE/C;;;;;;;OAOG;WACW,IAAI,CAAC,KAAK,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAKxC;;;;;;OAMG;WACW,SAAS,CAAC,KAAK,EAC3B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAKxC;;OAEG;WACW,IAAI;WAIJ,gBAAgB,CAAC,KAAK,EAClC,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,GACrC,KAAK,EAAE;IAKV;;;;;OAKG;WACW,UAAU,CAAC,KAAK,EAC5B,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,GACrC,KAAK;IAOD,YAAY,OAAe;gBAGzB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAGxC,KAAK;IAIL,SAAS;IAKhB;;OAEG;IACH,IAAW,SAAS,UAQnB;IAED;;OAEG;IACI,UAAU;CAMlB"}
@@ -1,86 +0,0 @@
1
- import { Bool, Circuit, Field, Poseidon, Struct, } from "snarkyjs";
2
- export class ProvableOption extends Struct({
3
- isSome: Bool,
4
- value: Field,
5
- }) {
6
- toSome() {
7
- this.isSome = Bool(true);
8
- return this;
9
- }
10
- }
11
- /**
12
- * Option facilitating in-circuit values that may or may not exist.
13
- */
14
- export class Option {
15
- /**
16
- * Creates a new Option from the provided parameters
17
- *
18
- * @param isSome
19
- * @param value
20
- * @param valueType
21
- * @returns New option from the provided parameters.
22
- */
23
- static from(isSome, value, valueType) {
24
- return new Option(isSome, value, valueType);
25
- }
26
- /**
27
- * Creates a new Option from the provided parameters
28
- *
29
- * @param value
30
- * @param valueType
31
- * @returns New option from the provided parameters.
32
- */
33
- static fromValue(value, valueType) {
34
- return this.from(Bool(true), value, valueType);
35
- }
36
- /**
37
- * @returns Empty / none option
38
- */
39
- static none() {
40
- return new Option(Bool(false), Field(0), Field);
41
- }
42
- static dummyValueFields(valueType) {
43
- const length = valueType.sizeInFields();
44
- return Array.from({ length }, () => Field(0));
45
- }
46
- /**
47
- * Computes a dummy value for the given value type.
48
- *
49
- * @param valueType - Value type to generate the dummy value for
50
- * @returns Dummy value for the given value type
51
- */
52
- static dummyValue(valueType) {
53
- const fields = Option.dummyValueFields(valueType);
54
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
55
- return valueType.fromFields(fields);
56
- }
57
- constructor(isSome, value, valueType) {
58
- this.isSome = isSome;
59
- this.value = value;
60
- this.valueType = valueType;
61
- this.isForcedSome = Bool(false);
62
- }
63
- clone() {
64
- return new Option(this.isSome, this.value, this.valueType);
65
- }
66
- forceSome() {
67
- this.isForcedSome = Circuit.if(this.isSome, Bool(false), Bool(true));
68
- this.isSome = Bool(true);
69
- }
70
- /**
71
- * @returns Tree representation of the current value
72
- */
73
- get treeValue() {
74
- const treeValue = Poseidon.hash(this.valueType.toFields(this.value));
75
- return Circuit.if(this.isSome.and(this.isForcedSome.not()), treeValue, Field(0));
76
- }
77
- /**
78
- * @returns Provable representation of the current option.
79
- */
80
- toProvable() {
81
- return new ProvableOption({
82
- isSome: this.isSome,
83
- value: this.treeValue,
84
- });
85
- }
86
- }
@@ -1,31 +0,0 @@
1
- import { Field, type FlexibleProvablePure } from "snarkyjs";
2
- /**
3
- * Helps manage path (key) identifiers for key-values in trees.
4
- */
5
- export declare class Path {
6
- /**
7
- * Encodes a JS string as a Field
8
- *
9
- * @param value
10
- * @returns Field representation of the provided value
11
- */
12
- static toField(value: string): Field;
13
- /**
14
- * Encodes a class name and its property name into a Field
15
- *
16
- * @param className
17
- * @param propertyKey
18
- * @returns Field representation of class name + property name
19
- */
20
- static fromProperty(className: string, propertyKey: string): Field;
21
- /**
22
- * Encodes an existing path with the provided key into a single Field.
23
- *
24
- * @param path
25
- * @param keyType
26
- * @param key
27
- * @returns Field representation of the leading path + the provided key.
28
- */
29
- static fromKey<KeyType>(path: Field, keyType: FlexibleProvablePure<KeyType>, key: KeyType): Field;
30
- }
31
- //# sourceMappingURL=Path.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../../src/model/Path.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,KAAK,oBAAoB,EAAY,MAAM,UAAU,CAAC;AAItE;;GAEG;AACH,qBAAa,IAAI;IACf;;;;;OAKG;WACW,OAAO,CAAC,KAAK,EAAE,MAAM;IAInC;;;;;;OAMG;WACW,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK;IAQzE;;;;;;;OAOG;WACW,OAAO,CAAC,OAAO,EAC3B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACtC,GAAG,EAAE,OAAO,GACX,KAAK;CAIT"}
@@ -1,44 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-extraneous-class */
2
- /* eslint-disable @shopify/no-fully-static-classes */
3
- import { Field, Poseidon } from "snarkyjs";
4
- import { stringToField } from "../utils/utils";
5
- /**
6
- * Helps manage path (key) identifiers for key-values in trees.
7
- */
8
- export class Path {
9
- /**
10
- * Encodes a JS string as a Field
11
- *
12
- * @param value
13
- * @returns Field representation of the provided value
14
- */
15
- static toField(value) {
16
- return stringToField(value);
17
- }
18
- /**
19
- * Encodes a class name and its property name into a Field
20
- *
21
- * @param className
22
- * @param propertyKey
23
- * @returns Field representation of class name + property name
24
- */
25
- static fromProperty(className, propertyKey) {
26
- return Poseidon.hash([
27
- Path.toField(className),
28
- Path.toField(propertyKey),
29
- Field(0),
30
- ]);
31
- }
32
- /**
33
- * Encodes an existing path with the provided key into a single Field.
34
- *
35
- * @param path
36
- * @param keyType
37
- * @param key
38
- * @returns Field representation of the leading path + the provided key.
39
- */
40
- static fromKey(path, keyType, key) {
41
- const keyHash = Poseidon.hash(keyType.toFields(key));
42
- return Poseidon.hash([path, keyHash]);
43
- }
44
- }
@@ -1,85 +0,0 @@
1
- import { Field } from "snarkyjs";
2
- import { Option, ProvableOption } from "./Option.js";
3
- declare const ProvableStateTransition_base: (new (value: {
4
- path: Field;
5
- from: ProvableOption;
6
- to: ProvableOption;
7
- }) => {
8
- path: Field;
9
- from: ProvableOption;
10
- to: ProvableOption;
11
- }) & {
12
- _isStruct: true;
13
- } & import("snarkyjs/dist/node/snarky.js").ProvablePure<{
14
- path: Field;
15
- from: ProvableOption;
16
- to: ProvableOption;
17
- }> & {
18
- toInput: (x: {
19
- path: Field;
20
- from: ProvableOption;
21
- to: ProvableOption;
22
- }) => {
23
- fields?: Field[] | undefined;
24
- packed?: [Field, number][] | undefined;
25
- };
26
- toJSON: (x: {
27
- path: Field;
28
- from: ProvableOption;
29
- to: ProvableOption;
30
- }) => {
31
- path: string;
32
- from: {
33
- isSome: boolean;
34
- value: string;
35
- };
36
- to: {
37
- isSome: boolean;
38
- value: string;
39
- };
40
- };
41
- fromJSON: (x: {
42
- path: string;
43
- from: {
44
- isSome: boolean;
45
- value: string;
46
- };
47
- to: {
48
- isSome: boolean;
49
- value: string;
50
- };
51
- }) => {
52
- path: Field;
53
- from: ProvableOption;
54
- to: ProvableOption;
55
- };
56
- };
57
- /**
58
- * Provable representation of a State Transition, used to
59
- * normalize state transitions of various value types for
60
- * the state transition circuit.
61
- */
62
- export declare class ProvableStateTransition extends ProvableStateTransition_base {
63
- static dummy(): ProvableStateTransition;
64
- }
65
- /**
66
- * Generic state transition that constraints the current method circuit
67
- * to external state, by providing a state anchor.
68
- */
69
- export declare class StateTransition<Value> {
70
- path: Field;
71
- fromValue: Option<Field> | Option<Value>;
72
- toValue: Option<Field> | Option<Value>;
73
- static from<Value>(path: Field, fromValue: Option<Value>): StateTransition<Value>;
74
- static fromTo<Value>(path: Field, fromValue: Option<Value>, toValue: Option<Value>): StateTransition<Value>;
75
- constructor(path: Field, fromValue: Option<Field> | Option<Value>, toValue: Option<Field> | Option<Value>);
76
- get from(): Option<Field> | Option<Value>;
77
- get to(): Option<Field> | Option<Value>;
78
- /**
79
- * Converts a StateTransition to a ProvableStateTransition,
80
- * while enforcing the 'from' property to be 'Some' in all cases.
81
- */
82
- toProvable(): ProvableStateTransition;
83
- }
84
- export {};
85
- //# sourceMappingURL=StateTransition.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"StateTransition.d.ts","sourceRoot":"","sources":["../../src/model/StateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,4BAQ3C;WACc,KAAK,IAAI,uBAAuB;CAO/C;AAED;;;GAGG;AACH,qBAAa,eAAe,CAAC,KAAK;IAcvB,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;WAfjC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;WAIjD,MAAM,CAAC,KAAK,EACxB,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;gBAMf,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,EACxC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAG/C,IAAW,IAAI,kCAId;IAED,IAAW,EAAE,kCAEZ;IAED;;;OAGG;IACI,UAAU,IAAI,uBAAuB;CAO7C"}
@@ -1,58 +0,0 @@
1
- import { Field, Struct } from "snarkyjs";
2
- import { Option, ProvableOption } from "./Option.js";
3
- /**
4
- * Provable representation of a State Transition, used to
5
- * normalize state transitions of various value types for
6
- * the state transition circuit.
7
- */
8
- export class ProvableStateTransition extends Struct({
9
- path: Field,
10
- // must be applied even if `None`
11
- from: ProvableOption,
12
- // must be ignored if `None`
13
- to: ProvableOption,
14
- }) {
15
- static dummy() {
16
- return new ProvableStateTransition({
17
- path: Field(0),
18
- from: Option.none().toProvable(),
19
- to: Option.none().toProvable(),
20
- });
21
- }
22
- }
23
- /**
24
- * Generic state transition that constraints the current method circuit
25
- * to external state, by providing a state anchor.
26
- */
27
- export class StateTransition {
28
- static from(path, fromValue) {
29
- return new StateTransition(path, fromValue, Option.none());
30
- }
31
- static fromTo(path, fromValue, toValue) {
32
- return new StateTransition(path, fromValue, toValue);
33
- }
34
- constructor(path, fromValue, toValue) {
35
- this.path = path;
36
- this.fromValue = fromValue;
37
- this.toValue = toValue;
38
- }
39
- get from() {
40
- const from = this.fromValue.clone();
41
- from.forceSome();
42
- return from;
43
- }
44
- get to() {
45
- return this.toValue.clone();
46
- }
47
- /**
48
- * Converts a StateTransition to a ProvableStateTransition,
49
- * while enforcing the 'from' property to be 'Some' in all cases.
50
- */
51
- toProvable() {
52
- return new ProvableStateTransition({
53
- path: this.path,
54
- from: this.from.toProvable(),
55
- to: this.to.toProvable(),
56
- });
57
- }
58
- }