Breaking changes were released in Forc version 36.0 for importing libraries and using constants defined in the Forc.toml
file.
-
Defining and structuring modules in Sway project has been reworded. The
dep
keyword has been removed from the language in favour ofmod
:mod
declarations include a single ident specifying the name of the submodule. Note that this is different fromdep
declarations which would supply a/
-separated file system path to the submodule. Since the name of the submodule is specified in the declaration, submodules no longer need to supply their name via alibrary name;
header at the start of the file and can instead use the plainlibrary;
. The name of a submodule is used to find the source file for that submodule. For a submodule namedbar
of a modulefoo
, either the filefoo/bar.sw
orbar.sw
must exist. These paths are relative to the file defining thefoo
module containing themod bar;
declaration. It is an error for both or none of these paths to exist. Module paths behave the same as they previously did except that they use module names instead of library names. -
Definition constants in
Forc.toml
is no longer supported. Instead, configurable constants defined in aconfigurable
block should be used. These constants do not change throughout the execution of a Sway program, but they can be changed at “configuration time” using the Rust SDK for example.