Skip to content
Open
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
7 changes: 6 additions & 1 deletion packages/account-sdk/src/sign/base-account/Signer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,14 @@ describe('Signer', () => {
params: [],
};

// eth_sendTransaction requires a valid 32-byte tx hash response
const mockValue = method === 'eth_sendTransaction'
? '0x' + 'a'.repeat(64) // valid 32-byte tx hash
: '0xSignature';

(decryptContent as Mock).mockResolvedValueOnce({
result: {
value: '0xSignature',
value: mockValue,
},
});

Expand Down
11 changes: 11 additions & 0 deletions packages/account-sdk/src/sign/base-account/Signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ export class Signer {
this.callback?.('accountsChanged', this.accounts);
break;
}
case 'eth_sendTransaction': {
const txHash = result.value as string;
// Validate that the response is a 32-byte tx hash (64 hex chars + 0x prefix = 66 chars)
// If the popup returns a 65-byte ECDSA signature instead of a tx hash, throw an error
if (typeof txHash === 'string' && txHash.startsWith('0x') && txHash.length !== 66) {
throw standardErrors.rpc.internal(
`eth_sendTransaction returned invalid response: expected 32-byte tx hash (66 chars) but got ${txHash.length} chars. The popup may have returned a signature instead of a transaction hash.`
);
}
break;
}
default:
break;
}
Expand Down