Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 12 additions & 26 deletions packages/stablecoin/Move.lock
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
# @generated by Move, please check-in and do not edit manually.

[move]
version = 2
manifest_digest = "2D16DF7BBB460E26A4151FFCA9834972024289FF6DFDD87F005D543C741A929E"
version = 3
manifest_digest = "81BC78646E98A3E9B44F5C38EE7C8F2728449C664A2184D884ECADF010D5C050"
deps_digest = "3C4103934B1E040BB6B23F1D610B4EF9F2F1166A50A104EADCF77467C004C600"
dependencies = [
{ name = "Sui" },
{ name = "sui_extensions" },
{ id = "Sui", name = "Sui" },
{ id = "sui_extensions", name = "sui_extensions" },
]

[[move.package]]
name = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "a4185da5659d8d299d34e1bb2515ff1f7e32a20a", subdir = "crates/sui-framework/packages/move-stdlib" }
id = "MoveStdlib"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/move-stdlib" }

[[move.package]]
name = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "a4185da5659d8d299d34e1bb2515ff1f7e32a20a", subdir = "crates/sui-framework/packages/sui-framework" }
id = "Sui"
source = { git = "https://github.com/MystenLabs/sui.git", rev = "mainnet", subdir = "crates/sui-framework/packages/sui-framework" }

dependencies = [
{ name = "MoveStdlib" },
{ id = "MoveStdlib", name = "MoveStdlib" },
]

[[move.package]]
name = "sui_extensions"
id = "sui_extensions"
source = { local = "../sui_extensions" }

dependencies = [
{ name = "Sui" },
{ id = "Sui", name = "Sui" },
]

[move.toolchain-version]
compiler-version = "1.32.2"
compiler-version = "1.55.0"
edition = "2024.beta"
flavor = "sui"

[env]

[env.testnet]
chain-id = "4c78adac"
original-published-id = "0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917"
latest-published-id = "0x346e3233f61eb0055713417bfaddda7dc3bf26816faad1f7606994a368b92917"
published-version = "1"

[env.mainnet]
chain-id = "35834a8a"
original-published-id = "0xecf47609d7da919ea98e7fd04f6e0648a0a79b337aaad373fa37aac8febf19c8"
latest-published-id = "0xecf47609d7da919ea98e7fd04f6e0648a0a79b337aaad373fa37aac8febf19c8"
published-version = "1"
4 changes: 2 additions & 2 deletions packages/stablecoin/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ license = "Apache 2.0"
[dependencies.Sui]
git = "https://github.com/MystenLabs/sui.git"
subdir = "crates/sui-framework/packages/sui-framework"
rev = "a4185da5659d8d299d34e1bb2515ff1f7e32a20a"
rev = "mainnet"

[dependencies.sui_extensions]
local = "../sui_extensions"
Expand All @@ -32,4 +32,4 @@ stablecoin = "0x0"

[dev-dependencies]

[dev-addresses]
[dev-addresses]
102 changes: 57 additions & 45 deletions packages/stablecoin/sources/entry.move
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,68 @@
/// wrapped objects from PTBs. Currently PTBs are unable to chain a reference from the output of one
/// function to the input of another, making it difficult to call functions on wrapped objects.
/// This module exposes those functions directly using entry functions.
module stablecoin::entry {
use stablecoin::treasury::Treasury;
module stablecoin::entry;

// === Entry Functions ===
use stablecoin::treasury::Treasury;

/// Start owner role transfer process.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun transfer_ownership<T>(treasury: &mut Treasury<T>, new_owner: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().begin_role_transfer(new_owner, ctx)
}
// === Entry Functions ===

/// Finalize owner role transfer process.
/// - Only callable by the pending owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun accept_ownership<T>(treasury: &mut Treasury<T>, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().accept_role(ctx)
}
/// Start owner role transfer process.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun transfer_ownership<T>(treasury: &mut Treasury<T>, new_owner: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().begin_role_transfer(new_owner, ctx)
}

/// Finalize owner role transfer process.
/// - Only callable by the pending owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun accept_ownership<T>(treasury: &mut Treasury<T>, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().owner_role_mut().accept_role(ctx)
}

