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

[Framework] Receiver function aliases for package.move #17205

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 45 additions & 0 deletions crates/sui-framework/packages/sui-framework/sources/package.move
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,51 @@ module sui::package {
use std::type_name;
use sui::types;

/// Allows calling `.burn` to destroy a `Publisher`.
public use fun burn_publisher as Publisher.burn;

/// Allows calling `.module_` to access the name of the module a
/// `Publisher` was derived from.
public use fun published_module as Publisher.module_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public use fun published_module as Publisher.module_;
public use fun published_module as Publisher.`module`;

Thoughts? Feelings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have ...mixed feelings, but not very strong, so happy to be persuaded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will land, but let me know if you do feel strongly about using the backticks for this (for me it makes the receiver syntax fiddlier/more conspicious than the non-receiver function, vs tacking an underscore on the end).


/// Allows calling `.package` to access the address of the package
/// a `Publisher` was derived from.
public use fun published_package as Publisher.package;

/// Allows calling `.package` to access the package this cap
/// authorizes upgrades for.
public use fun upgrade_package as UpgradeCap.package;

/// Allows calling `.policy` to access the most permissive kind of
/// upgrade this cap will authorize.
public use fun upgrade_policy as UpgradeCap.policy;

/// Allows calling `.authorize` to initiate an upgrade.
public use fun authorize_upgrade as UpgradeCap.authorize;

/// Allows calling `.commit` to finalize an upgrade.
public use fun commit_upgrade as UpgradeCap.commit;

/// Allows calling `.package` to access the package this ticket
/// authorizes an upgrade for.
public use fun ticket_package as UpgradeTicket.package;

/// Allows calling `.policy` to access the kind of upgrade this
/// ticket authorizes.
public use fun ticket_policy as UpgradeTicket.policy;

/// Allows calling `.digest` to access the digest of the bytecode
/// used for this upgrade.
public use fun ticket_digest as UpgradeTicket.digest;

/// Allows calling `.cap` to fetch the ID of the cap this receipt
/// should be applied to.
public use fun receipt_cap as UpgradeReceipt.cap;

/// Allows calling `.package` to fetch the ID of the package after
/// upgrade.
public use fun receipt_package as UpgradeReceipt.package;

/// Tried to create a `Publisher` using a type that isn't a
/// one-time witness.
const ENotOneTimeWitness: u64 = 0;
Expand Down