From bcab31a54094d9cf9c6bebec5f237087ac2a17af Mon Sep 17 00:00:00 2001 From: Laisha Wadhwa Date: Thu, 22 Aug 2024 21:39:08 +0530 Subject: [PATCH 1/4] Updated the emmitted event in the search page --- forc-plugins/forc-doc/src/render/search.rs | 4 ++-- forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/forc-plugins/forc-doc/src/render/search.rs b/forc-plugins/forc-doc/src/render/search.rs index e0f84216ebe..9213c17210d 100644 --- a/forc-plugins/forc-doc/src/render/search.rs +++ b/forc-plugins/forc-doc/src/render/search.rs @@ -25,10 +25,10 @@ pub(crate) fn generate_searchbar(module_info: &ModuleInfo) -> Box const searchbar = document.getElementById("search-input"); const searchForm = document.getElementById("search-form"); searchbar.addEventListener("keyup", function(event) {{ - searchForm.dispatchEvent(new Event('submit')); + onSearchFormSubmit(event); }}); searchbar.addEventListener("search", function(event) {{ - searchForm.dispatchEvent(new Event('submit')); + onSearchFormSubmit(event); }}); function onQueryParamsChange() {{ diff --git a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs index 5ab755043de..98490645094 100644 --- a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs +++ b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs @@ -38,7 +38,7 @@ fn test_impl_traits_default() { &doc_path, project_name, &expect![[ - r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

+ r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"## ]], ); @@ -195,7 +195,7 @@ fn test_impl_traits_no_deps() { &doc_path, project_name, &expect![[ - r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

+ r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"## ]], ); From 976537bd7d5f36b1f7bea022c6f285400210f236 Mon Sep 17 00:00:00 2001 From: Laisha Wadhwa Date: Tue, 3 Sep 2024 18:22:06 +0530 Subject: [PATCH 2/4] Merge Reference for sway book --- docs/book/src/SUMMARY.md | 4 +++ .../reference/known_issues_and_workarounds.md | 29 +++++++++++++++++++ docs/book/src/reference/storage.md | 11 +++++++ 3 files changed, 44 insertions(+) create mode 100644 docs/book/src/reference/storage.md diff --git a/docs/book/src/SUMMARY.md b/docs/book/src/SUMMARY.md index 262437ea2cc..8b5ce8382e1 100644 --- a/docs/book/src/SUMMARY.md +++ b/docs/book/src/SUMMARY.md @@ -73,6 +73,10 @@ - [Behavior Considered Undefined](./reference/undefined_behavior.md) - [Differences From Solidity](./reference/solidity_differences.md) - [Differences From Rust](./reference/rust_differences.md) + - [Storage](./reference/storage/storage.md) + - [Initialization](./reference/storage/init.md) + - [Reading & Writing](./reference/storage/read-write.md) + - [Libraries](./reference/storage/libraries/index.md) - [Contributing To Sway](./reference/contributing_to_sway.md) - [Keywords](./reference/keywords.md) - [Forc Reference](./forc/index.md) diff --git a/docs/book/src/reference/known_issues_and_workarounds.md b/docs/book/src/reference/known_issues_and_workarounds.md index d60c5d23de3..71c4d362943 100644 --- a/docs/book/src/reference/known_issues_and_workarounds.md +++ b/docs/book/src/reference/known_issues_and_workarounds.md @@ -8,6 +8,35 @@ * [#1182](https://github.com/FuelLabs/sway/issues/1182) Arrays in a `storage` block are not yet supported. See the [Manual Storage Management](../advanced/advanced_storage.md#manual-storage-management) section for details on how to use `store` and `get` from the standard library to manage storage slots directly. Note, however, that `StorageMap` _does_ support arbitrary types for `K` and `V` without any limitations. + +## Importing + +In [external libraries](../../language/program-types/libraries/external.md) we have looked at how a library can be imported into a project so that code can be reused. + +When it comes to importing only external libraries can be imported through the `Forc.toml` file; any other type of program will result in an error. + +This means that the following projects cannot be imported: + +- [contracts](../../language/program-types/contract.md) +- [internal libraries](../../language/program-types/libraries/internal.md) +- [scripts](../../language/program-types/script.md) +- [predicates](../../language/program-types/predicate.md) + +While contracts cannot be imported, a workaround is to move the contract's `abi` declaration into an [external library](../../language/program-types/libraries/external.md) and import that library anywhere the ABI is needed. + +## Pattern Matching + +### Nested Match Expressions + +In [nested match expressions](../../language/control-flow/match/complex/nested-expression.md) we nest a `match` expression by embedding it inside the `{}` brackets on the right side of the arrow `=>`. + +Match expressions cannot be used as a pattern, the left side of the arrow `=>`. + +### Constants + +When matching on [constants](../../language/control-flow/match/complex/constant.md) we specify that a constant must be used in order to match on a variable. Dynamic values, such as an argument to a function, cannot be matched upon because it will be treated as a [`catch_all`](../../language/control-flow/match/single-line.md) case and thus any subsequent patterns will not be checked. + + ## General * No compiler optimization passes have been implemented yet, therefore bytecode will be more expensive and larger than it would be in production. Note that eventually the optimizer will support zero-cost abstractions, avoiding the need for developers to go down to inline assembly to produce optimal code. diff --git a/docs/book/src/reference/storage.md b/docs/book/src/reference/storage.md new file mode 100644 index 00000000000..bbb6cea2d87 --- /dev/null +++ b/docs/book/src/reference/storage.md @@ -0,0 +1,11 @@ +# Storage + +A [smart contract](../../language/program-types/contract.md) is able to perform computation and store & manipulate data over time. + +In the following sections we'll take a look at how Sway handles `storage` through: + +- [Storage Initialization](init.md): How to declare a `storage` block +- [Reading & Writing](read-write.md): How to read from and write to storage +- [Libraries](libraries/index.md): Additional functionality provided by the [storage library](https://github.com/FuelLabs/sway/blob/master/sway-lib-std/src/storage.sw) +- [Namespaces](namespace.md): How to use `storage` namespaces +- [In keyword](in-keyword.md): How to override storage variable position From 494255a30ae388828cbdb7e92a1f9b3ae9fecbac Mon Sep 17 00:00:00 2001 From: Sophie Dankel <47993817+sdankel@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:45:52 -0700 Subject: [PATCH 3/4] Update forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs --- forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs index 0647d23df19..4699c55a6a9 100644 --- a/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs +++ b/forc-plugins/forc-doc/src/tests/expects/impl_trait/mod.rs @@ -194,7 +194,7 @@ fn test_impl_traits_no_deps() { &doc_path, project_name, &expect![[ - r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

+ r##"Bar in bar - Sway
pub struct Bar {}

Implementations

fn foo_bar()

Trait Implementations

fn foo()

something more about foo();

fn add(self, other: Self) -> Self

fn subtract(self, other: Self) -> Self

"## ]], ); From 27a1f8e11b6063eac60fb2ac2c3061a71f134352 Mon Sep 17 00:00:00 2001 From: Sophie <47993817+sdankel@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:36:35 -0800 Subject: [PATCH 4/4] update spell-check-custom-words.txt --- docs/book/spell-check-custom-words.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/book/spell-check-custom-words.txt b/docs/book/spell-check-custom-words.txt index 3b51147b9ee..69a868538f5 100644 --- a/docs/book/spell-check-custom-words.txt +++ b/docs/book/spell-check-custom-words.txt @@ -207,6 +207,7 @@ TicTacToe DAO Timelock transpiler +Namespaces namespacing unsafety prioritizations