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

poc: Receive trait for receiving coins #206

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Conversation

poszu
Copy link
Collaborator

@poszu poszu commented Oct 30, 2024

🚧

Related issue: #204

@poszu poszu requested a review from lrettig October 30, 2024 14:02
Copy link
Contributor

@lrettig lrettig left a comment

Choose a reason for hiding this comment

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

Great start. As part of this PR I think we should also implement this part of the design:

If there's no receive and no fallback method, a CALL or inbound tx with > 0 amount should fail.

Basically, a spend to a spawned account with no receive method should fail.

We can debate whether to fail txs with a method selector to a method that's not marked payable until we have #202

examples/wallet/program/src/main.rs Outdated Show resolved Hide resolved
let recipient_account = if let Some(account) = self.programs.get(&msg.recipient) {
account.clone()
} else {
return ExecutionResult::failed(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this should fail if the recipient doesn't exist. We still allow a coin transfer to a "stub" account that hasn't been spawned yet.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

How should it find the recipient's program code to call it? If the recipient isn't spawned yet, the host cannot know its program code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

As should be clear from the code snippet, it's only okay for a CALL without data. If there are args, and the recipient account hasn't been spawned, the tx will fail.

@poszu poszu force-pushed the feature/receive-func branch from e253708 to fb8dce5 Compare October 31, 2024 10:14
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.

2 participants