Skip to content

Commit

Permalink
feat: Upgraded ethereumjs-tx major version
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoares85 committed Feb 26, 2024
1 parent 7bdb6e3 commit c55d352
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 26 deletions.
43 changes: 26 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"abi-decoder": "^2.4.0",
"axios": "^1.6.7",
"dotenv": "^16.4.5",
"ethereumjs-tx": "^1.3.7",
"ethereumjs-tx": "^2.1.2",
"ethereumjs-util": "^7.1.5",
"express": "^4.18.2",
"log4js": "^6.9.1",
Expand Down
2 changes: 0 additions & 2 deletions src/lib/Federator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import * as typescriptUtils from './typescriptUtils';
import { ConfigChain } from './configChain';
import { IFederation } from '../contracts/IFederation';
import { LogWrapper } from './logWrapper';
import {AppDataSource} from "../services/AppDataSource";
import {Log} from "../entities/Log";
import {getLog, insertLog, updateLog} from "../models/log.model";
import {clearOldLogs} from "../models/logDebug.model";

Expand Down
21 changes: 15 additions & 6 deletions src/lib/TransactionSender.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Tx from 'ethereumjs-tx';
import { Transaction as Tx } from 'ethereumjs-tx';
import Common from 'ethereumjs-common';
import * as ethUtils from 'ethereumjs-util';
import * as utils from '../lib/utils';
import * as fs from 'fs';
Expand Down Expand Up @@ -110,7 +111,7 @@ export class TransactionSender {
}

async getChainId() {
if (this.chainId === undefined) {
if (this.chainId === undefined || this.chainId === null) {
this.chainId = parseInt(await this.client.eth.net.getId());
}
return this.chainId;
Expand All @@ -136,15 +137,14 @@ export class TransactionSender {
r: 0,
s: 0,
};

if (await this.isRsk()) {
delete rawTx.chainId;
delete rawTx.r;
delete rawTx.s;
}

rawTx.gas = this.numberToHexString(await this.getGasLimit(rawTx));

if (this.debuggingMode) {
rawTx.gas = this.numberToHexString(100);
this.logger.warn(`debugging mode enabled, forced rawTx.gas ${rawTx.gas}`);
Expand All @@ -154,7 +154,16 @@ export class TransactionSender {
}

signRawTransaction(rawTx, privateKey) {
const tx = new Tx(rawTx);
const customCommon = Common.forCustomChain(
'mainnet',
{
name: 'rsk-federator',
chainId: rawTx.chainId,
},
'petersburg',
)

const tx = new Tx(rawTx, { common: customCommon });
tx.sign(utils.hexStringToBuffer(privateKey));
return tx;
}
Expand Down

0 comments on commit c55d352

Please sign in to comment.