-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[Move] Added example of an auction using shared objects #856
Conversation
/// bidder or to the original owner if no bids have been placed. | ||
public fun end_auction<T: key + store>(auction: Auction<T>) { | ||
let Auction { id, to_sell, owner, bid_data } = auction; | ||
ID::delete(id); |
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.
Shared object cannot be deleted :(
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.
Makes sense... Can we then even transfer an object wrapped in a shared object? It would seem like we can mutate the object, but then we'd have to replace it with another one. Does it mean, that for to_sell
item to be transferable in the shared-object version, it would have to become an Option
in the Auction
struct?
struct Auction<T: key + store> has key {
id: VersionedID,
/// Item to be sold.
to_sell: Option<T>,
/// Owner of the time to be sold.
owner: address,
/// Data representing the highest bid (starts with no bid)
bid_data: Option<BidData>,
}
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.
If you intend the transfer out the wrapped object, then yes it needs to be optional.
/// bidder or back to the original owner if no bids have been | ||
/// placed. This is executed by the owner of the asset to be | ||
/// auctioned. | ||
public fun end_auction<T: key + store>(auction: Auction<T>, ctx: &mut TxContext) { |
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.
In fact, a shared object cannot be passed by-value, so it would fail here.
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.
Fixed both issues (I hope...)
576123c
to
0504990
Compare
@lxfind - does it look more reasonable now? |
cbba68b
to
5a7b1b7
Compare
…d existing code to share common parts with the other implementation
…mantics plus added (forgotten) shared auction tests
5a7b1b7
to
f7608a7
Compare
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.
Ship it!
This is the counterpart to the existing auction implementation using single-owner objects only. I have also refactored existing code to share common parts with the new implementation.