@proto-kit/module 0.1.1-develop.190 → 0.1.1-develop.2024
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/factories/MethodIdFactory.d.ts +6 -6
- package/dist/factories/MethodIdFactory.d.ts.map +1 -1
- package/dist/factories/MethodIdFactory.js +10 -34
- package/dist/factories/MethodIdFactory.js.map +1 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -0
- package/dist/messages/OutgoingMessage.d.ts +96 -0
- package/dist/messages/OutgoingMessage.d.ts.map +1 -0
- package/dist/messages/OutgoingMessage.js +68 -0
- package/dist/messages/OutgoingMessage.js.map +1 -0
- package/dist/messages/OutgoingMessages.d.ts +231 -0
- package/dist/messages/OutgoingMessages.d.ts.map +1 -0
- package/dist/messages/OutgoingMessages.js +66 -0
- package/dist/messages/OutgoingMessages.js.map +1 -0
- package/dist/method/MethodParameterEncoder.d.ts +26 -0
- package/dist/method/MethodParameterEncoder.d.ts.map +1 -0
- package/dist/method/MethodParameterEncoder.js +169 -0
- package/dist/method/MethodParameterEncoder.js.map +1 -0
- package/dist/method/runtimeMethod.d.ts +21 -5
- package/dist/method/runtimeMethod.d.ts.map +1 -1
- package/dist/method/runtimeMethod.js +69 -25
- package/dist/method/runtimeMethod.js.map +1 -0
- package/dist/module/decorator.js +1 -0
- package/dist/module/decorator.js.map +1 -0
- package/dist/runtime/MethodIdResolver.d.ts +10 -8
- package/dist/runtime/MethodIdResolver.d.ts.map +1 -1
- package/dist/runtime/MethodIdResolver.js +74 -33
- package/dist/runtime/MethodIdResolver.js.map +1 -0
- package/dist/runtime/Runtime.d.ts +20 -26
- package/dist/runtime/Runtime.d.ts.map +1 -1
- package/dist/runtime/Runtime.js +117 -62
- package/dist/runtime/Runtime.js.map +1 -0
- package/dist/runtime/RuntimeEnvironment.d.ts +10 -0
- package/dist/runtime/RuntimeEnvironment.d.ts.map +1 -0
- package/dist/runtime/RuntimeEnvironment.js +2 -0
- package/dist/runtime/RuntimeEnvironment.js.map +1 -0
- package/dist/runtime/RuntimeModule.d.ts +18 -15
- package/dist/runtime/RuntimeModule.d.ts.map +1 -1
- package/dist/runtime/RuntimeModule.js +33 -8
- package/dist/runtime/RuntimeModule.js.map +1 -0
- package/dist/state/InMemoryStateService.d.ts +11 -10
- package/dist/state/InMemoryStateService.d.ts.map +1 -1
- package/dist/state/InMemoryStateService.js +11 -8
- package/dist/state/InMemoryStateService.js.map +1 -0
- package/dist/state/decorator.d.ts.map +1 -1
- package/dist/state/decorator.js +2 -4
- package/dist/state/decorator.js.map +1 -0
- package/dist/testing/TestingRuntime.d.ts +8 -0
- package/dist/testing/TestingRuntime.d.ts.map +1 -0
- package/dist/testing/TestingRuntime.js +31 -0
- package/dist/testing/TestingRuntime.js.map +1 -0
- package/jest.config.cjs +12 -1
- package/package.json +10 -11
- package/src/factories/MethodIdFactory.ts +10 -17
- package/src/index.ts +4 -7
- package/src/messages/OutgoingMessages.ts +122 -0
- package/src/method/MethodParameterEncoder.ts +262 -0
- package/src/method/runtimeMethod.ts +130 -33
- package/src/runtime/MethodIdResolver.ts +83 -46
- package/src/runtime/Runtime.ts +193 -100
- package/src/runtime/RuntimeEnvironment.ts +16 -0
- package/src/runtime/RuntimeModule.ts +62 -30
- package/src/state/InMemoryStateService.ts +14 -18
- package/test/Runtime.test.ts +68 -42
- package/test/TestingRuntime.ts +43 -0
- package/test/messages/message.test.ts +42 -0
- package/test/method/MethodParameterEncoder.test.ts +124 -0
- package/test/method/runtimeMethod-fail.test.ts +53 -0
- package/{src/method/decorator.test.ts → test/method/runtimeMethod.test.ts} +3 -3
- package/test/modules/Admin.ts +4 -4
- package/test/modules/Balances.test.ts +92 -78
- package/test/modules/Balances.ts +15 -17
- package/test/modules/{methodId.test.ts → MethodIdResolver.test.ts} +24 -36
- package/test/modules/State.test.ts +81 -0
- package/test/runtimeMethod.test.ts +192 -20
- package/test/tsconfig.json +7 -0
- package/tsconfig.json +2 -2
- package/LICENSE.md +0 -201
- package/dist/method/MethodParameterDecoder.d.ts +0 -22
- package/dist/method/MethodParameterDecoder.d.ts.map +0 -1
- package/dist/method/MethodParameterDecoder.js +0 -33
- 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/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
- package/src/method/MethodParameterDecoder.ts +0 -68
- 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
- package/src/state/decorator.ts +0 -65
- package/test/state/MerkleTree.test.ts +0 -95
- package/test/state/MockAsyncMerkleStore.ts +0 -28
- package/test/transaction.test.ts +0 -82
- package/tsconfig.test.json +0 -9
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/consistent-type-assertions */
|
|
2
|
+
import { Proof, Provable, DynamicProof, } from "o1js";
|
|
3
|
+
import { filterNonUndefined, } from "@proto-kit/common";
|
|
4
|
+
const errors = {
|
|
5
|
+
fieldLengthNotMatching: (expected, actual) => new Error(`Expected ${expected} field elements, got ${actual}`),
|
|
6
|
+
typeNotCompatible: (name, error) => new Error(`Cannot decode type ${name}, it has to be either a Struct, CircuitValue or built-in snarkyjs type.${error !== undefined ? `Caused by: ${error}` : ""}`),
|
|
7
|
+
};
|
|
8
|
+
function isProofType(type) {
|
|
9
|
+
return type.prototype instanceof Proof;
|
|
10
|
+
}
|
|
11
|
+
function isDynamicProofType(type) {
|
|
12
|
+
return (type.prototype instanceof DynamicProof);
|
|
13
|
+
}
|
|
14
|
+
function isProofBaseType(type) {
|
|
15
|
+
return isProofType(type) || isDynamicProofType(type);
|
|
16
|
+
}
|
|
17
|
+
function getAllPropertyNamesOfPrototypeChain(type) {
|
|
18
|
+
if (type === undefined || type === null) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
return Object.getOwnPropertyNames(type).concat(...getAllPropertyNamesOfPrototypeChain(Object.getPrototypeOf(type)));
|
|
22
|
+
}
|
|
23
|
+
export function isFlexibleProvablePure(type) {
|
|
24
|
+
// The required properties are defined on the prototype for Structs and CircuitValues
|
|
25
|
+
// but on the constructor function itself for Field and Bool
|
|
26
|
+
// For aliases like Balance in library, it can even be 2 steps upwards the prototype chain
|
|
27
|
+
const props = getAllPropertyNamesOfPrototypeChain(type);
|
|
28
|
+
const mandatory = ["toFields", "fromFields", "sizeInFields"];
|
|
29
|
+
return mandatory.every((prop) => props.includes(prop));
|
|
30
|
+
}
|
|
31
|
+
export function checkArgsProvable(target, methodName) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
33
|
+
const paramtypes = Reflect.getMetadata("design:paramtypes", target, methodName);
|
|
34
|
+
if (paramtypes === undefined) {
|
|
35
|
+
throw new Error(`Method with name ${methodName} doesn't exist on this module`);
|
|
36
|
+
}
|
|
37
|
+
const indizes = paramtypes
|
|
38
|
+
.map((type, index) => {
|
|
39
|
+
if (isProofBaseType(type) || isFlexibleProvablePure(type)) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return `${index}`;
|
|
43
|
+
})
|
|
44
|
+
.filter(filterNonUndefined);
|
|
45
|
+
if (indizes.length > 0) {
|
|
46
|
+
const indexString = indizes.reduce((a, b) => `${a}, ${b}`);
|
|
47
|
+
throw new Error(`Not all arguments of method '${target.name}.${methodName}' are provable types or proofs (indizes: [${indexString}])`);
|
|
48
|
+
}
|
|
49
|
+
return paramtypes;
|
|
50
|
+
}
|
|
51
|
+
export class MethodParameterEncoder {
|
|
52
|
+
static fromMethod(target, methodName) {
|
|
53
|
+
const paramtypes = checkArgsProvable(target, methodName);
|
|
54
|
+
return new MethodParameterEncoder(paramtypes);
|
|
55
|
+
}
|
|
56
|
+
static fieldSize(type) {
|
|
57
|
+
if (isProofBaseType(type)) {
|
|
58
|
+
return ((MethodParameterEncoder.fieldSize(type.publicInputType) ?? 0) +
|
|
59
|
+
(MethodParameterEncoder.fieldSize(type.publicOutputType) ?? 0));
|
|
60
|
+
}
|
|
61
|
+
// as any, since we shouldn't be using this workaround in the first place
|
|
62
|
+
return type.sizeInFields();
|
|
63
|
+
}
|
|
64
|
+
constructor(types) {
|
|
65
|
+
this.types = types;
|
|
66
|
+
}
|
|
67
|
+
decode(fields, auxiliary) {
|
|
68
|
+
if (fields.length < this.fieldSize()) {
|
|
69
|
+
throw errors.fieldLengthNotMatching(this.fieldSize(), fields.length);
|
|
70
|
+
}
|
|
71
|
+
let stack = fields.slice();
|
|
72
|
+
const auxiliaryStack = auxiliary.slice();
|
|
73
|
+
return Promise.all(this.types.map((type) => {
|
|
74
|
+
const numberFieldsNeeded = MethodParameterEncoder.fieldSize(type) ?? -1;
|
|
75
|
+
if (numberFieldsNeeded === -1) {
|
|
76
|
+
throw errors.typeNotCompatible(type.constructor.name);
|
|
77
|
+
}
|
|
78
|
+
const structFields = stack.slice(0, numberFieldsNeeded);
|
|
79
|
+
stack = stack.slice(numberFieldsNeeded);
|
|
80
|
+
// Decode proof
|
|
81
|
+
if (isProofBaseType(type)) {
|
|
82
|
+
const auxiliaryData = auxiliaryStack.shift();
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
84
|
+
const proofData = JSON.parse(auxiliaryData);
|
|
85
|
+
const inputFieldSize = MethodParameterEncoder.fieldSize(type.publicInputType);
|
|
86
|
+
const input = structFields
|
|
87
|
+
.slice(0, inputFieldSize)
|
|
88
|
+
.map((x) => x.toString());
|
|
89
|
+
const output = structFields
|
|
90
|
+
.slice(inputFieldSize)
|
|
91
|
+
.map((x) => x.toString());
|
|
92
|
+
// fromJSON has incompatible signature for Proof and DynamicProof
|
|
93
|
+
if (isProofType(type)) {
|
|
94
|
+
return type.fromJSON({
|
|
95
|
+
...proofData,
|
|
96
|
+
publicInput: input,
|
|
97
|
+
publicOutput: output,
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (isDynamicProofType(type)) {
|
|
101
|
+
return type.fromJSON({
|
|
102
|
+
...proofData,
|
|
103
|
+
publicInput: input,
|
|
104
|
+
publicOutput: output,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return type.fromFields(structFields, []);
|
|
109
|
+
}));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Variant of encode() for provable code that skips the unprovable
|
|
113
|
+
* json encoding
|
|
114
|
+
*/
|
|
115
|
+
encode(args) {
|
|
116
|
+
/**
|
|
117
|
+
* Use the type info obtained previously to convert
|
|
118
|
+
* the args passed to fields
|
|
119
|
+
*/
|
|
120
|
+
return args
|
|
121
|
+
.map((argument, index) => {
|
|
122
|
+
if (argument instanceof Proof || argument instanceof DynamicProof) {
|
|
123
|
+
const argumentType = this.types[index];
|
|
124
|
+
const { publicOutputType, publicInputType } = argumentType;
|
|
125
|
+
const inputFields =
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
127
|
+
publicInputType?.toFields(argument.publicInput) ?? [];
|
|
128
|
+
const outputFields =
|
|
129
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
130
|
+
publicOutputType?.toFields(argument.publicOutput) ?? [];
|
|
131
|
+
let auxiliary = "";
|
|
132
|
+
// Has to be asProver, because this function will be called by runtimeMethod
|
|
133
|
+
// to transform the args into a Field[] to compute the argsHash
|
|
134
|
+
// In this case, the auxiliary might be empty, but it isn't used by that method anyways
|
|
135
|
+
Provable.asProver(() => {
|
|
136
|
+
const jsonProof = argument.toJSON();
|
|
137
|
+
auxiliary = JSON.stringify({
|
|
138
|
+
proof: jsonProof.proof,
|
|
139
|
+
maxProofsVerified: jsonProof.maxProofsVerified,
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
return {
|
|
143
|
+
fields: [...inputFields, ...outputFields],
|
|
144
|
+
auxiliary,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const argumentType = this.types[index];
|
|
148
|
+
return {
|
|
149
|
+
fields: argumentType.toFields(argument),
|
|
150
|
+
auxiliary: undefined,
|
|
151
|
+
};
|
|
152
|
+
})
|
|
153
|
+
.reduce((a, b) => {
|
|
154
|
+
return {
|
|
155
|
+
fields: [...a.fields, ...b.fields],
|
|
156
|
+
auxiliary: b.auxiliary !== undefined
|
|
157
|
+
? [...a.auxiliary, b.auxiliary]
|
|
158
|
+
: a.auxiliary,
|
|
159
|
+
};
|
|
160
|
+
}, { fields: [], auxiliary: [] });
|
|
161
|
+
}
|
|
162
|
+
fieldSize() {
|
|
163
|
+
return this.types
|
|
164
|
+
.map((type) => MethodParameterEncoder.fieldSize(type) ?? 0)
|
|
165
|
+
.reduce((a, b) => a + b, 0);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
/* eslint-enable @typescript-eslint/consistent-type-assertions */
|
|
169
|
+
//# sourceMappingURL=MethodParameterEncoder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MethodParameterEncoder.js","sourceRoot":"","sources":["../../src/method/MethodParameterEncoder.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,OAAO,EAEL,KAAK,EACL,QAAQ,EACR,YAAY,GAGb,MAAM,MAAM,CAAC;AACd,OAAO,EAKL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AAS;aAClB,CAAC;QACJ,CAAC,EACD,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAC9B,CAAC;IACN,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAC,KAAK;aACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,sBAAsB,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aAC1D,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;CACF;AACD,iEAAiE"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bool, FlexibleProvablePure } from "o1js";
|
|
2
|
+
import { ProvableStateTransition, MethodPublicOutput } from "@proto-kit/protocol";
|
|
3
|
+
import { ArgumentTypes } from "@proto-kit/common";
|
|
2
4
|
import type { RuntimeModule } from "../runtime/RuntimeModule.js";
|
|
3
|
-
export declare function toStateTransitionsHash(stateTransitions:
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
export declare function toStateTransitionsHash(stateTransitions: {
|
|
6
|
+
toProvable: () => ProvableStateTransition;
|
|
7
|
+
}[]): import("o1js/dist/node/lib/provable/field.js").Field;
|
|
8
|
+
export declare function toEventsHash(events: {
|
|
9
|
+
eventType: FlexibleProvablePure<any>;
|
|
10
|
+
event: any;
|
|
11
|
+
eventName: string;
|
|
12
|
+
condition: Bool;
|
|
13
|
+
}[]): import("o1js/dist/node/lib/provable/field.js").Field;
|
|
14
|
+
export type WrappedMethod = (...args: ArgumentTypes) => MethodPublicOutput;
|
|
15
|
+
export type AsyncWrappedMethod = (...args: ArgumentTypes) => Promise<MethodPublicOutput>;
|
|
16
|
+
export declare function toWrappedMethod(this: RuntimeModule<unknown>, methodName: string, moduleMethod: (...args: ArgumentTypes) => Promise<any>, options: {
|
|
17
|
+
invocationType: RuntimeMethodInvocationType;
|
|
18
|
+
}): AsyncWrappedMethod;
|
|
6
19
|
export declare function combineMethodName(runtimeModuleName: string, methodName: string): string;
|
|
7
20
|
export declare const runtimeMethodMetadataKey = "yab-method";
|
|
8
21
|
export declare const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods";
|
|
22
|
+
export declare const runtimeMethodTypeMetadataKey = "proto-kit-runtime-method-type";
|
|
9
23
|
/**
|
|
10
24
|
* Checks the metadata of the provided runtime module and its method,
|
|
11
25
|
* to see if it has been decorated with @runtimeMethod()
|
|
@@ -15,5 +29,7 @@ export declare const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods"
|
|
|
15
29
|
* @returns - If the provided method name is a runtime method or not
|
|
16
30
|
*/
|
|
17
31
|
export declare function isRuntimeMethod(target: RuntimeModule<unknown>, propertyKey: string): boolean;
|
|
18
|
-
export
|
|
32
|
+
export type RuntimeMethodInvocationType = "SIGNATURE" | "INCOMING_MESSAGE";
|
|
33
|
+
export declare function runtimeMessage(): (target: RuntimeModule<unknown>, methodName: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) => void;
|
|
34
|
+
export declare function runtimeMethod(): (target: RuntimeModule<unknown>, methodName: string, descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise<any>>) => void;
|
|
19
35
|
//# sourceMappingURL=runtimeMethod.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtimeMethod.d.ts","sourceRoot":"","sources":["../../src/method/runtimeMethod.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runtimeMethod.d.ts","sourceRoot":"","sources":["../../src/method/runtimeMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAS,oBAAoB,EAAY,MAAM,MAAM,CAAC;AAEnE,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAInB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa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{ Bool, Field, Poseidon } from "o1js";
|
|
1
2
|
import { container } from "tsyringe";
|
|
2
|
-
import {
|
|
3
|
-
import { toProver } from "@proto-kit/common";
|
|
4
|
-
import {
|
|
3
|
+
import { ProvableStateTransition, MethodPublicOutput, RuntimeMethodExecutionContext, StateTransitionReductionList, DefaultProvableHashList, } from "@proto-kit/protocol";
|
|
4
|
+
import { toProver, } from "@proto-kit/common";
|
|
5
|
+
import { MethodParameterEncoder, checkArgsProvable, } from "./MethodParameterEncoder";
|
|
5
6
|
const errors = {
|
|
6
7
|
runtimeNotProvided: (name) => new Error(`Runtime was not provided for module: ${name}`),
|
|
7
|
-
|
|
8
|
+
runtimeNameNotSet: () => new Error("Runtime name was not set"),
|
|
9
|
+
fieldNotConstant: (name) => new Error(`In-circuit field ${name} not a constant, this is likely a framework bug`),
|
|
8
10
|
};
|
|
9
|
-
export function toStateTransitionsHash(
|
|
10
|
-
|
|
11
|
-
stateTransitions) {
|
|
12
|
-
const stateTransitionsHashList = new DefaultProvableHashList(ProvableStateTransition);
|
|
11
|
+
export function toStateTransitionsHash(stateTransitions) {
|
|
12
|
+
const stateTransitionsHashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
13
13
|
return stateTransitions
|
|
14
14
|
.map((stateTransition) => stateTransition.toProvable())
|
|
15
15
|
.reduce((allStateTransitionsHashList, stateTransition) => allStateTransitionsHashList.push(stateTransition), stateTransitionsHashList)
|
|
16
16
|
.toField();
|
|
17
17
|
}
|
|
18
|
-
export function
|
|
18
|
+
export function toEventsHash(events) {
|
|
19
|
+
return events.reduce((acc, event) => {
|
|
20
|
+
const hashList = new DefaultProvableHashList(event.eventType, acc);
|
|
21
|
+
hashList.pushIf(event.event, event.condition);
|
|
22
|
+
return hashList.commitment;
|
|
23
|
+
}, Field(0));
|
|
24
|
+
}
|
|
25
|
+
export function toWrappedMethod(methodName, moduleMethod, options) {
|
|
19
26
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
20
|
-
const wrappedMethod = (...args) => {
|
|
21
|
-
Reflect.apply(moduleMethod, this, args);
|
|
22
|
-
const { result: { stateTransitions, status },
|
|
27
|
+
const wrappedMethod = async (...args) => {
|
|
28
|
+
await Reflect.apply(moduleMethod, this, args);
|
|
29
|
+
const { result: { stateTransitions, status, events }, } = executionContext.current();
|
|
23
30
|
const stateTransitionsHash = toStateTransitionsHash(stateTransitions);
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
const eventsHash = toEventsHash(events);
|
|
32
|
+
const { name, parent: runtime } = this;
|
|
33
|
+
if (name === undefined) {
|
|
34
|
+
throw errors.runtimeNameNotSet();
|
|
35
|
+
}
|
|
36
|
+
if (runtime === undefined) {
|
|
37
|
+
throw errors.runtimeNotProvided(name);
|
|
38
|
+
}
|
|
39
|
+
const { transaction, networkState } = executionContext.witnessInput();
|
|
40
|
+
const { methodIdResolver } = runtime;
|
|
41
|
+
// Assert that the given transaction has the correct methodId
|
|
42
|
+
const thisMethodId = Field(methodIdResolver.getMethodId(name, methodName));
|
|
43
|
+
if (!thisMethodId.isConstant()) {
|
|
44
|
+
throw errors.fieldNotConstant("methodId");
|
|
26
45
|
}
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
transaction.methodId.assertEquals(thisMethodId, "Runtimemethod called with wrong methodId on the transaction object");
|
|
47
|
+
/**
|
|
48
|
+
* Use the type info obtained previously to convert
|
|
49
|
+
* the args passed to fields
|
|
50
|
+
*/
|
|
51
|
+
const { fields } = MethodParameterEncoder.fromMethod(this, methodName).encode(args);
|
|
52
|
+
// Assert that the argsHash that has been signed matches the given arguments
|
|
53
|
+
const argsHash = Poseidon.hash(fields);
|
|
54
|
+
transaction.argsHash.assertEquals(argsHash, "argsHash and therefore arguments of transaction and runtime call does not match");
|
|
55
|
+
const isMessage = Bool(options.invocationType === "INCOMING_MESSAGE");
|
|
56
|
+
transaction.assertTransactionType(Bool(isMessage));
|
|
57
|
+
const transactionHash = transaction.hash();
|
|
58
|
+
const networkStateHash = networkState.hash();
|
|
29
59
|
return new MethodPublicOutput({
|
|
30
60
|
stateTransitionsHash,
|
|
31
61
|
status,
|
|
32
62
|
transactionHash,
|
|
33
63
|
networkStateHash,
|
|
64
|
+
isMessage,
|
|
65
|
+
eventsHash,
|
|
34
66
|
});
|
|
35
67
|
};
|
|
36
68
|
Object.defineProperty(wrappedMethod, "name", {
|
|
@@ -44,6 +76,7 @@ export function combineMethodName(runtimeModuleName, methodName) {
|
|
|
44
76
|
}
|
|
45
77
|
export const runtimeMethodMetadataKey = "yab-method";
|
|
46
78
|
export const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods";
|
|
79
|
+
export const runtimeMethodTypeMetadataKey = "proto-kit-runtime-method-type";
|
|
47
80
|
/**
|
|
48
81
|
* Checks the metadata of the provided runtime module and its method,
|
|
49
82
|
* to see if it has been decorated with @runtimeMethod()
|
|
@@ -55,8 +88,9 @@ export const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods";
|
|
|
55
88
|
export function isRuntimeMethod(target, propertyKey) {
|
|
56
89
|
return Boolean(Reflect.getMetadata(runtimeMethodMetadataKey, target, propertyKey));
|
|
57
90
|
}
|
|
58
|
-
|
|
91
|
+
function runtimeMethodInternal(options) {
|
|
59
92
|
return (target, methodName, descriptor) => {
|
|
93
|
+
checkArgsProvable(target, methodName);
|
|
60
94
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
61
95
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
62
96
|
let data = Reflect.getMetadata(runtimeMethodNamesMetadataKey, target);
|
|
@@ -68,10 +102,11 @@ export function runtimeMethod() {
|
|
|
68
102
|
}
|
|
69
103
|
Reflect.defineMetadata(runtimeMethodNamesMetadataKey, data, target);
|
|
70
104
|
Reflect.defineMetadata(runtimeMethodMetadataKey, true, target, methodName);
|
|
105
|
+
Reflect.defineMetadata(runtimeMethodTypeMetadataKey, options.invocationType, target, methodName);
|
|
71
106
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
72
107
|
const simulatedMethod = descriptor.value;
|
|
73
|
-
descriptor.value = function value(...args) {
|
|
74
|
-
const constructorName = this.
|
|
108
|
+
descriptor.value = async function value(...args) {
|
|
109
|
+
const constructorName = this.name;
|
|
75
110
|
/**
|
|
76
111
|
* If its a top level method call, wrap it into a wrapped method,
|
|
77
112
|
* since it'll be turned into a real/mock prover in provableMethod().
|
|
@@ -82,17 +117,16 @@ export function runtimeMethod() {
|
|
|
82
117
|
const simulatedWrappedMethod = Reflect.apply(toWrappedMethod, this, [
|
|
83
118
|
methodName,
|
|
84
119
|
simulatedMethod,
|
|
120
|
+
options,
|
|
85
121
|
]);
|
|
86
122
|
/**
|
|
87
123
|
* Before the prover runs, make sure it is operating on the correct
|
|
88
124
|
* RuntimeMethodExecutionContext state, meaning it enters and exits
|
|
89
125
|
* the context properly.
|
|
90
126
|
*/
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
127
|
async function prover() {
|
|
93
128
|
executionContext.beforeMethod(constructorName, methodName, args);
|
|
94
129
|
const innerProver = toProver(combineMethodName(constructorName, methodName), simulatedWrappedMethod, false, ...args).bind(this);
|
|
95
|
-
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
96
130
|
let result;
|
|
97
131
|
try {
|
|
98
132
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
@@ -105,15 +139,14 @@ export function runtimeMethod() {
|
|
|
105
139
|
}
|
|
106
140
|
executionContext.beforeMethod(constructorName, methodName, args);
|
|
107
141
|
if (executionContext.isTopLevel) {
|
|
108
|
-
if (!this.
|
|
142
|
+
if (!this.parent) {
|
|
109
143
|
throw errors.runtimeNotProvided(constructorName);
|
|
110
144
|
}
|
|
111
|
-
executionContext.setProver(prover.bind(this.
|
|
145
|
+
executionContext.setProver(prover.bind(this.parent.zkProgrammable));
|
|
112
146
|
}
|
|
113
|
-
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
114
147
|
let result;
|
|
115
148
|
try {
|
|
116
|
-
result = Reflect.apply(simulatedMethod, this, args);
|
|
149
|
+
result = await Reflect.apply(simulatedMethod, this, args);
|
|
117
150
|
}
|
|
118
151
|
finally {
|
|
119
152
|
executionContext.afterMethod();
|
|
@@ -122,3 +155,14 @@ export function runtimeMethod() {
|
|
|
122
155
|
};
|
|
123
156
|
};
|
|
124
157
|
}
|
|
158
|
+
export function runtimeMessage() {
|
|
159
|
+
return runtimeMethodInternal({
|
|
160
|
+
invocationType: "INCOMING_MESSAGE",
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export function runtimeMethod() {
|
|
164
|
+
return runtimeMethodInternal({
|
|
165
|
+
invocationType: "SIGNATURE",
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=runtimeMethod.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeMethod.js","sourceRoot":"","sources":["../../src/method/runtimeMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAwB,QAAQ,EAAE,MAAM,MAAM,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,QAAQ,GAGT,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAElC,MAAM,MAAM,GAAG;IACb,kBAAkB,EAAE,CAAC,IAAY,EAAE,EAAE,CACnC,IAAI,KAAK,CAAC,wCAAwC,IAAI,EAAE,CAAC;IAE3D,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAAC;IAE9D,gBAAgB,EAAE,CAAC,IAAY,EAAE,EAAE,CACjC,IAAI,KAAK,CACP,oBAAoB,IAA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U,EAAE,IAAI,CAAC,CAAC;YAEjE,IAAI,gBAAgB,CAAC,UAAU,EAAE;gBAC/B,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBAChB,MAAM,MAAM,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC;iBAClD;gBACD,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;aACrE;YAED,IAAI,MAAe,CAAC;YACpB,IAAI;gBACF,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;aAC3D;oBAAS;gBACR,gBAAgB,CAAC,WAAW,EAAE,CAAC;aAChC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,qBAAqB,CAAC;QAC3B,cAAc,EAAE,kBAAkB;KACnC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa;IAC3B,OAAO,qBAAqB,CAAC;QAC3B,cAAc,EAAE,WAAW;KAC5B,CAAC,CAAC;AACL,CAAC"}
|
package/dist/module/decorator.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator.js","sourceRoot":"","sources":["../../src/module/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAKtC;;;GAGG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO;IACL;;;OAGG;IACH,MACoC,EACpC,EAAE;QACF,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import { RuntimeMethodIdMapping } from "@proto-kit/protocol";
|
|
1
2
|
import type { Runtime, RuntimeModulesRecord } from "./Runtime";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* [0
|
|
6
|
-
* ...hash(stringToField(moduleName))[0..128],
|
|
7
|
-
* ...hash(stringToField(methodName))[0..128]
|
|
8
|
-
* ]
|
|
4
|
+
* Please see `getMethodId` to learn more about
|
|
5
|
+
* methodId encoding
|
|
9
6
|
*/
|
|
10
7
|
export declare class MethodIdResolver {
|
|
11
8
|
private readonly runtime;
|
|
12
|
-
private readonly modules;
|
|
13
9
|
private readonly dictionary;
|
|
14
|
-
constructor(runtime: Runtime<RuntimeModulesRecord
|
|
10
|
+
constructor(runtime: Runtime<RuntimeModulesRecord>);
|
|
11
|
+
/**
|
|
12
|
+
* The purpose of this method is to provide a dictionary where
|
|
13
|
+
* we can look up properties like methodId and invocationType
|
|
14
|
+
* for each runtimeMethod using their module name and method name
|
|
15
|
+
*/
|
|
16
|
+
methodIdMap(): RuntimeMethodIdMapping;
|
|
15
17
|
getMethodNameFromId(methodId: bigint): [string, string] | undefined;
|
|
16
18
|
getMethodId(moduleName: string, methodName: string): bigint;
|
|
17
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MethodIdResolver.d.ts","sourceRoot":"","sources":["../../src/runtime/MethodIdResolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MethodIdResolver.d.ts","sourceRoot":"","sources":["../../src/runtime/MethodIdResolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAS5E,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE/D;;;GAGG;AACH,qBACa,gBAAgB;IAMN,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAEpB;gBAG+B,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAkB5E;;;;OAIG;IACI,WAAW,IAAI,sBAAsB;IAuCrC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;IAcnE,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAQnE"}
|
|
@@ -1,50 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { filterNonUndefined } from "@proto-kit/common";
|
|
14
|
+
import { stringToField } from "@proto-kit/protocol";
|
|
15
|
+
import { Poseidon } from "o1js";
|
|
16
|
+
import { inject, injectable } from "tsyringe";
|
|
17
|
+
import { runtimeMethodTypeMetadataKey, } from "../method/runtimeMethod";
|
|
5
18
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* [0
|
|
9
|
-
* ...hash(stringToField(moduleName))[0..128],
|
|
10
|
-
* ...hash(stringToField(methodName))[0..128]
|
|
11
|
-
* ]
|
|
19
|
+
* Please see `getMethodId` to learn more about
|
|
20
|
+
* methodId encoding
|
|
12
21
|
*/
|
|
13
|
-
export class MethodIdResolver {
|
|
14
|
-
constructor(runtime
|
|
22
|
+
export let MethodIdResolver = class MethodIdResolver {
|
|
23
|
+
constructor(runtime) {
|
|
15
24
|
this.runtime = runtime;
|
|
16
|
-
this.modules = modules;
|
|
17
25
|
this.dictionary = {};
|
|
18
26
|
this.dictionary = runtime.runtimeModuleNames.reduce((dict, moduleName) => {
|
|
19
|
-
this.runtime.assertIsValidModuleName(
|
|
20
|
-
dict[(stringToField(moduleName).toBigInt() % modulus).toString()] =
|
|
21
|
-
moduleName;
|
|
27
|
+
this.runtime.assertIsValidModuleName(moduleName);
|
|
22
28
|
runtime.resolve(moduleName).runtimeMethodNames.forEach((methodName) => {
|
|
23
|
-
dict[
|
|
24
|
-
|
|
29
|
+
dict[this.getMethodId(moduleName, methodName).toString()] = {
|
|
30
|
+
moduleName,
|
|
31
|
+
methodName,
|
|
32
|
+
};
|
|
25
33
|
});
|
|
26
34
|
return dict;
|
|
27
35
|
}, {});
|
|
28
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The purpose of this method is to provide a dictionary where
|
|
39
|
+
* we can look up properties like methodId and invocationType
|
|
40
|
+
* for each runtimeMethod using their module name and method name
|
|
41
|
+
*/
|
|
42
|
+
methodIdMap() {
|
|
43
|
+
const methodIdResolver = this.runtime.dependencyContainer.resolve("MethodIdResolver");
|
|
44
|
+
const rawMappings = this.runtime.moduleNames.flatMap((moduleName) => {
|
|
45
|
+
const module = this.runtime.resolve(moduleName);
|
|
46
|
+
return module.runtimeMethodNames.map((method) => {
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
48
|
+
const type = Reflect.getMetadata(runtimeMethodTypeMetadataKey, module, method);
|
|
49
|
+
if (type !== undefined) {
|
|
50
|
+
return {
|
|
51
|
+
name: `${moduleName}.${method}`,
|
|
52
|
+
methodId: methodIdResolver.getMethodId(moduleName, method),
|
|
53
|
+
type,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
return rawMappings
|
|
60
|
+
.filter(filterNonUndefined)
|
|
61
|
+
.reduce((acc, entry) => {
|
|
62
|
+
acc[entry.name] = {
|
|
63
|
+
methodId: entry.methodId,
|
|
64
|
+
type: entry.type,
|
|
65
|
+
};
|
|
66
|
+
return acc;
|
|
67
|
+
}, {});
|
|
68
|
+
}
|
|
29
69
|
getMethodNameFromId(methodId) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const moduleName = this.dictionary[moduleNameHash];
|
|
33
|
-
// eslint-disable-next-line no-warning-comments
|
|
34
|
-
// TODO Replace by throwing exception?
|
|
35
|
-
if (moduleName === undefined) {
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
this.runtime.assertIsValidModuleName(this.modules, moduleName);
|
|
39
|
-
const methodName = this.dictionary[methodNameHash];
|
|
40
|
-
if (methodName === undefined) {
|
|
70
|
+
const methodPath = this.dictionary[methodId.toString()];
|
|
71
|
+
if (methodPath === undefined) {
|
|
41
72
|
return undefined;
|
|
42
73
|
}
|
|
74
|
+
const { moduleName, methodName } = methodPath;
|
|
75
|
+
this.runtime.assertIsValidModuleName(moduleName);
|
|
43
76
|
return [moduleName, methodName];
|
|
44
77
|
}
|
|
45
78
|
getMethodId(moduleName, methodName) {
|
|
46
|
-
this.runtime.assertIsValidModuleName(
|
|
47
|
-
return
|
|
48
|
-
|
|
79
|
+
this.runtime.assertIsValidModuleName(moduleName);
|
|
80
|
+
return Poseidon.hash([
|
|
81
|
+
stringToField(moduleName),
|
|
82
|
+
stringToField(methodName),
|
|
83
|
+
]).toBigInt();
|
|
49
84
|
}
|
|
50
|
-
}
|
|
85
|
+
};
|
|
86
|
+
MethodIdResolver = __decorate([
|
|
87
|
+
injectable(),
|
|
88
|
+
__param(0, inject("Runtime")),
|
|
89
|
+
__metadata("design:paramtypes", [Function])
|
|
90
|
+
], MethodIdResolver);
|
|
91
|
+
//# sourceMappingURL=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