@proto-kit/module 0.1.1-develop.600 → 0.1.1-develop.651

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.
@@ -1 +1 @@
1
- {"version":3,"file":"MethodParameterEncoder.d.ts","sourceRoot":"","sources":["../../src/method/MethodParameterEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAS,gBAAgB,EAAE,MAAM,MAAM,CAAC;AACxE,OAAO,EACL,aAAa,EAKd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,qBAAa,sBAAsB;IAuBb,OAAO,CAAC,QAAQ,CAAC,KAAK;WAtB5B,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM;WAiB7D,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAK5E,OAAO;IAEA,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAsBvD,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa;IAkB5C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG;QAClC,UAAU,EAAE,KAAK,EAAE,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;IAyCD,IAAW,SAAS,IAAI,MAAM,CAI7B;CACF"}
1
+ {"version":3,"file":"MethodParameterEncoder.d.ts","sourceRoot":"","sources":["../../src/method/MethodParameterEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,gBAAgB,EAGhB,gBAAgB,EACjB,MAAM,MAAM,CAAC;AACd,OAAO,EACL,aAAa,EAKd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAgB9D,qBAAa,sBAAsB;IAuBb,OAAO,CAAC,QAAQ,CAAC,KAAK;WAtB5B,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM;WAiB7D,SAAS,CAAC,IAAI,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,SAAS;IAK5E,OAAO;IAEA,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAsBvD,YAAY,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,aAAa;IAkB5C,MAAM,CAAC,IAAI,EAAE,aAAa,GAAG;QAClC,UAAU,EAAE,KAAK,EAAE,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB;IA4CD,IAAW,SAAS,IAAI,MAAM,CAI7B;CACF"}
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
- import { Proof } from "o1js";
2
+ import { Proof, Provable, } from "o1js";
3
3
  const errors = {
4
4
  fieldLengthNotMatching: (expected, actual) => new Error(`Expected ${expected} field elements, got ${actual}`),
5
5
  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}` : ""}`),
@@ -70,12 +70,15 @@ export class MethodParameterEncoder {
70
70
  const argumentType = this.types[index];
71
71
  return argumentType.toFields(argument);
72
72
  });
