Skip to content

Commit

Permalink
Merge pull request #59 from Zondax/dev
Browse files Browse the repository at this point in the history
Migrate to Typescript
  • Loading branch information
ftheirs authored Aug 29, 2022
2 parents 97a90fe + 7440011 commit 9ce2b41
Show file tree
Hide file tree
Showing 39 changed files with 1,279 additions and 12,774 deletions.
13 changes: 0 additions & 13 deletions .babelrc

This file was deleted.

62 changes: 0 additions & 62 deletions .circleci/config.yml

This file was deleted.

8 changes: 3 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ root = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{js,json,vue}]
indent_style = space
indent_size = 2
end_of_line = lf

[*.sh]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.cache
.git
node_modules
public
build
dist
27 changes: 27 additions & 0 deletions .eslintrc.js
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,
},
}
31 changes: 0 additions & 31 deletions .eslintrc.json

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/main.yaml
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
46 changes: 46 additions & 0 deletions .github/workflows/publish.yaml
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,10 @@ TODO\.md
/certs/cert.pem
/certs/server.cert
/certs/server.key

/.idea
/node_modules/
/output/
/dist/

/yarn.lock
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.cache
package.json
package-lock.json
dist
node_modules
9 changes: 9 additions & 0 deletions .prettierrc
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
}
4 changes: 0 additions & 4 deletions .prettierrc.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2019 ZondaX GmbH
Copyright 2018 - 2022 ZondaX AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
46 changes: 39 additions & 7 deletions README.md
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)
Binary file added docs/zondax_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/zondax_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions jest.config.integration.js

This file was deleted.

37 changes: 6 additions & 31 deletions jest.config.js
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',
}
9 changes: 0 additions & 9 deletions jest.config.unit.js

This file was deleted.

Loading

0 comments on commit 9ce2b41

Please sign in to comment.