@proto-kit/module 0.1.1-develop.211 → 0.1.1-develop.2137
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 +67 -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 +75 -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 +9 -9
- package/src/factories/MethodIdFactory.ts +10 -17
- package/src/index.ts +4 -4
- package/src/messages/OutgoingMessages.ts +124 -0
- package/src/method/MethodParameterEncoder.ts +262 -0
- package/src/method/runtimeMethod.ts +131 -33
- package/src/runtime/MethodIdResolver.ts +85 -46
- package/src/runtime/Runtime.ts +187 -96
- package/src/runtime/RuntimeEnvironment.ts +16 -0
- package/src/runtime/RuntimeModule.ts +58 -27
- package/src/state/InMemoryStateService.ts +14 -14
- 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 +88 -79
- package/test/modules/Balances.ts +15 -21
- package/test/modules/{methodId.test.ts → MethodIdResolver.test.ts} +24 -35
- package/test/modules/State.test.ts +46 -53
- 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/module/src/factories/MethodIdFactory.d.ts +0 -9
- package/dist/module/src/factories/MethodIdFactory.d.ts.map +0 -1
- package/dist/module/src/factories/MethodIdFactory.js +0 -36
- package/dist/module/src/index.d.ts +0 -11
- package/dist/module/src/index.d.ts.map +0 -1
- package/dist/module/src/index.js +0 -10
- package/dist/module/src/method/MethodParameterDecoder.d.ts +0 -22
- package/dist/module/src/method/MethodParameterDecoder.d.ts.map +0 -1
- package/dist/module/src/method/MethodParameterDecoder.js +0 -33
- package/dist/module/src/method/runtimeMethod.d.ts +0 -19
- package/dist/module/src/method/runtimeMethod.d.ts.map +0 -1
- package/dist/module/src/method/runtimeMethod.js +0 -123
- package/dist/module/src/module/decorator.d.ts +0 -8
- package/dist/module/src/module/decorator.d.ts.map +0 -1
- package/dist/module/src/module/decorator.js +0 -15
- package/dist/module/src/runtime/MethodIdResolver.d.ts +0 -18
- package/dist/module/src/runtime/MethodIdResolver.d.ts.map +0 -1
- package/dist/module/src/runtime/MethodIdResolver.js +0 -50
- package/dist/module/src/runtime/Runtime.d.ts +0 -72
- package/dist/module/src/runtime/Runtime.d.ts.map +0 -1
- package/dist/module/src/runtime/Runtime.js +0 -184
- package/dist/module/src/runtime/RuntimeModule.d.ts +0 -35
- package/dist/module/src/runtime/RuntimeModule.d.ts.map +0 -1
- package/dist/module/src/runtime/RuntimeModule.js +0 -56
- package/dist/module/src/state/InMemoryStateService.d.ts +0 -11
- package/dist/module/src/state/InMemoryStateService.d.ts.map +0 -1
- package/dist/module/src/state/InMemoryStateService.js +0 -21
- package/dist/module/src/state/decorator.d.ts +0 -7
- package/dist/module/src/state/decorator.d.ts.map +0 -1
- package/dist/module/src/state/decorator.js +0 -42
- package/dist/protocol/src/model/Option.d.ts +0 -98
- package/dist/protocol/src/model/Option.d.ts.map +0 -1
- package/dist/protocol/src/model/Option.js +0 -98
- package/dist/protocol/src/model/StateTransition.d.ts +0 -96
- package/dist/protocol/src/model/StateTransition.d.ts.map +0 -1
- package/dist/protocol/src/model/StateTransition.js +0 -65
- package/dist/protocol/src/model/network/NetworkState.d.ts +0 -64
- package/dist/protocol/src/model/network/NetworkState.d.ts.map +0 -1
- package/dist/protocol/src/model/network/NetworkState.js +0 -12
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts +0 -70
- package/dist/protocol/src/model/transaction/ProtocolTransaction.d.ts.map +0 -1
- package/dist/protocol/src/model/transaction/ProtocolTransaction.js +0 -18
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts +0 -63
- package/dist/protocol/src/model/transaction/RuntimeTransaction.d.ts.map +0 -1
- package/dist/protocol/src/model/transaction/RuntimeTransaction.js +0 -29
- package/dist/protocol/src/state/assert/assert.d.ts +0 -12
- package/dist/protocol/src/state/assert/assert.d.ts.map +0 -1
- package/dist/protocol/src/state/assert/assert.js +0 -23
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts +0 -60
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.d.ts.map +0 -1
- package/dist/protocol/src/state/context/RuntimeMethodExecutionContext.js +0 -105
- package/dist/state/State.d.ts +0 -65
- package/dist/state/State.d.ts.map +0 -1
- package/dist/state/State.js +0 -114
- package/dist/state/StateMap.d.ts +0 -37
- package/dist/state/StateMap.d.ts.map +0 -1
- package/dist/state/StateMap.js +0 -56
- package/dist/state/StateServiceProvider.d.ts +0 -10
- package/dist/state/StateServiceProvider.d.ts.map +0 -1
- package/dist/state/StateServiceProvider.js +0 -34
- package/src/method/MethodParameterDecoder.ts +0 -70
- package/src/state/decorator.ts +0 -63
- 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
|
@@ -1,184 +0,0 @@
|
|
|
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 Runtime_1;
|
|
11
|
-
// eslint-disable-next-line max-len
|
|
12
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,max-lines */
|
|
13
|
-
import { Experimental } from "snarkyjs";
|
|
14
|
-
import { injectable } from "tsyringe";
|
|
15
|
-
import { ModuleContainer, ZkProgrammable, } from "@proto-kit/common";
|
|
16
|
-
import { MethodPublicOutput, StateServiceProvider, } from "@proto-kit/protocol";
|
|
17
|
-
import { combineMethodName, isRuntimeMethod, toWrappedMethod, } from "../method/runtimeMethod";
|
|
18
|
-
import { MethodIdFactory } from "../factories/MethodIdFactory";
|
|
19
|
-
const errors = {
|
|
20
|
-
methodNotFound: (methodKey) => new Error(`Unable to find method with id ${methodKey}`),
|
|
21
|
-
};
|
|
22
|
-
export class RuntimeZkProgrammable extends ZkProgrammable {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
24
|
-
constructor(runtime) {
|
|
25
|
-
super();
|
|
26
|
-
this.runtime = runtime;
|
|
27
|
-
}
|
|
28
|
-
get appChain() {
|
|
29
|
-
return this.runtime.appChain;
|
|
30
|
-
}
|
|
31
|
-
zkProgramFactory() {
|
|
32
|
-
// We need to use explicit type annotations here,
|
|
33
|
-
// therefore we can't use destructuring
|
|
34
|
-
// eslint-disable-next-line max-len
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define,prefer-destructuring,putout/putout
|
|
36
|
-
const runtime = this.runtime;
|
|
37
|
-
const runtimeMethods = runtime.runtimeModuleNames.reduce((allMethods, runtimeModuleName) => {
|
|
38
|
-
runtime.isValidModuleName(runtime.definition.modules, runtimeModuleName);
|
|
39
|
-
/**
|
|
40
|
-
* Couldnt find a better way to circumvent the type assertion
|
|
41
|
-
* regarding resolving only known modules. We assert in the line above
|
|
42
|
-
* but we cast it to any anyways to satisfy the proof system.
|
|
43
|
-
*/
|
|
44
|
-
// eslint-disable-next-line max-len
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
46
|
-
const runtimeModule = runtime.resolve(runtimeModuleName);
|
|
47
|
-
// eslint-disable-next-line max-len
|
|
48
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
49
|
-
const modulePrototype = Object.getPrototypeOf(runtimeModule);
|
|
50
|
-
const modulePrototypeMethods = Object.getOwnPropertyNames(modulePrototype);
|
|
51
|
-
const moduleMethods = modulePrototypeMethods.reduce((allModuleMethods, methodName) => {
|
|
52
|
-
if (isRuntimeMethod(runtimeModule, methodName)) {
|
|
53
|
-
const combinedMethodName = combineMethodName(runtimeModuleName, methodName);
|
|
54
|
-
const method = modulePrototype[methodName];
|
|
55
|
-
const wrappedMethod = Reflect.apply(toWrappedMethod, runtimeModule, [methodName, method]);
|
|
56
|
-
// eslint-disable-next-line no-warning-comments
|
|
57
|
-
// TODO: find out how to import the Tuple type
|
|
58
|
-
const privateInputs = Reflect.getMetadata("design:paramtypes", runtimeModule, methodName);
|
|
59
|
-
return {
|
|
60
|
-
...allModuleMethods,
|
|
61
|
-
[combinedMethodName]: {
|
|
62
|
-
privateInputs,
|
|
63
|
-
method: wrappedMethod,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
return allModuleMethods;
|
|
68
|
-
}, {});
|
|
69
|
-
return {
|
|
70
|
-
...allMethods,
|
|
71
|
-
...moduleMethods,
|
|
72
|
-
};
|
|
73
|
-
}, {});
|
|
74
|
-
const sortedRuntimeMethods = Object.fromEntries(
|
|
75
|
-
// eslint-disable-next-line @typescript-eslint/require-array-sort-compare
|
|
76
|
-
Object.entries(runtimeMethods).sort());
|
|
77
|
-
const program = Experimental.ZkProgram({
|
|
78
|
-
publicOutput: MethodPublicOutput,
|
|
79
|
-
methods: sortedRuntimeMethods,
|
|
80
|
-
});
|
|
81
|
-
const SelfProof = Experimental.ZkProgram.Proof(program);
|
|
82
|
-
const methods = Object.keys(sortedRuntimeMethods).reduce((boundMethods, methodName) => {
|
|
83
|
-
boundMethods[methodName] = program[methodName].bind(program);
|
|
84
|
-
return boundMethods;
|
|
85
|
-
}, {});
|
|
86
|
-
return {
|
|
87
|
-
compile: program.compile.bind(program),
|
|
88
|
-
verify: program.verify.bind(program),
|
|
89
|
-
Proof: SelfProof,
|
|
90
|
-
methods,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Wrapper for an application specific runtime, which helps orchestrate
|
|
96
|
-
* runtime modules into an interoperable runtime.
|
|
97
|
-
*/
|
|
98
|
-
let Runtime = Runtime_1 = class Runtime extends ModuleContainer {
|
|
99
|
-
static from(definition) {
|
|
100
|
-
return new Runtime_1(definition);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new Runtime from the provided config
|
|
104
|
-
*
|
|
105
|
-
* @param modules - Configuration object for the constructed Runtime
|
|
106
|
-
*/
|
|
107
|
-
constructor(definition) {
|
|
108
|
-
super(definition);
|
|
109
|
-
this.stateServiceProviderInstance = new StateServiceProvider(
|
|
110
|
-
// eslint-disable-next-line etc/no-deprecated
|
|
111
|
-
this.definition.state);
|
|
112
|
-
this.definition = definition;
|
|
113
|
-
this.zkProgrammable = new RuntimeZkProgrammable(this);
|
|
114
|
-
}
|
|
115
|
-
// eslint-disable-next-line no-warning-comments
|
|
116
|
-
// TODO Remove after changing DFs to type-based approach
|
|
117
|
-
start() {
|
|
118
|
-
this.registerValue({
|
|
119
|
-
Runtime: this,
|
|
120
|
-
});
|
|
121
|
-
this.registerDependencyFactories([MethodIdFactory]);
|
|
122
|
-
}
|
|
123
|
-
get appChain() {
|
|
124
|
-
return this.container.resolve("AppChain");
|
|
125
|
-
}
|
|
126
|
-
get stateService() {
|
|
127
|
-
return this.stateServiceProviderInstance.stateService;
|
|
128
|
-
}
|
|
129
|
-
get stateServiceProvider() {
|
|
130
|
-
return this.stateServiceProviderInstance;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* @returns The dependency injection container of this runtime
|
|
134
|
-
*/
|
|
135
|
-
get dependencyContainer() {
|
|
136
|
-
return this.container;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* @param methodId The encoded name of the method to call.
|
|
140
|
-
* Encoding: "stringToField(module.name) << 128 + stringToField(method-name)"
|
|
141
|
-
*/
|
|
142
|
-
getMethodById(methodId) {
|
|
143
|
-
const methodDescriptor = this.container
|
|
144
|
-
.resolve("MethodIdResolver")
|
|
145
|
-
.getMethodNameFromId(methodId);
|
|
146
|
-
if (methodDescriptor === undefined) {
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
const [moduleName, methodName] = methodDescriptor;
|
|
150
|
-
this.isValidModuleName(this.definition.modules, moduleName);
|
|
151
|
-
const module = this.resolve(moduleName);
|
|
152
|
-
// eslint-disable-next-line max-len
|
|
153
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions,@typescript-eslint/no-unsafe-member-access
|
|
154
|
-
const method = module[methodName];
|
|
155
|
-
if (method === undefined) {
|
|
156
|
-
throw errors.methodNotFound(`${moduleName}.${methodName}`);
|
|
157
|
-
}
|
|
158
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
159
|
-
return method.bind(module);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Add a name and other respective properties required by RuntimeModules,
|
|
163
|
-
* that come from the current Runtime
|
|
164
|
-
*
|
|
165
|
-
* @param moduleName - Name of the runtime module to decorate
|
|
166
|
-
* @param containedModule
|
|
167
|
-
*/
|
|
168
|
-
decorateModule(moduleName, containedModule) {
|
|
169
|
-
containedModule.name = moduleName;
|
|
170
|
-
containedModule.runtime = this;
|
|
171
|
-
super.decorateModule(moduleName, containedModule);
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @returns A list of names of all the registered module names
|
|
175
|
-
*/
|
|
176
|
-
get runtimeModuleNames() {
|
|
177
|
-
return Object.keys(this.definition.modules);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
Runtime = Runtime_1 = __decorate([
|
|
181
|
-
injectable(),
|
|
182
|
-
__metadata("design:paramtypes", [Object])
|
|
183
|
-
], Runtime);
|
|
184
|
-
export { Runtime };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ConfigurableModule, Presets } from "@proto-kit/common";
|
|
2
|
-
import { NetworkState, RuntimeTransaction, StateService } from "@proto-kit/protocol";
|
|
3
|
-
import type { Runtime, RuntimeDefinition, RuntimeModulesRecord } from "./Runtime";
|
|
4
|
-
/**
|
|
5
|
-
* This type exists to carry over certain runtime properties
|
|
6
|
-
* to runtime modules, until we can inject them through DI.
|
|
7
|
-
*/
|
|
8
|
-
export interface PartialRuntime extends Pick<Runtime<RuntimeModulesRecord>, "zkProgrammable"> {
|
|
9
|
-
definition: Pick<RuntimeDefinition<RuntimeModulesRecord>, "state">;
|
|
10
|
-
get stateService(): StateService;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Base class for runtime modules providing the necessary utilities.
|
|
14
|
-
*/
|
|
15
|
-
export declare class RuntimeModule<Config> extends ConfigurableModule<Config> {
|
|
16
|
-
static presets: Presets<unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Holds all method names that are callable throw transactions
|
|
19
|
-
*/
|
|
20
|
-
readonly runtimeMethodNames: string[];
|
|
21
|
-
/**
|
|
22
|
-
* This property exists only to typecheck that the RuntimeModule
|
|
23
|
-
* was extended correctly in e.g. a decorator. We need at least
|
|
24
|
-
* one non-optional property in this class to make the typechecking work.
|
|
25
|
-
*/
|
|
26
|
-
isRuntimeModule: boolean;
|
|
27
|
-
name?: string;
|
|
28
|
-
test?: number;
|
|
29
|
-
runtime?: Runtime<RuntimeModulesRecord>;
|
|
30
|
-
constructor();
|
|
31
|
-
private getInputs;
|
|
32
|
-
get transaction(): RuntimeTransaction;
|
|
33
|
-
get network(): NetworkState;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=RuntimeModule.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeModule.d.ts","sourceRoot":"","sources":["../../../../src/runtime/RuntimeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EACV,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,WAAW,CAAC;AAMnB;;;GAGG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,gBAAgB,CAAC;IAC7D,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC;IAEnE,IAAI,YAAY,IAAI,YAAY,CAAC;CAClC;AAED;;GAEG;AACH,qBACa,aAAa,CAAC,MAAM,CAAE,SAAQ,kBAAkB,CAAC,MAAM,CAAC;IACnE,OAAc,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAM;IAE7C;;OAEG;IACH,SAAgB,kBAAkB,EAAE,MAAM,EAAE,CAAM;IAElD;;;;OAIG;IACI,eAAe,UAAQ;IAEvB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,OAAO,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;;IAY/C,OAAO,CAAC,SAAS;IAWjB,IAAW,WAAW,IAAI,kBAAkB,CAE3C;IAED,IAAW,OAAO,IAAI,YAAY,CAEjC;CACF"}
|
|
@@ -1,56 +0,0 @@
|
|
|
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
|
-
import { ConfigurableModule } from "@proto-kit/common";
|
|
11
|
-
import { container, injectable } from "tsyringe";
|
|
12
|
-
import { RuntimeMethodExecutionContext, } from "@proto-kit/protocol";
|
|
13
|
-
import { runtimeMethodNamesMetadataKey } from "../method/runtimeMethod";
|
|
14
|
-
const errors = {
|
|
15
|
-
inputDataNotSet: () => new Error("Input data for runtime execution not set"),
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Base class for runtime modules providing the necessary utilities.
|
|
19
|
-
*/
|
|
20
|
-
let RuntimeModule = class RuntimeModule extends ConfigurableModule {
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
/**
|
|
24
|
-
* Holds all method names that are callable throw transactions
|
|
25
|
-
*/
|
|
26
|
-
this.runtimeMethodNames = [];
|
|
27
|
-
/**
|
|
28
|
-
* This property exists only to typecheck that the RuntimeModule
|
|
29
|
-
* was extended correctly in e.g. a decorator. We need at least
|
|
30
|
-
* one non-optional property in this class to make the typechecking work.
|
|
31
|
-
*/
|
|
32
|
-
this.isRuntimeModule = true;
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
34
|
-
const methodNames = Reflect.getMetadata(runtimeMethodNamesMetadataKey, this);
|
|
35
|
-
this.runtimeMethodNames = methodNames ?? [];
|
|
36
|
-
}
|
|
37
|
-
getInputs() {
|
|
38
|
-
const { input } = container.resolve(RuntimeMethodExecutionContext);
|
|
39
|
-
if (input === undefined) {
|
|
40
|
-
throw errors.inputDataNotSet();
|
|
41
|
-
}
|
|
42
|
-
return input;
|
|
43
|
-
}
|
|
44
|
-
get transaction() {
|
|
45
|
-
return this.getInputs().transaction;
|
|
46
|
-
}
|
|
47
|
-
get network() {
|
|
48
|
-
return this.getInputs().networkState;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
RuntimeModule.presets = {};
|
|
52
|
-
RuntimeModule = __decorate([
|
|
53
|
-
injectable(),
|
|
54
|
-
__metadata("design:paramtypes", [])
|
|
55
|
-
], RuntimeModule);
|
|
56
|
-
export { RuntimeModule };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Field } from "snarkyjs";
|
|
2
|
-
import { StateService } from "@proto-kit/protocol";
|
|
3
|
-
/**
|
|
4
|
-
* Naive implementation of a StateService for testing purposes
|
|
5
|
-
*/
|
|
6
|
-
export declare class InMemoryStateService implements StateService {
|
|
7
|
-
values: Record<string, Field[] | undefined>;
|
|
8
|
-
get(key: Field): Field[] | undefined;
|
|
9
|
-
set(key: Field, value: Field[] | undefined): void;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=InMemoryStateService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryStateService.d.ts","sourceRoot":"","sources":["../../../../src/state/InMemoryStateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;GAEG;AACH,qBAAa,oBAAqB,YAAW,YAAY;IAChD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC,CAAM;IAEjD,GAAG,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,EAAE,GAAG,SAAS;IAIpC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS;CAWlD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Naive implementation of a StateService for testing purposes
|
|
3
|
-
*/
|
|
4
|
-
export class InMemoryStateService {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.values = {};
|
|
7
|
-
}
|
|
8
|
-
get(key) {
|
|
9
|
-
return this.values[key.toString()];
|
|
10
|
-
}
|
|
11
|
-
set(key, value) {
|
|
12
|
-
if (value === undefined &&
|
|
13
|
-
Object.prototype.hasOwnProperty.call(this.values, key.toString())) {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
15
|
-
delete this.values[key.toString()];
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
this.values[key.toString()] = value;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { RuntimeModule } from "../runtime/RuntimeModule.js";
|
|
2
|
-
/**
|
|
3
|
-
* Decorates a runtime module property as state, passing down some
|
|
4
|
-
* underlying values to improve developer experience.
|
|
5
|
-
*/
|
|
6
|
-
export declare function state(): <TargetRuntimeModule extends RuntimeModule<unknown>>(target: TargetRuntimeModule, propertyKey: string) => void;
|
|
7
|
-
//# sourceMappingURL=decorator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../../../../src/state/decorator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAgBjE;;;GAGG;AACH,wBAAgB,KAAK,mGAGJ,MAAM,UAqCtB"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Path } from "@proto-kit/protocol";
|
|
2
|
-
const errors = {
|
|
3
|
-
missingName: (className) => new Error(`Unable to provide a unique identifier for state, ${className} is missing a name.
|
|
4
|
-
Did you forget to extend your runtime module with 'extends RuntimeModule'?`),
|
|
5
|
-
missingRuntime: (className) => new Error(`Unable to provide 'runtime' for state, ${className} is missing a name.
|
|
6
|
-
Did you forget to extend your runtime module with 'extends RuntimeModule'?`),
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Decorates a runtime module property as state, passing down some
|
|
10
|
-
* underlying values to improve developer experience.
|
|
11
|
-
*/
|
|
12
|
-
export function state() {
|
|
13
|
-
return (target, propertyKey) => {
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/init-declarations
|
|
15
|
-
let value;
|
|
16
|
-
Object.defineProperty(target, propertyKey, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function get() {
|
|
19
|
-
// eslint-disable-next-line max-len
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
21
|
-
const self = this;
|
|
22
|
-
if (self.name === undefined) {
|
|
23
|
-
throw errors.missingName(self.constructor.name);
|
|
24
|
-
}
|
|
25
|
-
if (!self.runtime) {
|
|
26
|
-
throw errors.missingRuntime(self.constructor.name);
|
|
27
|
-
}
|
|
28
|
-
const path = Path.fromProperty(self.name, propertyKey);
|
|
29
|
-
if (value) {
|
|
30
|
-
value.path = path;
|
|
31
|
-
// eslint-disable-next-line no-warning-comments
|
|
32
|
-
// TODO: why is this complaining about `any`?
|
|
33
|
-
value.stateServiceProvider = self.runtime.stateServiceProvider;
|
|
34
|
-
}
|
|
35
|
-
return value;
|
|
36
|
-
},
|
|
37
|
-
set: (newValue) => {
|
|
38
|
-
value = newValue;
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, type FlexibleProvablePure } from "snarkyjs";
|
|
2
|
-
declare const ProvableOption_base: (new (value: {
|
|
3
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
4
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
5
|
-
}) => {
|
|
6
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
7
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
8
|
-
}) & {
|
|
9
|
-
_isStruct: true;
|
|
10
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
11
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
12
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
13
|
-
}> & {
|
|
14
|
-
toInput: (x: {
|
|
15
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
16
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
17
|
-
}) => {
|
|
18
|
-
fields?: import("snarkyjs/dist/node/lib/field").Field[] | undefined;
|
|
19
|
-
packed?: [import("snarkyjs/dist/node/lib/field").Field, number][] | undefined;
|
|
20
|
-
};
|
|
21
|
-
toJSON: (x: {
|
|
22
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
23
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
24
|
-
}) => {
|
|
25
|
-
isSome: boolean;
|
|
26
|
-
value: string;
|
|
27
|
-
};
|
|
28
|
-
fromJSON: (x: {
|
|
29
|
-
isSome: boolean;
|
|
30
|
-
value: string;
|
|
31
|
-
}) => {
|
|
32
|
-
isSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
33
|
-
value: import("snarkyjs/dist/node/lib/field").Field;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export declare class ProvableOption extends ProvableOption_base {
|
|
37
|
-
toSome(): this;
|
|
38
|
-
}
|
|
39
|
-
export interface ToFieldable {
|
|
40
|
-
toFields: () => Field[];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Option facilitating in-circuit values that may or may not exist.
|
|
44
|
-
*/
|
|
45
|
-
export declare class Option<Value> {
|
|
46
|
-
isSome: Bool;
|
|
47
|
-
value: Value;
|
|
48
|
-
valueType: FlexibleProvablePure<Value>;
|
|
49
|
-
/**
|
|
50
|
-
* Creates a new Option from the provided parameters
|
|
51
|
-
*
|
|
52
|
-
* @param isSome
|
|
53
|
-
* @param value
|
|
54
|
-
* @param valueType
|
|
55
|
-
* @returns New option from the provided parameters.
|
|
56
|
-
*/
|
|
57
|
-
static from<Value>(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
|
|
58
|
-
/**
|
|
59
|
-
* Creates a new Option from the provided parameters
|
|
60
|
-
*
|
|
61
|
-
* @param value
|
|
62
|
-
* @param valueType
|
|
63
|
-
* @returns New option from the provided parameters.
|
|
64
|
-
*/
|
|
65
|
-
static fromValue<Value>(value: Value, valueType: FlexibleProvablePure<Value>): Option<Value>;
|
|
66
|
-
/**
|
|
67
|
-
* @returns Empty / none option
|
|
68
|
-
*/
|
|
69
|
-
static none(): Option<import("snarkyjs/dist/node/lib/field").Field>;
|
|
70
|
-
isForcedSome: import("snarkyjs/dist/node/lib/bool").Bool;
|
|
71
|
-
constructor(isSome: Bool, value: Value, valueType: FlexibleProvablePure<Value>);
|
|
72
|
-
clone(): Option<Value>;
|
|
73
|
-
forceSome(): void;
|
|
74
|
-
/**
|
|
75
|
-
* @returns Tree representation of the current value
|
|
76
|
-
*/
|
|
77
|
-
get treeValue(): import("snarkyjs/dist/node/lib/field").Field;
|
|
78
|
-
/**
|
|
79
|
-
* Returns the `to`-value as decoded as a list of fields
|
|
80
|
-
* Not in circuit
|
|
81
|
-
*/
|
|
82
|
-
toFields(): Field[];
|
|
83
|
-
/**
|
|
84
|
-
* @returns Provable representation of the current option.
|
|
85
|
-
*/
|
|
86
|
-
toProvable(): ProvableOption;
|
|
87
|
-
/**
|
|
88
|
-
* @returns Returns the value of this option if it isSome,
|
|
89
|
-
* otherwise returns the given defaultValue
|
|
90
|
-
*/
|
|
91
|
-
orElse(defaultValue: Value): Value;
|
|
92
|
-
toJSON(): {
|
|
93
|
-
isSome: boolean;
|
|
94
|
-
value: string;
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
export {};
|
|
98
|
-
//# sourceMappingURL=Option.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Option.d.ts","sourceRoot":"","sources":["../../../../../protocol/src/model/Option.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EAEL,KAAK,oBAAoB,EAI1B,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElB,qBAAa,cAAe,SAAQ,mBAGlC;IACO,MAAM;CAId;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,KAAK,EAAE,CAAC;CACzB;AAED;;GAEG;AACH,qBAAa,MAAM,CAAC,KAAK;IAyCd,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IA1C/C;;;;;;;OAOG;WACW,IAAI,CAAC,KAAK,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAKxC;;;;;;OAMG;WACW,SAAS,CAAC,KAAK,EAC3B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAKxC;;OAEG;WACW,IAAI;IAIX,YAAY,6CAAe;gBAGzB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAGxC,KAAK;IAIL,SAAS;IAKhB;;OAEG;IACH,IAAW,SAAS,iDAQnB;IAED;;;OAGG;IACI,QAAQ,IAAI,KAAK,EAAE;IAO1B;;OAEG;IACI,UAAU;IAOjB;;;OAGG;IACI,MAAM,CAAC,YAAY,EAAE,KAAK,GAAG,KAAK;IASlC,MAAM;;;;CAYd"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, Poseidon, Provable, Struct, } from "snarkyjs";
|
|
2
|
-
export class ProvableOption extends Struct({
|
|
3
|
-
isSome: Bool,
|
|
4
|
-
value: Field,
|
|
5
|
-
}) {
|
|
6
|
-
toSome() {
|
|
7
|
-
this.isSome = Bool(true);
|
|
8
|
-
return this;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Option facilitating in-circuit values that may or may not exist.
|
|
13
|
-
*/
|
|
14
|
-
export class Option {
|
|
15
|
-
/**
|
|
16
|
-
* Creates a new Option from the provided parameters
|
|
17
|
-
*
|
|
18
|
-
* @param isSome
|
|
19
|
-
* @param value
|
|
20
|
-
* @param valueType
|
|
21
|
-
* @returns New option from the provided parameters.
|
|
22
|
-
*/
|
|
23
|
-
static from(isSome, value, valueType) {
|
|
24
|
-
return new Option(isSome, value, valueType);
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Creates a new Option from the provided parameters
|
|
28
|
-
*
|
|
29
|
-
* @param value
|
|
30
|
-
* @param valueType
|
|
31
|
-
* @returns New option from the provided parameters.
|
|
32
|
-
*/
|
|
33
|
-
static fromValue(value, valueType) {
|
|
34
|
-
return this.from(Bool(true), value, valueType);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* @returns Empty / none option
|
|
38
|
-
*/
|
|
39
|
-
static none() {
|
|
40
|
-
return new Option(Bool(false), Field(0), Field);
|
|
41
|
-
}
|
|
42
|
-
constructor(isSome, value, valueType) {
|
|
43
|
-
this.isSome = isSome;
|
|
44
|
-
this.value = value;
|
|
45
|
-
this.valueType = valueType;
|
|
46
|
-
this.isForcedSome = Bool(false);
|
|
47
|
-
}
|
|
48
|
-
clone() {
|
|
49
|
-
return new Option(this.isSome, this.value, this.valueType);
|
|
50
|
-
}
|
|
51
|
-
forceSome() {
|
|
52
|
-
this.isForcedSome = Provable.if(this.isSome, Bool(false), Bool(true));
|
|
53
|
-
this.isSome = Bool(true);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @returns Tree representation of the current value
|
|
57
|
-
*/
|
|
58
|
-
get treeValue() {
|
|
59
|
-
const treeValue = Poseidon.hash(this.valueType.toFields(this.value));
|
|
60
|
-
return Provable.if(this.isSome.and(this.isForcedSome.not()), treeValue, Field(0));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Returns the `to`-value as decoded as a list of fields
|
|
64
|
-
* Not in circuit
|
|
65
|
-
*/
|
|
66
|
-
toFields() {
|
|
67
|
-
if (this.isSome.toBoolean()) {
|
|
68
|
-
return this.valueType.toFields(this.value);
|
|
69
|
-
}
|
|
70
|
-
return [Field(0)];
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* @returns Provable representation of the current option.
|
|
74
|
-
*/
|
|
75
|
-
toProvable() {
|
|
76
|
-
return new ProvableOption({
|
|
77
|
-
isSome: this.isSome,
|
|
78
|
-
value: this.treeValue,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @returns Returns the value of this option if it isSome,
|
|
83
|
-
* otherwise returns the given defaultValue
|
|
84
|
-
*/
|
|
85
|
-
orElse(defaultValue) {
|
|
86
|
-
return Provable.if(this.isSome, this.valueType, this.value, defaultValue);
|
|
87
|
-
}
|
|
88
|
-
toJSON() {
|
|
89
|
-
const valueContent = this.valueType
|
|
90
|
-
.toFields(this.value)
|
|
91
|
-
.map((field) => field.toString())
|
|
92
|
-
.reduce((a, b) => `${a}, ${b}`);
|
|
93
|
-
return {
|
|
94
|
-
isSome: this.isSome.toBoolean(),
|
|
95
|
-
value: `[${valueContent}]`,
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { Field } from "snarkyjs";
|
|
2
|
-
import { Option, ProvableOption } from "./Option.js";
|
|
3
|
-
declare const ProvableStateTransition_base: (new (value: {
|
|
4
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
5
|
-
from: ProvableOption;
|
|
6
|
-
to: ProvableOption;
|
|
7
|
-
}) => {
|
|
8
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
9
|
-
from: ProvableOption;
|
|
10
|
-
to: ProvableOption;
|
|
11
|
-
}) & {
|
|
12
|
-
_isStruct: true;
|
|
13
|
-
} & import("snarkyjs/dist/node/snarky.js").ProvablePure<{
|
|
14
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
15
|
-
from: ProvableOption;
|
|
16
|
-
to: ProvableOption;
|
|
17
|
-
}> & {
|
|
18
|
-
toInput: (x: {
|
|
19
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
20
|
-
from: ProvableOption;
|
|
21
|
-
to: ProvableOption;
|
|
22
|
-
}) => {
|
|
23
|
-
fields?: import("snarkyjs/dist/node/lib/field.js").Field[] | undefined;
|
|
24
|
-
packed?: [import("snarkyjs/dist/node/lib/field.js").Field, number][] | undefined;
|
|
25
|
-
};
|
|
26
|
-
toJSON: (x: {
|
|
27
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
28
|
-
from: ProvableOption;
|
|
29
|
-
to: ProvableOption;
|
|
30
|
-
}) => {
|
|
31
|
-
path: string;
|
|
32
|
-
from: {
|
|
33
|
-
isSome: boolean;
|
|
34
|
-
value: string;
|
|
35
|
-
};
|
|
36
|
-
to: {
|
|
37
|
-
isSome: boolean;
|
|
38
|
-
value: string;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
fromJSON: (x: {
|
|
42
|
-
path: string;
|
|
43
|
-
from: {
|
|
44
|
-
isSome: boolean;
|
|
45
|
-
value: string;
|
|
46
|
-
};
|
|
47
|
-
to: {
|
|
48
|
-
isSome: boolean;
|
|
49
|
-
value: string;
|
|
50
|
-
};
|
|
51
|
-
}) => {
|
|
52
|
-
path: import("snarkyjs/dist/node/lib/field.js").Field;
|
|
53
|
-
from: ProvableOption;
|
|
54
|
-
to: ProvableOption;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Provable representation of a State Transition, used to
|
|
59
|
-
* normalize state transitions of various value types for
|
|
60
|
-
* the state transition circuit.
|
|
61
|
-
*/
|
|
62
|
-
export declare class ProvableStateTransition extends ProvableStateTransition_base {
|
|
63
|
-
static dummy(): ProvableStateTransition;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Generic state transition that constraints the current method circuit
|
|
67
|
-
* to external state, by providing a state anchor.
|
|
68
|
-
*/
|
|
69
|
-
export declare class StateTransition<Value> {
|
|
70
|
-
path: Field;
|
|
71
|
-
fromValue: Option<Field> | Option<Value>;
|
|
72
|
-
toValue: Option<Field> | Option<Value>;
|
|
73
|
-
static from<Value>(path: Field, fromValue: Option<Value>): StateTransition<Value>;
|
|
74
|
-
static fromTo<Value>(path: Field, fromValue: Option<Value>, toValue: Option<Value>): StateTransition<Value>;
|
|
75
|
-
constructor(path: Field, fromValue: Option<Field> | Option<Value>, toValue: Option<Field> | Option<Value>);
|
|
76
|
-
get from(): Option<import("snarkyjs/dist/node/lib/field.js").Field> | Option<Value>;
|
|
77
|
-
get to(): Option<import("snarkyjs/dist/node/lib/field.js").Field> | Option<Value>;
|
|
78
|
-
/**
|
|
79
|
-
* Converts a StateTransition to a ProvableStateTransition,
|
|
80
|
-
* while enforcing the 'from' property to be 'Some' in all cases.
|
|
81
|
-
*/
|
|
82
|
-
toProvable(): ProvableStateTransition;
|
|
83
|
-
toJSON(): {
|
|
84
|
-
path: string;
|
|
85
|
-
from: {
|
|
86
|
-
isSome: boolean;
|
|
87
|
-
value: string;
|
|
88
|
-
};
|
|
89
|
-
to: {
|
|
90
|
-
isSome: boolean;
|
|
91
|
-
value: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
export {};
|
|
96
|
-
//# sourceMappingURL=StateTransition.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransition.d.ts","sourceRoot":"","sources":["../../../../../protocol/src/model/StateTransition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAe,MAAM,aAAa,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAElE;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,4BAQ3C;WACc,KAAK,IAAI,uBAAuB;CAO/C;AAED;;;GAGG;AACH,qBAAa,eAAe,CAAC,KAAK;IAcvB,IAAI,EAAE,KAAK;IACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IACxC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;WAfjC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC;WAIjD,MAAM,CAAC,KAAK,EACxB,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EACxB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;gBAMf,IAAI,EAAE,KAAK,EACX,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,EACxC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;IAG/C,IAAW,IAAI,4EAId;IAED,IAAW,EAAE,4EAEZ;IAED;;;OAGG;IACI,UAAU,IAAI,uBAAuB;IAQrC,MAAM;;;;;;;;;;;CAOd"}
|