@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.
Files changed (93) hide show
  1. package/dist/index.d.ts +0 -5
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -5
  4. package/dist/method/MethodParameterDecoder.d.ts.map +1 -1
  5. package/dist/method/MethodParameterDecoder.js +1 -1
  6. package/dist/method/RuntimeMethodExecutionContext.d.ts +2 -2
  7. package/dist/method/RuntimeMethodExecutionContext.d.ts.map +1 -1
  8. package/dist/method/runtimeMethod.d.ts.map +1 -1
  9. package/dist/method/runtimeMethod.js +1 -2
  10. package/dist/module/src/factories/MethodIdFactory.d.ts +9 -0
  11. package/dist/module/src/factories/MethodIdFactory.d.ts.map +1 -0
  12. package/dist/module/src/factories/MethodIdFactory.js +36 -0
  13. package/dist/module/src/index.d.ts +11 -0
  14. package/dist/module/src/index.d.ts.map +1 -0
  15. package/dist/module/src/index.js +10 -0
  16. package/dist/module/src/method/MethodParameterDecoder.d.ts +22 -0
  17. package/dist/module/src/method/MethodParameterDecoder.d.ts.map +1 -0
  18. package/dist/module/src/method/MethodParameterDecoder.js +33 -0
  19. package/dist/module/src/method/runtimeMethod.d.ts +19 -0
  20. package/dist/module/src/method/runtimeMethod.d.ts.map +1 -0
  21. package/dist/module/src/method/runtimeMethod.js +123 -0
  22. package/dist/module/src/module/decorator.d.ts +8 -0
  23. package/dist/module/src/module/decorator.d.ts.map +1 -0
  24. package/dist/module/src/module/decorator.js +15 -0
  25. package/dist/module/src/runtime/MethodIdResolver.d.ts +18 -0
  26. package/dist/module/src/runtime/MethodIdResolver.d.ts.map +1 -0
  27. package/dist/module/src/runtime/MethodIdResolver.js +50 -0
  28. package/dist/module/src/runtime/Runtime.d.ts +72 -0
  29. package/dist/module/src/runtime/Runtime.d.ts.map +1 -0
  30. package/dist/module/src/runtime/Runtime.js +184 -0
  31. package/dist/module/src/runtime/RuntimeModule.d.ts +34 -0
  32. package/dist/module/src/runtime/RuntimeModule.d.ts.map +1 -0
  33. package/dist/module/src/runtime/RuntimeModule.js +56 -0
  34. package/dist/module/src/state/InMemoryStateService.d.ts +11 -0
  35. package/dist/module/src/state/InMemoryStateService.d.ts.map +1 -0
  36. package/dist/module/src/state/InMemoryStateService.js +21 -0
  37. package/dist/module/src/state/decorator.d.ts +7 -0
  38. package/dist/module/src/state/decorator.d.ts.map +1 -0
  39. package/dist/module/src/state/decorator.js +42 -0
  40. package/dist/protocol/src/model/Option.d.ts +98 -0
  41. package/dist/protocol/src/model/Option.d.ts.map +1 -0
  42. package/dist/protocol/src/model/Option.js +98 -0
  43. package/dist/protocol/src/model/StateTransition.d.ts +96 -0
  44. package/dist/protocol/src/model/StateTransition.d.ts.map +1 -0
  45. package/dist/protocol/src/model/StateTransition.js +65 -0
  46. package/dist/protocol/src/model/network/NetworkState.d.ts +64 -0
  47. package/dist/protocol/src/model/network/NetworkState.d.ts.map +1 -0
  48. package/dist/protocol/src/model/network/NetworkState.js +12 -0
  49. package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts +70 -0
  50. package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts.map +1 -0
  51. package/dist/protocol/src/model/transaction/ProtocolTransaction.js +18 -0
  52. package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts +63 -0
  53. package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts.map +1 -0
  54. package/dist/protocol/src/model/transaction/RuntimeTransaction.js +29 -0
  55. package/dist/protocol/src/state/assert/assert.d.ts +12 -0
  56. package/dist/protocol/src/state/assert/assert.d.ts.map +1 -0
  57. package/dist/protocol/src/state/assert/assert.js +23 -0
  58. package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts +60 -0
  59. package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -0
  60. package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.js +105 -0
  61. package/dist/runtime/Runtime.d.ts +6 -5
  62. package/dist/runtime/Runtime.d.ts.map +1 -1
  63. package/dist/runtime/Runtime.js +5 -7
  64. package/dist/runtime/RuntimeModule.d.ts +1 -3
  65. package/dist/runtime/RuntimeModule.d.ts.map +1 -1
  66. package/dist/runtime/RuntimeModule.js +1 -1
  67. package/dist/state/InMemoryStateService.d.ts +1 -4
  68. package/dist/state/InMemoryStateService.d.ts.map +1 -1
  69. package/dist/state/StateMap.d.ts +3 -3
  70. package/dist/state/StateMap.d.ts.map +1 -1
  71. package/dist/state/decorator.d.ts.map +1 -1
  72. package/dist/state/decorator.js +1 -1
  73. package/package.json +3 -4
  74. package/src/index.ts +0 -5
  75. package/src/method/MethodParameterDecoder.ts +3 -1
  76. package/src/method/runtimeMethod.ts +1 -2
  77. package/src/runtime/Runtime.ts +12 -10
  78. package/src/runtime/RuntimeModule.ts +5 -6
  79. package/src/state/InMemoryStateService.ts +1 -5
  80. package/src/state/decorator.ts +2 -4
  81. package/test/Runtime.test.ts +2 -2
  82. package/test/modules/Admin.ts +1 -1
  83. package/test/modules/Balances.test.ts +13 -8
  84. package/test/modules/Balances.ts +7 -3
  85. package/test/modules/State.test.ts +88 -0
  86. package/test/modules/methodId.test.ts +0 -1
  87. package/test/transaction.test.ts +1 -1
  88. package/src/method/RuntimeMethodExecutionContext.ts +0 -111
  89. package/src/method/assert.test.ts +0 -49
  90. package/src/method/assert.ts +0 -27
  91. package/src/state/State.ts +0 -154
  92. package/src/state/StateMap.ts +0 -69
  93. package/src/state/StateServiceProvider.ts +0 -24
