Skip to content

Commit

Permalink
remove migrate instruction (#1117)
Browse files Browse the repository at this point in the history
* remove migrate instruction

* regen js api
  • Loading branch information
samuelvanderwaal authored Jun 15, 2023
1 parent 7551a28 commit 3d253df
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 446 deletions.
34 changes: 1 addition & 33 deletions token-metadata/js/idl/mpl_token_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3107,14 +3107,7 @@
"optional": true
}
],
"args": [
{
"name": "migrateArgs",
"type": {
"defined": "MigrateArgs"
}
}
],
"args": [],
"defaultOptionalAccounts": true,
"discriminant": {
"type": "u8",
Expand Down Expand Up @@ -5232,31 +5225,6 @@
]
}
},
{
"name": "MigrateArgs",
"type": {
"kind": "enum",
"variants": [
{
"name": "V1",
"fields": [
{
"name": "migration_type",
"type": {
"defined": "MigrationType"
}
},
{
"name": "rule_set",
"type": {
"option": "publicKey"
}
}
]
}
]
}
},
{
"name": "LockArgs",
"type": {
Expand Down
24 changes: 2 additions & 22 deletions token-metadata/js/src/generated/instructions/Migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,14 @@

import * as beet from '@metaplex-foundation/beet';
import * as web3 from '@solana/web3.js';
import { MigrateArgs, migrateArgsBeet } from '../types/MigrateArgs';

/**
* @category Instructions
* @category Migrate
* @category generated
*/
export type MigrateInstructionArgs = {
migrateArgs: MigrateArgs;
};
/**
* @category Instructions
* @category Migrate
* @category generated
*/
export const MigrateStruct = new beet.FixableBeetArgsStruct<
MigrateInstructionArgs & {
instructionDiscriminator: number;
}
>(
[
['instructionDiscriminator', beet.u8],
['migrateArgs', migrateArgsBeet],
],
export const MigrateStruct = new beet.BeetArgsStruct<{ instructionDiscriminator: number }>(
[['instructionDiscriminator', beet.u8]],
'MigrateInstructionArgs',
);
/**
Expand Down Expand Up @@ -81,20 +65,16 @@ export const migrateInstructionDiscriminator = 48;
* this was indicated in the IDL from which this instruction was generated.
*
* @param accounts that will be accessed while the instruction is processed
* @param args to provide as instruction data to the program
*
* @category Instructions
* @category Migrate
* @category generated
*/
export function createMigrateInstruction(
accounts: MigrateInstructionAccounts,
args: MigrateInstructionArgs,
programId = new web3.PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s'),
) {
const [data] = MigrateStruct.serialize({
instructionDiscriminator: migrateInstructionDiscriminator,
...args,
});
const keys: web3.AccountMeta[] = [
{
Expand Down
56 changes: 0 additions & 56 deletions token-metadata/js/src/generated/types/MigrateArgs.ts

This file was deleted.

1 change: 0 additions & 1 deletion token-metadata/js/src/generated/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export * from './Key';
export * from './LeafInfo';
export * from './LockArgs';
export * from './MetadataDelegateRole';
export * from './MigrateArgs';
export * from './MigrationType';
export * from './MintArgs';
export * from './MintNewEditionFromMasterEditionViaTokenArgs';
Expand Down
71 changes: 2 additions & 69 deletions token-metadata/program/src/instruction/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{
instruction::MetadataInstruction,
processor::AuthorizationData,
state::{
AssetData, Collection, CollectionDetails, Creator, Data, DataV2, MigrationType,
PrintSupply, TokenStandard, Uses,
AssetData, Collection, CollectionDetails, Creator, Data, DataV2, PrintSupply,
TokenStandard, Uses,
},
};

Expand Down Expand Up @@ -411,16 +411,6 @@ impl RuleSetToggle {

//-- End Toggle implementation

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
pub enum MigrateArgs {
V1 {
migration_type: MigrationType,
rule_set: Option<Pubkey>,
},
}

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
Expand Down Expand Up @@ -660,63 +650,6 @@ impl InstructionBuilder for super::builders::Create {
}
}

/// Migrates an asset to a ProgrammableAsset type.
///
/// # Accounts:
///
///
/// 0. `[writable]` Metadata account
/// 1. `[writable]` Edition account
/// 2. `[writable]` Token account
/// 3. `[]` Token account owner
/// 4. `[]` Mint account
/// 5. `[writable, signer]` Payer
/// 6. `[signer]` Update authority
/// 7. `[]` Collection metadata account
/// 8. `[]` Delegate record account
/// 9. `[writable]` Token record account
/// 10. `[]` System program
/// 11. `[]` Instruction sysvar account
/// 12. `[]` SPL Token Program
/// 13. `[optional]` Token Authorization Rules Program
/// 14. `[optional]` Token Authorization Rules account
impl InstructionBuilder for super::builders::Migrate {
fn instruction(&self) -> solana_program::instruction::Instruction {
let mut accounts = vec![
AccountMeta::new(self.metadata, false),
AccountMeta::new(self.edition, false),
AccountMeta::new(self.token, false),
AccountMeta::new_readonly(self.token_owner, false),
AccountMeta::new_readonly(self.mint, false),
AccountMeta::new(self.payer, true),
AccountMeta::new_readonly(self.authority, true),
AccountMeta::new_readonly(self.collection_metadata, false),
AccountMeta::new_readonly(self.delegate_record, false),
AccountMeta::new(self.token_record, false),
AccountMeta::new_readonly(self.system_program, false),
AccountMeta::new_readonly(self.sysvar_instructions, false),
AccountMeta::new_readonly(self.spl_token_program, false),
];

// Optional authorization rules accounts
if let Some(rules) = &self.authorization_rules {
accounts.push(AccountMeta::new_readonly(mpl_token_auth_rules::ID, false));
accounts.push(AccountMeta::new_readonly(*rules, false));
} else {
accounts.push(AccountMeta::new_readonly(crate::ID, false));
accounts.push(AccountMeta::new_readonly(crate::ID, false));
}

Instruction {
program_id: crate::ID,
accounts,
data: MetadataInstruction::Migrate(self.args.clone())
.try_to_vec()
.unwrap(),
}
}
}

/// Builds the instruction to mint a token.
///
/// # Accounts:
Expand Down
3 changes: 2 additions & 1 deletion token-metadata/program/src/instruction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub const DEPRECATED_CREATE_RESERVATION_LIST: u8 = 6;
pub const DEPRECATED_MINT_PRINTING_TOKENS_VIA_TOKEN: u8 = 8;
pub const DEPRECATED_MINT_PRINTING_TOKENS: u8 = 9;
pub const CREATE_METADATA_ACCOUNT_V2: u8 = 16;
pub const MIGRATE: u8 = 48;

#[repr(C)]
#[cfg_attr(feature = "serde-feature", derive(Serialize, Deserialize))]
Expand Down Expand Up @@ -696,7 +697,7 @@ pub enum MetadataInstruction {
#[account(13, optional, name="authorization_rules_program", desc="Token Authorization Rules Program")]
#[account(14, optional, name="authorization_rules", desc="Token Authorization Rules account")]
#[default_optional_accounts]
Migrate(MigrateArgs),
Migrate,

/// Transfer an asset.
///
Expand Down
Loading

0 comments on commit 3d253df

Please sign in to comment.