@proto-kit/common 0.1.1-develop.1088 → 0.1.1-develop.1313
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/compiling/AtomicCompileHelper.d.ts +13 -0
- package/dist/compiling/AtomicCompileHelper.d.ts.map +1 -0
- package/dist/compiling/AtomicCompileHelper.js +40 -0
- package/dist/compiling/AtomicCompileHelper.js.map +1 -0
- package/dist/compiling/CompilableModule.d.ts +6 -0
- package/dist/compiling/CompilableModule.d.ts.map +1 -0
- package/dist/compiling/CompilableModule.js +2 -0
- package/dist/compiling/CompilableModule.js.map +1 -0
- package/dist/compiling/CompileRegistry.d.ts +26 -0
- package/dist/compiling/CompileRegistry.d.ts.map +1 -0
- package/dist/compiling/CompileRegistry.js +68 -0
- package/dist/compiling/CompileRegistry.js.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts +10 -0
- package/dist/compiling/services/ChildVerificationKeyService.d.ts.map +1 -0
- package/dist/compiling/services/ChildVerificationKeyService.js +27 -0
- package/dist/compiling/services/ChildVerificationKeyService.js.map +1 -0
- package/dist/config/ChildContainerCreatable.js +1 -0
- package/dist/config/ChildContainerCreatable.js.map +1 -0
- package/dist/config/ChildContainerProvider.js +1 -0
- package/dist/config/ChildContainerProvider.js.map +1 -0
- package/dist/config/ConfigurableModule.js +1 -0
- package/dist/config/ConfigurableModule.js.map +1 -0
- package/dist/config/ModuleContainer.d.ts +1 -0
- package/dist/config/ModuleContainer.d.ts.map +1 -1
- package/dist/config/ModuleContainer.js +14 -3
- package/dist/config/ModuleContainer.js.map +1 -0
- package/dist/config/injectAlias.d.ts +18 -0
- package/dist/config/injectAlias.d.ts.map +1 -0
- package/dist/config/injectAlias.js +47 -0
- package/dist/config/injectAlias.js.map +1 -0
- package/dist/dependencyFactory/DependencyFactory.js +1 -0
- package/dist/dependencyFactory/DependencyFactory.js.map +1 -0
- package/dist/dependencyFactory/injectOptional.js +1 -0
- package/dist/dependencyFactory/injectOptional.js.map +1 -0
- package/dist/dummyVerificationKey.d.ts +3 -0
- package/dist/dummyVerificationKey.d.ts.map +1 -0
- package/dist/dummyVerificationKey.js +8 -0
- package/dist/dummyVerificationKey.js.map +1 -0
- package/dist/events/EventEmitter.js +1 -0
- package/dist/events/EventEmitter.js.map +1 -0
- package/dist/events/EventEmitterProxy.d.ts +1 -0
- package/dist/events/EventEmitterProxy.d.ts.map +1 -1
- package/dist/events/EventEmitterProxy.js +12 -0
- package/dist/events/EventEmitterProxy.js.map +1 -0
- package/dist/events/EventEmittingComponent.d.ts +3 -0
- package/dist/events/EventEmittingComponent.d.ts.map +1 -1
- package/dist/events/EventEmittingComponent.js +1 -0
- package/dist/events/EventEmittingComponent.js.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts +17 -0
- package/dist/events/ReplayingSingleUseEventEmitter.d.ts.map +1 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js +34 -0
- package/dist/events/ReplayingSingleUseEventEmitter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +17 -0
- package/dist/log.d.ts.map +1 -1
- package/dist/log.js +40 -1
- package/dist/log.js.map +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js +1 -0
- package/dist/trees/InMemoryMerkleTreeStorage.js.map +1 -0
- package/dist/trees/MerkleTreeStore.js +1 -0
- package/dist/trees/MerkleTreeStore.js.map +1 -0
- package/dist/trees/MockAsyncMerkleStore.js +1 -0
- package/dist/trees/MockAsyncMerkleStore.js.map +1 -0
- package/dist/trees/RollupMerkleTree.js +1 -0
- package/dist/trees/RollupMerkleTree.js.map +1 -0
- package/dist/trees/VirtualMerkleTreeStore.js +1 -0
- package/dist/trees/VirtualMerkleTreeStore.js.map +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +13 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +40 -0
- package/dist/utils.js.map +1 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js +1 -0
- package/dist/zkProgrammable/ProvableMethodExecutionContext.js.map +1 -0
- package/dist/zkProgrammable/ZkProgrammable.d.ts +6 -5
- package/dist/zkProgrammable/ZkProgrammable.d.ts.map +1 -1
- package/dist/zkProgrammable/ZkProgrammable.js +24 -12
- package/dist/zkProgrammable/ZkProgrammable.js.map +1 -0
- package/dist/zkProgrammable/provableMethod.d.ts.map +1 -1
- package/dist/zkProgrammable/provableMethod.js +11 -13
- package/dist/zkProgrammable/provableMethod.js.map +1 -0
- package/jest.config.cjs +12 -1
- package/package.json +4 -4
- package/src/compiling/AtomicCompileHelper.ts +62 -0
- package/src/compiling/CompilableModule.ts +6 -0
- package/src/compiling/CompileRegistry.ts +78 -0
- package/src/compiling/services/ChildVerificationKeyService.ts +26 -0
- package/src/config/ModuleContainer.ts +20 -5
- package/src/config/injectAlias.ts +70 -0
- package/src/dummyVerificationKey.ts +10 -0
- package/src/events/EventEmitterProxy.ts +27 -3
- package/src/events/EventEmittingComponent.ts +4 -0
- package/src/events/ReplayingSingleUseEventEmitter.ts +42 -0
- package/src/index.ts +6 -0
- package/src/log.ts +47 -1
- package/src/types.ts +10 -1
- package/src/utils.ts +53 -2
- package/src/zkProgrammable/ZkProgrammable.ts +33 -13
- package/src/zkProgrammable/provableMethod.ts +15 -14
- package/test/config/ModuleContainer.test.ts +45 -2
- package/test/config/injectAlias.test.ts +28 -0
- package/test/zkProgrammable/ZkProgrammable.test.ts +7 -7
- package/dist/test/equalProvable.d.ts +0 -20
- package/dist/test/equalProvable.d.ts.map +0 -1
- package/dist/test/equalProvable.js +0 -13
|
@@ -2,12 +2,15 @@ import { ZkProgram, FlexibleProvablePure, Proof, Field, Provable } from "o1js";
|
|
|
2
2
|
import { Memoize } from "typescript-memoize";
|
|
3
3
|
|
|
4
4
|
import { log } from "../log";
|
|
5
|
+
import { dummyVerificationKey } from "../dummyVerificationKey";
|
|
6
|
+
import { reduceSequential } from "../utils";
|
|
7
|
+
import type { CompileRegistry } from "../compiling/CompileRegistry";
|
|
5
8
|
|
|
6
9
|
import { MOCK_PROOF } from "./provableMethod";
|
|
7
10
|
|
|
8
11
|
const errors = {
|
|
9
|
-
|
|
10
|
-
new Error(`
|
|
12
|
+
areProofsEnabledNotSet: (name: string) =>
|
|
13
|
+
new Error(`AreProofsEnabled was not injected for: ${name}`),
|
|
11
14
|
};
|
|
12
15
|
|
|
13
16
|
export interface CompileArtifact {
|
|
@@ -31,6 +34,7 @@ export interface Compile {
|
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
export interface PlainZkProgram<PublicInput = undefined, PublicOutput = void> {
|
|
37
|
+
name: string;
|
|
34
38
|
compile: Compile;
|
|
35
39
|
verify: Verify<PublicInput, PublicOutput>;
|
|
36
40
|
Proof: ReturnType<
|
|
@@ -75,10 +79,7 @@ export function verifyToMockable<PublicInput, PublicOutput>(
|
|
|
75
79
|
};
|
|
76
80
|
}
|
|
77
81
|
|
|
78
|
-
export const MOCK_VERIFICATION_KEY =
|
|
79
|
-
data: "mock-verification-key",
|
|
80
|
-
hash: Field(0),
|
|
81
|
-
};
|
|
82
|
+
export const MOCK_VERIFICATION_KEY = dummyVerificationKey();
|
|
82
83
|
|
|
83
84
|
export function compileToMockable(
|
|
84
85
|
compile: Compile,
|
|
@@ -99,28 +100,47 @@ export abstract class ZkProgrammable<
|
|
|
99
100
|
PublicInput = undefined,
|
|
100
101
|
PublicOutput = void,
|
|
101
102
|
> {
|
|
102
|
-
public abstract get
|
|
103
|
+
public abstract get areProofsEnabled(): AreProofsEnabled | undefined;
|
|
103
104
|
|
|
104
105
|
public abstract zkProgramFactory(): PlainZkProgram<
|
|
105
106
|
PublicInput,
|
|
106
107
|
PublicOutput
|
|
107
108
|
>[];
|
|
108
109
|
|
|
110
|
+
private zkProgramSingleton?: PlainZkProgram<PublicInput, PublicOutput>[];
|
|
111
|
+
|
|
109
112
|
@Memoize()
|
|
110
113
|
public get zkProgram(): PlainZkProgram<PublicInput, PublicOutput>[] {
|
|
111
|
-
|
|
114
|
+
if (this.zkProgramSingleton === undefined) {
|
|
115
|
+
this.zkProgramSingleton = this.zkProgramFactory();
|
|
116
|
+
}
|
|
112
117
|
|
|
113
|
-
return
|
|
114
|
-
if (!this.
|
|
115
|
-
throw errors.
|
|
118
|
+
return this.zkProgramSingleton.map((bucket) => {
|
|
119
|
+
if (!this.areProofsEnabled) {
|
|
120
|
+
throw errors.areProofsEnabledNotSet(this.constructor.name);
|
|
116
121
|
}
|
|
117
122
|
return {
|
|
118
123
|
...bucket,
|
|
119
|
-
verify: verifyToMockable(bucket.verify, this.
|
|
120
|
-
compile: compileToMockable(bucket.compile, this.
|
|
124
|
+
verify: verifyToMockable(bucket.verify, this.areProofsEnabled),
|
|
125
|
+
compile: compileToMockable(bucket.compile, this.areProofsEnabled),
|
|
121
126
|
};
|
|
122
127
|
});
|
|
123
128
|
}
|
|
129
|
+
|
|
130
|
+
public async compile(registry: CompileRegistry) {
|
|
131
|
+
return await reduceSequential(
|
|
132
|
+
this.zkProgram,
|
|
133
|
+
async (acc, program) => {
|
|
134
|
+
const result = await registry.compile(program);
|
|
135
|
+
return {
|
|
136
|
+
...acc,
|
|
137
|
+
[program.name]: result,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
141
|
+
{} as Record<string, CompileArtifact>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
124
144
|
}
|
|
125
145
|
|
|
126
146
|
export interface WithZkProgrammable<
|
|
@@ -15,6 +15,7 @@ export type ArgumentTypes = (
|
|
|
15
15
|
export type DecoratedMethod = (...args: ArgumentTypes) => Promise<unknown>;
|
|
16
16
|
|
|
17
17
|
export const MOCK_PROOF = "mock-proof";
|
|
18
|
+
// (await Proof.dummy(Field(0), Field(0), 2)).proof as string;
|
|
18
19
|
|
|
19
20
|
export function toProver(
|
|
20
21
|
methodName: string,
|
|
@@ -23,23 +24,23 @@ export function toProver(
|
|
|
23
24
|
...args: ArgumentTypes
|
|
24
25
|
) {
|
|
25
26
|
return async function prover(this: ZkProgrammable<any, any>) {
|
|
26
|
-
const areProofsEnabled = this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
const { areProofsEnabled } = this.areProofsEnabled!;
|
|
28
|
+
|
|
29
|
+
const zkProgram = this.zkProgram.find((prog) =>
|
|
30
|
+
Object.keys(prog.methods).includes(methodName)
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (zkProgram === undefined) {
|
|
34
|
+
throw new Error("Correct ZkProgram not found");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (areProofsEnabled) {
|
|
38
|
+
const programProvableMethod = zkProgram.methods[methodName];
|
|
39
|
+
return await Reflect.apply(programProvableMethod, this, args);
|
|
35
40
|
}
|
|
36
41
|
|
|
37
|
-
// create a mock proof by simulating method execution in JS
|
|
42
|
+
// create a mock proof by simulating method> execution in JS
|
|
38
43
|
const publicOutput = await Reflect.apply(simulatedMethod, this, args);
|
|
39
|
-
const zkProgram =
|
|
40
|
-
this.zkProgram.find((prog) => {
|
|
41
|
-
return Object.keys(prog.methods).includes(methodName);
|
|
42
|
-
}) ?? this.zkProgram[0];
|
|
43
44
|
|
|
44
45
|
return new zkProgram.Proof({
|
|
45
46
|
proof: MOCK_PROOF,
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
ModulesRecord,
|
|
11
11
|
} from "../../src/config/ModuleContainer";
|
|
12
12
|
import { TypedClass } from "../../src/types";
|
|
13
|
-
import { DependencyFactory } from "../../src";
|
|
13
|
+
import { DependencyFactory, expectDefined } from "../../src";
|
|
14
|
+
import { injectAlias } from "../../src/config/injectAlias";
|
|
14
15
|
|
|
15
16
|
// module container will accept modules that extend this type
|
|
16
17
|
class BaseTestModule<Config> extends ConfigurableModule<Config> {}
|
|
@@ -24,6 +25,7 @@ interface TestModuleConfig {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
@injectable()
|
|
28
|
+
@injectAlias(["child-alias", "multi-alias"])
|
|
27
29
|
class ChildModule extends BaseTestModule<NoConfig> {
|
|
28
30
|
public constructor(@inject("TestModule") public readonly testModule: any) {
|
|
29
31
|
super();
|
|
@@ -34,6 +36,7 @@ class ChildModule extends BaseTestModule<NoConfig> {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
@injectAlias(["base-alias", "multi-alias"])
|
|
37
40
|
class TestModule
|
|
38
41
|
extends BaseTestModule<TestModuleConfig>
|
|
39
42
|
implements DependencyFactory
|
|
@@ -66,7 +69,11 @@ class WrongTestModule {}
|
|
|
66
69
|
|
|
67
70
|
class TestModuleContainer<
|
|
68
71
|
Modules extends TestModulesRecord,
|
|
69
|
-
> extends ModuleContainer<Modules> {
|
|
72
|
+
> extends ModuleContainer<Modules> {
|
|
73
|
+
public get dependencyContainer() {
|
|
74
|
+
return this.container;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
70
77
|
|
|
71
78
|
describe("moduleContainer", () => {
|
|
72
79
|
let container: TestModuleContainer<{
|
|
@@ -169,4 +176,40 @@ describe("moduleContainer", () => {
|
|
|
169
176
|
expect(config.testConfigProperty2).toBe(2);
|
|
170
177
|
expect(config.testConfigProperty3).toBe(undefined);
|
|
171
178
|
});
|
|
179
|
+
|
|
180
|
+
it("should resolve dependencies correctly via alias", () => {
|
|
181
|
+
container.configure({
|
|
182
|
+
TestModule: {
|
|
183
|
+
testConfigProperty,
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
OtherTestModule: {
|
|
187
|
+
otherTestConfigProperty: testConfigProperty,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
container.create(() => tsyringeContainer.createChildContainer());
|
|
192
|
+
|
|
193
|
+
// Unfortunately we still need this so that the dependencies are registered
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
195
|
+
const m1 = container.resolve("base-alias" as any);
|
|
196
|
+
const m2 = container.resolve("TestModule");
|
|
197
|
+
|
|
198
|
+
expectDefined(m1);
|
|
199
|
+
// Check if its the same reference
|
|
200
|
+
expect(m1).toBe(m2);
|
|
201
|
+
|
|
202
|
+
const dm1 = container.resolve("child-alias" as any) as ChildModule;
|
|
203
|
+
const dm2 = container.resolve("DependencyModule1");
|
|
204
|
+
|
|
205
|
+
expect(dm1.x()).toBe("dependency factory works");
|
|
206
|
+
expect(dm1.testModule).toBeDefined();
|
|
207
|
+
expect(dm1).toBe(dm2);
|
|
208
|
+
|
|
209
|
+
const multi =
|
|
210
|
+
container.dependencyContainer.resolveAll<BaseTestModule<unknown>>(
|
|
211
|
+
"multi-alias"
|
|
212
|
+
);
|
|
213
|
+
expect(multi).toHaveLength(2);
|
|
214
|
+
});
|
|
172
215
|
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { getInjectAliases, injectAlias } from "../../src/config/injectAlias";
|
|
3
|
+
|
|
4
|
+
@injectAlias(["foo", "bar"])
|
|
5
|
+
class TestClass {}
|
|
6
|
+
|
|
7
|
+
@injectAlias(["ayy"])
|
|
8
|
+
class TestClass2 extends TestClass {}
|
|
9
|
+
|
|
10
|
+
describe("injectAlias metadata", () => {
|
|
11
|
+
it("set and retrieve", () => {
|
|
12
|
+
expect.assertions(2);
|
|
13
|
+
|
|
14
|
+
const aliases = getInjectAliases(TestClass);
|
|
15
|
+
|
|
16
|
+
expect(aliases).toHaveLength(2);
|
|
17
|
+
expect(aliases).toStrictEqual(["foo", "bar"]);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it("recursive", () => {
|
|
21
|
+
expect.assertions(2);
|
|
22
|
+
|
|
23
|
+
const aliases = getInjectAliases(TestClass2);
|
|
24
|
+
|
|
25
|
+
expect(aliases).toHaveLength(3);
|
|
26
|
+
expect(aliases).toStrictEqual(["ayy", "foo", "bar"]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -6,14 +6,12 @@ import { Field, Struct, Proof, ZkProgram } from "o1js";
|
|
|
6
6
|
import {
|
|
7
7
|
MOCK_PROOF,
|
|
8
8
|
provableMethod,
|
|
9
|
-
} from "../../src/zkProgrammable/provableMethod";
|
|
10
|
-
import {
|
|
11
9
|
AreProofsEnabled,
|
|
12
10
|
CompileArtifact,
|
|
13
11
|
MOCK_VERIFICATION_KEY,
|
|
14
12
|
ZkProgrammable,
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
ProvableMethodExecutionContext,
|
|
14
|
+
} from "../../src";
|
|
17
15
|
|
|
18
16
|
const appChainMock: AreProofsEnabled = {
|
|
19
17
|
areProofsEnabled: false,
|
|
@@ -39,7 +37,7 @@ class TestProgrammable extends ZkProgrammable<
|
|
|
39
37
|
TestPublicInput,
|
|
40
38
|
TestPublicOutput
|
|
41
39
|
> {
|
|
42
|
-
public
|
|
40
|
+
public areProofsEnabled: AreProofsEnabled = appChainMock;
|
|
43
41
|
|
|
44
42
|
@provableMethod()
|
|
45
43
|
public async foo(publicInput: TestPublicInput, bar: Balance) {
|
|
@@ -86,6 +84,7 @@ class TestProgrammable extends ZkProgrammable<
|
|
|
86
84
|
|
|
87
85
|
return [
|
|
88
86
|
{
|
|
87
|
+
name: program.name,
|
|
89
88
|
compile: program.compile.bind(program),
|
|
90
89
|
verify: program.verify.bind(program),
|
|
91
90
|
analyzeMethods: program.analyzeMethods.bind(program),
|
|
@@ -97,7 +96,7 @@ class TestProgrammable extends ZkProgrammable<
|
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
class OtherTestProgrammable extends ZkProgrammable<undefined, void> {
|
|
100
|
-
public
|
|
99
|
+
public areProofsEnabled: AreProofsEnabled = appChainMock;
|
|
101
100
|
|
|
102
101
|
public constructor(public testProgrammable: TestProgrammable) {
|
|
103
102
|
super();
|
|
@@ -129,6 +128,7 @@ class OtherTestProgrammable extends ZkProgrammable<undefined, void> {
|
|
|
129
128
|
|
|
130
129
|
return [
|
|
131
130
|
{
|
|
131
|
+
name: program.name,
|
|
132
132
|
compile: program.compile.bind(program),
|
|
133
133
|
verify: program.verify.bind(program),
|
|
134
134
|
analyzeMethods: program.analyzeMethods.bind(program),
|
|
@@ -183,7 +183,7 @@ describe("zkProgrammable", () => {
|
|
|
183
183
|
(areProofsEnabled, { verificationKey, shouldVerifyMockProofs }) => {
|
|
184
184
|
beforeAll(async () => {
|
|
185
185
|
testProgrammable = new TestProgrammable();
|
|
186
|
-
testProgrammable.
|
|
186
|
+
testProgrammable.areProofsEnabled.setProofsEnabled(areProofsEnabled);
|
|
187
187
|
zkProgramFactorySpy = jest.spyOn(testProgrammable, "zkProgramFactory");
|
|
188
188
|
artifact = await testProgrammable.zkProgram[0].compile();
|
|
189
189
|
}, 500_000);
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Field } from "o1js";
|
|
2
|
-
export declare function equalProvable(received: Field[], expected: Field[]): {
|
|
3
|
-
message: () => string;
|
|
4
|
-
pass: boolean;
|
|
5
|
-
};
|
|
6
|
-
interface CustomMatchers<R = void> {
|
|
7
|
-
equalProvable(expected: Field[]): R;
|
|
8
|
-
}
|
|
9
|
-
declare global {
|
|
10
|
-
namespace jest {
|
|
11
|
-
interface Expect extends CustomMatchers {
|
|
12
|
-
}
|
|
13
|
-
interface Matchers<R> extends CustomMatchers<R> {
|
|
14
|
-
}
|
|
15
|
-
interface InverseAsymmetricMatchers extends CustomMatchers {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=equalProvable.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"equalProvable.d.ts","sourceRoot":"","sources":["../../src/test/equalProvable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,wBAAgB,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE;;;EAajE;AAMD,UAAU,cAAc,CAAC,CAAC,GAAG,IAAI;IAC/B,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;CACrC;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,IAAI,CAAC;QACb,UAAU,MAAO,SAAQ,cAAc;SAAG;QAC1C,UAAU,QAAQ,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;SAAG;QAClD,UAAU,yBAA0B,SAAQ,cAAc;SAAG;KAC9D;CACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export function equalProvable(received, expected) {
|
|
2
|
-
expect(received).toHaveLength(expected.length);
|
|
3
|
-
const receivedBigInts = received.map((f) => f.toBigInt());
|
|
4
|
-
const expectedBigInts = expected.map((f) => f.toBigInt());
|
|
5
|
-
const pass = receivedBigInts.every((v, index) => v === expectedBigInts[index]);
|
|
6
|
-
return {
|
|
7
|
-
message: () => `Expected ${expectedBigInts}, received ${receivedBigInts}`,
|
|
8
|
-
pass,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
expect.extend({
|
|
12
|
-
equalProvable,
|
|
13
|
-
});
|