Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 8766eb9

Browse files
author
Joe C
authored
token-js: add GroupPointer and GroupMemberPointer to setAuthority
Add the newly added `GroupPointer` and `GroupMemberPointer` to the `setAuthority` instruction.
1 parent b7949fc commit 8766eb9

File tree

3 files changed

+96
-0
lines changed

3 files changed

+96
-0
lines changed

token/js/src/instructions/setAuthority.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export enum AuthorityType {
2828
TransferHookProgramId = 10,
2929
ConfidentialTransferFeeConfig = 11,
3030
MetadataPointer = 12,
31+
GroupPointer = 13,
32+
GroupMemberPointer = 14,
3133
}
3234

3335
/** TODO: docs */

token/js/test/e2e-2022/groupMemberPointer.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { PublicKey } from '@solana/web3.js';
44
import { sendAndConfirmTransaction, Keypair, SystemProgram, Transaction } from '@solana/web3.js';
55

66
import {
7+
AuthorityType,
78
ExtensionType,
89
createInitializeGroupMemberPointerInstruction,
910
createInitializeMintInstruction,
11+
createSetAuthorityInstruction,
1012
createUpdateGroupMemberPointerInstruction,
1113
getGroupMemberPointerState,
1214
getMint,
@@ -94,4 +96,49 @@ describe('GroupMember pointer', () => {
9496
memberAddress: newGroupMemberAddress,
9597
});
9698
});
99+
100+
it('can update authority', async () => {
101+
const newAuthority = PublicKey.unique();
102+
const transaction = new Transaction().add(
103+
createSetAuthorityInstruction(
104+
mint.publicKey,
105+
mintAuthority.publicKey,
106+
AuthorityType.GroupMemberPointer,
107+
newAuthority,
108+
[],
109+
TEST_PROGRAM_ID
110+
)
111+
);
112+
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);
113+
114+
const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
115+
const groupMemberPointer = getGroupMemberPointerState(mintInfo);
116+
117+
expect(groupMemberPointer).to.deep.equal({
118+
authority: newAuthority,
119+
memberAddress,
120+
});
121+
});
122+
123+
it('can update authority to null', async () => {
124+
const transaction = new Transaction().add(
125+
createSetAuthorityInstruction(
126+
mint.publicKey,
127+
mintAuthority.publicKey,
128+
AuthorityType.GroupMemberPointer,
129+
null,
130+
[],
131+
TEST_PROGRAM_ID
132+
)
133+
);
134+
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);
135+
136+
const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
137+
const groupMemberPointer = getGroupMemberPointerState(mintInfo);
138+
139+
expect(groupMemberPointer).to.deep.equal({
140+
authority: null,
141+
memberAddress,
142+
});
143+
});
97144
});

token/js/test/e2e-2022/groupPointer.test.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ import { PublicKey } from '@solana/web3.js';
44
import { sendAndConfirmTransaction, Keypair, SystemProgram, Transaction } from '@solana/web3.js';
55

66
import {
7+
AuthorityType,
78
ExtensionType,
89
createInitializeGroupPointerInstruction,
910
createInitializeMintInstruction,
11+
createSetAuthorityInstruction,
1012
createUpdateGroupPointerInstruction,
1113
getGroupPointerState,
1214
getMint,
@@ -94,4 +96,49 @@ describe('Group pointer', () => {
9496
groupAddress: newGroupAddress,
9597
});
9698
});
99+
100+
it('can update authority', async () => {
101+
const newAuthority = PublicKey.unique();
102+
const transaction = new Transaction().add(
103+
createSetAuthorityInstruction(
104+
mint.publicKey,
105+
mintAuthority.publicKey,
106+
AuthorityType.GroupPointer,
107+
newAuthority,
108+
[],
109+
TEST_PROGRAM_ID
110+
)
111+
);
112+
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);
113+
114+
const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
115+
const groupPointer = getGroupPointerState(mintInfo);
116+
117+
expect(groupPointer).to.deep.equal({
118+
authority: newAuthority,
119+
groupAddress,
120+
});
121+
});
122+
123+
it('can update authority to null', async () => {
124+
const transaction = new Transaction().add(
125+
createSetAuthorityInstruction(
126+
mint.publicKey,
127+
mintAuthority.publicKey,
128+
AuthorityType.GroupPointer,
129+
null,
130+
[],
131+
TEST_PROGRAM_ID
132+
)
133+
);
134+
await sendAndConfirmTransaction(connection, transaction, [payer, mintAuthority], undefined);
135+
136+
const mintInfo = await getMint(connection, mint.publicKey, undefined, TEST_PROGRAM_ID);
137+
const groupPointer = getGroupPointerState(mintInfo);
138+
139+
expect(groupPointer).to.deep.equal({
140+
authority: null,
141+
groupAddress,
142+
});
143+
});
97144
});

0 commit comments

Comments
 (0)