@@ -18,117 +18,90 @@ Create a new project using this template:
1818
1919``` bash
2020# If you don't have forge: `curl -L https://foundry.paradigm.xyz | bash`
21-
2221forge init --template Lay3rLabs/wavs-foundry-template my-wavs
2322```
2423
25- ## Testing
26-
27- Given the repository contains both Solidity and Rust code, there's 2 different
28- workflows.
29-
30- ### Setting up the Environment
31-
32- Initialize the submodule dependencies:
24+ ### Solidity
3325
3426``` bash
27+ # Initialize the submodule dependencies
3528forge install
36- ```
37-
38- Build the contracts:
3929
40- ``` bash
30+ # Build the contracts
4131forge build
42- ```
43-
44- Run the tests:
4532
46- ``` bash
33+ # Run the solidity tests. alias: `make test`
4734forge test
4835```
4936
50- ## Rust
37+ > You can also use ` make build ` to build the contracts, bindings, and components.
5138
52- Rust bindings to the contracts can be generated via ` forge bind ` , which requires
53- first building your contracts:
39+ ## Rust
5440
5541``` bash
42+ # Generate new bindings from your contract(s)
5643make bindings
57- ```
58-
59- Then, you can run the tests:
6044
61- ``` bash
62- cargo test
45+ # Run rust tests
46+ make test
6347```
6448
6549## WAVS
6650
67- Build the latest solidity:
51+ ### Install the WAVS CLI
6852
6953``` bash
70- make build
71- ```
72-
73- Install the WAVS CLI:
74-
75- ``` bash
76- # MacOS: if you get permission errors: eval `ssh-agent -s`; ssh-add
54+ # MacOS: if you get permission errors: eval `ssh-agent -s` && ssh-add
7755(cd lib/WAVS; cargo install --path ./packages/cli)
7856```
7957
58+ ### Start Anvil, WAVS, and Deploy Eigenlayer
59+
8060``` bash
61+ # copy over the .env file
8162cp .env.example .env
8263
8364# [!] Get your key from: https://openweathermap.org/
8465# Update the WAVS_ENV_OPEN_WEATHER_API_KEY in the .env file with your key`
8566
86- cp ./lib/WAVS/packages/wavs/wavs.toml .
87- cp ./lib/WAVS/packages/cli/cli.toml .
88-
8967# MacOS Docker:
9068# Docker Engine -> Settings -> Resources -> Network -> 'Enable Host Networking'
9169# or
9270# brew install chipmk/tap/docker-mac-net-connect && sudo brew services start chipmk/tap/docker-mac-net-connect
93-
94- # TODO: this is a temp workaround for MacOS (running anvil out of compose)
95- anvil
96-
97- docker compose up --build
71+ make start-all
9872```
9973
100- Deploy Eigenlayer and upload your WAVS Service contract
74+ ### Upload your WAVS Service Manager
10175
10276``` bash
103- docker_cmd=" docker exec -it wavs bash -c"
104- export CLI_EIGEN_CORE_DELEGATION_MANAGER=` ${docker_cmd} ' jq -r .eigen_core.local.delegation_manager ~/wavs/cli/deployments.json' | tr -d ' \r' `
105- export CLI_EIGEN_CORE_REWARDS_COORDINATOR=` ${docker_cmd} ' jq -r .eigen_core.local.rewards_coordinator ~/wavs/cli/deployments.json' | tr -d ' \r' `
106- export CLI_EIGEN_CORE_AVS_DIRECTORY=` ${docker_cmd} ' jq -r .eigen_core.local.avs_directory ~/wavs/cli/deployments.json' | tr -d ' \r' `
107- export FOUNDRY_ANVIL_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
108-
77+ # Deploy (override: FOUNDRY_ANVIL_PRIVATE_KEY)
10978forge script ./script/WavsServiceManager.s.sol --rpc-url http://localhost:8545 --broadcast
11079
111- # set this in the your terminal from the script output
112- export SERVICE_MANAGER_ADDRESS=0x851356ae760d987E095750cCeb3bC6014560891C
80+ # Grab deployed service manager address by name
81+ BROADCAST_FILE=./broadcast/WavsServiceManager.s.sol/31337/run-latest.json
82+ export SERVICE_MANAGER_ADDRESS=` jq -r ' .transactions[] | select(.contractName == "WavsServiceManager") | .contractAddress' " ${BROADCAST_FILE} " `
83+ echo " Service Manager Address: $SERVICE_MANAGER_ADDRESS "
11384```
11485
115- Build WAVS WASI component(s)
86+ ### Build WASI components
87+
88+ > Install ` cargo binstall cargo-component ` if you have not already. -- https://github.com/bytecodealliance/cargo-component#installation
11689
11790``` bash
118- # build all components/*
119- # https://github.com/bytecodealliance/cargo-component#installation / cargo binstall cargo-component
12091make wasi-build
12192
122- # Verify execution works as expected without deploying
12393# TODO: currently broken upstream
94+ # Verify execution works as expected without deploying
12495# wavs-cli exec --component $(pwd)/compiled/eth_trigger_weather.wasm --input Nashville,TN
12596```
12697
127- Deploy service and verify with adding a task
98+ ## Deploy Service and Verify
12899
129100``` bash
101+ # add read-write access
130102sudo chmod 0666 .docker/cli/deployments.json
131103
104+ # Contract trigger function signature to listen for
132105trigger_event=$( cast sig-event " NewTrigger(bytes)" ) ; echo $trigger_event
133106
134107service_info=` wavs-cli deploy-service --log-level=error --data ./.docker/cli --component $( pwd) /compiled/eth_trigger_weather.wasm \
@@ -139,10 +112,11 @@ service_info=`wavs-cli deploy-service --log-level=error --data ./.docker/cli --c
139112
140113echo " Service info: $service_info "
141114
115+ # Submit AVS request -> chain
142116SERVICE_ID=` echo $service_info | jq -r .service[0]` ; echo " Service ID: $SERVICE_ID "
143117wavs-cli add-task --input " Nashville,TN" --data ./.docker/cli --service-id ${SERVICE_ID}
144118
145- # Where the call address is the service manager in ./.docker/cli/deployments.json
119+ # Grab data from the contract directly
146120hex_bytes=$( cast decode-abi " getData(uint64)(bytes)" ` cast call ${SERVICE_MANAGER_ADDRESS} " getData(uint64)" 1` )
147121echo ` cast --to-ascii $hex_bytes `
148122```
0 commit comments