@vlayer/sdk 0.1.0-nightly-20241008-a3822d1 → 0.1.0-nightly-20241009-3c85ef5
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
package/src/api/lib/client.ts
CHANGED
@@ -2,18 +2,24 @@ import { VlayerClient } from "types/vlayer";
|
|
2
2
|
import { WebProofProvider } from "types/webProofProvider";
|
3
3
|
|
4
4
|
import { prove } from "../prover";
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
import { createExtensionWebProofProvider } from "../webProof";
|
6
|
+
export const createVlayerClient = (
|
7
|
+
{
|
8
|
+
url = "http://127.0.0.1:3000",
|
9
|
+
webProofProvider = createExtensionWebProofProvider(),
|
10
|
+
}: {
|
11
|
+
url?: string;
|
12
|
+
webProofProvider?: WebProofProvider;
|
13
|
+
} = {
|
14
|
+
url: "http://127.0.0.1:3000",
|
15
|
+
webProofProvider: createExtensionWebProofProvider(),
|
16
|
+
},
|
17
|
+
): VlayerClient => {
|
12
18
|
// TODO : implement high level api
|
13
19
|
console.log("createVlayerClient with", url, webProofProvider);
|
14
20
|
return {
|
15
21
|
prove: async ({ address, functionName, chainId, proverAbi, args }) => {
|
16
|
-
return prove(address, proverAbi, functionName, args, chainId);
|
22
|
+
return prove(address, proverAbi, functionName, args, chainId, url);
|
17
23
|
},
|
18
24
|
};
|
19
25
|
};
|
package/src/api/prover.ts
CHANGED
@@ -27,6 +27,7 @@ export async function prove<
|
|
27
27
|
functionName: F,
|
28
28
|
args: ContractFunctionArgs<T, AbiStateMutability, F>,
|
29
29
|
chainId: number = foundry.id,
|
30
|
+
url: string = "http://127.0.0.1:3000",
|
30
31
|
) {
|
31
32
|
const calldata = encodeFunctionData({
|
32
33
|
abi: abi as Abi,
|
@@ -41,14 +42,14 @@ export async function prove<
|
|
41
42
|
|
42
43
|
const {
|
43
44
|
result: { proof, evm_call_result },
|
44
|
-
} = await v_call(call, context);
|
45
|
+
} = await v_call(call, context, url);
|
45
46
|
|
46
|
-
const [, ...
|
47
|
+
const [, ...result] = decodeFunctionResult({
|
47
48
|
abi: abi as Abi,
|
48
49
|
data: evm_call_result,
|
49
50
|
functionName: functionName as string,
|
50
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
51
52
|
}) as any[];
|
52
53
|
|
53
|
-
return { proof,
|
54
|
+
return { proof, result };
|
54
55
|
}
|
package/src/api/v_call.ts
CHANGED
@@ -12,8 +12,9 @@ function v_callBody(call: CallParams, context: CallContext) {
|
|
12
12
|
export async function v_call(
|
13
13
|
call: CallParams,
|
14
14
|
context: CallContext,
|
15
|
+
url: string = "http://127.0.0.1:3000",
|
15
16
|
): Promise<VCallResponse> {
|
16
|
-
const response = await fetch(
|
17
|
+
const response = await fetch(url, {
|
17
18
|
method: "POST",
|
18
19
|
body: JSON.stringify(v_callBody(call, context)),
|
19
20
|
headers: { "Content-Type": "application/json" },
|
@@ -32,10 +32,15 @@ declare const chrome: {
|
|
32
32
|
// this id is fixed in the extension by the key in manifest.json
|
33
33
|
const EXTENSION_ID = "ghigbilfcgeibjkkajaekabeldkmijcd";
|
34
34
|
|
35
|
-
export const createExtensionWebProofProvider = (
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
export const createExtensionWebProofProvider = (
|
36
|
+
{
|
37
|
+
notaryUrl = "https://notary.pse.dev/v0.1.0-alpha.5/",
|
38
|
+
wsProxyUrl = "wss://notary.pse.dev/proxy",
|
39
|
+
}: WebProofProviderSetup = {
|
40
|
+
notaryUrl: "https://notary.pse.dev/v0.1.0-alpha.5/",
|
41
|
+
wsProxyUrl: "wss://notary.pse.dev/proxy",
|
42
|
+
},
|
43
|
+
): WebProofProvider => {
|
39
44
|
return {
|
40
45
|
getWebProof: async function (webProofSetup: WebProofSetupInput) {
|
41
46
|
return new Promise<WebProof>((resolve, reject) => {
|
package/src/index.ts
CHANGED
@@ -2,10 +2,11 @@ export { v_call } from "./api/v_call";
|
|
2
2
|
export type { CallParams, CallContext } from "types/vlayer";
|
3
3
|
export type { ContractSpec } from "types/ethereum";
|
4
4
|
|
5
|
-
export { getContractSpec
|
5
|
+
export { getContractSpec } from "./api/prover";
|
6
6
|
export * as testHelpers from "./api/helpers";
|
7
7
|
export { client as createTestClient } from "./api/helpers";
|
8
8
|
export { preverifyEmail } from "./api/email/preverify.ts";
|
9
|
+
export { createVlayerClient } from "./api/lib/client.ts";
|
9
10
|
|
10
11
|
export * from "./api/webProof";
|
11
12
|
export * from "./api/lib/types";
|