-
Notifications
You must be signed in to change notification settings - Fork 388
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
feat: add r/demo/atomicswap #2510
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
I think i'll try to be more grc20-centric for my demos. In involves writing some helpers to show how to actually come with |
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
…ev/moul/atomicswap
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
- [x] Switch to storing a `type XXX func() grc20.Token` instead of a `grc20.Token` directly. - [x] Implement `grc20reg`. - [x] Add new tests in `gnovm/tests` to demonstrate the current VM's management of the cross-realm feature and support potential changes in #2743. - [x] Create a demo in `atomicswap` or a similar application. (#2510 (comment)) - [x] Try using a `Token.Getter()` helper. (Works! f99654e) - [ ] Demonstrate how to manage "disappearing" functions during garbage collection by checking if the function pointer is nil or non-resolvable. Alternative to #2516 NOT(!) depending on #2743 --------- Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Ready for review. |
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.
Left a few comments, otherwise I will try it out after merging.
I will also port my k=x*y
minidex next to this so we can have it as an example.
func NewCustomCoinSwap(recipient std.Address, hashlock string, timelock time.Time) (int, *Swap) { | ||
sender := std.PrevRealm().Addr() | ||
sent := std.GetOrigSend() | ||
require(len(sent) != 0, "at least one coin needs to be sent") |
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.
This is Solidity's style. While I appreciate the conciseness, do you think we should stick to the Go idiomatic way of checking for errors? ie if err:= ...; err!=nil {panic(err)}
Not sure what should be the way forward.
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.
This is Go too, not very famous, and usually found only in mains or "scripts." I believe it will become more common in Gno realms.
For instance, here is a Go package I wrote several years ago because I was accustomed to having this helper in all my mains: https://pkg.go.dev/moul.io/u#CheckErr
} else { // by id | ||
swap, ok := swaps.Get(path) | ||
if !ok { | ||
return "404" | ||
} | ||
return swap.(*Swap).String() | ||
} |
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.
nit: can be written without the else
block enclosing the code
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 won't fix it myself since I prefer this version to resemble a "switch case" with clear responsibilities. However, if someone believes it's important enough, feel free to send a suggestion that I will approve.
Co-authored-by: Leon Hudak <[email protected]>
Co-authored-by: Leon Hudak <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
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 used this realm in an atomic swap experiment with a cosmwasm contract on the other side and it worked good :)
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.
LGTM
wugnot
.-> both, with a callback mechanism.
-> just
r
, and a single file. let's do it more!Depends on #3397 (cherry-picked)
Depends on #2529 (cherry-picked)
Depends on #2549 (cherry-picked)
Depends on #2551
Closes #2549