package/dist/index.d.ts CHANGED
@@ -1,13 +1,8 @@
1
- export * from "./method/RuntimeMethodExecutionContext";
2
- export * from "./method/assert";
3
1
  export * from "./method/runtimeMethod";
4
2
  export * from "./module/decorator";
5
3
  export * from "./runtime/RuntimeModule";
6
4
  export * from "./runtime/Runtime";
7
5
  export * from "./state/InMemoryStateService";
8
- export * from "./state/State";
9
- export * from "./state/StateMap";
10
- export * from "./state/StateServiceProvider";
11
6
  export * from "./state/decorator";
12
7
  export * from "./method/MethodParameterDecoder";
13
8
  export * from "./runtime/MethodIdResolver";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,13 +1,8 @@
1
- export * from "./method/RuntimeMethodExecutionContext";
2
- export * from "./method/assert";
3
1
  export * from "./method/runtimeMethod";
4
2
  export * from "./module/decorator";
5
3
  export * from "./runtime/RuntimeModule";
6
4
  export * from "./runtime/Runtime";
7
5
  export * from "./state/InMemoryStateService";
8
- export * from "./state/State";
9
- export * from "./state/StateMap";
10
- export * from "./state/StateServiceProvider";
11
6
  export * from "./state/decorator";
12
7
  export * from "./method/MethodParameterDecoder";
13
8
  export * from "./runtime/MethodIdResolver";
@@ -1 +1 @@
1
- {"version":3,"file":"MethodParameterDecoder.d.ts","sourceRoot":"","sources":["../../src/method/MethodParameterDecoder.ts"],"names":[],"mappings":"AACA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AC,EAAE,GAAG,EAAE,CAAC;KACjB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAYD,qBAAa,sBAAsB;IAWb,OAAO,CAAC,QAAQ,CAAC,KAAK;WAV5B,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM;IAU3E,OAAO;IAEA,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE;IAmB/C,IAAW,SAAS,IAAI,MAAM,CAM7B;CACF"}
@@ -28,6 +28,6 @@ export class MethodParameterDecoder {
28
28
  get fieldSize() {
29
29
  return this.types
30
30
  .map((type) => type.prototype._fields?.length ?? type.sizeInFields?.() ?? 0)
31
- .reduce((a, b) => a + b);
31
+ .reduce((a, b) => a + b, 0);
32
32
  }
33
33
  }
