Skip to content

Commit

Permalink
chore: added typegen test for type with native asset (#3066)
Browse files Browse the repository at this point in the history
* chore: added test

* chore: added alias type for Sway contract test

* Upgrading `forc` to `0.63.4`

* Adding changeset

* chore: updated typegen test

* changeset

---------

Co-authored-by: Anderson Arboleya <anderson@arboleya.me>
Co-authored-by: Nedim Salkić <nedim.salkic@fuel.sh>
  • Loading branch information
3 people authored Sep 6, 2024
1 parent cffa075 commit 8faeaa4
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 85 deletions.
4 changes: 4 additions & 0 deletions .changeset/afraid-crews-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

chore: added typegen test for type with native asset
10 changes: 10 additions & 0 deletions packages/abi-typegen/test/fixtures/forc-projects/full/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ enum MyContractError {
DivisionByZero: (),
}

type TupleWithNativeAssets = (AssetId, AssetId, bool);

fn divide(numerator: u64, denominator: u64) -> Result<u64, MyContractError> {
if (denominator == 0) {
return Err(MyContractError::DivisionByZero);
Expand Down Expand Up @@ -71,6 +73,8 @@ abi MyContract {
fn types_struct(x: MyStruct) -> MyStruct;
fn types_array(x: [u8; 3]) -> [u8; 3];
fn types_tuple(x: (u8, u8, u8)) -> (u8, u8, u8);
fn types_tuple_with_native_types(x: (AssetId, AssetId, bool)) -> (AssetId, AssetId, bool);
fn alias_types_tuple_with_native_types(x: TupleWithNativeAssets) -> TupleWithNativeAssets;
fn types_enum(x: MyEnum) -> MyEnum;
fn types_enum_with_vector(x: EnumWithVector) -> EnumWithVector;
fn types_vector_u8(x: Vec<u8>) -> Vec<u8>;
Expand Down Expand Up @@ -150,6 +154,12 @@ impl MyContract for Contract {
fn types_tuple(x: (u8, u8, u8)) -> (u8, u8, u8) {
(x.0, x.1, x.2)
}
fn types_tuple_with_native_types(x: (AssetId, AssetId, bool)) -> (AssetId, AssetId, bool) {
(x.0, x.1, x.2)
}
fn alias_types_tuple_with_native_types(x: TupleWithNativeAssets) -> TupleWithNativeAssets {
(x.0, x.1, x.2)
}
fn types_struct(x: MyStruct) -> MyStruct {
x
}
Expand Down
Loading

0 comments on commit 8faeaa4

Please sign in to comment.