-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Zondax/dev
Migrate to Typescript
- Loading branch information
Showing
39 changed files
with
1,279 additions
and
12,774 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.cache | ||
.git | ||
node_modules | ||
public | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module.exports = { | ||
root: true, | ||
parser: '@typescript-eslint/parser', | ||
plugins: ['@typescript-eslint', 'jest'], | ||
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:jest/recommended', 'prettier'], | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
settings: {}, | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
}, | ||
parserOptions: {}, | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-var-requires': 0, | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'no-prototype-builtins': 0, | ||
'@typescript-eslint/no-misused-new': 0, | ||
'no-undef': 0, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: 'Main' | ||
on: | ||
- push | ||
|
||
jobs: | ||
configure: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
uid_gid: ${{ steps.get-user.outputs.uid_gid }} | ||
datetime: ${{ steps.get-datetime.outputs.datetime }} | ||
steps: | ||
- id: get-user | ||
run: echo "::set-output name=uid_gid::$(id -u):$(id -g)" | ||
- id: get-datetime | ||
run: echo "::set-output name=datetime::$(date +'%Y%m%d%H%M%S')" | ||
|
||
build: | ||
needs: [configure] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Install node | ||
uses: actions/setup-node@v2 | ||
- name: Install dependencies | ||
run: yarn install | ||
- name: Run linter | ||
run: yarn linter | ||
- name: Run formatter | ||
run: yarn format | ||
- name: Build | ||
run: yarn build | ||
- name: Unit tests | ||
run: yarn test:unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: 'Publish packages' | ||
|
||
on: | ||
release: | ||
types: | ||
- published | ||
- edited | ||
tags: | ||
- "v[0-9]+(\\.[0-9]+)*" | ||
|
||
jobs: | ||
configure: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
datetime: ${{ steps.get-datetime.outputs.datetime }} | ||
steps: | ||
- id: get-datetime | ||
run: echo "::set-output name=datetime::$(date +'%Y%m%d%H%M%S')" | ||
|
||
publish_npm_package: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Install node | ||
uses: actions/setup-node@v2 | ||
with: | ||
registry-url: 'https://registry.npmjs.org' | ||
scope: '@zondax' | ||
- run: mv README-npm.md README.md | ||
- name: Install yarn | ||
run: npm install -g yarn | ||
- run: yarn install | ||
- run: yarn build | ||
- name: Get latest release version number | ||
id: get_version | ||
uses: battila7/get-version-action@v2 | ||
- name: Update tag | ||
run: | | ||
echo Publishing as ${{ steps.get_version.outputs.version }} | ||
npm --allow-same-version --no-git-tag-version version ${{ steps.get_version.outputs.version }} | ||
- name: Publish package | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_PUBLISH_AUTO }} | ||
run: | | ||
npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,3 +70,10 @@ TODO\.md | |
/certs/cert.pem | ||
/certs/server.cert | ||
/certs/server.key | ||
|
||
/.idea | ||
/node_modules/ | ||
/output/ | ||
/dist/ | ||
|
||
/yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.cache | ||
package.json | ||
package-lock.json | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"trailingComma": "all", | ||
"singleQuote": true, | ||
"arrowParens": "avoid", | ||
"semi": false, | ||
"useTabs": false, | ||
"printWidth": 140, | ||
"tabWidth": 2 | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,47 @@ | ||
# ledger-cosmos-js | ||
# @zondax/ledger-cosmos-js | ||
|
||
![zondax_light](docs/zondax_light.png#gh-light-mode-only) | ||
![zondax_dark](docs/zondax_dark.png#gh-dark-mode-only) | ||
|
||
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) | ||
[![npm version](https://badge.fury.io/js/ledger-cosmos-js.svg)](https://badge.fury.io/js/ledger-cosmos-js) | ||
[![CircleCI](https://circleci.com/gh/Zondax/ledger-cosmos-js/tree/master.svg?style=shield)](https://circleci.com/gh/Zondax/ledger-cosmos-js/tree/master) | ||
[![Main](https://github.com/Zondax/ledger-cosmos-js/workflows/Main/badge.svg)](https://github.com/Zondax/ledger-cosmos-js/actions?query=workflow%3AMain) | ||
[![npm version](https://badge.fury.io/js/%40zondax%2Fledger-cosmos-js.svg)](https://badge.fury.io/js/%40zondax%2Fledger-cosmos-js) | ||
|
||
|
||
This package provides a basic client library to communicate with a Tendermint/Cosmos App running in a Ledger Nano S/X | ||
This package provides a basic client library to communicate with a Tendermint/Cosmos App running in a Ledger Nano S/S+/X devices | ||
|
||
We recommend using the npmjs package in order to receive updates/fixes. | ||
|
||
This repo also includes a simple Vue example for U2F and WebUSB. | ||
|
||
![Example](docs/example.png) | ||
# Available commands | ||
|
||
| Operation | Response | Command | | ||
| ---------- | ---------------- | ----------------------- | | ||
| getVersion | app version | --------------- | | ||
| publicKey | pubkey | path (legacy command) | | ||
| getAddressAndPubKey | pubkey + address | path + ( showInDevice ) | | ||
| showAddressAndPubKey | signed message | path | | ||
| appInfo | name, version, flags, etc | --------------- | | ||
| deviceInfo | fw and mcu version, id, etc | Only available in dashboard | | ||
| sign | signed message | path + message | | ||
|
||
|
||
getAddress command requires that you set the derivation path (account, change, index) and has an option parameter to display the address on the device. By default, it will retrieve the information without user confirmation. | ||
|
||
|
||
# Testing with real devices | ||
|
||
It is possible to test this package with a real Ledger Nano device. To accomplish that, you will need to follow these steps: | ||
|
||
- Install the application in the Ledger device | ||
- Install the dependencies from this project | ||
- Run tests | ||
|
||
```shell script | ||
yarn install | ||
yarn test:integration | ||
``` | ||
|
||
# Who we are? | ||
|
||
**Note: WebUSB support requires Cosmos app >1.5.3** | ||
We are Zondax, a company pioneering blockchain services. If you want to know more about us, please visit us at [zondax.ch](https://zondax.ch) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,7 @@ | ||
// For a detailed explanation regarding each configuration property, visit: | ||
// https://jestjs.io/docs/en/configuration.html | ||
|
||
module.exports = { | ||
modulePaths: ["<rootDir>/src", "<rootDir>/tests"], | ||
|
||
moduleNameMapper: { | ||
"^jest$": "<rootDir>/tests/jest.js", | ||
"^index.js$": "<rootDir>/src/index.js", | ||
}, | ||
|
||
// Automatically clear mock calls and instances between every test | ||
clearMocks: true, | ||
|
||
// The directory where Jest should output its coverage files | ||
coverageDirectory: "coverage", | ||
|
||
// A list of paths to directories that Jest should use to search for files in | ||
roots: ["<rootDir>"], | ||
|
||
runner: "jest-serial-runner", | ||
|
||
// The test environment that will be used for testing | ||
testEnvironment: "node", | ||
|
||
// The glob patterns Jest uses to detect test files | ||
testMatch: [ | ||
"**/__tests__/**/*.[jt]s?(x)", | ||
"**/?(*.)+(spec|test).[tj]s?(x)", | ||
"**/?(*.)+(ispec|test).[tj]s?(x)", | ||
], | ||
}; | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
transformIgnorePatterns: ['^.+\\.js$'], | ||
modulePaths: ['<rootDir>/src', '<rootDir>/tests'], | ||
runner: 'jest-serial-runner', | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.