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
Initial interface for contract calls #9
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
421e622
Initial interface for contract calls
digorithm 47dcca4
Add fuel-merkle key
digorithm 5f4ba2c
Simplify how fuel-core is launched for testing
digorithm 5853551
Require fuel_client for contract setup
digorithm b2f11b9
Sort keys
digorithm File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
fuels-abigen-macro/tests/test_projects/simple_script/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[project] | ||
author = "Alex Hansen" | ||
license = "MIT" | ||
name = "Fuel example project" | ||
|
||
|
||
[dependencies] | ||
std = { path = "../stdlib" } |
79 changes: 79 additions & 0 deletions
79
fuels-abigen-macro/tests/test_projects/simple_script/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
script; | ||
use std::ops::Ord; | ||
|
||
struct Rgb { | ||
red: u64, | ||
green: u64, | ||
blue: u64, | ||
} | ||
|
||
|
||
enum PrimaryColor { | ||
Red : (), | ||
Green : (), | ||
Blue : () | ||
} | ||
|
||
impl Ord for PrimaryColor { | ||
fn gt(self, other: Self) -> bool { | ||
asm(r1: self, r2: other, r3) { | ||
gt r3 r1 r2; | ||
r3: bool | ||
} | ||
} | ||
fn lt(self, other: Self) -> bool { | ||
asm(r1: self, r2: other, r3) { | ||
lt r3 r1 r2; | ||
r3: bool | ||
} | ||
} | ||
fn eq(self, other: Self) -> bool { | ||
asm(r1: self, r2: other, r3) { | ||
eq r3 r1 r2; | ||
r3: bool | ||
} | ||
} | ||
} | ||
|
||
impl Color for PrimaryColor { | ||
// TODO: when we support match statements, change this to a match statement | ||
fn rgb(self) -> Rgb { | ||
if self == PrimaryColor::Red { | ||
Rgb { | ||
red: 255, | ||
blue: 0, | ||
green: 0, | ||
} | ||
} | ||
else if self == PrimaryColor::Green { | ||
Rgb { | ||
red: 0, | ||
blue: 0, | ||
green: 255, | ||
} | ||
} | ||
else if self == PrimaryColor::Blue { | ||
Rgb { | ||
red: 0, | ||
blue: 255, | ||
green: 0, | ||
} | ||
} | ||
else { | ||
Rgb { | ||
red: 0, | ||
blue: 0, | ||
green: 0 | ||
} | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
let first_color = PrimaryColor::Green; | ||
let rgb: Rgb = first_color.rgb(); | ||
} | ||
|
||
trait Color { | ||
fn rgb(self) -> Rgb; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried that before doing the ugly way, was getting this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will figure this out on the next PR I'll be submitting soon, need to merge this 😅.