Skip to content

Commit

Permalink
Merge pull request #39 from leapwallet/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
baryon2 authored Oct 23, 2024
2 parents 6610bf2 + 0d3ad1e commit e19e888
Show file tree
Hide file tree
Showing 15 changed files with 459 additions and 482 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/publish-beta.workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn lint:check
test:
Expand All @@ -17,15 +17,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn test

- name: Comment Test Coverage
uses: raulanatol/jest-coverage-comment-action@main
with:
github-token: ${{ secrets.NODE_AUTH_TOKEN }}
use-existing-reports: true
publish-npm-registry:
if: github.ref == 'refs/heads/staging'
needs: [lint, test]
Expand All @@ -34,7 +29,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
Expand All @@ -49,7 +44,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@leapwallet'
- run: yarn
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn lint:check
test:
Expand All @@ -18,15 +18,10 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn test:coverage
- run: yarn test

- name: Comment Test Coverage
uses: raulanatol/jest-coverage-comment-action@main
with:
github-token: ${{ secrets.NODE_AUTH_TOKEN }}
use-existing-reports: true
host-docs:
if: github.ref == 'refs/heads/main'
needs: [lint, test]
Expand All @@ -35,7 +30,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 16
node-version: 18
- run: yarn
- run: yarn doc:build
- uses: actions/upload-artifact@v2
Expand All @@ -55,7 +50,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://registry.npmjs.org'
- run: yarn
- run: yarn build
Expand All @@ -70,7 +65,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
registry-url: 'https://npm.pkg.github.com'
scope: '@leapwallet'
- run: yarn
Expand Down
14 changes: 3 additions & 11 deletions .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"all": true,
"include": [
"src/**/*.ts"
],
"exclude": [
"**/*.test.ts"
],
"reporter": [
"html",
"text",
"lcov"
],
"include": ["src/**/*.ts"],
"exclude": ["**/*.test.ts"],
"reporter": ["html", "text", "lcov"],
"report-dir": "./coverage"
}
9 changes: 9 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignore artifacts:
build
coverage

