@vlayer/sdk 0.1.0-nightly-20241003-7adc869 → 0.1.0-nightly-20241003-fda6b77

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
  "module": "src/index.ts",
5
- "version": "0.1.0-nightly-20241003-7adc869",
5
+ "version": "0.1.0-nightly-20241003-fda6b77",
6
6
  "types": "src/index.ts",
7
7
  "scripts": {
8
8
  "build": "npm run gen:types",
@@ -17,14 +17,12 @@ import { foundry } from "viem/chains";
17
17
 
18
18
  import type { ContractSpec, ContractArg } from "types/ethereum";
19
19
 
20
- export const testChainId1 = 100001;
20
+ const rpcUrls: Map<number, HttpTransport> = new Map([[foundry.id, http()]]);
21
21
 
22
- const rpcUrls: Map<number, HttpTransport> = new Map([[testChainId1, http()]]);
23
-
24
- export const chainIds = [testChainId1];
22
+ export const chainIds = [foundry.id];
25
23
 
26
24
  export function client(
27
- chainId: number = testChainId1,
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 = testChainId1,
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 = testChainId1,
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 = testChainId1,
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 = testChainId1,
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 = testChainId1,
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 = testChainId1,
29
+ chainId: number = foundry.id,
30
30
  ) {
31
31
  const calldata = encodeFunctionData({
32
32
  abi: abi as Abi,