Skip to content

Latest commit

 

History

History
79 lines (53 loc) · 2.47 KB

File metadata and controls

79 lines (53 loc) · 2.47 KB

Developer Notes

This is a set of random tips for working on this repo.

Creating a new contract

Make sure you have the dependencies installed:

cargo install cargo-generate --features vendored-openssl

Now, create the project using CosmWasm 1.5. The placeholder $DIR_NAME is the shortened name, like tasks and $CRATE_NAME is the full name for crates.io, like lavs-tasks or lay3r-staking

cd contracts # or contracts/avs, etc
cargo generate --git https://github.com/Lay3rLabs/cw-template.git -b slay3r -d minimal=true --name $CRATE_NAME
mv $CRATE_NAME $DIR_NAME
cd $DIR_NAME

# verify code compiles
cargo build
cargo test

# THIS MUST BE RUN IN WORKSPACE ROOT
./scripts/optimizer.sh

# try full-stack tests with golem (needs actual wasm)
cargo test --features golem

Importing Private Repos

We want to use layer-* packages which are in a remote private repo. This is fine on dev machines, as long as they have access. But this breaks both the Github Actions CI as well as the optimizer.sh wasm build script.

Common Steps

Create private key:

# (Don't use url comment like declared in ssh-agent docs... it confuses cargo)
ssh-keygen -f ~/.ssh/id_gh_lay3r_deploy -t ed25519 -m pem -C 'CI Deploy Key'

Make it deploy key:

  • Go to GitHub settings of the dependency to add a new deploy key
  • Title: "CI Deploy Key"
  • Key: output of cat ~/.ssh/id_gh_lay3r_deploy.pub

Github Actions

Follow the instructions from webfactory/ssh-agent.

  • Go to GitHub settings of this repo to set Actions secrets
  • Add new repository secret
  • Title: SSH_PRIVATE_KEY
  • Key: output of cat ~/.ssh/id_gh_lay3r_deploy

Then we add webfactory/ssh-agent@v0.9.0 to the top of every github actions job to provide access to this key to read the repo

Docker image

./scripts/optimize.sh has been updated to handle the repos. It passes the $SSH_AUTH_SOCK to the build container, so it can pull any repos with your active dev keys.

MacOS extra steps

Add keys to the launchd managed ssh-agent (source).

SSH_AUTH_SOCK=`launchctl getenv SSH_AUTH_SOCK` ssh-add

Then run ./scripts/optimize.sh.