Skip to content

Commit

Permalink
Merge pull request #16 from getsafle/bugfix-changed-package.json
Browse files Browse the repository at this point in the history
Bugfix changed package.json and fixed signTransaction
  • Loading branch information
sshubhamagg authored Dec 19, 2023
2 parents 1fb64a9 + 95a5fab commit 586f743
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### 1.0.0 (2023-12-07)

##### Implemented Keyring Controller for Base Chain and Added Support for legacy transactions.

- Added method to generate keyring
- Added method to restore a keyring
- Added method to add a new account to the keyring object
Expand All @@ -13,4 +14,10 @@
- Added getBalance() to fetch the balance in native currency.
- Added getFee() method for gas estimation for Legacy transactions.
- Added support for Legacy transactions.
- Updated README.md.
- Updated README.md.


##### Updated 'main' path and Updated signTransaction Method.

- Updated 'main' path to "src/index.js" .
- Removed signTransaction() dependency from getFees().
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@getsafle/vault-polygon-zkevm-controller",
"version": "1.0.0",
"description": "Polygon zkEVM controller for Safle Vault",
"main": "index.js",
"main": "src/index.js",
"scripts": {
"lint": "eslint . --ext .js",
"lint:fix": "eslint --fix . --ext .js",
Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ const { normalize: normalizeAddress } = require('eth-sig-util')

const SimpleKeyring = require('eth-simple-keyring')
const HdKeyring = require('eth-hd-keyring')

const { LegacyTransaction } = require('@ethereumjs/tx')
const { Common, Hardfork } = require('@ethereumjs/common')
const { bufferToHex } = require('ethereumjs-util')

const axios = require('axios')
let chainId;


const keyringTypes = [
SimpleKeyring,
Expand Down Expand Up @@ -266,6 +265,8 @@ class KeyringController extends EventEmitter {
async signTransaction(rawTx, privateKey) {

const pkey = Buffer.from(privateKey, 'hex');

const chainId = rawTx.chainId;

const common = Common.custom({ chainId: chainId }, { hardfork: Hardfork.Istanbul })

Expand Down Expand Up @@ -538,8 +539,7 @@ class KeyringController extends EventEmitter {
* @returns {Object} - gasLimit for the transaction and an Object of fees for the transaction
*/
async getFees(rawTx, web3) {
const { from, to, value, data } = rawTx
chainId = await web3.eth.getChainId();
const { from, to, value, data, chainId} = rawTx
const gasLimit = await web3.eth.estimateGas({ to, from, value, data });
let URL = (chainId === 1101) ? 'https://gasstation.polygon.technology/zkevm' : 'https://gasstation-testnet.polygon.technology/zkevm';

Expand Down
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ describe('Initialize wallet ', () => {
gasPrice: getFeeEstimate.fees.slow.gasPrice,
nonce: defaultNonce,
data: '0x',
chainId:TESTNET.CHAIN_ID
};

const privateKey = await zkEVMkeyring.exportAccount(accounts[0])
Expand Down

0 comments on commit 586f743

Please sign in to comment.