Merge pull request #1967 from bstchow/issue-1945-fix
[Issue #1945] Downcase address comparison in private_key_wallet.ts in subproviders module
This commit is contained in:
@@ -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": [
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user