@proto-kit/module 0.1.1-develop.244 → 0.1.1-develop.254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/method/runtimeMethod.d.ts +2 -1
- package/dist/method/runtimeMethod.d.ts.map +1 -1
- package/dist/method/runtimeMethod.js +29 -3
- package/package.json +2 -2
- package/src/method/runtimeMethod.ts +58 -5
- package/test/modules/Balances.test.ts +4 -8
- package/test/modules/Balances.ts +2 -5
- package/test/modules/State.test.ts +8 -3
- package/test/runtimeMethod.test.ts +55 -6
- package/test/transaction.test.ts +1 -1
- package/dist/method/RuntimeMethodExecutionContext.d.ts +0 -57
- package/dist/method/RuntimeMethodExecutionContext.d.ts.map +0 -1
- package/dist/method/RuntimeMethodExecutionContext.js +0 -92
- package/dist/method/assert.d.ts +0 -12
- package/dist/method/assert.d.ts.map +0 -1
- package/dist/method/assert.js +0 -23
- package/dist/module/src/factories/MethodIdFactory.d.ts +0 -9
- package/dist/module/src/factories/MethodIdFactory.d.ts.map +0 -1
- package/dist/module/src/factories/MethodIdFactory.js +0 -36
- package/dist/module/src/index.d.ts +0 -11
- package/dist/module/src/index.d.ts.map +0 -1
- package/dist/module/src/index.js +0 -10
- package/dist/module/src/method/MethodParameterDecoder.d.ts +0 -22
- package/dist/module/src/method/MethodParameterDecoder.d.ts.map +0 -1
- package/dist/module/src/method/MethodParameterDecoder.js +0 -33
- package/dist/module/src/method/runtimeMethod.d.ts +0 -19
- package/dist/module/src/method/runtimeMethod.d.ts.map +0 -1
- package/dist/module/src/method/runtimeMethod.js +0 -123
- package/dist/module/src/module/decorator.d.ts +0 -8
- package/dist/module/src/module/decorator.d.ts.map +0 -1
- package/dist/module/src/module/decorator.js +0 -15
- package/dist/module/src/runtime/MethodIdResolver.d.ts +0 -18
- package/dist/module/src/runtime/MethodIdResolver.d.ts.map +0 -1
- package/dist/module/src/runtime/MethodIdResolver.js +0 -50
- package/dist/module/src/runtime/Runtime.d.ts +0 -72
- package/dist/module/src/runtime/Runtime.d.ts.map +0 -1
- package/dist/module/src/runtime/Runtime.js +0 -184
- package/dist/module/src/runtime/RuntimeModule.d.ts +0 -34
- package/dist/module/src/runtime/RuntimeModule.d.ts.map +0 -1
- package/dist/module/src/runtime/RuntimeModule.js +0 -56
- package/dist/module/src/state/InMemoryStateService.d.ts +0 -11
- package/dist/module/src/state/InMemoryStateService.d.ts.map +0 -1
- package/dist/module/src/state/InMemoryStateService.js +0 -21
- package/dist/module/src/state/decorator.d.ts +0 -7
- package/dist/module/src/state/decorator.d.ts.map +0 -1
- package/dist/module/src/state/decorator.js +0 -42
- package/dist/protocol/src/model/Option.d.ts +0 -98
- package/dist/protocol/src/model/Option.d.ts.map +0 -1
- package/dist/protocol/src/model/Option.js +0 -98
- package/dist/protocol/src/model/StateTransition.d.ts +0 -96
- package/dist/protocol/src/model/StateTransition.d.ts.map +0 -1
- package/dist/protocol/src/model/StateTransition.js +0 -65
- package/dist/protocol/src/model/network/NetworkState.d.ts +0 -64
- package/dist/protocol/src/model/network/NetworkState.d.ts.map +0 -1
- package/dist/protocol/src/model/network/NetworkState.js +0 -12
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts +0 -70
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts.map +0 -1
- package/dist/protocol/src/model/transaction/ProtocolTransaction.js +0 -18
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts +0 -63
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts.map +0 -1
- package/dist/protocol/src/model/transaction/RuntimeTransaction.js +0 -29
- package/dist/protocol/src/state/assert/assert.d.ts +0 -12
- package/dist/protocol/src/state/assert/assert.d.ts.map +0 -1
- package/dist/protocol/src/state/assert/assert.js +0 -23
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts +0 -60
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts.map +0 -1
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.js +0 -105
- package/dist/state/State.d.ts +0 -65
- package/dist/state/State.d.ts.map +0 -1
- package/dist/state/State.js +0 -114
- package/dist/state/StateMap.d.ts +0 -37
- package/dist/state/StateMap.d.ts.map +0 -1
- package/dist/state/StateMap.js +0 -56
- package/dist/state/StateServiceProvider.d.ts +0 -10
- package/dist/state/StateServiceProvider.d.ts.map +0 -1
- package/dist/state/StateServiceProvider.js +0 -34
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryStateService.d.ts","sourceRoot":"","sources":["../../../../src/state/InMemoryStateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,CAAM;IAEjD,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,SAAS;IAIpC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS;CAWlD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Naive implementation of a StateService for testing purposes
|
|
3
|
-
*/
|
|
4
|
-
export class InMemoryStateService {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.values = {};
|
|
7
|
-
}
|
|
8
|
-
get(key) {
|
|
9
|
-
return this.values[key.toString()];
|
|
10
|
-
}
|
|
11
|
-
set(key, value) {
|
|
12
|
-
if (value === undefined &&
|
|
13
|
-
Object.prototype.hasOwnProperty.call(this.values, key.toString())) {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
15
|
-
delete this.values[key.toString()];
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.values[key.toString()] = value;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RuntimeModule } from "../runtime/RuntimeModule.js";
|
|
2
|
-
/**
|
|
3
|
-
* Decorates a runtime module property as state, passing down some
|
|
4
|
-
* underlying values to improve developer experience.
|
|
5
|
-
*/
|
|
6
|
-
export declare function state(): <TargetRuntimeModule extends RuntimeModule<unknown>>(target: TargetRuntimeModule, propertyKey: string) => void;
|
|
7
|
-
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../src/state/decorator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAgBjE;;;GAGG;AACH,wBAAgB,KAAK,mGAGJ,MAAM,UAqCtB"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Path } from "@proto-kit/protocol";
|
|
2
|
-
const errors = {
|
|
3
|
-
missingName: (className) => new Error(`Unable to provide a unique identifier for state, ${className} is missing a name.
|
|
4
|
-
Did you forget to extend your runtime module with 'extends RuntimeModule'?`),
|
|
5
|
-
missingRuntime: (className) => new Error(`Unable to provide 'runtime' for state, ${className} is missing a name.
|
|
6
|
-
Did you forget to extend your runtime module with 'extends RuntimeModule'?`),
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Decorates a runtime module property as state, passing down some
|
|
10
|
-
* underlying values to improve developer experience.
|
|
11
|
-
*/
|
|
12
|
-
export function state() {
|
|
13
|
-
return (target, propertyKey) => {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
15
|
-
let value;
|
|
16
|
-
Object.defineProperty(target, propertyKey, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
// eslint-disable-next-line max-len
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
21
|
-
const self = this;
|
|
22
|
-
if (self.name === undefined) {
|
|
23
|
-
throw errors.missingName(self.constructor.name);
|
|
24
|
-
}
|
|
25
|
-
if (!self.runtime) {
|
|
26
|
-
throw errors.missingRuntime(self.constructor.name);
|
|
27
|
-
}
|
|
28
|
-
const path = Path.fromProperty(self.name, propertyKey);
|
|
29
|
-
if (value) {
|
|
30
|
-
value.path = path;
|
|
31
|
-
// eslint-disable-next-line no-warning-comments
|
|
32
|
-
// TODO: why is this complaining about `any`?
|
|
33
|
-
value.stateServiceProvider = self.runtime.stateServiceProvider;
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
},
|
|
37
|
-
set: (newValue) => {
|
|
38
|
-
value = newValue;
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, type FlexibleProvablePure } from "snarkyjs";
|
|
2
|
-
declare const ProvableOption_base: (new (value: {
|
|
3
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
4
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
5
|
-
}) => {
|
|
6
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
7
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
8
|
-
}) & {
|
|
9
|
-
_isStruct: true;
|
|
10
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
11
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
12
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
13
|
-
}> & {
|
|
14
|
-
toInput: (x: {
|
|
15
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
16
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
17
|
-
}) => {
|
|
18
|
-
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
19
|
-
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
20
|
-
};
|
|
21
|
-
toJSON: (x: {
|
|
22
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
23
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
24
|
-
}) => {
|
|
25
|
-
isSome: boolean;
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
fromJSON: (x: {
|
|
29
|
-
isSome: boolean;
|
|
30
|
-
value: string;
|
|
31
|
-
}) => {
|
|
32
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
33
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare class ProvableOption extends ProvableOption_base {
|
|
37
|
-
toSome(): this;
|
|
38
|
-
}
|
|
39
|
-
export interface ToFieldable {
|
|
40
|
-
toFields: () => Field[];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Option facilitating in-circuit values that may or may not exist.
|
|
44
|
-
*/
|
|
45
|
-
export declare class Option<Value> {
|
|
46
|
-
isSome: Bool;
|
|
47
|
-
value: Value;
|
|
48
|
-
valueType: FlexibleProvablePure<Value>;
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new Option from the provided parameters
|
|
51
|
-
*
|
|
52
|
-
* @param isSome
|
|
53
|
-
* @param value
|
|
54
|
-
* @param valueType
|
|
55
|
-
* @returns New option from the provided parameters.
|
|
56
|
-
*/
|
|
57
|
-
static from<Value>(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new Option from the provided parameters
|
|
60
|
-
*
|
|
61
|
-
* @param value
|
|
62
|
-
* @param valueType
|
|
63
|
-
* @returns New option from the provided parameters.
|
|
64
|
-
*/
|
|
65
|
-
static fromValue<Value>(value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
|
|
66
|
-
/**
|
|
67
|
-
* @returns Empty / none option
|
|
68
|
-
*/
|
|
69
|
-
static none(): Option<import("snarkyjs/dist/node/lib/field").Field>;
|
|
70
|
-
isForcedSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
71
|
-
constructor(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>);
|
|
72
|
-
clone(): Option<Value>;
|
|
73
|
-
forceSome(): void;
|
|
74
|
-
/**
|
|
75
|
-
* @returns Tree representation of the current value
|
|
76
|
-
*/
|
|
77
|
-
get treeValue(): import("snarkyjs/dist/node/lib/field").Field;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the `to`-value as decoded as a list of fields
|
|
80
|
-
* Not in circuit
|
|
81
|
-
*/
|
|
82
|
-
toFields(): Field[];
|
|
83
|
-
/**
|
|
84
|
-
* @returns Provable representation of the current option.
|
|
85
|
-
*/
|
|
86
|
-
toProvable(): ProvableOption;
|
|
87
|
-
/**
|
|
88
|
-
* @returns Returns the value of this option if it isSome,
|
|
89
|
-
* otherwise returns the given defaultValue
|
|
90
|
-
*/
|
|
91
|
-
orElse(defaultValue: Value): Value;
|
|
92
|
-
toJSON(): {
|
|
93
|
-
isSome: boolean;
|
|
94
|
-
value: string;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export {};
|
|
98
|
-
//# sourceMappingURL=Option.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Option.d.ts","sourceRoot":"","sources":["../../../../../protocol/src/model/Option.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EAEL,KAAK,oBAAoB,EAI1B,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,qBAAa,cAAe,SAAQ,mBAGlC;IACO,MAAM;CAId;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,MAAM,CAAC,KAAK;IAyCd,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IA1C/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;IAIX,YAAY,6CAAe;gBAGzB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAGxC,KAAK;IAIL,SAAS;IAKhB;;OAEG;IACH,IAAW,SAAS,iDAQnB;IAED;;;OAGG;IACI,QAAQ,IAAI,KAAK,EAAE;IAO1B;;OAEG;IACI,UAAU;IAOjB;;;OAGG;IACI,MAAM,CAAC,YAAY,EAAE,KAAK,GAAG,KAAK;IASlC,MAAM;;;;CAYd"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, Poseidon, Provable, 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
|
-
constructor(isSome, value, valueType) {
|
|
43
|
-
this.isSome = isSome;
|
|
44
|
-
this.value = value;
|
|
45
|
-
this.valueType = valueType;
|
|
46
|
-
this.isForcedSome = Bool(false);
|
|
47
|
-
}
|
|
48
|
-
clone() {
|
|
49
|
-
return new Option(this.isSome, this.value, this.valueType);
|
|
50
|
-
}
|
|
51
|
-
forceSome() {
|
|
52
|
-
this.isForcedSome = Provable.if(this.isSome, Bool(false), Bool(true));
|
|
53
|
-
this.isSome = Bool(true);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @returns Tree representation of the current value
|
|
57
|
-
*/
|
|
58
|
-
get treeValue() {
|
|
59
|
-
const treeValue = Poseidon.hash(this.valueType.toFields(this.value));
|
|
60
|
-
return Provable.if(this.isSome.and(this.isForcedSome.not()), treeValue, Field(0));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns the `to`-value as decoded as a list of fields
|
|
64
|
-
* Not in circuit
|
|
65
|
-
*/
|
|
66
|
-
toFields() {
|
|
67
|
-
if (this.isSome.toBoolean()) {
|
|
68
|
-
return this.valueType.toFields(this.value);
|
|
69
|
-
}
|
|
70
|
-
return [Field(0)];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @returns Provable representation of the current option.
|
|
74
|
-
*/
|
|
75
|
-
toProvable() {
|
|
76
|
-
return new ProvableOption({
|
|
77
|
-
isSome: this.isSome,
|
|
78
|
-
value: this.treeValue,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @returns Returns the value of this option if it isSome,
|
|
83
|
-
* otherwise returns the given defaultValue
|
|
84
|
-
*/
|
|
85
|
-
orElse(defaultValue) {
|
|
86
|
-
return Provable.if(this.isSome, this.valueType, this.value, defaultValue);
|
|
87
|
-
}
|
|
88
|
-
toJSON() {
|
|
89
|
-
const valueContent = this.valueType
|
|
90
|
-
.toFields(this.value)
|
|
91
|
-
.map((field) => field.toString())
|
|
92
|
-
.reduce((a, b) => `${a}, ${b}`);
|
|
93
|
-
return {
|
|
94
|
-
isSome: this.isSome.toBoolean(),
|
|
95
|
-
value: `[${valueContent}]`,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Field } from "snarkyjs";
|
|
2
|
-
import { Option, ProvableOption } from "./Option.js";
|
|
3
|
-
declare const ProvableStateTransition_base: (new (value: {
|
|
4
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
5
|
-
from: ProvableOption;
|
|
6
|
-
to: ProvableOption;
|
|
7
|
-
}) => {
|
|
8
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
9
|
-
from: ProvableOption;
|
|
10
|
-
to: ProvableOption;
|
|
11
|
-
}) & {
|
|
12
|
-
_isStruct: true;
|
|
13
|
-
} & import("snarkyjs/dist/node/snarky.js").ProvablePure<{
|
|
14
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
15
|
-
from: ProvableOption;
|
|
16
|
-
to: ProvableOption;
|
|
17
|
-
}> & {
|
|
18
|
-
toInput: (x: {
|
|
19
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
20
|
-
from: ProvableOption;
|
|
21
|
-
to: ProvableOption;
|
|
22
|
-
}) => {
|
|
23
|
-
fields?: import("snarkyjs/dist/node/lib/field.js").Field[] | undefined;
|
|
24
|
-
packed?: [import("snarkyjs/dist/node/lib/field.js").Field, number][] | undefined;
|
|
25
|
-
};
|
|
26
|
-
toJSON: (x: {
|
|
27
|
-
path: import("snarkyjs/dist/node/lib/field.js").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: import("snarkyjs/dist/node/lib/field.js").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<import("snarkyjs/dist/node/lib/field.js").Field> | Option<Value>;
|
|
77
|
-
get to(): Option<import("snarkyjs/dist/node/lib/field.js").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
|
-
toJSON(): {
|
|
84
|
-
path: string;
|
|
85
|
-
from: {
|
|
86
|
-
isSome: boolean;
|
|
87
|
-
value: string;
|
|
88
|
-
};
|
|
89
|
-
to: {
|
|
90
|
-
isSome: boolean;
|
|
91
|
-
value: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export {};
|
|
96
|
-
//# sourceMappingURL=StateTransition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransition.d.ts","sourceRoot":"","sources":["../../../../../protocol/src/model/StateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElE;;;;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,4EAId;IAED,IAAW,EAAE,4EAEZ;IAED;;;OAGG;IACI,UAAU,IAAI,uBAAuB;IAQrC,MAAM;;;;;;;;;;;CAOd"}
|
|
@@ -1,65 +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
|
-
toJSON() {
|
|
59
|
-
return {
|
|
60
|
-
path: this.path.toString(),
|
|
61
|
-
from: this.from.toJSON(),
|
|
62
|
-
to: this.to.toJSON(),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Field, UInt64 } from "snarkyjs";
|
|
2
|
-
declare const CurrentBlock_base: (new (value: {
|
|
3
|
-
height: UInt64;
|
|
4
|
-
}) => {
|
|
5
|
-
height: UInt64;
|
|
6
|
-
}) & {
|
|
7
|
-
_isStruct: true;
|
|
8
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
9
|
-
height: UInt64;
|
|
10
|
-
}> & {
|
|
11
|
-
toInput: (x: {
|
|
12
|
-
height: UInt64;
|
|
13
|
-
}) => {
|
|
14
|
-
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
15
|
-
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
16
|
-
};
|
|
17
|
-
toJSON: (x: {
|
|
18
|
-
height: UInt64;
|
|
19
|
-
}) => {
|
|
20
|
-
height: string;
|
|
21
|
-
};
|
|
22
|
-
fromJSON: (x: {
|
|
23
|
-
height: string;
|
|
24
|
-
}) => {
|
|
25
|
-
height: UInt64;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
export declare class CurrentBlock extends CurrentBlock_base {
|
|
29
|
-
}
|
|
30
|
-
declare const NetworkState_base: (new (value: {
|
|
31
|
-
block: CurrentBlock;
|
|
32
|
-
}) => {
|
|
33
|
-
block: CurrentBlock;
|
|
34
|
-
}) & {
|
|
35
|
-
_isStruct: true;
|
|
36
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
37
|
-
block: CurrentBlock;
|
|
38
|
-
}> & {
|
|
39
|
-
toInput: (x: {
|
|
40
|
-
block: CurrentBlock;
|
|
41
|
-
}) => {
|
|
42
|
-
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
43
|
-
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
44
|
-
};
|
|
45
|
-
toJSON: (x: {
|
|
46
|
-
block: CurrentBlock;
|
|
47
|
-
}) => {
|
|
48
|
-
block: {
|
|
49
|
-
height: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
fromJSON: (x: {
|
|
53
|
-
block: {
|
|
54
|
-
height: string;
|
|
55
|
-
};
|
|
56
|
-
}) => {
|
|
57
|
-
block: CurrentBlock;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export declare class NetworkState extends NetworkState_base {
|
|
61
|
-
hash(): Field;
|
|
62
|
-
}
|
|
63
|
-
export {};
|
|
64
|
-
//# sourceMappingURL=NetworkState.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkState.d.ts","sourceRoot":"","sources":["../../../../../../protocol/src/model/network/NetworkState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,MAAM,EAAE,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE3D,qBAAa,YAAa,SAAQ,iBAEhC;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,YAAa,SAAQ,iBAEhC;IACO,IAAI,IAAI,KAAK;CAGrB"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Poseidon, Struct, UInt64 } from "snarkyjs";
|
|
2
|
-
export class CurrentBlock extends Struct({
|
|
3
|
-
height: UInt64,
|
|
4
|
-
}) {
|
|
5
|
-
}
|
|
6
|
-
export class NetworkState extends Struct({
|
|
7
|
-
block: CurrentBlock,
|
|
8
|
-
}) {
|
|
9
|
-
hash() {
|
|
10
|
-
return Poseidon.hash(CurrentBlock.toFields(this.block));
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, PublicKey, Signature, UInt64 } from "snarkyjs";
|
|
2
|
-
declare const ProtocolTransaction_base: (new (value: {
|
|
3
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
4
|
-
nonce: UInt64;
|
|
5
|
-
sender: PublicKey;
|
|
6
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
7
|
-
signature: Signature;
|
|
8
|
-
}) => {
|
|
9
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
10
|
-
nonce: UInt64;
|
|
11
|
-
sender: PublicKey;
|
|
12
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
13
|
-
signature: Signature;
|
|
14
|
-
}) & {
|
|
15
|
-
_isStruct: true;
|
|
16
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
17
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
18
|
-
nonce: UInt64;
|
|
19
|
-
sender: PublicKey;
|
|
20
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
21
|
-
signature: Signature;
|
|
22
|
-
}> & {
|
|
23
|
-
toInput: (x: {
|
|
24
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
25
|
-
nonce: UInt64;
|
|
26
|
-
sender: PublicKey;
|
|
27
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
28
|
-
signature: Signature;
|
|
29
|
-
}) => {
|
|
30
|
-
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
31
|
-
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
32
|
-
};
|
|
33
|
-
toJSON: (x: {
|
|
34
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
35
|
-
nonce: UInt64;
|
|
36
|
-
sender: PublicKey;
|
|
37
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
38
|
-
signature: Signature;
|
|
39
|
-
}) => {
|
|
40
|
-
methodId: string;
|
|
41
|
-
nonce: string;
|
|
42
|
-
sender: string;
|
|
43
|
-
argsHash: string;
|
|
44
|
-
signature: any;
|
|
45
|
-
};
|
|
46
|
-
fromJSON: (x: {
|
|
47
|
-
methodId: string;
|
|
48
|
-
nonce: string;
|
|
49
|
-
sender: string;
|
|
50
|
-
argsHash: string;
|
|
51
|
-
signature: any;
|
|
52
|
-
}) => {
|
|
53
|
-
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
54
|
-
nonce: UInt64;
|
|
55
|
-
sender: PublicKey;
|
|
56
|
-
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
57
|
-
signature: Signature;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export declare class ProtocolTransaction extends ProtocolTransaction_base {
|
|
61
|
-
static getSignatureData(args: {
|
|
62
|
-
methodId: Field;
|
|
63
|
-
nonce: UInt64;
|
|
64
|
-
argsHash: Field;
|
|
65
|
-
}): Field[];
|
|
66
|
-
getSignatureData(): Field[];
|
|
67
|
-
validateSignature(): Bool;
|
|
68
|
-
}
|
|
69
|
-
export {};
|
|
70
|
-
//# sourceMappingURL=ProtocolTransaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolTransaction.d.ts","sourceRoot":"","sources":["../../../../../../protocol/src/model/transaction/ProtocolTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAU,MAAM,EAAE,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE7E,qBAAa,mBAAoB,SAAQ,wBAMvC;WACc,gBAAgB,CAAC,IAAI,EAAE;QACnC,QAAQ,EAAE,KAAK,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC;KACjB,GAAG,KAAK,EAAE;IAIJ,gBAAgB,IAAI,KAAK,EAAE;IAI3B,iBAAiB,IAAI,IAAI;CAGjC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Field, PublicKey, Signature, Struct, UInt64 } from "snarkyjs";
|
|
2
|
-
export class ProtocolTransaction extends Struct({
|
|
3
|
-
methodId: Field,
|
|
4
|
-
nonce: UInt64,
|
|
5
|
-
sender: PublicKey,
|
|
6
|
-
argsHash: Field,
|
|
7
|
-
signature: Signature,
|
|
8
|
-
}) {
|
|
9
|
-
static getSignatureData(args) {
|
|
10
|
-
return [args.methodId, ...args.nonce.toFields(), args.argsHash];
|
|
11
|
-
}
|
|
12
|
-
getSignatureData() {
|
|
13
|
-
return ProtocolTransaction.getSignatureData(this);
|
|
14
|
-
}
|
|
15
|
-
validateSignature() {
|
|
16
|
-
return this.signature.verify(this.sender, this.getSignatureData());
|
|
17
|
-
}
|
|
18
|
-
}
|