@vlayer/sdk 0.1.0-nightly-20241008-a3822d1 → 0.1.0-nightly-20241009-3c85ef5

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.
@@ -3,9 +3,9 @@ export const enum ExtensionAction {
3
3
  }
4
4
 
5
5
  export const enum ExtensionMessageType {
6
- ProofDone,
7
- ProofError,
8
- RedirectBack,
6
+ ProofDone = "ProofDone",
7
+ ProofError = "ProofError",
8
+ RedirectBack = "RedirectBack",
9
9
  }
10
10
 
11
11
  export type ExtensionMessage =
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vlayer/sdk",
3
3
  "type": "module",
4
4
  "module": "src/index.ts",
5
- "version": "0.1.0-nightly-20241008-a3822d1",
5
+ "version": "0.1.0-nightly-20241009-3c85ef5",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -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
- export const createVlayerClient = ({
6
- url,
7
- webProofProvider,
8
- }: {
9
- url: string;
10
- webProofProvider: WebProofProvider;
11
- }): VlayerClient => {
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 [, ...returnValue] = decodeFunctionResult({
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, returnValue };
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("http://127.0.0.1:3000", {
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
- notaryUrl = "https://notary.pse.dev/v0.1.0-alpha.5/",
37
- wsProxyUrl = "wss://notary.pse.dev/proxy",
38
- }: WebProofProviderSetup): WebProofProvider => {
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, prove } from "./api/prover";
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";