73
- const argsJSON = args.map((argument, index) => {
74
- if (argument instanceof Proof) {
75
- return JSON.stringify(argument.toJSON());
76
- }
77
- const argumentType = this.types[index];
78
- return JSON.stringify(argumentType.toJSON(argument));
73
+ let argsJSON = [];
74
+ Provable.asProver(() => {
75
+ argsJSON = args.map((argument, index) => {
76
+ if (argument instanceof Proof) {
77
+ return JSON.stringify(argument.toJSON());
78
+ }
79
+ const argumentType = this.types[index];
80
+ return JSON.stringify(argumentType.toJSON(argument));
81
+ });
79
82
  });
80
83
  return {
81
84
  argsFields,
@@ -3,7 +3,7 @@ import { ArgumentTypes } from "@proto-kit/common";
3
3
  import type { RuntimeModule } from "../runtime/RuntimeModule.js";
4
4
  export declare function toStateTransitionsHash(stateTransitions: StateTransition<any>[]): import("o1js/dist/node/lib/field.js").Field;
5
5
  export type WrappedMethod = (...args: ArgumentTypes) => MethodPublicOutput;
6
- export declare function toWrappedMethod(this: RuntimeModule<unknown>, methodName: string, moduleMethod: (...args: ArgumentTypes) => unknown, methodArguments: ArgumentTypes, options: {
6
+ export declare function toWrappedMethod(this: RuntimeModule<unknown>, methodName: string, moduleMethod: (...args: ArgumentTypes) => unknown, options: {
7
7
  invocationType: RuntimeMethodInvocationType;
8
8
  }): WrappedMethod;
9
9
  export declare function combineMethodName(runtimeModuleName: string, methodName: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"runtimeMethod.d.ts","sourceRoot":"","sources":["../../src/method/runtimeMethod.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,eAAe,EAGf,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAOL,aAAa,EAGd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAoBjE,wBAAgB,sBAAsB,CAEpC,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,+CAczC;AAGD,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,aAAa,KAAK,kBAAkB,CAAC;AAE3E,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,aAAa,KAAK,OAAO,EACjD,eAAe,EAAE,aAAa,EAC9B,OAAO,EAAE;IACP,cAAc,EAAE,2BAA2B,CAAC;CAC7C,iBAiFF;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,MAAM,EACzB,UAAU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AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,WAAW,EAAE,MAAM,WAKpB;AAED,MAAM,MAAM,2BAA2B,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAyG3E,wBAAgB,cAAc,iGAI7B;AAED,wBAAgB,aAAa,iGAI5B"}
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable max-statements */
2
- import { Bool, Field, Poseidon, } from "o1js";
2
+ import { Bool, Field, Poseidon } from "o1js";
3
3
  import { container } from "tsyringe";
4
- import { DefaultProvableHashList, ProvableStateTransition, MethodPublicOutput, RuntimeMethodExecutionContext, } from "@proto-kit/protocol";
4
+ import { ProvableStateTransition, MethodPublicOutput, RuntimeMethodExecutionContext, StateTransitionReductionList, } from "@proto-kit/protocol";
5
5
  import { toProver, } from "@proto-kit/common";
6
6
  import { MethodParameterEncoder } from "./MethodParameterEncoder";
7
7
  const errors = {
@@ -13,21 +13,19 @@ const errors = {
13
13
  export function toStateTransitionsHash(
14
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
15
  stateTransitions) {
16
- const stateTransitionsHashList = new DefaultProvableHashList(ProvableStateTransition);
16
+ const stateTransitionsHashList = new StateTransitionReductionList(ProvableStateTransition);
17
17
  return stateTransitions
18
18
  .map((stateTransition) => stateTransition.toProvable())
19
19
  .reduce((allStateTransitionsHashList, stateTransition) => allStateTransitionsHashList.push(stateTransition), stateTransitionsHashList)
20
20
  .toField();
21
21
  }
22
- export function toWrappedMethod(methodName, moduleMethod, methodArguments, options) {
22
+ export function toWrappedMethod(methodName, moduleMethod, options) {
23
23
  const executionContext = container.resolve(RuntimeMethodExecutionContext);
24
24
  const wrappedMethod = (...args) => {
25
25
  Reflect.apply(moduleMethod, this, args);
26
- const { result: { stateTransitions, status }, input, } = executionContext.current();
26
+ const { result: { stateTransitions, status }, } = executionContext.current();
27
27
  const stateTransitionsHash = toStateTransitionsHash(stateTransitions);
28
- if (input === undefined) {
29
- throw errors.methodInputsNotProvided();
30
- }
28
+ const input = this.getInputs();
31
29
  const { name, runtime } = this;
32
30
  if (name === undefined) {
33
31
  throw errors.runtimeNameNotSet();
@@ -49,10 +47,10 @@ export function toWrappedMethod(methodName, moduleMethod, methodArguments, optio
49
47
  */
50
48
  const { argsFields } = MethodParameterEncoder.fromMethod(this, methodName).encode(args);
51
49
  // Assert that the argsHash that has been signed matches the given arguments
52
- // We can use js-if here, because methodArguments is statically sizes
50
+ // We can use js-if here, because args are statically sized
53
51
  // i.e. the result of the if-statement will be the same for all executions
54
52
  // of this method
55
- const argsHash = methodArguments.length > 0 ? Poseidon.hash(argsFields) : Field(0);
53
+ const argsHash = (args ?? []).length > 0 ? Poseidon.hash(argsFields) : Field(0);
56
54
  transaction.argsHash.assertEquals(argsHash, "argsHash and therefore arguments of transaction and runtime call does not match");
57
55
  const isMessage = Bool(options.invocationType === "INCOMING_MESSAGE");
58
56
  transaction.assertTransactionType(Bool(isMessage));
@@ -106,7 +104,7 @@ function runtimeMethodInternal(options) {
106
104
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
107
105
  const simulatedMethod = descriptor.value;
108
106
  descriptor.value = function value(...args) {
109
- const constructorName = this.constructor.name;
107
+ const constructorName = this.name;
110
108
  /**
111
109
  * If its a top level method call, wrap it into a wrapped method,
112
110
  * since it'll be turned into a real/mock prover in provableMethod().
@@ -117,7 +115,6 @@ function runtimeMethodInternal(options) {
117
115
  const simulatedWrappedMethod = Reflect.apply(toWrappedMethod, this, [
118
116
  methodName,
119
117
  simulatedMethod,
120
- args,
121
118
  options,
122
119
  ]);
123
120
  /**
@@ -1,3 +1,4 @@
1
+ import { RuntimeMethodIdMapping } from "@proto-kit/protocol";
1
2
  import type { Runtime, RuntimeModulesRecord } from "./Runtime";
2
3
  /**
3
4
  * Please see `getMethodId` to learn more about
@@ -7,6 +8,12 @@ export declare class MethodIdResolver {
7
8
  private readonly runtime;
8
9
  private readonly dictionary;
9
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;
10
17
  getMethodNameFromId(methodId: bigint): [string, string] | undefined;
11
18
  getMethodId(moduleName: string, methodName: string): bigint;
12
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MethodIdResolver.d.ts","sourceRoot":"","sources":["../../src/runtime/MethodIdResolver.ts"],"names":[],"mappings":"AAIA,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;IAkBrE,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
+ {"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;IAsCrC,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"}
@@ -10,9 +10,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
10
10
  var __param = (this && this.__param) || function (paramIndex, decorator) {
11
11
  return function (target, key) { decorator(target, key, paramIndex); }
12
12
  };
13
+ import { filterNonUndefined } from "@proto-kit/common";
13
14
  import { stringToField } from "@proto-kit/protocol";
14
15
  import { Poseidon } from "o1js";
15
16
  import { inject, injectable } from "tsyringe";
17
+ import { runtimeMethodTypeMetadataKey, } from "../method/runtimeMethod";
16
18
  /**
17
19
  * Please see `getMethodId` to learn more about
18
20
  * methodId encoding
@@ -32,6 +34,37 @@ let MethodIdResolver = class MethodIdResolver {
32
34
  return dict;
33
35
  }, {});
34
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
+ const type = Reflect.getMetadata(runtimeMethodTypeMetadataKey, module, method);
48
+ if (type !== undefined) {
49
+ return {
50
+ name: `${moduleName}.${method}`,
51
+ methodId: methodIdResolver.getMethodId(moduleName, method),
52
+ type,
53
+ };
54
+ }
55
+ return undefined;
56
+ });
57
+ });
58
+ return rawMappings
59
+ .filter(filterNonUndefined)
60
+ .reduce((acc, entry) => {
61
+ acc[entry.name] = {
62
+ methodId: entry.methodId,
63
+ type: entry.type,
64
+ };
65
+ return acc;
66
+ }, {});
67
+ }
35
68
  getMethodNameFromId(methodId) {
36
69
  const methodPath = this.dictionary[methodId.toString()];
37
70
  if (methodPath === undefined) {
@@ -5,6 +5,7 @@ import { MethodPublicOutput, StateServiceProvider, StateService } from "@proto-k
5
5
  import { RuntimeModule } from "./RuntimeModule";
6
6
  import { MethodIdResolver } from "./MethodIdResolver";
7
7
  import { RuntimeEnvironment } from "./RuntimeEnvironment";
8
+ export declare function getAllPropertyNames(obj: any): (string | symbol)[];
8
9
  /**
9
10
  * Record of modules accepted by the Runtime module container.
10
11
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/Runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAc,MAAM,UAAU,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EAEd,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,YAAY,EACb,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D;;;;;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,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;I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OAAO,SAAS,oBAAoB,EACrD,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACrC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IASxB,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;;;;OAIG;gBACgB,UAAU,EAAE,iBAAiB,CAAC,OAAO,CAAC;IAQlD,MAAM,CAAC,sBAAsB,EAAE,sBAAsB;IAM5D,IAAW,QAAQ,IAAI,gBAAgB,GAAG,SAAS,CAElD;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAItD;IAED,IAAW,YAAY,IAAI,YAAY,CAEtC;IAED,IAAW,gBAAgB,IAAI,gBAAgB,CAE9C;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;IAuBhD;;;;;;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"}
@@ -14,8 +14,20 @@ import { Experimental } from "o1js";
14
14
  import { injectable } from "tsyringe";
15
15
  import { ModuleContainer, ZkProgrammable, } from "@proto-kit/common";
16
16
  import { MethodPublicOutput, } from "@proto-kit/protocol";
17
- import { combineMethodName, isRuntimeMethod, toWrappedMethod, } from "../method/runtimeMethod";
17
+ import { combineMethodName, isRuntimeMethod, runtimeMethodTypeMetadataKey, toWrappedMethod, } from "../method/runtimeMethod";
18
18
  import { MethodIdFactory } from "../factories/MethodIdFactory";
19
+ export function getAllPropertyNames(obj) {
20
+ let keys = [];
21
+ // if primitive (primitives still have keys) skip the first iteration
22
+ if (!(obj instanceof Object)) {
23
+ obj = Object.getPrototypeOf(obj);
24
+ }
25
+ while (obj) {
26
+ keys = keys.concat(Reflect.ownKeys(obj));
27
+ obj = Object.getPrototypeOf(obj);
28
+ }
29
+ return keys;
30
+ }
19
31
  const errors = {
20
32
  methodNotFound: (methodKey) => new Error(`Unable to find method with id ${methodKey}`),
21
33
  };
@@ -47,12 +59,13 @@ export class RuntimeZkProgrammable extends ZkProgrammable {
47
59
  // eslint-disable-next-line max-len
48
60
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
49
61
  const modulePrototype = Object.getPrototypeOf(runtimeModule);
50
- const modulePrototypeMethods = Object.getOwnPropertyNames(modulePrototype);
62
+ const modulePrototypeMethods = getAllPropertyNames(runtimeModule).map((method) => method.toString());
51
63
  const moduleMethods = modulePrototypeMethods.reduce((allModuleMethods, methodName) => {
52
64
  if (isRuntimeMethod(runtimeModule, methodName)) {
53
65
  const combinedMethodName = combineMethodName(runtimeModuleName, methodName);
54
66
  const method = modulePrototype[methodName];
55
- const wrappedMethod = Reflect.apply(toWrappedMethod, runtimeModule, [methodName, method]);
67
+ const invocationType = Reflect.getMetadata(runtimeMethodTypeMetadataKey, runtimeModule, methodName);
68
+ const wrappedMethod = Reflect.apply(toWrappedMethod, runtimeModule, [methodName, method, { invocationType }]);
56
69
  // eslint-disable-next-line no-warning-comments
57
70
  // TODO: find out how to import the Tuple type
58
71
  const privateInputs = Reflect.getMetadata("design:paramtypes", runtimeModule, methodName);
@@ -86,6 +99,7 @@ export class RuntimeZkProgrammable extends ZkProgrammable {
86
99
  return {
87
100
  compile: program.compile.bind(program),
88
101
  verify: program.verify.bind(program),
102
+ analyzeMethods: program.analyzeMethods.bind(program),
89
103
  Proof: SelfProof,
90
104
  methods,
91
105
  };
@@ -1,5 +1,5 @@
1
1
  import { ConfigurableModule, NoConfig, Presets } from "@proto-kit/common";
2
- import { NetworkState, RuntimeTransaction } from "@proto-kit/protocol";
2
+ import { NetworkState, RuntimeTransaction, RuntimeMethodExecutionData } from "@proto-kit/protocol";
3
3
  import { RuntimeEnvironment } from "./RuntimeEnvironment";
4
4
  /**
5
5
  * Base class for runtime modules providing the necessary utilities.
@@ -19,7 +19,7 @@ export declare class RuntimeModule<Config = NoConfig> extends ConfigurableModule
19
19
  name?: string;
20
20
  runtime?: RuntimeEnvironment;
21
21
  constructor();
22
- private getInputs;
22
+ getInputs(): RuntimeMethodExecutionData;
23
23
  get transaction(): RuntimeTransaction;
24
24
  get network(): NetworkState;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeModule.d.ts","sourceRoot":"","sources":["../../src/runtime/RuntimeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EACL,YAAY,EACZ,kBAAkB,EAInB,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D;;GAEG;AACH,qBACa,aAAa,CACxB,MAAM,GAAG,QAAQ,CACjB,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IAClC,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,kBAAkB,CAAC;;IAYpC,OAAO,CAAC,SAAS;IAWjB,IAAW,WAAW,IAAI,kBAAkB,CAE3C;IAED,IAAW,OAAO,IAAI,YAAY,CAEjC;CACF"}
1
+ {"version":3,"file":"RuntimeModule.d.ts","sourceRoot":"","sources":["../../src/runtime/RuntimeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EACL,YAAY,EACZ,kBAAkB,EAGlB,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;AAS7B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAO1D;;GAEG;AACH,qBACa,aAAa,CACxB,MAAM,GAAG,QAAQ,CACjB,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IAClC,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,kBAAkB,CAAC;;IAY7B,SAAS,IAAI,0BAA0B;IAa9C,IAAW,WAAW,IAAI,kBAAkB,CAE3C;IAED,IAAW,OAAO,IAAI,YAAY,CAEjC;CACF"}
@@ -9,8 +9,9 @@ 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 "@proto-kit/protocol";
12
+ import { RuntimeMethodExecutionContext, RuntimeMethodExecutionDataStruct, } from "@proto-kit/protocol";
13
13
  import { runtimeMethodNamesMetadataKey } from "../method/runtimeMethod";
14
+ import { Provable } from "o1js";
14
15
  const errors = {
15
16
  inputDataNotSet: () => new Error("Input data for runtime execution not set"),
16
17
  };
@@ -35,11 +36,13 @@ let RuntimeModule = class RuntimeModule extends ConfigurableModule {
35
36
  this.runtimeMethodNames = methodNames ?? [];
36
37
  }
37
38
  getInputs() {
38
- const { input } = container.resolve(RuntimeMethodExecutionContext);
39
- if (input === undefined) {
40
- throw errors.inputDataNotSet();
41
- }
42
- return input;
39
+ return Provable.witness(RuntimeMethodExecutionDataStruct, () => {
40
+ const { input } = container.resolve(RuntimeMethodExecutionContext);
41
+ if (input === undefined) {
42
+ throw errors.inputDataNotSet();
43
+ }
44
+ return input;
45
+ });
43
46
  }
44
47
  get transaction() {
45
48
  return this.getInputs().transaction;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@proto-kit/module",
3
3
  "license": "MIT",
4
4
  "private": false,
5
- "version": "0.1.1-develop.600+699a7df",
5
+ "version": "0.1.1-develop.651+7591cb6",
6
6
  "type": "module",
7
7
  "scripts": {
8
8
  "build": "tsc -p tsconfig.json",
@@ -31,5 +31,5 @@
31
31
  "o1js": "0.13.1",
32
32
  "tsyringe": "^4.7.0"
33
33
  },
34
- "gitHead": "699a7dfa3b5d3415ab4500f0cd495d6781365c6a"
34
+ "gitHead": "7591cb6bdf58a6cd525a10902c25bc292efcfc6b"
35
35
  }
@@ -1,5 +1,11 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
- import { Field, FlexibleProvable, Proof, ProvableExtended } from "o1js";
2
+ import {
3
+ Field,
4
+ FlexibleProvable,
5
+ Proof,
6
+ Provable,
7
+ ProvableExtended,
8
+ } from "o1js";
3
9
  import {
4
10
  ArgumentTypes,
5
11
  ProofTypes,
@@ -118,13 +124,16 @@ export class MethodParameterEncoder {
118
124
  return argumentType.toFields(argument);
119
125
  });
120
126
 
121
- const argsJSON = args.map((argument, index) => {
122
- if (argument instanceof Proof) {
123
- return JSON.stringify(argument.toJSON());
124
- }
127
+ let argsJSON: string[] = [];
128
+ Provable.asProver(() => {
129
+ argsJSON = args.map((argument, index) => {
130
+ if (argument instanceof Proof) {
131
+ return JSON.stringify(argument.toJSON());
132
+ }
125
133
 
126
- const argumentType = this.types[index] as ToJSONableStatic;
127
- return JSON.stringify(argumentType.toJSON(argument));
134
+ const argumentType = this.types[index] as ToJSONableStatic;
135
+ return JSON.stringify(argumentType.toJSON(argument));
136
+ });
128
137
  });
129
138
 
130
139
  return {
@@ -1,20 +1,14 @@
1
1
  /* eslint-disable max-statements */
2
- import {
3
- Bool,
4
- Field,
5
- FlexibleProvable,
6
- Poseidon,
7
- Proof,
8
- ProvableExtended,
9
- } from "o1js";
2
+ import { Bool, Field, Poseidon } from "o1js";
10
3
  import { container } from "tsyringe";
11
4
  import {
12
5
  StateTransition,
13
- DefaultProvableHashList,
14
6
  ProvableStateTransition,
15
7
  MethodPublicOutput,
16
8
  RuntimeMethodExecutionContext,
9
+ RuntimeMethodExecutionDataStruct,
17
10
  SignedTransaction,
11
+ StateTransitionReductionList,
18
12
  } from "@proto-kit/protocol";
19
13
  import {
20
14
  DecoratedMethod,
@@ -29,6 +23,8 @@ import {
29
23
  } from "@proto-kit/common";
30
24
 
31
25
  import type { RuntimeModule } from "../runtime/RuntimeModule.js";
26
+ import { MethodIdResolver } from "../runtime/MethodIdResolver";
27
+ import { state } from "../state/decorator.js";
32
28
  import { MethodParameterEncoder } from "./MethodParameterEncoder";
33
29
 
34
30
  const errors = {
@@ -52,7 +48,7 @@ export function toStateTransitionsHash(
52
48
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
49
  stateTransitions: StateTransition<any>[]
54
50
  ) {
55
- const stateTransitionsHashList = new DefaultProvableHashList(
51
+ const stateTransitionsHashList = new StateTransitionReductionList(
56
52
  ProvableStateTransition
57
53
  );
58
54
 
@@ -73,7 +69,6 @@ export function toWrappedMethod(
73
69
  this: RuntimeModule<unknown>,
74
70
  methodName: string,
75
71
  moduleMethod: (...args: ArgumentTypes) => unknown,
76
- methodArguments: ArgumentTypes,
77
72
  options: {
78
73
  invocationType: RuntimeMethodInvocationType;
79
74
  }
@@ -86,14 +81,11 @@ export function toWrappedMethod(
86
81
  Reflect.apply(moduleMethod, this, args);
87
82
  const {
88
83
  result: { stateTransitions, status },
89
- input,
90
84
  } = executionContext.current();
91
85
 
92
86
  const stateTransitionsHash = toStateTransitionsHash(stateTransitions);
93
87
 
94
- if (input === undefined) {
95
- throw errors.methodInputsNotProvided();
96
- }
88
+ const input = this.getInputs();
97
89
 
98
90
  const { name, runtime } = this;
99
91
 
@@ -122,14 +114,17 @@ export function toWrappedMethod(
122
114
  * Use the type info obtained previously to convert
123
115
  * the args passed to fields
124
116
  */
125
- const { argsFields } = MethodParameterEncoder.fromMethod(this, methodName).encode(args);
117
+ const { argsFields } = MethodParameterEncoder.fromMethod(
118
+ this,
119
+ methodName
120
+ ).encode(args);
126
121
 
127
122
  // Assert that the argsHash that has been signed matches the given arguments
128
- // We can use js-if here, because methodArguments is statically sizes
123
+ // We can use js-if here, because args are statically sized
129
124
  // i.e. the result of the if-statement will be the same for all executions
130
125
  // of this method
131
126
  const argsHash =
132
- methodArguments.length > 0 ? Poseidon.hash(argsFields) : Field(0);
127
+ (args ?? []).length > 0 ? Poseidon.hash(argsFields) : Field(0);
133
128
 
134
129
  transaction.argsHash.assertEquals(
135
130
  argsHash,
@@ -189,7 +184,9 @@ export function isRuntimeMethod(
189
184
 
190
185
  export type RuntimeMethodInvocationType = "SIGNATURE" | "INCOMING_MESSAGE";
191
186
 
192
- function runtimeMethodInternal(options: { invocationType: RuntimeMethodInvocationType }) {
187
+ function runtimeMethodInternal(options: {
188
+ invocationType: RuntimeMethodInvocationType;
189
+ }) {
193
190
  return (
194
191
  target: RuntimeModule<unknown>,
195
192
  methodName: string,
@@ -227,7 +224,7 @@ function runtimeMethodInternal(options: { invocationType: RuntimeMethodInvocatio
227
224
  this: RuntimeModule<unknown>,
228
225
  ...args: ArgumentTypes
229
226
  ) {
230
- const constructorName = this.constructor.name;
227
+ const constructorName = this.name!;
231
228
 
232
229
  /**
233
230
  * If its a top level method call, wrap it into a wrapped method,
@@ -239,7 +236,6 @@ function runtimeMethodInternal(options: { invocationType: RuntimeMethodInvocatio
239
236
  const simulatedWrappedMethod = Reflect.apply(toWrappedMethod, this, [
240
237
  methodName,
241
238
  simulatedMethod,
242
- args,
243
239
  options,
244
240
  ]);
245
241
 
@@ -1,7 +1,13 @@
1
- import { stringToField } from "@proto-kit/protocol";
1
+ import { filterNonUndefined } from "@proto-kit/common";
2
+ import { stringToField, RuntimeMethodIdMapping } from "@proto-kit/protocol";
2
3
  import { Poseidon } from "o1js";
3
4
  import { inject, injectable } from "tsyringe";
4
5
 
6
+ import {
7
+ RuntimeMethodInvocationType,
8
+ runtimeMethodTypeMetadataKey,
9
+ } from "../method/runtimeMethod";
10
+
5
11
  import type { Runtime, RuntimeModulesRecord } from "./Runtime";
6
12
 
7
13
  /**
@@ -33,6 +39,49 @@ export class MethodIdResolver {
33
39
  }, {});
34
40
  }
35
41
 
42
+ /**
43
+ * The purpose of this method is to provide a dictionary where
44
+ * we can look up properties like methodId and invocationType
45
+ * for each runtimeMethod using their module name and method name
46
+ */
47
+ public methodIdMap(): RuntimeMethodIdMapping {
48
+ const methodIdResolver =
49
+ this.runtime.dependencyContainer.resolve<MethodIdResolver>(
50
+ "MethodIdResolver"
51
+ );
52
+
53
+ const rawMappings = this.runtime.moduleNames.flatMap((moduleName) => {
54
+ const module = this.runtime.resolve(moduleName);
55
+ return module.runtimeMethodNames.map((method) => {
56
+ const type = Reflect.getMetadata(
57
+ runtimeMethodTypeMetadataKey,
58
+ module,
59
+ method
60
+ ) as RuntimeMethodInvocationType | undefined;
61
+
62
+ if (type !== undefined) {
63
+ return {
64
+ name: `${moduleName}.${method}`,
65
+ methodId: methodIdResolver.getMethodId(moduleName, method),
66
+ type,
67
+ } as const;
68
+ }
69
+
70
+ return undefined;
71
+ });
72
+ });
73
+
74
+ return rawMappings
75
+ .filter(filterNonUndefined)
76
+ .reduce<RuntimeMethodIdMapping>((acc, entry) => {
77
+ acc[entry.name] = {
78
+ methodId: entry.methodId,
79
+ type: entry.type,
80
+ };
81
+ return acc;
82
+ }, {});
83
+ }
84
+
36
85
  public getMethodNameFromId(methodId: bigint): [string, string] | undefined {
37
86
  const methodPath = this.dictionary[methodId.toString()];
38
87
 
@@ -10,7 +10,6 @@ import {
10
10
  TypedClass,
11
11
  ZkProgrammable,
12
12
  PlainZkProgram,
13
- WithZkProgrammable,
14
13
  AreProofsEnabled,
15
14
  ChildContainerProvider,
16
15
  } from "@proto-kit/common";
@@ -23,6 +22,7 @@ import {
23
22
  import {
24
23
  combineMethodName,
25
24
  isRuntimeMethod,
25
+ runtimeMethodTypeMetadataKey,
26
26
  toWrappedMethod,
27
27
  WrappedMethod,
28
28
  } from "../method/runtimeMethod";
@@ -32,6 +32,19 @@ import { RuntimeModule } from "./RuntimeModule";
32
32
  import { MethodIdResolver } from "./MethodIdResolver";
33
33
  import { RuntimeEnvironment } from "./RuntimeEnvironment";
34
34
 
35
+ export function getAllPropertyNames(obj: any) {
36
+ let keys: (string | symbol)[] = [];
37
+ // if primitive (primitives still have keys) skip the first iteration
38
+ if (!(obj instanceof Object)) {
39
+ obj = Object.getPrototypeOf(obj);
40
+ }
41
+ while (obj) {
42
+ keys = keys.concat(Reflect.ownKeys(obj));
43
+ obj = Object.getPrototypeOf(obj);
44
+ }
45
+ return keys;
46
+ }
47
+
35
48
  /**
36
49
  * Record of modules accepted by the Runtime module container.
37
50
  *
@@ -104,8 +117,9 @@ export class RuntimeZkProgrammable<
104
117
  (...args: unknown[]) => unknown
105
118
  >;
106
119
 
107
- const modulePrototypeMethods =
108
- Object.getOwnPropertyNames(modulePrototype);
120
+ const modulePrototypeMethods = getAllPropertyNames(runtimeModule).map(
121
+ (method) => method.toString()
122
+ );
109
123
 
110
124
  const moduleMethods = modulePrototypeMethods.reduce<Methods>(
111
125
  (allModuleMethods, methodName) => {
@@ -115,10 +129,16 @@ export class RuntimeZkProgrammable<
115
129
  methodName
116
130
  );
117
131
  const method = modulePrototype[methodName];
132
+ const invocationType = Reflect.getMetadata(
133
+ runtimeMethodTypeMetadataKey,
134
+ runtimeModule,
135
+ methodName
136
+ );
137
+
118
138
  const wrappedMethod = Reflect.apply(
119
139
  toWrappedMethod,
120
140
  runtimeModule,
121
- [methodName, method]
141
+ [methodName, method, { invocationType }]
122
142
  );
123
143
 
124
144
  // eslint-disable-next-line no-warning-comments
@@ -175,6 +195,7 @@ export class RuntimeZkProgrammable<
175
195
  return {
176
196
  compile: program.compile.bind(program),
177
197
  verify: program.verify.bind(program),
198
+ analyzeMethods: program.analyzeMethods.bind(program),
178
199
  Proof: SelfProof,
179
200
  methods,
180
201
  };
@@ -6,6 +6,7 @@ import {
6
6
  StateService,
7
7
  RuntimeMethodExecutionContext,
8
8
  RuntimeMethodExecutionData,
9
+ RuntimeMethodExecutionDataStruct,
9
10
  } from "@proto-kit/protocol";
10
11
 
11
12
  import { runtimeMethodNamesMetadataKey } from "../method/runtimeMethod";
@@ -16,6 +17,7 @@ import type {
16
17
  RuntimeModulesRecord,
17
18
  } from "./Runtime";
18
19
  import { RuntimeEnvironment } from "./RuntimeEnvironment";
20
+ import { Provable } from "o1js";
19
21
 
20
22
  const errors = {
21
23
  inputDataNotSet: () => new Error("Input data for runtime execution not set"),
@@ -56,15 +58,17 @@ export class RuntimeModule<
56
58
  this.runtimeMethodNames = methodNames ?? [];
57
59
  }
58
60
 
59
- private getInputs(): RuntimeMethodExecutionData {
60
- const { input } = container.resolve<RuntimeMethodExecutionContext>(
61
- RuntimeMethodExecutionContext
62
- );
61
+ public getInputs(): RuntimeMethodExecutionData {
62
+ return Provable.witness(RuntimeMethodExecutionDataStruct, () => {
63
+ const { input } = container.resolve<RuntimeMethodExecutionContext>(
64
+ RuntimeMethodExecutionContext
65
+ );
66
+ if (input === undefined) {
67
+ throw errors.inputDataNotSet();
68
+ }
63
69
 
64
- if (input === undefined) {
65
- throw errors.inputDataNotSet();
66
- }
67
- return input;
70
+ return input;
71
+ });
68
72
  }
69
73
 
70
74
  public get transaction(): RuntimeTransaction {