@vlayer/sdk 0.1.0-nightly-20241016-82138b7 → 0.1.0-nightly-20241017-3ad4fbf

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-20241017-3ad4fbf",
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
  };
@@ -21,32 +21,20 @@ export type CallContext = {
21
21
  chain_id: number; // 31337
22
22
  };
23
23
 
24
- export interface Proof {
24
+ export type Proof = {
25
25
  length: bigint;
26
26
  seal: {
27
27
  verifierSelector: Hex;
28
- seal: [Hex, Hex, Hex, Hex, Hex, Hex, Hex, Hex];
28
+ seal: readonly [Hex, Hex, Hex, Hex, Hex, Hex, Hex, Hex];
29
29
  mode: number;
30
30
  };
31
- dynamicParamsOffsets: [
32
- bigint,
33
- bigint,
34
- bigint,
35
- bigint,
36
- bigint,
37
- bigint,
38
- bigint,
39
- bigint,
40
- bigint,
41
- bigint,
42
- ];
43
- assumptions: {
31
+ callAssumptions: {
44
32
  proverContractAddress: Address;
45
33
  functionSelector: Hex;
46
34
  settleBlockHash: Hex;
47
35
  settleBlockNumber: bigint;
48
36
  };
49
- }
37
+ };
50
38
 
51
39
  export interface VCallResult {
52
40
  evm_call_result: Hex;
@@ -59,7 +47,6 @@ export interface VCallResponse {
59
47
  id: number;
60
48
  }
61
49
 
62
- // Add more methods here
63
50
  export type VlayerClient = {
64
51
  prove: <
65
52
  T extends readonly [AbiFunction, ...Abi[number][]],
@@ -71,7 +58,7 @@ export type VlayerClient = {
71
58
  hash,
72
59
  }: {
73
60
  hash: string;
74
- }) => Promise<{ proof: Proof; result: unknown[] }>;
61
+ }) => Promise<[Proof, ...unknown[]]>;
75
62
  };
76
63
 
77
64
  export type VlayerClientProveArgs<
@@ -1,15 +1,10 @@
1
1
  import { AbiFunction, Hex, Abi, ContractFunctionName } from "viem";
2
2
  import type { ContractFunctionArgsWithout } from "./viem";
3
- import {
4
- Branded,
5
- WebProof,
6
- WebProofStepExpectUrl,
7
- WebProofStepStartPage,
8
- } from "../../../web-proof-commons";
3
+ import { Branded, WebProof, WebProofStep } from "../../../web-proof-commons";
9
4
 
10
5
  export type WebProofSetupInput = {
11
6
  logoUrl: string;
12
- steps: [WebProofStepExpectUrl, WebProofStepStartPage, WebProofStepStartPage];
7
+ steps: WebProofStep[];
13
8
  };
14
9
 
15
10
  export type WebProofSetup = Branded<
@@ -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
  });
package/src/index.ts CHANGED
@@ -4,3 +4,6 @@ export { createVlayerClient } from "./api/lib/client.ts";
4
4
 
5
5
  export * from "./api/webProof";
6
6
  export * from "./api/lib/types";
7
+
8
+ export * from "./web-proof-commons/types/webProof.ts";
9
+ export * from "./web-proof-commons/utils.ts";