Skip to content

Commit

Permalink
Merge branch 'main' into test-bytes-0x
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Nov 20, 2023
2 parents 6659b7a + 5dea85e commit 2174b6a
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 214 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
YARN_VERSION: ${{ steps.yarn-version.outputs.YARN_VERSION }}
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -41,7 +41,7 @@ jobs:
- prepare
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- prepare
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:
- prepare
strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 19.x]
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14
v18
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [7.0.0]
### Changed
- **BREAKING**: Increase minimum Node.js version to v16 ([#332](https://github.com/MetaMask/eth-sig-util/pull/332))
- **BREAKING**: Bump `@metamask/abi-utils` from `^1.0.2` to `^2.0.2` ([#326](https://github.com/MetaMask/eth-sig-util/pull/336))
- Bump `@metamask/utils` from `^5.0.2` to `^8.1.0` ([#333](https://github.com/MetaMask/eth-sig-util/pull/333))

## [6.0.1]
### Changed
- Swap out legacy `ethereumjs-abi` for `@metamask/abi-utils` ([#319](https://github.com/MetaMask/eth-sig-util/pull/319))

### Fixed
- Bump `ethereum-cryptography` from `^2.0.0` to `^2.1.2` ([#302](https://github.com/MetaMask/eth-sig-util/pull/302))
- Bump `ethereumjs/util` from `^8.0.6` to `^8.1.0` ([#302](https://github.com/MetaMask/eth-sig-util/pull/302))
- Remove unused dependency `bn.js` (#334) ([#302](https://github.com/MetaMask/eth-sig-util/pull/302))

## [6.0.0]
### Changed
- **BREAKING**: Fix `normalize` for empty strings and `0` ([#315](https://github.com/MetaMask/eth-sig-util/pull/315))
Expand Down Expand Up @@ -119,7 +134,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix package metadata ([#81](https://github.com/MetaMask/eth-sig-util/pull/81)
- Switch from Node.js v8 to Node.js v10 ([#76](https://github.com/MetaMask/eth-sig-util/pull/77) and [#80](https://github.com/MetaMask/eth-sig-util/pull/80))

[Unreleased]: https://github.com/MetaMask/eth-sig-util/compare/v6.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/eth-sig-util/compare/v7.0.0...HEAD
[7.0.0]: https://github.com/MetaMask/eth-sig-util/compare/v6.0.1...v7.0.0
[6.0.1]: https://github.com/MetaMask/eth-sig-util/compare/v6.0.0...v6.0.1
[6.0.0]: https://github.com/MetaMask/eth-sig-util/compare/v5.1.0...v6.0.0
[5.1.0]: https://github.com/MetaMask/eth-sig-util/compare/v5.0.3...v5.1.0
[5.0.3]: https://github.com/MetaMask/eth-sig-util/compare/v5.0.2...v5.0.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The full API documentation for the latest published version of this library is [

### Setup

- Install [Node.js](https://nodejs.org) version 14
- Install [Node.js](https://nodejs.org) version 18
- If you are using [nvm](https://github.com/creationix/nvm#installation) (recommended) running `nvm use` will automatically choose the right node version for you.
- Install [Yarn v3](https://yarnpkg.com/getting-started/install)
- Run `yarn install` to install dependencies and run any required post-install scripts
Expand Down
25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/eth-sig-util",
"version": "6.0.0",
"version": "7.0.0",
"description": "A few useful functions for signing ethereum data",
"keywords": [
"ethereum",
Expand All @@ -26,10 +26,10 @@
"files": [
"dist",
"!__snapshots__",
"!*.test.js",
"!*.test.js.map",
"!*.test.ts",
"!*.test.d.ts"
"!**/*.test.js",
"!**/*.test.js.map",
"!**/*.test.ts",
"!**/*.test.d.ts"
],
"scripts": {
"build": "tsc --project .",
Expand All @@ -44,12 +44,10 @@
"test:watch": "jest --watch"
},
"dependencies": {
"@ethereumjs/util": "^8.0.6",
"@metamask/abi-utils": "^1.2.0",
"@metamask/utils": "^5.0.2",
"bn.js": "^4.12.0",
"ethereum-cryptography": "^2.0.0",
"ethjs-util": "^0.1.6",
"@ethereumjs/util": "^8.1.0",
"@metamask/abi-utils": "^2.0.2",
"@metamask/utils": "^8.1.0",
"ethereum-cryptography": "^2.1.2",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1"
},
Expand All @@ -60,9 +58,8 @@
"@metamask/eslint-config-jest": "^11.1.0",
"@metamask/eslint-config-nodejs": "^11.1.0",
"@metamask/eslint-config-typescript": "^11.1.0",
"@types/bn.js": "^4.11.6",
"@types/jest": "^27.0.6",
"@types/node": "^14.14.25",
"@types/node": "^16.18.50",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"ajv": "^8.11.0",
Expand All @@ -83,7 +80,7 @@
},
"packageManager": "yarn@3.2.2",
"engines": {
"node": ">=14.0.0"
"node": "^16.20 || ^18.16 || >=20"
},
"publishConfig": {
"access": "public",
Expand Down
12 changes: 9 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import {
ecrecover,
fromRpcSig,
fromSigned,
isHexString,
toBuffer,
ToBufferInputTypes,
toUnsigned,
} from '@ethereumjs/util';
import { add0x, bytesToHex, numberToBytes } from '@metamask/utils';
import { intToHex, isHexString, stripHexPrefix } from 'ethjs-util';
import {
numberToHex,
remove0x,
add0x,
bytesToHex,
numberToBytes,
} from '@metamask/utils';

/**
* Pads the front of the given hex string with zeroes until it reaches the
Expand Down Expand Up @@ -76,7 +82,7 @@ export function concatSig(v: Buffer, r: Buffer, s: Buffer): string {
const vSig = bufferToInt(v);
const rStr = padWithZeroes(toUnsigned(rSig).toString('hex'), 64);
const sStr = padWithZeroes(toUnsigned(sSig).toString('hex'), 64);
const vStr = stripHexPrefix(intToHex(vSig));
const vStr = remove0x(numberToHex(vSig));
return add0x(rStr.concat(sStr, vStr));
}

Expand Down
Loading

0 comments on commit 2174b6a

Please sign in to comment.