-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Aptos Framework][Coin] Switch to an explicit opt-out model for coin transfers #5871
Conversation
aptos-move/framework/aptos-framework/sources/aptos_account.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-framework/sources/aptos_account.move
Outdated
Show resolved
Hide resolved
aptos-move/framework/aptos-framework/sources/aptos_account.move
Outdated
Show resolved
Hide resolved
8642ddf
to
c3540f1
Compare
e4886b9
to
2103c60
Compare
@@ -22,13 +42,37 @@ module aptos_framework::aptos_account { | |||
coin::register<AptosCoin>(&signer); | |||
} | |||
|
|||
/// Convenient function to transfer APT to a recipient account that might not exist. | |||
/// This would create the recipient account first, which also registers it to receive APT, before transferring. | |||
public entry fun transfer(source: &signer, to: address, amount: u64) { |
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: should we call this function by a more explicit name? smth like transfer_to_existing_or_nonexisting_account
- this does sound way more verbose than transfer
, but think transfer
is a simple name that people might mis-use
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.
That's really verbose. I'm not sure how people would misuse transfer here as it's meant to implicitly create an account (and may be register the coin type) if one doesn't exist yet. As proposed (I'll create an AIP soon), this new flow/function should be the default to use so users wouldn't need to worry about the nuances of accounts and coin registration.
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.
yeah I don't feel strong about this, just thought that some devs might use the transfer function here as the default transfer function without realizing that they could be transferring coins to an account that doesn't exist yet. as long as we make it clear, sgtm
2103c60
to
77e7a38
Compare
4237498
to
c81284c
Compare
6a2a12e
to
7089c7b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ Forge suite
|
✅ Forge suite
|
Description
Context:
Currently, in many cases, coins (ERC-20 tokens, including APT) cannot be sent directly to an account if:
aptos_account::transfer
oraccount::create_account
needs to be called by another account that can pay for gas. This is generally a slight annoyance but not too big of a pain.Proposed solution:
Switch over to an explicit opt-out model. By default, an account can receive transfers of coins they have not registered via
aptos_account::transfer_coins
. They can explicitly opt-out any time viaaptos_account:: set_allow_direct_coin_transfers
Test Plan
Unit tests