ethers-rs/scripts/examples.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

43 lines
1.4 KiB
Bash
Raw Normal View History

refactor: examples (#1940) * ToC * Big numbers section * Middleware examples: builder * Middleware examples: gas_escalator * Middleware examples: gas_oracle * Middleware examples: signer * Middleware examples: missing stubs * review: applied DaniPopes suggestions to big numbers * typo * Middleware examples: nonce_manager * cargo +nightly fmt * update roadmap * Middleware examples: policy * Middleware examples: added docs * Contracts examples: created folder; included abigen example * Contracts examples: refactor abigen docs. Fixed cargo example reference * Contracts examples: contract_events; minor docs changes * Moved each example under its own crate. Cargo builds locally TODO: Fix broken examples CI * Big numbers examples: used regular operators for math * Single examples run correctly (missing overall CI execution) Example crates dependencies Removed duplicates * review: Applied gakonst note to remove commented items in workspace manifest * review: Applied gakonst note to restore visibility on contract constructor * ci: - Run/Build examples in a single step to avoid duplicated scripts - Removed ci.yaml step "Build all examples" * cargo +nightly fmt * ci: fix WASM step error * Removed deprecated EthGasStation example * WASM example uses local copy of `contract_abi.json`. In this way we keep the WASM example auto-consistent, at the cost of a small duplication * Cargo.lock aligned to master branch * Removed useless comments in examples * review: Applied gakonst note to add panic!() on the policy middleware example * review: Applied gakonst suggestion to add a custom middleware example * typos in docs * Update examples/big-numbers/examples/bn_math_operations.rs review: Accepted commit suggested by DaniPopes Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: Applied DaniPopes suggestion on assert_eq! * Update examples/big-numbers/README.md review: Accepted DaniPopes suggestion on big-numbers docs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: All imports now reference the "ethers" crate * ci: added features ["ws", "rustls"] where needed cargo +nigthly fmt * Examples with special features (e.g. ipc, trezor etc.) are built alongside them. This is expressed as a "default" requirement in their respective Cargo.toml * cargo +nightly fmt * Examples: Gas oracle API keys from env Added missing features in middleware Cargo.toml * typo: use expect() instead of unwrap() * Updated ToC Moved 2 examples under more relevant folders * Gas oracle examples raise panic on middleware errors * review: removed useless [[example]] in Cargo.toml * review: removed #[allow(unused_must_use)] from gas_escalator example * review: Removed prefixes from file names * review: removed useless [[example]] in Cargo.toml * docs: Updated description to run examples in the workspace README.md Co-authored-by: Andrea Simeoni <> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
2022-12-29 12:53:11 +00:00
#!/bin/bash
set -e; # Fail fast
# shellcheck shell=bash
# examples that we can't run because they require some additional infra, docker or ledger for example
ignored=(
refactor: examples (#1940) * ToC * Big numbers section * Middleware examples: builder * Middleware examples: gas_escalator * Middleware examples: gas_oracle * Middleware examples: signer * Middleware examples: missing stubs * review: applied DaniPopes suggestions to big numbers * typo * Middleware examples: nonce_manager * cargo +nightly fmt * update roadmap * Middleware examples: policy * Middleware examples: added docs * Contracts examples: created folder; included abigen example * Contracts examples: refactor abigen docs. Fixed cargo example reference * Contracts examples: contract_events; minor docs changes * Moved each example under its own crate. Cargo builds locally TODO: Fix broken examples CI * Big numbers examples: used regular operators for math * Single examples run correctly (missing overall CI execution) Example crates dependencies Removed duplicates * review: Applied gakonst note to remove commented items in workspace manifest * review: Applied gakonst note to restore visibility on contract constructor * ci: - Run/Build examples in a single step to avoid duplicated scripts - Removed ci.yaml step "Build all examples" * cargo +nightly fmt * ci: fix WASM step error * Removed deprecated EthGasStation example * WASM example uses local copy of `contract_abi.json`. In this way we keep the WASM example auto-consistent, at the cost of a small duplication * Cargo.lock aligned to master branch * Removed useless comments in examples * review: Applied gakonst note to add panic!() on the policy middleware example * review: Applied gakonst suggestion to add a custom middleware example * typos in docs * Update examples/big-numbers/examples/bn_math_operations.rs review: Accepted commit suggested by DaniPopes Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: Applied DaniPopes suggestion on assert_eq! * Update examples/big-numbers/README.md review: Accepted DaniPopes suggestion on big-numbers docs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: All imports now reference the "ethers" crate * ci: added features ["ws", "rustls"] where needed cargo +nigthly fmt * Examples with special features (e.g. ipc, trezor etc.) are built alongside them. This is expressed as a "default" requirement in their respective Cargo.toml * cargo +nightly fmt * Examples: Gas oracle API keys from env Added missing features in middleware Cargo.toml * typo: use expect() instead of unwrap() * Updated ToC Moved 2 examples under more relevant folders * Gas oracle examples raise panic on middleware errors * review: removed useless [[example]] in Cargo.toml * review: removed #[allow(unused_must_use)] from gas_escalator example * review: Removed prefixes from file names * review: removed useless [[example]] in Cargo.toml * docs: Updated description to run examples in the workspace README.md Co-authored-by: Andrea Simeoni <> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
2022-12-29 12:53:11 +00:00
"examples-contracts:deploy_moonbeam"
"examples-providers:ipc"
"examples-wallets:ledger"
"examples-wallets:trezor"
"examples-wallets:yubi"
"examples-transactions:remove_liquidity"
)
refactor: examples (#1940) * ToC * Big numbers section * Middleware examples: builder * Middleware examples: gas_escalator * Middleware examples: gas_oracle * Middleware examples: signer * Middleware examples: missing stubs * review: applied DaniPopes suggestions to big numbers * typo * Middleware examples: nonce_manager * cargo +nightly fmt * update roadmap * Middleware examples: policy * Middleware examples: added docs * Contracts examples: created folder; included abigen example * Contracts examples: refactor abigen docs. Fixed cargo example reference * Contracts examples: contract_events; minor docs changes * Moved each example under its own crate. Cargo builds locally TODO: Fix broken examples CI * Big numbers examples: used regular operators for math * Single examples run correctly (missing overall CI execution) Example crates dependencies Removed duplicates * review: Applied gakonst note to remove commented items in workspace manifest * review: Applied gakonst note to restore visibility on contract constructor * ci: - Run/Build examples in a single step to avoid duplicated scripts - Removed ci.yaml step "Build all examples" * cargo +nightly fmt * ci: fix WASM step error * Removed deprecated EthGasStation example * WASM example uses local copy of `contract_abi.json`. In this way we keep the WASM example auto-consistent, at the cost of a small duplication * Cargo.lock aligned to master branch * Removed useless comments in examples * review: Applied gakonst note to add panic!() on the policy middleware example * review: Applied gakonst suggestion to add a custom middleware example * typos in docs * Update examples/big-numbers/examples/bn_math_operations.rs review: Accepted commit suggested by DaniPopes Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: Applied DaniPopes suggestion on assert_eq! * Update examples/big-numbers/README.md review: Accepted DaniPopes suggestion on big-numbers docs Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com> * review: All imports now reference the "ethers" crate * ci: added features ["ws", "rustls"] where needed cargo +nigthly fmt * Examples with special features (e.g. ipc, trezor etc.) are built alongside them. This is expressed as a "default" requirement in their respective Cargo.toml * cargo +nightly fmt * Examples: Gas oracle API keys from env Added missing features in middleware Cargo.toml * typo: use expect() instead of unwrap() * Updated ToC Moved 2 examples under more relevant folders * Gas oracle examples raise panic on middleware errors * review: removed useless [[example]] in Cargo.toml * review: removed #[allow(unused_must_use)] from gas_escalator example * review: Removed prefixes from file names * review: removed useless [[example]] in Cargo.toml * docs: Updated description to run examples in the workspace README.md Co-authored-by: Andrea Simeoni <> Co-authored-by: DaniPopes <57450786+DaniPopes@users.noreply.github.com>
2022-12-29 12:53:11 +00:00
example_crates=$(cargo metadata --format-version 1 |
jq -c '.workspace_members' |
jq -r 'map(select(startswith("examples")) |
sub("\\s.*$";"")) | .[]')
for crate in $example_crates; do
# Remove "examples-" prefix from crate name (e.g. examples-contracts => contracts)
cratedir="${crate#examples-}"
srcdir="examples/$cratedir/examples"
# Retrieve all example files in crate:
# Transform the absolute path into the filename (e.g. some-path/deploy_anvil.rs => deploy_anvil)
example_files=$(find $srcdir -type f -name '*.rs' -exec basename {} \; | sed 's/\.[^.]*$//')
for file in $example_files; do
# Build the example
echo "Building example: $crate:$file"
cargo build -p $crate --example $file
# Run the example
if [[ "${ignored[*]}" =~ $(basename "$crate:$file") ]]; then
echo "skipping: $crate:$file"
continue
fi
echo "running $crate:$file"
cargo run -p $crate --example $file
done
done