-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[token] add partial withdraw with capability #5652
[token] add partial withdraw with capability #5652
Conversation
@@ -272,6 +275,14 @@ module aptos_token::token { | |||
expiration_sec: u64, | |||
} | |||
|
|||
/// capability to do partial withdraw with signer. The capability owner can withdraw up to amount token | |||
struct PartialWithdrawCapability has drop, store { |
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 happens if I create both a WithdrawCapability
and a PartialWithdrawCapability
for the same item?
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, looks weird. It seems the WithdrawCapability
can include PartialWithdrawCapability
and add a withdraw_with_capability_v2
with an extra amount
param. So why not just reuse WithdrawCapability
?
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.
-
withdraw capability is just a capability that allows the capability owner to withdraw from NFT holder's token store. There is no guarantee that token exists.
This is designed this way to avoid escrowing the token. If there is no sufficient balance, the withdraw txn fails. -
WithdrawCapability and PartialWithdrawCapability have very different meaning. The first is one time capability. You use it once and it is gone no matter if you have withdrawn the full amount. The 2nd allows you to use multiple times untils you withdraw entire amount.
So the NFT holder should explicitly create this PartialWithdrawCapability to give permission on multiple partial withdraws.
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.
From the API and the fields they have. There is no reason to distinguish them IMO. allowing partial withdraw should be a subset of allowing full withdraw. I mean, if you allow ppl to withdraw in full, you should allow them to withdraw partially by default.
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.
They is real a CapCap
PR. hahahahahahah
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.
updated, remove the redundant struct and only keep the new function
18e86bb
to
facd18c
Compare
facd18c
to
9fbaa55
Compare
9fbaa55
to
08f49b7
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
address the request on enabling partial withdraw token with capability.
This allows people list x fungible tokens and buyer can buy a smaller than x amount. The rest of the tokens can still be listed on sale until all the tokens are bought
Test Plan
added unit test