Skip to content

Commit

Permalink
chore: upgrading forc to 0.49.1 (FuelLabs#1670)
Browse files Browse the repository at this point in the history
  • Loading branch information
arboleya authored Jan 23, 2024
1 parent 84cab17 commit bb60c88
Show file tree
Hide file tree
Showing 25 changed files with 347 additions and 129 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-toes-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@fuel-ts/forc": patch
"@fuel-ts/versions": patch
---

Upgrading forc to 0.49.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #region custom-transactions-1
script;

use std::token::force_transfer_to_contract;
use std::asset::force_transfer_to_contract;

fn main(
contract_address: b256,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// #region contract-balance-2
contract;

use std::token::transfer_to_address;
use std::asset::transfer_to_address;

abi TransferToAddress {
#[payable]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ impl MyContract for Contract {
x
}
fn types_evm_address(x: EvmAddress) -> EvmAddress {
EvmAddress::from(
0x0606060606060606060606060606060606060606060606060606060606060606,
)
EvmAddress::from(0x0606060606060606060606060606060606060606060606060606060606060606)
}
fn types_bytes(x: Bytes) -> Bytes {
x
Expand Down
2 changes: 1 addition & 1 deletion packages/forc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.48.1
0.49.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,38 @@ use std::logging::log;

use advanced_logging_other_contract_abi::AdvancedLoggingOtherContract;

impl AbiEncode for str[25] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[34] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AdvancedLoggingOtherContract for Contract {
fn msg_from_other_contract(a: u8) {
log(__to_str_array("Hello from other Contract"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,118 @@ use std::contract_id::ContractId;

use advanced_logging_other_contract_abi::AdvancedLoggingOtherContract;

impl AbiEncode for str[8] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[10] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[11] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[12] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[14] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[18] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[24] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

enum GameState {
Playing: u8,
GameOver: u8,
Expand Down Expand Up @@ -45,9 +157,7 @@ impl AdvancedLogging for Contract {
ammo: 10,
game_id: 10_11_12u64,
state: GameState::Playing(1),
contract_Id: ContractId::from(
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
),
contract_Id: ContractId::from(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF),
difficulty: Difficulty::Medium(true),
};

Expand Down Expand Up @@ -95,9 +205,7 @@ impl AdvancedLogging for Contract {
ammo: 10,
game_id: 10_11_12u64,
state: GameState::Playing(1),
contract_Id: ContractId::from(
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF,
),
contract_Id: ContractId::from(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FFFFFFFFFFFFFFFFFFFFFFFFFFFFF),
difficulty: Difficulty::Medium(true),
};
require(a == b, game_ref);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl TestContract for Contract {
value + 1
}
fn call_external_foo(param: u64, contract_id: b256) -> u64 {
let external_contract = abi(TestContract, contract_id().into());
let external_contract = abi(TestContract, contract_id);
let response = external_contract.foo(param);
response + 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,6 @@ impl ConfigurableContract for Contract {
}

fn echo_configurables() -> (u8, u16, u32, u64, bool, b256, Colors, [[u32; 2]; 2], str[4], (u8, bool, str[2]), Struct1) {
(
U8,
U16, U32, U64, BOOL, B256, ENUM, ARRAY, STR_4, TUPLE,
STRUCT_1,
)
(U8, U16, U32, U64, BOOL, B256, ENUM, ARRAY, STR_4, TUPLE, STRUCT_1)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,38 @@ use std::assert::assert;
use std::logging::log;
use std::b512::B512;

impl AbiEncode for str[10] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

impl AbiEncode for str[12] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

pub struct U8Struct {
i: u8,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ contract;
use std::constants::ZERO_B256;

use std::{
asset::{
mint_to_address,
transfer_to_address,
},
call_frames::{
contract_id,
msg_asset_id,
},
context::msg_amount,
token::{
mint_to_address,
transfer_to_address,
},
};

abi LiquidityPool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ contract;

use std::{
address::Address,
asset::*,
context::balance_of,
context::msg_amount,
contract_id::ContractId,
token::*,
};

use std::constants::ZERO_B256;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ fn main(

result = result && (u32_vec.get(1).unwrap() == 1u32);

result = result && (vec_in_vec
.get(0)
.unwrap()
.get(1)
.unwrap() == 1u32);
result = result && (vec_in_vec.get(0).unwrap().get(1).unwrap() == 1u32);

result = result && (struct_in_vec.get(0).unwrap().a == 0u32);

Expand Down Expand Up @@ -58,14 +54,15 @@ fn main(
let (tuple_a, tuple_b) = vec_in_tuple;
result = result && (tuple_a.get(1).unwrap() == 1u32);

result = result && (vec_in_a_vec_in_a_struct_in_a_vec
.get(1)
.unwrap()
.a
.get(1)
.unwrap()
.get(1)
.unwrap() == 10u32);
result = result
&& (vec_in_a_vec_in_a_struct_in_a_vec
.get(1)
.unwrap()
.a
.get(1)
.unwrap()
.get(1)
.unwrap() == 10u32);

result
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
contract;

use std::{
asset::{
transfer_to_address,
},
bytes::Bytes,
constants::BASE_ASSET_ID,
logging::log,
message::{
send_message,
},
token::{
transfer_to_address,
},
};
use custom_errors::{AccessError, InputError};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@ script;

use std::logging::log;

impl AbiEncode for str[6] {
fn abi_encode(self, ref mut buffer: Buffer) {
let s = from_str_array(self);

let len = s.len();
let ptr = s.as_ptr();

let mut i = 0;
while i < len {
let byte = ptr.add::<u8>(i).read::<u8>();
buffer.push(byte);
i += 1;
}
}
}

fn main(foo: u8) -> u8 {
log(__to_str_array("u8 foo"));
log(foo);
Expand Down
Loading

0 comments on commit bb60c88

Please sign in to comment.