@vlayer/sdk 0.1.0-nightly-20241121-ee5bff1 → 0.1.0-nightly-20241125-3bf0279
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/api/lib/client.js +42 -13
- package/dist/api/lib/client.test.js +15 -7
- package/dist/api/lib/types/viem.d.ts +1 -1
- package/dist/api/lib/types/vlayer.d.ts +17 -0
- package/dist/api/lib/types/webProofProvider.d.ts +9 -4
- package/dist/api/prover.d.ts +1 -1
- package/dist/api/prover.js +2 -1
- package/dist/api/webProof/createWebProofRequest.d.ts +2 -0
- package/dist/api/webProof/createWebProofRequest.js +9 -0
- package/dist/api/webProof/index.d.ts +1 -1
- package/dist/api/webProof/index.js +1 -1
- package/dist/api/webProof/providers/extension.js +52 -11
- package/dist/api/webProof/steps/index.d.ts +3 -3
- package/dist/config/createContext.d.ts +2 -2
- package/dist/config/createContext.js +4 -4
- package/dist/config/deploy.js +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/web-proof-commons/types/message.d.ts +18 -6
- package/dist/web-proof-commons/types/message.js +1 -0
- package/package.json +1 -1
- package/dist/api/webProof/createWebProof.d.ts +0 -2
- package/dist/api/webProof/createWebProof.js +0 -7
package/dist/api/lib/client.js
CHANGED
@@ -8,15 +8,9 @@ function dropEmptyProofFromArgs(args) {
|
|
8
8
|
}
|
9
9
|
return [];
|
10
10
|
}
|
11
|
-
function
|
12
|
-
|
13
|
-
|
14
|
-
hash += Math.floor(Math.random() * 16).toString(16);
|
15
|
-
}
|
16
|
-
return hash;
|
17
|
-
}
|
18
|
-
async function getHash() {
|
19
|
-
return Promise.resolve(generateRandomHash());
|
11
|
+
async function getHash(vcall_response) {
|
12
|
+
const result = await vcall_response;
|
13
|
+
return [result.result.hash, result];
|
20
14
|
}
|
21
15
|
export const createVlayerClient = ({ url = "http://127.0.0.1:3000", webProofProvider = createExtensionWebProofProvider(), } = {
|
22
16
|
url: "http://127.0.0.1:3000",
|
@@ -24,9 +18,9 @@ export const createVlayerClient = ({ url = "http://127.0.0.1:3000", webProofProv
|
|
24
18
|
}) => {
|
25
19
|
const resultHashMap = new Map();
|
26
20
|
return {
|
27
|
-
prove: async ({ address, functionName, chainId, proverAbi, args }) => {
|
21
|
+
prove: async ({ address, functionName, chainId, gasLimit, proverAbi, args, }) => {
|
28
22
|
webProofProvider.notifyZkProvingStatus(ZkProvingStatus.Proving);
|
29
|
-
const
|
23
|
+
const response = prove(address, proverAbi, functionName, args, chainId, gasLimit, url)
|
30
24
|
.catch((error) => {
|
31
25
|
webProofProvider.notifyZkProvingStatus(ZkProvingStatus.Error);
|
32
26
|
throw error;
|
@@ -35,8 +29,12 @@ export const createVlayerClient = ({ url = "http://127.0.0.1:3000", webProofProv
|
|
35
29
|
webProofProvider.notifyZkProvingStatus(ZkProvingStatus.Done);
|
36
30
|
return result;
|
37
31
|
});
|
38
|
-
const hash = await getHash();
|
39
|
-
resultHashMap.set(hash, [
|
32
|
+
const [hash, result_promise] = await getHash(response);
|
33
|
+
resultHashMap.set(hash, [
|
34
|
+
Promise.resolve(result_promise),
|
35
|
+
proverAbi,
|
36
|
+
functionName,
|
37
|
+
]);
|
40
38
|
return { hash };
|
41
39
|
},
|
42
40
|
waitForProvingResult: async ({ hash, }) => {
|
@@ -53,5 +51,36 @@ export const createVlayerClient = ({ url = "http://127.0.0.1:3000", webProofProv
|
|
53
51
|
}));
|
54
52
|
return [proof, ...result];
|
55
53
|
},
|
54
|
+
proveWeb: async function ({ address, proverAbi, functionName, chainId, args, }) {
|
55
|
+
const webProofPlaceholder = args[0];
|
56
|
+
const commitmentArgs = args.slice(1);
|
57
|
+
const webProof = await webProofProvider.getWebProof({
|
58
|
+
proverCallCommitment: {
|
59
|
+
address,
|
60
|
+
proverAbi,
|
61
|
+
functionName,
|
62
|
+
commitmentArgs,
|
63
|
+
chainId,
|
64
|
+
},
|
65
|
+
logoUrl: webProofPlaceholder.logoUrl,
|
66
|
+
steps: webProofPlaceholder.steps,
|
67
|
+
});
|
68
|
+
const hash = await this.prove({
|
69
|
+
address,
|
70
|
+
functionName,
|
71
|
+
chainId,
|
72
|
+
proverAbi,
|
73
|
+
args: [
|
74
|
+
{
|
75
|
+
webProofJson: JSON.stringify({
|
76
|
+
tls_proof: webProof,
|
77
|
+
notary_pub_key: webProofPlaceholder.notaryPubKey,
|
78
|
+
}),
|
79
|
+
},
|
80
|
+
...commitmentArgs,
|
81
|
+
],
|
82
|
+
});
|
83
|
+
return hash;
|
84
|
+
},
|
56
85
|
};
|
57
86
|
};
|
@@ -20,6 +20,13 @@ beforeEach(() => {
|
|
20
20
|
},
|
21
21
|
};
|
22
22
|
});
|
23
|
+
function generateRandomHash() {
|
24
|
+
let hash = "0x";
|
25
|
+
for (let i = 0; i < 40; ++i) {
|
26
|
+
hash += Math.floor(Math.random() * 16).toString(16);
|
27
|
+
}
|
28
|
+
return hash;
|
29
|
+
}
|
23
30
|
describe("Success zk-proving", () => {
|
24
31
|
beforeEach(() => {
|
25
32
|
fetchMocker.mockResponseOnce((req) => {
|
@@ -27,6 +34,7 @@ describe("Success zk-proving", () => {
|
|
27
34
|
return {
|
28
35
|
body: JSON.stringify({
|
29
36
|
result: {
|
37
|
+
hash: generateRandomHash(),
|
30
38
|
proof: {},
|
31
39
|
},
|
32
40
|
}),
|
@@ -67,14 +75,14 @@ describe("Failed zk-proving", () => {
|
|
67
75
|
const webProofProvider = createExtensionWebProofProvider();
|
68
76
|
const zkProvingSpy = vi.spyOn(webProofProvider, "notifyZkProvingStatus");
|
69
77
|
const vlayer = createVlayerClient({ webProofProvider });
|
70
|
-
const hash = await vlayer.prove({
|
71
|
-
address: `0x${"a".repeat(40)}`,
|
72
|
-
functionName: "main",
|
73
|
-
proverAbi: [],
|
74
|
-
args: [],
|
75
|
-
chainId: 42,
|
76
|
-
});
|
77
78
|
try {
|
79
|
+
const hash = await vlayer.prove({
|
80
|
+
address: `0x${"a".repeat(40)}`,
|
81
|
+
functionName: "main",
|
82
|
+
proverAbi: [],
|
83
|
+
args: [],
|
84
|
+
chainId: 42,
|
85
|
+
});
|
78
86
|
await vlayer.waitForProvingResult(hash);
|
79
87
|
}
|
80
88
|
catch (e) {
|
@@ -4,5 +4,5 @@ type Without<T extends readonly unknown[], P> = T extends readonly [
|
|
4
4
|
infer F,
|
5
5
|
...infer R
|
6
6
|
] ? F extends P ? Without<R, P> : readonly [F, ...Without<R, P>] : [];
|
7
|
-
export type ContractFunctionArgsWithout<abi extends Abi, functionName extends ContractFunctionName<abi>, without> = AbiParametersToPrimitiveTypes<Without<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName>["inputs"], without>, "inputs"
|
7
|
+
export type ContractFunctionArgsWithout<abi extends Abi, functionName extends ContractFunctionName<abi>, without> = AbiParametersToPrimitiveTypes<Without<ExtractAbiFunction<abi extends Abi ? abi : Abi, functionName>["inputs"], without>, "inputs">;
|
8
8
|
export {};
|
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Branded } from "../../../web-proof-commons/utils.js";
|
2
2
|
import { Abi, AbiStateMutability, Address, ContractFunctionArgs, ContractFunctionName, ContractFunctionReturnType, Hex } from "viem";
|
3
|
+
import { WebProofRequest } from "./webProofProvider.js";
|
4
|
+
import { ContractFunctionArgsWithout } from "./viem.js";
|
3
5
|
type Calldata = string;
|
4
6
|
export type CallParams = {
|
5
7
|
to: Address;
|
@@ -7,6 +9,7 @@ export type CallParams = {
|
|
7
9
|
};
|
8
10
|
export type CallContext = {
|
9
11
|
chain_id: number;
|
12
|
+
gas_limit: number;
|
10
13
|
};
|
11
14
|
export type BrandedHash<T, F> = Branded<{
|
12
15
|
hash: string;
|
@@ -27,6 +30,7 @@ export type Proof = {
|
|
27
30
|
};
|
28
31
|
};
|
29
32
|
export interface VCallResult {
|
33
|
+
hash: Hex;
|
30
34
|
evm_call_result: Hex;
|
31
35
|
proof: Proof;
|
32
36
|
}
|
@@ -41,8 +45,21 @@ export type VlayerClient = {
|
|
41
45
|
proverAbi: T;
|
42
46
|
functionName: F;
|
43
47
|
chainId?: number;
|
48
|
+
gasLimit?: number;
|
44
49
|
args: ContractFunctionArgs<T, AbiStateMutability, F>;
|
45
50
|
}) => Promise<BrandedHash<T, F>>;
|
46
51
|
waitForProvingResult: <T extends Abi, F extends ContractFunctionName<T>>(hash: BrandedHash<T, F>) => Promise<ContractFunctionReturnType<T, AbiStateMutability, F>>;
|
52
|
+
proveWeb: <T extends Abi, F extends ContractFunctionName<T>>(args: {
|
53
|
+
address: Hex;
|
54
|
+
proverAbi: T;
|
55
|
+
functionName: F;
|
56
|
+
chainId: number;
|
57
|
+
args: [
|
58
|
+
WebProofRequest,
|
59
|
+
...ContractFunctionArgsWithout<T, F, {
|
60
|
+
name: "webProof";
|
61
|
+
}>
|
62
|
+
];
|
63
|
+
}) => Promise<BrandedHash<T, F>>;
|
47
64
|
};
|
48
65
|
export {};
|
@@ -1,11 +1,12 @@
|
|
1
1
|
import { Hex, Abi, ContractFunctionName } from "viem";
|
2
2
|
import type { ContractFunctionArgsWithout } from "./viem.js";
|
3
|
-
import { Branded, WebProof, WebProofStep, ZkProvingStatus } from "../../../web-proof-commons/index.js";
|
4
|
-
export type
|
3
|
+
import { Branded, ExtensionMessageType, ExtensionMessage, WebProof, WebProofStep, ZkProvingStatus } from "../../../web-proof-commons/index.js";
|
4
|
+
export type WebProofRequestInput = {
|
5
5
|
logoUrl: string;
|
6
6
|
steps: WebProofStep[];
|
7
|
+
notaryPubKey?: string;
|
7
8
|
};
|
8
|
-
export type
|
9
|
+
export type WebProofRequest = Branded<WebProofRequestInput & {
|
9
10
|
isWebProof: true;
|
10
11
|
}, "webProof">;
|
11
12
|
export type ProverCallCommitment<T extends Abi, F extends ContractFunctionName<T>> = {
|
@@ -19,10 +20,14 @@ export type ProverCallCommitment<T extends Abi, F extends ContractFunctionName<T
|
|
19
20
|
};
|
20
21
|
export type GetWebProofArgs<T extends Abi, F extends ContractFunctionName<T>> = {
|
21
22
|
proverCallCommitment: ProverCallCommitment<T, F>;
|
22
|
-
} &
|
23
|
+
} & WebProofRequestInput;
|
23
24
|
export type WebProofProvider = {
|
24
25
|
getWebProof: <T extends Abi, F extends ContractFunctionName<T>>(args: GetWebProofArgs<T, F>) => Promise<WebProof>;
|
26
|
+
requestWebProof: <T extends Abi, F extends ContractFunctionName<T>>(args: GetWebProofArgs<T, F>) => void;
|
25
27
|
notifyZkProvingStatus: (status: ZkProvingStatus) => void;
|
28
|
+
addEventListeners: <T extends ExtensionMessageType>(messageType: T, listener: (args: Extract<ExtensionMessage, {
|
29
|
+
type: T;
|
30
|
+
}>) => void) => void;
|
26
31
|
};
|
27
32
|
export type WebProofProviderSetup = {
|
28
33
|
notaryUrl?: string;
|
package/dist/api/prover.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import { type Abi, AbiStateMutability, type Address, ContractFunctionArgs, ContractFunctionName } from "viem";
|
2
|
-
export declare function prove<T extends Abi, F extends ContractFunctionName<T>>(prover: Address, abi: T, functionName: F, args: ContractFunctionArgs<T, AbiStateMutability, F>, chainId?: number, url?: string): Promise<import("./lib/types/vlayer.js").VCallResponse>;
|
2
|
+
export declare function prove<T extends Abi, F extends ContractFunctionName<T>>(prover: Address, abi: T, functionName: F, args: ContractFunctionArgs<T, AbiStateMutability, F>, chainId?: number, gasLimit?: number, url?: string): Promise<import("./lib/types/vlayer.js").VCallResponse>;
|
package/dist/api/prover.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { encodeFunctionData, } from "viem";
|
2
2
|
import { v_call } from "./v_call.js";
|
3
3
|
import { foundry } from "viem/chains";
|
4
|
-
export async function prove(prover, abi, functionName, args, chainId = foundry.id, url = "http://127.0.0.1:3000") {
|
4
|
+
export async function prove(prover, abi, functionName, args, chainId = foundry.id, gasLimit = 1_000_000, url = "http://127.0.0.1:3000") {
|
5
5
|
const calldata = encodeFunctionData({
|
6
6
|
abi: abi,
|
7
7
|
functionName: functionName,
|
@@ -10,6 +10,7 @@ export async function prove(prover, abi, functionName, args, chainId = foundry.i
|
|
10
10
|
const call = { to: prover, data: calldata };
|
11
11
|
const context = {
|
12
12
|
chain_id: chainId,
|
13
|
+
gas_limit: gasLimit,
|
13
14
|
};
|
14
15
|
return v_call(call, context, url);
|
15
16
|
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
const NOTARY_PUB_KEY = "-----BEGIN PUBLIC KEY-----\nMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAExpX/4R4z40gI6C/j9zAM39u58LJu\n3Cx5tXTuqhhu/tirnBi5GniMmspOTEsps4ANnPLpMmMSfhJ+IFHbc3qVOA==\n-----END PUBLIC KEY-----\n";
|
2
|
+
export const createWebProofRequest = ({ logoUrl, steps, notaryPubKey = NOTARY_PUB_KEY, }) => {
|
3
|
+
return {
|
4
|
+
logoUrl,
|
5
|
+
steps,
|
6
|
+
notaryPubKey,
|
7
|
+
isWebProof: true,
|
8
|
+
};
|
9
|
+
};
|
@@ -1,45 +1,86 @@
|
|
1
1
|
import { ExtensionMessageType, } from "../../../web-proof-commons/index.js";
|
2
|
-
// this id is fixed in the extension by the key in manifest.json
|
3
2
|
const EXTENSION_ID = "jbchhcgphfokabmfacnkafoeeeppjmpl";
|
4
3
|
class ExtensionWebProofProvider {
|
5
4
|
notaryUrl;
|
6
5
|
wsProxyUrl;
|
7
6
|
port = null;
|
7
|
+
listeners = {};
|
8
8
|
constructor(notaryUrl, wsProxyUrl) {
|
9
9
|
this.notaryUrl = notaryUrl;
|
10
10
|
this.wsProxyUrl = wsProxyUrl;
|
11
11
|
}
|
12
12
|
notifyZkProvingStatus(status) {
|
13
13
|
if (typeof chrome !== "undefined") {
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
// Chrome does not provide reliable api to check if given extension is installed
|
15
|
+
// what we could do is to use management api but
|
16
|
+
// 1) this will need to provided extra permission
|
17
|
+
// 2) still is not reliable because this api becomes defined when first extension that uses it is installed
|
18
|
+
// so still will need to try catch
|
19
|
+
try {
|
20
|
+
chrome.runtime.sendMessage(EXTENSION_ID, {
|
21
|
+
action: "NotifyZkProvingStatus" /* ExtensionAction.NotifyZkProvingStatus */,
|
22
|
+
payload: { status },
|
23
|
+
});
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
25
|
+
}
|
26
|
+
catch (e) {
|
27
|
+
console.log("Cant send message", "look that extension is not installed ");
|
28
|
+
}
|
18
29
|
}
|
19
30
|
}
|
20
31
|
connectToExtension() {
|
21
32
|
if (!this.port) {
|
22
33
|
this.port = chrome.runtime.connect(EXTENSION_ID);
|
34
|
+
this.port.onMessage.addListener((message) => {
|
35
|
+
if (message.type === ExtensionMessageType.ProofDone) {
|
36
|
+
this.listeners[ExtensionMessageType.ProofDone]?.forEach((cb) => {
|
37
|
+
cb(message);
|
38
|
+
});
|
39
|
+
}
|
40
|
+
if (message.type === ExtensionMessageType.ProofError) {
|
41
|
+
this.listeners[ExtensionMessageType.ProofError]?.forEach((cb) => {
|
42
|
+
cb(message);
|
43
|
+
});
|
44
|
+
}
|
45
|
+
});
|
23
46
|
}
|
24
47
|
return this.port;
|
25
48
|
}
|
26
|
-
|
49
|
+
addEventListeners(messageType, listener) {
|
50
|
+
this.connectToExtension();
|
51
|
+
if (!this.listeners[messageType]) {
|
52
|
+
this.listeners[messageType] = [];
|
53
|
+
}
|
54
|
+
this.listeners[messageType].push(listener);
|
55
|
+
}
|
56
|
+
requestWebProof(webProofRequest) {
|
57
|
+
this.connectToExtension().postMessage({
|
58
|
+
action: "RequestWebProof" /* ExtensionAction.RequestWebProof */,
|
59
|
+
payload: {
|
60
|
+
notaryUrl: this.notaryUrl,
|
61
|
+
wsProxyUrl: this.wsProxyUrl,
|
62
|
+
logoUrl: webProofRequest.logoUrl,
|
63
|
+
steps: webProofRequest.steps,
|
64
|
+
},
|
65
|
+
});
|
66
|
+
}
|
67
|
+
async getWebProof(webProofRequest) {
|
27
68
|
return new Promise((resolve, reject) => {
|
28
69
|
chrome.runtime.sendMessage(EXTENSION_ID, {
|
29
|
-
action:
|
70
|
+
action: "RequestWebProof" /* ExtensionAction.RequestWebProof */,
|
30
71
|
payload: {
|
31
72
|
notaryUrl: this.notaryUrl,
|
32
73
|
wsProxyUrl: this.wsProxyUrl,
|
33
|
-
logoUrl:
|
34
|
-
steps:
|
74
|
+
logoUrl: webProofRequest.logoUrl,
|
75
|
+
steps: webProofRequest.steps,
|
35
76
|
},
|
36
77
|
});
|
37
78
|
this.connectToExtension().onMessage.addListener((message) => {
|
38
79
|
if (message.type === ExtensionMessageType.ProofDone) {
|
39
|
-
resolve(message.proof);
|
80
|
+
resolve(message.payload.proof);
|
40
81
|
}
|
41
82
|
if (message.type === ExtensionMessageType.ProofError) {
|
42
|
-
reject(new Error(message.error));
|
83
|
+
reject(new Error(message.payload.error));
|
43
84
|
}
|
44
85
|
});
|
45
86
|
});
|
@@ -2,8 +2,8 @@ import { expectUrl } from "./expectUrl.js";
|
|
2
2
|
import { startPage } from "./startPage.js";
|
3
3
|
import { notarize } from "./notarize.js";
|
4
4
|
declare const steps: {
|
5
|
-
expectUrl: (url: string, label: string) => import("../../../
|
6
|
-
startPage: (url: string, label: string) => import("../../../
|
7
|
-
notarize: (url: string, method: string | undefined, label: string) => import("../../../
|
5
|
+
expectUrl: (url: string, label: string) => import("../../../index.js").WebProofStepExpectUrl;
|
6
|
+
startPage: (url: string, label: string) => import("../../../index.js").WebProofStepStartPage;
|
7
|
+
notarize: (url: string, method: string | undefined, label: string) => import("../../../index.js").WebProofStepNotarize;
|
8
8
|
};
|
9
9
|
export { expectUrl, startPage, notarize, steps };
|
@@ -2,7 +2,7 @@ import { type Chain, type CustomTransport, custom } from "viem";
|
|
2
2
|
import { Config } from "./getConfig.js";
|
3
3
|
export declare const customTransport: typeof custom;
|
4
4
|
export { Chain };
|
5
|
-
export declare const createContext: (config: Config, transport?: CustomTransport) =>
|
5
|
+
export declare const createContext: (config: Config, transport?: CustomTransport) => {
|
6
6
|
chain: Chain;
|
7
7
|
account: {
|
8
8
|
address: import("viem").Address;
|
@@ -4952,4 +4952,4 @@ export declare const createContext: (config: Config, transport?: CustomTransport
|
|
4952
4952
|
chainName: string;
|
4953
4953
|
proverUrl: string;
|
4954
4954
|
privateKey: `0x${string}`;
|
4955
|
-
}
|
4955
|
+
};
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { createWalletClient, http, publicActions, custom, } from "viem";
|
2
2
|
import { privateKeyToAccount } from "viem/accounts";
|
3
3
|
import { getChainConfirmations } from "./getChainConfirmations.js";
|
4
|
-
|
4
|
+
import * as chains from "viem/chains";
|
5
|
+
const getChainSpecs = (chainName) => {
|
5
6
|
try {
|
6
|
-
const chains = await import("viem/chains");
|
7
7
|
return chains[chainName];
|
8
8
|
}
|
9
9
|
catch {
|
@@ -15,8 +15,8 @@ const createEthClient = (chain, jsonRpcUrl, transport) => createWalletClient({
|
|
15
15
|
chain,
|
16
16
|
transport: transport || http(jsonRpcUrl),
|
17
17
|
}).extend(publicActions);
|
18
|
-
export const createContext =
|
19
|
-
const chain =
|
18
|
+
export const createContext = (config, transport) => {
|
19
|
+
const chain = getChainSpecs(config.chainName);
|
20
20
|
const jsonRpcUrl = config.jsonRpcUrl ?? chain.rpcUrls.default.http[0];
|
21
21
|
return {
|
22
22
|
...config,
|
package/dist/config/deploy.js
CHANGED
@@ -2,7 +2,7 @@ import { getConfig } from "./getConfig.js";
|
|
2
2
|
import { createContext } from "./createContext.js";
|
3
3
|
import { getChainConfirmations } from "./getChainConfirmations.js";
|
4
4
|
export const waitForContractDeploy = async ({ hash, }) => {
|
5
|
-
const { ethClient: client } =
|
5
|
+
const { ethClient: client } = createContext(getConfig());
|
6
6
|
const receipt = await client.waitForTransactionReceipt({
|
7
7
|
hash,
|
8
8
|
confirmations: getChainConfirmations(client.chain?.name),
|
@@ -15,7 +15,7 @@ export const waitForContractDeploy = async ({ hash, }) => {
|
|
15
15
|
return receipt.contractAddress;
|
16
16
|
};
|
17
17
|
export const waitForTransactionReceipt = async ({ hash, }) => {
|
18
|
-
const { ethClient } =
|
18
|
+
const { ethClient } = createContext(getConfig());
|
19
19
|
return ethClient.waitForTransactionReceipt({
|
20
20
|
hash,
|
21
21
|
confirmations: getChainConfirmations(ethClient.chain?.name),
|
@@ -26,7 +26,7 @@ export const waitForTransactionReceipt = async ({ hash, }) => {
|
|
26
26
|
export const deployVlayerContracts = async ({ proverSpec, verifierSpec, proverArgs, verifierArgs, }) => {
|
27
27
|
console.log("Starting contract deployment process...");
|
28
28
|
const config = getConfig();
|
29
|
-
const { chain, ethClient, account } =
|
29
|
+
const { chain, ethClient, account } = createContext(config);
|
30
30
|
console.log("Deploying prover contract...");
|
31
31
|
const proverHash = await ethClient.deployContract({
|
32
32
|
chain,
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -7,8 +7,8 @@ export declare const EXTENSION_STEP: {
|
|
7
7
|
};
|
8
8
|
export type ExtensionStep = (typeof EXTENSION_STEP)[keyof typeof EXTENSION_STEP];
|
9
9
|
export declare const enum ExtensionAction {
|
10
|
-
RequestWebProof =
|
11
|
-
NotifyZkProvingStatus =
|
10
|
+
RequestWebProof = "RequestWebProof",
|
11
|
+
NotifyZkProvingStatus = "NotifyZkProvingStatus"
|
12
12
|
}
|
13
13
|
export declare enum ZkProvingStatus {
|
14
14
|
NotStarted = "NotStarted",
|
@@ -29,19 +29,31 @@ export declare enum ExtensionMessageType {
|
|
29
29
|
ProofDone = "ProofDone",
|
30
30
|
ProofError = "ProofError",
|
31
31
|
RedirectBack = "RedirectBack",
|
32
|
-
TabOpened = "TabOpened"
|
32
|
+
TabOpened = "TabOpened",
|
33
|
+
ProofProcessing = "ProofProcessing"
|
33
34
|
}
|
34
35
|
export type ExtensionMessage = {
|
35
36
|
type: ExtensionMessageType.ProofDone;
|
36
|
-
|
37
|
+
payload: {
|
38
|
+
proof: WebProof;
|
39
|
+
};
|
37
40
|
} | {
|
38
41
|
type: ExtensionMessageType.ProofError;
|
39
|
-
|
42
|
+
payload: {
|
43
|
+
error: string;
|
44
|
+
};
|
40
45
|
} | {
|
41
46
|
type: ExtensionMessageType.RedirectBack;
|
42
47
|
} | {
|
43
48
|
type: ExtensionMessageType.TabOpened;
|
44
|
-
|
49
|
+
payload: {
|
50
|
+
tabId: number;
|
51
|
+
};
|
52
|
+
} | {
|
53
|
+
type: ExtensionMessageType.ProofProcessing;
|
54
|
+
payload: {
|
55
|
+
progress?: number;
|
56
|
+
};
|
45
57
|
};
|
46
58
|
export type WebProverSessionConfig = {
|
47
59
|
notaryUrl: string | null;
|
@@ -16,4 +16,5 @@ export var ExtensionMessageType;
|
|
16
16
|
ExtensionMessageType["ProofError"] = "ProofError";
|
17
17
|
ExtensionMessageType["RedirectBack"] = "RedirectBack";
|
18
18
|
ExtensionMessageType["TabOpened"] = "TabOpened";
|
19
|
+
ExtensionMessageType["ProofProcessing"] = "ProofProcessing";
|
19
20
|
})(ExtensionMessageType || (ExtensionMessageType = {}));
|
package/package.json
CHANGED