Skip to content

Commit

Permalink
vrs values
Browse files Browse the repository at this point in the history
  • Loading branch information
seaona committed Oct 18, 2024
1 parent df9890f commit 33cb530
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/stub/keyring-bridge.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Transaction } from '@ethereumjs/tx';
import { signTypedData, SignTypedDataVersion } from '@metamask/eth-sig-util';
import { bufferToHex } from 'ethereumjs-util';
import { bufferToHex, rlp } from 'ethereumjs-util';
import { addHexPrefix, Common } from './keyring-utils';

// BIP32 Public Key: xpub6ELgkkwgfoky9h9fFu4Auvx6oHvJ6XfwiS1NE616fe9Uf4H3JHtLGjCePVkb6RFcyDCqVvjXhNXbDNDqs6Kjoxw7pTAeP1GSEiLHmA5wYa9
Expand Down Expand Up @@ -173,8 +173,14 @@ export class FakeLedgerBridge extends FakeKeyringBridge {
// common,
// }).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));

//removing r, s, v values from the unsigned tx
const txBuffer = Buffer.from(tx, 'hex');
return Transaction.fromSerializedTx(txBuffer, {
const VALID_TYPES = [1, 2];
const txType = VALID_TYPES.includes(rawTx[0]) ? rawTx[0] : null;
const rlpData = txType === null ? txBuffer : txBuffer.slice(1, tx.length);
const rlpTx = rlp.decode(rlpData);

return Transaction.fromValuesArray(rlpTx.slice(0,6), {
common,
}).sign(Buffer.from(KNOWN_PRIVATE_KEYS[0], 'hex'));
}
Expand Down

0 comments on commit 33cb530

Please sign in to comment.