metaplex-foundation / python-api

136 stars 86 forks source link

update the primary_sale_happened property #41

Open dusking opened 2 years ago

dusking commented 2 years ago

The update_token_metadata function doesn't allow updating primary_sale_happened. Is there another way to do so?

crypt0miester commented 2 years ago

it is the byte before the last, in line 187. in metadata.py.

 ​    ​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​0​, ​0​])

value I believe is 1 if the primary sale has happened.

sorry, I am in mobile.

JeffryCA commented 2 years ago

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])
JeffryCA commented 2 years ago

The

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])

This sadly does not work. Can you elaborate further @crypt0miester ?

The error is:

3 Metaplex Token Metadata instruction

Program log: Error: BorshIoError Program Metaplex Token Metadata consumed 3816 of 200000 compute units Program returned error: Failed to serialize or deserialize account data: Unknown

crypt0miester commented 2 years ago

The

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])

This sadly does not work. Can you elaborate further @crypt0miester ?

The error is:

3 Metaplex Token Metadata instruction

Program log: Error: BorshIoError Program Metaplex Token Metadata consumed 3816 of 200000 compute units Program returned error: Failed to serialize or deserialize account data: Unknown

you only changed 0 to 1? have you made any other changes? I will have to test the code. currently AFK.

JeffryCA commented 2 years ago

The

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])

This sadly does not work. Can you elaborate further @crypt0miester ? The error is:

3 Metaplex Token Metadata instruction

Program log: Error: BorshIoError Program Metaplex Token Metadata consumed 3816 of 200000 compute units Program returned error: Failed to serialize or deserialize account data: Unknown

you only changed 0 to 1? have you made any other changes? I will have to test the code. currently AFK.

I only change 0 to 1. No other changes.

crypt0miester commented 2 years ago

The

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])

This sadly does not work. Can you elaborate further @crypt0miester ? The error is:

3 Metaplex Token Metadata instruction

Program log: Error: BorshIoError Program Metaplex Token Metadata consumed 3816 of 200000 compute units Program returned error: Failed to serialize or deserialize account data: Unknown

you only changed 0 to 1? have you made any other changes? I will have to test the code. currently AFK.

I only change 0 to 1. No other changes.

send me the transaction id

JeffryCA commented 2 years ago

The

Like this?

​_data​ ​=​ ​bytes​([​1​]) ​+​ ​_get_data_buffer​(​name​, ​symbol​, ​uri​, ​fee​, ​creators​,  ​verified​, ​share​) ​+​ ​bytes​([​1​, ​0​])

This sadly does not work. Can you elaborate further @crypt0miester ? The error is:

3 Metaplex Token Metadata instruction

Program log: Error: BorshIoError Program Metaplex Token Metadata consumed 3816 of 200000 compute units Program returned error: Failed to serialize or deserialize account data: Unknown

you only changed 0 to 1? have you made any other changes? I will have to test the code. currently AFK.

I only change 0 to 1. No other changes.

send me the transaction id

3HWEep4QApqbhb3kZpikEt9H1Gp58f4H4YVPM3BsqM9fDUEKc6GR8B1jt59UwpwKJ8iQxsBAHA7BW593evM5zf2H

JeffryCA commented 2 years ago

Any news @crypt0miester? Or any way you can point me to the right docs to try and change the code as well?

crypt0miester commented 2 years ago

contact me in discord CryptoMiester#1865

crypt0miester commented 2 years ago

https://github.com/crypt0miester/python-api/tree/v1.2

here you go, please test it.

JeffryCA commented 2 years ago

https://github.com/crypt0miester/python-api/tree/v1.2

here you go, please test it.

@crypt0miester I fixed some minor bugs to make the "update_primary_sale_happened" function work but the transaction failed.

1 Metaplex Token Metadata instruction

Program log: Instruction: Update primary sale via token Program log: Error: InvalidAccountData Program Metaplex Token Metadata consumed 1568 of 200000 compute units Program returned error: invalid account data for instruction

https://solscan.io/tx/2aUVQ5zfStewbn1JhFfUDL48NF7U62ABeZi7gjRxxGiTHGr2ymF5EGGE4TZU9kqbsY99cQv6D1Nqvg57R9P7mKVi?cluster=devnet

crypt0miester commented 2 years ago

you probably have a wrong account data value in your code. double check

JeffryCA commented 2 years ago

I think I was trying to call this before minting but after the creation of the metadata. I now tried after the mint and it worked. I was wondering if I always need the private key of the owner to perform the update?

crypt0miester commented 2 years ago

try adding the instruction at the end of the minting.

JeffryCA commented 2 years ago

I tried that but I get:

5 Metaplex Token Metadata instruction

Program log: Instruction: Update primary sale via token Program log: Owner does not match that on the account given Program Metaplex Token Metadata consumed 5831 of 200000 compute units Program returned error: custom program error: 0x2b

code looks like this:


...
create_master_edition_ix = create_master_edition_instruction(
        mint=mint_account,
        update_authority=source_account.public_key,
        mint_authority=source_account.public_key,
        payer=source_account.public_key,
        supply=supply,
)
tx = tx.add(create_master_edition_ix)

# update primary sale happened
update_primary_sale_happened_ix = update_primary_sale_happened_instruction(
    update_authority=source_account.public_key,
    mint_key=mint_account,
    token=associated_token_account,
)
tx = tx.add(update_primary_sale_happened_ix)
crypt0miester commented 2 years ago

guess it doesnt work. sorry can't help further.