-
Notifications
You must be signed in to change notification settings - Fork 224
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
Soroban counter.sol example #1645
Soroban counter.sol example #1645
Conversation
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
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.
Looks great
src/emit/instructions.rs
Outdated
bin.builder | ||
.build_conditional_branch(success, success_block, bail_block) | ||
.unwrap(); | ||
// Soroban doesnt have return codes, and only returns a single i64 value |
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 was wondering if this should be enforced in sema; for Soroban, we could simply give an error diagnostic if a function returns anything else but an int64
.
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.
What is reffered to here is the wasm
functions, not Solidity functions. That is, if a Solidity function returns nothing, the wasm
function returns an i64
value to be XDR decoded as Void
.
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.
Right, the comment could with explaining that
…dinsoliman/solang into soroban_counter_contract
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
fn print(&self, bin: &Binary, string: PointerValue, length: IntValue) { | ||
unimplemented!() | ||
} | ||
fn print(&self, bin: &Binary, string: PointerValue, length: IntValue) {} |
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.
Should this function be doing nothing?
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.
When there is a runtime error, an overflow maybe, a call to this function is made. The ideal scenario is to make a call to Soroban's host function responsible for logging, but since this is out of scope for this PR, I left it out.
A //TODO
might be better here
Signed-off-by: salaheldinsoliman <salaheldin_sameh@aucegypt.edu>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1645 +/- ##
==========================================
+ Coverage 88.51% 88.58% +0.07%
==========================================
Files 163 164 +1
Lines 72869 73152 +283
==========================================
+ Hits 64497 64802 +305
+ Misses 8372 8350 -22 ☔ View full report in Codecov by Sentry. |
This PR aims to make Solang support a simple counter.sol example on Soroban, where a storage variable is instatiated, modified and retrieved. The counter contract is only limited to
uint64
data types, and only supportsinstance
soroban storage.This can be considered a "skeleton" for supporting more data and storage types, as well as more host function invokations.
put_contract_data
,get_contract_data
andhas_contract_data
init
forstorage_initializer