From 2614fa20d2c5b4a0584baa265e42bd03b4984543 Mon Sep 17 00:00:00 2001 From: Joe C Date: Mon, 6 May 2024 09:47:01 -0500 Subject: [PATCH] refactor(experimental): graphql: token-2022 extensions account state: non transferable This PR adds Token-2022 extension parsed account state support for `NonTransferable`. Ref #2644. --- .../rpc-graphql/src/__tests__/account-test.ts | 28 +++++++++++++++++++ packages/rpc-graphql/src/resolvers/account.ts | 3 ++ packages/rpc-graphql/src/schema/account.ts | 7 +++++ 3 files changed, 38 insertions(+) diff --git a/packages/rpc-graphql/src/__tests__/account-test.ts b/packages/rpc-graphql/src/__tests__/account-test.ts index 492ad7efa7f0..e67e697433fd 100644 --- a/packages/rpc-graphql/src/__tests__/account-test.ts +++ b/packages/rpc-graphql/src/__tests__/account-test.ts @@ -1395,6 +1395,34 @@ describe('account', () => { }, }); }); + it('non-transferable', async () => { + expect.assertions(1); + const source = /* GraphQL */ ` + query testQuery($address: Address!) { + account(address: $address) { + ... on MintAccount { + extensions { + ... on SplToken2022ExtensionNonTransferable { + extension # Interface field + } + } + } + } + } + `; + const result = await rpcGraphQL.query(source, { address: megaMintAddress }); + expect(result).toMatchObject({ + data: { + account: { + extensions: expect.arrayContaining([ + { + extension: 'nonTransferable', + }, + ]), + }, + }, + }); + }); }); }); }); diff --git a/packages/rpc-graphql/src/resolvers/account.ts b/packages/rpc-graphql/src/resolvers/account.ts index bcb7579e7538..d6618de270d0 100644 --- a/packages/rpc-graphql/src/resolvers/account.ts +++ b/packages/rpc-graphql/src/resolvers/account.ts @@ -214,6 +214,9 @@ function resolveToken2022ExtensionType(extensionResult: Token2022ExtensionResult if (extensionResult.extension === 'mintCloseAuthority') { return 'SplToken2022ExtensionMintCloseAuthority'; } + if (extensionResult.extension === 'nonTransferable') { + return 'SplToken2022ExtensionNonTransferable'; + } if (extensionResult.extension === 'permanentDelegate') { return 'SplToken2022ExtensionPermanentDelegate'; } diff --git a/packages/rpc-graphql/src/schema/account.ts b/packages/rpc-graphql/src/schema/account.ts index ca3ba6d580d1..60684808b3a4 100644 --- a/packages/rpc-graphql/src/schema/account.ts +++ b/packages/rpc-graphql/src/schema/account.ts @@ -34,6 +34,13 @@ export const accountTypeDefs = /* GraphQL */ ` rateAuthority: Account } + """ + Token-2022 Extension: Non-Transferable + """ + type SplToken2022ExtensionNonTransferable implements SplToken2022Extension { + extension: String + } + """ Account interface """