@vlayer/sdk 0.1.0-nightly-20241016-82138b7 → 0.1.0-nightly-20241016-4769145

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vlayer/sdk",
3
3
  "type": "module",
4
4
  "exports": "./src/index.ts",
5
- "version": "0.1.0-nightly-20241016-82138b7",
5
+ "version": "0.1.0-nightly-20241016-4769145",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -30,7 +30,7 @@ describe("parseEmail", () => {
30
30
  const email = await parseEmail(
31
31
  `${emailHeaders}${dkimHeader}\n${dkimHeader2}\n\n${body}`,
32
32
  );
33
- const dkim = email.headers.filter((h) => h.key === "dkim-signature")!;
33
+ const dkim = email.headers.filter((h) => h.key === "dkim-signature");
34
34
 
35
35
  expect(dkim).toHaveLength(2);
36
36
  expect(parseParams(dkim[0].value).s).toBe("selector1");
@@ -5,7 +5,7 @@ import { prove } from "../prover";
5
5
  import { createExtensionWebProofProvider } from "../webProof";
6
6
  import { type Abi, decodeFunctionResult } from "viem";
7
7
 
8
- function dropProofFromArgs(args: unknown) {
8
+ function dropEmptyProofFromArgs(args: unknown) {
9
9
  if (Array.isArray(args)) {
10
10
  return args.slice(1);
11
11
  }
@@ -32,7 +32,6 @@ export const createVlayerClient = (
32
32
  webProofProvider: createExtensionWebProofProvider(),
33
33
  },
34
34
  ): VlayerClient => {
35
- // TODO : implement high level api
36
35
  console.log("createVlayerClient with", url, webProofProvider);
37
36
  const resultHashMap = new Map<
38
37
  string,
@@ -62,15 +61,15 @@ export const createVlayerClient = (
62
61
  result: { proof, evm_call_result },
63
62
  } = await savedProvingData[0];
64
63
 
65
- const result = dropProofFromArgs(
64
+ const result = dropEmptyProofFromArgs(
66
65
  decodeFunctionResult({
67
- abi: savedProvingData[1] as Abi,
66
+ abi: savedProvingData[1],
68
67
  data: evm_call_result,
69
- functionName: savedProvingData[2] as string,
68
+ functionName: savedProvingData[2],
70
69
  }),
71
70
  );
72
71
 
73
- return { proof, result };
72
+ return [proof, ...result];
74
73
  },
75
74
  };
76
75
  };
@@ -59,7 +59,6 @@ export interface VCallResponse {
59
59
  id: number;
60
60
  }
61
61
 
62
- // Add more methods here
63
62
  export type VlayerClient = {
64
63
  prove: <
65
64
  T extends readonly [AbiFunction, ...Abi[number][]],
@@ -71,7 +70,7 @@ export type VlayerClient = {
71
70
  hash,
72
71
  }: {
73
72
  hash: string;
74
- }) => Promise<{ proof: Proof; result: unknown[] }>;
73
+ }) => Promise<[Proof, ...unknown[]]>;
75
74
  };
76
75
 
77
76
  export type VlayerClientProveArgs<
@@ -63,7 +63,7 @@ export const createExtensionWebProofProvider = (
63
63
  resolve(message.proof);
64
64
  }
65
65
  if (message.type === ExtensionMessageType.ProofError) {
66
- reject(message.error);
66
+ reject(new Error(message.error));
67
67
  }
68
68
  });
69
69
  });