Skip to content

hyperlane-xyz/fuel-contracts

Repository files navigation

Hyperlane Fuel / Sway contracts

Getting set up

Follow the Sway book's installation instructions.

Building and testing everything

To build all packages:

forc build && cargo build

To test all packages:

forc test && cargo test

How to work in this repo

A package defines a single contract, and possibly many libraries.

Libraries that require testing should be implemented in their own package, and another test package should exist with the same name and a suffix -test.

There are two types of tests in Fuel/Sway - unit tests that are implemented fully in Sway, and "integration tests" in Rust that involve deploying contracts and making calls against them. Unit tests are not fully built out, so we instead opt for Rust-based tests. See the Sway book for more info. See Testing with Rust to set up Rust tests in a new package.

To build a single package, from its directory:

forc build

To test a single package, from its directory run the following. This requires Rust integration tests to be present. Add on -- --nocapture to observe logs.

cargo test

To format a package:

forc fmt

Fuel / Sway resources

  • Sway book - recommend reading this in its entirety
  • Fuel book - Higher level intro to Fuel
  • Fuel docs - Concepts section is the most useful part here. Not 100% sure if this is describing v1 or v2 of Fuel though.
  • Fuel specs - rather specific, good for searching for specific things
  • Sway std lib - great for existing Sway patterns & understanding the std lib
  • Fuel Rust SDK book - good for understanding how to interact with Fuel/Sway contracts via the Rust SDK
  • Fuel Discord - find invite on the Fuel site. Great for specific issues / questions

Troubleshooting

If cargo build or cargo test fails with a message like:

attempted ssh-agent authentication, but no usernames succeeded: `git`

Try following these instructions: rust-lang/cargo#3381 (comment)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published