Skip to content
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/chess/register realm #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

moul
Copy link
Contributor

@moul moul commented Sep 26, 2023

First part of #160.

Following this, the concluding action requires the faucet to transition from the traditional gnokey send XXXugnot targetAddr. Instead, it should employ:

gnokey maketx call -pkgaddr gno.land/r/demo/chess/register -func RegisterPlayer -send 12345ugnot -args $targetAddr $args $token

This change ensures that the registration process aligns seamlessly with the newly proposed on-chain mechanism.

Depends on gnolang/faucet#2

@moul moul self-assigned this Sep 26, 2023
@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for gnochess canceled.

Name Link
🔨 Latest commit caf6f0b
🔍 Latest deploy log https://app.netlify.com/sites/gnochess/deploys/651288004c0084000858d684

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for gnochess-signup-form canceled.

Name Link
🔨 Latest commit caf6f0b
🔍 Latest deploy log https://app.netlify.com/sites/gnochess-signup-form/deploys/65128800047d470008ad4136

@moul moul marked this pull request as ready for review September 26, 2023 07:31

var players = avl.Tree{} // player -> token

func RegisterPlayer(playerAddr std.Address, token string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you ensure the user send the same token as in mailchimp ?

Copy link
Contributor Author

@moul moul Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The faucet is sending it, with money at the same time.

Check the next line: assertIsFaucet().

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! sorry i just realized!

@moul
Copy link
Contributor Author

moul commented Sep 26, 2023

The missing part is roughly this: https://github.com/gnolang/faucet/pull/2/files.

I suggest we make the generic faucet repo accepting a custom callback to build the tx with arbitrary message when we don't want the faucet to actually call "send", but do "something else".

sent := std.GetOrigSend()
banker := std.GetBanker(std.BankerTypeOrigSend)
pkgaddr := std.GetOrigPkgAddr()
banker.SendCoins(pkgaddr, playerAddr, sent)
Copy link
Contributor

@tbruyelle tbruyelle Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure I understood correctly, so here you are transferring from the realm account to the player account. So I assume the faucet funded the realm just before ?

Copy link
Contributor Author

@moul moul Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not transferring from the realm account (real); I’m transferring what is still in the pipe, freshly sent by the faucet (unreal), not less, not more.

if ever someone funds the realm without a register, it is just a lost.

The amount received is directly forwarded in the same transaction; at the end of successful or failed register; the realm balance is the same at the beginning and at the end.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont get that notion of still in the pipe...

If std.GetOrigPkgAddr() returns the address of the original faucet, this register realm acts as a passe-plat, and just sends the tokens from the original faucet to the player account. Am I correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants