Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #1967 from bstchow/issue-1945-fix
Browse files Browse the repository at this point in the history
[Issue #1945] Downcase address comparison in private_key_wallet.ts in subproviders module
  • Loading branch information
dekz authored Jul 18, 2019
2 parents d3fbf02 + aff8e1e commit 1aeea39
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/subproviders/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[
{
"version": "4.1.2",
"changes": [
{
"note": "Fix bug in Private Key subprovider causing checksummed tx.origin addresses to be rejected.",
"pr": 1962
}
]
},
{
"version": "4.1.1",
"changes": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class PrivateKeyWalletSubprovider extends BaseWalletSubprovider {
*/
public async signTransactionAsync(txParams: PartialTxParams): Promise<string> {
PrivateKeyWalletSubprovider._validateTxParams(txParams);
if (txParams.from !== undefined && txParams.from !== this._address) {
if (txParams.from !== undefined && txParams.from.toLowerCase() !== this._address.toLowerCase()) {
throw new Error(
`Requested to sign transaction with address: ${txParams.from}, instantiated with address: ${
this._address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ describe('PrivateKeyWalletSubprovider', () => {
const txHex = await subprovider.signTransactionAsync(fixtureData.TX_DATA);
expect(txHex).to.be.equal(fixtureData.TX_DATA_SIGNED_RESULT);
});
it('signs a transaction where the tx.origin is checksummed.', async () => {
const TX_DATA_CHECKSUMMED_ORIGIN = {
...fixtureData.TX_DATA,
from: fixtureData.TEST_RPC_ACCOUNT_0_CHECKSUMMED,
};
const txHex = await subprovider.signTransactionAsync(TX_DATA_CHECKSUMMED_ORIGIN);
expect(txHex).to.be.equal(fixtureData.TX_DATA_SIGNED_RESULT);
});
it('signs an EIP712 sign typed data message', async () => {
const signature = await subprovider.signTypedDataAsync(
fixtureData.TEST_RPC_ACCOUNT_0,
Expand Down
2 changes: 2 additions & 0 deletions packages/subproviders/test/utils/fixture_data.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const TEST_RPC_ACCOUNT_0 = '0x5409ed021d9299bf6814279a6a1411a7e866a631';
const TEST_RPC_ACCOUNT_0_CHECKSUMMED = '0x5409ED021D9299bf6814279A6A1411A7e866A631';
const TEST_RPC_ACCOUNT_1 = '0x6ecbe1db9ef729cbe972c83fb886247691fb6beb';
const NULL_ADDRESS = '0x0000000000000000000000000000000000000000';
const networkId = 42;
export const fixtureData = {
NULL_ADDRESS,
TEST_RPC_ACCOUNT_0,
TEST_RPC_ACCOUNT_0_CHECKSUMMED,
TEST_RPC_ACCOUNT_0_ACCOUNT_PRIVATE_KEY: 'F2F48EE19680706196E2E339E5DA3491186E0C4C5030670656B0E0164837257D',
TEST_RPC_ACCOUNT_1,
TEST_RPC_MNEMONIC: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
Expand Down

0 comments on commit 1aeea39

Please sign in to comment.