me-foundation / open_creator_protocol

34 stars 15 forks source link

Accept a separate account to pay for fees when migrating to MPL. #76

Closed lithdew closed 1 year ago

lithdew commented 1 year ago

I ran into an issue with the "migrate to MPL" instruction.

OCP assumes that the "from" account specified here: https://github.com/magiceden-oss/open_creator_protocol/blob/main/programs/open_creator_protocol/src/instructions/nft_proxy/migrate_to_mpl.rs#L33-L49

... is responsible for paying for the fees when instantiating a master edition V3 account in Metaplex.

However, I am currently working with an OCP mint whose update authority is a PDA account (which must be specified as the "from" account in the "migrate to MPL" instruction), which does not have sufficient SOL to expend for instantiating the master edition V3 account.

And as shown in the line of code below, the "payer" account specified to Metaplex's "create_master_edition_v3" account in the "migrate to MPL" instruction is set to be the "from" account:

https://github.com/magiceden-oss/open_creator_protocol/blob/main/programs/open_creator_protocol/src/instructions/nft_proxy/migrate_to_mpl.rs#L135

I would like to propose adding a "payer" account argument to the "migrate to MPL" instruction to overcome this issue, which is to be passed to "create_master_edition_v3" as the payer account responsible for providing the SOL required to instantiate the Metaplex master edition account. Without it, I am unable to migrate any of the OCP mints I am working with to MPL.

    'Program ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E invoke [2]',
    'Program log: Instruction: MigrateToMpl',
    'Program CMTQqjzH6Anr9XcPVt73EFDTjWkJWPzH7H6DtvhHcyzV invoke [3]',
    'Program log: ManagedTokenInstruction::MigrationAuthority',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [4]',
    'Program log: Instruction: SetAuthority',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3007 of 338903 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [4]',
    'Program log: Instruction: SetAuthority',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3167 of 333344 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
    'Program CMTQqjzH6Anr9XcPVt73EFDTjWkJWPzH7H6DtvhHcyzV consumed 14996 of 344721 compute units',
    'Program CMTQqjzH6Anr9XcPVt73EFDTjWkJWPzH7H6DtvhHcyzV success',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [3]',
    'Program log: Instruction: ThawAccount',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4267 of 326926 compute units',
    'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [3]',
    'Program log: V3 Create Master Edition',
    'Program log: Transfer 2853600 lamports to the new account',
    'Program 11111111111111111111111111111111 invoke [4]',
    'Transfer: `from` must not carry data',
    'Program 11111111111111111111111111111111 failed: invalid program argument',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 24946 of 318051 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: invalid program argument',
    'Program ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E consumed 163383 of 456488 compute units',
    'Program ocp4vWUzA2z2XMYJ3QhM9vWdyoyoQwAFJhRdVTbvo9E failed: invalid program argument',
    'Program HGB5eybkj4y6tmWbsipqEUkBBrjHNpHCT72TiomDzRYd consumed 206895 of 500000 compute units',
    'Program HGB5eybkj4y6tmWbsipqEUkBBrjHNpHCT72TiomDzRYd failed: invalid program argument'
madergaser commented 1 year ago

PR #77 should fix this issue, program should be updated on devnet and mainnet and the npm release 0.3.5 has the new payer field as well.