Skip to content

Commit 5924438

Browse files
committed
feat: enforce permanent delegate extension for M on initialize
1 parent cbe938f commit 5924438

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

programs/earn/src/instructions/admin/initialize.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,17 @@ impl Initialize<'_> {
140140
return err!(EarnError::InvalidMint);
141141
}
142142

143-
// // 3. Must have the Permanent Delegate extension
144-
// // and the global account as the delegate
145-
// // The reason this is required is to enable forced exits to wM in the event
146-
// // an earner is removed from the earner list.
147-
// if !extensions.contains(&ExtensionType::PermanentDelegate) {
148-
// return err!(EarnError::InvalidMint);
149-
// }
150-
// let permanent_delegate_config = mint_ext_data.get_extension::<PermanentDelegate>()?;
151-
// if permanent_delegate_config.delegate != OptionalNonZeroPubkey(*global_key) {
152-
// return err!(EarnError::InvalidMint);
153-
// }
143+
// 3. Must have the Permanent Delegate extension
144+
// and the global account as the delegate
145+
// The reason this is required is to enable forced exits to wM in the event
146+
// an earner is removed from the earner list.
147+
if !extensions.contains(&ExtensionType::PermanentDelegate) {
148+
return err!(EarnError::InvalidMint);
149+
}
150+
let permanent_delegate_config = mint_ext_data.get_extension::<PermanentDelegate>()?;
151+
if permanent_delegate_config.delegate != OptionalNonZeroPubkey(*global_key) {
152+
return err!(EarnError::InvalidMint);
153+
}
154154

155155
Ok(())
156156
}

tests/test-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export async function createMintInstruction(
135135
const mintLen = getMintLen([
136136
ExtensionType.ScaledUiAmountConfig,
137137
ExtensionType.DefaultAccountState,
138-
// ExtensionType.PermanentDelegate,
138+
ExtensionType.PermanentDelegate,
139139
]);
140140

141141
const lamports = await connection.getMinimumBalanceForRentExemption(mintLen);
@@ -150,7 +150,7 @@ export async function createMintInstruction(
150150
}),
151151
createInitializeScaledUiAmountConfigInstruction(mint, extensionAuth, 1.0, TOKEN_2022_PROGRAM_ID),
152152
createInitializeDefaultAccountStateInstruction(mint, AccountState.Initialized, TOKEN_2022_PROGRAM_ID),
153-
// createInitializePermanentDelegateInstruction(mint, payer.publicKey, TOKEN_2022_PROGRAM_ID),
153+
createInitializePermanentDelegateInstruction(mint, payer.publicKey, TOKEN_2022_PROGRAM_ID),
154154
createInitializeMintInstruction(mint, 6, payer.publicKey, payer.publicKey, TOKEN_2022_PROGRAM_ID),
155155
];
156156

tests/unit/earn.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ class EarnTest<V extends Variant = Variant.New> {
466466
let tx = new Transaction();
467467
tx.add(...ixs);
468468

469-
await this.provider.sendAndConfirm!(tx, [this.admin, mint, mintAuthority]);
469+
await this.provider.sendAndConfirm!(tx, [this.admin, mint]);
470470

471471
// Verify the mint was created properly
472472
const mintInfo = await this.provider.connection.getAccountInfo(mint.publicKey);

0 commit comments

Comments
 (0)