Skip to content

Commit

Permalink
integrate supra-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
so-kkroy22 committed May 9, 2024
1 parent b7670d2 commit 19dfc03
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 64 deletions.
2 changes: 1 addition & 1 deletion aptos-move/framework/aptos-stdlib/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "1.0.0"
[addresses]
std = "0x1"
aptos_std = "0x1"
aptos_framework = "0x1"
supra_framework = "0x1"
Extensions = "0x1" # For Prover to instantiate `{{Ext}}` in prelude.

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/framework/aptos-token-objects/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ version = "1.0.0"
[addresses]
std = "0x1"
aptos_std = "0x1"
aptos_framework = "0x1"
supra_framework = "0x1"
aptos_token_objects = "0x4"

[dependencies]
MoveStdlib = { local = "../move-stdlib" }
AptosFramework = { local = "../aptos-framework"}
SupraFramework = { local = "../supra-framework"}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module aptos_token_objects::aptos_token {
use std::option::{Self, Option};
use std::string::String;
use std::signer;
use aptos_framework::object::{Self, ConstructorRef, Object};
use supra_framework::object::{Self, ConstructorRef, Object};
use aptos_token_objects::collection;
use aptos_token_objects::property_map;
use aptos_token_objects::royalty;
Expand All @@ -30,7 +30,7 @@ module aptos_token_objects::aptos_token {
/// The property map being mutated is not mutable
const EPROPERTIES_NOT_MUTABLE: u64 = 6;

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Storage state for managing the no-code Collection.
struct AptosCollection has key {
/// Used to mutate collection fields
Expand All @@ -55,7 +55,7 @@ module aptos_token_objects::aptos_token {
tokens_freezable_by_creator: bool,
}

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Storage state for managing the no-code Token.
struct AptosToken has key {
/// Used to burn.
Expand Down Expand Up @@ -672,7 +672,7 @@ module aptos_token_objects::aptos_token {
#[test_only]
use std::string;
#[test_only]
use aptos_framework::account;
use supra_framework::account;

#[test(creator = @0x123)]
fun test_create_and_transfer(creator: &signer) acquires AptosCollection, AptosToken {
Expand Down
20 changes: 10 additions & 10 deletions aptos-move/framework/aptos-token-objects/sources/collection.move
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ module aptos_token_objects::collection {
use std::option::{Self, Option};
use std::signer;
use std::string::{Self, String};
use aptos_framework::aggregator_v2::{Self, Aggregator, AggregatorSnapshot};
use aptos_framework::event;
use aptos_framework::object::{Self, ConstructorRef, ExtendRef, Object};
use supra_framework::aggregator_v2::{Self, Aggregator, AggregatorSnapshot};
use supra_framework::event;
use supra_framework::object::{Self, ConstructorRef, ExtendRef, Object};

use aptos_token_objects::royalty::{Self, Royalty};

Expand Down Expand Up @@ -53,7 +53,7 @@ module aptos_token_objects::collection {

const MAX_U64: u64 = 18446744073709551615;

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Represents the common fields for a collection.
struct Collection has key {
/// The creator of this collection.
Expand All @@ -80,7 +80,7 @@ module aptos_token_objects::collection {
mutated_field_name: String,
}

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Fixed supply tracker, this is useful for ensuring that a limited number of tokens are minted.
/// and adding events and supply tracking to a collection.
struct FixedSupply has key {
Expand All @@ -94,7 +94,7 @@ module aptos_token_objects::collection {
mint_events: event::EventHandle<MintEvent>,
}

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Unlimited supply tracker, this is useful for adding events and supply tracking to a collection.
struct UnlimitedSupply has key {
current_supply: u64,
Expand All @@ -105,7 +105,7 @@ module aptos_token_objects::collection {
mint_events: event::EventHandle<MintEvent>,
}

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Supply tracker, useful for tracking amount of issued tokens.
/// If max_value is not set to U64_MAX, this ensures that a limited number of tokens are minted.
struct ConcurrentSupply has key {
Expand Down Expand Up @@ -649,7 +649,7 @@ module aptos_token_objects::collection {
assert!(event::counter(&borrow_global<FixedSupply>(collection_address).burn_events) == 1, 0);
}

#[test(fx = @aptos_framework, creator = @0x123)]
#[test(fx = @supra_framework, creator = @0x123)]
fun test_create_mint_burn_for_concurrent(fx: &signer, creator: &signer) acquires FixedSupply, UnlimitedSupply, ConcurrentSupply {
let feature = features::get_concurrent_token_v2_feature();
let agg_feature = features::get_aggregator_v2_api_feature();
Expand Down Expand Up @@ -682,7 +682,7 @@ module aptos_token_objects::collection {
}

#[test(creator = @0x123, trader = @0x456)]
#[expected_failure(abort_code = 0x50003, location = aptos_framework::object)]
#[expected_failure(abort_code = 0x50003, location = supra_framework::object)]
entry fun test_create_and_transfer(creator: &signer, trader: &signer) {
let creator_address = signer::address_of(creator);
let collection_name = string::utf8(b"collection name");
Expand All @@ -696,7 +696,7 @@ module aptos_token_objects::collection {
}

#[test(creator = @0x123)]
#[expected_failure(abort_code = 0x80001, location = aptos_framework::object)]
#[expected_failure(abort_code = 0x80001, location = supra_framework::object)]
entry fun test_duplicate_collection(creator: &signer) {
let collection_name = string::utf8(b"collection name");
create_collection_helper(creator, collection_name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module aptos_token_objects::property_map {
use aptos_std::from_bcs;
use aptos_std::simple_map::{Self, SimpleMap};
use aptos_std::type_info;
use aptos_framework::object::{Self, ConstructorRef, Object};
use supra_framework::object::{Self, ConstructorRef, Object};

// Errors
/// The property map does not exist
Expand Down Expand Up @@ -48,7 +48,7 @@ module aptos_token_objects::property_map {
const STRING: u8 = 9;

// Structs
#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// A Map for typed key to value mapping, the contract using it
/// should keep track of what keys are what types, and parse them accordingly.
struct PropertyMap has drop, key {
Expand Down
4 changes: 2 additions & 2 deletions aptos-move/framework/aptos-token-objects/sources/royalty.move
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
module aptos_token_objects::royalty {
use std::error;
use std::option::{Self, Option};
use aptos_framework::object::{Self, ConstructorRef, ExtendRef, Object};
use supra_framework::object::{Self, ConstructorRef, ExtendRef, Object};

friend aptos_token_objects::token;

Expand All @@ -15,7 +15,7 @@ module aptos_token_objects::royalty {
/// The royalty denominator cannot be 0
const EROYALTY_DENOMINATOR_IS_ZERO: u64 = 3;

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// The royalty of a token within this collection
///
/// Royalties are optional for a collection. Royalty percentage is calculated
Expand Down
22 changes: 11 additions & 11 deletions aptos-move/framework/aptos-token-objects/sources/token.move
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ module aptos_token_objects::token {
use std::string::{Self, String};
use std::signer;
use std::vector;
use aptos_framework::aggregator_v2::{Self, AggregatorSnapshot, DerivedStringSnapshot};
use aptos_framework::event;
use aptos_framework::object::{Self, ConstructorRef, Object};
use supra_framework::aggregator_v2::{Self, AggregatorSnapshot, DerivedStringSnapshot};
use supra_framework::event;
use supra_framework::object::{Self, ConstructorRef, Object};
use aptos_std::string_utils::{to_string};
use aptos_token_objects::collection::{Self, Collection};
use aptos_token_objects::royalty::{Self, Royalty};

#[test_only]
use aptos_framework::object::ExtendRef;
use supra_framework::object::ExtendRef;

/// The token does not exist
const ETOKEN_DOES_NOT_EXIST: u64 = 1;
Expand All @@ -38,7 +38,7 @@ module aptos_token_objects::token {
const MAX_URI_LENGTH: u64 = 512;
const MAX_DESCRIPTION_LENGTH: u64 = 2048;

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Represents the common fields to all tokens.
struct Token has key {
/// The collection from which this token resides.
Expand All @@ -63,7 +63,7 @@ module aptos_token_objects::token {
mutation_events: event::EventHandle<MutationEvent>,
}

#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
/// Represents first addition to the common fields for all tokens
/// Starts being populated once aggregator_v2_api_enabled is enabled.
struct TokenIdentifiers has key {
Expand All @@ -76,7 +76,7 @@ module aptos_token_objects::token {

// DEPRECATED, NEVER USED
#[deprecated]
#[resource_group_member(group = aptos_framework::object::ObjectGroup)]
#[resource_group_member(group = supra_framework::object::ObjectGroup)]
struct ConcurrentTokenIdentifiers has key {
index: AggregatorSnapshot<u64>,
name: AggregatorSnapshot<String>,
Expand Down Expand Up @@ -612,7 +612,7 @@ module aptos_token_objects::token {
}

#[test(creator = @0x123)]
#[expected_failure(abort_code = 0x80001, location = aptos_framework::object)]
#[expected_failure(abort_code = 0x80001, location = supra_framework::object)]
fun test_duplicate_tokens(creator: &signer) {
let collection_name = string::utf8(b"collection name");
let token_name = string::utf8(b"token name");
Expand Down Expand Up @@ -722,7 +722,7 @@ module aptos_token_objects::token {

#[test(creator = @0x123)]
fun test_create_from_account_burn_and_delete(creator: &signer) acquires Token, TokenIdentifiers {
use aptos_framework::account;
use supra_framework::account;

let collection_name = string::utf8(b"collection name");
let token_name = string::utf8(b"token name");
Expand All @@ -747,7 +747,7 @@ module aptos_token_objects::token {

#[test(creator = @0x123,fx = @std)]
fun test_create_burn_and_delete(creator: &signer, fx: signer) acquires Token, TokenIdentifiers {
use aptos_framework::account;
use supra_framework::account;
use std::features;

let feature = features::get_auids();
Expand All @@ -774,7 +774,7 @@ module aptos_token_objects::token {
assert!(!object::is_object(token_addr), 2);
}

#[test(fx = @aptos_framework, creator = @0x123)]
#[test(fx = @supra_framework, creator = @0x123)]
fun test_upgrade_to_concurrent_and_numbered_tokens(fx: &signer, creator: &signer) acquires Token, TokenIdentifiers {
use std::debug;

Expand Down
4 changes: 2 additions & 2 deletions aptos-move/framework/aptos-token/Move.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ version = "1.0.0"

[addresses]
std = "0x1"
aptos_framework = "0x1"
supra_framework = "0x1"
aptos_token = "0x3"

[dependencies]
MoveStdlib = { local = "../move-stdlib" }
AptosFramework = { local = "../aptos-framework"}
SupraFramework = { local = "../supra-framework"}
16 changes: 8 additions & 8 deletions aptos-move/framework/aptos-token/sources/property_map.spec.move
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ spec aptos_token::property_map {
}

spec add(map: &mut PropertyMap, key: String, value: PropertyValue) {
use aptos_framework::simple_map;
use supra_framework::simple_map;

aborts_if !(string::length(key) <= MAX_PROPERTY_NAME_LENGTH);
aborts_if !(!simple_map::spec_contains_key(map.map, key));
Expand All @@ -65,15 +65,15 @@ spec aptos_token::property_map {
}

spec borrow(map: &PropertyMap, key: &String): &PropertyValue {
use aptos_framework::simple_map;
use supra_framework::simple_map;
aborts_if !simple_map::spec_contains_key(map.map, key);
}

/// Check utf8 for correctness and whether equal
/// to `prop.type`
spec read_string(map: &PropertyMap, key: &String): String {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;
pragma aborts_if_is_partial;

// TODO: Unable to handle abort from `from_bcs::to_string` because there is a function call at assert.
Expand All @@ -90,7 +90,7 @@ spec aptos_token::property_map {

spec read_u8(map: &PropertyMap, key: &String): u8 {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;

let str = b"u8";
aborts_if !simple_map::spec_contains_key(map.map, key);
Expand All @@ -102,7 +102,7 @@ spec aptos_token::property_map {

spec read_u64(map: &PropertyMap, key: &String): u64 {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;

let str = b"u64";
aborts_if !simple_map::spec_contains_key(map.map, key);
Expand All @@ -114,7 +114,7 @@ spec aptos_token::property_map {

spec read_address(map: &PropertyMap, key: &String): address {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;

let str = b"address";
aborts_if !simple_map::spec_contains_key(map.map, key);
Expand All @@ -126,7 +126,7 @@ spec aptos_token::property_map {

spec read_u128(map: &PropertyMap, key: &String): u128 {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;

let str = b"u128";
aborts_if !simple_map::spec_contains_key(map.map, key);
Expand All @@ -138,7 +138,7 @@ spec aptos_token::property_map {

spec read_bool(map: &PropertyMap, key: &String): bool {
use std::string;
use aptos_framework::simple_map;
use supra_framework::simple_map;

let str = b"bool";
aborts_if !simple_map::spec_contains_key(map.map, key);
Expand Down
6 changes: 3 additions & 3 deletions aptos-move/framework/aptos-token/sources/token.move
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ module aptos_token::token {
use std::string::{Self, String};
use std::vector;

use aptos_framework::account;
use aptos_framework::event::{Self, EventHandle};
use aptos_framework::timestamp;
use supra_framework::account;
use supra_framework::event::{Self, EventHandle};
use supra_framework::timestamp;
use aptos_std::table::{Self, Table};
use aptos_token::property_map::{Self, PropertyMap, PropertyValue};
use aptos_token::token_event_store;
Expand Down
8 changes: 4 additions & 4 deletions aptos-move/framework/aptos-token/sources/token.spec.move
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ spec aptos_token::token {
spec withdraw_with_capability(
withdraw_proof: WithdrawCapability,
): Token {
let now_seconds = global<timestamp::CurrentTimeMicroseconds>(@aptos_framework).microseconds;
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@aptos_framework);
let now_seconds = global<timestamp::CurrentTimeMicroseconds>(@supra_framework).microseconds;
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@supra_framework);
aborts_if now_seconds / timestamp::MICRO_CONVERSION_FACTOR > withdraw_proof.expiration_sec;
include WithdrawWithEventInternalAbortsIf{
account_addr: withdraw_proof.token_owner,
Expand All @@ -492,8 +492,8 @@ spec aptos_token::token {
withdraw_proof: WithdrawCapability,
withdraw_amount: u64,
): (Token, Option<WithdrawCapability>) {
let now_seconds = global<timestamp::CurrentTimeMicroseconds>(@aptos_framework).microseconds;
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@aptos_framework);
let now_seconds = global<timestamp::CurrentTimeMicroseconds>(@supra_framework).microseconds;
aborts_if !exists<timestamp::CurrentTimeMicroseconds>(@supra_framework);
aborts_if now_seconds / timestamp::MICRO_CONVERSION_FACTOR > withdraw_proof.expiration_sec;
aborts_if withdraw_amount > withdraw_proof.amount;
include WithdrawWithEventInternalAbortsIf{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module aptos_token::token_coin_swap {
use std::error;
use aptos_std::table::Table;
use aptos_std::type_info::TypeInfo;
use aptos_framework::event::EventHandle;
use supra_framework::event::EventHandle;
use aptos_token::token::{Token, TokenId};

//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
module aptos_token::token_event_store {
use std::string::String;
use std::signer;
use aptos_framework::event::{Self, EventHandle};
use aptos_framework::account;
use supra_framework::event::{Self, EventHandle};
use supra_framework::account;
use std::option::Option;
use aptos_std::any::Any;
use std::option;
Expand Down
Loading

0 comments on commit 19dfc03

Please sign in to comment.