FuelLabs/sway-libs

Issue Building Example from sway-libs Repository

chlenc opened this issue · 3 comments

chlenc commented

Describe the bug

Issue Building Example from sway-libs Repository

Hello Fuel community,

I recently updated my Fuel latest toolchain and fuelup, and encountered an issue while trying to build one of the examples from the sway-libs repository.

Here's what I did:

  1. Cloned the sway-libs repository:
    git clone git@github.com:FuelLabs/sway-standards.git
    
  2. Navigated to the src3-mint-burn example:
    cd ./sway-standards/
    cd examples/src3-mint-burn/
    
  3. Attempted to build the example:
    forc build
    

However, I encountered the following error during the build process:

Creating a new `Forc.lock` file. (Cause: lock file did not exist)
    Adding core
    Adding src20
    Adding src3
    Adding src5
    Adding src7
    Adding std git+https://github.com/fuellabs/sway?tag=v0.46.1#512a3386f8961185188302f391ccc96553d23a7a
   Created new lock file at /Users/alexey/Desktop/sway-standards/examples/Forc.lock
 Compiling library core (/Users/alexey/.forc/git/checkouts/std-9be0d6062747ea7/512a3386f8961185188302f391ccc96553d23a7a/sway-lib-core)
 Compiling library std (git+https://github.com/fuellabs/sway?tag=v0.46.1#512a3386f8961185188302f391ccc96553d23a7a)
 Compiling library src7 (/Users/alexey/Desktop/sway-standards/standards/src7-metadata)
 Compiling library src3 (/Users/alexey/Desktop/sway-standards/standards/src3-mint-burn)
 Compiling library src20 (/Users/alexey/Desktop/sway-standards/standards/src20-native-asset)
 Compiling contract single_src7_asset (/Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset)
warning
  --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:55:17
   |
53 | 
54 |     #[storage(read)]
55 |     fn metadata(asset: AssetId, key: String) -> Option<Metadata> {
   |                 ----- This declaration is never used.
56 |         require(asset == AssetId::default(), "Invalid AssetId provided");
   |
____

error
  --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:56:26
   |
54 | 
55 |     fn metadata(asset: AssetId, key: String) -> Option<Metadata> {
56 |         require(asset == AssetId::default(), "Invalid AssetId provided");
   |                          ^^^^^^^^^^^^^^^^ Function "default" expects 1 argument but you provided 0.
57 | 
58 |         if key == String::from_ascii_str("social:x") {
   |
____

error
  --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:78:21
   |
76 | 
77 |     fn total_supply(asset: AssetId) -> Option<u64> {
78 |         if asset == AssetId::default() {
   |                     ^^^^^^^^^^^^^^^^ Function "default" expects 1 argument but you provided 0.
79 |             Some(TOTAL_SUPPLY)
80 |         } else {
   |
____

error
  --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:87:21
   |
85 | 
86 |     fn name(asset: AssetId) -> Option<String> {
87 |         if asset == AssetId::default() {
   |                     ^^^^^^^^^^^^^^^^ Function "default" expects 1 argument but you provided 0.
88 |             Some(String::from_ascii_str(from_str_array(NAME)))
89 |         } else {
   |
____

error
  --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:96:21
   |
94 | 
95 |     fn symbol(asset: AssetId) -> Option<String> {
96 |         if asset == AssetId::default() {
   |                     ^^^^^^^^^^^^^^^^ Function "default" expects 1 argument but you provided 0.
97 |             Some(String::from_ascii_str(from_str_array(SYMBOL)))
98 |         } else {
   |
____

error
   --> /Users/alexey/Desktop/sway-standards/examples/src7-metadata/single_asset/src/single_asset.sw:105:21
    |
103 | 
104 |     fn decimals(asset: AssetId) -> Option<u8> {
105 |         if asset == AssetId::default() {
    |                     ^^^^^^^^^^^^^^^^ Function "default" expects 1 argument but you provided 0.
106 |             Some(DECIMALS)
107 |         } else {
    |
____

  Aborting due to 5 errors.
Error: Failed to compile single_src7_asset

Here are the details of my toolchain setup:

Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
beta-4-aarch64-apple-darwin
latest-2023-11-15-aarch64-apple-darwin
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.46.1
    - forc-client
      - forc-deploy : 0.46.1
      - forc-run : 0.46.1
    - forc-doc : 0.46.1
    - forc-explore : 0.28.1
    - forc-fmt : 0.46.1
    - forc-index : 0.24.3
    - forc-lsp : 0.46.1
    - forc-tx : 0.46.1
    - forc-wallet : 0.3.0
  fuel-core : 0.20.5
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.24.3

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45

Has anyone experienced a similar issue or can provide insights into what might be going wrong? Any help or suggestions would be greatly appreciated!

Thank you in advance!

Steps to reproduce

  1. Cloned the sway-libs repository:
    git clone git@github.com:FuelLabs/sway-standards.git
    
  2. Navigated to the src3-mint-burn example:
    cd ./sway-standards/
    cd examples/src3-mint-burn/
    
  3. Attempted to build the example:
    forc build
    

Minimal reproducible code example

-

Rust Version

rustc 1.75.0 (82e1608df 2023-12-21)

Forc Version

forc 0.46.1

Expected behavior

successful build

Additional context

No response

It looks like you are trying to compile with forc v0.46.1. The sway-standards repository is currently up to date with forc v0.49.1.

If you’d still like to use forc v0.46.1, you can checkout the v0.2.0 release of sway-standards https://github.com/FuelLabs/sway-standards/releases/tag/v0.2.0

chlenc commented

I have run fuelup self update and fuelup update before, my toolchain is latest, please help to switch to the right sway version

chlenc commented

worked with the nightly toolchain