Skip to content

Commit e65edd6

Browse files
committed
update portal mint
1 parent 16c6020 commit e65edd6

File tree

4 files changed

+73
-8
lines changed

4 files changed

+73
-8
lines changed

programs/portal/src/instructions/admin.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,22 @@ pub fn set_threshold(ctx: Context<SetThreshold>, threshold: u8) -> Result<()> {
625625
ctx.accounts.config.threshold = threshold;
626626
Ok(())
627627
}
628+
629+
// * Set Mint
630+
#[derive(Accounts)]
631+
pub struct SetMint<'info> {
632+
pub owner: Signer<'info>,
633+
634+
#[account(
635+
mut,
636+
has_one = owner,
637+
)]
638+
pub config: Account<'info, Config>,
639+
640+
pub mint: InterfaceAccount<'info, token_interface::Mint>,
641+
}
642+
643+
pub fn set_mint(ctx: Context<SetMint>) -> Result<()> {
644+
ctx.accounts.config.mint = ctx.accounts.mint.key();
645+
Ok(())
646+
}

programs/portal/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ pub mod portal {
172172
instructions::claim_token_authority(ctx)
173173
}
174174

175+
pub fn set_mint(ctx: Context<SetMint>) -> Result<()> {
176+
instructions::set_mint(ctx)
177+
}
178+
175179
pub fn set_paused(ctx: Context<SetPaused>, pause: bool) -> Result<()> {
176180
instructions::set_paused(ctx, pause)
177181
}

services/cli/main.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
} from '../../sdk/src';
4646
import { createInitializeConfidentialTransferMintInstruction } from './confidential-transfers';
4747
import { Program, BN } from '@coral-xyz/anchor';
48-
import { anchorProvider, keysFromEnv, NttManager } from './utils';
48+
import { anchorProvider, keysFromEnv, NttManager, updatePortalMint } from './utils';
4949
import { MerkleTree } from '../../sdk/src/merkle';
5050
import { bs58 } from '@coral-xyz/anchor/dist/cjs/utils/bytes';
5151
import { SolanaUnsignedTransaction } from '@wormhole-foundation/sdk-solana/dist/cjs';
@@ -78,7 +78,7 @@ async function main() {
7878
.command('print-addresses')
7979
.description('Print the addresses of all the relevant programs and accounts')
8080
.action(() => {
81-
const [mMint, wmMint, multisig] = keysFromEnv(['M_MINT_KEYPAIR', 'WM_MINT_KEYPAIR', 'M_MINT_MULTISIG_KEYPAIR']);
81+
const [mMint, wmMint] = keysFromEnv(['M_MINT_KEYPAIR', 'WM_MINT_KEYPAIR']);
8282
const [portalTokenAuthPda] = PublicKey.findProgramAddressSync([Buffer.from('token_authority')], PROGRAMS.portal);
8383
const [earnTokenAuthPda] = PublicKey.findProgramAddressSync([Buffer.from('token_authority')], PROGRAMS.earn);
8484
const [portalEmitter] = PublicKey.findProgramAddressSync([Buffer.from('emitter')], PROGRAMS.portal);
@@ -94,7 +94,6 @@ async function main() {
9494
'Earn Program': PROGRAMS.earn,
9595
'Swap Program': PROGRAMS.swap,
9696
'M Mint': mMint.publicKey,
97-
'M Mint Multisig': multisig.publicKey,
9897
'Portal Token Authority': portalTokenAuthPda,
9998
'Earn Token Authority': earnTokenAuthPda,
10099
'wM Mint': wmMint.publicKey,
@@ -246,7 +245,26 @@ async function main() {
246245
});
247246

248247
program.command('update-portal-mint').action(async () => {
249-
const [owner] = keysFromEnv(['PAYER_KEYPAIR']);
248+
const [payer, mint] = keysFromEnv(['PAYER_KEYPAIR', 'M_MINT_KEYPAIR']);
249+
const { ntt } = NttManager(connection, payer, mint.publicKey);
250+
251+
let owner = payer.publicKey;
252+
if (process.env.SQUADS_VAULT) {
253+
owner = new PublicKey(process.env.SQUADS_VAULT);
254+
}
255+
256+
const tx = new Transaction().add(updatePortalMint(owner, ntt.pdas.configAccount(), mint.publicKey));
257+
258+
if (process.env.SQUADS_VAULT) {
259+
const b = tx.serialize({ verifySignatures: false });
260+
console.log('Transaction:', {
261+
b64: b.toString('base64'),
262+
b58: bs58.encode(b),
263+
});
264+
} else {
265+
const sig = await connection.sendTransaction(tx, [payer]);
266+
console.log(`Paused: ${sig}`);
267+
}
250268
});
251269

252270
program
@@ -366,7 +384,7 @@ async function main() {
366384
const pauseTxn = (await ntt.pause(sender).next()).value as SolanaUnsignedTransaction<'Mainnet', 'Solana'>;
367385
const tx = pauseTxn.transaction.transaction as Transaction;
368386

369-
if (process.env.SQUADS_MULTISIG) {
387+
if (process.env.SQUADS_VAULT) {
370388
const b = tx.serialize({ verifySignatures: false });
371389
console.log('Transaction:', {
372390
b64: b.toString('base64'),
@@ -390,7 +408,7 @@ async function main() {
390408
const pauseTxn = (await cmd(sender).next()).value as SolanaUnsignedTransaction<'Mainnet', 'Solana'>;
391409
const tx = pauseTxn.transaction.transaction as Transaction;
392410

393-
if (process.env.SQUADS_MULTISIG) {
411+
if (process.env.SQUADS_VAULT) {
394412
const b = tx.serialize({ verifySignatures: false });
395413
console.log('Transaction:', {
396414
b64: b.toString('base64'),

services/cli/utils.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Keypair, Connection, PublicKey } from '@solana/web3.js';
1+
import { Keypair, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
22
import { SolanaNtt } from '@wormhole-foundation/sdk-solana-ntt';
33
import { SolanaPlatform, SolanaSendSigner } from '@wormhole-foundation/sdk-solana';
4-
import { AccountAddress, Wormhole } from '@wormhole-foundation/sdk';
4+
import { AccountAddress, sha256, Wormhole } from '@wormhole-foundation/sdk';
55
import { AnchorProvider, Wallet } from '@coral-xyz/anchor';
66

77
const PORTAL = new PublicKey('mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY');
@@ -45,3 +45,27 @@ export function anchorProvider(connection: Connection, owner: Keypair) {
4545
skipPreflight: false,
4646
});
4747
}
48+
49+
export function updatePortalMint(owner: PublicKey, config: PublicKey, mMint: PublicKey): TransactionInstruction {
50+
return new TransactionInstruction({
51+
programId: PORTAL,
52+
keys: [
53+
{
54+
pubkey: owner,
55+
isSigner: true,
56+
isWritable: false,
57+
},
58+
{
59+
pubkey: config,
60+
isSigner: false,
61+
isWritable: true,
62+
},
63+
{
64+
pubkey: mMint,
65+
isSigner: false,
66+
isWritable: false,
67+
},
68+
],
69+
data: Buffer.concat([Buffer.from(sha256('global:set_mint').subarray(0, 8))]),
70+
});
71+
}

0 commit comments

Comments
 (0)