Skip to content

Commit

Permalink
refactor: eth-lib removal
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbrugneaux committed Feb 23, 2024
1 parent be1dd0c commit 18295a3
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 133 deletions.
1 change: 0 additions & 1 deletion packages/sdk/wallets/wallet-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@types/debug": "^4.1.5",
"bignumber.js": "^9.0.0",
"debug": "^4.1.1",
"eth-lib": "^0.2.8",
"web3": "1.10.0",
"web3-eth-accounts": "1.10.0"
},
Expand Down
15 changes: 12 additions & 3 deletions packages/sdk/wallets/wallet-base/src/signing-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('rlpEncodedTx', () => {
function ckToViem(tx: CeloTx & { v?: number }) {
return {
...tx,
gas: BigInt(tx.gas!),
gas: BigInt(tx.gas! as string),
maxFeePerGas: BigInt(tx.maxFeePerGas?.toString()!),
maxPriorityFeePerGas: BigInt(tx.maxPriorityFeePerGas?.toString()!),
value: BigInt(tx.value?.toString()!),
Expand Down Expand Up @@ -356,7 +356,7 @@ describe('recoverTransaction', () => {
"data": "0xabcdef",
"feeCurrency": "0x",
"gas": 10,
"gasPrice": 99,
"gasPrice": "99",
"gatewayFee": "0x5678",
"gatewayFeeRecipient": "0x1be31a94361a391bbafb2a4ccd704f57dc04d4bb",
"nonce": 0,
Expand Down Expand Up @@ -565,8 +565,17 @@ describe('extractSignature', () => {
`)
})
it('fails when length is wrong', () => {
expect(() =>
extractSignature(
'0xf88282ad5a8063630a94588e4b68193001e4d10928660ab4165b813717c0880de0b6b3a764000083abcdefc094cd2a3d9f938e13cd947ec05abc7fe734df8dd82680a091b5504a59e529e7efa42dbb97fbc3311a91d035c873a94ab0789441fc989f84a02e8254d6b3101b63417e5d496833bc84f4832d4a8bf8a2b83e291d8f38c0f62d'
)
).toThrowErrorMatchingInlineSnapshot(
`"@extractSignature: provided transaction has 13 elements but celo-legacy txs with a signature have 12 [{"0":173,"1":90},{},{"0":99},{"0":99},{"0":10},{"0":88,"1":142,"2":75,"3":104,"4":25,"5":48,"6":1,"7":228,"8":209,"9":9,"10":40,"11":102,"12":10,"13":180,"14":22,"15":91,"16":129,"17":55,"18":23,"19":192},{"0":13,"1":224,"2":182,"3":179,"4":167,"5":100,"6":0,"7":0},{"0":171,"1":205,"2":239},[],{"0":205,"1":42,"2":61,"3":159,"4":147,"5":142,"6":19,"7":205,"8":148,"9":126,"10":192,"11":90,"12":188,"13":127,"14":231,"15":52,"16":223,"17":141,"18":216,"19":38},{},{"0":145,"1":181,"2":80,"3":74,"4":89,"5":229,"6":41,"7":231,"8":239,"9":164,"10":45,"11":187,"12":151,"13":251,"14":195,"15":49,"16":26,"17":145,"18":208,"19":53,"20":200,"21":115,"22":169,"23":74,"24":176,"25":120,"26":148,"27":65,"28":252,"29":152,"30":159,"31":132},{"0":46,"1":130,"2":84,"3":214,"4":179,"5":16,"6":27,"7":99,"8":65,"9":126,"10":93,"11":73,"12":104,"13":51,"14":188,"15":132,"16":244,"17":131,"18":45,"19":74,"20":139,"21":248,"22":162,"23":184,"24":62,"25":41,"26":29,"27":143,"28":56,"29":192,"30":246,"31":45}]"`
)
})
it('fails when length is empty', () => {
expect(() => extractSignature('0x')).toThrowErrorMatchingInlineSnapshot(
`"@extractSignature: provided transaction has 0 elements but celo-legacy txs with a signature have 12 []"`
`"Invalid byte sequence"`
)
})
})
Expand Down
235 changes: 126 additions & 109 deletions packages/sdk/wallets/wallet-base/src/signing-utils.ts

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-hsm-aws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"@types/secp256k1": "^4.0.0",
"aws-sdk": "^2.705.0",
"bignumber.js": "^9.0.0",
"debug": "^4.1.1",
"eth-lib": "^0.2.8"
"debug": "^4.1.1"
},
"devDependencies": {
"@noble/ciphers": "0.4.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-hsm-azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
"@ethereumjs/util": "8.0.5",
"@types/secp256k1": "^4.0.0",
"bignumber.js": "^9.0.0",
"debug": "^4.1.1",
"eth-lib": "^0.2.8"
"debug": "^4.1.1"
},
"devDependencies": {
"@noble/ciphers": "0.4.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-hsm-gcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"@types/debug": "^4.1.5",
"@types/secp256k1": "^4.0.0",
"bignumber.js": "^9.0.0",
"debug": "^4.1.1",
"eth-lib": "^0.2.8"
"debug": "^4.1.1"
},
"devDependencies": {
"@noble/ciphers": "0.4.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-hsm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"@types/debug": "^4.1.5",
"@types/secp256k1": "^4.0.0",
"asn1js": "^2.0.26",
"bignumber.js": "^9.0.0",
"eth-lib": "^0.2.8"
"bignumber.js": "^9.0.0"
},
"devDependencies": {
"dotenv": "^8.2.0"
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"@celo/connect": "^5.1.2",
"@celo/utils": "^6.0.0",
"@celo/wallet-base": "^5.1.2",
"@ethereumjs/util": "8.0.5",
"eth-lib": "^0.2.8"
"@ethereumjs/util": "8.0.5"
},
"devDependencies": {
"viem": "~1.5.4",
Expand Down
3 changes: 1 addition & 2 deletions packages/sdk/wallets/wallet-remote/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"@celo/utils": "^6.0.0",
"@celo/wallet-base": "^5.1.2",
"@ethereumjs/util": "8.0.5",
"@types/debug": "^4.1.5",
"eth-lib": "^0.2.8"
"@types/debug": "^4.1.5"
},
"devDependencies": {
"web3": "1.10.0"
Expand Down
9 changes: 1 addition & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2009,7 +2009,6 @@ __metadata:
"@types/debug": "npm:^4.1.5"
bignumber.js: "npm:^9.0.0"
debug: "npm:^4.1.1"
eth-lib: "npm:^0.2.8"
viem: "npm:~1.5.4"
web3: "npm:1.10.0"
web3-eth-accounts: "npm:1.10.0"
Expand All @@ -2035,7 +2034,6 @@ __metadata:
bignumber.js: "npm:^9.0.0"
debug: "npm:^4.1.1"
dotenv: "npm:^8.2.0"
eth-lib: "npm:^0.2.8"
web3: "npm:1.10.0"
languageName: unknown
linkType: soft
Expand All @@ -2061,7 +2059,6 @@ __metadata:
bignumber.js: "npm:^9.0.0"
debug: "npm:^4.1.1"
dotenv: "npm:^8.2.0"
eth-lib: "npm:^0.2.8"
web3: "npm:1.10.0"
languageName: unknown
linkType: soft
Expand All @@ -2085,7 +2082,6 @@ __metadata:
bignumber.js: "npm:^9.0.0"
debug: "npm:^4.1.1"
dotenv: "npm:^8.2.0"
eth-lib: "npm:^0.2.8"
web3: "npm:1.10.0"
languageName: unknown
linkType: soft
Expand All @@ -2105,7 +2101,6 @@ __metadata:
asn1js: "npm:^2.0.26"
bignumber.js: "npm:^9.0.0"
dotenv: "npm:^8.2.0"
eth-lib: "npm:^0.2.8"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2137,7 +2132,6 @@ __metadata:
"@celo/utils": "npm:^6.0.0"
"@celo/wallet-base": "npm:^5.1.2"
"@ethereumjs/util": "npm:8.0.5"
eth-lib: "npm:^0.2.8"
viem: "npm:~1.5.4"
web3: "npm:1.10.0"
languageName: unknown
Expand All @@ -2152,7 +2146,6 @@ __metadata:
"@celo/wallet-base": "npm:^5.1.2"
"@ethereumjs/util": "npm:8.0.5"
"@types/debug": "npm:^4.1.5"
eth-lib: "npm:^0.2.8"
web3: "npm:1.10.0"
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -11425,7 +11418,7 @@ __metadata:
languageName: node
linkType: hard

"eth-lib@npm:0.2.8, eth-lib@npm:^0.2.8":
"eth-lib@npm:0.2.8":
version: 0.2.8
resolution: "eth-lib@npm:0.2.8"
dependencies:
Expand Down

0 comments on commit 18295a3

Please sign in to comment.