Skip to content

Commit

Permalink
Merge branch 'solana-labs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
nasjuice authored May 9, 2024
2 parents d64f2ce + 211fde6 commit 7188ee8
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/rpc-graphql/src/__tests__/account-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,8 @@ describe('account', () => {
const megaMintAddress = '5gSwsLGzyCwgwPJSnxjsQCaFeE19ZFaibHMLky9TDFim';
// See scripts/fixtures/spl-token-22-mint-mega-token-member.json
const megaMemberAddress = 'CXZDzjSrQ5jPaBgk6ckTQrLPTnUURiY2GnAgVCS9Fggz';
// See scripts/fixtures/spl-token-22-account-mega-token-member.json
const megaAccountAddress = 'aUg6iJ3p43hTJsxHrQ1KfqMQYStoFvqcSJRcc51cYzK';
it('mint-close-authority', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
Expand Down Expand Up @@ -1903,6 +1905,60 @@ describe('account', () => {
},
});
});

it('confidential-transfer-account', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($address: Address!) {
account(address: $address) {
... on TokenAccount {
extensions {
... on SplTokenExtensionConfidentialTransferAccount {
actualPendingBalanceCreditCounter
allowConfidentialCredits
allowNonConfidentialCredits
approved
availableBalance
decryptableAvailableBalance
elgamalPubkey
expectedPendingBalanceCreditCounter
maximumPendingBalanceCreditCounter
pendingBalanceCreditCounter
pendingBalanceHi
pendingBalanceLo
extension
}
}
}
}
}
`;

const result = await rpcGraphQL.query(source, { address: megaAccountAddress });
expect(result).toMatchObject({
data: {
account: {
extensions: expect.arrayContaining([
{
actualPendingBalanceCreditCounter: null,
allowConfidentialCredits: expect.any(Boolean),
allowNonConfidentialCredits: expect.any(Boolean),
approved: expect.any(Boolean),
availableBalance: expect.any(String),
decryptableAvailableBalance: expect.any(String),
elgamalPubkey: expect.any(String),
expectedPendingBalanceCreditCounter: null,
extension: 'confidentialTransferAccount',
maximumPendingBalanceCreditCounter: null,
pendingBalanceCreditCounter: null,
pendingBalanceHi: expect.any(String),
pendingBalanceLo: expect.any(String),
},
]),
},
},
});
});
});
});
});
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 @@ -267,6 +267,9 @@ function resolveTokenExtensionType(extensionResult: Token2022ExtensionResult) {
if (extensionResult.extension === 'transferHook') {
return 'SplTokenExtensionTransferHook';
}
if (extensionResult.extension === 'confidentialTransferAccount') {
return 'SplTokenExtensionConfidentialTransferAccount';
}
}

export const accountResolvers = {
Expand Down
19 changes: 19 additions & 0 deletions packages/rpc-graphql/src/schema/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,25 @@ export const accountTypeDefs = /* GraphQL */ `
hookProgramId: Account
}
"""
Token-2022 Extension: ConfidentialTransferAccount
"""
type SplTokenExtensionConfidentialTransferAccount implements SplTokenExtension {
extension: String
actualPendingBalanceCreditCounter: Int
allowConfidentialCredits: Boolean
allowNonConfidentialCredits: Boolean
approved: Boolean
availableBalance: String
decryptableAvailableBalance: String
elgamalPubkey: String
expectedPendingBalanceCreditCounter: Int
maximumPendingBalanceCreditCounter: Int
pendingBalanceCreditCounter: Int
pendingBalanceHi: String
pendingBalanceLo: String
}
"""
Account interface
"""
Expand Down

0 comments on commit 7188ee8

Please sign in to comment.