@vlayer/sdk 0.1.0-nightly-20241022-004c3c4 → 0.1.0-nightly-20241028-74b5b0d
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
package/src/api/helpers.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import {
|
2
2
|
type Abi,
|
3
|
+
Account,
|
3
4
|
type Address,
|
5
|
+
type Chain,
|
4
6
|
type ContractFunctionArgs,
|
5
7
|
type ContractFunctionName,
|
6
8
|
createTestClient,
|
@@ -10,6 +12,7 @@ import {
|
|
10
12
|
publicActions,
|
11
13
|
PublicClient,
|
12
14
|
walletActions,
|
15
|
+
WriteContractParameters,
|
13
16
|
} from "viem";
|
14
17
|
|
15
18
|
import { privateKeyToAccount, generatePrivateKey } from "viem/accounts";
|
@@ -132,20 +135,27 @@ export async function writeContract<
|
|
132
135
|
functionName: F,
|
133
136
|
args: ContractFunctionArgs<T, "payable" | "nonpayable", F>,
|
134
137
|
sender?: Address,
|
135
|
-
|
138
|
+
chain: Chain = foundry,
|
136
139
|
) {
|
137
|
-
const ethClient = createAnvilClient(
|
140
|
+
const ethClient = createAnvilClient(chain.id);
|
138
141
|
const selectedSender = sender || (await ethClient.getAddresses())[0];
|
139
142
|
|
140
143
|
const txHash = await ethClient.writeContract({
|
141
|
-
abi,
|
142
144
|
address,
|
145
|
+
abi: abi as Abi,
|
143
146
|
functionName,
|
144
|
-
args,
|
147
|
+
args: args as readonly unknown[],
|
148
|
+
chain,
|
145
149
|
account: selectedSender,
|
146
|
-
|
147
|
-
} as
|
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 {
|
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
|
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
|
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,
|