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

[Bug] aptos _token_object.create_named_token getting error in public native fun create_snapshot #12505

Open
harispericorn opened this issue Mar 13, 2024 · 5 comments
Labels
bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@harispericorn
Copy link

harispericorn commented Mar 13, 2024

🐛 Bug

To reproduce

using aptos 3.0.2

Code snippet to reproduce

        let token_constructor_ref = token::create_named_token(
            resource_signer,
            collection_name,
            collection_description,
            token_name,
            option::none(),
            token_uri,
        );

with values 
 
        let token_constructor_ref = token::create_named_token(
            resource_signer,
            string::utf8(b"Collection #1"),,
            string::utf8(b"Collection desc #1"),
            string::utf8(b"Token #1"),
            option::none(),
            [token_uri](string::utf8(b"https://token.uri/1")),
        );
        

Stack trace/error message

│ 103 │     public native fun create_snapshot<Element: copy + drop>(value: Element): AggregatorSnapshot<Element>;
│     │                       ^^^^^^^^^^^^^^^
│     │                       │
│     │                       Test was not expected to error, but it aborted with code 196613 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::aggregator_v2 rooted here
│     │                       In this function in 0x1::aggregator_v2
│ 
│ 
│ stack trace
│       token_contract::create_token_extended(/home/spericorn/Documents/propbase-blockchain/sources/token_contract.move:472-479)
│       token_contract::create_token(/home/spericorn/Documents/propbase-blockchain/sources/token_contract.move:425-435)
│       primary_market_test::test_failure_set_sale_config_not_admin(/home/spericorn/Documents/propbase-blockchain/tests/primary_market.test.move:252-262)

Expected Behavior

it should not show error

System information

Please complete the following information:

  • Aptos Core Version : latest
  • Rust Version
  • Computer OS : Ubuntu

Additional context

hero contract also errors

image

@harispericorn harispericorn added the bug Something isn't working label Mar 13, 2024
@mashharuki
Copy link
Contributor

@mashharuki
Copy link
Contributor

INCLUDING DEPENDENCY AptosFramework
INCLUDING DEPENDENCY AptosStdlib
INCLUDING DEPENDENCY AptosTokenObjects
INCLUDING DEPENDENCY MoveStdlib
BUILDING marketplace
Running Move unit tests
[ FAIL    ] 0x9324da379576a6210929ee2611cd1995a21451d0be44ec92a92d17cae1d665ee::test_list_and_purchase::test_fixed_price
[ PASS    ] 0x9324da379576a6210929ee2611cd1995a21451d0be44ec92a92d17cae1d665ee::test_list_and_purchase::test_no_listing
[ FAIL    ] 0x9324da379576a6210929ee2611cd1995a21451d0be44ec92a92d17cae1d665ee::test_list_and_purchase::test_not_enough_coin_fixed_price

Test failures:

Failures in 0x9324da379576a6210929ee2611cd1995a21451d0be44ec92a92d17cae1d665ee::test_list_and_purchase:

┌── test_fixed_price ──────
│ error[E11001]: test failure
│     ┌─ /Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-framework/sources/aggregator_v2/aggregator_v2.move:103:23
│     │
│ 103 │     public native fun create_snapshot<Element: copy + drop>(value: Element): AggregatorSnapshot<Element>;
│     │                       ^^^^^^^^^^^^^^^
│     │                       │
│     │                       Test was not expected to error, but it aborted with code 196613 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::aggregator_v2 rooted here
│     │                       In this function in 0x1::aggregator_v2
│ 
│ 
│ stack trace
│       aptos_token::mint_internal(/Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-token-objects/sources/aptos_token.move:284)
│       aptos_token::mint_token_object(/Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-token-objects/sources/aptos_token.move:193-202)
│       test_utils::mint_tokenv2_with_collection(/Users/harukikondo/git/marketplace-example/move/sources/test_utils.move:71-80)
│       test_utils::mint_tokenv2(/Users/harukikondo/git/marketplace-example/move/sources/test_utils.move:85)
│       test_list_and_purchase::test_fixed_price(/Users/harukikondo/git/marketplace-example/move/sources/list_and_purchase.move:331)
│ 
└──────────────────


