Repository: solana-labs/solana-program-library
Pull request #6294 (2024-02-24 15:03:04)

token-js: add `GroupPointer` and `GroupMemberPointer` to `setAuthority`
Add the newly added `GroupPointer` and `GroupMemberPointer` to the
`setAuthority` instruction.


buffalojoec: > [!WARNING]
> <b>This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6294?utm_source=stack-comment-downstack-mergeability-warning" >on Graphite</a>.</b>
> <a href="https://graphite.dev/docs/merge-pull-requests">Learn more</a>

Current dependencies on/for this PR:
* **#6293** <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6293?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a>
* **#6294** <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6294?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a> 👈
* **#6292** <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6292?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a>
* **#6291** <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6291?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a>
* **#6290** <a href="https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6290?utm_source=stack-comment-icon" target="_blank"><img src="https://static.graphite.dev/graphite-32x32-black.png" alt="Graphite" width="10px" height="10px"/></a>
* `master`

This [stack of pull requests](https://stacking.dev/?utm_source=stack-comment) is managed by [Graphite](https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6294?utm_source=stack-comment).
buffalojoec: ### Merge activity

* **Feb 24, 10:24 AM EST**: @buffalojoec started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/solana-labs/solana-program-library/6294).


Patch:
diff --git a/token/js/src/instructions/setAuthority.ts b/token/js/src/instructions/setAuthority.ts
index 545955cc1..58ef8e271 100644
--- a/token/js/src/instructions/setAuthority.ts
+++ b/token/js/src/instructions/setAuthority.ts
@@ -28,6 +28,8 @@ export enum AuthorityType {
     TransferHookProgramId = 10,
     ConfidentialTransferFeeConfig = 11,
     MetadataPointer = 12,
+    GroupPointer = 13,
+    GroupMemberPointer = 14,
 }
 
 /** TODO: docs */


Test patch:
diff --git a/token/js/test/e2e-2022/groupMemberPointer.test.ts b/token/js/test/e2e-2022/groupMemberPointer.test.ts
index bf5d664ff..7111787e1 100644
--- a/token/js/test/e2e-2022/groupMemberPointer.test.ts
+++ b/token/js/test/e2e-2022/groupMemberPointer.test.ts
@@ -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,
@@ -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,
+        });
+    });
 });
diff --git a/token/js/test/e2e-2022/groupPointer.test.ts b/token/js/test/e2e-2022/groupPointer.test.ts
index 0f2322dfe..5375031d4 100644
--- a/token/js/test/e2e-2022/groupPointer.test.ts
+++ b/token/js/test/e2e-2022/groupPointer.test.ts
@@ -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,
@@ -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,
+        });
+    });
 });