Merge pull request #300 from LedgerHQ/develop

App release 1.9.18
This commit is contained in:
apaillier-ledger
2022-04-27 10:54:12 +02:00
committed by GitHub
479 changed files with 1879 additions and 1126 deletions

40
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,40 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Fix [Subject of the issue]'
labels: 'bug'
assignees: ''
---
## Description
Describe your issue in as much detail as possible here.
## Your environment
* OS and version
* branch that causes this issue
* Device (Nano S, Nano X, Ledger Blue)
## Steps to reproduce
* Tell us how to reproduce this issue <br />
* Where the issue is, if you know <br />
* Which commands triggered the issue, if any
## Expected behaviour
Tell us what should happen
## Actual behaviour
Tell us what happens instead
## Logs
Please paste any logs here that demonstrate the issue, if they exist
## Proposed solution
If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it

View File

@@ -0,0 +1,18 @@
---
name: Feature report
about: Suggest an idea for this project
title: 'Add [Subject of the issue]'
labels: 'enhancement'
assignees: ''
---
## Description
Describe your issue in as much detail as possible here.
## Your environment
* OS and version
* branch that causes this issue
* Device (Nano S, Nano X, Ledger Blue)

View File

@@ -0,0 +1,19 @@
---
name: Network request
about: Request of new chain or network
title: 'Add {NameChain} network ({SYMBOL})'
labels: 'enhancement, chain/network'
assignees: ''
---
## Description
- [ ] Symbol:
- [ ] ChainId:
- [ ] Website:
- [ ] Block-Explorer:
- [ ] [slip-0044](https://github.com/satoshilabs/slips/blob/master/slip-0044.md) type:
## Additional comments
Please post additional comments in this section if you have them, otherwise delete it.

View File

@@ -0,0 +1,80 @@
name: 'Commit and push if the version file has changed'
inputs:
name:
description: 'The name of the commiter'
required: true
default: 'github-actions[bot]'
email:
description: 'The email of the commiter'
required: true
default: 'github-actions[bot]@users.noreply.github.com'
message:
description: 'The commit message'
required: true
default: 'New release version(s)'
files:
description: 'The file(s) to add in the commit'
required: true
default: '*'
directory:
description: 'The directory in which the action will be performed'
required: true
default: '.'
branch:
description: 'Checkout (or create) on a specific branch before commit/push'
required: true
default: 'master'
secret:
description: 'A token allowing to push the commit on the repository'
required: true
default: '.'
repository:
description: 'The repository where to push'
required: true
default: ''
runs:
using: 'composite'
steps:
- name: Commit the changes
id: commit
run: |
git config --global user.name ${{ inputs.name }}
ORIGIN="$(pwd)"
cd ${{ inputs.directory }}
git switch ${{ inputs.branch }} 2>/dev/null || git switch -c ${{ inputs.branch }}
echo "-----------------------------------------------------------"
echo "Initial repo status"
git status
CHANGES="$(git status --porcelain ${{ inputs.files }})"
if [ -z "${CHANGES}" ]; \
then \
echo "-----------------------------------------------------------"; \
echo "No changes, stopping now"; \
echo "COMMIT=NO" > $GITHUB_ENV; \
cd "${ORIGIN}"; \
exit 0; \
fi
echo -e "Changes:\n${CHANGES}"
git add ${{ inputs.files }}
echo "-----------------------------------------------------------"
echo "Repo status before commit"
git status
git commit -am "${{ inputs.message }}"
echo "COMMIT=YES" > $GITHUB_ENV
git log -n 2
cd "${ORIGIN}"
shell: bash
- run: echo "${{ env.COMMIT }}"
shell: bash
- name: Push commit
if: ${{ env.COMMIT == 'YES' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ inputs.secret }}
branch: ${{ inputs.branch }}
directory: ${{ inputs.directory }}
repository: ${{ inputs.repository }}

21
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,21 @@
## Description
Please provide a detailed description of what was done in this PR.
(And mentioned if linked to an issue [docs](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue))
## Changes include
- [ ] Bugfix (non-breaking change that solves an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (change that is not backwards-compatible and/or changes current functionality)
- [ ] Tests
- [ ] Documentation
- [ ] Other (for changes that might not fit in any category)
## Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it.
## Additional comments
Please post additional comments in this section if you have them, otherwise delete it.

View File

@@ -0,0 +1,14 @@
name: 'Auto Author Assign'
on:
pull_request_target:
types: [opened, reopened]
permissions:
pull-requests: write
jobs:
assign-author:
runs-on: ubuntu-latest
steps:
- uses: toshimaru/auto-author-assign@v1.4.0

View File

@@ -1,12 +1,14 @@
name: Compilation & tests
on:
workflow_dispatch:
push:
branches:
- master
pull_request:
branches:
- master
- develop
jobs:
job_build_debug_nano_s:
@@ -102,8 +104,27 @@ jobs:
name: scan-build
path: scan-build
building_for_e2e_tests:
name: Building binaries for E2E tests
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
steps:
- uses: actions/checkout@v2
- name: Build testing binaries
run: cd tests && ./build_local_test_elfs.sh
- name: Upload app binaries
uses: actions/upload-artifact@v2
with:
name: e2e_elfs
path: ./tests/elfs/
jobs-e2e-tests:
needs: [job_build_debug_nano_s, job_build_debug_nano_x]
name: E2E tests
needs: [building_for_e2e_tests]
runs-on: ubuntu-latest
steps:
- name: Test
@@ -113,28 +134,30 @@ jobs:
echo $DISPLAY
- name: Checkout
uses: actions/checkout@v2
- run: sudo apt-get update -y && sudo apt-get install -y libusb-1.0.0 libudev-dev
- name: Install node
uses: actions/setup-node@v2
with:
node-version: "14.4.0"
- name: Install yarn
run: |
npm install -g yarn
run: npm install -g yarn
- name: Build/Install build js deps
run: |
cd tests && yarn install
run: cd tests && yarn install
- name: Create tmp folder for artifacts
run: |
mkdir tests/elfs
run: mkdir tests/elfs
- name: Download app binaries
uses: actions/download-artifact@v2
with:
path: tests/elfs
path: tmp/
- name: Gather elfs
run: |
cd tests/elfs
cp `find . -name "*.elf"` .
run: cp `find tmp/e2e_elfs/ -name "*.elf"` tests/elfs/
- name: Run zemu tests
run: |
cd tests && yarn test
run: cd tests && yarn test

View File

@@ -7,6 +7,7 @@ on:
pull_request:
branches:
- master
- develop
jobs:
job_lint:
@@ -18,8 +19,8 @@ jobs:
uses: actions/checkout@v2
- name: Lint
uses: DoozyX/clang-format-lint-action@v0.11
uses: DoozyX/clang-format-lint-action@v0.13
with:
source: "./"
extensions: "h,c"
clangFormatVersion: 10
clangFormatVersion: 12.0.0

53
.github/workflows/sdk-generation.yml vendored Normal file
View File

@@ -0,0 +1,53 @@
name: Updating the SDK
on:
workflow_dispatch:
push:
branches:
- master
- develop
jobs:
updating_SDK:
name: Updating the SDK
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v2
with:
# by default the action uses fetch-depth = 1, which creates
# shallow repositories from which we can't push
fetch-depth: 0
submodules: recursive
# needed, else the push inside the action will use default credentials
# instead of provided ones
persist-credentials: false
- name: Build new SDK
run: python tools/build_sdk.py
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: Commit & push changes in the SDK if any
uses: ./.github/actions/commit-changes
with:
name: 'ldg-github-ci'
directory: ethereum-plugin-sdk
branch: ${{ steps.extract_branch.outputs.branch }}
message: "[update] Branch ${{ steps.extract_branch.outputs.branch }} | Commit ${GITHUB_SHA}"
secret: ${{ secrets.CI_BOT_TOKEN }}
repository: LedgerHQ/ethereum-plugin-sdk
- name: Update the SDK submodule in the Ethereum app
uses: ./.github/actions/commit-changes
with:
name: 'ldg-github-ci'
files: ethereum-plugin-sdk
branch: ${{ steps.extract_branch.outputs.branch }}
message: "[update][SDK] Branch ${{ steps.extract_branch.outputs.branch }} | Commit ${GITHUB_SHA}"
secret: ${{ secrets.CI_BOT_TOKEN }}
repository: LedgerHQ/app-ethereum

View File

@@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.9.18](https://github.com/ledgerhq/app-ethereum/compare/1.9.17...1.9.18) - 2022-04-25
### Added
- Easier way of adding a chain into the Makefile
- EIP 1024 support
- Conflux chain
- Moonbeam chain
- KardiaChain
- BitTorrent Chain
- Wethio chain
### Changed
- More uniform naming between the ERC-721 & ERC-1155 screens
### Fixed
- CI (mostly Zemu tests)
- App crashing when trying to approve an NFT transaction without having received the NFT information beforehand
- App refusing to approve an NFT transaction with a long collection name
## [1.9.17](https://github.com/ledgerhq/app-ethereum/compare/1.9.16...1.9.17) - 2022-01-14
### Added

229
Makefile
View File

@@ -28,222 +28,37 @@ APP_LOAD_PARAMS += --path "45'"
# Samsung temporary implementation for wallet ID on 0xda7aba5e/0xc1a551c5
APP_LOAD_PARAMS += --path "1517992542'/1101353413'"
##################
# Define Version #
##################
APPVERSION_M=1
APPVERSION_N=9
APPVERSION_P=17
APPVERSION_P=18
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
APP_LOAD_FLAGS= --appFlags 0x240 --dep Ethereum:$(APPVERSION)
###########################
# Set Chain environnement #
###########################
ifeq ($(CHAIN),)
CHAIN=ethereum
endif
ifeq ($(CHAIN),ethereum)
# Lock the application on its standard path for 1.5. Please complain if non compliant
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=1
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Ethereum"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40
else ifeq ($(CHAIN),ropsten)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=3
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
# Keep for Starkware Ropsten tests
DEFINES += HAVE_TOKENS_EXTRA_LIST
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Eth Ropsten"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40
else ifeq ($(CHAIN),goerli)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=5
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
# Keep for Starkware Goerli tests
DEFINES += HAVE_TOKENS_EXTRA_LIST
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Eth Goerli"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40
else ifeq ($(CHAIN),ellaism)
APP_LOAD_PARAMS += --path "44'/163'"
DEFINES += CHAINID_UPCASE=\"ELLA\" CHAINID_COINNAME=\"ELLA\" CHAIN_KIND=CHAIN_KIND_ELLAISM CHAIN_ID=64
APPNAME = "Ellaism"
else ifeq ($(CHAIN),ethereum_classic)
# Also allows ETC to access the ETH derivation path to recover forked assets
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETC\" CHAINID_COINNAME=\"ETC\" CHAIN_KIND=CHAIN_KIND_ETHEREUM_CLASSIC CHAIN_ID=61
APPNAME = "Ethereum Classic"
else ifeq ($(CHAIN),ethersocial)
APP_LOAD_PARAMS += --path "44'/31102'"
DEFINES += CHAINID_UPCASE=\"ETHERSOCIAL\" CHAINID_COINNAME=\"ESN\" CHAIN_KIND=CHAIN_KIND_ETHERSOCIAL CHAIN_ID=31102
APPNAME = "Ethersocial"
else ifeq ($(CHAIN),ether1)
APP_LOAD_PARAMS += --path "44'/1313114'"
DEFINES += CHAINID_UPCASE=\"ETHER1\" CHAINID_COINNAME=\"ETHO\" CHAIN_KIND=CHAIN_KIND_ETHER1 CHAIN_ID=1313114
APPNAME = "Ether-1"
else ifeq ($(CHAIN),expanse)
APP_LOAD_PARAMS += --path "44'/40'"
DEFINES += CHAINID_UPCASE=\"EXPANSE\" CHAINID_COINNAME=\"EXP\" CHAIN_KIND=CHAIN_KIND_EXPANSE CHAIN_ID=2
APPNAME = "Expanse"
else ifeq ($(CHAIN),pirl)
APP_LOAD_PARAMS += --path "44'/164'"
DEFINES += CHAINID_UPCASE=\"PIRL\" CHAINID_COINNAME=\"PIRL\" CHAIN_KIND=CHAIN_KIND_PIRL CHAIN_ID=3125659152
APPNAME = "Pirl"
else ifeq ($(CHAIN),poa)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"POA\" CHAINID_COINNAME=\"POA\" CHAIN_KIND=CHAIN_KIND_POA CHAIN_ID=99
APPNAME = "POA"
else ifeq ($(CHAIN),artis_sigma1)
APP_LOAD_PARAMS += --path "44'/246529'"
DEFINES += CHAINID_UPCASE=\"ARTISSIGMA1\" CHAINID_COINNAME=\"ATS\" CHAIN_KIND=CHAIN_KIND_ARTIS_SIGMA1 CHAIN_ID=246529
APPNAME = "ARTIS sigma1"
else ifeq ($(CHAIN),artis_tau1)
APP_LOAD_PARAMS += --path "44'/246785'"
DEFINES += CHAINID_UPCASE=\"ARTISTAU1\" CHAINID_COINNAME=\"ATS\" CHAIN_KIND=CHAIN_KIND_ARTIS_TAU1 CHAIN_ID=246785
APPNAME = "ARTIS tau1"
else ifeq ($(CHAIN),rsk)
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
DEFINES += CHAINID_UPCASE=\"RSK\" CHAINID_COINNAME=\"RBTC\" CHAIN_KIND=CHAIN_KIND_RSK CHAIN_ID=30
APPNAME = "RSK"
else ifeq ($(CHAIN),rsk_testnet)
APP_LOAD_PARAMS += --path "44'/37310'"
DEFINES += CHAINID_UPCASE=\"RSKTESTNET\" CHAINID_COINNAME=\"RBTC\" CHAIN_KIND=CHAIN_KIND_RSK CHAIN_ID=31
APPNAME = "RSK Test"
else ifeq ($(CHAIN),ubiq)
APP_LOAD_PARAMS += --path "44'/108'"
DEFINES += CHAINID_UPCASE=\"UBIQ\" CHAINID_COINNAME=\"UBQ\" CHAIN_KIND=CHAIN_KIND_UBIQ CHAIN_ID=8
APPNAME = "Ubiq"
else ifeq ($(CHAIN),akroma)
APP_LOAD_PARAMS += --path "44'/200625'"
DEFINES += CHAINID_UPCASE=\"AKA\" CHAINID_COINNAME=\"AKA\" CHAIN_KIND=CHAIN_KIND_AKROMA CHAIN_ID=200625
APPNAME = "Akroma"
else ifeq ($(CHAIN),wanchain)
APP_LOAD_PARAMS += --path "44'/5718350'"
DEFINES += CHAINID_UPCASE=\"WAN\" CHAINID_COINNAME=\"WAN\" CHAIN_KIND=CHAIN_KIND_WANCHAIN CHAIN_ID=1
APPNAME = "Wanchain"
else ifeq ($(CHAIN),kusd)
APP_LOAD_PARAMS += --path "44'/91927009'"
DEFINES += CHAINID_UPCASE=\"KUSD\" CHAINID_COINNAME=\"KUSD\" CHAIN_KIND=CHAIN_KIND_KUSD CHAIN_ID=1
APPNAME = "kUSD"
else ifeq ($(CHAIN),musicoin)
APP_LOAD_PARAMS += --path "44'/184'"
DEFINES += CHAINID_UPCASE=\"MUSICOIN\" CHAINID_COINNAME=\"MUSIC\" CHAIN_KIND=CHAIN_KIND_MUSICOIN CHAIN_ID=7762959
APPNAME = "Musicoin"
else ifeq ($(CHAIN),callisto)
APP_LOAD_PARAMS += --path "44'/820'"
DEFINES += CHAINID_UPCASE=\"CALLISTO\" CHAINID_COINNAME=\"CLO\" CHAIN_KIND=CHAIN_KIND_CALLISTO CHAIN_ID=820
APPNAME = "Callisto"
else ifeq ($(CHAIN),ethergem)
APP_LOAD_PARAMS += --path "44'/1987'"
DEFINES += CHAINID_UPCASE=\"ETHERGEM\" CHAINID_COINNAME=\"EGEM\" CHAIN_KIND=CHAIN_KIND_ETHERGEM CHAIN_ID=1987
APPNAME = "EtherGem"
else ifeq ($(CHAIN),atheios)
APP_LOAD_PARAMS += --path "44'/1620'"
DEFINES += CHAINID_UPCASE=\"ATHEIOS\" CHAINID_COINNAME=\"ATH\" CHAIN_KIND=CHAIN_KIND_ATHEIOS CHAIN_ID=1620
APPNAME = "Atheios"
else ifeq ($(CHAIN),gochain)
APP_LOAD_PARAMS += --path "44'/6060'"
DEFINES += CHAINID_UPCASE=\"GOCHAIN\" CHAINID_COINNAME=\"GO\" CHAIN_KIND=CHAIN_KIND_GOCHAIN CHAIN_ID=60
APPNAME = "GoChain"
else ifeq ($(CHAIN),mix)
APP_LOAD_PARAMS += --path "44'/76'"
DEFINES += CHAINID_UPCASE=\"MIX\" CHAINID_COINNAME=\"MIX\" CHAIN_KIND=CHAIN_KIND_MIX CHAIN_ID=76
APPNAME = "Mix"
else ifeq ($(CHAIN),reosc)
APP_LOAD_PARAMS += --path "44'/2894'"
DEFINES += CHAINID_UPCASE=\"REOSC\" CHAINID_COINNAME=\"REOSC\" CHAIN_KIND=CHAIN_KIND_REOSC CHAIN_ID=2894
APPNAME = "REOSC"
else ifeq ($(CHAIN),hpb)
APP_LOAD_PARAMS += --path "44'/269'"
DEFINES += CHAINID_UPCASE=\"HPB\" CHAINID_COINNAME=\"HPB\" CHAIN_KIND=CHAIN_KIND_HPB CHAIN_ID=269
APPNAME = "HPB"
else ifeq ($(CHAIN),tomochain)
APP_LOAD_PARAMS += --path "44'/889'"
DEFINES += CHAINID_UPCASE=\"TOMOCHAIN\" CHAINID_COINNAME=\"TOMO\" CHAIN_KIND=CHAIN_KIND_TOMOCHAIN CHAIN_ID=88
APPNAME = "TomoChain"
else ifeq ($(CHAIN),moonriver)
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
DEFINES += CHAINID_UPCASE=\"MOONRIVER\" CHAINID_COINNAME=\"MOVR\" CHAIN_KIND=CHAIN_KIND_MOONRIVER CHAIN_ID=1285
APPNAME = "Moonriver"
else ifeq ($(CHAIN),tobalaba)
APP_LOAD_PARAMS += --path "44'/401697'"
DEFINES += CHAINID_UPCASE=\"TOBALABA\" CHAINID_COINNAME=\"TOBALABA\" CHAIN_KIND=CHAIN_KIND_TOBALABA CHAIN_ID=401697
APPNAME = "Tobalaba"
else ifeq ($(CHAIN),webchain)
APP_LOAD_PARAMS += --path "44'/227'"
DEFINES += CHAINID_UPCASE=\"WEBCHAIN\" CHAINID_COINNAME=\"WEB\" CHAIN_KIND=CHAIN_KIND_WEBCHAIN CHAIN_ID=24484
APPNAME = "Webchain"
else ifeq ($(CHAIN),dexon)
APP_LOAD_PARAMS += --path "44'/237'"
DEFINES += CHAINID_UPCASE=\"DEXON\" CHAINID_COINNAME=\"DXN\" CHAIN_KIND=CHAIN_KIND_DEXON CHAIN_ID=237
APPNAME = "DEXON"
else ifeq ($(CHAIN),volta)
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"VOLTA\" CHAINID_COINNAME=\"VOLTA\" CHAIN_KIND=CHAIN_KIND_VOLTA CHAIN_ID=73799
APPNAME = "Volta"
else ifeq ($(CHAIN),ewc)
APP_LOAD_PARAMS += --path "44'/246'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"EWC\" CHAINID_COINNAME=\"EWC\" CHAIN_KIND=CHAIN_KIND_EWC CHAIN_ID=246
APPNAME = "EnergyWebChain"
else ifeq ($(CHAIN),thundercore)
APP_LOAD_PARAMS += --path "44'/1001'"
DEFINES += CHAINID_UPCASE=\"THUNDERCORE\" CHAINID_COINNAME=\"TT\" CHAIN_KIND=CHAIN_KIND_THUNDERCORE CHAIN_ID=108
APPNAME = "ThunderCore"
else ifeq ($(CHAIN),flare)
SUPPORTED_CHAINS=$(shell find makefile_conf/chain/ -type f -name '*.mk'| sed 's/.*\/\(.*\).mk/\1/g' | sort)
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"FLARE\" CHAINID_COINNAME=\"FLR\" CHAIN_KIND=CHAIN_KIND_FLARE CHAIN_ID=14
# Pending review parameters
APP_LOAD_PARAMS += --tlvraw 9F:01
DEFINES += HAVE_PENDING_REVIEW_SCREEN
APPNAME = "Flare"
else ifeq ($(CHAIN),flare_coston)
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"FLARE\" CHAINID_COINNAME=\"FLR\" CHAIN_KIND=CHAIN_KIND_FLARE CHAIN_ID=16
APPNAME = "Flare Coston"
else ifeq ($(CHAIN),bsc)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"BSC\" CHAINID_COINNAME=\"BNB\" CHAIN_KIND=CHAIN_KIND_BSC CHAIN_ID=56
APPNAME = "Binance Smart Chain"
else ifeq ($(CHAIN),songbird)
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"SONGBIRD\" CHAINID_COINNAME=\"SGB\" CHAIN_KIND=CHAIN_KIND_SONGBIRD CHAIN_ID=19
APPNAME = "Songbird"
else ifeq ($(CHAIN),polygon)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"POLYGON\" CHAINID_COINNAME=\"MATIC\" CHAIN_KIND=CHAIN_KIND_POLYGON CHAIN_ID=137
APPNAME = "Polygon"
else ifeq ($(CHAIN),shyft)
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"SHYFT\" CHAINID_COINNAME=\"SHFT\" CHAIN_KIND=CHAIN_KIND_SHYFT CHAIN_ID=7341
APPNAME = "Shyft"
# Check if chain is available
ifeq ($(shell test -s ./makefile_conf/chain/$(CHAIN).mk && echo -n yes), yes)
include ./makefile_conf/chain/$(CHAIN).mk
else
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error Unsupported CHAIN - use ethereum, ropsten, goerli, moonriver, ethereum_classic, expanse, poa, artis_sigma1, artis_tau1, rsk, rsk_testnet, ubiq, wanchain, kusd, musicoin, pirl, akroma, atheios, callisto, ethersocial, ellaism, ether1, ethergem, gochain, mix, reosc, hpb, tomochain, tobalaba, dexon, volta, ewc, webchain, thundercore, bsc, songbird, polygon, shyft)
endif
$(error Unsupported CHAIN - use $(SUPPORTED_CHAINS))
endif
#########
# Other #
#########
APP_LOAD_PARAMS += $(APP_LOAD_FLAGS) --path "44'/1'"
DEFINES += $(DEFINES_LIB)
@@ -322,7 +137,6 @@ DEFINES += HAVE_NFT_TESTING_KEY
endif
endif
# Enabling debug PRINTF
DEBUG:=0
ifneq ($(DEBUG),0)
@@ -388,9 +202,8 @@ $(info INFO: Need to reinitialize git submodules)
$(shell git submodule update --init)
endif
# rebuild
$(shell python3 ethereum-plugin-sdk/build_sdk.py)
$(shell find ./ethereum-plugin-sdk -iname '*.h' -o -iname '*.c' | xargs clang-format-10 -i)
# rebuild SDK
$(shell python3 tools/build_sdk.py)
# check if a difference is noticed (fail if it happens in CI build)
ifneq ($(shell git status | grep 'ethereum-plugin-sdk'),)
@@ -423,4 +236,4 @@ include $(BOLOS_SDK)/Makefile.rules
dep/%.d: %.c Makefile
listvariants:
@echo VARIANTS CHAIN ethereum ropsten goerli moonriver ethereum_classic expanse poa rsk rsk_testnet ubiq wanchain pirl akroma atheios callisto ethersocial ether1 gochain musicoin ethergem mix ellaism reosc hpb tomochain dexon volta ewc thundercore bsc songbird polygon shyft
@echo VARIANTS CHAIN $(SUPPORTED_CHAINS)

151
README.md
View File

@@ -1,47 +1,119 @@
# app-ethereum
Ethereum wallet application framework for Nano S and Nano X.
Ledger Blue is not maintained anymore, but the app can still be compiled for this target using the branch `blue-final-release`.
<br />
<div align="center">
<a href="https://github.com/LedgerHQ/app-ethereum">
<img src="https://img.icons8.com/nolan/64/ethereum.png"/>
</a>
<h1 align="center">app-ethereum</h1>
<p align="center">
Ethereum wallet application for Ledger Blue, Nano S and Nano X
<br />
<a href="https://github.com/LedgerHQ/app-ethereum/tree/master/doc"><strong>« Explore the docs »</strong></a>
<br />
<br />
<a href="https://github.com/LedgerHQ/app-ethereum/issues">Report Bug</a>
· <a href="https://github.com/LedgerHQ/app-ethereum/issues">Request Feature</a>
· <a href="https://github.com/LedgerHQ/app-ethereum/issues">Request New Network</a>
</p>
</div>
<br/>
<details>
<summary>Table of Contents</summary>
- [About the project](#about-the-project)
- [Documentation](#documentation)
- [Plugins](#plugins)
- [Testing](#testing)
- [Requirements](#requirements)
- [Build the applications required by the test suite](#build-the-applications-required-by-the-test-suite)
- [Running all tests](#running-all-tests)
- [With Makefile](#with-makefile)
- [With yarn](#with-yarn)
- [Running a specific tests](#running-a-specific-tests)
- [Adding tests](#adding-tests)
- [Zemu](#zemu)
- [Update binaries](#update-binaries)
- [Contributing](#contributing)
</details>
## About the project
Ethereum wallet application framework for Nano S and Nano X.
Ledger Blue is not maintained anymore, but the app can still be compiled for this target using the branch [`blue-final-release`](https://github.com/LedgerHQ/app-ethereum/tree/blue-final-release).
## Documentation
This app follows the specification available in the `doc/` folder.
To compile it and load it on a device, please check out our [developer portal](https://developers.ledger.com/docs/nano-app/introduction/).
# Plugins
### Plugins
This app support external plugins. More info in [doc/ethapp_plugin.asc](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc). If you wish to have a look at an existing plugin, feel free to check out the [Boilerplate plugin](https://github.com/LedgerHQ/app-plugin-boilerplate).
We have the concept of plugins in the ETH app.
Find the documentations here:
- [Blog Ethereum plugins](https://blog.ledger.com/ethereum-plugins/)
- [Ethereum application Plugins : Technical Specifications](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc)
- [Plugin guide](https://hackmd.io/300Ukv5gSbCbVcp3cZuwRQ)
- [Boilerplate plugin](https://github.com/LedgerHQ/app-plugin-boilerplate)
# Testing
## Testing
Testing is done via the open-source framework [zemu](https://github.com/Zondax/zemu).
## Running tests
### Requirements
First [install yarn](https://classic.yarnpkg.com/en/docs/install/#debian-stable).
Open `tests/build_local_test_elfs.sh` and add your BOLOS SDKs path to `NANOS_SDK` and `NANOX_SDK`.
This helper script will build the applications required by the test suite and move them at the right place.
```
cd tests
./build_local_test_elfs.sh
```
Then you can install the project by simply running:
```
cd ..
make test
```
This will run `make install_tests` and `make run_tests`
- [nodeJS == 16](https://github.com/nvm-sh/nvm)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
- [build environnement](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
To run a specific tests (here the send test):
```
cd tests
jest --runInBand --detectOpenHandles src/send.test.js
```
#### Build the applications required by the test suite
Make sure you're in the `tests` folder before running `jest` or `yarn test`.
1. Add your BOLOS SDKs path to:
- `NANOS_SDK` and `NANOX_SDK`
2. Go to the `tests` folder and run `./build_local_test_elfs.sh`
- ```sh
cd tests
# This helper script will build the applications required by the test suite and move them at the right place.
yarn install
./build_local_test_elfs.sh
```
### Running all tests
#### With Makefile
1. Then you can install and run tests by simply running on the `root` of the repo:
- ```sh
make test
```
- This will run `make install_tests` and `make run_tests`
#### With yarn
1. Go to the `tests` folder and run:
- ```sh
yarn test
```
### Running a specific tests
1. Go to the `tests` folder and run:
- ```sh
yarn jest --runInBand --detectOpenHandles {YourTestFile}
```
2. For example with the `send test`:
- ```sh
yarn jest --runInBand --detectOpenHandles src/send.test.js
```
## Adding tests
### Adding tests
### Zemu
#### Zemu
To add tests, copy one of the already existing test files in `tests/src/`.
You then need to adapt the `buffer` and `tx` variables to adapt to the APDU you wish to send.
@@ -54,16 +126,33 @@ You then need to adapt the `buffer` and `tx` variables to adapt to the APDU you
Finally make sure you adapt the expected signature!
### Update binaries
#### Update binaries
Don't forget to update the binaries in the test folder. To do so, compile with those environement variables:
```
```sh
make DEBUG=1 ALLOW_DATA=1
```
Then copy the binary to the `tests/elfs` folder (in this case, compiled with SDK for nanoS):
```
```sh
cp bin/app.elf tests/elfs/ethereum_nanos.elf
```
Repeat the operation for a binary compiled with nanoX SDK and change for `ethereum_nanox.elf`.
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag `enhancement`.
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/my-feature`)
3. Commit your Changes (`git commit -m 'feat: my new feature`)
4. Push to the Branch (`git push origin feature/my-feature`)
5. Open a Pull Request
Please try to follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).

View File

@@ -1,7 +1,7 @@
Ethereum application : Common Technical Specifications
=======================================================
Ledger Firmware Team <hello@ledger.fr>
Application version 1.5.0 - 25th of September 2020
Application version 1.9.18 - 29th of January 2022
## 1.0
- Initial release
@@ -26,6 +26,9 @@ Application version 1.5.0 - 25th of September 2020
## 1.9.13
- Add SET PLUGIN
## 1.9.17
- Add PERFORM PRIVACY OPERATION
## About
This application describes the APDU messages interface to communicate with the Ethereum application.
@@ -251,9 +254,9 @@ This commands provides a trusted description of an NFT to associate a contract a
It shall be run immediately before performing a transaction involving a contract calling this contract address to display the proper nft information to the user if necessary, as marked in GET APP CONFIGURATION flags.
The signature is computed on
The signature is computed on:
type || version || len(collectionName) || collectionName || address || chainId || keyId || algorithmId || len(signature) || signature
type || version || len(collectionName) || collectionName || address || chainId || keyId || algorithmId
#### Coding
@@ -379,6 +382,52 @@ type || version || len(pluginName) || pluginName || address || selector || chain
None
### PERFORM PRIVACY OPERATION
#### Description
This command performs privacy operations as defined in EIP 1024 (https://ethereum-magicians.org/t/eip-1024-cross-client-encrypt-decrypt/505)
It can return the public encryption key on Curve25519 for a given Ethereum account or the shared secret (generated by the scalar multiplication of the remote public key by the account private key on Curve25519) used to decrypt private data encrypted for a given Ethereum account
All data can be optionally checked on the device before being returned.
#### Coding
'Command'
[width="80%"]
|==============================================================================================================================
| *CLA* | *INS* | *P1* | *P2* | *Lc* | *Le*
| E0 | 18 | 00 : return data
01 : display data and confirm before returning
| 00 : return the public encryption key
01 : return the shared secret | variable | variable
|==============================================================================================================================
'Input data'
[width="80%"]
|==============================================================================================================================
| *Description* | *Length*
| Number of BIP 32 derivations to perform (max 10) | 1
| First derivation index (big endian) | 4
| ... | 4
| Last derivation index (big endian) | 4
| Third party public key on Curve25519, if returning the shared secret | 32
|==============================================================================================================================
'Output data'
[width="80%"]
|==============================================================================================================================
| *Description* | *Length*
| Public encryption key or shared secret | 32
|==============================================================================================================================
### GET APP CONFIGURATION
#### Description

BIN
icons/nanos_app_bttc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

BIN
icons/nanos_app_wethio.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
icons/nanox_app_bttc.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 B

BIN
icons/nanox_app_wethio.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/200625'"
DEFINES += CHAINID_UPCASE=\"AKA\" CHAINID_COINNAME=\"AKA\" CHAIN_KIND=CHAIN_KIND_AKROMA CHAIN_ID=200625
APPNAME = "Akroma"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/246529'"
DEFINES += CHAINID_UPCASE=\"ARTISSIGMA1\" CHAINID_COINNAME=\"ATS\" CHAIN_KIND=CHAIN_KIND_ARTIS_SIGMA1 CHAIN_ID=246529
APPNAME = "ARTIS sigma1"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/246785'"
DEFINES += CHAINID_UPCASE=\"ARTISTAU1\" CHAINID_COINNAME=\"ATS\" CHAIN_KIND=CHAIN_KIND_ARTIS_TAU1 CHAIN_ID=246785
APPNAME = "ARTIS tau1"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/1620'"
DEFINES += CHAINID_UPCASE=\"ATHEIOS\" CHAINID_COINNAME=\"ATH\" CHAIN_KIND=CHAIN_KIND_ATHEIOS CHAIN_ID=1620
APPNAME = "Atheios"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"BSC\" CHAINID_COINNAME=\"BNB\" CHAIN_KIND=CHAIN_KIND_BSC CHAIN_ID=56
APPNAME = "Binance Smart Chain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"BTTC\" CHAINID_COINNAME=\"BTT\" CHAIN_KIND=CHAIN_KIND_BTTC CHAIN_ID=199
APPNAME = "BTTC"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/820'"
DEFINES += CHAINID_UPCASE=\"CALLISTO\" CHAINID_COINNAME=\"CLO\" CHAIN_KIND=CHAIN_KIND_CALLISTO CHAIN_ID=820
APPNAME = "Callisto"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"CONFLUX\" CHAINID_COINNAME=\"CFX\" CHAIN_KIND=CHAIN_KIND_CONFLUX_ESPACE CHAIN_ID=1030
APPNAME = "Conflux eSpace"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/237'"
DEFINES += CHAINID_UPCASE=\"DEXON\" CHAINID_COINNAME=\"DXN\" CHAIN_KIND=CHAIN_KIND_DEXON CHAIN_ID=237
APPNAME = "DEXON"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/163'"
DEFINES += CHAINID_UPCASE=\"ELLA\" CHAINID_COINNAME=\"ELLA\" CHAIN_KIND=CHAIN_KIND_ELLAISM CHAIN_ID=64
APPNAME = "Ellaism"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/1313114'"
DEFINES += CHAINID_UPCASE=\"ETHER1\" CHAINID_COINNAME=\"ETHO\" CHAIN_KIND=CHAIN_KIND_ETHER1 CHAIN_ID=1313114
APPNAME = "Ether-1"

View File

@@ -0,0 +1,13 @@
# Lock the application on its standard path for 1.5. Please complain if non compliant
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=1
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Ethereum"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40

View File

@@ -0,0 +1,4 @@
# Also allows ETC to access the ETH derivation path to recover forked assets
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETC\" CHAINID_COINNAME=\"ETC\" CHAIN_KIND=CHAIN_KIND_ETHEREUM_CLASSIC CHAIN_ID=61
APPNAME = "Ethereum Classic"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/1987'"
DEFINES += CHAINID_UPCASE=\"ETHERGEM\" CHAINID_COINNAME=\"EGEM\" CHAIN_KIND=CHAIN_KIND_ETHERGEM CHAIN_ID=1987
APPNAME = "EtherGem"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/31102'"
DEFINES += CHAINID_UPCASE=\"ETHERSOCIAL\" CHAINID_COINNAME=\"ESN\" CHAIN_KIND=CHAIN_KIND_ETHERSOCIAL CHAIN_ID=31102
APPNAME = "Ethersocial"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/246'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"EWC\" CHAINID_COINNAME=\"EWC\" CHAIN_KIND=CHAIN_KIND_EWC CHAIN_ID=246
APPNAME = "EnergyWebChain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/40'"
DEFINES += CHAINID_UPCASE=\"EXPANSE\" CHAINID_COINNAME=\"EXP\" CHAIN_KIND=CHAIN_KIND_EXPANSE CHAIN_ID=2
APPNAME = "Expanse"

View File

@@ -0,0 +1,8 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"FLARE\" CHAINID_COINNAME=\"FLR\" CHAIN_KIND=CHAIN_KIND_FLARE CHAIN_ID=14
# Pending review parameters
APP_LOAD_PARAMS += --tlvraw 9F:01
DEFINES += HAVE_PENDING_REVIEW_SCREEN
APPNAME = "Flare"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"FLARE\" CHAINID_COINNAME=\"FLR\" CHAIN_KIND=CHAIN_KIND_FLARE CHAIN_ID=16
APPNAME = "Flare Coston"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/6060'"
DEFINES += CHAINID_UPCASE=\"GOCHAIN\" CHAINID_COINNAME=\"GO\" CHAIN_KIND=CHAIN_KIND_GOCHAIN CHAIN_ID=60
APPNAME = "GoChain"

View File

@@ -0,0 +1,14 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=5
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
# Keep for Starkware Goerli tests
DEFINES += HAVE_TOKENS_EXTRA_LIST
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Eth Goerli"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/269'"
DEFINES += CHAINID_UPCASE=\"HPB\" CHAINID_COINNAME=\"HPB\" CHAIN_KIND=CHAIN_KIND_HPB CHAIN_ID=269
APPNAME = "HPB"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"KARDIACHAIN\" CHAINID_COINNAME=\"KAI\" CHAIN_KIND=CHAIN_KIND_KARDIACHAIN CHAIN_ID=24
APPNAME = "KardiaChain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/91927009'"
DEFINES += CHAINID_UPCASE=\"KUSD\" CHAINID_COINNAME=\"KUSD\" CHAIN_KIND=CHAIN_KIND_KUSD CHAIN_ID=1
APPNAME = "kUSD"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/76'"
DEFINES += CHAINID_UPCASE=\"MIX\" CHAINID_COINNAME=\"MIX\" CHAIN_KIND=CHAIN_KIND_MIX CHAIN_ID=76
APPNAME = "Mix"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'"
DEFINES += CHAINID_UPCASE=\"MOONBEAM\" CHAINID_COINNAME=\"GLMR\" CHAIN_KIND=CHAIN_KIND_MOONBEAM CHAIN_ID=1284
APPNAME = "Moonbeam"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
DEFINES += CHAINID_UPCASE=\"MOONRIVER\" CHAINID_COINNAME=\"MOVR\" CHAIN_KIND=CHAIN_KIND_MOONRIVER CHAIN_ID=1285
APPNAME = "Moonriver"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/184'"
DEFINES += CHAINID_UPCASE=\"MUSICOIN\" CHAINID_COINNAME=\"MUSIC\" CHAIN_KIND=CHAIN_KIND_MUSICOIN CHAIN_ID=7762959
APPNAME = "Musicoin"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/164'"
DEFINES += CHAINID_UPCASE=\"PIRL\" CHAINID_COINNAME=\"PIRL\" CHAIN_KIND=CHAIN_KIND_PIRL CHAIN_ID=3125659152
APPNAME = "Pirl"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"POA\" CHAINID_COINNAME=\"POA\" CHAIN_KIND=CHAIN_KIND_POA CHAIN_ID=99
APPNAME = "POA"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"POLYGON\" CHAINID_COINNAME=\"MATIC\" CHAIN_KIND=CHAIN_KIND_POLYGON CHAIN_ID=137
APPNAME = "Polygon"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/2894'"
DEFINES += CHAINID_UPCASE=\"REOSC\" CHAINID_COINNAME=\"REOSC\" CHAIN_KIND=CHAIN_KIND_REOSC CHAIN_ID=2894
APPNAME = "REOSC"

View File

@@ -0,0 +1,14 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"ETHEREUM\" CHAINID_COINNAME=\"ETH\" CHAIN_KIND=CHAIN_KIND_ETHEREUM CHAIN_ID=3
# Starkware integration
APP_LOAD_PARAMS += --path "2645'/579218131'"
DEFINES += HAVE_STARKWARE
# Keep for Starkware Ropsten tests
DEFINES += HAVE_TOKENS_EXTRA_LIST
DEFINES += STARK_BIP32_PATH_0=0x80000A55 STARK_BIP32_PATH_1=0xA2862AD3
# Allow to derive ETH 2 public keys
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
DEFINES += HAVE_ETH2
APPNAME = "Eth Ropsten"
DEFINES_LIB=
APP_LOAD_FLAGS=--appFlags 0xa40

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
DEFINES += CHAINID_UPCASE=\"RSK\" CHAINID_COINNAME=\"RBTC\" CHAIN_KIND=CHAIN_KIND_RSK CHAIN_ID=30
APPNAME = "RSK"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/37310'"
DEFINES += CHAINID_UPCASE=\"RSKTESTNET\" CHAINID_COINNAME=\"RBTC\" CHAIN_KIND=CHAIN_KIND_RSK CHAIN_ID=31
APPNAME = "RSK Test"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"SHYFT\" CHAINID_COINNAME=\"SHFT\" CHAIN_KIND=CHAIN_KIND_SHYFT CHAIN_ID=7341
APPNAME = "Shyft"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"SONGBIRD\" CHAINID_COINNAME=\"SGB\" CHAIN_KIND=CHAIN_KIND_SONGBIRD CHAIN_ID=19
APPNAME = "Songbird"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/1001'"
DEFINES += CHAINID_UPCASE=\"THUNDERCORE\" CHAINID_COINNAME=\"TT\" CHAIN_KIND=CHAIN_KIND_THUNDERCORE CHAIN_ID=108
APPNAME = "ThunderCore"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/401697'"
DEFINES += CHAINID_UPCASE=\"TOBALABA\" CHAINID_COINNAME=\"TOBALABA\" CHAIN_KIND=CHAIN_KIND_TOBALABA CHAIN_ID=401697
APPNAME = "Tobalaba"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/889'"
DEFINES += CHAINID_UPCASE=\"TOMOCHAIN\" CHAINID_COINNAME=\"TOMO\" CHAIN_KIND=CHAIN_KIND_TOMOCHAIN CHAIN_ID=88
APPNAME = "TomoChain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/108'"
DEFINES += CHAINID_UPCASE=\"UBIQ\" CHAINID_COINNAME=\"UBQ\" CHAIN_KIND=CHAIN_KIND_UBIQ CHAIN_ID=8
APPNAME = "Ubiq"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
DEFINES += CHAINID_UPCASE=\"VOLTA\" CHAINID_COINNAME=\"VOLTA\" CHAIN_KIND=CHAIN_KIND_VOLTA CHAIN_ID=73799
APPNAME = "Volta"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/5718350'"
DEFINES += CHAINID_UPCASE=\"WAN\" CHAINID_COINNAME=\"WAN\" CHAIN_KIND=CHAIN_KIND_WANCHAIN CHAIN_ID=1
APPNAME = "Wanchain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/227'"
DEFINES += CHAINID_UPCASE=\"WEBCHAIN\" CHAINID_COINNAME=\"WEB\" CHAIN_KIND=CHAIN_KIND_WEBCHAIN CHAIN_ID=24484
APPNAME = "Webchain"

View File

@@ -0,0 +1,3 @@
APP_LOAD_PARAMS += --path "44'/77777'"
DEFINES += CHAINID_UPCASE=\"WETHIO\" CHAINID_COINNAME=\"ZYN\" CHAIN_KIND=CHAIN_KIND_WETHIO CHAIN_ID=78
APPNAME = "Wethio"

View File

@@ -1,3 +1,6 @@
#ifndef _APDU_CONSTANTS_H_
#define _APDU_CONSTANTS_H_
#include "shared_context.h"
#define APP_FLAG_DATA_ALLOWED 0x01
@@ -17,6 +20,7 @@
#define INS_SET_EXTERNAL_PLUGIN 0x12
#define INS_PROVIDE_NFT_INFORMATION 0x14
#define INS_SET_PLUGIN 0x16
#define INS_PERFORM_PRIVACY_OPERATION 0x18
#define P1_CONFIRM 0x01
#define P1_NON_CONFIRM 0x00
#define P2_NO_CHAINCODE 0x00
@@ -111,6 +115,13 @@ void handleSetPlugin(uint8_t p1,
unsigned int *flags,
unsigned int *tx);
void handlePerformPrivacyOperation(uint8_t p1,
uint8_t p2,
uint8_t *workBuffer,
uint16_t dataLength,
unsigned int *flags,
unsigned int *tx);
#ifdef HAVE_ETH2
void handleGetEth2PublicKey(uint8_t p1,
@@ -156,3 +167,5 @@ void handleStarkwareUnsafeSign(uint8_t p1,
unsigned int *tx);
#endif
#endif // _APDU_CONSTANTS_H_

View File

@@ -58,7 +58,12 @@ typedef enum chain_kind_e {
CHAIN_KIND_BSC,
CHAIN_KIND_SONGBIRD,
CHAIN_KIND_POLYGON,
CHAIN_KIND_SHYFT
CHAIN_KIND_SHYFT,
CHAIN_KIND_CONFLUX_ESPACE,
CHAIN_KIND_MOONBEAM,
CHAIN_KIND_BTTC,
CHAIN_KIND_KARDIACHAIN,
CHAIN_KIND_WETHIO
} chain_kind_t;
typedef struct chain_config_s {
@@ -69,4 +74,4 @@ typedef struct chain_config_s {
#define ETHEREUM_MAINNET_CHAINID 1
#endif /* _CHAIN_CONFIG_H_ */
#endif // _CHAIN_CONFIG_H_

View File

@@ -3,6 +3,7 @@
#include "eth_plugin_internal.h"
#include "shared_context.h"
#include "network.h"
#include "ethUtils.h"
void eth_plugin_prepare_init(ethPluginInitContract_t *init, uint8_t *selector, uint32_t dataSize) {
memset((uint8_t *) init, 0, sizeof(ethPluginInitContract_t));
@@ -47,14 +48,14 @@ void eth_plugin_prepare_query_contract_UI(ethQueryContractUI_t *queryContractUI,
memset((uint8_t *) queryContractUI, 0, sizeof(ethQueryContractUI_t));
// If no extra information was found, set the pointer to NULL
if (allzeroes(&tmpCtx.transactionContext.extraInfo[1], sizeof(union extraInfo_t))) {
if (NO_EXTRA_INFO(tmpCtx, 1)) {
queryContractUI->item1 = NULL;
} else {
queryContractUI->item1 = &tmpCtx.transactionContext.extraInfo[1];
}
// If no extra information was found, set the pointer to NULL
if (allzeroes(&tmpCtx.transactionContext.extraInfo[0], sizeof(union extraInfo_t))) {
if (NO_EXTRA_INFO(tmpCtx, 0)) {
queryContractUI->item2 = NULL;
} else {
queryContractUI->item2 = &tmpCtx.transactionContext.extraInfo[0];
@@ -110,7 +111,7 @@ static bool eth_plugin_perform_init_old_internal(uint8_t *contractAddress,
j++) {
if (memcmp(init->selector, (const void *) PIC(selectors[j]), SELECTOR_SIZE) == 0) {
if ((INTERNAL_ETH_PLUGINS[i].availableCheck == NULL) ||
((PluginAvailableCheck) PIC(INTERNAL_ETH_PLUGINS[i].availableCheck))()) {
((PluginAvailableCheck) PIC(INTERNAL_ETH_PLUGINS[i].availableCheck)) ()) {
strlcpy(dataContext.tokenContext.pluginName,
INTERNAL_ETH_PLUGINS[i].alias,
PLUGIN_ID_LENGTH);

View File

@@ -1,7 +1,11 @@
#ifndef __ETH_PLUGIN_HANDLER_H__
#ifndef _ETH_PLUGIN_HANDLER_H_
#define _ETH_PLUGIN_HANDLER_H_
#include "eth_plugin_interface.h"
#define NO_EXTRA_INFO(ctx, idx) \
(allzeroes(&(ctx.transactionContext.extraInfo[idx]), sizeof(extraInfo_t)))
void eth_plugin_prepare_init(ethPluginInitContract_t *init, uint8_t *selector, uint32_t dataSize);
void eth_plugin_prepare_provide_parameter(ethPluginProvideParameter_t *provideParameter,
uint8_t *parameter,
@@ -27,4 +31,4 @@ eth_plugin_result_t eth_plugin_call(int method, void *parameter);
void plugin_ui_start(void);
#endif
#endif // _ETH_PLUGIN_HANDLER_H_

View File

@@ -1,6 +1,5 @@
#ifndef __ETH_PLUGIN_INTERFACE_H__
#define __ETH_PLUGIN_INTERFACE_H__
#ifndef _ETH_PLUGIN_INTERFACE_H_
#define _ETH_PLUGIN_INTERFACE_H_
#include "os.h"
#include "cx.h"
@@ -13,7 +12,8 @@ typedef enum {
ETH_PLUGIN_INTERFACE_VERSION_1 = 1,
ETH_PLUGIN_INTERFACE_VERSION_2 = 2,
ETH_PLUGIN_INTERFACE_VERSION_3 = 3,
ETH_PLUGIN_INTERFACE_VERSION_LATEST = 4,
ETH_PLUGIN_INTERFACE_VERSION_4 = 4,
ETH_PLUGIN_INTERFACE_VERSION_LATEST = 5,
} eth_plugin_interface_version_t;
typedef enum {
@@ -76,7 +76,7 @@ typedef struct ethPluginInitContract_t {
ethPluginSharedRO_t *pluginSharedRO;
uint8_t *pluginContext;
size_t pluginContextLength;
uint8_t *selector; // 4 bytes selector
const uint8_t *selector; // 4 bytes selector
size_t dataSize;
char *alias; // 29 bytes alias if ETH_PLUGIN_RESULT_OK_ALIAS set
@@ -89,7 +89,7 @@ typedef struct ethPluginProvideParameter_t {
ethPluginSharedRW_t *pluginSharedRW;
ethPluginSharedRO_t *pluginSharedRO;
uint8_t *pluginContext;
uint8_t *parameter; // 32 bytes parameter
const uint8_t *parameter; // 32 bytes parameter
uint32_t parameterOffset;
uint8_t result;
@@ -106,9 +106,9 @@ typedef struct ethPluginFinalize_t {
uint8_t *tokenLookup1; // set by the plugin if a token should be looked up
uint8_t *tokenLookup2;
uint8_t *amount; // set an uint256 pointer if uiType is UI_AMOUNT_ADDRESS
uint8_t *address; // set to the destination address if uiType is UI_AMOUNT_ADDRESS. Set to the
// user's address if uiType is UI_TYPE_GENERIC
const uint8_t *amount; // set an uint256 pointer if uiType is UI_AMOUNT_ADDRESS
const uint8_t *address; // set to the destination address if uiType is UI_AMOUNT_ADDRESS. Set
// to the user's address if uiType is UI_TYPE_GENERIC
uint8_t uiType;
uint8_t numScreens; // ignored if uiType is UI_AMOUNT_ADDRESS
@@ -179,4 +179,4 @@ typedef struct ethQueryContractUI_t {
} ethQueryContractUI_t;
#endif
#endif // _ETH_PLUGIN_INTERFACE_H_

View File

@@ -1,3 +1,4 @@
#include <string.h>
#include "eth_plugin_internal.h"
bool erc20_plugin_available_check(void);
@@ -5,12 +6,12 @@ bool erc20_plugin_available_check(void);
void erc20_plugin_call(int message, void* parameters);
void compound_plugin_call(int message, void* parameters);
void copy_address(uint8_t* dst, uint8_t* parameter, uint8_t dst_size) {
void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size) {
uint8_t copy_size = MIN(dst_size, ADDRESS_LENGTH);
memmove(dst, parameter + PARAMETER_LENGTH - copy_size, copy_size);
}
void copy_parameter(uint8_t* dst, uint8_t* parameter, uint8_t dst_size) {
void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size) {
uint8_t copy_size = MIN(dst_size, PARAMETER_LENGTH);
memmove(dst, parameter, copy_size);
}

View File

@@ -1,14 +1,17 @@
#ifndef __ETH_PLUGIN_INTERNAL_H__
#ifndef _ETH_PLUGIN_INTERNAL_H_
#define _ETH_PLUGIN_INTERNAL_H_
#include <stdint.h>
#include <stdbool.h>
#include "eth_plugin_interface.h"
#define SELECTOR_SIZE 4
#define PARAMETER_LENGTH 32
#define RUN_APPLICATION 1
void copy_address(uint8_t* dst, uint8_t* parameter, uint8_t dst_size);
void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
void copy_parameter(uint8_t* dst, uint8_t* parameter, uint8_t dst_size);
void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
void erc721_plugin_call(int message, void* parameters);
void erc1155_plugin_call(int message, void* parameters);
@@ -45,4 +48,4 @@ extern const uint8_t* const STARKWARE_SELECTORS[NUM_STARKWARE_SELECTORS];
extern internalEthPlugin_t const INTERNAL_ETH_PLUGINS[];
#endif
#endif // _ETH_PLUGIN_INTERNAL_H_

View File

@@ -6,11 +6,6 @@
#define ZERO(x) memset(&x, 0, sizeof(x))
static int os_strcmp(const char* s1, const char* s2) {
size_t size = strlen(s1) + 1;
return memcmp(s1, s2, size);
}
int handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) {
PRINTF("Params on the address %d\n", (unsigned int) params);
PRINTF("Address to check %s\n", params->address_to_check);
@@ -69,7 +64,7 @@ int handle_check_address(check_address_parameters_t* params, chain_config_t* cha
offset_0x = 2;
}
if (os_strcmp(locals_union1.address, params->address_to_check + offset_0x) != 0) {
if (strcmp(locals_union1.address, params->address_to_check + offset_0x) != 0) {
PRINTF("Addresses don't match\n");
return 0;
}

View File

@@ -15,13 +15,6 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
PRINTF("Amount is too big, 32 bytes max but buffer has %u bytes", params->amount_length);
return 0;
}
if (!parse_swap_config(params->coin_configuration,
params->coin_configuration_length,
ticker,
&decimals)) {
PRINTF("Error while parsing config\n");
return 0;
}
// If the amount is a fee, its value is nominated in ETH even if we're doing an ERC20 swap
if (params->is_fee) {
@@ -30,6 +23,15 @@ int handle_get_printable_amount(get_printable_amount_parameters_t* params, chain
ticker[ticker_len] = ' ';
ticker[ticker_len + 1] = '\0';
decimals = WEI_TO_ETHER;
} else {
// If the amount is *not* a fee, decimals and ticker are built from the given config
if (!parse_swap_config(params->coin_configuration,
params->coin_configuration_length,
ticker,
&decimals)) {
PRINTF("Error while parsing config\n");
return 0;
}
}
amountToString(params->amount,

View File

@@ -1,6 +1,6 @@
#include "handle_swap_sign_transaction.h"
#include "usbd_core.h"
#include "os_io_seproxyhal.h"
#include "ux.h"
#include "handle_swap_sign_transaction.h"
#include "shared_context.h"
#include "utils.h"
@@ -79,4 +79,4 @@ void handle_swap_sign_transaction(chain_config_t* config) {
BLE_power(1, "Nano X");
#endif // HAVE_BLE
app_main();
}
}

View File

@@ -269,6 +269,21 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) {
case CHAIN_KIND_SHYFT:
numTokens = NUM_TOKENS_SHYFT;
break;
case CHAIN_KIND_CONFLUX_ESPACE:
numTokens = NUM_TOKENS_CONFLUX_ESPACE;
break;
case CHAIN_KIND_MOONBEAM:
numTokens = NUM_TOKENS_MOONBEAM;
break;
case CHAIN_KIND_KARDIACHAIN:
numTokens = NUM_TOKENS_KARDIACHAIN;
break;
case CHAIN_KIND_BTTC:
numTokens = NUM_TOKENS_BTTC;
break;
case CHAIN_KIND_WETHIO:
numTokens = NUM_TOKENS_WETHIO;
break;
}
for (i = 0; i < numTokens; i++) {
switch (chainConfig->kind) {
@@ -380,13 +395,29 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) {
case CHAIN_KIND_SHYFT:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_SHYFT[i]);
break;
case CHAIN_KIND_CONFLUX_ESPACE:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_CONFLUX_ESPACE[i]);
break;
case CHAIN_KIND_MOONBEAM:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_MOONBEAM[i]);
break;
case CHAIN_KIND_BTTC:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_BTTC[i]);
break;
case CHAIN_KIND_KARDIACHAIN:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_KARDIACHAIN[i]);
break;
case CHAIN_KIND_WETHIO:
currentToken = (tokenDefinition_t *) PIC(&TOKENS_WETHIO[i]);
break;
}
if (memcmp(currentToken->address, tmpContent.txContent.destination, ADDRESS_LENGTH) == 0) {
return currentToken;
}
}
#endif
//
// Works for ERC-20 & NFT tokens since both structs in the union have the
// contract address aligned
for (uint8_t i = 0; i < MAX_ITEMS; i++) {
currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token;
if (tmpCtx.transactionContext.tokenSet[i] &&
@@ -396,15 +427,6 @@ extraInfo_t *getKnownToken(uint8_t *contractAddress) {
}
}
for (uint8_t i = 0; i < MAX_ITEMS; i++) {
currentItem = (union extraInfo_t *) &tmpCtx.transactionContext.extraInfo[i].token;
if (tmpCtx.transactionContext.tokenSet[i] &&
(memcmp(currentItem->nft.contractAddress, contractAddress, ADDRESS_LENGTH) == 0)) {
PRINTF("Token found at index %d\n", i);
return currentItem;
}
}
return NULL;
}
@@ -548,6 +570,15 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
tx);
break;
case INS_PERFORM_PRIVACY_OPERATION:
handlePerformPrivacyOperation(G_io_apdu_buffer[OFFSET_P1],
G_io_apdu_buffer[OFFSET_P2],
G_io_apdu_buffer + OFFSET_CDATA,
G_io_apdu_buffer[OFFSET_LC],
flags,
tx);
break;
case INS_SIGN:
handleSign(G_io_apdu_buffer[OFFSET_P1],
G_io_apdu_buffer[OFFSET_P2],

View File

@@ -1,14 +1,14 @@
#include "tokens.h"
#ifndef _NFT_H_
#define _NFT_H_
// An `nftInfo_t` must be the same size as a `tokenDefinition_t`. This is because both will be held
// in a `extraInfo_t` which is a union of a `nftInfo_t` and a `tokenDefinition_t`. By having both
// struct the same size, we know they will be aligned, which facilitates accessing the items.
#include <stdint.h>
// We defined the collection name max length to be the size of a `tokenDefinition_t` and remove the
// `ADDRESS_LENGTH` which corresponds to `sizeof(contractAddress`).
#define COLLECTION_NAME_MAX_LEN sizeof(tokenDefinition_t) - ADDRESS_LENGTH
#define COLLECTION_NAME_MAX_LEN 70
#define NO_NFT_METADATA (NO_EXTRA_INFO(tmpCtx, 1))
typedef struct nftInfo_t {
char collectionName[COLLECTION_NAME_MAX_LEN];
char contractAddress[ADDRESS_LENGTH];
} nftInfo_t;
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
} nftInfo_t;
#endif // _NFT_H_

View File

@@ -1,5 +1,5 @@
#ifndef __POORSTREAM_H__
#define __POORSTREAM_H__
#ifndef _POORSTREAM_H_
#define _POORSTREAM_H_
#include <stdbool.h>
#include <stdint.h>
@@ -18,4 +18,4 @@ void poorstream_init(poorstream_t *stream, uint8_t *buffer);
void poorstream_flush(poorstream_t *stream);
void poorstream_write_bits(poorstream_t *stream, uint64_t bits, uint32_t num_bits);
#endif
#endif // _POORSTREAM_H_

View File

@@ -1,17 +1,9 @@
#ifndef __SHARED_CONTEXT_H__
#define __SHARED_CONTEXT_H__
#ifndef _SHARED_CONTEXT_H_
#define _SHARED_CONTEXT_H_
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "os.h"
#include "cx.h"
#include "os_io_seproxyhal.h"
#include "ethUstream.h"
#include "ethUtils.h"
#include "uint256.h"
#include "tokens.h"
#include "chainConfig.h"
#include "nft.h"
@@ -222,4 +214,4 @@ extern uint32_t eth2WithdrawalIndex;
void reset_app_context(void);
#endif // __SHARED_CONTEXT_H__
#endif // _SHARED_CONTEXT_H_

View File

@@ -4,6 +4,7 @@
#include "stark_utils.h"
#include "ui_callbacks.h"
#include "utils.h"
#include "ethUtils.h"
static unsigned char const C_cx_Stark256_n[] = {
// n: 0x0800000000000010ffffffffffffffffb781126dcae7b2321e66a241adc64d2f
@@ -16,13 +17,13 @@ static unsigned char const STARK_DERIVE_BIAS[] = {
0x38, 0xa1, 0x3b, 0x4b, 0x92, 0x0e, 0x94, 0x11, 0xae, 0x6d, 0xa5, 0xf4, 0x0b, 0x03, 0x58, 0xb1};
void starkDerivePrivateKey(uint32_t *bip32Path, uint32_t bip32PathLength, uint8_t *privateKeyData) {
#if 0
// Sanity check
#if 0
// Sanity check
if (bip32Path[0] != STARK_BIP32_PATH_0) {
PRINTF("Invalid Stark derivation path %d\n", bip32Path[0]);
THROW(0x6a80);
}
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, privateKeyData, NULL);
os_perso_derive_node_bip32(CX_CURVE_256K1, bip32Path, bip32PathLength, privateKeyData, NULL);
PRINTF("Private key before processing %.*H\n", 32, privateKeyData);
// TODO - support additional schemes
cx_math_modm(privateKeyData, 32, C_cx_Stark256_n, 32);

View File

@@ -1,5 +1,5 @@
#ifndef __STARK_CRYPTO_H__
#define __STARK_CRYPTO_H__
#ifndef _STARK_CRYPTO_H_
#define _STARK_CRYPTO_H_
#include <stdbool.h>
#include <stdint.h>
@@ -18,4 +18,4 @@ void pedersen(FieldElement res, /* out */
FieldElement a,
FieldElement b);
#endif
#endif // _STARK_CRYPTO_H_

View File

@@ -1,5 +1,5 @@
#ifndef __STARK_UTILS_H__
#define __STARK_UTILS_H__
#ifndef _STARK_UTILS_H_
#define _STARK_UTILS_H_
#include <stdbool.h>
#include <stdint.h>
@@ -32,4 +32,4 @@ int stark_sign(uint8_t *signature, /* out */
FieldElement msg,
FieldElement condition);
#endif
#endif // _STARK_UTILS_H_

View File

@@ -1,5 +1,5 @@
#ifndef SWAP_LIB_CALLS
#define SWAP_LIB_CALLS
#ifndef _SWAP_LIB_CALLS_H_
#define _SWAP_LIB_CALLS_H_
#include "stdbool.h"
@@ -50,4 +50,4 @@ typedef struct create_transaction_parameters_s {
char* destination_address_extra_id;
} create_transaction_parameters_t;
#endif
#endif // _SWAP_LIB_CALLS_H_

View File

@@ -194,4 +194,14 @@ const tokenDefinition_t const TOKENS_POLYGON[NUM_TOKENS_POLYGON] = {};
const tokenDefinition_t const TOKENS_SHYFT[NUM_TOKENS_SHYFT] = {};
const tokenDefinition_t const TOKENS_CONFLUX_ESPACE[NUM_TOKENS_CONFLUX_ESPACE] = {};
const tokenDefinition_t const TOKENS_MOONBEAM[NUM_TOKENS_MOONBEAM] = {};
const tokenDefinition_t const TOKENS_BTTC[NUM_TOKENS_BTTC] = {};
const tokenDefinition_t const TOKENS_KARDIACHAIN[NUM_TOKENS_KARDIACHAIN] = {};
const tokenDefinition_t const TOKENS_WETHIO[NUM_TOKENS_WETHIO] = {};
#endif

View File

@@ -25,14 +25,11 @@
#define MAX_ITEMS 2
typedef struct tokenDefinition_t {
uint8_t address[ADDRESS_LENGTH]; // must be first item
#ifdef HAVE_CONTRACT_NAME_IN_DESCRIPTOR
uint8_t contractName[ADDRESS_LENGTH];
#endif
uint8_t address[ADDRESS_LENGTH];
char ticker[MAX_TICKER_LEN];
char nft_pad[20]; // Adding some padding because the `nftInfo_t` is based on the size of a
// `tokenDefinition_t`. By adding some padding here we give more space to the
// collection name in the `nftInfo_t`. See `nftInfo_t` for more information.
uint8_t decimals;
} tokenDefinition_t;
@@ -46,25 +43,23 @@ extern tokenDefinition_t const TOKENS_EXTRA[NUM_TOKENS_EXTRA];
#ifndef HAVE_TOKENS_LIST
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
#ifndef LEDGER_TEST_PUBLIC_KEY
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
// production key 2019-01-11 03:07PM (erc20signer)
0x04, 0x5e, 0x6c, 0x10, 0x20, 0xc1, 0x4d, 0xc4, 0x64, 0x42, 0xfe, 0x89, 0xf9,
0x7c, 0x0b, 0x68, 0xcd, 0xb1, 0x59, 0x76, 0xdc, 0x24, 0xf2, 0x4c, 0x31, 0x6e,
0x7b, 0x30, 0xfe, 0x4e, 0x8c, 0xc7, 0x6b, 0x14, 0x89, 0x15, 0x0c, 0x21, 0x51,
0x4e, 0xbf, 0x44, 0x0f, 0xf5, 0xde, 0xa5, 0x39, 0x3d, 0x83, 0xde, 0x53, 0x58,
0xcd, 0x09, 0x8f, 0xce, 0x8f, 0xd0, 0xf8, 0x1d, 0xaa, 0x94, 0x97, 0x91, 0x83};
0x04, 0x5e, 0x6c, 0x10, 0x20, 0xc1, 0x4d, 0xc4, 0x64, 0x42, 0xfe, 0x89, 0xf9, 0x7c,
0x0b, 0x68, 0xcd, 0xb1, 0x59, 0x76, 0xdc, 0x24, 0xf2, 0x4c, 0x31, 0x6e, 0x7b, 0x30,
0xfe, 0x4e, 0x8c, 0xc7, 0x6b, 0x14, 0x89, 0x15, 0x0c, 0x21, 0x51, 0x4e, 0xbf, 0x44,
0x0f, 0xf5, 0xde, 0xa5, 0x39, 0x3d, 0x83, 0xde, 0x53, 0x58, 0xcd, 0x09, 0x8f, 0xce,
0x8f, 0xd0, 0xf8, 0x1d, 0xaa, 0x94, 0x97, 0x91, 0x83
#else
static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
// test key 2019-01-11 03:07PM (erc20signer)
0x04, 0x20, 0xda, 0x62, 0x00, 0x3c, 0x0c, 0xe0, 0x97, 0xe3, 0x36, 0x44, 0xa1,
0x0f, 0xe4, 0xc3, 0x04, 0x54, 0x06, 0x9a, 0x44, 0x54, 0xf0, 0xfa, 0x9d, 0x4e,
0x84, 0xf4, 0x50, 0x91, 0x42, 0x9b, 0x52, 0x20, 0xaf, 0x9e, 0x35, 0xc0, 0xb2,
0xd9, 0x28, 0x93, 0x80, 0x13, 0x73, 0x07, 0xde, 0x4d, 0xd1, 0xd4, 0x18, 0x42,
0x8c, 0xf2, 0x1a, 0x93, 0xb3, 0x35, 0x61, 0xbb, 0x09, 0xd8, 0x8f, 0xe5, 0x79,
};
0x04, 0x20, 0xda, 0x62, 0x00, 0x3c, 0x0c, 0xe0, 0x97, 0xe3, 0x36, 0x44, 0xa1, 0x0f,
0xe4, 0xc3, 0x04, 0x54, 0x06, 0x9a, 0x44, 0x54, 0xf0, 0xfa, 0x9d, 0x4e, 0x84, 0xf4,
0x50, 0x91, 0x42, 0x9b, 0x52, 0x20, 0xaf, 0x9e, 0x35, 0xc0, 0xb2, 0xd9, 0x28, 0x93,
0x80, 0x13, 0x73, 0x07, 0xde, 0x4d, 0xd1, 0xd4, 0x18, 0x42, 0x8c, 0xf2, 0x1a, 0x93,
0xb3, 0x35, 0x61, 0xbb, 0x09, 0xd8, 0x8f, 0xe5, 0x79
#endif
};
#else
@@ -106,6 +101,11 @@ static const uint8_t LEDGER_SIGNATURE_PUBLIC_KEY[] = {
#define NUM_TOKENS_MOONRIVER 0
#define NUM_TOKENS_POLYGON 0
#define NUM_TOKENS_SHYFT 0
#define NUM_TOKENS_CONFLUX_ESPACE 0
#define NUM_TOKENS_MOONBEAM 0
#define NUM_TOKENS_BTTC 0
#define NUM_TOKENS_KARDIACHAIN 0
#define NUM_TOKENS_WETHIO 0
extern tokenDefinition_t const TOKENS_AKROMA[NUM_TOKENS_AKROMA];
extern tokenDefinition_t const TOKENS_ELLAISM[NUM_TOKENS_ELLAISM];
@@ -143,7 +143,12 @@ extern tokenDefinition_t const TOKENS_SONGBIRD[NUM_TOKENS_SONGBIRD];
extern tokenDefinition_t const TOKENS_MOONRIVER[NUM_TOKENS_MOONRIVER];
extern tokenDefinition_t const TOKENS_POLYGON[NUM_TOKENS_POLYGON];
extern tokenDefinition_t const TOKENS_SHYFT[NUM_TOKENS_SHYFT];
extern tokenDefinition_t const TOKENS_CONFLUX_ESPACE[NUM_TOKENS_CONFLUX_ESPACE];
extern tokenDefinition_t const TOKENS_MOONBEAM[NUM_TOKENS_MOONBEAM];
extern tokenDefinition_t const TOKENS_BTTC[NUM_TOKENS_BTTC];
extern tokenDefinition_t const TOKENS_KARDIACHAIN[NUM_TOKENS_KARDIACHAIN];
extern tokenDefinition_t const TOKENS_WETHIO[NUM_TOKENS_WETHIO];
#endif /* HAVE_TOKENS_LIST */
#endif /* _TOKENS_H_ */
#endif // _TOKENS_H_

View File

@@ -1,3 +1,6 @@
#ifndef _UI_CALLBACKS_H_
#define _UI_CALLBACKS_H_
#include "shared_context.h"
#include "ux.h"
@@ -14,6 +17,8 @@ unsigned int io_seproxyhal_touch_data_cancel(const bagl_element_t *e);
unsigned int io_seproxyhal_touch_signMessage712_v0_ok(const bagl_element_t *e);
unsigned int io_seproxyhal_touch_signMessage712_v0_cancel(const bagl_element_t *e);
unsigned int io_seproxyhal_touch_eth2_address_ok(const bagl_element_t *e);
unsigned int io_seproxyhal_touch_privacy_ok(const bagl_element_t *e);
unsigned int io_seproxyhal_touch_privacy_cancel(const bagl_element_t *e);
void ui_idle(void);
void ui_warning_contract_data(void);
@@ -22,3 +27,5 @@ void io_seproxyhal_send_status(uint32_t sw);
void format_signature_out(const uint8_t *signature);
void finalizeParsing(bool direct);
extraInfo_t *getKnownToken(uint8_t *contractAddress);
#endif // _UI_CALLBACKS_H_

View File

@@ -1,3 +1,6 @@
#ifndef _UI_FLOW_H_
#define _UI_FLOW_H_
#include "shared_context.h"
#include "os_io_seproxyhal.h"
@@ -23,6 +26,10 @@ extern const ux_flow_step_t* const ux_sign_712_v0_flow[];
extern const ux_flow_step_t* const ux_display_public_eth2_flow[];
extern const ux_flow_step_t* const ux_display_privacy_public_key_flow[];
extern const ux_flow_step_t* const ux_display_privacy_shared_secret_flow[];
#ifdef HAVE_STARKWARE
extern const ux_flow_step_t* const ux_display_stark_public_flow[];
@@ -52,3 +59,5 @@ extern const ux_flow_step_t* const ux_approval_starkware_verify_escape_flow[];
extern const ux_flow_step_t* const ux_stark_unsafe_sign_flow[];
#endif
#endif // _UI_FLOW_H_

View File

@@ -115,7 +115,7 @@ void amountToString(const uint8_t *amount,
uint8_t decimals,
const char *ticker,
char *out_buffer,
uint8_t out_buffer_size) {
size_t out_buffer_size) {
char tmp_buffer[100] = {0};
if (uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)) == false) {

View File

@@ -37,8 +37,8 @@ void amountToString(const uint8_t* amount,
uint8_t decimals,
const char* ticker,
char* out_buffer,
uint8_t out_buffer_size);
size_t out_buffer_size);
bool parse_swap_config(uint8_t* config, uint8_t config_len, char* ticker, uint8_t* decimals);
#endif /* _UTILS_H_ */
#endif // _UTILS_H_

View File

@@ -164,4 +164,4 @@ parserStatus_e continueTx(txContext_t *context);
void copyTxData(txContext_t *context, uint8_t *out, uint32_t length);
uint8_t readTxByte(txContext_t *context);
#endif /* _ETHUSTREAM_H_ */
#endif // _ETHUSTREAM_H_

View File

@@ -237,10 +237,10 @@ void getEthDisplayableAddress(uint8_t *in,
getEthAddressStringFromBinary(in, out + 2, sha3, chainId);
}
bool adjustDecimals(char *src,
uint32_t srcLength,
bool adjustDecimals(const char *src,
size_t srcLength,
char *target,
uint32_t targetLength,
size_t targetLength,
uint8_t decimals) {
uint32_t startOffset;
uint32_t lastZeroOffset = 0;

View File

@@ -22,6 +22,7 @@
#include "cx.h"
#include "chainConfig.h"
/**
* @brief Decode an RLP encoded field - see
* https://github.com/ethereum/wiki/wiki/RLP
@@ -57,10 +58,10 @@ void getEthDisplayableAddress(uint8_t *in,
cx_sha3_t *sha3,
uint64_t chainId);
bool adjustDecimals(char *src,
uint32_t srcLength,
bool adjustDecimals(const char *src,
size_t srcLength,
char *target,
uint32_t targetLength,
size_t targetLength,
uint8_t decimals);
static __attribute__((no_instrument_function)) inline int allzeroes(void *buf, size_t n) {
@@ -83,4 +84,4 @@ static __attribute__((no_instrument_function)) inline int ismaxint(uint8_t *buf,
static const char HEXDIGITS[] = "0123456789abcdef";
#endif /* _ETHUTILS_H_ */
#endif // _ETHUTILS_H_

View File

@@ -45,27 +45,27 @@ uint64_t get_chain_id(void) {
return chain_id;
}
network_info_t *get_network(void) {
const network_info_t *get_network(void) {
uint64_t chain_id = get_chain_id();
for (uint8_t i = 0; i < sizeof(NETWORK_MAPPING) / sizeof(*NETWORK_MAPPING); i++) {
for (size_t i = 0; i < sizeof(NETWORK_MAPPING) / sizeof(*NETWORK_MAPPING); i++) {
if (NETWORK_MAPPING[i].chain_id == chain_id) {
return (network_info_t *) PIC(&NETWORK_MAPPING[i]);
return (const network_info_t *) PIC(&NETWORK_MAPPING[i]);
}
}
return NULL;
}
char *get_network_name(void) {
network_info_t *network = get_network();
const char *get_network_name(void) {
const network_info_t *network = get_network();
if (network == NULL) {
return NULL;
} else {
return (char *) PIC(network->name);
return (const char *) PIC(network->name);
}
}
char *get_network_ticker(void) {
network_info_t *network = get_network();
const char *get_network_ticker(void) {
const network_info_t *network = get_network();
if (network == NULL) {
return chainConfig->coinName;
} else {

View File

@@ -1,3 +1,6 @@
#ifndef _NETWORK_H_
#define _NETWORK_H_
#include <stdint.h>
#include "tokens.h"
#include "shared_context.h"
@@ -13,8 +16,10 @@ typedef struct network_info_s {
// Returns the current chain id. Defaults to 0 if txType was not found.
uint64_t get_chain_id(void);
// Returns a pointer to the network struct, or NULL if there is none.
network_info_t *get_network(void);
const network_info_t *get_network(void);
// Returns a pointer to the network name, or NULL if there is none.
char *get_network_name(void);
const char *get_network_name(void);
// Returns a pointer to the network ticker, or chainConfig->coinName if there is none.
char *get_network_ticker(void);
const char *get_network_ticker(void);
#endif // _NETWORK_H_

View File

@@ -73,4 +73,4 @@ void divmod256(uint256_t *l, uint256_t *r, uint256_t *div, uint256_t *mod);
bool tostring128(uint128_t *number, uint32_t base, char *out, uint32_t outLength);
bool tostring256(uint256_t *number, uint32_t base, char *out, uint32_t outLength);
#endif /* _UINT256_H_ */
#endif // _UINT256_H_

View File

@@ -1,3 +1,8 @@
#ifndef _GET_ETH2_PUB_KEY_H_
#define _GET_ETH2_PUB_KEY_H_
#include "shared_context.h"
uint32_t set_result_get_eth2_publicKey(void);
#endif // _GET_ETH2_PUB_KEY_H_

Some files were not shown because too many files have changed in this diff Show More