┌── test_not_enough_coin_fixed_price ──────
│ error[E11001]: test failure
│     ┌─ /Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-framework/sources/aggregator_v2/aggregator_v2.move:103:23
│     │
│ 103 │     public native fun create_snapshot<Element: copy + drop>(value: Element): AggregatorSnapshot<Element>;
│     │                       ^^^^^^^^^^^^^^^
│     │                       │
│     │                       Test did not error as expected. Expected test to abort with code 65542 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::coin but instead it aborted with code 196613 originating in the module 0000000000000000000000000000000000000000000000000000000000000001::aggregator_v2 rooted here
│     │                       In this function in 0x1::aggregator_v2
│ 
│ 
│ stack trace
│       aptos_token::mint_internal(/Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-token-objects/sources/aptos_token.move:284)
│       aptos_token::mint_token_object(/Users/harukikondo/.move/https___github_com_aptos-labs_aptos-core_git_mainnet/aptos-move/framework/aptos-token-objects/sources/aptos_token.move:193-202)
│       test_utils::mint_tokenv2_with_collection(/Users/harukikondo/git/marketplace-example/move/sources/test_utils.move:71-80)
│       test_utils::mint_tokenv2(/Users/harukikondo/git/marketplace-example/move/sources/test_utils.move:85)
│       test_list_and_purchase::test_not_enough_coin_fixed_price(/Users/harukikondo/git/marketplace-example/move/sources/list_and_purchase.move:331)
│ 
└──────────────────

Test result: FAILED. Total tests: 3; passed: 1; failed: 2
{
  "Error": "Move unit tests failed"
}

@mashharuki
Copy link
Contributor

Code is here

#[test_only]
module marketplace::test_utils {
    use std::signer;
    use std::string;
    use std::vector;

    use aptos_framework::account;
    use aptos_framework::aptos_coin::{Self, AptosCoin};
    use aptos_framework::coin;
    use aptos_framework::object::{Self, Object};

    use aptos_token_objects::token::Token;
    use aptos_token_objects::aptos_token;
    use aptos_token_objects::collection::Collection;
    use marketplace::list_and_purchase;

    public inline fun setup(
        aptos_framework: &signer,
        marketplace: &signer,
        seller: &signer,
        purchaser: &signer,
    ): (address, address, address) {
        list_and_purchase::setup_test(marketplace);
        let (burn_cap, mint_cap) = aptos_coin::initialize_for_test(aptos_framework);

        let marketplace_addr = signer::address_of(marketplace);
        account::create_account_for_test(marketplace_addr);
        coin::register<AptosCoin>(marketplace);

        let seller_addr = signer::address_of(seller);
        account::create_account_for_test(seller_addr);
        coin::register<AptosCoin>(seller);

        let purchaser_addr = signer::address_of(purchaser);
        account::create_account_for_test(purchaser_addr);
        coin::register<AptosCoin>(purchaser);

        let coins = coin::mint(10000, &mint_cap);
        coin::deposit(seller_addr, coins);
        let coins = coin::mint(10000, &mint_cap);
        coin::deposit(purchaser_addr, coins);

        coin::destroy_burn_cap(burn_cap);
        coin::destroy_mint_cap(mint_cap);

        (marketplace_addr, seller_addr, purchaser_addr)
    }

    public fun mint_tokenv2_with_collection(seller: &signer): (Object<Collection>, Object<Token>) {
        let collection_name = string::utf8(b"collection_name");

        let collection_object = aptos_token::create_collection_object(
            seller,
            string::utf8(b"collection description"),
            2,
            collection_name,
            string::utf8(b"collection uri"),
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            true,
            1,
            100,
        );

        let aptos_token = aptos_token::mint_token_object(
            seller,
            collection_name,
            string::utf8(b"description"),
            string::utf8(b"token_name"),
            string::utf8(b"uri"),
            vector::empty(),
            vector::empty(),
            vector::empty(),
        );
        (object::convert(collection_object), object::convert(aptos_token))
    }

    public fun mint_tokenv2(seller: &signer): Object<Token> {
        let (_collection, token) = mint_tokenv2_with_collection(seller);
        token
    }
}

@lbmeiyi lbmeiyi added the stale-exempt Prevents issues from being automatically marked and closed as stale label Mar 26, 2024
@arturgrigor
Copy link

Try changing the dependencies revisions in your Move.toml file from mainnet to main.

@sweetim
Copy link

sweetim commented Apr 14, 2024

it works on devnet too, however when it is published to the chain, and a transaction is made using the APTOS explorer to call this function will fail too, any workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
None yet
Development

No branches or pull requests

5 participants