@vlayer/sdk 0.1.0-nightly-20241023-a7e98bb → 0.1.0-nightly-20241028-591419e

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-20241023-a7e98bb",
5
+ "version": "0.1.0-nightly-20241028-591419e",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  type Abi,
3
+ Account,
3
4
  type Address,
4
5
  type Chain,
5
6
  type ContractFunctionArgs,
@@ -11,6 +12,7 @@ import {
11
12
  publicActions,
12
13
  PublicClient,
13
14
  walletActions,
15
+ WriteContractParameters,
14
16
  } from "viem";
15
17
 
16
18
  import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
@@ -139,13 +141,21 @@ export async function writeContract<
139
141
  const selectedSender = sender || (await ethClient.getAddresses())[0];
140
142
 
141
143
  const txHash = await ethClient.writeContract({
142
- abi: abi as Abi,
143
144
  address,
145
+ abi: abi as Abi,
144
146
  functionName,
145
147
  args: args as readonly unknown[],
146
148
  chain,
147
149
  account: selectedSender,
148
- });
150
+ chainOverride: undefined,
151
+ } as WriteContractParameters<
152
+ Abi,
153
+ ContractFunctionName<Abi, "nonpayable" | "payable">,
154
+ ContractFunctionArgs<Abi, "nonpayable" | "payable", F>,
155
+ Chain | undefined,
156
+ Account | undefined,
157
+ Chain | undefined
158
+ >);
149
159
 
150
160
  const txReceipt = await ethClient.waitForTransactionReceipt({ hash: txHash });
151
161
 
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  Abi,
3
- AbiFunction,
4
3
  AbiStateMutability,
5
4
  Address,
6
5
  ContractFunctionArgs,
@@ -46,10 +45,7 @@ export interface VCallResponse {
46
45
  }
47
46
 
48
47
  export type VlayerClient = {
49
- prove: <
50
- T extends readonly [AbiFunction, ...Abi[number][]],
51
- F extends ContractFunctionName<T>,
52
- >(args: {
48
+ prove: <T extends Abi, F extends ContractFunctionName<T>>(args: {
53
49
  address: Hex;
54
50
  proverAbi: T;
55
51
  functionName: F;
@@ -1,4 +1,4 @@
1
- import { AbiFunction, Hex, Abi, ContractFunctionName } from "viem";
1
+ import { Hex, Abi, ContractFunctionName } from "viem";
2
2
  import type { ContractFunctionArgsWithout } from "./viem";
3
3
  import { Branded, WebProof, WebProofStep } from "../../../web-proof-commons";
4
4
 
@@ -15,7 +15,7 @@ export type WebProofSetup = Branded<
15
15
  >;
16
16
 
17
17
  export type ProverCallCommitment<
18
- T extends readonly [AbiFunction, ...Abi[number][]],
18
+ T extends Abi,
19
19
  F extends ContractFunctionName<T>,
20
20
  > = {
21
21
  address: Hex;
@@ -26,17 +26,14 @@ export type ProverCallCommitment<
26
26
  };
27
27
 
28
28
  export type GetWebProofArgs<
29
- T extends readonly [AbiFunction, ...Abi[number][]],
29
+ T extends Abi,
30
30
  F extends ContractFunctionName<T>,
31
31
  > = {
32
32
  proverCallCommitment: ProverCallCommitment<T, F>;
33
33
  } & WebProofSetupInput;
34
34
 
35
35
  export type WebProofProvider = {
36
- getWebProof: <
37
- T extends readonly [AbiFunction, ...Abi[number][]],
38
- F extends ContractFunctionName<T>,
39
- >(
36
+ getWebProof: <T extends Abi, F extends ContractFunctionName<T>>(
40
37
  args: GetWebProofArgs<T, F>,
41
38
  ) => Promise<WebProof>;
42
39
  };
package/src/api/prover.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import {
2
2
  type Abi,
3
- AbiFunction,
4
3
  AbiStateMutability,
5
4
  type Address,
6
5
  ContractFunctionArgs,
@@ -12,10 +11,7 @@ import { type CallContext, type CallParams } from "types/vlayer";
12
11
  import { v_call } from "./v_call";
13
12
  import { foundry } from "viem/chains";
14
13
 
15
- export async function prove<
16
- T extends readonly [AbiFunction, ...Abi[number][]],
17
- F extends ContractFunctionName<T>,
18
- >(
14
+ export async function prove<T extends Abi, F extends ContractFunctionName<T>>(
19
15
  prover: Address,
20
16
  abi: T,
21
17
  functionName: F,