@vlayer/sdk 0.1.0-nightly-20241017-3ad4fbf → 0.1.0-nightly-20241021-1eb6b14

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.
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-20241017-3ad4fbf",
5
+ "version": "0.1.0-nightly-20241021-1eb6b14",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -22,6 +22,7 @@
22
22
  "dns-over-http-resolver": "^3.0.3",
23
23
  "postal-mime": "^2.3.2",
24
24
  "viem": "2.21.0",
25
- "vite-tsconfig-paths": "^5.0.1"
25
+ "vite-tsconfig-paths": "^5.0.1",
26
+ "@vitejs/plugin-react": "^4.3.2"
26
27
  }
27
28
  }
@@ -26,13 +26,13 @@ export function parseParams(str: string) {
26
26
  .split("=")
27
27
  .map((v) => v && v.trim()),
28
28
  ),
29
- );
29
+ ) as Record<string, string>;
30
30
  }
31
31
 
32
32
  function parseHeader(header: Header) {
33
33
  const params = parseParams(header.value);
34
34
  if (!params) {
35
- throw new DkimParsingError(`Invalid DKIM header ${header}`);
35
+ throw new DkimParsingError(`Invalid DKIM header ${header.value}`);
36
36
  }
37
37
 
38
38
  if (!params.d) {
@@ -13,16 +13,13 @@ import {
13
13
  } from "viem";
14
14
 
15
15
  import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
16
- import { foundry, optimismSepolia } from "viem/chains";
16
+ import { foundry } from "viem/chains";
17
17
 
18
18
  import type { ContractSpec, ContractArg } from "types/ethereum";
19
19
 
20
- const rpcUrls: Map<number, HttpTransport> = new Map([
21
- [foundry.id, http()],
22
- [optimismSepolia.id, http("https://sepolia.optimism.io")],
23
- ]);
20
+ const rpcUrls: Map<number, HttpTransport> = new Map([[foundry.id, http()]]);
24
21
 
25
- export const chainIds = [foundry.id, optimismSepolia.id];
22
+ export const chainIds = [foundry.id];
26
23
 
27
24
  export function createAnvilClient(
28
25
  chainId: number = foundry.id,
@@ -7,7 +7,7 @@ import { type Abi, decodeFunctionResult } from "viem";
7
7
 
8
8
  function dropEmptyProofFromArgs(args: unknown) {
9
9
  if (Array.isArray(args)) {
10
- return args.slice(1);
10
+ return args.slice(1) as unknown[];
11
11
  }
12
12
  return [];
13
13
  }
@@ -39,6 +39,7 @@ export const createVlayerClient = (
39
39
  >();
40
40
 
41
41
  return {
42
+ // eslint-disable-next-line @typescript-eslint/require-await
42
43
  prove: async ({ address, functionName, chainId, proverAbi, args }) => {
43
44
  const result_promise = prove(
44
45
  address,
@@ -15,7 +15,6 @@ export type ContractArg =
15
15
  | string
16
16
  | boolean
17
17
  | bigint
18
- | Address
19
18
  | number[]
20
19
  | string[]
21
20
  | boolean[]
@@ -8,8 +8,6 @@ import {
8
8
  Hex,
9
9
  } from "viem";
10
10
 
11
- import { type ProverCallCommitment } from "types/webProofProvider.ts";
12
-
13
11
  type Calldata = string;
14
12
 
15
13
  export type CallParams = {
@@ -51,19 +49,16 @@ export type VlayerClient = {
51
49
  prove: <
52
50
  T extends readonly [AbiFunction, ...Abi[number][]],
53
51
  F extends ContractFunctionName<T>,
54
- >(
55
- args: VlayerClientProveArgs<T, F>,
56
- ) => Promise<{ hash: string }>;
52
+ >(args: {
53
+ address: Hex;
54
+ proverAbi: T;
55
+ functionName: F;
56
+ chainId: number;
57
+ args: ContractFunctionArgs<T, AbiStateMutability, F>;
58
+ }) => Promise<{ hash: string }>;
57
59
  waitForProvingResult: ({
58
60
  hash,
59
61
  }: {
60
62
  hash: string;
61
63
  }) => Promise<[Proof, ...unknown[]]>;
62
64
  };
63
-
64
- export type VlayerClientProveArgs<
65
- T extends readonly [AbiFunction, ...Abi[number][]],
66
- F extends ContractFunctionName<T>,
67
- > = ProverCallCommitment<T, F> & {
68
- args: ContractFunctionArgs<T, AbiStateMutability, F>;
69
- };
@@ -33,7 +33,7 @@ declare const chrome: {
33
33
  };
34
34
 
35
35
  // this id is fixed in the extension by the key in manifest.json
36
- const EXTENSION_ID = "ghigbilfcgeibjkkajaekabeldkmijcd";
36
+ const EXTENSION_ID = "jbchhcgphfokabmfacnkafoeeeppjmpl";
37
37
 
38
38
  export const createExtensionWebProofProvider = (
39
39
  {
@@ -23,12 +23,14 @@ export const enum ExtensionMessageType {
23
23
  ProofDone = "ProofDone",
24
24
  ProofError = "ProofError",
25
25
  RedirectBack = "RedirectBack",
26
+ TabOpened = "TabOpened",
26
27
  }
27
28
 
28
29
  export type ExtensionMessage =
29
30
  | { type: ExtensionMessageType.ProofDone; proof: WebProof }
30
31
  | { type: ExtensionMessageType.ProofError; error: string }
31
- | { type: ExtensionMessageType.RedirectBack };
32
+ | { type: ExtensionMessageType.RedirectBack }
33
+ | { type: ExtensionMessageType.TabOpened; tabId: number };
32
34
 
33
35
  export type WebProverSessionConfig = {
34
36
  notaryUrl: string;