/// Change the master minter address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_master_minter<T>(treasury: &mut Treasury<T>, new_master_minter: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_master_minter(new_master_minter, ctx)
}
/// Change the master minter address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_master_minter<T>(
treasury: &mut Treasury<T>,
new_master_minter: address,
ctx: &TxContext,
) {
treasury.assert_is_compatible();
treasury.roles_mut().update_master_minter(new_master_minter, ctx)
}

/// Change the blocklister address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_blocklister<T>(treasury: &mut Treasury<T>, new_blocklister: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_blocklister(new_blocklister, ctx)
}
/// Change the blocklister address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_blocklister<T>(
treasury: &mut Treasury<T>,
new_blocklister: address,
ctx: &TxContext,
) {
treasury.assert_is_compatible();
treasury.roles_mut().update_blocklister(new_blocklister, ctx)
}

/// Change the pauser address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_pauser<T>(treasury: &mut Treasury<T>, new_pauser: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_pauser(new_pauser, ctx)
}
/// Change the pauser address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_pauser<T>(treasury: &mut Treasury<T>, new_pauser: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_pauser(new_pauser, ctx)
}

/// Change the metadata updater address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_metadata_updater<T>(treasury: &mut Treasury<T>, new_metadata_updater: address, ctx: &TxContext) {
treasury.assert_is_compatible();
treasury.roles_mut().update_metadata_updater(new_metadata_updater, ctx)
}
/// Change the metadata updater address.
/// - Only callable by the owner.
/// - Only callable if the Treasury object is compatible with this package.
entry fun update_metadata_updater<T>(
treasury: &mut Treasury<T>,
new_metadata_updater: address,
ctx: &TxContext,
) {
treasury.assert_is_compatible();
treasury.roles_mut().update_metadata_updater(new_metadata_updater, ctx)
}
83 changes: 41 additions & 42 deletions packages/stablecoin/sources/mint_allowance.move
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,45 @@
// See the License for the specific language governing permissions and
// limitations under the License.

module stablecoin::mint_allowance {

const EOverflow: u64 = 0;
const EInsufficientAllowance: u64 = 1;

/// A MintAllowance for a coin of type T.
/// Used for minting and burning.
public struct MintAllowance<phantom T> has store {
value: u64
}

/// [Package private] Gets the current allowance of the MintAllowance object.
public(package) fun value<T>(self: &MintAllowance<T>): u64 {
self.value
}

/// [Package private] Create a new MintAllowance for type T.
public(package) fun new<T>(): MintAllowance<T> {
MintAllowance { value: 0 }
}

/// [Package private] Set allowance to `value`
public(package) fun set<T>(self: &mut MintAllowance<T>, value: u64) {
self.value = value;
}

/// [Package private] Increase the allowance by `value`
public(package) fun increase<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(value < (18446744073709551615u64 - self.value), EOverflow);
self.value = self.value + value;
}

/// [Package private] Decrease the allowance by `value`
public(package) fun decrease<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(self.value >= value, EInsufficientAllowance);
self.value = self.value - value;
}

/// [Package private] Destroy object
public(package) fun destroy<T>(self: MintAllowance<T>) {
let MintAllowance { value: _ } = self;
}
module stablecoin::mint_allowance;

const EOverflow: u64 = 0;
const EInsufficientAllowance: u64 = 1;

/// A MintAllowance for a coin of type T.
/// Used for minting and burning.
public struct MintAllowance<phantom T> has store {
value: u64,
}

/// [Package private] Gets the current allowance of the MintAllowance object.
public(package) fun value<T>(self: &MintAllowance<T>): u64 {
self.value
}

/// [Package private] Create a new MintAllowance for type T.
public(package) fun new<T>(): MintAllowance<T> {
MintAllowance { value: 0 }
}

/// [Package private] Set allowance to `value`
public(package) fun set<T>(self: &mut MintAllowance<T>, value: u64) {
self.value = value;
}

/// [Package private] Increase the allowance by `value`
public(package) fun increase<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(value < (std::u64::max_value!() - self.value), EOverflow);
self.value = self.value + value;
}

/// [Package private] Decrease the allowance by `value`
public(package) fun decrease<T>(self: &mut MintAllowance<T>, value: u64) {
assert!(self.value >= value, EInsufficientAllowance);
self.value = self.value - value;
}

/// [Package private] Destroy object
public(package) fun destroy<T>(self: MintAllowance<T>) {
let MintAllowance { value: _ } = self;
}
Loading
Loading