@proto-kit/protocol 0.1.1-develop.165 → 0.1.1-develop.186
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/model/MethodPublicOutput.d.ts +6 -7
- package/dist/model/MethodPublicOutput.d.ts.map +1 -1
- package/dist/model/Option.d.ts +11 -7
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +10 -0
- package/dist/model/StateTransition.d.ts +11 -0
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +7 -0
- package/dist/model/StateTransitionProvableBatch.d.ts +4 -4
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -1
- package/dist/model/StateTransitionProvableBatch.js +6 -6
- package/dist/model/network/NetworkState.d.ts.map +1 -1
- package/dist/model/network/NetworkState.js +1 -3
- package/dist/model/transaction/RuntimeTransaction.d.ts +9 -1
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +5 -2
- package/dist/protocol/Protocol.d.ts +1 -1
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.d.ts +1 -1
- package/dist/protocol/ProtocolModule.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.js +3 -3
- package/dist/prover/block/BlockProvable.d.ts +1 -1
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.d.ts +2 -2
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +5 -4
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +1 -1
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionWitnessProvider.js +1 -1
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.d.ts.map +1 -1
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts.map +1 -1
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.js +3 -3
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +6 -6
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -1
- package/dist/utils/merkletree/RollupMerkleTree.js +4 -4
- package/dist/utils/{Utils.d.ts → utils.d.ts} +2 -5
- package/dist/utils/{Utils.d.ts.map → utils.d.ts.map} +1 -1
- package/dist/utils/utils.js +51 -0
- package/package.json +4 -4
- package/src/model/Option.ts +13 -0
- package/src/model/StateTransition.ts +8 -0
- package/src/model/StateTransitionProvableBatch.ts +8 -7
- package/src/model/network/NetworkState.ts +1 -3
- package/src/model/transaction/RuntimeTransaction.ts +5 -1
- package/src/protocol/Protocol.ts +1 -1
- package/src/protocol/ProtocolModule.ts +4 -5
- package/src/prover/block/BlockProvable.ts +2 -2
- package/src/prover/block/BlockProver.ts +6 -1
- package/src/prover/statetransition/StateTransitionProver.ts +6 -9
- package/src/prover/statetransition/StateTransitionWitnessProvider.ts +1 -1
- package/src/prover/statetransition/StateTransitionWitnessProviderReference.ts +2 -2
- package/src/utils/merkletree/InMemoryMerkleTreeStorage.ts +4 -4
- package/src/utils/merkletree/MerkleTreeStore.ts +1 -1
- package/src/utils/merkletree/RollupMerkleTree.ts +9 -4
- package/src/utils/utils.ts +29 -45
- package/test/utils.test.ts +30 -0
- package/dist/config/ConfigurableModule.d.ts +0 -18
- package/dist/config/ConfigurableModule.d.ts.map +0 -1
- package/dist/config/ConfigurableModule.js +0 -20
- package/dist/config/ConfigurationAggregator.d.ts +0 -10
- package/dist/config/ConfigurationAggregator.d.ts.map +0 -1
- package/dist/config/ConfigurationAggregator.js +0 -35
- package/dist/config/ConfigurationReceiver.d.ts +0 -25
- package/dist/config/ConfigurationReceiver.d.ts.map +0 -1
- package/dist/config/ConfigurationReceiver.js +0 -36
- package/dist/config/ModuleContainer.d.ts +0 -44
- package/dist/config/ModuleContainer.d.ts.map +0 -1
- package/dist/config/ModuleContainer.js +0 -89
- package/dist/config/types.d.ts +0 -2
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -1
- package/dist/model/MethodPublicInput.d.ts +0 -51
- package/dist/model/MethodPublicInput.d.ts.map +0 -1
- package/dist/model/MethodPublicInput.js +0 -11
- package/dist/prover/block/BlockScopedModule.d.ts +0 -3
- package/dist/prover/block/BlockScopedModule.d.ts.map +0 -1
- package/dist/prover/block/BlockScopedModule.js +0 -6
- package/dist/src/model/Option.d.ts +0 -158
- package/dist/src/model/Option.d.ts.map +0 -1
- package/dist/src/model/Option.js +0 -53
- package/dist/src/model/Path.d.ts +0 -35
- package/dist/src/model/Path.d.ts.map +0 -1
- package/dist/src/model/Path.js +0 -51
- package/dist/src/model/StateTransition.d.ts +0 -201
- package/dist/src/model/StateTransition.d.ts.map +0 -1
- package/dist/src/model/StateTransition.js +0 -43
- package/dist/src/utils/PrefixedHashList.d.ts +0 -15
- package/dist/src/utils/PrefixedHashList.d.ts.map +0 -1
- package/dist/src/utils/PrefixedHashList.js +0 -28
- package/dist/src/utils/ProvableHashList.d.ts +0 -30
- package/dist/src/utils/ProvableHashList.d.ts.map +0 -1
- package/dist/src/utils/ProvableHashList.js +0 -43
- package/dist/utils/PrefixedHashList.d.ts +0 -14
- package/dist/utils/PrefixedHashList.d.ts.map +0 -1
- package/dist/utils/PrefixedHashList.js +0 -12
- package/dist/utils/Utils.js +0 -64
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts +0 -26
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts.map +0 -1
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.js +0 -79
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationAggregator.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationAggregator.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,eAAe,EACf,UAAU,EACV,mBAAmB,EACnB,4BAA4B,EAC7B,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,8BAAsB,uBAAuB,CAAC,KAAK,SAAS,UAAU;IACpE,SAAS,CAAC,WAAW,CACnB,OAAO,EAAE,KAAK,EACd,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,EACnE,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,eAAe,CAAC,KAAK,CAAC;aAgCT,SAAS,CACvB,MAAM,EAAE,mBAAmB,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,GAClD,IAAI;CACR"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,guard-for-in,@typescript-eslint/no-unsafe-member-access,max-len,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/consistent-type-assertions */
|
|
2
|
-
import merge from "lodash/merge";
|
|
3
|
-
/**
|
|
4
|
-
* In this context, a "Component" is just a way of generalizing Modules,
|
|
5
|
-
* because they don't have to be modules, they can be any configurable unit
|
|
6
|
-
*/
|
|
7
|
-
export class ConfigurationAggregator {
|
|
8
|
-
applyConfig(modules, currentConfig, config) {
|
|
9
|
-
const nextConfig = {};
|
|
10
|
-
for (const key in config) {
|
|
11
|
-
// Set config to module
|
|
12
|
-
if (currentConfig[key] === undefined) {
|
|
13
|
-
// Initialize config with merge between config and defaultConfig
|
|
14
|
-
// eslint-disable-next-line prefer-destructuring,putout/putout
|
|
15
|
-
const defaultConfig = modules[key].defaultConfig;
|
|
16
|
-
const newConfig = config[key];
|
|
17
|
-
for (const configKey in newConfig) {
|
|
18
|
-
defaultConfig[configKey] = newConfig[configKey];
|
|
19
|
-
}
|
|
20
|
-
// The result of that is always a valid Required<Config> since FlipOptional<Config> requires the exact opposite of Config
|
|
21
|
-
modules[key].config = defaultConfig;
|
|
22
|
-
nextConfig[key] = defaultConfig;
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// Append/overwrite to existing config
|
|
26
|
-
const newConfig = config[key];
|
|
27
|
-
const moduleConfig = currentConfig[key];
|
|
28
|
-
merge(moduleConfig, newConfig);
|
|
29
|
-
modules[key].config = moduleConfig;
|
|
30
|
-
nextConfig[key] = moduleConfig;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return nextConfig;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { FlipOptional } from "./types";
|
|
2
|
-
/**
|
|
3
|
-
* Configs:
|
|
4
|
-
*
|
|
5
|
-
* A property that accepts undefined, is an optional argument.
|
|
6
|
-
* That means that you will have to provide it via defaultConfig() and it will
|
|
7
|
-
* be non-undefined via this.config. This is used by devs to indicate
|
|
8
|
-
* configurability but not necessary explicit definition.
|
|
9
|
-
* I.e. when the default arguments will work most of the time
|
|
10
|
-
*
|
|
11
|
-
* If devs want a property that can be undefined, they should use null instead
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare abstract class ConfigurationReceiver<Config> {
|
|
15
|
-
private currentConfig?;
|
|
16
|
-
/**
|
|
17
|
-
* Retrieves the configured config object.
|
|
18
|
-
* This is only available in instance methods like start(), using this in
|
|
19
|
-
* the constructor will throw an Exception
|
|
20
|
-
*/
|
|
21
|
-
get config(): Required<Config>;
|
|
22
|
-
set config(config: Required<Config>);
|
|
23
|
-
abstract get defaultConfig(): FlipOptional<Config>;
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=ConfigurationReceiver.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigurationReceiver.d.ts","sourceRoot":"","sources":["../../src/config/ConfigurationReceiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAO5C;;;;;;;;;;;GAWG;AACH,8BAAsB,qBAAqB,CAAC,MAAM;IAChD,OAAO,CAAC,aAAa,CAAC,CAA+B;IAErD;;;;OAIG;IACH,IAAW,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,CAOpC;IAED,IAAW,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAEzC;IAED,aAAoB,aAAa,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;CAC3D"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const errors = {
|
|
2
|
-
configNotSet: (name) => new Error(`RuntimeModule (${name}) config has not been set!`),
|
|
3
|
-
};
|
|
4
|
-
/**
|
|
5
|
-
* Configs:
|
|
6
|
-
*
|
|
7
|
-
* A property that accepts undefined, is an optional argument.
|
|
8
|
-
* That means that you will have to provide it via defaultConfig() and it will
|
|
9
|
-
* be non-undefined via this.config. This is used by devs to indicate
|
|
10
|
-
* configurability but not necessary explicit definition.
|
|
11
|
-
* I.e. when the default arguments will work most of the time
|
|
12
|
-
*
|
|
13
|
-
* If devs want a property that can be undefined, they should use null instead
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
export class ConfigurationReceiver {
|
|
17
|
-
constructor() {
|
|
18
|
-
this.currentConfig = undefined;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves the configured config object.
|
|
22
|
-
* This is only available in instance methods like start(), using this in
|
|
23
|
-
* the constructor will throw an Exception
|
|
24
|
-
*/
|
|
25
|
-
get config() {
|
|
26
|
-
if (this.currentConfig === undefined) {
|
|
27
|
-
// eslint-disable-next-line no-warning-comments
|
|
28
|
-
// TODO Check properly, Config could also be void
|
|
29
|
-
throw errors.configNotSet(this.constructor.name);
|
|
30
|
-
}
|
|
31
|
-
return this.currentConfig;
|
|
32
|
-
}
|
|
33
|
-
set config(config) {
|
|
34
|
-
this.currentConfig = config;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { Frequency, InjectionToken } from "tsyringe";
|
|
2
|
-
import { TypedClassConstructor } from "../utils/utils";
|
|
3
|
-
import { Configurable, ConfigurableModule } from "./ConfigurableModule";
|
|
4
|
-
export declare const errors: {
|
|
5
|
-
configNotSet: (moduleName: string) => Error;
|
|
6
|
-
configNotSetInContainer: (moduleName: string) => Error;
|
|
7
|
-
onlyStringModuleNames: (moduleName: NonNullable<unknown>) => Error;
|
|
8
|
-
unableToDecorateModule: (moduleName: InjectionToken<unknown>) => Error;
|
|
9
|
-
nonModuleDependecy: (runtimeModuleName: string) => Error;
|
|
10
|
-
unknownDependency: (runtimeModuleName: string, name: string) => Error;
|
|
11
|
-
};
|
|
12
|
-
export type BaseModuleType = TypedClassConstructor<Configurable<unknown>>;
|
|
13
|
-
export interface ModulesRecord<ModuleType extends BaseModuleType = BaseModuleType> {
|
|
14
|
-
[name: string]: ModuleType;
|
|
15
|
-
}
|
|
16
|
-
export type ModulesConfig<Modules extends ModulesRecord> = {
|
|
17
|
-
[ConfigKey in keyof Modules]: InstanceType<Modules[ConfigKey]>["config"];
|
|
18
|
-
};
|
|
19
|
-
export declare abstract class ModuleContainer<Modules extends ModulesRecord, Config extends ModulesConfig<Modules>> {
|
|
20
|
-
definition: {
|
|
21
|
-
modules: Modules;
|
|
22
|
-
config?: Config;
|
|
23
|
-
};
|
|
24
|
-
static moduleDecorationFrequency: Frequency;
|
|
25
|
-
container: import("tsyringe").DependencyContainer;
|
|
26
|
-
constructor(definition: {
|
|
27
|
-
modules: Modules;
|
|
28
|
-
config?: Config;
|
|
29
|
-
});
|
|
30
|
-
get moduleNames(): string[];
|
|
31
|
-
validateModule<ModuleName extends keyof Modules>(moduleName: ModuleName | string, containedModule: ConfigurableModule<unknown>): void;
|
|
32
|
-
registerModules(modules: Modules): void;
|
|
33
|
-
registerValue<Value>(modules: Record<string, Value>): void;
|
|
34
|
-
configure(config: Config): void;
|
|
35
|
-
resolve<ModuleName extends keyof Modules>(moduleName: ModuleName): InstanceType<Modules[ModuleName]>;
|
|
36
|
-
moduleNameToString<ModuleName extends keyof Modules>(moduleName: ModuleName | string): string;
|
|
37
|
-
/**
|
|
38
|
-
* Override this in the child class to provide custom
|
|
39
|
-
* features or module checks
|
|
40
|
-
*/
|
|
41
|
-
decorateModule<ModuleName extends keyof Modules>(moduleName: ModuleName | string, containedModule: InstanceType<Modules[ModuleName]>): void;
|
|
42
|
-
onAfterModuleResolution<ModuleName extends keyof Modules>(moduleName: ModuleName | string): void;
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=ModuleContainer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleContainer.d.ts","sourceRoot":"","sources":["../../src/config/ModuleContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,cAAc,EAAa,MAAM,UAAU,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAExE,eAAO,MAAM,MAAM;+BACU,MAAM;0CAKK,MAAM;wCAKR,YAAY,OAAO,CAAC;yCAMnB,eAAe,OAAO,CAAC;4CAIpB,MAAM;2CAIP,MAAM,QAAQ,MAAM;CAM5D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1E,MAAM,WAAW,aAAa,CAC5B,UAAU,SAAS,cAAc,GAAG,cAAc;IAElD,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B;AAED,MAAM,MAAM,aAAa,CAAC,OAAO,SAAS,aAAa,IAAI;KACxD,SAAS,IAAI,MAAM,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;CACzE,CAAC;AAEF,8BAAsB,eAAe,CACnC,OAAO,SAAS,aAAa,EAC7B,MAAM,SAAS,aAAa,CAAC,OAAO,CAAC;IAO5B,UAAU,EAAE;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IARH,OAAc,yBAAyB,EAAE,SAAS,CAAU;IAErD,SAAS,yCAAoC;gBAG3C,UAAU,EAAE;QACjB,OAAO,EAAE,OAAO,CAAC;QACjB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAKH,IAAW,WAAW,aAErB;IAEM,cAAc,CAAC,UAAU,SAAS,MAAM,OAAO,EACpD,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,eAAe,EAAE,kBAAkB,CAAC,OAAO,CAAC,GAC3C,IAAI;IAsBA,eAAe,CAAC,OAAO,EAAE,OAAO;IAahC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;IAMnD,SAAS,CAAC,MAAM,EAAE,MAAM;IAIxB,OAAO,CAAC,UAAU,SAAS,MAAM,OAAO,EAC7C,UAAU,EAAE,UAAU,GACrB,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAI7B,kBAAkB,CAAC,UAAU,SAAS,MAAM,OAAO,EACxD,UAAU,EAAE,UAAU,GAAG,MAAM,GAC9B,MAAM;IAQT;;;OAGG;IACI,cAAc,CAAC,UAAU,SAAS,MAAM,OAAO,EACpD,UAAU,EAAE,UAAU,GAAG,MAAM,EAC/B,eAAe,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAa7C,uBAAuB,CAAC,UAAU,SAAS,MAAM,OAAO,EAC7D,UAAU,EAAE,UAAU,GAAG,MAAM;CAclC"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { container, Lifecycle } from "tsyringe";
|
|
2
|
-
export const errors = {
|
|
3
|
-
configNotSet: (moduleName) => new Error(`Trying to retrieve config of ${moduleName}, which was not yet set`),
|
|
4
|
-
configNotSetInContainer: (moduleName) => new Error(`Trying to set config of ${moduleName}, but it was not yet set in the module container`),
|
|
5
|
-
onlyStringModuleNames: (moduleName) => new Error(
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
7
|
-
`Only string module names, using ${typeof moduleName} instead: ${moduleName.toString()}`),
|
|
8
|
-
unableToDecorateModule: (moduleName) =>
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
10
|
-
new Error(`Unable to decorate module ${moduleName.toString()}`),
|
|
11
|
-
nonModuleDependecy: (runtimeModuleName) => new Error(`
|
|
12
|
-
Unable to register module: ${runtimeModuleName}, attempting to inject a non-module dependency`),
|
|
13
|
-
unknownDependency: (runtimeModuleName, name) => new Error(`Unable to register module: ${runtimeModuleName},
|
|
14
|
-
attempting to inject a dependency that is not registred
|
|
15
|
-
as a runtime module for this chain: ${name}`),
|
|
16
|
-
};
|
|
17
|
-
export class ModuleContainer {
|
|
18
|
-
constructor(definition) {
|
|
19
|
-
this.definition = definition;
|
|
20
|
-
this.container = container.createChildContainer();
|
|
21
|
-
this.registerModules(definition.modules);
|
|
22
|
-
}
|
|
23
|
-
get moduleNames() {
|
|
24
|
-
return Object.keys(this.definition.modules);
|
|
25
|
-
}
|
|
26
|
-
validateModule(moduleName, containedModule) {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
28
|
-
const dependencies = Reflect.getMetadata("design:paramtypes", containedModule);
|
|
29
|
-
dependencies?.forEach((dependency) => {
|
|
30
|
-
const name = typeof dependency === "string" ? dependency : dependency.name;
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
32
|
-
if (!name) {
|
|
33
|
-
throw errors.nonModuleDependecy(this.moduleNameToString(moduleName));
|
|
34
|
-
}
|
|
35
|
-
if (!this.moduleNames.includes(name)) {
|
|
36
|
-
throw errors.unknownDependency(this.moduleNameToString(moduleName), name);
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
registerModules(modules) {
|
|
41
|
-
for (const moduleName in modules) {
|
|
42
|
-
if (Object.prototype.hasOwnProperty.call(modules, moduleName)) {
|
|
43
|
-
this.container.register(moduleName, { useClass: modules[moduleName] }, { lifecycle: Lifecycle.ContainerScoped });
|
|
44
|
-
this.onAfterModuleResolution(moduleName);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
registerValue(modules) {
|
|
49
|
-
Object.entries(modules).forEach(([moduleName, useValue]) => {
|
|
50
|
-
this.container.register(moduleName, { useValue });
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
configure(config) {
|
|
54
|
-
this.definition.config = config;
|
|
55
|
-
}
|
|
56
|
-
resolve(moduleName) {
|
|
57
|
-
return this.container.resolve(this.moduleNameToString(moduleName));
|
|
58
|
-
}
|
|
59
|
-
moduleNameToString(moduleName) {
|
|
60
|
-
if (typeof moduleName !== "string") {
|
|
61
|
-
throw errors.onlyStringModuleNames(moduleName);
|
|
62
|
-
}
|
|
63
|
-
return moduleName;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Override this in the child class to provide custom
|
|
67
|
-
* features or module checks
|
|
68
|
-
*/
|
|
69
|
-
decorateModule(moduleName, containedModule) {
|
|
70
|
-
const moduleNameString = this.moduleNameToString(moduleName);
|
|
71
|
-
const config = this.definition.config?.[moduleNameString];
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
73
|
-
if (!config) {
|
|
74
|
-
throw errors.configNotSetInContainer(moduleNameString);
|
|
75
|
-
}
|
|
76
|
-
containedModule.config = config;
|
|
77
|
-
}
|
|
78
|
-
onAfterModuleResolution(moduleName) {
|
|
79
|
-
this.container.afterResolution(
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
81
|
-
moduleName, (containedModuleName, containedModule) => {
|
|
82
|
-
if (Array.isArray(containedModule)) {
|
|
83
|
-
throw errors.unableToDecorateModule(containedModuleName);
|
|
84
|
-
}
|
|
85
|
-
this.decorateModule(moduleName, containedModule);
|
|
86
|
-
}, { frequency: ModuleContainer.moduleDecorationFrequency });
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
ModuleContainer.moduleDecorationFrequency = "Once";
|
package/dist/config/types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/config/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,qBAAqB,CAAC,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC"}
|
package/dist/config/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { Bool, Field } from "snarkyjs";
|
|
2
|
-
declare const MethodPublicInput_base: (new (value: {
|
|
3
|
-
stateTransitionsHash: Field;
|
|
4
|
-
status: Bool;
|
|
5
|
-
transactionHash: Field;
|
|
6
|
-
}) => {
|
|
7
|
-
stateTransitionsHash: Field;
|
|
8
|
-
status: Bool;
|
|
9
|
-
transactionHash: Field;
|
|
10
|
-
}) & {
|
|
11
|
-
_isStruct: true;
|
|
12
|
-
} & import("snarkyjs/dist/node/snarky").ProvablePure<{
|
|
13
|
-
stateTransitionsHash: Field;
|
|
14
|
-
status: Bool;
|
|
15
|
-
transactionHash: Field;
|
|
16
|
-
}> & {
|
|
17
|
-
toInput: (x: {
|
|
18
|
-
stateTransitionsHash: Field;
|
|
19
|
-
status: Bool;
|
|
20
|
-
transactionHash: Field;
|
|
21
|
-
}) => {
|
|
22
|
-
fields?: Field[] | undefined;
|
|
23
|
-
packed?: [Field, number][] | undefined;
|
|
24
|
-
};
|
|
25
|
-
toJSON: (x: {
|
|
26
|
-
stateTransitionsHash: Field;
|
|
27
|
-
status: Bool;
|
|
28
|
-
transactionHash: Field;
|
|
29
|
-
}) => {
|
|
30
|
-
stateTransitionsHash: string;
|
|
31
|
-
status: boolean;
|
|
32
|
-
transactionHash: string;
|
|
33
|
-
};
|
|
34
|
-
fromJSON: (x: {
|
|
35
|
-
stateTransitionsHash: string;
|
|
36
|
-
status: boolean;
|
|
37
|
-
transactionHash: string;
|
|
38
|
-
}) => {
|
|
39
|
-
stateTransitionsHash: Field;
|
|
40
|
-
status: Bool;
|
|
41
|
-
transactionHash: Field;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Public input used to link in-circuit execution with
|
|
46
|
-
* the proof's public input.
|
|
47
|
-
*/
|
|
48
|
-
export declare class MethodPublicInput extends MethodPublicInput_base {
|
|
49
|
-
}
|
|
50
|
-
export {};
|
|
51
|
-
//# sourceMappingURL=MethodPublicInput.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MethodPublicInput.d.ts","sourceRoot":"","sources":["../../src/model/MethodPublicInput.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAU,MAAM,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/C;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,sBAIrC;CAAG"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, Struct } from "snarkyjs";
|
|
2
|
-
/**
|
|
3
|
-
* Public input used to link in-circuit execution with
|
|
4
|
-
* the proof's public input.
|
|
5
|
-
*/
|
|
6
|
-
export class MethodPublicInput extends Struct({
|
|
7
|
-
stateTransitionsHash: Field,
|
|
8
|
-
status: Bool,
|
|
9
|
-
transactionHash: Field,
|
|
10
|
-
}) {
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BlockScopedModule.d.ts","sourceRoot":"","sources":["../../../src/prover/block/BlockScopedModule.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,OAAO,IAAI,CAAC;AAClB,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { Bool, Field, type FlexibleProvablePure } from "snarkyjs";
|
|
2
|
-
export declare function ProvableOption(value: { isSome: Bool; value: Field }): {
|
|
3
|
-
isSome: {
|
|
4
|
-
toField: {};
|
|
5
|
-
not: {};
|
|
6
|
-
and: {};
|
|
7
|
-
or: {};
|
|
8
|
-
assertEquals: {};
|
|
9
|
-
assertTrue: {};
|
|
10
|
-
assertFalse: {};
|
|
11
|
-
equals: {};
|
|
12
|
-
sizeInFields: {};
|
|
13
|
-
toFields: {};
|
|
14
|
-
toString: {};
|
|
15
|
-
toJSON: {};
|
|
16
|
-
toBoolean: {};
|
|
17
|
-
};
|
|
18
|
-
value: {
|
|
19
|
-
neg: {};
|
|
20
|
-
inv: {};
|
|
21
|
-
add: {};
|
|
22
|
-
sub: {};
|
|
23
|
-
mul: {};
|
|
24
|
-
div: {};
|
|
25
|
-
square: {};
|
|
26
|
-
sqrt: {};
|
|
27
|
-
toString: {};
|
|
28
|
-
toBigInt: {};
|
|
29
|
-
toJSON: {};
|
|
30
|
-
sizeInFields: {};
|
|
31
|
-
toFields: {};
|
|
32
|
-
lessThan: {};
|
|
33
|
-
lessThanOrEqual: {};
|
|
34
|
-
greaterThan: {};
|
|
35
|
-
greaterThanOrEqual: {};
|
|
36
|
-
assertLessThan: {};
|
|
37
|
-
assertLessThanOrEqual: {};
|
|
38
|
-
assertGreaterThan: {};
|
|
39
|
-
assertGreaterThanOrEqual: {};
|
|
40
|
-
lt: {};
|
|
41
|
-
lte: {};
|
|
42
|
-
gt: {};
|
|
43
|
-
gte: {};
|
|
44
|
-
assertLt: {};
|
|
45
|
-
assertLte: {};
|
|
46
|
-
assertGt: {};
|
|
47
|
-
assertGte: {};
|
|
48
|
-
assertEquals: {};
|
|
49
|
-
assertBool: {};
|
|
50
|
-
assertBoolean: {};
|
|
51
|
-
isZero: {};
|
|
52
|
-
toBits: {};
|
|
53
|
-
equals: {};
|
|
54
|
-
seal: {};
|
|
55
|
-
rangeCheckHelper: {};
|
|
56
|
-
isConstant: {};
|
|
57
|
-
toConstant: {};
|
|
58
|
-
fromFields: {};
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
export type ProvableOptionStruct = ReturnType<typeof ProvableOption>;
|
|
62
|
-
/**
|
|
63
|
-
* Option facilitating in-circuit values that may or may not exist.
|
|
64
|
-
*/
|
|
65
|
-
export declare class Option<Value> {
|
|
66
|
-
isSome: Bool;
|
|
67
|
-
value: Value;
|
|
68
|
-
valueType: FlexibleProvablePure<Value>;
|
|
69
|
-
/**
|
|
70
|
-
* Creates a new Option from the provided parameters
|
|
71
|
-
*
|
|
72
|
-
* @param isSome
|
|
73
|
-
* @param value
|
|
74
|
-
* @param valueType
|
|
75
|
-
* @returns New option from the provided parameters.
|
|
76
|
-
*/
|
|
77
|
-
static from<Value>(
|
|
78
|
-
isSome: Bool,
|
|
79
|
-
value: Value,
|
|
80
|
-
valueType: FlexibleProvablePure<Value>
|
|
81
|
-
): Option<Value>;
|
|
82
|
-
/**
|
|
83
|
-
* @returns Empty / none option
|
|
84
|
-
*/
|
|
85
|
-
static none(): Option<Field>;
|
|
86
|
-
constructor(
|
|
87
|
-
isSome: Bool,
|
|
88
|
-
value: Value,
|
|
89
|
-
valueType: FlexibleProvablePure<Value>
|
|
90
|
-
);
|
|
91
|
-
/**
|
|
92
|
-
* @returns Tree representation of the current value
|
|
93
|
-
*/
|
|
94
|
-
get treeValue(): Field;
|
|
95
|
-
/**
|
|
96
|
-
* @returns Provable representation of the current option.
|
|
97
|
-
*/
|
|
98
|
-
toProvable(): {
|
|
99
|
-
isSome: {
|
|
100
|
-
toField: {};
|
|
101
|
-
not: {};
|
|
102
|
-
and: {};
|
|
103
|
-
or: {};
|
|
104
|
-
assertEquals: {};
|
|
105
|
-
assertTrue: {};
|
|
106
|
-
assertFalse: {};
|
|
107
|
-
equals: {};
|
|
108
|
-
sizeInFields: {};
|
|
109
|
-
toFields: {};
|
|
110
|
-
toString: {};
|
|
111
|
-
toJSON: {};
|
|
112
|
-
toBoolean: {};
|
|
113
|
-
};
|
|
114
|
-
value: {
|
|
115
|
-
neg: {};
|
|
116
|
-
inv: {};
|
|
117
|
-
add: {};
|
|
118
|
-
sub: {};
|
|
119
|
-
mul: {};
|
|
120
|
-
div: {};
|
|
121
|
-
square: {};
|
|
122
|
-
sqrt: {};
|
|
123
|
-
toString: {};
|
|
124
|
-
toBigInt: {};
|
|
125
|
-
toJSON: {};
|
|
126
|
-
sizeInFields: {};
|
|
127
|
-
toFields: {};
|
|
128
|
-
lessThan: {};
|
|
129
|
-
lessThanOrEqual: {};
|
|
130
|
-
greaterThan: {};
|
|
131
|
-
greaterThanOrEqual: {};
|
|
132
|
-
assertLessThan: {};
|
|
133
|
-
assertLessThanOrEqual: {};
|
|
134
|
-
assertGreaterThan: {};
|
|
135
|
-
assertGreaterThanOrEqual: {};
|
|
136
|
-
lt: {};
|
|
137
|
-
lte: {};
|
|
138
|
-
gt: {};
|
|
139
|
-
gte: {};
|
|
140
|
-
assertLt: {};
|
|
141
|
-
assertLte: {};
|
|
142
|
-
assertGt: {};
|
|
143
|
-
assertGte: {};
|
|
144
|
-
assertEquals: {};
|
|
145
|
-
assertBool: {};
|
|
146
|
-
assertBoolean: {};
|
|
147
|
-
isZero: {};
|
|
148
|
-
toBits: {};
|
|
149
|
-
equals: {};
|
|
150
|
-
seal: {};
|
|
151
|
-
rangeCheckHelper: {};
|
|
152
|
-
isConstant: {};
|
|
153
|
-
toConstant: {};
|
|
154
|
-
fromFields: {};
|
|
155
|
-
};
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=Option.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Option.d.ts","sourceRoot":"","sources":["../../../src/model/Option.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAW,KAAK,EAAE,KAAK,oBAAoB,EAAoB,MAAM,UAAU,CAAC;AAE7F,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAInE;AAED,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAErE;;GAEG;AACH,qBAAa,MAAM,CAAC,KAAK;IAoBG,MAAM,EAAE,IAAI;IAAS,KAAK,EAAE,KAAK;IAAS,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAnB1G;;;;;;;OAOG;WACW,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAI5F;;OAEG;WACW,IAAI;gBAIQ,MAAM,EAAE,IAAI,EAAS,KAAK,EAAE,KAAK,EAAS,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAE1G;;OAEG;IACH,IAAW,SAAS,UAMnB;IAED;;OAEG;IACI,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAMlB"}
|
package/dist/src/model/Option.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2
|
-
/* eslint-disable new-cap */
|
|
3
|
-
/* eslint-disable max-classes-per-file */
|
|
4
|
-
import { Bool, Circuit, Field, Poseidon, Struct } from "snarkyjs";
|
|
5
|
-
export function ProvableOption(value) {
|
|
6
|
-
class ProvableOptionStruct extends Struct(value) {}
|
|
7
|
-
return new ProvableOptionStruct(value);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Option facilitating in-circuit values that may or may not exist.
|
|
11
|
-
*/
|
|
12
|
-
export class Option {
|
|
13
|
-
/**
|
|
14
|
-
* Creates a new Option from the provided parameters
|
|
15
|
-
*
|
|
16
|
-
* @param isSome
|
|
17
|
-
* @param value
|
|
18
|
-
* @param valueType
|
|
19
|
-
* @returns New option from the provided parameters.
|
|
20
|
-
*/
|
|
21
|
-
static from(isSome, value, valueType) {
|
|
22
|
-
return new Option(isSome, value, valueType);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* @returns Empty / none option
|
|
26
|
-
*/
|
|
27
|
-
static none() {
|
|
28
|
-
return new Option(Bool(false), Field(0), Field);
|
|
29
|
-
}
|
|
30
|
-
constructor(isSome, value, valueType) {
|
|
31
|
-
this.isSome = isSome;
|
|
32
|
-
this.value = value;
|
|
33
|
-
this.valueType = valueType;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* @returns Tree representation of the current value
|
|
37
|
-
*/
|
|
38
|
-
get treeValue() {
|
|
39
|
-
const treeValue = Poseidon.hash(this.valueType.toFields(this.value));
|
|
40
|
-
// if the sequencer claims the value is `None`,
|
|
41
|
-
// then we use Field(0) as the treeValue so it can be proven later
|
|
42
|
-
return Circuit.if(this.isSome, treeValue, Field(0));
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* @returns Provable representation of the current option.
|
|
46
|
-
*/
|
|
47
|
-
toProvable() {
|
|
48
|
-
return ProvableOption({
|
|
49
|
-
isSome: this.isSome,
|
|
50
|
-
value: this.treeValue,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
package/dist/src/model/Path.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Field, type FlexibleProvablePure } from "snarkyjs";
|
|
2
|
-
/**
|
|
3
|
-
* Helps manage path (key) identifiers for key-values in trees.
|
|
4
|
-
*/
|
|
5
|
-
export declare class Path {
|
|
6
|
-
/**
|
|
7
|
-
* Encodes a JS string as a Field
|
|
8
|
-
*
|
|
9
|
-
* @param value
|
|
10
|
-
* @returns Field representation of the provided value
|
|
11
|
-
*/
|
|
12
|
-
static toField(value: string): Field;
|
|
13
|
-
/**
|
|
14
|
-
* Encodes a class name and its property name into a Field
|
|
15
|
-
*
|
|
16
|
-
* @param className
|
|
17
|
-
* @param propertyKey
|
|
18
|
-
* @returns Field representation of class name + property name
|
|
19
|
-
*/
|
|
20
|
-
static fromProperty(className: string, propertyKey: string): Field;
|
|
21
|
-
/**
|
|
22
|
-
* Encodes an existing path with the provided key into a single Field.
|
|
23
|
-
*
|
|
24
|
-
* @param path
|
|
25
|
-
* @param keyType
|
|
26
|
-
* @param key
|
|
27
|
-
* @returns Field representation of the leading path + the provided key.
|
|
28
|
-
*/
|
|
29
|
-
static fromKey<KeyType>(
|
|
30
|
-
path: Field,
|
|
31
|
-
keyType: FlexibleProvablePure<KeyType>,
|
|
32
|
-
key: KeyType
|
|
33
|
-
): Field;
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=Path.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Path.d.ts","sourceRoot":"","sources":["../../../src/model/Path.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,EAAE,KAAK,oBAAoB,EAAY,MAAM,UAAU,CAAC;AAEtE;;GAEG;AACH,qBAAa,IAAI;IACf;;;;;OAKG;WACW,OAAO,CAAC,KAAK,EAAE,MAAM;IAUnC;;;;;;OAMG;WACW,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,KAAK;IAQzE;;;;;;;OAOG;WACW,OAAO,CAAC,OAAO,EAC3B,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACtC,GAAG,EAAE,OAAO,GACX,KAAK;CAIT"}
|
package/dist/src/model/Path.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2
|
-
/* eslint-disable new-cap */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
4
|
-
/* eslint-disable @shopify/no-fully-static-classes */
|
|
5
|
-
/* eslint-disable import/prefer-default-export */
|
|
6
|
-
import { Field, Poseidon } from "snarkyjs";
|
|
7
|
-
/**
|
|
8
|
-
* Helps manage path (key) identifiers for key-values in trees.
|
|
9
|
-
*/
|
|
10
|
-
export class Path {
|
|
11
|
-
/**
|
|
12
|
-
* Encodes a JS string as a Field
|
|
13
|
-
*
|
|
14
|
-
* @param value
|
|
15
|
-
* @returns Field representation of the provided value
|
|
16
|
-
*/
|
|
17
|
-
static toField(value) {
|
|
18
|
-
const fields = value
|
|
19
|
-
.split("")
|
|
20
|
-
.map((character) => character.codePointAt(0))
|
|
21
|
-
.filter((code) => code !== undefined)
|
|
22
|
-
.map((code) => Field(code));
|
|
23
|
-
return Poseidon.hash(fields);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Encodes a class name and its property name into a Field
|
|
27
|
-
*
|
|
28
|
-
* @param className
|
|
29
|
-
* @param propertyKey
|
|
30
|
-
* @returns Field representation of class name + property name
|
|
31
|
-
*/
|
|
32
|
-
static fromProperty(className, propertyKey) {
|
|
33
|
-
return Poseidon.hash([
|
|
34
|
-
Path.toField(className),
|
|
35
|
-
Path.toField(propertyKey),
|
|
36
|
-
Field(0),
|
|
37
|
-
]);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Encodes an existing path with the provided key into a single Field.
|
|
41
|
-
*
|
|
42
|
-
* @param path
|
|
43
|
-
* @param keyType
|
|
44
|
-
* @param key
|
|
45
|
-
* @returns Field representation of the leading path + the provided key.
|
|
46
|
-
*/
|
|
47
|
-
static fromKey(path, keyType, key) {
|
|
48
|
-
const keyHash = Poseidon.hash(keyType.toFields(key));
|
|
49
|
-
return Poseidon.hash([path, keyHash]);
|
|
50
|
-
}
|
|
51
|
-
}
|