Skip to content

Commit c30a1bd

Browse files
committed
Derive multisigTokenAuthority from token mint info
1 parent 703df78 commit c30a1bd

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

solana/tests/anchor.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ describe("example-native-token-transfers", () => {
504504
const published = emitter.publishMessage(0, serialized, 200);
505505
const rawVaa = guardians.addSignatures(published, [0]);
506506
const vaa = deserialize("Ntt:WormholeTransfer", serialize(rawVaa));
507-
const redeemTxs = ntt.redeem([vaa], sender, multisigTokenAuthority);
507+
const redeemTxs = ntt.redeem([vaa], sender);
508508
await signSendWait(ctx, redeemTxs, signer);
509509

510510
assert.bn(await testDummyTransferHook.counter.value()).equal(2);

solana/ts/lib/ntt.ts

+12-9
Original file line numberDiff line numberDiff line change
@@ -549,14 +549,24 @@ export namespace NTT {
549549
nttMessage: Ntt.Message;
550550
revertOnDelay: boolean;
551551
recipient?: PublicKey;
552-
multisigTokenAuthority?: PublicKey;
553552
},
554553
pdas?: Pdas
555554
): Promise<TransactionInstruction> {
556555
const [major, , ,] = parseVersion(program.idl.version);
557556

558557
pdas = pdas ?? NTT.pdas(program.programId);
559558

559+
const mintInfo = await splToken.getMint(
560+
program.provider.connection,
561+
config.mint,
562+
undefined,
563+
config.tokenProgram
564+
);
565+
let multisigTokenAuthority: PublicKey | null = null;
566+
if (!mintInfo.mintAuthority?.equals(pdas.tokenAuthority())) {
567+
multisigTokenAuthority = mintInfo.mintAuthority;
568+
}
569+
560570
const recipientAddress =
561571
args.recipient ??
562572
(await getInboxItem(program, args.chain, args.nttMessage))
@@ -584,19 +594,12 @@ export namespace NTT {
584594
},
585595
// NOTE: SPL Multisig token authority is only support for versions >= 3.x.x
586596
...(major >= 3 && {
587-
multisigTokenAuthority: args.multisigTokenAuthority ?? null,
597+
multisigTokenAuthority,
588598
}),
589599
})
590600
.instruction();
591601

592-
const mintInfo = await splToken.getMint(
593-
program.provider.connection,
594-
config.mint,
595-
undefined,
596-
config.tokenProgram
597-
);
598602
const transferHook = splToken.getTransferHook(mintInfo);
599-
600603
if (transferHook) {
601604
const source = await custodyAccountAddress(pdas, config);
602605
const mint = config.mint;

solana/ts/sdk/ntt.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -954,11 +954,7 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
954954
}
955955
}
956956

957-
async *redeem(
958-
attestations: Ntt.Attestation[],
959-
payer: AccountAddress<C>,
960-
multisigTokenAuthority?: PublicKey
961-
) {
957+
async *redeem(attestations: Ntt.Attestation[], payer: AccountAddress<C>) {
962958
const config = await this.getConfig();
963959
if (config.paused) throw new Error("Contract is paused");
964960

@@ -1022,7 +1018,6 @@ export class SolanaNtt<N extends Network, C extends SolanaChains>
10221018
})
10231019
: NTT.createReleaseInboundMintInstruction(this.program, config, {
10241020
...releaseArgs,
1025-
multisigTokenAuthority,
10261021
});
10271022

10281023
const tx = new Transaction();

0 commit comments

Comments
 (0)