Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/frontend/src/sol/utils/sol-instructions.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,15 @@ const mapSolSystemInstruction = (instruction: SolParsedInstruction): MappedSolTr
const {
data: { lamports },
accounts: {
payer: { address: payer }
payer: { address: payer },
newAccount: { address: destination }
}
} = instruction;

return {
amount: lamports,
payer
payer,
destination
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ describe('sol-instructions.utils', () => {
});
expect(mapSolInstruction(mockInstruction2)).toStrictEqual({
amount: 2039280n,
destination: 'DSkZKdPXxJYtcqcUzAkpHbr4or65H1a7WmePYsKQQBGH',
payer: '5Dqoon9MdWRgwmJ839FJ2ZTpTAcc1MMprZeNyaxpaV1Q'
});

Expand Down
24 changes: 22 additions & 2 deletions src/frontend/src/tests/sol/utils/sol-transactions.utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ describe('sol-transactions.utils', () => {
expect(mapSolTransactionMessage(mockSolParsedTransactionMessage)).toStrictEqual({
amount: 2044380n,
unreviewed: true,
destination: 'ADaUMid9yfUytqMBgopwjb2DTLSokTSzL1zt6iGPaS49',
destination: 'DSkZKdPXxJYtcqcUzAkpHbr4or65H1a7WmePYsKQQBGH',
payer: '5Dqoon9MdWRgwmJ839FJ2ZTpTAcc1MMprZeNyaxpaV1Q',
source: '5Dqoon9MdWRgwmJ839FJ2ZTpTAcc1MMprZeNyaxpaV1Q'
source: '5Dqoon9MdWRgwmJ839FJ2ZTpTAcc1MMprZeNyaxpaV1Q',
ambiguous: true
});
});

Expand Down Expand Up @@ -374,6 +375,25 @@ describe('sol-transactions.utils', () => {
});
});

it('should flag account creation hidden behind a benign trailing transfer as ambiguous', () => {
spyMapSolInstruction
.mockReturnValueOnce({ amount: 9n, payer: mockSolAddress, destination: mockSolAddress2 })
.mockReturnValueOnce({ amount: 1n, source: mockSolAddress, destination: mockAtaAddress });

expect(
mapSolTransactionMessage({
...mockSolParsedTransactionMessage,
instructions: [instruction1, instruction2]
})
).toStrictEqual({
amount: 10n,
source: mockSolAddress,
destination: mockAtaAddress,
payer: mockSolAddress,
ambiguous: true
});
});

it('should not flag repeated transfers to the same destination as ambiguous', () => {
spyMapSolInstruction
.mockReturnValueOnce({ amount: 9n, source: mockSolAddress, destination: mockSolAddress2 })
Expand Down
Loading