Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to forc v0.56.0 and fuel-core v0.24.2 #83

Merged
merged 3 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.75.0
FORC_VERSION: 0.53.0
CORE_VERSION: 0.23.0
FORC_VERSION: 0.56.0
CORE_VERSION: 0.24.2
PATH_TO_SCRIPTS: .github/scripts

jobs:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ If you don't find what you're looking for, feel free to create an issue and prop
To import a standard the following should be added to the project's `Forc.toml` file under `[dependencies]` with the most recent release:

```rust
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.1.0" }
standards = { git = "https://github.com/FuelLabs/sway-standards", tag = "v0.5.0" }
```

> **NOTE:**
Expand Down Expand Up @@ -150,7 +150,7 @@ Example of the SRC-12 implementation where contract deployments contain configur
Example of the SRC-12 implementation where all contract deployments are identitcal and thus have the same bytecode and root.

> **Note**
> All standards currently use `forc v0.53.0`.
> All standards currently use `forc v0.56.0`.

<!-- TODO:
## Contributing
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
contract;

use standards::src20::SRC20;
use std::{call_frames::contract_id, string::String};
use std::string::String;

configurable {
/// The total supply of coins for the asset minted by this contract.
Expand Down
9 changes: 3 additions & 6 deletions examples/src3-mint-burn/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use std::{
burn,
mint_to,
},
call_frames::{
contract_id,
msg_asset_id,
},
call_frames::msg_asset_id,
context::msg_amount,
hash::Hash,
storage::storage_string::*,
Expand Down Expand Up @@ -60,7 +57,7 @@ impl SRC3 for Contract {
/// ```
#[storage(read, write)]
fn mint(recipient: Identity, sub_id: SubId, amount: u64) {
let asset_id = AssetId::new(contract_id(), sub_id);
let asset_id = AssetId::new(ContractId::this(), sub_id);

// If this SubId is new, increment the total number of distinguishable assets this contract has minted.
let asset_supply = storage.total_supply.get(asset_id).try_read();
Expand Down Expand Up @@ -113,7 +110,7 @@ impl SRC3 for Contract {
#[payable]
#[storage(read, write)]
fn burn(sub_id: SubId, amount: u64) {
let asset_id = AssetId::new(contract_id(), sub_id);
let asset_id = AssetId::new(ContractId::this(), sub_id);
require(msg_amount() == amount, "Incorrect amount provided");
require(msg_asset_id() == asset_id, "Incorrect asset provided");

Expand Down
5 changes: 1 addition & 4 deletions examples/src3-mint-burn/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use std::{
burn,
mint_to,
},
call_frames::{
contract_id,
msg_asset_id,
},
call_frames::msg_asset_id,
constants::DEFAULT_SUB_ID,
context::msg_amount,
string::String,
Expand Down
17 changes: 6 additions & 11 deletions examples/src6-vault/single_asset_single_sub_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ contract;
use std::{
asset::transfer,
call_frames::msg_asset_id,
constants::{
BASE_ASSET_ID,
ZERO_B256,
},
constants::ZERO_B256,
context::msg_amount,
hash::{
Hash,
Expand All @@ -19,8 +16,6 @@ use std::{
use standards::{src20::SRC20, src6::{Deposit, SRC6, Withdraw}};

configurable {
/// The only asset that can be deposited and withdrawn from this vault.
ACCEPTED_ASSET: AssetId = BASE_ASSET_ID,
/// The only sub vault that can be deposited and withdrawn from this vault.
ACCEPTED_SUB_VAULT: SubId = ZERO_B256,
PRE_CALCULATED_SHARE_VAULT_SUB_ID: SubId = 0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b,
Expand All @@ -42,7 +37,7 @@ impl SRC6 for Contract {
require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id");

let underlying_asset = msg_asset_id();
require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID");
require(underlying_asset == AssetId::base(), "INVALID_ASSET_ID");

let asset_amount = msg_amount();
require(asset_amount != 0, "ZERO_ASSETS");
Expand Down Expand Up @@ -73,7 +68,7 @@ impl SRC6 for Contract {
underlying_asset: AssetId,
vault_sub_id: SubId,
) -> u64 {
require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID");
require(underlying_asset == AssetId::base(), "INVALID_ASSET_ID");
require(vault_sub_id == ACCEPTED_SUB_VAULT, "INVALID_vault_sub_id");

let shares = msg_amount();
Expand Down Expand Up @@ -102,7 +97,7 @@ impl SRC6 for Contract {

#[storage(read)]
fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64 {
if underlying_asset == ACCEPTED_ASSET && vault_sub_id == ACCEPTED_SUB_VAULT {
if underlying_asset == AssetId::base() && vault_sub_id == ACCEPTED_SUB_VAULT {
// In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable.
storage.managed_assets.read()
} else {
Expand All @@ -116,7 +111,7 @@ impl SRC6 for Contract {
underlying_asset: AssetId,
vault_sub_id: SubId,
) -> Option<u64> {
if underlying_asset == ACCEPTED_ASSET {
if underlying_asset == AssetId::base() {
// This is the max value of u64 minus the current managed_assets. Ensures that the sum will always be lower than u64::MAX.
Some(u64::max() - storage.managed_assets.read())
} else {
Expand All @@ -126,7 +121,7 @@ impl SRC6 for Contract {

#[storage(read)]
fn max_withdrawable(underlying_asset: AssetId, vault_sub_id: SubId) -> Option<u64> {
if underlying_asset == ACCEPTED_ASSET {
if underlying_asset == AssetId::base() {
// In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable.
Some(storage.managed_assets.read())
} else {
Expand Down
14 changes: 4 additions & 10 deletions examples/src6-vault/single_asset_vault/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ contract;
use std::{
asset::transfer,
call_frames::msg_asset_id,
constants::BASE_ASSET_ID,
context::msg_amount,
hash::{
Hash,
Expand Down Expand Up @@ -39,19 +38,14 @@ storage {
decimals: StorageMap<AssetId, u8> = StorageMap {},
}

configurable {
/// The only asset that can be deposited and withdrawn from this vault.
ACCEPTED_ASSET: AssetId = BASE_ASSET_ID,
}

impl SRC6 for Contract {
#[payable]
#[storage(read, write)]
fn deposit(receiver: Identity, vault_sub_id: SubId) -> u64 {
let asset_amount = msg_amount();
let underlying_asset = msg_asset_id();

require(underlying_asset == ACCEPTED_ASSET, "INVALID_ASSET_ID");
require(underlying_asset == AssetId::base(), "INVALID_ASSET_ID");
let (shares, share_asset, share_asset_vault_sub_id) = preview_deposit(underlying_asset, vault_sub_id, asset_amount);
require(asset_amount != 0, "ZERO_ASSETS");

Expand Down Expand Up @@ -106,7 +100,7 @@ impl SRC6 for Contract {

#[storage(read)]
fn managed_assets(underlying_asset: AssetId, vault_sub_id: SubId) -> u64 {
if underlying_asset == ACCEPTED_ASSET {
if underlying_asset == AssetId::base() {
let vault_share_asset = vault_asset_id(underlying_asset, vault_sub_id).0;
// In this implementation managed_assets and max_withdrawable are the same. However in case of lending out of assets, managed_assets should be greater than max_withdrawable.
managed_assets(vault_share_asset)
Expand All @@ -121,7 +115,7 @@ impl SRC6 for Contract {
underlying_asset: AssetId,
vault_sub_id: SubId,
) -> Option<u64> {
if underlying_asset == ACCEPTED_ASSET {
if underlying_asset == AssetId::base() {
// This is the max value of u64 minus the current managed_assets. Ensures that the sum will always be lower than u64::MAX.
Some(u64::max() - managed_assets(underlying_asset))
} else {
Expand All @@ -131,7 +125,7 @@ impl SRC6 for Contract {

#[storage(read)]
fn max_withdrawable(underlying_asset: AssetId, vault_sub_id: SubId) -> Option<u64> {
if underlying_asset == ACCEPTED_ASSET {
if underlying_asset == AssetId::base() {
// In this implementation total_assets and max_withdrawable are the same. However in case of lending out of assets, total_assets should be greater than max_withdrawable.
Some(managed_assets(underlying_asset))
} else {
Expand Down
2 changes: 1 addition & 1 deletion examples/src7-metadata/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contract;

use standards::{src20::SRC20, src7::{Metadata, SRC7}};

use std::{call_frames::contract_id, hash::Hash, storage::storage_string::*, string::String};
use std::{hash::Hash, storage::storage_string::*, string::String};

// In this example, all assets minted from this contract have the same decimals, name, and symbol
configurable {
Expand Down
2 changes: 1 addition & 1 deletion examples/src7-metadata/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ contract;

use standards::{src20::SRC20, src7::{Metadata, SRC7}};

use std::{call_frames::contract_id, string::String};
use std::string::String;

configurable {
/// The total supply of coins for the asset minted by this contract.
Expand Down
Loading