From c4b50b8c62ee16406106ad8c8684170e9618b52c Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 27 Sep 2022 17:12:36 -0500 Subject: [PATCH 1/6] wip --- index.js | 5 +- package.json | 5 +- test/test-eth-ledger-bridge-keyring.js | 5 +- yarn.lock | 89 ++++++++++++++++++++------ 4 files changed, 80 insertions(+), 24 deletions(-) diff --git a/index.js b/index.js index 9c11576c..7b1afd07 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,7 @@ const { EventEmitter } = require('events') const HDKey = require('hdkey') -const ethUtil = require('ethereumjs-util') +const ethUtil = require('@ethereumjs/util') +const ethUtilRlp = require('@ethereumjs/rlp') const sigUtil = require('eth-sig-util') const { TransactionFactory } = require('@ethereumjs/tx') @@ -282,7 +283,7 @@ class LedgerBridgeKeyring extends EventEmitter { rawTxHex = Buffer.isBuffer(messageToSign) ? messageToSign.toString('hex') - : ethUtil.rlp.encode(messageToSign).toString('hex') + : Buffer.from(ethUtilRlp.encode(messageToSign)).toString('hex') return this._signTransaction(address, rawTxHex, (payload) => { // Because tx will be immutable, first get a plain javascript object that diff --git a/package.json b/package.json index d0c42007..e02cf571 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,10 @@ "mocha/**/mkdirp": "^0.5.3" }, "dependencies": { + "@ethereumjs/rlp": "^4.0.0", + "@ethereumjs/tx": "^4.0.0", + "@ethereumjs/util": "^8.0.0", "eth-sig-util": "^2.0.0", - "@ethereumjs/tx": "^3.2.0", - "ethereumjs-util": "^7.0.9", "hdkey": "0.8.0" }, "devDependencies": { diff --git a/test/test-eth-ledger-bridge-keyring.js b/test/test-eth-ledger-bridge-keyring.js index c995d5de..59151a91 100644 --- a/test/test-eth-ledger-bridge-keyring.js +++ b/test/test-eth-ledger-bridge-keyring.js @@ -6,7 +6,8 @@ const chai = require('chai') const spies = require('chai-spies') const EthereumTx = require('ethereumjs-tx') const HDKey = require('hdkey') -const ethUtil = require('ethereumjs-util') +const ethUtil = require('@ethereumjs/util') +const ethUtilRlp = require('@ethereumjs/rlp') const { TransactionFactory } = require('@ethereumjs/tx') const Common = require('@ethereumjs/common').default const sigUtil = require('eth-sig-util') @@ -527,7 +528,7 @@ describe('LedgerBridgeKeyring', function () { sandbox.on(keyring, '_sendMessage', (msg, cb) => { assert.deepStrictEqual(msg.params, { hdPath: "m/44'/60'/0'/0", - tx: ethUtil.rlp.encode(newFakeTx.getMessageToSign(false)).toString('hex'), + tx: Buffer.from(ethUtilRlp.encode(newFakeTx.getMessageToSign(false))).toString('hex'), }) cb({ success: true, payload: expectedRSV }) }) diff --git a/yarn.lock b/yarn.lock index dd853962..c5f2a312 100644 --- a/yarn.lock +++ b/yarn.lock @@ -117,19 +117,74 @@ crc-32 "^1.2.0" ethereumjs-util "^7.1.0" -"@ethereumjs/tx@^3.2.0": - version "3.3.0" - resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-3.3.0.tgz#14ed1b7fa0f28e1cd61e3ecbdab824205f6a4378" - integrity sha512-yTwEj2lVzSMgE6Hjw9Oa1DZks/nKTWM8Wn4ykDNapBPua2f4nXO3qKnni86O6lgDj5fVNRqbDsD0yy7/XNGDEA== +"@ethereumjs/common@^3.0.0": + version "3.0.0" + resolved "https://registry.yarnpkg.com/@ethereumjs/common/-/common-3.0.0.tgz#a8786536e2af71d01e5d3f1c3a0272bc935fd817" + integrity sha512-yHgMom5HFlAJIu8fmA1n0UvBnanhULfuNQAD+tT6ZR6sndLUz2Mc4eegF3Rby579lqJMAc/rpsToP7wA/i4R/w== dependencies: - "@ethereumjs/common" "^2.4.0" - ethereumjs-util "^7.1.0" + "@ethereumjs/util" "^8.0.0" + crc-32 "^1.2.0" + +"@ethereumjs/rlp@^4.0.0", "@ethereumjs/rlp@^4.0.0-beta.2": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@ethereumjs/rlp/-/rlp-4.0.0.tgz#66719891bd727251a7f233f9ca80212d1994f8c8" + integrity sha512-LM4jS5n33bJN60fM5EC8VeyhUgga6/DjCPBV2vWjnfVtobqtOiNC4SQ1MRFqyBSmJGGdB533JZWewyvlcdJtkQ== + +"@ethereumjs/tx@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@ethereumjs/tx/-/tx-4.0.0.tgz#da284dd1d3407d910a055da99dc0d1c917097a8c" + integrity sha512-W3Fc61kAA3D6vJad2vsfh9ygdaMeScYpf49ephoo/0y+CP9IN+MMrqA6mx1X0Fr/jf52IuW4hDHE/rmgadBV6g== + dependencies: + "@ethereumjs/common" "^3.0.0" + "@ethereumjs/rlp" "^4.0.0" + "@ethereumjs/util" "^8.0.0" + ethereum-cryptography "^1.1.2" + +"@ethereumjs/util@^8.0.0": + version "8.0.0" + resolved "https://registry.yarnpkg.com/@ethereumjs/util/-/util-8.0.0.tgz#52363fe29113c0ee70c8e9df20bc713e00089720" + integrity sha512-Zz/Ovar0VU/CaYHLvigBTjG5PmkG0OzjvRjjoXRJbJcdWJoTCN2N4BYgoCBOZomKjaAT4ABpQ7wer6ZFOglvjg== + dependencies: + "@ethereumjs/rlp" "^4.0.0-beta.2" + ethereum-cryptography "^1.1.2" "@metamask/eslint-config@^3.0.0": version "3.2.0" resolved "https://registry.yarnpkg.com/@metamask/eslint-config/-/eslint-config-3.2.0.tgz#66b9b2bea1616821506501e76de4ac991f34914f" integrity sha512-WKfB81fD5NZBFbj/UqMyfNss/b25XrukVC3j2mcaIEF0uzSKzh1b/yy7aXxcfXshWemHz28MOwZT9Bin5KV37w== +"@noble/hashes@1.1.2", "@noble/hashes@~1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.1.2.tgz#e9e035b9b166ca0af657a7848eb2718f0f22f183" + integrity sha512-KYRCASVTv6aeUi1tsF8/vpyR7zpfs3FUzy2Jqm+MU+LmUKhQ0y2FpfwqkCcxSg2ua4GALJd8k2R76WxwZGbQpA== + +"@noble/secp256k1@1.6.3", "@noble/secp256k1@~1.6.0": + version "1.6.3" + resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.6.3.tgz#7eed12d9f4404b416999d0c87686836c4c5c9b94" + integrity sha512-T04e4iTurVy7I8Sw4+c5OSN9/RkPlo1uKxAomtxQNLq8j1uPAqnsqG1bqvY3Jv7c13gyr6dui0zmh/I3+f/JaQ== + +"@scure/base@~1.1.0": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.1.tgz#ebb651ee52ff84f420097055f4bf46cfba403938" + integrity sha512-ZxOhsSyxYwLJj3pLZCefNitxsj093tb2vq90mp2txoYeBqbcjDjqFhyM8eUjq/uFm6zJ+mUuqxlS2FkuSY1MTA== + +"@scure/bip32@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@scure/bip32/-/bip32-1.1.0.tgz#dea45875e7fbc720c2b4560325f1cf5d2246d95b" + integrity sha512-ftTW3kKX54YXLCxH6BB7oEEoJfoE2pIgw7MINKAs5PsS6nqKPuKk1haTF/EuHmYqG330t5GSrdmtRuHaY1a62Q== + dependencies: + "@noble/hashes" "~1.1.1" + "@noble/secp256k1" "~1.6.0" + "@scure/base" "~1.1.0" + +"@scure/bip39@1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@scure/bip39/-/bip39-1.1.0.tgz#92f11d095bae025f166bef3defcc5bf4945d419a" + integrity sha512-pwrPOS16VeTKg98dYXQyIjJEcWfz7/1YJIwxUEPFfQPtc86Ym/1sVgQ2RLoD43AazMk2l/unK4ITySSpW2+82w== + dependencies: + "@noble/hashes" "~1.1.1" + "@scure/base" "~1.1.0" + "@types/bn.js@^4.11.3": version "4.11.6" resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c" @@ -860,6 +915,16 @@ ethereum-cryptography@^0.1.3: secp256k1 "^4.0.1" setimmediate "^1.0.5" +ethereum-cryptography@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/ethereum-cryptography/-/ethereum-cryptography-1.1.2.tgz#74f2ac0f0f5fe79f012c889b3b8446a9a6264e6d" + integrity sha512-XDSJlg4BD+hq9N2FjvotwUET9Tfxpxc3kWGE2AqUG5vcbeunnbImVk3cj6e/xT3phdW21mE8R5IugU4fspQDcQ== + dependencies: + "@noble/hashes" "1.1.2" + "@noble/secp256k1" "1.6.3" + "@scure/bip32" "1.1.0" + "@scure/bip39" "1.1.0" + ethereumjs-abi@0.6.8: version "0.6.8" resolved "https://registry.yarnpkg.com/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz#71bc152db099f70e62f108b7cdfca1b362c6fcae" @@ -902,18 +967,6 @@ ethereumjs-util@^6.0.0: rlp "^2.2.3" secp256k1 "^3.0.1" -ethereumjs-util@^7.0.9: - version "7.0.9" - resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.0.9.tgz#2038baeb30f370a3e576ec175bd70bbbb6807d42" - integrity sha512-cRqvYYKJoitq6vMKMf8pXeVwvTrX+dRD0JwHaYqm8jvogK14tqIoCWH/KUHcRwnVxVXEYF/o6pup5jRG4V0xzg== - dependencies: - "@types/bn.js" "^5.1.0" - bn.js "^5.1.2" - create-hash "^1.1.2" - ethereum-cryptography "^0.1.3" - ethjs-util "0.1.6" - rlp "^2.2.4" - ethereumjs-util@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-7.1.0.tgz#e2b43a30bfcdbcb432a4eb42bd5f2393209b3fd5" From 53207138404edd600facab35f2ddf619e748ff43 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 19 Dec 2022 17:07:26 -0600 Subject: [PATCH 2/6] bump minimum node version to 14 --- .circleci/config.yml | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 32af1a38..c12ac383 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ workflows: jobs: prep-deps: docker: - - image: circleci/node:12 + - image: circleci/node:14 steps: - checkout - run: @@ -37,7 +37,7 @@ jobs: test-lint: docker: - - image: circleci/node:12 + - image: circleci/node:14 steps: - checkout - attach_workspace: @@ -48,7 +48,7 @@ jobs: test-unit: docker: - - image: circleci/node:12 + - image: circleci/node:14 steps: - checkout - attach_workspace: @@ -59,7 +59,7 @@ jobs: all-tests-pass: docker: - - image: circleci/node:12 + - image: circleci/node:14 steps: - run: name: All tests passed diff --git a/package.json b/package.json index e02cf571..1d4e2af9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "index.js" ], "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" }, "scripts": { "test": "mocha", From d19924e0be06664f1dbd90b9dd40f832c53d6c50 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Tue, 3 Oct 2023 06:19:40 +0000 Subject: [PATCH 3/6] chore: update allow-scripts config --- package.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4d5edd6c..f062325c 100644 --- a/package.json +++ b/package.json @@ -91,11 +91,8 @@ "lavamoat": { "allowScripts": { "@lavamoat/preinstall-always-fail": false, - "eth-sig-util>ethereumjs-abi>ethereumjs-util>keccak": false, - "eth-sig-util>ethereumjs-util>keccak": false, - "ethereumjs-tx>ethereumjs-util>keccak": false, - "ethereumjs-util>ethereum-cryptography>keccak": false, - "ethereumjs-util>ethereum-cryptography>secp256k1": false, + "eth-sig-util>ethereumjs-util>ethereum-cryptography>keccak": false, + "eth-sig-util>ethereumjs-util>ethereum-cryptography>secp256k1": false, "hdkey>secp256k1": false } } From 7c75942c867111add6c32d43b7c4e4a5f58a0a8c Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Tue, 3 Oct 2023 06:19:49 +0000 Subject: [PATCH 4/6] yarn dedupe --- yarn.lock | 105 ++++-------------------------------------------------- 1 file changed, 7 insertions(+), 98 deletions(-) diff --git a/yarn.lock b/yarn.lock index 1be1470b..73b2de56 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,16 +15,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.18.6": - version: 7.18.6 - resolution: "@babel/code-frame@npm:7.18.6" - dependencies: - "@babel/highlight": ^7.18.6 - checksum: 195e2be3172d7684bf95cff69ae3b7a15a9841ea9d27d3c843662d50cdd7d6470fd9c8e64be84d031117e4a4083486effba39f9aef6bbb2c89f7f21bcfba33ba - languageName: node - linkType: hard - -"@babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.21.4": +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.18.6, @babel/code-frame@npm:^7.21.4": version: 7.21.4 resolution: "@babel/code-frame@npm:7.21.4" dependencies: @@ -63,18 +54,6 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.21.3": - version: 7.21.3 - resolution: "@babel/generator@npm:7.21.3" - dependencies: - "@babel/types": ^7.21.3 - "@jridgewell/gen-mapping": ^0.3.2 - "@jridgewell/trace-mapping": ^0.3.17 - jsesc: ^2.5.1 - checksum: be6bb5a32a0273260b91210d4137b7b5da148a2db8dd324654275cb0af865ae59de5e1536e93ac83423b2586415059e1c24cf94293026755cf995757238da749 - languageName: node - linkType: hard - "@babel/generator@npm:^7.21.4, @babel/generator@npm:^7.7.2": version: 7.21.4 resolution: "@babel/generator@npm:7.21.4" @@ -230,7 +209,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.21.4": +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.16.4, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.4": version: 7.21.4 resolution: "@babel/parser@npm:7.21.4" bin: @@ -239,15 +218,6 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.16.4, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.21.3": - version: 7.21.3 - resolution: "@babel/parser@npm:7.21.3" - bin: - parser: ./bin/babel-parser.js - checksum: a71e6456a1260c2a943736b56cc0acdf5f2a53c6c79e545f56618967e51f9b710d1d3359264e7c979313a7153741b1d95ad8860834cc2ab4ce4f428b13cc07be - languageName: node - linkType: hard - "@babel/plugin-syntax-async-generators@npm:^7.8.4": version: 7.8.4 resolution: "@babel/plugin-syntax-async-generators@npm:7.8.4" @@ -402,25 +372,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.12.5": - version: 7.21.3 - resolution: "@babel/traverse@npm:7.21.3" - dependencies: - "@babel/code-frame": ^7.18.6 - "@babel/generator": ^7.21.3 - "@babel/helper-environment-visitor": ^7.18.9 - "@babel/helper-function-name": ^7.21.0 - "@babel/helper-hoist-variables": ^7.18.6 - "@babel/helper-split-export-declaration": ^7.18.6 - "@babel/parser": ^7.21.3 - "@babel/types": ^7.21.3 - debug: ^4.1.0 - globals: ^11.1.0 - checksum: 0af5bcd47a2fc501592b90ac1feae9d449afb9ab0772a4f6e68230f4cd3a475795d538c1de3f880fe3414b6c2820bac84d02c6549eea796f39d74a603717447b - languageName: node - linkType: hard - -"@babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2, @babel/traverse@npm:^7.21.4, @babel/traverse@npm:^7.7.2": +"@babel/traverse@npm:^7.12.5, @babel/traverse@npm:^7.21.0, @babel/traverse@npm:^7.21.2, @babel/traverse@npm:^7.21.4, @babel/traverse@npm:^7.7.2": version: 7.21.4 resolution: "@babel/traverse@npm:7.21.4" dependencies: @@ -438,7 +390,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.20.2, @babel/types@npm:^7.21.2, @babel/types@npm:^7.21.4, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.18.6, @babel/types@npm:^7.20.2, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.0, @babel/types@npm:^7.21.2, @babel/types@npm:^7.21.4, @babel/types@npm:^7.3.0, @babel/types@npm:^7.3.3, @babel/types@npm:^7.8.3": version: 7.21.4 resolution: "@babel/types@npm:7.21.4" dependencies: @@ -449,17 +401,6 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.18.6, @babel/types@npm:^7.20.7, @babel/types@npm:^7.21.0, @babel/types@npm:^7.21.3, @babel/types@npm:^7.8.3": - version: 7.21.3 - resolution: "@babel/types@npm:7.21.3" - dependencies: - "@babel/helper-string-parser": ^7.19.4 - "@babel/helper-validator-identifier": ^7.19.1 - to-fast-properties: ^2.0.0 - checksum: b750274718ba9cefd0b81836c464009bb6ba339fccce51b9baff497a0a2d96c044c61dc90cf203cec0adc770454b53a9681c3f7716883c802b85ab84c365ba35 - languageName: node - linkType: hard - "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -594,7 +535,7 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^8.0.0": +"@ethereumjs/util@npm:^8.0.0, @ethereumjs/util@npm:^8.0.5": version: 8.1.0 resolution: "@ethereumjs/util@npm:8.1.0" dependencies: @@ -605,17 +546,6 @@ __metadata: languageName: node linkType: hard -"@ethereumjs/util@npm:^8.0.5": - version: 8.0.5 - resolution: "@ethereumjs/util@npm:8.0.5" - dependencies: - "@chainsafe/ssz": 0.9.4 - "@ethereumjs/rlp": ^4.0.1 - ethereum-cryptography: ^1.1.2 - checksum: 318386785295b4584289b1aa576d2621392b3a918d127890db62d3f74184f3377694dd9e951e19bfb9ab80e8dc9e38e180236cac2651dead26097d10963731f9 - languageName: node - linkType: hard - "@ethersproject/abi@npm:^5.5.0": version: 5.7.0 resolution: "@ethersproject/abi@npm:5.7.0" @@ -1209,7 +1139,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/gen-mapping@npm:^0.3.0": +"@jridgewell/gen-mapping@npm:^0.3.0, @jridgewell/gen-mapping@npm:^0.3.2": version: 0.3.3 resolution: "@jridgewell/gen-mapping@npm:0.3.3" dependencies: @@ -1220,17 +1150,6 @@ __metadata: languageName: node linkType: hard -"@jridgewell/gen-mapping@npm:^0.3.2": - version: 0.3.2 - resolution: "@jridgewell/gen-mapping@npm:0.3.2" - dependencies: - "@jridgewell/set-array": ^1.0.1 - "@jridgewell/sourcemap-codec": ^1.4.10 - "@jridgewell/trace-mapping": ^0.3.9 - checksum: 1832707a1c476afebe4d0fbbd4b9434fdb51a4c3e009ab1e9938648e21b7a97049fa6009393bdf05cab7504108413441df26d8a3c12193996e65493a4efb6882 - languageName: node - linkType: hard - "@jridgewell/resolve-uri@npm:3.1.0, @jridgewell/resolve-uri@npm:^3.0.3": version: 3.1.0 resolution: "@jridgewell/resolve-uri@npm:3.1.0" @@ -1262,7 +1181,7 @@ __metadata: languageName: node linkType: hard -"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.13": +"@jridgewell/trace-mapping@npm:^0.3.12, @jridgewell/trace-mapping@npm:^0.3.13, @jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.9": version: 0.3.18 resolution: "@jridgewell/trace-mapping@npm:0.3.18" dependencies: @@ -1272,16 +1191,6 @@ __metadata: languageName: node linkType: hard -"@jridgewell/trace-mapping@npm:^0.3.17, @jridgewell/trace-mapping@npm:^0.3.9": - version: 0.3.17 - resolution: "@jridgewell/trace-mapping@npm:0.3.17" - dependencies: - "@jridgewell/resolve-uri": 3.1.0 - "@jridgewell/sourcemap-codec": 1.4.14 - checksum: 9d703b859cff5cd83b7308fd457a431387db5db96bd781a63bf48e183418dd9d3d44e76b9e4ae13237f6abeeb25d739ec9215c1d5bfdd08f66f750a50074a339 - languageName: node - linkType: hard - "@lavamoat/aa@npm:^3.1.1": version: 3.1.2 resolution: "@lavamoat/aa@npm:3.1.2" From e70ae0025dd4fd60b9a08fc97e13e5f6d1c379d7 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 4 Oct 2023 12:02:55 -0500 Subject: [PATCH 5/6] update --- src/ledger-keyring.test.ts | 7 ++++--- src/ledger-keyring.ts | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ledger-keyring.test.ts b/src/ledger-keyring.test.ts index 4c15cd8f..f8789f7a 100644 --- a/src/ledger-keyring.test.ts +++ b/src/ledger-keyring.test.ts @@ -2,7 +2,8 @@ import { Common, Chain, Hardfork } from '@ethereumjs/common'; import { TransactionFactory } from '@ethereumjs/tx'; import sigUtil from 'eth-sig-util'; import EthereumTx from 'ethereumjs-tx'; -import * as ethUtil from 'ethereumjs-util'; +import * as ethUtil from '@ethereumjs/util'; +import {RLP} from '@ethereumjs/rlp' import HDKey from 'hdkey'; import { LedgerBridge } from './ledger-bridge'; @@ -536,9 +537,9 @@ describe('LedgerKeyring', function () { .mockImplementation(async (params) => { expect(params).toStrictEqual({ hdPath: "m/44'/60'/0'/0", - tx: ethUtil.rlp + tx: RLP .encode(newFakeTx.getMessageToSign(false)) - .toString('hex'), + .toString(), }); return expectedRSV; }); diff --git a/src/ledger-keyring.ts b/src/ledger-keyring.ts index bef198d3..444d22a3 100644 --- a/src/ledger-keyring.ts +++ b/src/ledger-keyring.ts @@ -3,7 +3,8 @@ import { TransactionFactory, TxData, TypedTransaction } from '@ethereumjs/tx'; import { Buffer } from 'buffer'; import * as sigUtil from 'eth-sig-util'; import type OldEthJsTransaction from 'ethereumjs-tx'; -import * as ethUtil from 'ethereumjs-util'; +import * as ethUtil from '@ethereumjs/util'; +import { RLP } from '@ethereumjs/rlp'; // eslint-disable-next-line import/no-nodejs-modules import { EventEmitter } from 'events'; import HDKey from 'hdkey'; @@ -333,7 +334,7 @@ export class LedgerKeyring extends EventEmitter { rawTxHex = Buffer.isBuffer(messageToSign) ? messageToSign.toString('hex') - : ethUtil.rlp.encode(messageToSign).toString('hex'); + : RLP.encode(messageToSign).toString(); return this.#signTransaction(address, rawTxHex, (payload) => { // Because tx will be immutable, first get a plain javascript object that From 5f1a5828040366df56680ac97f6215dd43b08b86 Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 4 Oct 2023 15:44:49 -0500 Subject: [PATCH 6/6] lint --- jest.config.js | 4 ++-- src/ledger-keyring.test.ts | 8 +++----- src/ledger-keyring.ts | 4 ++-- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/jest.config.js b/jest.config.js index 178632c7..6fc5cddf 100644 --- a/jest.config.js +++ b/jest.config.js @@ -43,8 +43,8 @@ module.exports = { global: { branches: 65.42, functions: 88.57, - lines: 81.57, - statements: 81.49, + lines: 81.63, + statements: 81.55, }, }, diff --git a/src/ledger-keyring.test.ts b/src/ledger-keyring.test.ts index f8789f7a..9bfd4058 100644 --- a/src/ledger-keyring.test.ts +++ b/src/ledger-keyring.test.ts @@ -1,9 +1,9 @@ import { Common, Chain, Hardfork } from '@ethereumjs/common'; +import { RLP } from '@ethereumjs/rlp'; import { TransactionFactory } from '@ethereumjs/tx'; +import * as ethUtil from '@ethereumjs/util'; import sigUtil from 'eth-sig-util'; import EthereumTx from 'ethereumjs-tx'; -import * as ethUtil from '@ethereumjs/util'; -import {RLP} from '@ethereumjs/rlp' import HDKey from 'hdkey'; import { LedgerBridge } from './ledger-bridge'; @@ -537,9 +537,7 @@ describe('LedgerKeyring', function () { .mockImplementation(async (params) => { expect(params).toStrictEqual({ hdPath: "m/44'/60'/0'/0", - tx: RLP - .encode(newFakeTx.getMessageToSign(false)) - .toString(), + tx: RLP.encode(newFakeTx.getMessageToSign(false)).toString(), }); return expectedRSV; }); diff --git a/src/ledger-keyring.ts b/src/ledger-keyring.ts index 444d22a3..24399214 100644 --- a/src/ledger-keyring.ts +++ b/src/ledger-keyring.ts @@ -1,10 +1,10 @@ +import { RLP } from '@ethereumjs/rlp'; import { TransactionFactory, TxData, TypedTransaction } from '@ethereumjs/tx'; +import * as ethUtil from '@ethereumjs/util'; // eslint-disable-next-line import/no-nodejs-modules import { Buffer } from 'buffer'; import * as sigUtil from 'eth-sig-util'; import type OldEthJsTransaction from 'ethereumjs-tx'; -import * as ethUtil from '@ethereumjs/util'; -import { RLP } from '@ethereumjs/rlp'; // eslint-disable-next-line import/no-nodejs-modules import { EventEmitter } from 'events'; import HDKey from 'hdkey';