Skip to content

Commit

Permalink
solana-labs#2406: add multisigAuthority test in transfer-checked-with…
Browse files Browse the repository at this point in the history
…-fee
  • Loading branch information
Hrushi20 committed Apr 28, 2024
1 parent c4f6ca1 commit c70085f
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 3 deletions.
30 changes: 30 additions & 0 deletions packages/rpc-graphql/src/__tests__/__setup__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1712,6 +1712,36 @@ export const mockTransactionToken2022AllExtensions = {
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
},
{
parsed: {
info: {
destination: "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
feeAmount: {
amount: "5",
decimals: 2,
uiAmount: 0.05,
uiAmountString: "0.05"
},
mint: "FsHcsGiY43QmZc6yTgwYC1DA5U3ZgycXxn3bd2oBjrEZ",
multisigAuthority: "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
signers: [
"2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
"2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB"
],
source: "2Pwe6Yahh5cbzvCwRMtTYFeboSwYiWeHhYJzZZBsU6eB",
tokenAmount: {
amount: "55",
decimals: 2,
uiAmount: 0.55,
uiAmountString: "0.55"
}
},
type: 'transferCheckedWithFee',
},
program: 'spl-token',
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
stackHeight: null,
}
// TODO (more) ...
],
recentBlockhash: '6vRS7MoToVccMqfQecdVC6UbmARaT5mha91zhreqnce9',
Expand Down
84 changes: 83 additions & 1 deletion packages/rpc-graphql/src/__tests__/transaction-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ describe('transaction', () => {
});
});

it('transfer-checked-with-fee', async () => {
it('transfer-checked-with-fee-with-authority', async () => {
expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
Expand Down Expand Up @@ -975,6 +975,88 @@ describe('transaction', () => {
},
});
});

it('transfer-checked-with-fee-with-multisigAuthority', async () => {
// expect.assertions(1);
const source = /* GraphQL */ `
query testQuery($signature: Signature!) {
transaction(signature: $signature) {
message {
instructions {
programId
... on SplTokenTransferCheckedWithFee {
mint {
address
}
source {
address
}
destination {
address
}
feeAmount {
amount
decimals
uiAmount
uiAmountString
}
tokenAmount {
amount
decimals
uiAmount
uiAmountString
}
multisigAuthority {
address
}
signers
}
}
}
}
}
`;

const result = await rpcGraphQL.query(source, { signature });
expect(result).toMatchObject({
data: {
transaction: {
message: {
instructions: expect.arrayContaining([
{
destination: {
address: expect.any(String),
},
feeAmount: {
amount: expect.any(String),
decimals: expect.any(Number),
uiAmount: null, // can't convert decimal to BigInt
uiAmountString: expect.any(String),
},
mint: {
address: expect.any(String),
},
multisigAuthority: {
address: expect.any(String),
},
programId: 'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
signers: [expect.any(String),expect.any(String)],
source: {
address: expect.any(String),
},
tokenAmount: {
amount: expect.any(String),
decimals: expect.any(Number),
uiAmount: null, // Can't convert decimal to BigInt
uiAmountString: expect.any(String),
},
},
]),
},
},
},
});
});
});
});
});
3 changes: 2 additions & 1 deletion packages/rpc-graphql/src/resolvers/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,8 @@ export const instructionResolvers = {
authority: resolveAccount('authority'),
destination: resolveAccount('destination'),
mint: resolveAccount('mint'),
source: resolveAccount('source'),
multisigAuthority: resolveAccount('multisigAuthority'),
source: resolveAccount('source')
},
SplTokenTransferInstruction: {
authority: resolveAccount('authority'),
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-graphql/src/schema/instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ export const instructionTypeDefs = /* GraphQL */ `
source: Account
tokenAmount: TokenAmount
multisigAuthority: Account
signers: [Account]
signers: [Address]
}
# TODO: Extensions!
Expand Down

0 comments on commit c70085f

Please sign in to comment.