Skip to content

Commit

Permalink
Merge pull request #3677 from iotaledger/chore/cleanup-iota-framework
Browse files Browse the repository at this point in the history
chore(iota-framework): cleanup framework, system and stardust Move packages
  • Loading branch information
miker83z authored Oct 28, 2024
2 parents c6bd157 + 6aa4029 commit ae8009f
Show file tree
Hide file tree
Showing 29 changed files with 66 additions and 295 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion crates/iota-framework-snapshot/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"1": {
"git_revision": "79d2e3399d20",
"git_revision": "f1f6c498eb44",
"package_ids": [
"0x0000000000000000000000000000000000000000000000000000000000000001",
"0x0000000000000000000000000000000000000000000000000000000000000002",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ module iota::authenticator_state {

fun jwk_equal(a: &JWK, b: &JWK): bool {
(&a.kty == &b.kty) &&
(&a.e == &b.e) &&
(&a.n == &b.n) &&
(&a.alg == &b.alg)
(&a.e == &b.e) &&
(&a.n == &b.n) &&
(&a.alg == &b.alg)
}

fun jwk_id_equal(a: &JwkId, b: &JwkId): bool {
Expand Down
12 changes: 0 additions & 12 deletions crates/iota-framework/packages/iota-framework/sources/coin.move
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,4 @@ module iota::coin {
}
}

// === Deprecated code ===

// oops, wanted treasury: &TreasuryCap<T>
public fun supply<T>(treasury: &mut TreasuryCap<T>): &Supply<T> {
&treasury.total_supply
}

// deprecated as we have CoinMetadata now
#[allow(unused_field)]
public struct CurrencyCreated<phantom T> has copy, drop {
decimals: u8
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ module iota::coin_manager {

/// Mint `amount` of `Coin` and send it to `recipient`. Invokes `mint()`.
public fun mint_and_transfer<T>(
_: &CoinManagerTreasuryCap<T>,
manager: &mut CoinManager<T>,
amount: u64,
recipient: address,
ctx: &mut TxContext
_: &CoinManagerTreasuryCap<T>,
manager: &mut CoinManager<T>,
amount: u64,
recipient: address,
ctx: &mut TxContext
) {
assert!(total_supply(manager) + amount <= maximum_supply(manager), EMaximumSupplyReached);
coin::mint_and_transfer(&mut manager.treasury_cap, amount, recipient, ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,7 @@ module iota::config {
)
}

/*
This is kept native to keep gas costing consistent.
*/
/* This is kept native to keep gas costing consistent. */
native fun read_setting_impl<
FieldSettingValue: key,
SettingValue: store,
Expand All @@ -276,15 +274,12 @@ module iota::config {
name: address,
current_epoch: u64,
): Option<Value>;
/*
// but the code is essentially
/* but the code is essentially:
if (!field::exists_with_type<Name, Value>(&config.id, setting)) return option::none()
let sobj: &Setting<Value> = field::borrow(&config.id, setting);
let data = sobj.data.borrow();
if (current_epoch > data.newer_value_epoch) option::some(data.newer_value)
else data.older_value_opt
}
*/

}
28 changes: 14 additions & 14 deletions crates/iota-framework/packages/iota-framework/sources/display.move
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ module iota::display {
/// on the property values of an Object.
/// ```
/// // Example of a display object
/// Display<0x...::capy::Capy> {
/// Display<0x107A::nft::Nft> {
/// fields:
/// <name, "Capy { genes }">
/// <link, "https://capy.art/capy/{ id }">
/// <image, "https://api.capy.art/capy/{ id }/svg">
/// <description, "Lovely Capy, one of many">
/// <name, "IOTEST Nft">
/// <link, "https://iotestnft.com/nft/{ id }">
/// <image, "https://api.iotestnft.com/nft/{ id }/svg">
/// <description, "One of many Iotest Nfts">
/// }
/// ```
///
Expand Down Expand Up @@ -200,26 +200,26 @@ module iota::display_tests {
#[allow(unused_field)]
/// An example object.
/// Purely for visibility.
public struct Capy has key {
public struct IotestNft has key {
id: UID,
name: String
}

/// Test witness type to create a Publisher object.
public struct CAPY has drop {}
public struct IOTESTNFT has drop {}

#[test]
fun capy_init() {
fun nft_test_init() {
let mut test = test::begin(@0x2);
let pub = package::test_claim(CAPY {}, test.ctx());
let pub = package::test_claim(IOTESTNFT {}, test.ctx());

// create a new display object
let mut display = display::new<Capy>(&pub, test.ctx());
let mut display = display::new<IotestNft>(&pub, test.ctx());

display.add(b"name".to_string(), b"Capy {name}".to_string());
display.add(b"link".to_string(), b"https://capy.art/capy/{id}".to_string());
display.add(b"image".to_string(), b"https://api.capy.art/capy/{id}/svg".to_string());
display.add(b"description".to_string(), b"A Lovely Capy".to_string());
display.add(b"name".to_string(), b"IOTEST Nft {name}".to_string());
display.add(b"link".to_string(), b"https://iotestnft.com/nft/{id}".to_string());
display.add(b"image".to_string(), b"https://api.iotestnft.com/nft/{id}/svg".to_string());
display.add(b"description".to_string(), b"One of many Iotest Nfts".to_string());

pub.burn_publisher();
transfer::public_transfer(display, @0x2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ module iota::kiosk {
const EWrongKiosk: u64 = 5;
/// Trying to exclusively list an already listed item.
const EAlreadyListed: u64 = 6;
/// Trying to call `uid_mut` when `allow_extensions` set to false.
const EUidAccessNotAllowed: u64 = 7;
/// 7 is reserved due to a previous interface having EUidAccessNotAllowed.
/// Attempt to `take` an item that is locked.
const EItemLocked: u64 = 8;
/// Taking or mutably borrowing an item that is listed.
Expand All @@ -143,12 +142,6 @@ module iota::kiosk {
/// Number of items stored in a Kiosk. Used to allow unpacking
/// an empty Kiosk if it was wrapped or has a single owner.
item_count: u32,
/// [DEPRECATED] Please, don't use the `allow_extensions` and the matching
/// `set_allow_extensions` function - it is a legacy feature that is being
/// replaced by the `kiosk_extension` module and its Extensions API.
///
/// Exposes `uid_mut` publicly when set to `true`, set to `false` by default.
allow_extensions: bool
}

/// A Capability granting the bearer a right to `place` and `take` items
Expand Down Expand Up @@ -248,7 +241,6 @@ module iota::kiosk {
profits: balance::zero(),
owner: ctx.sender(),
item_count: 0,
allow_extensions: false
};

let cap = KioskOwnerCap {
Expand All @@ -265,7 +257,7 @@ module iota::kiosk {
public fun close_and_withdraw(
self: Kiosk, cap: KioskOwnerCap, ctx: &mut TxContext
): Coin<IOTA> {
let Kiosk { id, profits, owner: _, item_count, allow_extensions: _ } = self;
let Kiosk { id, profits, owner: _, item_count } = self;
let KioskOwnerCap { id: cap_id, `for` } = cap;

assert!(id.to_inner() == `for`, ENotOwner);
Expand Down Expand Up @@ -532,16 +524,6 @@ module iota::kiosk {
&mut self.id
}

/// [DEPRECATED]
/// Allow or disallow `uid` and `uid_mut` access via the `allow_extensions`
/// setting.
public fun set_allow_extensions(
self: &mut Kiosk, cap: &KioskOwnerCap, allow_extensions: bool
) {
assert!(self.has_access(cap), ENotOwner);
self.allow_extensions = allow_extensions;
}

/// Get the immutable `UID` for dynamic field access.
/// Always enabled.
///
Expand All @@ -551,13 +533,6 @@ module iota::kiosk {
&self.id
}

/// Get the mutable `UID` for dynamic field access and extensions.
/// Aborts if `allow_extensions` set to `false`.
public fun uid_mut(self: &mut Kiosk): &mut UID {
assert!(self.allow_extensions, EUidAccessNotAllowed);
&mut self.id
}

/// Get the owner of the Kiosk.
public fun owner(self: &Kiosk): address {
self.owner
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

/// Defines a LabelerCap used for creating labels in a ``iota::timelock::Timelock`` object.
/// The LabelerCap can be created only be consuming an OTW, making then labels unique for each cap.
module iota::labeler {

/// Error code for when a type passed to the `create_labeler_cap` function is not a one-time witness.
Expand Down
43 changes: 0 additions & 43 deletions crates/iota-framework/packages/iota-framework/sources/math.move

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ module iota::pay {
vec.destroy_empty();
}

/// Join `coin` into `self`. Re-exports `coin::join` function.
/// Deprecated: you should call `coin.join(other)` directly.
public entry fun join<T>(self: &mut Coin<T>, coin: Coin<T>) {
self.join(coin)
}

/// Join everything in `coins` with `self`
public entry fun join_vec<T>(self: &mut Coin<T>, mut coins: vector<Coin<T>>) {
let (mut i, len) = (0, coins.length());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module iota::tx_context {
const ENoIDsCreated: u64 = 1;

/// Information about the transaction currently being executed.
/// This cannot be constructed by a transaction--it is a privileged object created by
/// This cannot be constructed by a transaction. It is a privileged object created by
/// the VM and passed in to the entrypoint of the transaction as `&mut TxContext`.
public struct TxContext has drop {
/// The address of the user that signed the current transaction
Expand Down Expand Up @@ -52,7 +52,7 @@ module iota::tx_context {

/// Return the epoch start time as a unix timestamp in milliseconds.
public fun epoch_timestamp_ms(self: &TxContext): u64 {
self.epoch_timestamp_ms
self.epoch_timestamp_ms
}

/// Create an `address` that has not been used. As it is an object address, it will never
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ module iota::vec_map {
const EUnequalLengths: u64 = 5;

/// A map data structure backed by a vector. The map is guaranteed not to contain duplicate keys, but entries
/// are *not* sorted by key--entries are included in insertion order.
/// All operations are O(N) in the size of the map--the intention of this data structure is only to provide
/// are *not* sorted by key. Entries are included in insertion order.
/// All operations are O(N) in the size of the map. The intention of this data structure is only to provide
/// the convenience of programming against a map API.
/// Large maps should use handwritten parent/child relationships instead.
/// Maps that need sorted iteration rather than insertion order iteration should also be handwritten.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module iota::vec_set {
const EKeyDoesNotExist: u64 = 1;

/// A set data structure backed by a vector. The set is guaranteed not to
/// contain duplicate keys. All operations are O(N) in the size of the set
/// - the intention of this data structure is only to provide the convenience
/// contain duplicate keys. All operations are O(N) in the size of the set.
/// The intention of this data structure is only to provide the convenience
/// of programming against a set API. Sets that need sorted iteration rather
/// than insertion order iteration should be handwritten.
public struct VecSet<K: copy + drop> has copy, drop, store {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module iota::address_tests {
assert!(@0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff.to_ascii_string() == b"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff".to_ascii_string());
}

#[test]
#[test]
fun to_string_ok() {
assert!(@0x0.to_string() == b"0000000000000000000000000000000000000000000000000000000000000000".to_string());
assert!(@0x1.to_string() == b"0000000000000000000000000000000000000000000000000000000000000001".to_string());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Modifications Copyright (c) 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

#[test_only, allow(deprecated_usage)]
#[test_only]
module iota::coin_tests {
use iota::coin::{Self, Coin};
use iota::pay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module iota::groth16_tests {

let vk_bytes = arr.pop_back();
assert!(vk_bytes == expected_vk_bytes);
}
}

#[test]
#[expected_failure(abort_code = groth16::EInvalidVerifyingKey)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ module iota::poseidon_tests {
assert!(actual == expected);

let msg = vector[1u256, 2u256, 3u256, 4u256, 5u256, 6u256, 7u256, 8u256, 9u256, 10u256,
11u256, 12u256, 13u256, 14u256, 15u256];
11u256, 12u256, 13u256, 14u256, 15u256];
let expected = 4203130618016961831408770638653325366880478848856764494148034853759773445968u256;
let actual = poseidon_bn254(&msg);
assert!(actual == expected);

let msg = vector[0u256, 1u256, 2u256, 3u256, 4u256, 5u256, 6u256, 7u256, 8u256, 9u256,
10u256, 11u256, 12u256, 13u256, 14u256, 15u256, 16u256, 17u256, 18u256, 19u256,
20u256, 21u256, 22u256, 23u256, 24u256, 25u256, 26u256, 27u256, 28u256, 29u256];
10u256, 11u256, 12u256, 13u256, 14u256, 15u256, 16u256, 17u256, 18u256, 19u256,
20u256, 21u256, 22u256, 23u256, 24u256, 25u256, 26u256, 27u256, 28u256, 29u256];
let expected = 4123755143677678663754455867798672266093104048057302051129414708339780424023u256;
let actual = poseidon_bn254(&msg);
assert!(actual == expected);

let msg = vector[0u256, 1u256, 2u256, 3u256, 4u256, 5u256, 6u256, 7u256, 8u256, 9u256,
10u256, 11u256, 12u256, 13u256, 14u256, 15u256, 16u256, 17u256, 18u256, 19u256,
20u256, 21u256, 22u256, 23u256, 24u256, 25u256, 26u256, 27u256, 28u256, 29u256,
30u256, 31u256, 32u256];
10u256, 11u256, 12u256, 13u256, 14u256, 15u256, 16u256, 17u256, 18u256, 19u256,
20u256, 21u256, 22u256, 23u256, 24u256, 25u256, 26u256, 27u256, 28u256, 29u256,
30u256, 31u256, 32u256];
let expected = 15368023340287843142129781602124963668572853984788169144128906033251913623349u256;
let actual = poseidon_bn254(&msg);
assert!(actual == expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ module iota::event_tests {
assert_eq(event::events_by_type<S1>().length(), 2)
}

#[test]
#[test]
fun test_emit_heterogenous() {
let e0 = S1(0);
let e1 = S2(1);
Expand Down
Loading

0 comments on commit ae8009f

Please sign in to comment.