Commit graph

18 commits

Author SHA1 Message Date
mitchmindtree
4ffa867b3d
refactor: Move the examples workspace manifest into examples directory. Use it in CI. (#4145)
## Description

This moves the examples workspace manifest introduced in #4118 into the
`examples/` directory and cleans it up a bit.

We also now integrate the examples workspace into CI, making the old
`examples-checker` script redundant. This old script is also removed as
a part of this PR.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
2023-02-21 11:15:29 +11:00
Braqzen
4131a16927
Add logging::log & assert::assert_eq to prelude.sw (#3916) 2023-01-29 14:28:06 -07:00
Nick Furfaro
c471e825e8
Rename core::num to core::primitives (#3488)
The current `core::num` name is not well aligned with types like `b256`
which are not numeric types.
In addition, in Rust, methods like `min(), `max()` and `bits()` are in
the `primitives` module.
Closes #2777
2022-12-02 01:56:58 +00:00
Mohammad Fawaz
d613be1f8f
Update lock files for all examples (#3307) 2022-11-06 20:29:02 -05:00
Mohammad Fawaz
cfecaf4c40
Generic trait From<T> in the standard library (#3241)
Closes #1078 

* New trait `From<T>` in a new library called `convert.rs`
* Most changes are trivial
* Added `From` to the prelude
* Had to modify `from()` in `U128`, `U256`, and `B512` to take a tuple
of components instead of multiple arguments to conform to the trait.
This is a breaking change of course.
* Updating lock files for all the examples.
2022-11-02 15:41:06 +00:00
Mazdak Farrokhzad
cd100147ab
Eliminate need for ~ in ~Foo::bar() (#3218)
Fixes https://github.com/FuelLabs/sway/issues/1436.

This PR first removes the need for `~` in `~Foo::bar` by first delaying
the interpretation of `Foo::Bar` (associated call, free function call,
or enum variant construction?) until type checking. This is achieved
with `ExprKind::AmbiguousPathExpression`. During type checking, we ask
whether `Foo` (and any prefixes) is a module, or an enum. If it's
neither, we attempt type checking as an associated function call.
Otherwise, we continue as if we had a `ExpressionKind::DelineatedPath`.

Once `~` is made redundant, it's then also removed from the language and
so also from tests, examples, and the standard library.

Co-authored-by: Alex Hansen <alex@alex-hansen.com>
2022-10-31 19:45:38 +00:00
Chris O'Brien
64266d36b4
Make Shape state changes in Format API more robust (#2732)
* Make  changes more robust

* clippy

* use & fn items

* add struct, storage & fn

* add asm

* add expr and conditionals

* add attributes

* add remaining updates

* fmt

* fix fn body format call

* add changes to Shape and CodeLine
2022-09-14 10:35:41 +10:00
Chris O'Brien
3c83178581
Replace old formatter with new formatter (#2669)
* update plugin and swayfmt toml, remove old formatter

* update config to formatter for consistency

* wip fix lsp formatting

* more merge conflicts

* update dependencies to 22.1

* remove files that made it back in from merge

* comment out function in LSP that uses formatter

* format examples and remove debug printlns

* Merge #2669 (swayfmt replacement PR) with `master` including newline formatting fixes (#2698)

* refactor: forc-deploy requires wallet address and accepts signature (#2629)

* Add the `CopyTypes` trait to `DeclarationId` (#2682)

Co-authored-by: Toby Hutton <toby@grusly.com>

* fix: Unformatted comment spans add extra newline (#2692)

* newline handler checks for existing newlines before inserting new ones

* stability test added

* newline-comment handler interaction test added

* review suggestion

* feat: add basic comment context formatting (#2697)

* feat: add comment context formatting

* test: enhance newline-comment handler interaction test

* Apply suggestions from code review

Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>

Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>

* Update `examples/` for recent swayfmt-v2 patches

Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>

* change name to swayfmt, kashira

* add swayfmt file

* sort toml dependencies

* fix excess newlines in format_context

* test on examples

Co-authored-by: mitchmindtree <mitchell.nordine@fuel.sh>
Co-authored-by: Kaya Gökalp <kayagokalp@sabanciuniv.edu>
Co-authored-by: Emily Herbert <17410721+emilyaherbert@users.noreply.github.com>
Co-authored-by: Toby Hutton <toby@grusly.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-09-02 11:40:00 -05:00
Nick Furfaro
f1632e5437
Furnic/revert b256 add (#1961)
* feat: Implement Add for b256

* modify: make U128 functions public

* feat: add b256_ops module to stdlib

* docs: add comments

* reorganize: move b256_ops tests to e2e harness

* test: stuff

* refactor: cleanup unneeded mut variables

* feat: add core-utils lib

* fixup

* refactor: use new lib for compostion

* chore: fix manifest project name

* refactor: rename module to compose

* cleanup

* refactor: rename to core_utils

* fixup

* chore: rename new lib and update manifests

* test: fix last assert

* docs: add module level docs

* fixup

* chore: remove and rebuild for lock files

* fixup

* test: cleanup

* chore: rebuild basic_predicate

* chore: rebuild

* fix: restore test project

* fix: add oracle file

* chore: rebuild sdk-harness tests

* Revert "Implement Add for b256 (#1707)"

This reverts commit 560ca4b4c6.

* chore: rebuild lockfiles
2022-06-13 16:05:16 -05:00
Nick Furfaro
560ca4b4c6
Implement Add for b256 (#1707)
* feat: Implement Add for b256

* modify: make U128 functions public

* feat: add b256_ops module to stdlib

* docs: add comments

* reorganize: move b256_ops tests to e2e harness

* test: stuff

* refactor: cleanup unneeded mut variables

* feat: add core-utils lib

* fixup

* refactor: use new lib for compostion

* chore: fix manifest project name

* refactor: rename module to compose

* cleanup

* refactor: rename to core_utils

* fixup

* chore: rename new lib and update manifests

* test: fix last assert

* docs: add module level docs

* fixup

* chore: remove and rebuild for lock files

* fixup

* test: cleanup

* chore: rebuild basic_predicate

* chore: rebuild

* fix: restore test project

* fix: add oracle file

* chore: rebuild sdk-harness tests
2022-06-10 18:24:27 -07:00
mitchmindtree
fb4bc7a8ef
Disambiguate path dependencies using the ID of the package at the path root (#1790)
* Disambiguate `path` dependencies using the parent package ID

Implements and closes #1789.

TODO:

- [x] Disambiguate `path` dependencies using parent package ID.
- [ ] Impl `Display` and `FromStr` for `PinnedId` to convert it to and
  from hex for path source string in lock file.
- [ ] Address #1637 now to reduce this PR adding even more noise in the
  lock file `dependencies` lists.
- [ ] Refactor `fetch_deps` slightly to better accomodate new `Root`
  source variant.
- [ ] Update lock files of all examples and tests in repository.

* Swap `ToString` impls for `Display`. Add `PinnedId` impls.

Also removes the `lock::source_from_str/source_to_string` impls in
favour of implementing `Display` and `FromStr` for `SourcePinned`.

* Only disambiguate pkg lock dependencies if the name requires it

Closes #1637.

* Update new add_deps function for changes applied to pin_pkg

* Fix path dependency disambiguation using a path root rather than parent

Improves path dependency disambiguation by using the ID of the package
that is the root of the subgraph of path dependencies.

* Update `examples` forc lock files for path disambiguation changes

* Update E2E test forc lock files for path disambiguation changes

* Update stdlib test lock files for path dependency disambiguation changes

* Update new lock files introduced since previous rebase
2022-06-08 16:14:48 +10:00
Braqzen
a71f942f9d
Deprecating old functions (#1610)
* Deprecating old functions

* Removing out of date section
2022-05-19 14:42:34 +01:00
Braqzen
9e23221f38
Added generic keccak256 function (#1606)
* Added generic keccak256 function

* Updated formatting
2022-05-19 13:21:37 +01:00
bing
9ca992fec8
Fix space formatting between parenthesis and opening quotation marks (#1603)
* Fix space formatting between fn opening parenthesis and string

* Move check out of append_with_whitespace, since it's more correct there

* Update formatting within hashing example
2022-05-19 12:49:50 +08:00
Nick Furfaro
c000ccf915
Cleanup constants.sw & add impl b256 to core/num (#1599)
* cleanup: remove some consts from constants.sw

* feat: add impl b256 to num module

* test: fix all usage of ZERO const in tests

* fix: update example project to use new b256::min()

* style: fmt

* fix: fix comments

* style: fmt examples

* Revert "fix: fix comments"

This reverts commit 65e7176a4e.

* docs: fix comment for b256::max()

* fix: update intrinsics

* fmt
2022-05-18 20:01:27 -07:00
Nick Furfaro
48d27406df
Adding a generic log function (#1572)
* feat: add generic log function

* feat: use log() in require()

* refactor: rename chain module to logging

* cleanup

* docs: add mod level description and function description

* fix typo

* fix docs typo

* fixup

* cleanup: remove unused dep

* fix: restore bare chain module

* fix: update examples

* fixup

* test: add logging of different types

* refactor: use intrinsics module

* fix: remove params from intrinsic wrappers

* fmt

* style: fmt
2022-05-18 18:44:43 -07:00
Braqzen
8e3c174c1f
Added generic sha256 (#1544)
* Added generic sha256

* Update sway-lib-std/src/hash.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* Inlined comments and updated formatting

* Cleaned up asm

* Fixing import

* Updating tests, WIP

* Pushing up tests that fail to compile

* Updating docs

* Formatting

* Updating compiler intrinsics

* Saving before pulling master in

* Updated tests

* Fixed formatting

* Starting to add hash validation for testing

* Updated integers

* Added str hashing

* Added concrete tuple validation

* Added concrete array validation

* Added concrete enum validation

* Added b256 validation

* Formatting & core::num update

* Testing struct, WIP

* Hashing struct works

* Formatting

* Updating examples for mdbook

* Updating to buggy formatting and removed comment

* Updating import formatting

* Update sway-lib-std/src/hash.sw

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
2022-05-18 20:13:57 +01:00
Nick
c158ef700c
Hashing and Cryptography (#1362)
* hashing and cryptography

* fix deps

* signature forc toml lock

* signature forc toml example dep std

* index title

* rust to sway code example

* include fix

* book end line formatting

* Update docs/src/blockchain-development/hashing_and_cryptography.md

Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>

* title, nits, formatting

* toml file

* editor level formatting fix

* editor level formatting fix

* fix formatter formatting in b512..

* fmt

Co-authored-by: SilentCicero <>
Co-authored-by: John Adler <adlerjohn@users.noreply.github.com>
Co-authored-by: Mohammad Fawaz <mohammadfawaz89@gmail.com>
2022-05-05 21:29:14 -04:00