# Ignore all HTML files:
**/*.html
.github
docs/
dist/
30 changes: 30 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const eslint = require('@eslint/js');
const tseslint = require('@typescript-eslint/eslint-plugin');
const tseslintParser = require('@typescript-eslint/parser');
module.exports = [
{ ignores: ['coverage/', 'dist/', '.github/', '.git/'] },
{
...eslint.configs.recommended,
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tseslintParser,
parserOptions: {
ecmaVersion: 2020,
},
globals: {
// es6 environment globals
Promise: 'readonly',
Symbol: 'readonly',
},
},
plugins: {
'@typescript-eslint': tseslint,
},
rules: {
...tseslint.configs.recommended.rules,
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-namespace': 'off',
},
},
];
68 changes: 20 additions & 48 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@leapwallet/leap-keychain",
"version": "0.2.5-beta.5",
"version": "0.2.5-beta.9",
"description": "A javascript library for crypto key management",
"scripts": {
"test": "nyc mocha",
"lint:prettier": "prettier . --ignore-path .gitignore",
"lint:prettier": "prettier .",
"lint:prettier:check": "yarn lint:prettier -c",
"lint:prettier:fix": "yarn lint:prettier -w",
"lint:eslint": "eslint . --ignore-path .gitignore",
"lint:eslint": "eslint .",
"lint:eslint:check": "yarn lint:eslint",
"lint:eslint:fix": "yarn lint:eslint --fix",
"lint:tsc": "tsc --noEmit",
Expand All @@ -21,32 +21,24 @@
"build": "tsc -p tsconfig-browser.json && tsc -p tsconfig-node.json",
"test:coverage": "nyc"
},
"jest": {
"preset": "ts-jest",
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/node_modules/",
"/dist/"
]
},
"types": "dist/browser/src/index.d.ts",
"types": "dist/browser/index.d.ts",
"license": "MIT",
"repository": "leapwallet/leap-keychain",
"keywords": [
"leap wallet"
],
"engines": {
"node": "16"
"node": "18"
},
"author": "Leap Wallet <[email protected]> (https://leapwallet.io)",
"bugs": "https://github.com/leapwallet/leap-keychain/issues",
"homepage": "https://github.com/leapwallet/leap-keychain#readme",
"files": [
"dist/browser/src/",
"dist/node/src/"
"dist/browser/",
"dist/node/"
],
"main": "dist/node/src/index.js",
"browser": "dist/browser/src/index.js",
"main": "dist/node/index.js",
"browser": "dist/browser/index.js",
"dependencies": {
"@ethersproject/bytes": "5.7.0",
"@ethersproject/hdnode": "5.7.0",
Expand All @@ -71,14 +63,14 @@
"@types/jest": "28.1.4",
"@types/mocha": "^10.0.9",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "5.9.1",
"@typescript-eslint/parser": "5.9.1",
"eslint": "8.6.0",
"expect.js": "^0.3.1",
"mocha": "^10.7.3",
"nyc": "^17.1.0",
"@typescript-eslint/eslint-plugin": "8.11.0",
"@typescript-eslint/parser": "8.11.0",
"eslint": "9.13.0",
"expect.js": "0.3.1",
"mocha": "10.7.3",
"nyc": "17.1.0",
"prettier": "2.5.1",
"ts-node": "^10.9.2",
"ts-node": "10.9.2",
"typedoc": "0.22.17",
"typedoc-plugin-missing-exports": "1.0.0",
"typescript": "4.7.3"
Expand All @@ -89,30 +81,10 @@
"jsxSingleQuote": true,
"trailingComma": "all"
},
"eslintConfig": {
"env": {
"es6": true,
"jest": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-namespace": "off"
}
},
"resolutions": {
"protobufjs": "6.11.4"

"protobufjs": "6.11.4",
"semver": "7.6.0",
"braces": "3.0.3",
"secp256k1": "4.0.4"
}
}
4 changes: 2 additions & 2 deletions src/key/eth-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class EthWallet {
static generateWalletFromPvtKey(pvtKey: string, options: WalletOptions) {
try {
new Wallet(pvtKey);
} catch (e) {
throw new Error('Invalid private key');
} catch (e: any) {
throw new Error(`Invalid private key ${e.message}`);
}
return new EthWallet('', pvtKey.replace('0x', ''), 'pvtKey', options);
}
Expand Down
12 changes: 6 additions & 6 deletions test/encoding.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { encodeSecp256k1Pubkey, encodeSecp256k1Signature } from '../src';
import * as base64js from 'base64-js';
import expect from 'expect.js'
import expect from 'expect.js';

describe('encoding', function() {
describe('encoding', function () {
describe('public key encoding', () => {
it('returns correct encoding type', function() {
it('returns correct encoding type', function () {
const pubkey = new Uint8Array([
0x02, 0x75, 0x9f, 0x18, 0x2b, 0x3e, 0x3d, 0x29, 0x5c, 0x5d, 0x3b, 0x0d, 0x80, 0x5e, 0x8b, 0x1a, 0x4f, 0x13,
0x75, 0x4a, 0x1d, 0x6a, 0x56, 0x37, 0x9c, 0xc8, 0x0d, 0x91, 0x1d, 0x6d, 0x51, 0x0c, 0x37,
Expand All @@ -13,7 +13,7 @@ describe('encoding', function() {
expect(pubkey_encoded.type).to.equal('tendermint/PubKeySecp256k1');
});

it('throws error if public key of incorrect size is passed', function() {
it('throws error if public key of incorrect size is passed', function () {
const pubkey = new Uint8Array([
0x02, 0x75, 0x9f, 0x18, 0x2b, 0x3e, 0x3d, 0x29, 0x5c, 0x5d, 0x3b, 0x0d, 0x80, 0x5e, 0x8b, 0x1a, 0x4f, 0x13,
0x75, 0x4a, 0x1d, 0x6a, 0x56, 0x37, 0x9c, 0xc8, 0x0d, 0x91, 0x1d, 0x6d, 0x51, 0x0c,
Expand All @@ -26,7 +26,7 @@ describe('encoding', function() {
expect(t).throwError();
});

it('throws error if public key of with incorrect starting bytes is passed', function() {
it('throws error if public key of with incorrect starting bytes is passed', function () {
const pubkey = new Uint8Array([
0x80, 0x75, 0x9f, 0x18, 0x2b, 0x3e, 0x3d, 0x29, 0x5c, 0x5d, 0x3b, 0x0d, 0x80, 0x5e, 0x8b, 0x1a, 0x4f, 0x13,
0x75, 0x4a, 0x1d, 0x6a, 0x56, 0x37, 0x9c, 0xc8, 0x0d, 0x91, 0x1d, 0x6d, 0x51, 0x0c, 0x37,
Expand All @@ -41,7 +41,7 @@ describe('encoding', function() {
});

describe('signature encoding', () => {
it('encodeSecp256k1Signature', function() {
it('encodeSecp256k1Signature', function () {
const pubkey = new Uint8Array(33);
pubkey[0] = 3;
for (let i = 1; i < 33; i++) {
Expand Down
2 changes: 1 addition & 1 deletion test/encryption-utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { decrypt, encrypt } from '../src';
import expect from 'expect.js'
import expect from 'expect.js';

describe('encryption-utils', () => {
it('encrypt-decrypt-2', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/keychain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Bip32 } from '../src/crypto/bip32/hd-wallet';
import { sha256 } from '@noble/hashes/sha256';
import { ripemd160 } from '@noble/hashes/ripemd160';
import { Secp256k1, secp256k1Token } from '../src/crypto/ecc/secp256k1';
import expect from 'expect.js'
import expect from 'expect.js';

const { ref1, ref2 } = referenceWallets;

Expand Down
Loading

0 comments on commit e19e888

Please sign in to comment.