Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
refactor(experimental): graphql: token-2022 extensions: EnableConfide…
Browse files Browse the repository at this point in the history
…ntialTransferNonConfidentialCredits DisableNonConfidentialTransferConfidentialCredits
  • Loading branch information
nasjuice committed May 6, 2024
1 parent 7f6f40f commit 5af1db2
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 0 deletions.
56 changes: 56 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2212,6 +2212,62 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
account: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
owner: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
},
type: 'enableConfidentialTransferNonConfidentialCredits',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
account: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
multisigOwner: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
signers: [
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
],
},
type: 'enableConfidentialTransferNonConfidentialCredits',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
account: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
owner: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
},
type: 'disableNonConfidentialTransferConfidentialCredits',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
account: '2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
multisigOwner: 'FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ',
signers: [
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
'2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB',
],
},
type: 'disableNonConfidentialTransferConfidentialCredits',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
120 changes: 120 additions & 0 deletions packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2414,6 +2414,126 @@ describe('transaction', () => {
},
});
});

it('enable-confidential-transfer-non-confidential-credits', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenEnableConfidentialTransferNonConfidentialCredits {
account {
address
}
multisigOwner {
address
}
owner {
address
}
signers
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
account: {
address: expect.any(String),
},
multisigOwner: null,
owner: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
signers: null,
},
{
account: {
address: expect.any(String),
},
multisigOwner: {
address: expect.any(String),
},
owner: null,
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
signers: expect.arrayContaining([expect.any(String)]),
},
]),
},
},
},
});
});

it('disable-non-confidential-transfer-confidential-credits', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenDisableNonConfidentialTransferConfidentialCredits {
account {
address
}
multisigOwner {
address
}
owner {
address
}
signers
}
}
}
}
}
`;
const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
account: {
address: expect.any(String),
},
multisigOwner: null,
owner: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
signers: null,
},
{
account: {
address: expect.any(String),
},
multisigOwner: {
address: expect.any(String),
},
owner: null,
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
signers: expect.arrayContaining([expect.any(String)]),
},
]),
},
},
},
});
});
});
});
});
16 changes: 16 additions & 0 deletions packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ export const instructionResolvers = {
multisigOwner: resolveAccount('multisigOwner'),
owner: resolveAccount('owner'),
},
SplTokenDisableNonConfidentialTransferConfidentialCredits: {
account: resolveAccount('account'),
multisigOwner: resolveAccount('multisigOwner'),
owner: resolveAccount('owner'),
},
SplTokenDisableRequiredMemoTransfers: {
account: resolveAccount('account'),
multisigOwner: resolveAccount('multisigOwner'),
Expand All @@ -228,6 +233,11 @@ export const instructionResolvers = {
multisigOwner: resolveAccount('multisigOwner'),
owner: resolveAccount('owner'),
},
SplTokenEnableConfidentialTransferNonConfidentialCredits: {
account: resolveAccount('account'),
multisigOwner: resolveAccount('multisigOwner'),
owner: resolveAccount('owner'),
},
SplTokenEnableCpiGuardInstruction: {
account: resolveAccount('account'),
multisigOwner: resolveAccount('multisigOwner'),
Expand Down Expand Up @@ -763,6 +773,12 @@ export const instructionResolvers = {
if (jsonParsedConfigs.instructionType === 'disableConfidentialTransferConfidentialCredits') {
return 'SplTokenDisableConfidentialTransferConfidentialCredits';
}
if (jsonParsedConfigs.instructionType === 'enableConfidentialTransferNonConfidentialCredits') {
return 'SplTokenEnableConfidentialTransferNonConfidentialCredits';
}
if (jsonParsedConfigs.instructionType === 'disableNonConfidentialTransferConfidentialCredits') {
return 'SplTokenDisableNonConfidentialTransferConfidentialCredits';
}
}
if (jsonParsedConfigs.programName === 'stake') {
if (jsonParsedConfigs.instructionType === 'initialize') {
Expand Down
21 changes: 21 additions & 0 deletions packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,27 @@ export const instructionTypeDefs = /* GraphQL */ `
signers: [Address]
}
"""
SplToken-2022: EnableConfidentialTransferNonConfidentialCredits instruction
"""
type SplTokenEnableConfidentialTransferNonConfidentialCredits implements TransactionInstruction {
programId: Address
account: Account
multisigOwner: Account
owner: Account
signers: [Address]
}
"""
SplToken-2022: DisableNonConfidentialTransferConfidentialCredits instruction
"""
type SplTokenDisableNonConfidentialTransferConfidentialCredits implements TransactionInstruction {
programId: Address
account: Account
multisigOwner: Account
owner: Account
signers: [Address]
}
# TODO: Extensions!
# ...
Expand Down

0 comments on commit 5af1db2

Please sign in to comment.