Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Z4karia authored Apr 12, 2024
1 parent 0adc3f0 commit 8a447dd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
45 changes: 5 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion app/src/coin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 8 additions & 11 deletions docs/APDUSPEC.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -64,7 +64,7 @@ The general structure of commands and responses is as follows:

--------------

### INS_GET_ADDR
### INS_GET_ADDR_SECP256K1

#### Command

Expand All @@ -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 | ? |
Expand Down Expand Up @@ -109,21 +109,18 @@ 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

*First Packet*

| 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*

Expand Down
65 changes: 52 additions & 13 deletions docs/TXSPEC.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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},
Expand All @@ -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:

Expand Down
Binary file removed docs/zondax_dark.png
Binary file not shown.
Binary file removed docs/zondax_light.png
Binary file not shown.

0 comments on commit 8a447dd

Please sign in to comment.