Commit graph

517 commits

Author SHA1 Message Date
Joshua Batty
60ea55e692
chore: bump to v0.55.0 (#5872)
## Description

waiting on #5871
2024-04-18 09:47:57 +02:00
IGI-111
d90cbc8419
Bump to v0.54.0 (#5853) 2024-04-13 04:03:01 +04:00
Joshua Batty
b30f0e83d3
chore: bump to v0.53.0 (#5831)
## Description
Bump repo to 0.53.0

waiting on #5813

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-04-11 11:15:06 +00:00
Cameron Carstens
a386e7be4d
Expand Native Asset Docs (#5808)
## Description

- Additional docs covering Native Assets including:
     - EVM vs FuelVM Assets
     - What `AssetId` is
     - How to use `AssetId`
     - What `SubId` is
     - What the default asset is
     - How to mint coins
     - How to burn coins
     - How to transfer coins
     - How to check contract balances
     - How to check transaction values
     - How to receive assets in contracts
     - ERC-20 equivalent example
     - ERC-1155 equivalent example
- The Liquidity Pool example has been moved to its own section in
examples

These changes were originally included in
https://github.com/FuelLabs/sway/pull/5806 but have been pulled out into
a separate 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] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [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.

---------

Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com>
2024-04-09 07:54:18 +09:00
Kaya Gökalp
c1ea517f05
chore: bump to v0.52.1 (#5822)
## Description

Bump repo to 0.52.1
2024-04-03 12:57:19 +04:00
Ben Greenberg
a72d664d3e
docs: add troubleshooting for slow performance (#5794)
## Description

Add a troubleshooting section for slow performance in the LSP server
advising users on steps to mediate it.

## Checklist

- [ ] 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).
- [ ] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2024-04-02 18:50:12 +00:00
Cameron Carstens
efe725ee8d
Fix dead links (#5807)
## Description

Paths have changed in Sway-Standards and Sway-Libs resulting in dead
links.

Required for any other PRs to have passing CI.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] 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] If my change requires substantial documentation changes, I have
[requested support from the DevRel
team](https://github.com/FuelLabs/devrel-requests/issues/new/choose)
- [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.
2024-04-02 11:46:06 +09:00
IGI-111
98d8f4cadb
Bump to v0.52.0 (#5791) 2024-03-27 13:22:13 +04:00
IGI-111
f063a78e89
Expose external code loading with std::execution::run_external (#5685)
## Description

Fixes #1846
Fixes #5691

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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.

---------

Co-authored-by: Vaivaswatha Nagaraj <vaivaswatha.nagaraj@fuel.sh>
Co-authored-by: xunilrj <xunilrj@hotmail.com>
2024-03-22 08:34:52 +01:00
Vaivaswatha N
9e51eebd6d
stdlib: Fix temp alloc size in try_as_str_array. (#5753)
Allocation must be based on the type size with padding.

In addition to the usual testing, I've also tested against
https://github.com/FuelLabs/fuel-vm/tree/feature/0.43.3-memory-grow.
2024-03-20 12:18:41 +05:30
Call Delegation
e40daf79b4
feat: Add predicate and script templates (#5238)
## Description

When DevRel creates more tutorials on predicates and scripts, it's not
ideal to use the same template designed for contracts and ask developers
to erase everything and start afresh. It's clearer to have developers
use a template tailored for the respective program type.

These templates are already compatible with existing `forc` commands
like

Predicate
1. `forc new --predicate MyPredicate`
2. `cargo generate --init fuellabs/sway templates/sway-predicate-test-rs
--name MyPredicate`

Script
1. `forc new --script MyScript`
2. `cargo generate --init fuellabs/sway templates/sway-script-test-rs
--name MyScript`

## 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.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2024-03-20 09:54:08 +11:00
Daniel Frederico Lins Leite
39d25b6a84
fallback when all contract selectors fail (#5703)
## Description

This PR closes https://github.com/FuelLabs/sway/issues/5566.

Contracts now can have a special function decorated with `#[fallback]`
which is called when the contract method selection fails.

This function for all intents and purposes works as a standard contract
method, so:

- it cannot call others contracts methods;
- it has the same limitations of inputs and outputs.

This function can return a value like a normal contract would, or it can
use the `__contract_ret` intrinsics to return any value.

## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [ ] 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.
2024-03-14 15:21:19 +00:00
Cameron Carstens
aa23d5e9d4
Advanced Storage Docs (#5715)
## Description

There have been a number of questions on the forum regarding storage and
the section needed and update. The following changes have been made:

- Simplified basic storage examples
- Added examples that include structs
- Added basic examples that include `StorageMap`
- Added basic examples that include `StorageVec`
- Added basic examples that include `StorageString`
- Added basic examples that include `StorageBytes`
- Added advanced nested examples using `StorageVec` and `StorageMap`
- Added advanced nested examples using `StorageString` and `StorageMap`
- Added advanced nested examples using `StorageBytes` and `StorageVec`
- ~~Added table of contents~~ Removed due to CI errors not accepting TOB
format
- Fixed inline docs on `StorageString`
- Fixed inline docs on `StorageBytes`
- Fixed inline docs on `StorageKey`

## 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.

---------

Co-authored-by: Sarah Schwartz <58856580+sarahschwartz@users.noreply.github.com>
2024-03-13 11:09:55 +09:00
Sarah Schwartz
1589c8f5a2
docs: add type conversions page (#5708)
This PR adds a Type Conversions page to make it easier for developers to
quickly find a solution to converting a type.
2024-03-11 17:29:18 +00:00
Cameron Carstens
2ab18c1dbb
Rename predicate_id() to predicate_address() and additional Predicate docs (#5596)
## Description

An external discussion led to the conclusion that for a predicate's
hash, rather than [adding the `PredicateId`
type](https://github.com/FuelLabs/sway/issues/5476) the formal naming
convention should be "Predicate Address". This would allow the `Address`
type to semantically cover both cases of a predicate and externally
owned account.

Additional documentation on predicates has also been added which
includes the use of address instead of id or root.

## 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.
2024-03-06 02:57:09 +00:00
Sophie Dankel
cd04e737b9
Add docs about forc debug (#5683)
## Description


## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-03-05 13:19:24 -07:00
Vaivaswatha N
0c03ce06ef
Replace __jmpb_ssp with __jmp_mem (#5674)
The new intrinsic jumps to an absolute address that is fetched from
`MEM[$hp]`. This is more versatile than the `__jmpb_ssp` that was
previously provided. An immediate advantage being that we can have a
working version of `ldc` even in debug
builds.

The test has been modified too, to demonstrate an LDC use that works. A
working version is at
309c79a8f7/test-contract/src/main.sw

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2024-03-03 06:20:09 +00:00
Cameron Carstens
d5b8cb8f99
Encapsulation for std-lib (#5658)
## Description

Merges the staging branch into master from the following PRs:

https://github.com/FuelLabs/sway/pull/5640
https://github.com/FuelLabs/sway/pull/5630
https://github.com/FuelLabs/sway/pull/5621
https://github.com/FuelLabs/sway/pull/5613

## 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.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2024-03-03 09:48:17 +04:00
iwantanode
41a166c37b
fix: several typos in the documentation (#5362)
## Description

Hello
I fixed some typos in the docs,
Hope it helps.
Br,
Tudor.

---------

Co-authored-by: IGI-111 <igi-111@protonmail.com>
2024-02-26 22:24:31 +00:00
Vaivaswatha N
a8fd24f08d
Provide __jmpb_ssp intrinsic (#5576)
The new intrinsic `__jmpb_ssp(offset: u64)` jumps backwards, from the
current value of `$ssp`, by a provided byte offset.

This intrinsic is necessary for dynamically loading and executing a
contract.

Here's an example contract (taken from
https://github.com/FuelLabs/ldc-testing) for dynamically loading another
contract and transferring control to it. The "loadable" contract is the
one used in the link above.

```
// to be compiled in release mode
contract;

abi MyContract {
    fn test_function(code_id: ContractId);
}

impl MyContract for Contract {
    fn test_function(code_id_p: ContractId) {
        let length = asm(code_id, length, word, ssp_saved) {
            // Allocate 32 bytes on the heap (we can't use the stack)
            addi word zero i32;
            aloc word;

            lw code_id fp i74;
           
            // Log the ContractID for debugging
            logd zero zero code_id word;

            // Load the entire contract with LDC
            csiz length code_id;
            // Save the old ssp
            move ssp_saved ssp;
            ldc code_id zero length;
            // return the ssp difference, to feed __jmpb_ssp.
            // This need not always be equal to `length` as `ldc` pads the `length`.
            sub length ssp ssp_saved;
            length: u64
        };
        __jmpb_ssp(length)
    }
}
```

The intrinsic generates code to do the following:
1. Subract offset from `$ssp`.
2. Subtract `$is` since `$jmp` adds it back.
3. Divide by 4 since `Jmp` multiplies by 4
4. Jump to the computed value.

Closes #5563
2024-02-23 21:53:56 +00:00
IGI-111
d1e8f019c1
Revert to cc 1.0.83 and bump to 0.51.1 (#5649)
cc version 1.0.86 has a bug that blocks our cross compilation pipeline
https://github.com/rust-lang/cc-rs/issues/964
2024-02-23 08:59:26 +03:00
IGI-111
694457da6a
Bump to v0.51.0 (#5647) 2024-02-22 19:12:42 +00:00
Marcos Henrich
b32d0e0ae4
Implements the Never ! types as a TypeInfo bottom type. (#5602)
## Description

We now parse the `!` as a TypeInfo::Never, and remove the usage of empty
enums as Never type in our code.

This commit removes completely the DeterministicallyAborts and
TypeCheckUnificationContext.

The DeterministicallyAborts can be removed because the Never TypeInfo is
now propagated using the type checker. Code blocks that return, break,
continue, or call an expression that returns Never, are marked as Never.

Partially fixes #5562.

## 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.
2024-02-20 05:44:38 +04:00
IGI-111
18bde0ff7a
Storage namespace annotation (#5601)
## Description

Add a `#[namespace(my_namespace)]` annotation to allow developers to
avoid storage slot collisions when loading contract code using LDC.

Fixes #5490


## 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.
2024-02-19 13:03:16 +11:00
Sophie Dankel
6e77e2cb23
Add instructions for LSP on Code OSS (#5624)
## Description

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
2024-02-16 19:46:38 -03:00
Marcos Henrich
80be608517
Implements Iterator trait and for loops. (#5557)
## Description

This implements an Iterator trait in std-lib, and adds iter() to Vec.
This also adds parsing and desugaring of for loops.

```
    for pattern in iterator {
        code_block
    }
```
 is desugared into:
```
    let mut iterable = iterator;
    while true {
        let value_opt = iterable.next();
        if value_opt.is_none() {
             break;
        }
        let value = value_opt.unwrap();
        code_block
    }
```

This also adds for loops documentation to the control flow docs.

We still have to fix this issues:
 -  #5567
 -  #5568
 -  #5570
 -  #5571

Closes #145

## 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.
2024-02-08 18:26:24 +00:00
IGI-111
11231184a0
Bump to v0.50.0 (#5564) 2024-02-07 18:19:09 +04:00
Sophie Dankel
d3152bb83a
Add page for LSP troubleshooting (#5554)
## Description

Adds a doc page for troubleshooting LSP. If users report an issue with
LSP, we can direct them here to save time.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
2024-02-05 22:11:48 +00:00
Samuel Moelius
d6734b48fe
Fix typo in generic_types.md (#5535) 2024-02-04 04:57:19 +00:00
Igor Rončević
8320c1ba12
Struct field privacy (#5508)
## Description

This PR makes struct fields private by default and introduces explicit
public struct fields:

```
pub struct Struct {
    pub public_field: u8,
    private_field: u8,    
}
```

Private fields can be accessed only withing the module in which their
struct is declared.

Error messages are properly orchestrated so that no conflicting or
duplicated messages are emitted. Since the change is a breaking change,
relevant suggestion on how to fix the particular issue are given.

To avoid an abrupt breaking change, the errors are temporarily turned
into warnings. These warnings will become errors in the upcoming
versions of Sway. The demo section below demonstrate how the errors will
look like, and how a one warning equivalent looks now.

Standard library structs like `Vec` or `String`, are adapted where
needed by adding the `pub` keyword to the fields that are accessed
outside of the struct declaration module. Some of these fields should
very likely remain public, but some, like e.g., `RawBytes::ptr` or
`Vec::buf` should be private. Adjusting the standard library to properly
utilize private fields is out of scope of this PR and will be done
separately. I expect breaking changes in the STD once we start modeling
structs keeping encapsulation in mind.

In addition, the PR:
- migrates
[annotate_snippets](https://github.com/rust-lang/annotate-snippets-rs)
crate to its latest version (breaking changes)
- removes a redundant non-existing field error and orchestrates
non-existing field error with privacy errors
- replaces an invalid and misleading error when accessing fields on
storage elements that are not structs

Closes #4692.

## Known limitations

There is an issue in displaying multi-line code snippets, which is
independent of these changes, but wasn't apparent before. The issue is
visible in the demo section below, where the struct bodies are sometimes
not fully shown, and they should be. This issue is reported in #5499 and
will be solved in a separate PR.

## Demo (an excerpt 😄)

### Private struct field is inaccessible

![Private struct field is
inaccessible](8ac07c2b-8135-470b-ad7a-820a4934f232)

![Private struct field is
inaccessible](ca944a7a-e6c4-4b6f-97f1-18000e649452)

### Struct cannot be instantiated

![Struct cannot be instantiated due to inaccessible private
fields](05993416-91d6-4f58-8fd6-8c35c23595f8)

![Struct cannot be instantiated due to inaccessible private
fields](655c17df-a520-45a0-8af4-f1e424ddf085)

### Struct pattern must ignore inaccessible private fields

![Struct pattern must ignore inaccessible private
fields](90396d14-de63-4b08-9f22-e260f406542d)

### Struct pattern has missing fields

![Struct pattern has missing
fields](0ddf44e8-7598-461a-b85b-48006670b0ca)

### Errors temporarily turned into warnings

![Error turned into
warning](ba235248-740f-4fd2-b1fa-29fc35ee8c84)

## 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.
2024-01-30 17:15:24 +04:00
IGI-111
059b057401
Redesign From trait into From/Into pair (#5259)
## Description

Change `From` conversion trait into the expected `From`/`Into` rust-like
trait pair and `TryFrom` into a `TryFrom`/`TryInto` pair.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] 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.

---------

Co-authored-by: Marcos Henrich <marcoshenrich@gmail.com>
Co-authored-by: João Matos <joao@tritao.eu>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-01-29 00:46:12 +01:00
João Matos
8c93989b5e
Remove token library from book libraries.md (#5505)
This fixes the build.
2024-01-23 21:51:41 +11:00
Kaya Gökalp
2ac7030570
chore: bump version to 0.49.1 (#5495)
## Description
Bumps version to 0.49.1.
2024-01-19 21:29:31 +03:00
Cameron Carstens
d4c12dd813
Remove Subcurrency from examples (#5475)
## Description

As a continuation of https://github.com/FuelLabs/sway/pull/5461 and
improving the clarity of Native Assets on Fuel vs tokens, the legacy
Subcurrency example has been removed.

The Subcurrency example showed an implementation of a token using a
`StorageMap` to store addresses to balances. This sort of implementation
should not be promoted in Sway as it is a counterproductive example and
takes away from Native Assets on Fuel.

## 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.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-01-18 02:06:10 +00:00
Kaya Gökalp
a17fbf3e7d
chore: bump to v0.49.0 (#5452)
## Description
Bumps repo to 0.49.0, made this a major one after some thought as we
longer support beta-4 as tooling with this release.
Also ran `cargo update` as this is a breaking change

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-01-18 04:42:23 +03:00
Cameron Carstens
c72934deb7
Formalize Asset and Coin Terminology in the std-lib (#5461)
## Description

We currently use the following terminology in the standard library when
discussing native assets on Fuel:
 - Asset
 - Coin
 - Token

This can be incredibly confusing for new developers. A naming convention
that is consistent across the standard library, docs, and examples is
critical for clarity.
 
In the following PR I formalize the use of the words "Asset" and "Coin".

- An "Asset" is a Native Asset on Fuel and has the associated `AssetId`
type. Assets are distinguishable from one another.
- A "Coin" represents a singular unit of an Asset. Coins of the same
Asset are not distinguishable from one another.

The changes made reflect the distinction that Fuel does not use tokens
like other ecosystems such as Ethereum and uses Native Assets with a
UTXO design instead.

The Asset and Coin terminology is also consistent the fuel-vm's input
and outputs types. This is already seen in the `input.sw` file with the
`Input::Coin` enum and `output.sw`'s `Output::Coin` enum in the standard
library respectively.

## Breaking Changes

Imports using the `token` import should now use the `asset` import.

Before:
```sway
use std::token::mint;
```
After:
```sway
use std::asset::mint;
```

## 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.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2024-01-15 10:04:35 +07:00
Brandon
848e762218
Added assert_ne(x, y) function (#5426)
## Description
Closes #5321

Added an assertion that mirrors the existing `assert_eq(x, y)` function.
The `assert_ne(x, y)` function asserts that the two passed values are
not equal. This removes the need for the workaround `assert(x != y)`.

Documentation was updated in all areas that `assert_eq()` is referenced.
Tests were created similarly to the `assert_eq()` tests. The function
was also added to
[`prelude.sw`](9ee4b7a85d/sway-lib-std/src/prelude.sw (L20)).


## 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.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
2024-01-03 13:22:17 +00:00
Sophie Dankel
e5649ca021
Fix broken link in access_control.md (#5420)
## Description


## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.
2023-12-21 23:16:29 +00:00
Sarah Schwartz
fe65ca46dd
docs: configure spell check, minor improvements (#5369)
This PR configures the spell-check added to the docs workflow in the
github-actions repo: https://github.com/FuelLabs/github-actions/pull/23

The files checked are configured in `.spellcheck.yml`. This is also
where you can configure what types of elements are ignored.

Right now it ignores:
- All code blocks that have a language (and will check code blocks that
do not have a language)
- Anything in between backticks
- Words in `spell-check-custom-words.txt` (case sensitive, only exact
match)
- Numbers, even if they are attached to a word
- Links in markdown link format

#### Handling errors:

If the test fails:
- look up the word in the question to verify it is a real word and is
correctly spelled
- If it is a file name or is code, use backticks to ignore the word.
- If it is a real word that is spelled correctly, or an acronym that is
either common or is defined already, add it to
`spell-check-custom-words.txt`.
- If needed, rewrite the sentence. Ex: DON'T use "`lock`ing" and add
"ing" to the custom words list. Instead, rewrite the sentence as
"locking with the `lock` method".
- If it otherwise should be ignored, you can configure the pipeline in
`.spellcheck.yml`.

---------

Co-authored-by: Sophie Dankel <47993817+sdankel@users.noreply.github.com>
2023-12-19 15:10:26 -08:00
Sophie Dankel
0d0dd8f7ec
Add fuel-debugger as a forc plugin (#5390)
## Description

Closes https://github.com/FuelLabs/fuel-debugger/issues/15

Moves https://github.com/FuelLabs/fuel-debugger into a forc plugin.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] I have commented my code, particularly in hard-to-understand
areas.
- [ ] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [ ] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [ ] 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).
- [ ] I have requested a review from the relevant team or maintainers.

---------

Co-authored-by: Hannes Karppila <hannes.karppila@gmail.com>
2023-12-14 15:03:25 -08:00
IGI-111
6886ef050c
Fix release Dockerfile and bump to v0.48.1 (#5370) 2023-12-06 10:37:39 +00:00
Joshua Batty
e451140ce0
Bump to v0.48.0 (#5275)
Co-authored-by: Kaya Gokalp <kayagokalp123@gmail.com>
2023-12-06 17:48:58 +11:00
IGI-111
34265301c6
Bump to v0.47.0 (#5257) 2023-11-06 11:04:34 +04:00
Cesar
6d345f6e0e
#4318 forc-crypto plugin exposing a CLI for common-use cryptographic operations (#5153)
## Description

Fixes #4318

Supported algorithms:
* [x] keccak256
* [x] sha256
* [ ] ~ecrecover~ (this will be added later)
* [x] bech32-to-hex
* [x] hex-to-bech32
* [x] new-key / parse-secret (from
https://github.com/FuelLabs/fuel-core/blob/master/bin/keygen/src/keygen.rs)

## 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-10-28 11:54:58 -03:00
xiaolou86
4e26138b5e
docs: fix typos (#5198)
Co-authored-by: IGI-111 <igi-111@protonmail.com>
2023-10-18 13:14:41 +04:00
Sandusky
98d0810fac
docs: link to docs hub fuel installation guide (#5144)
## Description

In order to remove documentation redundancy issues, the fuel
installation guide is being centralized in the docs-hub.
Check [docs-hub/62](https://github.com/FuelLabs/docs-hub/pull/62)


## 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).
- [ ] I have added tests that prove my fix is effective or that my
feature works.
- [] 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).
- [ ] I have requested a review from the relevant team or maintainers.
2023-10-12 05:02:36 +00:00
Daniel Frederico Lins Leite
32582e0538
deprecated attribute (#5142)
## Description

This PR is part of https://github.com/FuelLabs/sway/pull/4794. It is the
minimum implementation for deprecation. Pretty much only what was needed
for deprecating `U256`.

It also minimally implements `#[allow(deprecated)]`.

## 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-10-03 13:11:52 +02:00
Paul Razvan Berg
103095e1f8
chore/docs: improve wording and fix typos (#5157)
## Description

Smol docs update. Fixes:

- A typo in assembly docs.
- A typo in unit testing docs.
- Couple of code documentation typos.
2023-10-02 11:51:16 +11:00
Kaya Gökalp
512a3386f8
Bump to v0.46.1 (#5149)
## Description
Bumps version to 0.46.1.
2023-09-28 23:42:04 +03:00
Marcos Henrich
8d8eda3975
Adds associated types documentation. (#5128)
## Description

Adds to the Sway book a new entry for associated types explaining what
they are and how they can be used.

Adds associated types to reference docs.

## Checklist

- [ ] I have linked to any relevant issues.
- [ ] 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).
- [ ] 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.

---------

Co-authored-by: Joshua Batty <joshpbatty@gmail.com>
2023-09-25 10:53:37 +01:00