diff --git a/README.md b/README.md index d89ed074..579646f3 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,15 @@ -# Ledger Cosmos app +# Ledger THORChain app [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -[![GithubActions](https://github.com/cosmos/ledger-cosmos/actions/workflows/main.yml/badge.svg)](https://github.com/cosmos/ledger-cosmos/blob/main/.github/workflows/main.yaml) --- -![zondax_light](docs/zondax_light.png#gh-light-mode-only) -![zondax_dark](docs/zondax_dark.png#gh-dark-mode-only) - -_Please visit our website at [zondax.ch](zondax.ch)_ - -You can also visit [Zondax Hub](https://hub.zondax.ch/cosmos) to test any of the versions of the app +Forked from [Cosmos App](https://github.com/LedgerHQ/app-cosmos) by Zondax --- -This project contains the Cosmos app for Ledger Nano S, Nano S+, X and Stax. +This project contains the THORChain app for Ledger Nano S, Nano S+, X and Stax. -- Ledger Nano S/S+/X/Stax Cosmos app +- Ledger Nano S/S+/X/Stax THORChain app - Specs / Documentation - C++ unit tests - Zemu tests @@ -28,28 +22,6 @@ Please: - **Do not use a Ledger device with funds for development purposes.** - **Have a separate and marked device that is used ONLY for development and testing** -Tip: - -- In releases, you will find a precompiled test app. If you are just curious, you can run `zxtool.sh` and avoid building. - -## Download and install a prerelease - -*Once the app is approved by Ledger, it will be available in their app store (Ledger Live). -You can get builds generated by CircleCI from the release tab. THESE ARE UNVETTED DEVELOPMENT RELEASES* - -Download a release from here (https://github.com/Zondax/ledger-cosmos/releases). You only need `zxtool.sh` - -If the file is not executable, run -```sh -chmod +x ./zxtool.sh -``` - -then run: - -```sh -./installer_s.sh load -``` - # Development ## Preconditions @@ -116,14 +88,7 @@ If you see conan is not found, check that you installed the package in the same ## How to test with Zemu? -> What is Zemu?? Great you asked!! -> As part of this project, we are making public a beta version of our internal testing+emulation framework for Ledger apps. -> -> Npm Package here: https://www.npmjs.com/package/@zondax/zemu -> -> Repo here: https://github.com/Zondax/zemu - -Let's go! First install everything: +First, install everything: > At this moment, if you change the app you will need to run `make` before running the test again. ```bash diff --git a/app/src/coin.h b/app/src/coin.h index 6a51b7eb..5ff033c3 100644 --- a/app/src/coin.h +++ b/app/src/coin.h @@ -55,7 +55,6 @@ typedef enum { #define COIN_DEFAULT_CHAINID "thorchain" -// In non-expert mode, the app will convert from uatom to ATOM #define COIN_DEFAULT_DENOM_BASE "rune" #define COIN_DEFAULT_DENOM_REPR "RUNE" #define COIN_DEFAULT_DENOM_FACTOR 8u diff --git a/docs/APDUSPEC.md b/docs/APDUSPEC.md index 64e4cac3..cab34af5 100644 --- a/docs/APDUSPEC.md +++ b/docs/APDUSPEC.md @@ -1,4 +1,4 @@ -# Cosmos App - Ledger Nano S +# THORChain App - Ledger Nano S ## General structure The general structure of commands and responses is as follows: @@ -64,7 +64,7 @@ The general structure of commands and responses is as follows: -------------- -### INS_GET_ADDR +### INS_GET_ADDR_SECP256K1 #### Command @@ -79,7 +79,7 @@ The general structure of commands and responses is as follows: | HRP_LEN | byte(1) | Bech32 HRP Length | 1<=HRP_LEN<=83 | | HRP | byte (HRP_LEN) | Bech32 HRP | | | Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 118 / 60 | +| Path[1] | byte (4) | Derivation Path Data | 931 | | Path[2] | byte (4) | Derivation Path Data | ? | | Path[3] | byte (4) | Derivation Path Data | ? | | Path[4] | byte (4) | Derivation Path Data | ? | @@ -109,7 +109,6 @@ First three items in the derivation path will be hardened automatically hardened | L | byte (1) | Bytes in payload | (depends) | The first packet/chunk includes only the derivation path and HRP. -At the moment, seding HRP is optional but it will be mandatory in a future version. All other packets/chunks should contain message to sign @@ -117,13 +116,11 @@ All other packets/chunks should contain message to sign | Field | Type | Content | Expected | | ---------- | -------- | ---------------------- | --------- | -| Path[0] | byte (4) | Derivation Path Data | 44 | -| Path[1] | byte (4) | Derivation Path Data | 118 / 60 | -| Path[2] | byte (4) | Derivation Path Data | ? | -| Path[3] | byte (4) | Derivation Path Data | ? | -| Path[4] | byte (4) | Derivation Path Data | ? | -| HRP_LEN | byte(1) | Bech32 HRP Length | 1<=HRP_LEN<=83 | -| HRP | byte (HRP_LEN) | Bech32 HRP | | +| Path[0] | byte (4) | Derivation Path Data | 44 | +| Path[1] | byte (4) | Derivation Path Data | 931 | +| Path[2] | byte (4) | Derivation Path Data | ? | +| Path[3] | byte (4) | Derivation Path Data | ? | +| Path[4] | byte (4) | Derivation Path Data | ? | *Other Chunks/Packets* diff --git a/docs/TXSPEC.md b/docs/TXSPEC.md index 2343d236..d43a0fcc 100644 --- a/docs/TXSPEC.md +++ b/docs/TXSPEC.md @@ -1,8 +1,7 @@ Transaction Specification ------------------------- -The THORChain App supports the JSON Format transaction type. -### JSON Format +### Format Transactions passed to the Ledger device will be in the following format. The Ledger device MUST accept any transaction (valid as below) in this format. @@ -11,7 +10,7 @@ Transactions passed to the Ledger device will be in the following format. The Le "account_number": {number}, "chain_id": {string}, "fee": { - "amount": [{"amount": {number}, "denom": {string}}, ...], + "amount": [], "gas": {number} }, "memo": {string}, @@ -20,31 +19,71 @@ Transactions passed to the Ledger device will be in the following format. The Le } ``` -`msgs` is a list of messages, which are arbitrary JSON structures. +`msgs` is a list of messages, which are arbitrary JSON structures. Ledger app currently supports `MsgDeposit` & `MsgSend` (examples below). #### Examples ```json { - "account_number": "123", - "chain_id": "cosmoshub-4", + "account_number": "588", + "chain_id": "thorchain", "fee": { - "amount": [{"amount": "4000", "denom": "uatom"}, ...], - "gas": "40000" + "amount": [], + "gas": "2000000" }, - "memo": "this is a comment", - "msgs": [{arbitrary}], - "sequence": "42" + "memo": "TestMemo", + "msgs": [ + { + "type": "thorchain/MsgSend", + "value": { + "amount": [ + { + "amount": "150000000", + "denom": "rune" + } + ], + "from_address": "tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv5t5gp", + "to_address": "tthor10xgrknu44d83qr4s4uw56cqxg0hsev5e68lc9z" + } + } + ], + "sequence": "5" } ``` -Note, all the `{number}` values must be passed as string. +```json +{ + "account_number": "588", + "chain_id": "thorchain", + "fee": { + "amount": [], + "gas": "10000000" + }, + "memo": "", + "msgs": [ + { + "type": "thorchain/MsgDeposit", + "value": { + "coins": [ + { + "amount": "330000000", + "asset": "THOR.RUNE" + } + ], + "memo": "SWAP:BNB.BNB:tbnb1qk2m905ypazwfau9cn0qnr4c4yxz63v9u9md20:", + "signer": "tthor1c648xgpter9xffhmcqvs7lzd7hxh0prgv5t5gp" + } + } + ], + "sequence": "6" +} +``` #### Display Logic The Ledger device SHOULD pick a suitable display representation for the transaction. -The key type (secp256k1 / ed25519), `chain_id`, `account_number`, `sequence`, `fee`, and `memo` should be displayed in that order, each on their own page, autoscrolling if necessary. +The key type (secp256k1 / ed25519), `account_number`, `chain_id`, `fee` , `memo`, and `sequence`, should be displayed in that order, each on their own page, autoscrolling if necessary. Some fields may be clipped when not in advanced mode. `msgs` should be iterated through and each displayed according to the following recursive logic: diff --git a/docs/zondax_dark.png b/docs/zondax_dark.png deleted file mode 100644 index c14ba368..00000000 Binary files a/docs/zondax_dark.png and /dev/null differ diff --git a/docs/zondax_light.png b/docs/zondax_light.png deleted file mode 100644 index 3d25fda0..00000000 Binary files a/docs/zondax_light.png and /dev/null differ