@proto-kit/module 0.1.1-develop.191 → 0.1.1-develop.239
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/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -5
- package/dist/method/MethodParameterDecoder.d.ts.map +1 -1
- package/dist/method/MethodParameterDecoder.js +1 -1
- package/dist/method/RuntimeMethodExecutionContext.d.ts +2 -2
- package/dist/method/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/method/runtimeMethod.d.ts.map +1 -1
- package/dist/method/runtimeMethod.js +1 -2
- package/dist/module/src/factories/MethodIdFactory.d.ts +9 -0
- package/dist/module/src/factories/MethodIdFactory.d.ts.map +1 -0
- package/dist/module/src/factories/MethodIdFactory.js +36 -0
- package/dist/module/src/index.d.ts +11 -0
- package/dist/module/src/index.d.ts.map +1 -0
- package/dist/module/src/index.js +10 -0
- package/dist/module/src/method/MethodParameterDecoder.d.ts +22 -0
- package/dist/module/src/method/MethodParameterDecoder.d.ts.map +1 -0
- package/dist/module/src/method/MethodParameterDecoder.js +33 -0
- package/dist/module/src/method/runtimeMethod.d.ts +19 -0
- package/dist/module/src/method/runtimeMethod.d.ts.map +1 -0
- package/dist/module/src/method/runtimeMethod.js +123 -0
- package/dist/module/src/module/decorator.d.ts +8 -0
- package/dist/module/src/module/decorator.d.ts.map +1 -0
- package/dist/module/src/module/decorator.js +15 -0
- package/dist/module/src/runtime/MethodIdResolver.d.ts +18 -0
- package/dist/module/src/runtime/MethodIdResolver.d.ts.map +1 -0
- package/dist/module/src/runtime/MethodIdResolver.js +50 -0
- package/dist/module/src/runtime/Runtime.d.ts +72 -0
- package/dist/module/src/runtime/Runtime.d.ts.map +1 -0
- package/dist/module/src/runtime/Runtime.js +184 -0
- package/dist/module/src/runtime/RuntimeModule.d.ts +34 -0
- package/dist/module/src/runtime/RuntimeModule.d.ts.map +1 -0
- package/dist/module/src/runtime/RuntimeModule.js +56 -0
- package/dist/module/src/state/InMemoryStateService.d.ts +11 -0
- package/dist/module/src/state/InMemoryStateService.d.ts.map +1 -0
- package/dist/module/src/state/InMemoryStateService.js +21 -0
- package/dist/module/src/state/decorator.d.ts +7 -0
- package/dist/module/src/state/decorator.d.ts.map +1 -0
- package/dist/module/src/state/decorator.js +42 -0
- package/dist/protocol/src/model/Option.d.ts +98 -0
- package/dist/protocol/src/model/Option.d.ts.map +1 -0
- package/dist/protocol/src/model/Option.js +98 -0
- package/dist/protocol/src/model/StateTransition.d.ts +96 -0
- package/dist/protocol/src/model/StateTransition.d.ts.map +1 -0
- package/dist/protocol/src/model/StateTransition.js +65 -0
- package/dist/protocol/src/model/network/NetworkState.d.ts +64 -0
- package/dist/protocol/src/model/network/NetworkState.d.ts.map +1 -0
- package/dist/protocol/src/model/network/NetworkState.js +12 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts +70 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts.map +1 -0
- package/dist/protocol/src/model/transaction/ProtocolTransaction.js +18 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts +63 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts.map +1 -0
- package/dist/protocol/src/model/transaction/RuntimeTransaction.js +29 -0
- package/dist/protocol/src/state/assert/assert.d.ts +12 -0
- package/dist/protocol/src/state/assert/assert.d.ts.map +1 -0
- package/dist/protocol/src/state/assert/assert.js +23 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts +60 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -0
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.js +105 -0
- package/dist/runtime/Runtime.d.ts +6 -5
- package/dist/runtime/Runtime.d.ts.map +1 -1
- package/dist/runtime/Runtime.js +5 -7
- package/dist/runtime/RuntimeModule.d.ts +1 -3
- package/dist/runtime/RuntimeModule.d.ts.map +1 -1
- package/dist/runtime/RuntimeModule.js +1 -1
- package/dist/state/InMemoryStateService.d.ts +1 -4
- package/dist/state/InMemoryStateService.d.ts.map +1 -1
- package/dist/state/StateMap.d.ts +3 -3
- package/dist/state/StateMap.d.ts.map +1 -1
- package/dist/state/decorator.d.ts.map +1 -1
- package/dist/state/decorator.js +1 -1
- package/package.json +3 -4
- package/src/index.ts +0 -5
- package/src/method/MethodParameterDecoder.ts +3 -1
- package/src/method/runtimeMethod.ts +1 -2
- package/src/runtime/Runtime.ts +12 -10
- package/src/runtime/RuntimeModule.ts +5 -6
- package/src/state/InMemoryStateService.ts +1 -5
- package/src/state/decorator.ts +2 -4
- package/test/Runtime.test.ts +2 -2
- package/test/modules/Admin.ts +1 -1
- package/test/modules/Balances.test.ts +13 -8
- package/test/modules/Balances.ts +7 -3
- package/test/modules/State.test.ts +88 -0
- package/test/modules/methodId.test.ts +0 -1
- package/test/transaction.test.ts +1 -1
- package/src/method/RuntimeMethodExecutionContext.ts +0 -111
- package/src/method/assert.test.ts +0 -49
- package/src/method/assert.ts +0 -27
- package/src/state/State.ts +0 -154
- package/src/state/StateMap.ts +0 -69
- package/src/state/StateServiceProvider.ts +0 -24
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Field, PublicKey, UInt64 } from "snarkyjs";
|
|
2
|
+
import { ProtocolTransaction } from "./ProtocolTransaction";
|
|
3
|
+
declare const RuntimeTransaction_base: (new (value: {
|
|
4
|
+
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
5
|
+
nonce: UInt64;
|
|
6
|
+
sender: PublicKey;
|
|
7
|
+
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
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
|
+
}) & {
|
|
14
|
+
_isStruct: true;
|
|
15
|
+
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
16
|
+
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
17
|
+
nonce: UInt64;
|
|
18
|
+
sender: PublicKey;
|
|
19
|
+
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
20
|
+
}> & {
|
|
21
|
+
toInput: (x: {
|
|
22
|
+
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
23
|
+
nonce: UInt64;
|
|
24
|
+
sender: PublicKey;
|
|
25
|
+
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
26
|
+
}) => {
|
|
27
|
+
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
28
|
+
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
29
|
+
};
|
|
30
|
+
toJSON: (x: {
|
|
31
|
+
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
32
|
+
nonce: UInt64;
|
|
33
|
+
sender: PublicKey;
|
|
34
|
+
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
35
|
+
}) => {
|
|
36
|
+
methodId: string;
|
|
37
|
+
nonce: string;
|
|
38
|
+
sender: string;
|
|
39
|
+
argsHash: string;
|
|
40
|
+
};
|
|
41
|
+
fromJSON: (x: {
|
|
42
|
+
methodId: string;
|
|
43
|
+
nonce: string;
|
|
44
|
+
sender: string;
|
|
45
|
+
argsHash: string;
|
|
46
|
+
}) => {
|
|
47
|
+
methodId: import("snarkyjs/dist/node/lib/field").Field;
|
|
48
|
+
nonce: UInt64;
|
|
49
|
+
sender: PublicKey;
|
|
50
|
+
argsHash: import("snarkyjs/dist/node/lib/field").Field;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* This struct is used to expose transaction information to the runtime method
|
|
55
|
+
* execution. This class has not all data included in transactions on purpose.
|
|
56
|
+
* For example, we don't want to expose the signature or args as fields.
|
|
57
|
+
*/
|
|
58
|
+
export declare class RuntimeTransaction extends RuntimeTransaction_base {
|
|
59
|
+
static fromProtocolTransaction({ methodId, nonce, sender, argsHash, }: ProtocolTransaction): RuntimeTransaction;
|
|
60
|
+
hash(): Field;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=RuntimeTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeTransaction.d.ts","sourceRoot":"","sources":["../../../../../../protocol/src/model/transaction/RuntimeTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,SAAS,EAAU,MAAM,EAAE,MAAM,UAAU,CAAC;AAEtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE5D;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,uBAKtC;WACc,uBAAuB,CAAC,EACpC,QAAQ,EACR,KAAK,EACL,MAAM,EACN,QAAQ,GACT,EAAE,mBAAmB,GAAG,kBAAkB;IASpC,IAAI,IAAI,KAAK;CAQrB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Field, Poseidon, PublicKey, Struct, UInt64 } from "snarkyjs";
|
|
2
|
+
/**
|
|
3
|
+
* This struct is used to expose transaction information to the runtime method
|
|
4
|
+
* execution. This class has not all data included in transactions on purpose.
|
|
5
|
+
* For example, we don't want to expose the signature or args as fields.
|
|
6
|
+
*/
|
|
7
|
+
export class RuntimeTransaction extends Struct({
|
|
8
|
+
methodId: Field,
|
|
9
|
+
nonce: UInt64,
|
|
10
|
+
sender: PublicKey,
|
|
11
|
+
argsHash: Field,
|
|
12
|
+
}) {
|
|
13
|
+
static fromProtocolTransaction({ methodId, nonce, sender, argsHash, }) {
|
|
14
|
+
return new RuntimeTransaction({
|
|
15
|
+
methodId,
|
|
16
|
+
nonce,
|
|
17
|
+
sender,
|
|
18
|
+
argsHash,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
hash() {
|
|
22
|
+
return Poseidon.hash([
|
|
23
|
+
this.methodId,
|
|
24
|
+
...this.sender.toFields(),
|
|
25
|
+
...this.nonce.toFields(),
|
|
26
|
+
this.argsHash,
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Bool } from "snarkyjs";
|
|
2
|
+
/**
|
|
3
|
+
* Maintains an execution status of the current runtime module method,
|
|
4
|
+
* while prioritizing one-time failures. The assertion won't change the
|
|
5
|
+
* execution status if it has previously failed at least once within the
|
|
6
|
+
* same method execution context.
|
|
7
|
+
*
|
|
8
|
+
* @param condition - Result of the assertion made about the execution status
|
|
9
|
+
* @param message - Optional message describing the prior status
|
|
10
|
+
*/
|
|
11
|
+
export declare function assert(condition: Bool, message?: string): void;
|
|
12
|
+
//# sourceMappingURL=assert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../../../../protocol/src/state/assert/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,UAAU,CAAC;AAO1C;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,QAWvD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Bool, Provable } from "snarkyjs";
|
|
2
|
+
import { container } from "tsyringe";
|
|
3
|
+
import { log } from "@proto-kit/common";
|
|
4
|
+
import { RuntimeMethodExecutionContext } from "../context/RuntimeMethodExecutionContext";
|
|
5
|
+
/**
|
|
6
|
+
* Maintains an execution status of the current runtime module method,
|
|
7
|
+
* while prioritizing one-time failures. The assertion won't change the
|
|
8
|
+
* execution status if it has previously failed at least once within the
|
|
9
|
+
* same method execution context.
|
|
10
|
+
*
|
|
11
|
+
* @param condition - Result of the assertion made about the execution status
|
|
12
|
+
* @param message - Optional message describing the prior status
|
|
13
|
+
*/
|
|
14
|
+
export function assert(condition, message) {
|
|
15
|
+
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
16
|
+
const previousStatus = executionContext.current().result.status;
|
|
17
|
+
const status = Provable.if(previousStatus, Bool, condition, previousStatus);
|
|
18
|
+
if (!condition.toBoolean()) {
|
|
19
|
+
log.debug("Assertion failed: ", message);
|
|
20
|
+
executionContext.setStatusMessage(message);
|
|
21
|
+
}
|
|
22
|
+
executionContext.setStatus(status);
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Bool } from "snarkyjs";
|
|
2
|
+
import { ProvableMethodExecutionContext, ProvableMethodExecutionResult } from "@proto-kit/common";
|
|
3
|
+
import { StateTransition } from "../../model/StateTransition";
|
|
4
|
+
import { RuntimeTransaction } from "../../model/transaction/RuntimeTransaction";
|
|
5
|
+
import { NetworkState } from "../../model/network/NetworkState";
|
|
6
|
+
export declare class RuntimeProvableMethodExecutionResult extends ProvableMethodExecutionResult {
|
|
7
|
+
stateTransitions: StateTransition<any>[];
|
|
8
|
+
status: Bool;
|
|
9
|
+
statusMessage?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RuntimeMethodExecutionData {
|
|
12
|
+
transaction: RuntimeTransaction;
|
|
13
|
+
networkState: NetworkState;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Execution context used to wrap runtime module methods,
|
|
17
|
+
* allowing them to post relevant information (such as execution status)
|
|
18
|
+
* into the context without any unnecessary 'prop drilling'.
|
|
19
|
+
*/
|
|
20
|
+
export declare class RuntimeMethodExecutionContext extends ProvableMethodExecutionContext {
|
|
21
|
+
methods: string[];
|
|
22
|
+
input: RuntimeMethodExecutionData | undefined;
|
|
23
|
+
private lastInput;
|
|
24
|
+
result: RuntimeProvableMethodExecutionResult;
|
|
25
|
+
private isSimulated;
|
|
26
|
+
private assertSetupCalled;
|
|
27
|
+
/**
|
|
28
|
+
* Adds an in-method generated state transition to the current context
|
|
29
|
+
* @param stateTransition - State transition to add to the context
|
|
30
|
+
*/
|
|
31
|
+
addStateTransition<Value>(stateTransition: StateTransition<Value>): void;
|
|
32
|
+
/**
|
|
33
|
+
* @param message - Status message to acompany the current status
|
|
34
|
+
*/
|
|
35
|
+
setStatusMessage(message?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* @param status - Execution status of the current method
|
|
38
|
+
*/
|
|
39
|
+
setStatus(status: Bool): void;
|
|
40
|
+
/**
|
|
41
|
+
* @param input Input witness data required for a runtime execution
|
|
42
|
+
*/
|
|
43
|
+
setup(input: RuntimeMethodExecutionData): void;
|
|
44
|
+
setSimulated(simulated: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Manually clears/resets the execution context
|
|
47
|
+
*/
|
|
48
|
+
clear(): void;
|
|
49
|
+
afterMethod(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Had to override current() otherwise it would not infer
|
|
52
|
+
* the type of result correctly (parent type would be reused)
|
|
53
|
+
*/
|
|
54
|
+
current(): {
|
|
55
|
+
isFinished: boolean;
|
|
56
|
+
result: RuntimeProvableMethodExecutionResult;
|
|
57
|
+
input: RuntimeMethodExecutionData | undefined;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=RuntimeMethodExecutionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RuntimeMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../../../../../protocol/src/state/context/RuntimeMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAShE,qBAAa,oCAAqC,SAAQ,6BAA6B;IAE9E,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,CAAM;IAE9C,MAAM,EAAE,IAAI,CAAc;IAE1B,aAAa,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,kBAAkB,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBACa,6BAA8B,SAAQ,8BAA8B;IACxE,OAAO,EAAE,MAAM,EAAE,CAAM;IAEvB,KAAK,EAAE,0BAA0B,GAAG,SAAS,CAAC;IAGrD,OAAO,CAAC,SAAS,CAAyC;IAE1C,MAAM,uCAA8C;IAEpE,OAAO,CAAC,WAAW,CAAkB;IAErC,OAAO,CAAC,iBAAiB;IAQzB;;;OAGG;IACI,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,KAAK,CAAC;IAKxE;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM;IAQxC;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,IAAI;IAQ7B;;OAEG;IACI,KAAK,CAAC,KAAK,EAAE,0BAA0B;IAIvC,YAAY,CAAC,SAAS,EAAE,OAAO;IAItC;;OAEG;IACI,KAAK;IAIL,WAAW;IASlB;;;OAGG;IACI,OAAO;;;;;CAOf"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Bool } from "snarkyjs";
|
|
8
|
+
import { singleton } from "tsyringe";
|
|
9
|
+
import { ProvableMethodExecutionContext, ProvableMethodExecutionResult } from "@proto-kit/common";
|
|
10
|
+
const errors = {
|
|
11
|
+
setupNotCalled: () => new Error("Setup has not been called prior to executing a runtime method. Be sure to do that so that the Runtime is setup property for execution"),
|
|
12
|
+
};
|
|
13
|
+
export class RuntimeProvableMethodExecutionResult extends ProvableMethodExecutionResult {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
this.stateTransitions = [];
|
|
18
|
+
this.status = Bool(true);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execution context used to wrap runtime module methods,
|
|
23
|
+
* allowing them to post relevant information (such as execution status)
|
|
24
|
+
* into the context without any unnecessary 'prop drilling'.
|
|
25
|
+
*/
|
|
26
|
+
let RuntimeMethodExecutionContext = class RuntimeMethodExecutionContext extends ProvableMethodExecutionContext {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.methods = [];
|
|
30
|
+
this.result = new RuntimeProvableMethodExecutionResult();
|
|
31
|
+
this.isSimulated = false;
|
|
32
|
+
}
|
|
33
|
+
assertSetupCalled() {
|
|
34
|
+
if (this.input === undefined) {
|
|
35
|
+
throw errors.setupNotCalled();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Adds an in-method generated state transition to the current context
|
|
40
|
+
* @param stateTransition - State transition to add to the context
|
|
41
|
+
*/
|
|
42
|
+
addStateTransition(stateTransition) {
|
|
43
|
+
this.assertSetupCalled();
|
|
44
|
+
this.result.stateTransitions.push(stateTransition);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @param message - Status message to acompany the current status
|
|
48
|
+
*/
|
|
49
|
+
setStatusMessage(message) {
|
|
50
|
+
var _a;
|
|
51
|
+
this.assertSetupCalled();
|
|
52
|
+
if (this.isSimulated) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
(_a = this.result).statusMessage ?? (_a.statusMessage = message);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* @param status - Execution status of the current method
|
|
59
|
+
*/
|
|
60
|
+
setStatus(status) {
|
|
61
|
+
this.assertSetupCalled();
|
|
62
|
+
if (this.isSimulated) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.result.status = status;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @param input Input witness data required for a runtime execution
|
|
69
|
+
*/
|
|
70
|
+
setup(input) {
|
|
71
|
+
this.input = input;
|
|
72
|
+
}
|
|
73
|
+
setSimulated(simulated) {
|
|
74
|
+
this.isSimulated = simulated;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Manually clears/resets the execution context
|
|
78
|
+
*/
|
|
79
|
+
clear() {
|
|
80
|
+
this.result = new RuntimeProvableMethodExecutionResult();
|
|
81
|
+
}
|
|
82
|
+
afterMethod() {
|
|
83
|
+
super.afterMethod();
|
|
84
|
+
if (this.isFinished) {
|
|
85
|
+
this.lastInput = this.input;
|
|
86
|
+
this.input = undefined;
|
|
87
|
+
this.isSimulated = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Had to override current() otherwise it would not infer
|
|
92
|
+
* the type of result correctly (parent type would be reused)
|
|
93
|
+
*/
|
|
94
|
+
current() {
|
|
95
|
+
return {
|
|
96
|
+
isFinished: this.isFinished,
|
|
97
|
+
result: this.result,
|
|
98
|
+
input: this.lastInput,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
RuntimeMethodExecutionContext = __decorate([
|
|
103
|
+
singleton()
|
|
104
|
+
], RuntimeMethodExecutionContext);
|
|
105
|
+
export { RuntimeMethodExecutionContext };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Experimental } from "snarkyjs";
|
|
2
2
|
import { DependencyContainer } from "tsyringe";
|
|
3
3
|
import { StringKeyOf, ModuleContainer, ModulesConfig, ModulesRecord, TypedClass, ZkProgrammable, PlainZkProgram, WithZkProgrammable, AreProofsEnabled } from "@proto-kit/common";
|
|
4
|
-
import { MethodPublicOutput } from "@proto-kit/protocol";
|
|
5
|
-
import {
|
|
6
|
-
import { StateServiceProvider } from "../state/StateServiceProvider";
|
|
7
|
-
import { RuntimeModule } from "./RuntimeModule.js";
|
|
4
|
+
import { MethodPublicOutput, StateServiceProvider, StateService } from "@proto-kit/protocol";
|
|
5
|
+
import { RuntimeModule } from "./RuntimeModule";
|
|
8
6
|
/**
|
|
9
7
|
* Record of modules accepted by the Runtime module container.
|
|
10
8
|
*
|
|
@@ -16,7 +14,10 @@ export type RuntimeModulesRecord = ModulesRecord<TypedClass<RuntimeModule<unknow
|
|
|
16
14
|
* Definition / required arguments for the Runtime class
|
|
17
15
|
*/
|
|
18
16
|
export interface RuntimeDefinition<Modules extends RuntimeModulesRecord> {
|
|
19
|
-
|
|
17
|
+
/**
|
|
18
|
+
* @deprecated
|
|
19
|
+
*/
|
|
20
|
+
state?: StateService;
|
|
20
21
|
modules: Modules;
|
|
21
22
|
config?: ModulesConfig<Modules>;
|
|
22
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/Runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAc,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"Runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/Runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAc,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,aAAa,CAC9C,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CACnC,CAAC;AAOF;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,OAAO,SAAS,oBAAoB;IACrE;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACjC;AAED,qBAAa,qBAAqB,CAChC,OAAO,SAAS,oBAAoB,CACpC,SAAQ,cAAc,CAAC,SAAS,EAAE,kBAAkB,CAAC;IAE3B,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;gBAAzB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC;IAInD,IAAW,QAAQ,iCAElB;IAEM,gBAAgB,IAAI,cAAc,CAAC,SAAS,EAAE,kBAAkB,CAAC;CAgHzE;AAED;;;GAGG;AACH,qBACa,OAAO,CAAC,OAAO,SAAS,oBAAoB,CACvD,SAAQ,eAAe,CAAC,OAAO,CAC/B,YAAW,kBAAkB,CAAC,SAAS,EAAE,kBAAkB,CAAC;WAE9C,IAAI,CAAC,OAAO,SAAS,oBAAoB,EACrD,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAMjC,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;IAEpD,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAEvC,cAAc,EAAE,cAAc,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAErE,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAG3C;IAEF;;;;OAIG;gBACgB,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAQlD,KAAK;IAOZ,IAAW,QAAQ,IAAI,gBAAgB,GAAG,SAAS,CAElD;IAED,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAED;;OAEG;IACH,IAAW,mBAAmB,IAAI,mBAAmB,CAEpD;IAED;;;OAGG;IACI,aAAa,CAClB,QAAQ,EAAE,MAAM,GACf,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,SAAS;IAwBhD;;;;;;OAMG;IACI,cAAc,CACnB,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,EAChC,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IAQ9D;;OAEG;IACH,IAAW,kBAAkB,aAE5B;CACF"}
|
package/dist/runtime/Runtime.js
CHANGED
|
@@ -13,9 +13,8 @@ var Runtime_1;
|
|
|
13
13
|
import { Experimental } from "snarkyjs";
|
|
14
14
|
import { injectable } from "tsyringe";
|
|
15
15
|
import { ModuleContainer, ZkProgrammable, } from "@proto-kit/common";
|
|
16
|
-
import { MethodPublicOutput } from "@proto-kit/protocol";
|
|
17
|
-
import { combineMethodName, isRuntimeMethod, toWrappedMethod, } from "../method/runtimeMethod
|
|
18
|
-
import { StateServiceProvider } from "../state/StateServiceProvider";
|
|
16
|
+
import { MethodPublicOutput, StateServiceProvider, } from "@proto-kit/protocol";
|
|
17
|
+
import { combineMethodName, isRuntimeMethod, toWrappedMethod, } from "../method/runtimeMethod";
|
|
19
18
|
import { MethodIdFactory } from "../factories/MethodIdFactory";
|
|
20
19
|
const errors = {
|
|
21
20
|
methodNotFound: (methodKey) => new Error(`Unable to find method with id ${methodKey}`),
|
|
@@ -107,12 +106,11 @@ let Runtime = Runtime_1 = class Runtime extends ModuleContainer {
|
|
|
107
106
|
*/
|
|
108
107
|
constructor(definition) {
|
|
109
108
|
super(definition);
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
this.
|
|
109
|
+
this.stateServiceProviderInstance = new StateServiceProvider(
|
|
110
|
+
// eslint-disable-next-line etc/no-deprecated
|
|
111
|
+
this.definition.state);
|
|
113
112
|
this.definition = definition;
|
|
114
113
|
this.zkProgrammable = new RuntimeZkProgrammable(this);
|
|
115
|
-
// this.registerDependencyFactories([MethodIdFactory]);
|
|
116
114
|
}
|
|
117
115
|
// eslint-disable-next-line no-warning-comments
|
|
118
116
|
// TODO Remove after changing DFs to type-based approach
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ConfigurableModule, Presets } from "@proto-kit/common";
|
|
2
|
-
import { NetworkState, RuntimeTransaction } from "@proto-kit/protocol";
|
|
3
|
-
import { StateService } from "../state/InMemoryStateService";
|
|
2
|
+
import { NetworkState, RuntimeTransaction, StateService } from "@proto-kit/protocol";
|
|
4
3
|
import type { Runtime, RuntimeDefinition, RuntimeModulesRecord } from "./Runtime";
|
|
5
4
|
/**
|
|
6
5
|
* This type exists to carry over certain runtime properties
|
|
@@ -26,7 +25,6 @@ export declare class RuntimeModule<Config> extends ConfigurableModule<Config> {
|
|
|
26
25
|
*/
|
|
27
26
|
isRuntimeModule: boolean;
|
|
28
27
|
name?: string;
|
|
29
|
-
test?: number;
|
|
30
28
|
runtime?: Runtime<RuntimeModulesRecord>;
|
|
31
29
|
constructor();
|
|
32
30
|
private getInputs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeModule.d.ts","sourceRoot":"","sources":["../../src/runtime/RuntimeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,
|
|
1
|
+
{"version":3,"file":"RuntimeModule.d.ts","sourceRoot":"","sources":["../../src/runtime/RuntimeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAMnB;;;GAGG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,gBAAgB,CAAC;IAC7D,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEnE,IAAI,YAAY,IAAI,YAAY,CAAC;CAClC;AAED;;GAEG;AACH,qBACa,aAAa,CAAC,MAAM,CAAE,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IACnE,OAAc,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAM;IAE7C;;OAEG;IACH,SAAgB,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAElD;;;;OAIG;IACI,eAAe,UAAQ;IAEvB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;;IAY/C,OAAO,CAAC,SAAS;IAWjB,IAAW,WAAW,IAAI,kBAAkB,CAE3C;IAED,IAAW,OAAO,IAAI,YAAY,CAEjC;CACF"}
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { ConfigurableModule } from "@proto-kit/common";
|
|
11
11
|
import { container, injectable } from "tsyringe";
|
|
12
|
-
import { RuntimeMethodExecutionContext, } from "
|
|
12
|
+
import { RuntimeMethodExecutionContext, } from "@proto-kit/protocol";
|
|
13
13
|
import { runtimeMethodNamesMetadataKey } from "../method/runtimeMethod";
|
|
14
14
|
const errors = {
|
|
15
15
|
inputDataNotSet: () => new Error("Input data for runtime execution not set"),
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { Field } from "snarkyjs";
|
|
2
|
-
|
|
3
|
-
get: (key: Field) => Field[] | undefined;
|
|
4
|
-
set: (key: Field, value: Field[] | undefined) => void;
|
|
5
|
-
}
|
|
2
|
+
import { StateService } from "@proto-kit/protocol";
|
|
6
3
|
/**
|
|
7
4
|
* Naive implementation of a StateService for testing purposes
|
|
8
5
|
*/
|