@@ -1,5 +1,5 @@
1
1
  import { Bool } from "snarkyjs";
2
- import type { StateTransition, NetworkState } from "@proto-kit/protocol";
2
+ import type { StateTransition, NetworkState, ToFieldable } from "@proto-kit/protocol";
3
3
  import { ProvableMethodExecutionContext, ProvableMethodExecutionResult } from "@proto-kit/common";
4
4
  import { RuntimeTransaction } from "@proto-kit/protocol/src/model/transaction/RuntimeTransaction";
5
5
  export declare class RuntimeProvableMethodExecutionResult extends ProvableMethodExecutionResult {
@@ -26,7 +26,7 @@ export declare class RuntimeMethodExecutionContext extends ProvableMethodExecuti
26
26
  * Adds an in-method generated state transition to the current context
27
27
  * @param stateTransition - State transition to add to the context
28
28
  */
29
- addStateTransition<Value>(stateTransition: StateTransition<Value>): void;
29
+ addStateTransition<Value extends ToFieldable>(stateTransition: StateTransition<Value>): void;
30
30
  /**
31
31
  * @param message - Status message to acompany the current status
32
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"RuntimeMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../src/method/RuntimeMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,U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,eAAO,MAAM,wBAAwB,eAAe,CAAC;AACrD,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,WAAW,EAAE,MAAM,WAKpB;AAED,wBAAgB,aAAa,aAEjB,cAAc,OAAO,CAAC,cAClB,MAAM,cACN,kBAAkB,UAuFjC"}
@@ -1,7 +1,6 @@
1
1
  import { container } from "tsyringe";
2
- import { DefaultProvableHashList, ProvableStateTransition, MethodPublicOutput, } from "@proto-kit/protocol";
2
+ import { DefaultProvableHashList, ProvableStateTransition, MethodPublicOutput, RuntimeMethodExecutionContext } from "@proto-kit/protocol";
3
3
  import { toProver } from "@proto-kit/common";
4
- import { RuntimeMethodExecutionContext } from "./RuntimeMethodExecutionContext.js";
5
4
  const errors = {
6
5
  runtimeNotProvided: (name) => new Error(`Runtime was not provided for module: ${name}`),
7
6
  methodInputsNotProvided: () => new Error("Method execution inputs not provided, provide them via context.inputs"),
@@ -0,0 +1,9 @@
1
+ import { DependencyFactory } from "@proto-kit/common";
2
+ import { MethodIdResolver } from "../runtime/MethodIdResolver";
3
+ import type { Runtime, RuntimeModulesRecord } from "../runtime/Runtime";
4
+ export declare class MethodIdFactory extends DependencyFactory {
5
+ private readonly runtime;
6
+ constructor(runtime: Runtime<RuntimeModulesRecord>);
7
+ methodIdResolver(): MethodIdResolver;
8
+ }
9
+ //# sourceMappingURL=MethodIdFactory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodIdFactory.d.ts","sourceRoot":"","sources":["../../../../src/factories/MethodIdFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAExE,qBACa,eAAgB,SAAQ,iBAAiB;IAE/B,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAMrE,gBAAgB,IAAI,gBAAgB;CAG5C"}
@@ -0,0 +1,36 @@
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 { dependency, dependencyFactory, DependencyFactory } from "@proto-kit/common";
14
+ import { inject } from "tsyringe";
15
+ import { MethodIdResolver } from "../runtime/MethodIdResolver";
16
+ let MethodIdFactory = class MethodIdFactory extends DependencyFactory {
17
+ constructor(runtime) {
18
+ super();
19
+ this.runtime = runtime;
20
+ }
21
+ methodIdResolver() {
22
+ return new MethodIdResolver(this.runtime, this.runtime.definition.modules);
23
+ }
24
+ };
25
+ __decorate([
26
+ dependency(),
27
+ __metadata("design:type", Function),
28
+ __metadata("design:paramtypes", []),
29
+ __metadata("design:returntype", MethodIdResolver)
30
+ ], MethodIdFactory.prototype, "methodIdResolver", null);
31
+ MethodIdFactory = __decorate([
32
+ dependencyFactory(),
33
+ __param(0, inject("Runtime")),
34
+ __metadata("design:paramtypes", [Function])
35
+ ], MethodIdFactory);
36
+ export { MethodIdFactory };
@@ -0,0 +1,11 @@
1
+ export * from "../../protocol/src/state/assert/assert";
2
+ export * from "./method/runtimeMethod";
3
+ export * from "./module/decorator";
4
+ export * from "./runtime/RuntimeModule";
5
+ export * from "./runtime/Runtime";
6
+ export * from "./state/InMemoryStateService";
7
+ export * from "@proto-kit/protocol/src/state/StateServiceProvider";
8
+ export * from "./state/decorator";
9
+ export * from "./method/MethodParameterDecoder";
10
+ export * from "./runtime/MethodIdResolver";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oDAAoD,CAAC;AACnE,cAAc,mBAAmB,CAAC;AAClC,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,10 @@
1
+ export * from "../../protocol/src/state/assert/assert";
2
+ export * from "./method/runtimeMethod";
3
+ export * from "./module/decorator";
4
+ export * from "./runtime/RuntimeModule";
5
+ export * from "./runtime/Runtime";
6
+ export * from "./state/InMemoryStateService";
7
+ export * from "@proto-kit/protocol/src/state/StateServiceProvider";
8
+ export * from "./state/decorator";
9
+ export * from "./method/MethodParameterDecoder";
10
+ export * from "./runtime/MethodIdResolver";
@@ -0,0 +1,22 @@
1
+ import { Field } from "snarkyjs";
2
+ import { RuntimeModule } from "../runtime/RuntimeModule";
3
+ export interface Fieldable {
4
+ toFields: () => Field[];
5
+ }
6
+ export interface FromFieldClass {
7
+ new: (...args: any[]) => any;
8
+ fromFields: (fields: Field[]) => Fieldable;
9
+ name: string;
10
+ prototype: {
11
+ _fields?: any[];
12
+ };
13
+ sizeInFields?: () => number;
14
+ }
15
+ export declare class MethodParameterDecoder {
16
+ private readonly types;
17
+ static fromMethod(target: RuntimeModule<unknown>, methodName: string): MethodParameterDecoder;
18
+ private constructor();
19
+ fromFields(fields: Field[]): Fieldable[];
20
+ get fieldSize(): number;
21
+ }
22
+ //# sourceMappingURL=MethodParameterDecoder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodParameterDecoder.d.ts","sourceRoot":"","sources":["../../../../src/method/MethodParameterDecoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAC7B,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,SAAS,CAAC;IAC3C,IAAI,EAAE,MAAM,CAAC;IAEb,SAAS,EAAE;QACT,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;KACjB,CAAC;IACF,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAYD,qBAAa,sBAAsB;IAWb,OAAO,CAAC,QAAQ,CAAC,KAAK;WAV5B,UAAU,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,UAAU,EAAE,MAAM;IAU3E,OAAO;IAEA,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE;IAmB/C,IAAW,SAAS,IAAI,MAAM,CAM7B;CACF"}
@@ -0,0 +1,33 @@
1
+ const errors = {
2
+ fieldLengthNotMatching: (expected, actual) => new Error(`Expected ${expected} field elements, got ${actual}`),
3
+ typeNotCompatible: (name) => new Error(`Cannot decode type ${name}, it has to be either a Struct, CircuitValue or built-in snarkyjs type`),
4
+ };
5
+ export class MethodParameterDecoder {
6
+ static fromMethod(target, methodName) {
7
+ const paramtypes = Reflect.getMetadata("design:paramtypes", target, methodName);
8
+ return new MethodParameterDecoder(paramtypes);
9
+ }
10
+ constructor(types) {
11
+ this.types = types;
12
+ }
13
+ fromFields(fields) {
14
+ if (fields.length < this.fieldSize) {
15
+ throw errors.fieldLengthNotMatching(this.fieldSize, fields.length);
16
+ }
17
+ let stack = fields.slice();
18
+ return this.types.map((type) => {
19
+ const numberFieldsNeeded = type.prototype._fields?.length ?? type.sizeInFields?.() ?? -1;
20
+ if (numberFieldsNeeded === -1) {
21
+ throw errors.typeNotCompatible(type.name);
22
+ }
23
+ const structFields = stack.slice(0, numberFieldsNeeded);
24
+ stack = stack.slice(numberFieldsNeeded);
25
+ return type.fromFields(structFields);
26
+ });
27
+ }
28
+ get fieldSize() {
29
+ return this.types
30
+ .map((type) => type.prototype._fields?.length ?? type.sizeInFields?.() ?? 0)
31
+ .reduce((a, b) => a + b, 0);
32
+ }
33
+ }
@@ -0,0 +1,19 @@
1
+ import { StateTransition, MethodPublicOutput } from "@proto-kit/protocol";
2
+ import type { RuntimeModule } from "../runtime/RuntimeModule.js";
3
+ export declare function toStateTransitionsHash(stateTransitions: StateTransition<any>[]): import("snarkyjs/dist/node/lib/field.js").Field;
4
+ export type WrappedMethod = (...args: unknown[]) => MethodPublicOutput;
5
+ export declare function toWrappedMethod(this: RuntimeModule<unknown>, methodName: string, moduleMethod: (...args: unknown[]) => unknown): WrappedMethod;
6
+ export declare function combineMethodName(runtimeModuleName: string, methodName: string): string;
7
+ export declare const runtimeMethodMetadataKey = "yab-method";
8
+ export declare const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods";
9
+ /**
10
+ * Checks the metadata of the provided runtime module and its method,
11
+ * to see if it has been decorated with @runtimeMethod()
12
+ *
13
+ * @param target - Runtime module to check
14
+ * @param propertyKey - Name of the method to check in the prior runtime module
15
+ * @returns - If the provided method name is a runtime method or not
16
+ */
17
+ export declare function isRuntimeMethod(target: RuntimeModule<unknown>, propertyKey: string): boolean;
18
+ export declare function runtimeMethod(): (target: RuntimeModule<unknown>, methodName: string, descriptor: PropertyDescriptor) => void;
19
+ //# sourceMappingURL=runtimeMethod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimeMethod.d.ts","sourceRoot":"","sources":["../../../../src/method/runtimeMethod.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EAGf,kBAAkB,EAEnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAYjE,wBAAgB,sBAAsB,CAEpC,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,mDAczC;AAGD,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,kBAAkB,CAAC;AAEvE,wBAAgB,eAAe,CAC7B,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,iBAoC9C;AAED,wBAAgB,iBAAiB,CAC/B,iBAAiB,EAAE,MAAM,EACzB,UAAU,EAAE,MAAM,UAGnB;AAED,eAAO,MAAM,wBAAwB,eAAe,CAAC;AACrD,eAAO,MAAM,6BAA6B,8BAA8B,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,EAC9B,WAAW,EAAE,MAAM,WAKpB;AAED,wBAAgB,aAAa,aAEjB,cAAc,OAAO,CAAC,cAClB,MAAM,cACN,kBAAkB,UAuFjC"}
@@ -0,0 +1,123 @@
1
+ import { container } from "tsyringe";
2
+ import { DefaultProvableHashList, ProvableStateTransition, MethodPublicOutput, RuntimeMethodExecutionContext } from "@proto-kit/protocol";
3
+ import { toProver } from "@proto-kit/common";
4
+ const errors = {
5
+ runtimeNotProvided: (name) => new Error(`Runtime was not provided for module: ${name}`),
6
+ methodInputsNotProvided: () => new Error("Method execution inputs not provided, provide them via context.inputs"),
7
+ };
8
+ export function toStateTransitionsHash(
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ stateTransitions) {
11
+ const stateTransitionsHashList = new DefaultProvableHashList(ProvableStateTransition);
12
+ return stateTransitions
13
+ .map((stateTransition) => stateTransition.toProvable())
14
+ .reduce((allStateTransitionsHashList, stateTransition) => allStateTransitionsHashList.push(stateTransition), stateTransitionsHashList)
15
+ .toField();
16
+ }
17
+ export function toWrappedMethod(methodName, moduleMethod) {
18
+ const executionContext = container.resolve(RuntimeMethodExecutionContext);
19
+ const wrappedMethod = (...args) => {
20
+ Reflect.apply(moduleMethod, this, args);
21
+ const { result: { stateTransitions, status }, input, } = executionContext.current();
22
+ const stateTransitionsHash = toStateTransitionsHash(stateTransitions);
23
+ if (input === undefined) {
24
+ throw errors.methodInputsNotProvided();
25
+ }
26
+ const transactionHash = input.transaction.hash();
27
+ const networkStateHash = input.networkState.hash();
28
+ return new MethodPublicOutput({
29
+ stateTransitionsHash,
30
+ status,
31
+ transactionHash,
32
+ networkStateHash,
33
+ });
34
+ };
35
+ Object.defineProperty(wrappedMethod, "name", {
36
+ value: `wrapped_${methodName}`,
37
+ writable: false,
38
+ });
39
+ return wrappedMethod;
40
+ }
41
+ export function combineMethodName(runtimeModuleName, methodName) {
42
+ return `${runtimeModuleName}.${methodName}`;
43
+ }
44
+ export const runtimeMethodMetadataKey = "yab-method";
45
+ export const runtimeMethodNamesMetadataKey = "proto-kit-runtime-methods";
46
+ /**
47
+ * Checks the metadata of the provided runtime module and its method,
48
+ * to see if it has been decorated with @runtimeMethod()
49
+ *
50
+ * @param target - Runtime module to check
51
+ * @param propertyKey - Name of the method to check in the prior runtime module
52
+ * @returns - If the provided method name is a runtime method or not
53
+ */
54
+ export function isRuntimeMethod(target, propertyKey) {
55
+ return Boolean(Reflect.getMetadata(runtimeMethodMetadataKey, target, propertyKey));
56
+ }
57
+ export function runtimeMethod() {
58
+ return (target, methodName, descriptor) => {
59
+ const executionContext = container.resolve(RuntimeMethodExecutionContext);
60
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
61
+ let data = Reflect.getMetadata(runtimeMethodNamesMetadataKey, target);
62
+ if (data !== undefined) {
63
+ data.push(methodName);
64
+ }
65
+ else {
66
+ data = [methodName];
67
+ }
68
+ Reflect.defineMetadata(runtimeMethodNamesMetadataKey, data, target);
69
+ Reflect.defineMetadata(runtimeMethodMetadataKey, true, target, methodName);
70
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
71
+ const simulatedMethod = descriptor.value;
72
+ descriptor.value = function value(...args) {
73
+ const constructorName = this.constructor.name;
74
+ /**
75
+ * If its a top level method call, wrap it into a wrapped method,
76
+ * since it'll be turned into a real/mock prover in provableMethod().
77
+ *
78
+ * Otherwise provableMethod() will just call the originalMethod provided
79
+ * if method is not called at the top level.
80
+ */
81
+ const simulatedWrappedMethod = Reflect.apply(toWrappedMethod, this, [
82
+ methodName,
83
+ simulatedMethod,
84
+ ]);
85
+ /**
86
+ * Before the prover runs, make sure it is operating on the correct
87
+ * RuntimeMethodExecutionContext state, meaning it enters and exits
88
+ * the context properly.
89
+ */
90
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
+ async function prover() {
92
+ executionContext.beforeMethod(constructorName, methodName, args);
93
+ const innerProver = toProver(combineMethodName(constructorName, methodName), simulatedWrappedMethod, false, ...args).bind(this);
94
+ // eslint-disable-next-line @typescript-eslint/init-declarations
95
+ let result;
96
+ try {
97
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
98
+ result = await Reflect.apply(innerProver, this, args);
99
+ }
100
+ finally {
101
+ executionContext.afterMethod();
102
+ }
103
+ return result;
104
+ }
105
+ executionContext.beforeMethod(constructorName, methodName, args);
106
+ if (executionContext.isTopLevel) {
107
+ if (!this.runtime) {
108
+ throw errors.runtimeNotProvided(constructorName);
109
+ }
110
+ executionContext.setProver(prover.bind(this.runtime.zkProgrammable));
111
+ }
112
+ // eslint-disable-next-line @typescript-eslint/init-declarations
113
+ let result;
114
+ try {
115
+ result = Reflect.apply(simulatedMethod, this, args);
116
+ }
117
+ finally {
118
+ executionContext.afterMethod();
119
+ }
120
+ return result;
121
+ };
122
+ };
123
+ }
@@ -0,0 +1,8 @@
1
+ import { StaticConfigurableModule, TypedClass } from "@proto-kit/common";
2
+ import { RuntimeModule } from "../runtime/RuntimeModule.js";
3
+ /**
4
+ * Marks the decorated class as a runtime module, while also
5
+ * making it injectable with our dependency injection solution.
6
+ */
7
+ export declare function runtimeModule(): (target: StaticConfigurableModule<unknown> & TypedClass<RuntimeModule<unknown>>) => void;
8
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../src/module/decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D;;;GAGG;AACH,wBAAgB,aAAa,aAMjB,yBAAyB,OAAO,CAAC,GACvC,WAAW,cAAc,OAAO,CAAC,CAAC,UAIvC"}
@@ -0,0 +1,15 @@
1
+ import { injectable } from "tsyringe";
2
+ /**
3
+ * Marks the decorated class as a runtime module, while also
4
+ * making it injectable with our dependency injection solution.
5
+ */
6
+ export function runtimeModule() {
7
+ return (
8
+ /**
9
+ * Check if the target class extends RuntimeModule, while
10
+ * also providing static config presets
11
+ */
12
+ target) => {
13
+ injectable()(target);
14
+ };
15
+ }
@@ -0,0 +1,18 @@
1
+ import type { Runtime, RuntimeModulesRecord } from "./Runtime";
2
+ /**
3
+ * How do we encode MethodIds
4
+ * A MethodId is defined as the following in little-endian
5
+ * [0
6
+ * ...hash(stringToField(moduleName))[0..128],
7
+ * ...hash(stringToField(methodName))[0..128]
8
+ * ]
9
+ */
10
+ export declare class MethodIdResolver {
11
+ private readonly runtime;
12
+ private readonly modules;
13
+ private readonly dictionary;
14
+ constructor(runtime: Runtime<RuntimeModulesRecord>, modules: RuntimeModulesRecord);
15
+ getMethodNameFromId(methodId: bigint): [string, string] | undefined;
16
+ getMethodId(moduleName: string, methodName: string): bigint;
17
+ }
18
+ //# sourceMappingURL=MethodIdResolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MethodIdResolver.d.ts","sourceRoot":"","sources":["../../../../src/runtime/MethodIdResolver.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAM/D;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAIzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;gBAGzC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC,EACtC,OAAO,EAAE,oBAAoB;IAmBzC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS;IAsBnE,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM;CAQnE"}
@@ -0,0 +1,50 @@
1
+ import { singleFieldToString, stringToField } from "@proto-kit/protocol";
2
+ const offset = 128n;
3
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
4
+ const modulus = 2n ** (offset - 1n);
5
+ /**
6
+ * How do we encode MethodIds
7
+ * A MethodId is defined as the following in little-endian
8
+ * [0
9
+ * ...hash(stringToField(moduleName))[0..128],
10
+ * ...hash(stringToField(methodName))[0..128]
11
+ * ]
12
+ */
13
+ export class MethodIdResolver {
14
+ constructor(runtime, modules) {
15
+ this.runtime = runtime;
16
+ this.modules = modules;
17
+ this.dictionary = {};
18
+ this.dictionary = runtime.runtimeModuleNames.reduce((dict, moduleName) => {
19
+ this.runtime.assertIsValidModuleName(modules, moduleName);
20
+ dict[(stringToField(moduleName).toBigInt() % modulus).toString()] =
21
+ moduleName;
22
+ runtime.resolve(moduleName).runtimeMethodNames.forEach((methodName) => {
23
+ dict[(stringToField(methodName).toBigInt() % modulus).toString()] =
24
+ methodName;
25
+ });
26
+ return dict;
27
+ }, {});
28
+ }
29
+ getMethodNameFromId(methodId) {
30
+ const moduleNameHash = singleFieldToString(methodId >> offset);
31
+ const methodNameHash = singleFieldToString(methodId % modulus);
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) {
41
+ return undefined;
42
+ }
43
+ return [moduleName, methodName];
44
+ }
45
+ getMethodId(moduleName, methodName) {
46
+ this.runtime.assertIsValidModuleName(this.modules, moduleName);
47
+ return ((stringToField(moduleName).toBigInt() % modulus << offset) +
48
+ (stringToField(methodName).toBigInt() % modulus));
49
+ }
50
+ }
@@ -0,0 +1,72 @@
1
+ import { Experimental } from "snarkyjs";
2
+ import { DependencyContainer } from "tsyringe";
3
+ import { StringKeyOf, ModuleContainer, ModulesConfig, ModulesRecord, TypedClass, ZkProgrammable, PlainZkProgram, WithZkProgrammable, AreProofsEnabled } from "@proto-kit/common";
4
+ import { MethodPublicOutput, StateServiceProvider, StateService } from "@proto-kit/protocol";
5
+ import { RuntimeModule } from "./RuntimeModule";
6
+ /**
7
+ * Record of modules accepted by the Runtime module container.
8
+ *
9
+ * We have to use TypedClass since RuntimeModule
10
+ * is an abstract class
11
+ */
12
+ export type RuntimeModulesRecord = ModulesRecord<TypedClass<RuntimeModule<unknown>>>;
13
+ /**
14
+ * Definition / required arguments for the Runtime class
15
+ */
16
+ export interface RuntimeDefinition<Modules extends RuntimeModulesRecord> {
17
+ /**
18
+ * @deprecated
19
+ */
20
+ state?: StateService;
21
+ modules: Modules;
22
+ config?: ModulesConfig<Modules>;
23
+ }
24
+ export declare class RuntimeZkProgrammable<Modules extends RuntimeModulesRecord> extends ZkProgrammable<undefined, MethodPublicOutput> {
25
+ runtime: Runtime<Modules>;
26
+ constructor(runtime: Runtime<Modules>);
27
+ get appChain(): AreProofsEnabled | undefined;
28
+ zkProgramFactory(): PlainZkProgram<undefined, MethodPublicOutput>;
29
+ }
30
+ /**
31
+ * Wrapper for an application specific runtime, which helps orchestrate
32
+ * runtime modules into an interoperable runtime.
33
+ */
34
+ export declare class Runtime<Modules extends RuntimeModulesRecord> extends ModuleContainer<Modules> implements WithZkProgrammable<undefined, MethodPublicOutput> {
35
+ static from<Modules extends RuntimeModulesRecord>(definition: RuntimeDefinition<Modules>): Runtime<Modules>;
36
+ program?: ReturnType<typeof Experimental.ZkProgram>;
37
+ definition: RuntimeDefinition<Modules>;
38
+ zkProgrammable: ZkProgrammable<undefined, MethodPublicOutput>;
39
+ private readonly stateServiceProviderInstance;
40
+ /**
41
+ * Creates a new Runtime from the provided config
42
+ *
43
+ * @param modules - Configuration object for the constructed Runtime
44
+ */
45
+ constructor(definition: RuntimeDefinition<Modules>);
46
+ start(): void;
47
+ get appChain(): AreProofsEnabled | undefined;
48
+ get stateService(): StateService;
49
+ get stateServiceProvider(): StateServiceProvider;
50
+ /**
51
+ * @returns The dependency injection container of this runtime
52
+ */
53
+ get dependencyContainer(): DependencyContainer;
54
+ /**
55
+ * @param methodId The encoded name of the method to call.
56
+ * Encoding: "stringToField(module.name) << 128 + stringToField(method-name)"
57
+ */
58
+ getMethodById(methodId: bigint): ((...args: unknown[]) => unknown) | undefined;
59
+ /**
60
+ * Add a name and other respective properties required by RuntimeModules,
61
+ * that come from the current Runtime
62
+ *
63
+ * @param moduleName - Name of the runtime module to decorate
64
+ * @param containedModule
65
+ */
66
+ decorateModule(moduleName: StringKeyOf<Modules>, containedModule: InstanceType<Modules[StringKeyOf<Modules>]>): void;
67
+ /**
68
+ * @returns A list of names of all the registered module names
69
+ */
70
+ get runtimeModuleNames(): string[];
71
+ }
72
+ //# sourceMappingURL=Runtime.d.ts.map
@@ -0,0 +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,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,S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