Skip to content

Commit

Permalink
token-js: add GroupPointer and GroupMemberPointer to setAuthority
Browse files Browse the repository at this point in the history
Add the newly added `GroupPointer` and `GroupMemberPointer` to the
`setAuthority` instruction.
  • Loading branch information
Joe C authored Feb 24, 2024
1 parent b7949fc commit 8766eb9
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
2 changes: 2 additions & 0 deletions token/js/src/instructions/setAuthority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export enum AuthorityType {
TransferHookProgramId = 10,
ConfidentialTransferFeeConfig = 11,
MetadataPointer = 12,
GroupPointer = 13,
GroupMemberPointer = 14,
}

/** TODO: docs */
Expand Down
47 changes: 47 additions & 0 deletions token/js/test/e2e-2022/groupMemberPointer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { PublicKey } from '@solana/web3.js';
import { sendAndConfirmTransaction, Keypair, SystemProgram, Transaction } from '@solana/web3.js';

import {
AuthorityType,
ExtensionType,
createInitializeGroupMemberPointerInstruction,
createInitializeMintInstruction,
createSetAuthorityInstruction,
createUpdateGroupMemberPointerInstruction,
getGroupMemberPointerState,
getMint,
Expand Down Expand Up @@ -94,4 +96,49 @@ describe('GroupMember pointer', () => {
memberAddress: newGroupMemberAddress,
});
});

it('can update authority', async () => {
const newAuthority = PublicKey.unique();
const transaction = new Transaction().add(
createSetAuthorityInstruction(
mint.publicKey,
mintAuthority.publicKey,
AuthorityType.GroupMemberPointer,
newAuthority,
[],
TEST_PROGRAM_ID
)
);
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);

const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
const groupMemberPointer = getGroupMemberPointerState(mintInfo);

expect(groupMemberPointer).to.deep.equal({
authority: newAuthority,
memberAddress,
});
});

it('can update authority to null', async () => {
const transaction = new Transaction().add(
createSetAuthorityInstruction(
mint.publicKey,
mintAuthority.publicKey,
AuthorityType.GroupMemberPointer,
null,
[],
TEST_PROGRAM_ID
)
);
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);

const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
const groupMemberPointer = getGroupMemberPointerState(mintInfo);

expect(groupMemberPointer).to.deep.equal({
authority: null,
memberAddress,
});
});
});
47 changes: 47 additions & 0 deletions token/js/test/e2e-2022/groupPointer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { PublicKey } from '@solana/web3.js';
import { sendAndConfirmTransaction, Keypair, SystemProgram, Transaction } from '@solana/web3.js';

import {
AuthorityType,
ExtensionType,
createInitializeGroupPointerInstruction,
createInitializeMintInstruction,
createSetAuthorityInstruction,
createUpdateGroupPointerInstruction,
getGroupPointerState,
getMint,
Expand Down Expand Up @@ -94,4 +96,49 @@ describe('Group pointer', () => {
groupAddress: newGroupAddress,
});
});

it('can update authority', async () => {
const newAuthority = PublicKey.unique();
const transaction = new Transaction().add(
createSetAuthorityInstruction(
mint.publicKey,
mintAuthority.publicKey,
AuthorityType.GroupPointer,
newAuthority,
[],
TEST_PROGRAM_ID
)
);
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);

const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
const groupPointer = getGroupPointerState(mintInfo);

expect(groupPointer).to.deep.equal({
authority: newAuthority,
groupAddress,
});
});

it('can update authority to null', async () => {
const transaction = new Transaction().add(
createSetAuthorityInstruction(
mint.publicKey,
mintAuthority.publicKey,
AuthorityType.GroupPointer,
null,
[],
TEST_PROGRAM_ID
)
);
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);

const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
const groupPointer = getGroupPointerState(mintInfo);

expect(groupPointer).to.deep.equal({
authority: null,
groupAddress,
});
});
});

0 comments on commit 8766eb9

Please sign in to comment.