Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(examples): adjust breaking changes and detect failures in ci (#1040)
Browse files Browse the repository at this point in the history
* dbg message

* update ci

* fix: examples

* ci: add examples build step and set chmod +x examples.sh

* echo filename

* fix: path to examples
  • Loading branch information
mattsse authored Mar 16, 2022
1 parent db331ee commit 5d14198
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,18 @@ jobs:
- uses: Swatinem/rust-cache@v1
with:
cache-on-failure: true
- name: Build all examples
run: |
export PATH=$HOME/bin:$PATH
for file in examples/*.rs; do
name="$(echo "$file" | cut -f 1 -d '.')"
echo "building $name"
cargo build -p ethers --example "$(basename "$name")"
done
- name: Run all examples
run: |
export PATH=$HOME/bin:$PATH
chmod +x ./scripts/examples.sh
./scripts/examples.sh
windows-build:
Expand Down
4 changes: 2 additions & 2 deletions examples/contract_human_readable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async fn main() -> Result<()> {
// compile the project and get the artifacts
let output = project.compile().unwrap();
let contract = output.find("SimpleStorage").expect("could not find contract").clone();
let (abi, bytecode, _) = contract.into_parts_or_default();
let (abi, bytecode, _) = contract.into_parts();

// 2. instantiate our wallet & ganache
let ganache = Ganache::new().spawn();
Expand All @@ -46,7 +46,7 @@ async fn main() -> Result<()> {
let client = Arc::new(client);

// 5. create a factory which will be used to deploy instances of the contract
let factory = ContractFactory::new(abi, bytecode, client.clone());
let factory = ContractFactory::new(abi.unwrap(), bytecode.unwrap(), client.clone());

// 6. deploy it with the constructor arguments
let contract = factory.deploy("initial value".to_string())?.legacy().send().await?;
Expand Down
9 changes: 4 additions & 5 deletions examples/moonbeam_with_abi.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
use ethers::prelude::*;
use eyre::Result;
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};

abigen!(
SimpleContract,
"./examples/contract_abi.json",
event_derives(serde::Deserialize, serde::Serialize)
);

const MOONBEAM_DEV_ENDPOINT: &str = "http://localhost:9933";

/// This requires a running moonbeam dev instance on `localhost:9933`
/// See `https://docs.moonbeam.network/builders/get-started/moonbeam-dev/` for reference
///
Expand All @@ -22,7 +18,10 @@ const MOONBEAM_DEV_ENDPOINT: &str = "http://localhost:9933";
/// Also requires the `legacy` feature to send Legacy transaction instead of an EIP-1559
#[tokio::main]
#[cfg(feature = "legacy")]
async fn main() -> Result<()> {
async fn main() -> eyre::Result<()> {
use std::{convert::TryFrom, path::Path, sync::Arc, time::Duration};
const MOONBEAM_DEV_ENDPOINT: &str = "http://localhost:9933";

// set the path to the contract, `CARGO_MANIFEST_DIR` points to the directory containing the
// manifest of `ethers`. which will be `../` relative to this file
let source = Path::new(&env!("CARGO_MANIFEST_DIR")).join("examples/contract.sol");
Expand Down
1 change: 1 addition & 0 deletions scripts/examples.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
set -e
# shellcheck shell=bash
# run all examples
for file in examples/*.rs; do
Expand Down

0 comments on commit 5d14198

Please sign in to comment.