Skip to content

Commit 1a599c4

Browse files
committedJan 14, 2025
getting crypto error
1 parent 6b5cd6c commit 1a599c4

File tree

6 files changed

+82
-49
lines changed

6 files changed

+82
-49
lines changed
 

‎packages/cli/.env.example

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CHAIN_ID=1337
2+
RPC_URL=http://127.0.0.1:8545
3+
PRIVKEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

‎packages/cli/lib/constants.ts

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
import { join } from "path";
22

3-
const CHAIN_ID = "31337";
43
const CONTRACT_NAME = "Walnut";
5-
const CONTRACT_DIR = join(__dirname, "../../../contracts");
4+
const CONTRACT_DIR = join(__dirname, "../../contracts");
65

7-
const BROADCAST_FILE = join(
8-
CONTRACT_DIR,
9-
"broadcast",
10-
`${CONTRACT_NAME}.s.sol`,
11-
CHAIN_ID,
12-
"run-latest.json",
13-
);
14-
const ABI_FILE = join(
15-
CONTRACT_DIR,
16-
"out",
17-
`${CONTRACT_NAME}.sol`,
18-
`${CONTRACT_NAME}.json`,
19-
);
20-
21-
export { BROADCAST_FILE, ABI_FILE };
6+
export { CONTRACT_NAME, CONTRACT_DIR };

‎packages/cli/src/app.ts

+20-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {
22
createShieldedWalletClient,
3+
getShieldedContract,
34
type ShieldedContract,
45
type ShieldedWalletClient,
56
} from "seismic-viem";
6-
import { Chain, http } from "viem";
7+
import { Abi, Address, Chain, http } from "viem";
78

89
import {
910
getShieldedContractWithCheck,
@@ -18,8 +19,8 @@ interface AppConfig {
1819
privateKey: string;
1920
};
2021
contract: {
21-
abiFile: string;
22-
broadcastFile: string;
22+
abi: Abi;
23+
address: Address;
2324
};
2425
}
2526

@@ -42,13 +43,26 @@ export class App {
4243

4344
this.contract = await getShieldedContractWithCheck(
4445
this.walletClient,
45-
readContractABI(this.config.contract.abiFile),
46-
readContractAddress(this.config.contract.broadcastFile),
46+
this.config.contract.abi,
47+
this.config.contract.address,
4748
);
49+
console.log("contract", this.contract);
50+
51+
52+
const walletClient1 = await createShieldedWalletClient({
53+
chain: this.config.wallet.chain,
54+
transport: http(this.config.wallet.rpcUrl),
55+
privateKey: this.config.wallet.privateKey as `0x${string}`,
56+
});
57+
const contract1 = getShieldedContract({
58+
abi: this.config.contract.abi,
59+
address: this.config.contract.address,
60+
client: walletClient1,
61+
});
62+
console.log("contract1", contract1);
4863
}
4964

5065
async reset() {
51-
console.log("- Writing reset()");
5266
await this.walletClient.waitForTransactionReceipt({
5367
hash: await this.contract.write.reset(),
5468
});

‎packages/cli/src/index.ts

+54-23
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,68 @@
11
import dotenv from "dotenv";
2+
import { join } from "path";
23
dotenv.config();
34

4-
import { seismicDevnet } from "seismic-viem";
5+
import { createShieldedWalletClient, getShieldedContract, seismicDevnet } from "seismic-viem";
56

67
import { App } from "./app";
7-
import { BROADCAST_FILE, ABI_FILE } from "../lib/constants";
8+
import { CONTRACT_NAME, CONTRACT_DIR } from "../lib/constants";
9+
import { readContractAddress, readContractABI } from "../lib/utils";
10+
import { http } from "viem";
11+
import { anvil } from "viem/chains";
812

913
async function main() {
10-
if (!process.env.RPC_URL || !process.env.ALICE_PRIVKEY) {
14+
if (!process.env.CHAIN_ID || !process.env.RPC_URL || !process.env.PRIVKEY) {
1115
console.error("Please set your environment variables.");
1216
process.exit(1);
1317
}
1418

15-
const app = new App({
16-
wallet: {
17-
chain: seismicDevnet,
18-
rpcUrl: process.env.RPC_URL,
19-
privateKey: process.env.ALICE_PRIVKEY,
20-
},
21-
contract: {
22-
abiFile: ABI_FILE,
23-
broadcastFile: BROADCAST_FILE,
24-
},
25-
});
26-
await app.init();
27-
28-
await app.reset();
29-
await app.shake();
30-
await app.shake();
31-
await app.hit();
32-
await app.shake();
33-
await app.hit();
34-
await app.look();
19+
const broadcastFile = join(
20+
CONTRACT_DIR,
21+
"broadcast",
22+
`${CONTRACT_NAME}.s.sol`,
23+
process.env.CHAIN_ID,
24+
"run-latest.json",
25+
);
26+
const abiFile = join(
27+
CONTRACT_DIR,
28+
"out",
29+
`${CONTRACT_NAME}.sol`,
30+
`${CONTRACT_NAME}.json`,
31+
);
32+
33+
// const walletClient = await createShieldedWalletClient({
34+
// chain: anvil,
35+
// transport: http(process.env.RPC_URL),
36+
// privateKey: process.env.PRIVKEY as `0x${string}`,
37+
// });
38+
// const contract = getShieldedContract({
39+
// abi: readContractABI(abiFile),
40+
// address: readContractAddress(broadcastFile),
41+
// client: walletClient,
42+
// });
43+
// await contract.write.reset();
44+
// console.log("contract", contract);
45+
46+
// const app = new App({
47+
// wallet: {
48+
// chain: seismicDevnet,
49+
// rpcUrl: process.env.RPC_URL,
50+
// privateKey: process.env.PRIVKEY,
51+
// },
52+
// contract: {
53+
// abi: readContractABI(abiFile),
54+
// address: readContractAddress(broadcastFile),
55+
// },
56+
// });
57+
// await app.init();
58+
59+
// await app.reset();
60+
// await app.shake();
61+
// await app.shake();
62+
// await app.hit();
63+
// await app.shake();
64+
// await app.hit();
65+
// await app.look();
3566
}
3667

3768
main();

‎packages/contracts/.env.example

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
RPC_URL=127.0.0.1:8545
2-
DEPLOYER_PRIVKEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
1+
RPC_URL=http://127.0.0.1:8545
2+
PRIVKEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

‎packages/contracts/script/Walnut.s.sol

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ contract WalnutScript is Script {
88
Walnut public walnut;
99

1010
function run() public {
11-
uint256 deployerPrivateKey = vm.envUint("DEPLOYER_PRIVKEY");
11+
uint256 deployerPrivateKey = vm.envUint("PRIVKEY");
1212

1313
vm.startBroadcast(deployerPrivateKey);
1414
walnut = new Walnut(2, suint256(0));

0 commit comments

Comments
 (0)
Please sign in to comment.