@vlayer/sdk 0.1.0-nightly-20241003-ad46150 → 0.1.0-nightly-20241003-23d0e97
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 +1 -1
- package/src/api/helpers.ts +8 -10
- package/src/api/prover.ts +2 -2
package/package.json
CHANGED
package/src/api/helpers.ts
CHANGED
@@ -17,14 +17,12 @@ import { foundry } from "viem/chains";
|
|
17
17
|
|
18
18
|
import type { ContractSpec, ContractArg } from "types/ethereum";
|
19
19
|
|
20
|
-
|
20
|
+
const rpcUrls: Map<number, HttpTransport> = new Map([[foundry.id, http()]]);
|
21
21
|
|
22
|
-
const
|
23
|
-
|
24
|
-
export const chainIds = [testChainId1];
|
22
|
+
export const chainIds = [foundry.id];
|
25
23
|
|
26
24
|
export function client(
|
27
|
-
chainId: number =
|
25
|
+
chainId: number = foundry.id,
|
28
26
|
): ReturnType<typeof walletActions> & PublicClient {
|
29
27
|
const transport = rpcUrls.get(chainId);
|
30
28
|
if (transport == undefined) {
|
@@ -43,7 +41,7 @@ export function client(
|
|
43
41
|
export async function deployContract(
|
44
42
|
contractSpec: ContractSpec,
|
45
43
|
args: ContractArg[] = [],
|
46
|
-
chainId: number =
|
44
|
+
chainId: number = foundry.id,
|
47
45
|
): Promise<Address> {
|
48
46
|
const ethClient = client(chainId);
|
49
47
|
|
@@ -84,7 +82,7 @@ export async function deployProverVerifier<P extends Abi, V extends Abi>(
|
|
84
82
|
prover?: ContractArg[];
|
85
83
|
verifier?: Tail<ContractArg>[];
|
86
84
|
} = {},
|
87
|
-
chainId: number =
|
85
|
+
chainId: number = foundry.id,
|
88
86
|
) {
|
89
87
|
console.log("Deploying prover");
|
90
88
|
const proverAddress = await deployContract(
|
@@ -113,7 +111,7 @@ export async function call<
|
|
113
111
|
address: Address,
|
114
112
|
functionName: F,
|
115
113
|
args?: ContractFunctionArgs<T, "pure" | "view", F>,
|
116
|
-
chainId: number =
|
114
|
+
chainId: number = foundry.id,
|
117
115
|
) {
|
118
116
|
const ethClient = client(chainId);
|
119
117
|
|
@@ -134,7 +132,7 @@ export async function writeContract<
|
|
134
132
|
functionName: F,
|
135
133
|
args: ContractFunctionArgs<T, "payable" | "nonpayable", F>,
|
136
134
|
sender?: Address,
|
137
|
-
chainId: number =
|
135
|
+
chainId: number = foundry.id,
|
138
136
|
) {
|
139
137
|
const ethClient = client(chainId);
|
140
138
|
const selectedSender = sender || (await ethClient.getAddresses())[0];
|
@@ -161,5 +159,5 @@ export async function writeContract<
|
|
161
159
|
export const getTestAccount = () => privateKeyToAccount(generatePrivateKey());
|
162
160
|
|
163
161
|
export const getTestAddresses = (
|
164
|
-
chainId: number =
|
162
|
+
chainId: number = foundry.id,
|
165
163
|
): Promise<Address[]> => client(chainId).getAddresses();
|
package/src/api/prover.ts
CHANGED
@@ -11,8 +11,8 @@ import {
|
|
11
11
|
|
12
12
|
import { type CallContext, type CallParams } from "types/vlayer";
|
13
13
|
import { v_call } from "./v_call";
|
14
|
-
import { testChainId1 } from "./helpers";
|
15
14
|
import { ContractSpec } from "types/ethereum";
|
15
|
+
import { foundry } from "viem/chains";
|
16
16
|
|
17
17
|
export async function getContractSpec(file: string): Promise<ContractSpec> {
|
18
18
|
return Bun.file(file).json();
|
@@ -26,7 +26,7 @@ export async function prove<
|
|
26
26
|
abi: T,
|
27
27
|
functionName: F,
|
28
28
|
args: ContractFunctionArgs<T, AbiStateMutability, F>,
|
29
|
-
chainId =
|
29
|
+
chainId: number = foundry.id,
|
30
30
|
) {
|
31
31
|
const calldata = encodeFunctionData({
|
32
32
|
abi: abi as Abi,
|