Skip to content

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions account state:…
Browse files Browse the repository at this point in the history
… non transferable

This PR adds Token-2022 extension parsed account state support for `NonTransferable`.

Ref #2644.
  • Loading branch information
buffalojoec authored May 6, 2024
1 parent 5ab9e90 commit 2614fa2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
28 changes: 28 additions & 0 deletions packages/rpc-graphql/src/__tests__/account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
]),
},
},
});
});
});
});
});
3 changes: 3 additions & 0 deletions packages/rpc-graphql/src/resolvers/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down
7 changes: 7 additions & 0 deletions packages/rpc-graphql/src/schema/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ export const accountTypeDefs = /* GraphQL */ `
rateAuthority: Account
}
"""
Token-2022 Extension: Non-Transferable
"""
type SplToken2022ExtensionNonTransferable implements SplToken2022Extension {
extension: String
}
"""
Account interface
"""
Expand Down

0 comments on commit 2614fa2

Please sign in to comment.