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

Trying to use Burn Authority to burn asset owned by random wallet yields errors #118

Open
daoplays opened this issue May 9, 2024 · 1 comment
Assignees

Comments

@daoplays
Copy link

daoplays commented May 9, 2024

Hi, I created an asset with the below code via CPI:


CreateV1CpiBuilder::new(ctx.accounts.core_program)
            .authority(Some(ctx.accounts.program_pda))
            .asset(ctx.accounts.asset_account)
            .collection(Some(ctx.accounts.collection_account))
            .payer(ctx.accounts.user)
            .owner(Some(ctx.accounts.program_pda))
            .data_state(mpl_core::types::DataState::AccountState)
            .name(args.name.to_string())
            .uri(args.uri.to_string())
            .plugins(vec![
                mpl_core::types::PluginAuthorityPair {
                    plugin: mpl_core::types::Plugin::PermanentBurnDelegate(
                        mpl_core::types::PermanentBurnDelegate {},
                    ),
                    authority: Some(mpl_core::types::PluginAuthority::Address {
                        address: *ctx.accounts.program_pda.key,
                    }),
                },
                mpl_core::types::PluginAuthorityPair {
                    plugin: mpl_core::types::Plugin::PermanentTransferDelegate(
                        mpl_core::types::PermanentTransferDelegate {},
                    ),
                    authority: Some(mpl_core::types::PluginAuthority::Address {
                        address: *ctx.accounts.program_pda.key,
                    }),
                },
            ])
            .system_program(ctx.accounts.system_program)
            .invoke_signed(&[&[b"pda", &[pda_bump_seed]]])
            .unwrap();

This asset was then transferred to a random wallet. In a separate interaction with the program i tried to burn it using the program_pda account that was set as the permanent burn authority:

mpl_core::instructions::BurnV1CpiBuilder::new(ctx.accounts.core_program)
            .asset(ctx.accounts.asset_account)
            .collection(Some(ctx.accounts.collection_account))
            .authority(Some(ctx.accounts.program_pda))
            .payer(ctx.accounts.user)
            .system_program(Some(ctx.accounts.system_program))
            .invoke_signed(&[&[b"pda", &[pda_bump_seed]]])
            .unwrap();

This yielded the following error:
Program invoked: Unknown Program (CoREENxT6tW1HoK8ypY1SxRMZTcVPm7R94rH4PZNhX7d)
Program logged: "Instruction: Burn"
Program logged: "PermanentBurnDelegate: ForceApproved"
Program consumed: 13654 of 164453 compute units
Program returned error: "instruction changed the balance of a read-only account"

which i don't understand because all the accounts are writable.

I thought it might be because the burn deposits sol in the owners account, but that isn't passed in the above burn instruction, so i tried adding the owner as an extra account, but that gave a different error, that the owner wasn't a signer.

My expectation is that the program, designated as the burn authority, should be able to burn any asset, but i'm not sure how.

@danenbm
Copy link
Contributor

danenbm commented Jun 11, 2024

We previously had an issue where we were sending the SOL back to the authority, and the authority wasn't writable. At first we accidentally made the owner writable, but later fixed it to be the intended design which is send the SOL back to the payer, which is writable and a signer.

Its a bit confusing since we had multiple changes for this. The PR where we get it into the right state is:
#134. I think it could have also been confused by various clients which might have been different from the program.

But at this point it should be fixed, and the funds go back to the payer. Are you still having an issue with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants