aptos-labs / aptos-core

Aptos is a layer 1 blockchain built to support the widespread use of blockchain through better technology and user experience.
https://aptosfoundation.org
Other
6k stars 3.61k forks source link

[Bug] AptosCoin does not have a paired metadata #14033

Closed JoeruCodes closed 1 month ago

JoeruCodes commented 1 month ago

πŸ› Bug

According to the documentation it says that for migration reasons all coins automatically have a paired_metadata counterpart, but AptosCoin type doesnt seem to have one when 0x1::coin::paired_metadata is called.

https://aptos.dev/en/build/smart-contracts/fungible-asset

To reproduce

Code snippet to reproduce

    use aptos_framework::aptos_coin::AptosCoin;
    #[test]
    fun test_paired_metadata_for_apt(){
        assert!(option::is_some(&coin::paired_metadata<AptosCoin>()), 1);
    }

Stack trace/error message

β”Œβ”€β”€ test_paired_metadata_for_apt ──────
β”‚ error[E11001]: test failure
β”‚     β”Œβ”€ /sources/deployer.move:160:9
β”‚     β”‚
β”‚ 159 β”‚     fun test_paired_metadata_for_apt(){
β”‚     β”‚         ---------------------------- In this function in <addr>::deployer
β”‚ 160 β”‚         assert!(option::is_some(&coin::paired_metadata<AptosCoin>()), 0);
β”‚     β”‚         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Test was not expected to error, but it aborted with code 0 originating in the module <addr>::deployer rooted here

Expected Behavior

The assert shouldn't fail and instead of being empty, the option should have the paired metadata of the AptosCoin.

System information

Please complete the following information:

JoeruCodes commented 1 month ago

This function should create fungible_asset in the coin_conversion_table and may resolve this issue the only problem is that, I can't do it in my smart contract as it requires aptos_framework (0x1) as a signer...

Calling this function in the init_module function in the aptos_coin module should virtually solve this problem

image

lightmark commented 1 month ago

If this is for test, can you see https://github.com/aptos-labs/aptos-core/pull/12028 ? you can all ensure_initialized_with_fa_metadata_for_test before test your own code.

JoeruCodes commented 1 month ago

I see thank you