Merge pull request #570 from LedgerHQ/cev/B2CA-1558_Port-Standard-Makefile
B2CA-1558: Port Standard Makefile
119
.github/actions/commit-changes/action.yml
vendored
@@ -1,119 +0,0 @@
|
||||
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: '.'
|
||||
src_branch:
|
||||
description: 'Checkout (or create) a specific branch before commit/push. Defaults to current branch'
|
||||
required: false
|
||||
default: ''
|
||||
dst_branch:
|
||||
description: 'Push the created commit on a specific branch. Defaults to current branch'
|
||||
required: false
|
||||
default: ''
|
||||
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 }}
|
||||
|
||||
CURRENT_BRANCH=${GITHUB_REF#refs/heads/};
|
||||
# calculating source branch
|
||||
if [ -n "${{ inputs.src_branch }}" ]; \
|
||||
then \
|
||||
git switch ${{ inputs.src_branch }} 2>/dev/null || git switch -c ${{ inputs.src_branch }}; \
|
||||
SRC_BRANCH=${{ inputs.src_branch }}; \
|
||||
else \
|
||||
SRC_BRANCH=`git branch --show-current`; \
|
||||
if [ -z "$SRC_BRANCH" ]; \
|
||||
then \
|
||||
SRC_BRANCH=$CURRENT_BRANCH; \
|
||||
fi \
|
||||
fi
|
||||
|
||||
# calculating destination branch
|
||||
if [ -n "${{ inputs.dst_branch }}" ]; \
|
||||
then \
|
||||
DST_BRANCH=${{ inputs.dst_branch }}; \
|
||||
else \
|
||||
DST_BRANCH=`git branch --show-current`; \
|
||||
if [ -z "$DST_BRANCH" ]; \
|
||||
then \
|
||||
DST_BRANCH=$CURRENT_BRANCH; \
|
||||
fi \
|
||||
fi
|
||||
|
||||
echo "-----------------------------------------------------------"
|
||||
echo "Initial repo status"
|
||||
git status
|
||||
# checking changes, commit if needed
|
||||
CHANGES="$(git status --porcelain ${{ inputs.files }})"
|
||||
if [ -n "${CHANGES}" ]; \
|
||||
then \
|
||||
echo -e "Changes:\n${CHANGES}"; \
|
||||
git add ${{ inputs.files }}; \
|
||||
echo "-----------------------------------------------------------"; \
|
||||
echo "Repo status before commit"; \
|
||||
git status; \
|
||||
git commit -am "${{ inputs.message }}"; \
|
||||
fi
|
||||
|
||||
# compute if a push is needed
|
||||
if [ -n "${CHANGES}" -o "$SRC_BRANCH" != "$DST_BRANCH" ]; \
|
||||
then \
|
||||
PUSH="YES"; \
|
||||
else \
|
||||
PUSH="NO"; \
|
||||
fi
|
||||
|
||||
git log -n 2
|
||||
cd "${ORIGIN}"
|
||||
|
||||
echo " -- Env SRC_BRANCH: $SRC_BRANCH";
|
||||
echo " -- Env DST_BRANCH: $DST_BRANCH";
|
||||
echo " -- Env PUSH: $PUSH"
|
||||
# exporting these variables for next steps
|
||||
echo "##[set-output name=src_branch;]$(echo $SRC_BRANCH)";
|
||||
echo "##[set-output name=dst_branch;]$(echo $DST_BRANCH)";
|
||||
echo "##[set-output name=push;]$(echo $PUSH)";
|
||||
shell: bash
|
||||
|
||||
- name: Push commit
|
||||
if: steps.commit.outputs.push == 'YES'
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ inputs.secret }}
|
||||
branch: ${{ steps.commit.outputs.dst_branch }}
|
||||
directory: ${{ inputs.directory }}
|
||||
repository: ${{ inputs.repository }}
|
||||
2
.github/workflows/codeql_checks.yml
vendored
@@ -28,6 +28,8 @@ jobs:
|
||||
steps:
|
||||
- name: Clone
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v3
|
||||
|
||||
5
.github/workflows/codespell.yml
vendored
@@ -15,9 +15,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Check misspellings
|
||||
uses: codespell-project/actions-codespell@v2
|
||||
with:
|
||||
builtin: clear,rare
|
||||
check_filenames: true
|
||||
path: src, src_bagl, src_common, src_features, src_nbgl, src_plugin_sdk, src_plugins, doc, client
|
||||
path: src, src_bagl, src_features, src_nbgl, src_plugin_sdk, src_plugins, doc, client
|
||||
|
||||
1
.github/workflows/pr_on_all_plugins.yml
vendored
@@ -41,6 +41,7 @@ jobs:
|
||||
- name: Checkout SDK repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: true
|
||||
repository: LedgerHQ/ethereum-plugin-sdk
|
||||
ref: develop
|
||||
- name: Retrieve SDK reference
|
||||
|
||||
52
.github/workflows/sdk-generation.yml
vendored
@@ -1,52 +0,0 @@
|
||||
---
|
||||
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@v4
|
||||
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: ./tools/build_sdk.sh
|
||||
|
||||
- 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
|
||||
dst_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: Create SDK update pull request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
branch: sdk/update-submodule
|
||||
delete-branch: true
|
||||
title: Update the SDK submodule
|
||||
reviewers: apailler-ledger
|
||||
12
.gitignore
vendored
@@ -3,17 +3,15 @@ bin/
|
||||
debug/
|
||||
build/
|
||||
|
||||
# Unit tests and code coverage
|
||||
tests/unit/build/
|
||||
tests/unit/coverage/
|
||||
tests/unit/coverage.*
|
||||
|
||||
# Python
|
||||
venv/
|
||||
*.pyc
|
||||
__version__.py
|
||||
|
||||
# JS
|
||||
tests/node_modules
|
||||
tests/lib
|
||||
tests/yarn-error.log
|
||||
tests/elfs/*
|
||||
tests/snapshots-tmp
|
||||
|
||||
.vscode
|
||||
.idea
|
||||
|
||||
395
Makefile
@@ -21,289 +21,39 @@ endif
|
||||
|
||||
include $(BOLOS_SDK)/Makefile.defines
|
||||
|
||||
DEFINES_LIB = USE_LIB_ETHEREUM
|
||||
APP_LOAD_PARAMS = --curve secp256k1 $(COMMON_LOAD_PARAMS)
|
||||
# Allow the app to use path 45 for multi-sig (see BIP45).
|
||||
APP_LOAD_PARAMS += --path "45'"
|
||||
# Samsung temporary implementation for wallet ID on 0xda7aba5e/0xc1a551c5
|
||||
APP_LOAD_PARAMS += --path "1517992542'/1101353413'"
|
||||
########################################
|
||||
# Mandatory configuration #
|
||||
########################################
|
||||
|
||||
##################
|
||||
# Define Version #
|
||||
##################
|
||||
ifeq ($(CHAIN),)
|
||||
CHAIN = ethereum
|
||||
# Temporary definition to ensure VSCode extension works... To be cleaned later
|
||||
APPNAME = Ethereum
|
||||
endif
|
||||
|
||||
SUPPORTED_CHAINS = $(shell find makefile_conf/chain/ -type f -name '*.mk'| sed 's/.*\/\(.*\).mk/\1/g' | sort)
|
||||
ifneq ($(CHAIN),$(filter $(CHAIN),$(SUPPORTED_CHAINS)))
|
||||
$(error Unsupported CHAIN. Use one of: $(SUPPORTED_CHAINS))
|
||||
endif
|
||||
include ./makefile_conf/chain/$(CHAIN).mk
|
||||
|
||||
APPVERSION_M = 1
|
||||
APPVERSION_N = 11
|
||||
APPVERSION_P = 0
|
||||
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev
|
||||
APP_LOAD_FLAGS = --appFlags 0xa40 --dep Ethereum:$(APPVERSION)
|
||||
|
||||
#########################
|
||||
# Set Chain environment #
|
||||
#########################
|
||||
|
||||
ifeq ($(CHAIN),)
|
||||
CHAIN = ethereum
|
||||
endif
|
||||
|
||||
SUPPORTED_CHAINS = $(shell find makefile_conf/chain/ -type f -name '*.mk'| sed 's/.*\/\(.*\).mk/\1/g' | sort)
|
||||
|
||||
# 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
|
||||
$(error Unsupported CHAIN - use $(SUPPORTED_CHAINS))
|
||||
endif
|
||||
CFLAGS += -DAPPNAME=\"$(APPNAME)\"
|
||||
DEFINES += CHAINID_COINNAME=\"$(TICKER)\" CHAIN_ID=$(CHAIN_ID)
|
||||
|
||||
#########
|
||||
# Other #
|
||||
#########
|
||||
|
||||
APP_LOAD_PARAMS += $(APP_LOAD_FLAGS) --path "44'/1'"
|
||||
DEFINES += $(DEFINES_LIB)
|
||||
|
||||
#prepare hsm generation
|
||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
||||
ICONNAME = icons/nanos_app_chain_$(CHAIN_ID).gif
|
||||
else ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
ICONNAME = icons/stax_app_chain_$(CHAIN_ID).gif
|
||||
DEFINES += ICONGLYPH=C_stax_chain_$(CHAIN_ID)_64px
|
||||
DEFINES += ICONBITMAP=C_stax_chain_$(CHAIN_ID)_64px_bitmap
|
||||
DEFINES += ICONGLYPH_SMALL=C_stax_chain_$(CHAIN_ID)
|
||||
GLYPH_FILES += $(ICONNAME)
|
||||
else
|
||||
ICONNAME = icons/nanox_app_chain_$(CHAIN_ID).gif
|
||||
endif
|
||||
|
||||
################
|
||||
# Default rule #
|
||||
################
|
||||
all: default
|
||||
|
||||
############
|
||||
# Platform #
|
||||
############
|
||||
|
||||
DEFINES += OS_IO_SEPROXYHAL
|
||||
DEFINES += HAVE_SPRINTF HAVE_SNPRINTF_FORMAT_U
|
||||
DEFINES += HAVE_IO_USB HAVE_L4_USBLIB IO_USB_MAX_ENDPOINTS=4 IO_HID_EP_LENGTH=64 HAVE_USB_APDU
|
||||
DEFINES += LEDGER_MAJOR_VERSION=$(APPVERSION_M) LEDGER_MINOR_VERSION=$(APPVERSION_N) LEDGER_PATCH_VERSION=$(APPVERSION_P)
|
||||
DEFINES += BUILD_YEAR=\"$(shell date +%Y)\"
|
||||
|
||||
# U2F
|
||||
DEFINES += HAVE_U2F HAVE_IO_U2F
|
||||
DEFINES += U2F_PROXY_MAGIC=\"w0w\"
|
||||
DEFINES += USB_SEGMENT_SIZE=64
|
||||
DEFINES += BLE_SEGMENT_SIZE=32 #max MTU, min 20
|
||||
DEFINES += APPVERSION=\"$(APPVERSION)\"
|
||||
|
||||
#WEBUSB_URL = www.ledgerwallet.com
|
||||
#DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=$(shell echo -n $(WEBUSB_URL) | wc -c) WEBUSB_URL=$(shell echo -n $(WEBUSB_URL) | sed -e "s/./\\\'\0\\\',/g")
|
||||
|
||||
DEFINES += HAVE_WEBUSB WEBUSB_URL_SIZE_B=0 WEBUSB_URL=""
|
||||
|
||||
ifneq (,$(filter $(TARGET_NAME),TARGET_NANOX TARGET_STAX))
|
||||
DEFINES += HAVE_BLE BLE_COMMAND_TIMEOUT_MS=2000
|
||||
DEFINES += HAVE_BLE_APDU # basic ledger apdu transport over BLE
|
||||
SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=128
|
||||
else
|
||||
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
|
||||
endif
|
||||
|
||||
ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
DEFINES += NBGL_QRCODE
|
||||
SDK_SOURCE_PATH += qrcode
|
||||
else
|
||||
DEFINES += HAVE_BAGL
|
||||
DEFINES += HAVE_UX_FLOW
|
||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=32
|
||||
else
|
||||
DEFINES += HAVE_GLO096
|
||||
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=64
|
||||
DEFINES += HAVE_BAGL_ELLIPSIS # long label truncation feature
|
||||
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_REGULAR_11PX
|
||||
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_EXTRABOLD_11PX
|
||||
DEFINES += HAVE_BAGL_FONT_OPEN_SANS_LIGHT_16PX
|
||||
endif
|
||||
endif
|
||||
|
||||
####################
|
||||
# Enabled Features #
|
||||
####################
|
||||
|
||||
# Enables direct data signing without having to specify it in the settings. Useful when testing with speculos.
|
||||
ALLOW_DATA ?= 0
|
||||
ifneq ($(ALLOW_DATA),0)
|
||||
DEFINES += HAVE_ALLOW_DATA
|
||||
endif
|
||||
|
||||
# Bypass the signature verification for setExternalPlugin, setPlugin, provideERC20TokenInfo and provideNFTInfo calls
|
||||
BYPASS_SIGNATURES ?= 0
|
||||
ifneq ($(BYPASS_SIGNATURES),0)
|
||||
DEFINES += HAVE_BYPASS_SIGNATURES
|
||||
endif
|
||||
|
||||
# Enable the SET_PLUGIN test key
|
||||
SET_PLUGIN_TEST_KEY ?= 0
|
||||
ifneq ($(SET_PLUGIN_TEST_KEY),0)
|
||||
DEFINES += HAVE_SET_PLUGIN_TEST_KEY
|
||||
endif
|
||||
|
||||
# NFTs
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_NFT_SUPPORT
|
||||
NFT_TEST_KEY ?= 0
|
||||
ifneq ($(NFT_TEST_KEY),0)
|
||||
DEFINES += HAVE_NFT_TEST_KEY
|
||||
endif
|
||||
NFT_STAGING_KEY ?= 0
|
||||
ifneq ($(NFT_STAGING_KEY),0)
|
||||
# Key used by the staging backend
|
||||
DEFINES += HAVE_NFT_STAGING_KEY
|
||||
endif
|
||||
endif
|
||||
ifneq (,$(filter $(DEFINES),HAVE_NFT_TEST_KEY))
|
||||
ifneq (, $(filter $(DEFINES),HAVE_NFT_STAGING_KEY))
|
||||
$(error Multiple alternative NFT keys set at once)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Dynamic memory allocator
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_DYN_MEM_ALLOC
|
||||
endif
|
||||
|
||||
# EIP-712
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_EIP712_FULL_SUPPORT
|
||||
endif
|
||||
|
||||
# CryptoAssetsList key
|
||||
CAL_TEST_KEY ?= 0
|
||||
ifneq ($(CAL_TEST_KEY),0)
|
||||
# Key used in our test framework
|
||||
DEFINES += HAVE_CAL_TEST_KEY
|
||||
endif
|
||||
CAL_STAGING_KEY ?= 0
|
||||
ifneq ($(CAL_STAGING_KEY),0)
|
||||
# Key used by the staging CAL
|
||||
DEFINES += HAVE_CAL_STAGING_KEY
|
||||
endif
|
||||
ifneq (,$(filter $(DEFINES),HAVE_CAL_TEST_KEY))
|
||||
ifneq (, $(filter $(DEFINES),HAVE_CAL_STAGING_KEY))
|
||||
# Can't use both the staging and testing keys
|
||||
$(error Multiple alternative CAL keys set at once)
|
||||
endif
|
||||
endif
|
||||
|
||||
# ENS
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_DOMAIN_NAME
|
||||
DOMAIN_NAME_TEST_KEY ?= 0
|
||||
ifneq ($(DOMAIN_NAME_TEST_KEY),0)
|
||||
DEFINES += HAVE_DOMAIN_NAME_TEST_KEY
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enabling debug PRINTF
|
||||
ifneq ($(DEBUG),0)
|
||||
DEFINES += HAVE_STACK_OVERFLOW_CHECK
|
||||
ifeq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_PRINTF PRINTF=screen_printf
|
||||
else
|
||||
DEFINES += HAVE_PRINTF PRINTF=mcu_usb_printf
|
||||
endif
|
||||
else
|
||||
DEFINES += PRINTF\(...\)=
|
||||
endif
|
||||
|
||||
ifneq ($(NOCONSENT),)
|
||||
DEFINES += NO_CONSENT
|
||||
endif
|
||||
|
||||
##############
|
||||
# Compiler #
|
||||
##############
|
||||
|
||||
ifneq ($(BOLOS_ENV),)
|
||||
$(info BOLOS_ENV=$(BOLOS_ENV))
|
||||
CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
|
||||
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
|
||||
else
|
||||
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
|
||||
endif
|
||||
ifeq ($(CLANGPATH),)
|
||||
$(info CLANGPATH is not set: clang will be used from PATH)
|
||||
endif
|
||||
ifeq ($(GCCPATH),)
|
||||
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
|
||||
endif
|
||||
|
||||
CC := $(CLANGPATH)clang
|
||||
CFLAGS += -Wno-format-invalid-specifier -Wno-format-extra-args
|
||||
AS := $(GCCPATH)arm-none-eabi-gcc
|
||||
LD := $(GCCPATH)arm-none-eabi-gcc
|
||||
LDLIBS += -lm -lgcc -lc
|
||||
|
||||
# import rules to compile glyphs(/pone)
|
||||
include $(BOLOS_SDK)/Makefile.glyphs
|
||||
|
||||
### variables processed by the common makefile.rules of the SDK to grab source files and include dirs
|
||||
APP_SOURCE_PATH += src_common src src_features src_plugins
|
||||
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl lib_u2f
|
||||
ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
# Application source files
|
||||
APP_SOURCE_PATH += src src_features src_plugins
|
||||
ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
APP_SOURCE_PATH += src_nbgl
|
||||
else
|
||||
SDK_SOURCE_PATH += lib_ux
|
||||
APP_SOURCE_PATH += src_bagl
|
||||
endif
|
||||
|
||||
# Allow usage of function from lib_standard_app/crypto_helpers.c
|
||||
APP_SOURCE_FILES += $(filter-out ./ethereum-plugin-sdk/src/main.c, $(wildcard ./ethereum-plugin-sdk/src/*.c))
|
||||
INCLUDES_PATH += ./ethereum-plugin-sdk/src
|
||||
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_standard_app/crypto_helpers.c
|
||||
|
||||
### initialize plugin SDK submodule if needed, rebuild it, and warn if a difference is noticed
|
||||
ifeq ($(CHAIN),ethereum)
|
||||
ifneq ($(shell git submodule status | grep '^[-+]'),)
|
||||
$(info INFO: Need to reinitialize git submodules)
|
||||
$(shell git submodule update --init)
|
||||
endif
|
||||
|
||||
# rebuild SDK
|
||||
$(shell ./tools/build_sdk.sh)
|
||||
|
||||
# check if a difference is noticed (fail if it happens in CI build)
|
||||
ifneq ($(shell git status | grep 'ethereum-plugin-sdk'),)
|
||||
ifneq ($(JENKINS_URL),)
|
||||
$(error ERROR: please update ethereum-plugin-sdk submodule first)
|
||||
else
|
||||
$(warning WARNING: please update ethereum-plugin-sdk submodule first)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
load: all
|
||||
python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS)
|
||||
|
||||
delete:
|
||||
python3 -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)
|
||||
|
||||
install_tests:
|
||||
cd tests/zemu/ && (yarn install || sudo yarn install)
|
||||
|
||||
run_tests:
|
||||
cd tests/zemu/ && (yarn test || sudo yarn test)
|
||||
|
||||
test: install_tests run_tests
|
||||
|
||||
unit-test:
|
||||
make -C tests/unit
|
||||
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_standard_app/format.c
|
||||
INCLUDES_PATH += ${BOLOS_SDK}/lib_standard_app
|
||||
|
||||
ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
NETWORK_ICONS_FILE = $(GEN_SRC_DIR)/net_icons.gen.c
|
||||
@@ -315,11 +65,102 @@ $(NETWORK_ICONS_FILE):
|
||||
APP_SOURCE_FILES += $(NETWORK_ICONS_FILE)
|
||||
endif
|
||||
|
||||
# import generic rules from the sdk
|
||||
include $(BOLOS_SDK)/Makefile.rules
|
||||
# Application icons following guidelines:
|
||||
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
|
||||
ICON_NANOS = icons/nanos_app_chain_$(CHAIN_ID).gif
|
||||
ICON_NANOX = icons/nanox_app_chain_$(CHAIN_ID).gif
|
||||
ICON_NANOSP = icons/nanox_app_chain_$(CHAIN_ID).gif
|
||||
ICON_STAX = icons/stax_app_chain_$(CHAIN_ID).gif
|
||||
|
||||
#add dependency on custom makefile filename
|
||||
dep/%.d: %.c Makefile
|
||||
#prepare hsm generation
|
||||
ifeq ($(TARGET_NAME),TARGET_STAX)
|
||||
DEFINES += ICONGLYPH=C_stax_chain_$(CHAIN_ID)_64px
|
||||
DEFINES += ICONBITMAP=C_stax_chain_$(CHAIN_ID)_64px_bitmap
|
||||
DEFINES += ICONGLYPH_SMALL=C_stax_chain_$(CHAIN_ID)
|
||||
endif
|
||||
|
||||
listvariants:
|
||||
@echo VARIANTS CHAIN $(SUPPORTED_CHAINS)
|
||||
|
||||
# Application allowed derivation curves.
|
||||
# Possibles curves are: secp256k1, secp256r1, ed25519 and bls12381g1
|
||||
# If your app needs it, you can specify multiple curves by using:
|
||||
# `CURVE_APP_LOAD_PARAMS = <curve1> <curve2>`
|
||||
CURVE_APP_LOAD_PARAMS += secp256k1
|
||||
|
||||
# Application allowed derivation paths.
|
||||
# You should request a specific path for your app.
|
||||
# This serve as an isolation mechanism.
|
||||
# Most application will have to request a path according to the BIP-0044
|
||||
# and SLIP-0044 standards.
|
||||
# If your app needs it, you can specify multiple path by using:
|
||||
# `PATH_APP_LOAD_PARAMS = "44'/1'" "45'/1'"`
|
||||
PATH_APP_LOAD_PARAMS += "45'" "44'/1'"
|
||||
|
||||
# Setting to allow building variant applications
|
||||
# - <VARIANT_PARAM> is the name of the parameter which should be set
|
||||
# to specify the variant that should be build.
|
||||
# - <VARIANT_VALUES> a list of variant that can be build using this app code.
|
||||
# * It must at least contains one value.
|
||||
# * Values can be the app ticker or anything else but should be unique.
|
||||
VARIANT_PARAM = CHAIN
|
||||
VARIANT_VALUES = $(SUPPORTED_CHAINS)
|
||||
|
||||
# Activate dependency only for specific CHAIN
|
||||
ifneq ($(CHAIN),ethereum)
|
||||
DEP_APP_LOAD_PARAMS = Ethereum:$(APPVERSION)
|
||||
DEFINES_LIB = USE_LIB_ETHEREUM
|
||||
endif
|
||||
|
||||
# Enabling DEBUG flag will enable PRINTF and disable optimizations
|
||||
#DEBUG = 1
|
||||
|
||||
########################################
|
||||
# Application custom permissions #
|
||||
########################################
|
||||
# See SDK `include/appflags.h` for the purpose of each permission
|
||||
#HAVE_APPLICATION_FLAG_DERIVE_MASTER = 1
|
||||
HAVE_APPLICATION_FLAG_GLOBAL_PIN = 1
|
||||
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
|
||||
HAVE_APPLICATION_FLAG_LIBRARY = 1
|
||||
|
||||
########################################
|
||||
# Application communication interfaces #
|
||||
########################################
|
||||
ENABLE_BLUETOOTH = 1
|
||||
#ENABLE_NFC = 1
|
||||
|
||||
########################################
|
||||
# NBGL custom features #
|
||||
########################################
|
||||
ENABLE_NBGL_QRCODE = 1
|
||||
#ENABLE_NBGL_KEYBOARD = 1
|
||||
#ENABLE_NBGL_KEYPAD = 1
|
||||
|
||||
########################################
|
||||
# Features disablers #
|
||||
########################################
|
||||
# These advanced settings allow to disable some feature that are by
|
||||
# default enabled in the SDK `Makefile.standard_app`.
|
||||
DISABLE_STANDARD_APP_FILES = 1
|
||||
#DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE = 1 # To allow custom size declaration
|
||||
#DISABLE_STANDARD_APP_DEFINES = 1 # Will set all the following disablers
|
||||
#DISABLE_STANDARD_SNPRINTF = 1
|
||||
#DISABLE_STANDARD_USB = 1
|
||||
#DISABLE_STANDARD_WEBUSB = 1
|
||||
#DISABLE_STANDARD_BAGL_UX_FLOW = 1
|
||||
#DISABLE_DEBUG_LEDGER_ASSERT = 1
|
||||
#DISABLE_DEBUG_THROW = 1
|
||||
|
||||
########################################
|
||||
# Main app configuration #
|
||||
########################################
|
||||
|
||||
DEFINES += CHAINID_COINNAME=\"$(TICKER)\" CHAIN_ID=$(CHAIN_ID)
|
||||
DEFINES += BUILD_YEAR=\"$(shell date +%Y)\"
|
||||
|
||||
# Enabled Features #
|
||||
include makefile_conf/features.mk
|
||||
|
||||
#########################
|
||||
|
||||
# Import generic rules from the SDK
|
||||
include $(BOLOS_SDK)/Makefile.standard_app
|
||||
|
||||
@@ -135,6 +135,12 @@ If you prefer using a terminal to perform the steps manually, you can use the gu
|
||||
|
||||
Setup a compilation environment by following the [shell with docker approach](#with-a-terminal).
|
||||
|
||||
Be sure you checkout the submodule:
|
||||
|
||||
```shell
|
||||
git submodule update --init
|
||||
```
|
||||
|
||||
From inside the container, use the following command to build the app:
|
||||
|
||||
```shell
|
||||
|
||||
|
Before Width: | Height: | Size: 70 B |
|
Before Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 53 B |
|
Before Width: | Height: | Size: 58 B |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 110 B |
|
Before Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 127 B |
|
Before Width: | Height: | Size: 157 B |
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/200625'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/200625'"
|
||||
TICKER = "AKA"
|
||||
CHAIN_ID = 200625
|
||||
APPNAME = "Akroma"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/550'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/550'"
|
||||
TICKER = "TXDC"
|
||||
CHAIN_ID = 51
|
||||
APPNAME = "ApothemNetwork"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/246529'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/246529'"
|
||||
TICKER = "ATS"
|
||||
CHAIN_ID = 246529
|
||||
APPNAME = "ARTIS sigma1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/246785'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/246785'"
|
||||
TICKER = "ATS"
|
||||
CHAIN_ID = 246785
|
||||
APPNAME = "ARTIS tau1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/810'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/810'" "44'/60'"
|
||||
TICKER = "ASTR"
|
||||
CHAIN_ID = 592
|
||||
APPNAME = "Astar Polkadot EVM"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1620'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/1620'"
|
||||
TICKER = "ATH"
|
||||
CHAIN_ID = 1620
|
||||
APPNAME = "Atheios"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "BNB"
|
||||
CHAIN_ID = 56
|
||||
APPNAME = "Binance Smart Chain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "BTT"
|
||||
CHAIN_ID = 199
|
||||
APPNAME = "BTTC"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/820'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/820'"
|
||||
TICKER = "CLO"
|
||||
CHAIN_ID = 820
|
||||
APPNAME = "Callisto"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "CFX"
|
||||
CHAIN_ID = 1030
|
||||
APPNAME = "Conflux eSpace"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "CUBE"
|
||||
CHAIN_ID = 1818
|
||||
APPNAME = "Cube"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/237'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/237'"
|
||||
TICKER = "DXN"
|
||||
CHAIN_ID = 237
|
||||
APPNAME = "DEXON"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/163'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/163'"
|
||||
TICKER = "ELLA"
|
||||
CHAIN_ID = 64
|
||||
APPNAME = "Ellaism"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/246'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/246'" "44'/60'"
|
||||
TICKER = "EWT"
|
||||
CHAIN_ID = 246
|
||||
APPNAME = "EnergyWebChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1313114'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/1313114'"
|
||||
TICKER = "ETHO"
|
||||
CHAIN_ID = 1313114
|
||||
APPNAME = "Ether-1"
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
# Lock the application on its standard path for 1.5. Please complain if non compliant
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "ETH"
|
||||
CHAIN_ID = 1
|
||||
# Allow to derive ETH 2 public keys
|
||||
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
|
||||
PATH_APP_LOAD_PARAMS += "12381/3600"
|
||||
CURVE_APP_LOAD_PARAMS += bls12381g1
|
||||
DEFINES += HAVE_ETH2
|
||||
APPNAME = "Ethereum"
|
||||
DEFINES_LIB=
|
||||
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
|
||||
APP_LOAD_FLAGS=--appFlags 0xa40
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Also allows ETC to access the ETH derivation path to recover forked assets
|
||||
APP_LOAD_PARAMS += --path "44'/61'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/61'" "44'/60'"
|
||||
TICKER = "ETC"
|
||||
CHAIN_ID = 61
|
||||
APPNAME = "Ethereum Classic"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1987'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/1987'"
|
||||
TICKER = "EGEM"
|
||||
CHAIN_ID = 1987
|
||||
APPNAME = "EtherGem"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/31102'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/31102'"
|
||||
TICKER = "ESN"
|
||||
CHAIN_ID = 31102
|
||||
APPNAME = "Ethersocial"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/40'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/40'"
|
||||
TICKER = "EXP"
|
||||
CHAIN_ID = 2
|
||||
APPNAME = "Expanse"
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "FLR"
|
||||
CHAIN_ID = 14
|
||||
|
||||
# Pending review parameters
|
||||
APP_LOAD_PARAMS += --tlvraw 9F:01
|
||||
DEFINES += HAVE_PENDING_REVIEW_SCREEN
|
||||
|
||||
APPNAME = "Flare"
|
||||
@@ -1,4 +0,0 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
TICKER = "FLR"
|
||||
CHAIN_ID = 16
|
||||
APPNAME = "Flare Coston"
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/6060'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/6060'"
|
||||
TICKER = "GO"
|
||||
CHAIN_ID = 60
|
||||
APPNAME = "GoChain"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "ETH"
|
||||
CHAIN_ID = 5
|
||||
# Allow to derive ETH 2 public keys
|
||||
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
|
||||
DEFINES += HAVE_ETH2
|
||||
APPNAME = "Eth Goerli"
|
||||
DEFINES_LIB=
|
||||
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
|
||||
APP_LOAD_FLAGS=--appFlags 0xa40
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/269'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/269'"
|
||||
TICKER = "HPB"
|
||||
CHAIN_ID = 269
|
||||
APPNAME = "HPB"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/161803'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/161803'"
|
||||
TICKER = "A4G"
|
||||
CHAIN_ID = 846000
|
||||
APPNAME = "ID4Good"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "KAI"
|
||||
CHAIN_ID = 24
|
||||
APPNAME = "KardiaChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "MTR"
|
||||
CHAIN_ID = 82
|
||||
APPNAME = "Meter"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/76'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/76'"
|
||||
TICKER = "MIX"
|
||||
CHAIN_ID = 76
|
||||
APPNAME = "Mix"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1284'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'" "44'/1284'"
|
||||
TICKER = "GLMR"
|
||||
CHAIN_ID = 1284
|
||||
APPNAME = "Moonbeam"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/1285'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'" "44'/1285'"
|
||||
TICKER = "MOVR"
|
||||
CHAIN_ID = 1285
|
||||
APPNAME = "Moonriver"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "MTV"
|
||||
CHAIN_ID = 62621
|
||||
APPNAME = "MultiVAC"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/184'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/184'"
|
||||
TICKER = "MUSIC"
|
||||
CHAIN_ID = 7762959
|
||||
APPNAME = "Musicoin"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/685'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/685'" "44'/60'"
|
||||
TICKER = "OAS"
|
||||
CHAIN_ID = 248
|
||||
APPNAME = "Oasys"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "OKT"
|
||||
CHAIN_ID = 66
|
||||
APPNAME = "OKXChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/164'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/164'"
|
||||
TICKER = "PIRL"
|
||||
CHAIN_ID = 3125659152
|
||||
APPNAME = "Pirl"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "POA"
|
||||
CHAIN_ID = 99
|
||||
APPNAME = "POA"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "MATIC"
|
||||
CHAIN_ID = 137
|
||||
APPNAME = "Polygon"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/2894'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/2894'"
|
||||
TICKER = "REOSC"
|
||||
CHAIN_ID = 2894
|
||||
APPNAME = "REOSC"
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
TICKER = "ETH"
|
||||
CHAIN_ID = 3
|
||||
# Allow to derive ETH 2 public keys
|
||||
APP_LOAD_PARAMS += --path "12381/3600" --curve bls12381g1
|
||||
DEFINES += HAVE_ETH2
|
||||
APPNAME = "Eth Ropsten"
|
||||
DEFINES_LIB=
|
||||
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
|
||||
APP_LOAD_FLAGS=--appFlags 0xa40
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/137'" --path "44'/00'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/137'" "44'/00'"
|
||||
TICKER = "RBTC"
|
||||
CHAIN_ID = 30
|
||||
APPNAME = "RSK"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/37310'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/37310'"
|
||||
TICKER = "RBTC"
|
||||
CHAIN_ID = 31
|
||||
APPNAME = "RSK Test"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/809'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/809'" "44'/60'"
|
||||
TICKER = "SDN"
|
||||
CHAIN_ID = 336
|
||||
APPNAME = "Shiden EVM"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'"
|
||||
TICKER = "SHFT"
|
||||
CHAIN_ID = 7341
|
||||
APPNAME = "Shyft"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/554'" "44'/60'"
|
||||
TICKER = "SGB"
|
||||
CHAIN_ID = 19
|
||||
APPNAME = "Songbird"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/554'" "44'/60'"
|
||||
TICKER = "TCR"
|
||||
CHAIN_ID = 20531812
|
||||
APPNAME = "TecraCoin"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/554'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/554'" "44'/60'"
|
||||
TICKER = "TCR"
|
||||
CHAIN_ID = 20531811
|
||||
APPNAME = "TecraTestnet"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/1001'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/1001'"
|
||||
TICKER = "TT"
|
||||
CHAIN_ID = 108
|
||||
APPNAME = "ThunderCore"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/889'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/889'"
|
||||
TICKER = "TOMO"
|
||||
CHAIN_ID = 88
|
||||
APPNAME = "TomoChain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/108'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/108'"
|
||||
TICKER = "UBQ"
|
||||
CHAIN_ID = 8
|
||||
APPNAME = "Ubiq"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/73799'" --path "44'/60'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/73799'" "44'/60'"
|
||||
TICKER = "VOLTA"
|
||||
CHAIN_ID = 73799
|
||||
APPNAME = "Volta"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/5718350'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/5718350'"
|
||||
TICKER = "WAN"
|
||||
CHAIN_ID = 888
|
||||
APPNAME = "Wanchain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/227'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/227'"
|
||||
TICKER = "WEB"
|
||||
CHAIN_ID = 24484
|
||||
APPNAME = "Webchain"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/77777'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/77777'"
|
||||
TICKER = "ZYN"
|
||||
CHAIN_ID = 78
|
||||
APPNAME = "Wethio"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_LOAD_PARAMS += --path "44'/60'" --path "44'/550'"
|
||||
PATH_APP_LOAD_PARAMS += "44'/60'" "44'/550'"
|
||||
TICKER = "XDC"
|
||||
CHAIN_ID = 50
|
||||
APPNAME = "XDC Network"
|
||||
|
||||
85
makefile_conf/features.mk
Normal file
@@ -0,0 +1,85 @@
|
||||
# Activate requested features
|
||||
# ---------------------------
|
||||
# Enables direct data signing without having to specify it in the settings. Useful when testing with speculos.
|
||||
ALLOW_DATA ?= 0
|
||||
ifneq ($(ALLOW_DATA),0)
|
||||
DEFINES += HAVE_ALLOW_DATA
|
||||
endif
|
||||
|
||||
# Bypass the signature verification for setExternalPlugin, setPlugin, provideERC20TokenInfo and provideNFTInfo calls
|
||||
BYPASS_SIGNATURES ?= 0
|
||||
ifneq ($(BYPASS_SIGNATURES),0)
|
||||
DEFINES += HAVE_BYPASS_SIGNATURES
|
||||
endif
|
||||
|
||||
# Enable the SET_PLUGIN test key
|
||||
SET_PLUGIN_TEST_KEY ?= 0
|
||||
ifneq ($(SET_PLUGIN_TEST_KEY),0)
|
||||
DEFINES += HAVE_SET_PLUGIN_TEST_KEY
|
||||
endif
|
||||
|
||||
# NFTs
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_NFT_SUPPORT
|
||||
NFT_TEST_KEY ?= 0
|
||||
ifneq ($(NFT_TEST_KEY),0)
|
||||
DEFINES += HAVE_NFT_TEST_KEY
|
||||
endif
|
||||
NFT_STAGING_KEY ?= 0
|
||||
ifneq ($(NFT_STAGING_KEY),0)
|
||||
# Key used by the staging backend
|
||||
DEFINES += HAVE_NFT_STAGING_KEY
|
||||
endif
|
||||
endif
|
||||
|
||||
# Dynamic memory allocator
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_DYN_MEM_ALLOC
|
||||
endif
|
||||
|
||||
# EIP-712
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_EIP712_FULL_SUPPORT
|
||||
endif
|
||||
|
||||
# CryptoAssetsList key
|
||||
CAL_TEST_KEY ?= 0
|
||||
ifneq ($(CAL_TEST_KEY),0)
|
||||
# Key used in our test framework
|
||||
DEFINES += HAVE_CAL_TEST_KEY
|
||||
endif
|
||||
CAL_STAGING_KEY ?= 0
|
||||
ifneq ($(CAL_STAGING_KEY),0)
|
||||
# Key used by the staging CAL
|
||||
DEFINES += HAVE_CAL_STAGING_KEY
|
||||
endif
|
||||
|
||||
# ENS
|
||||
ifneq ($(TARGET_NAME),TARGET_NANOS)
|
||||
DEFINES += HAVE_DOMAIN_NAME
|
||||
DOMAIN_NAME_TEST_KEY ?= 0
|
||||
ifneq ($(DOMAIN_NAME_TEST_KEY),0)
|
||||
DEFINES += HAVE_DOMAIN_NAME_TEST_KEY
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(NOCONSENT),)
|
||||
DEFINES += NO_CONSENT
|
||||
endif
|
||||
|
||||
# Check features incompatibilities
|
||||
# --------------------------------
|
||||
# NFTs
|
||||
ifneq (,$(filter $(DEFINES),HAVE_NFT_TEST_KEY))
|
||||
ifneq (, $(filter $(DEFINES),HAVE_NFT_STAGING_KEY))
|
||||
$(error Multiple alternative NFT keys set at once)
|
||||
endif
|
||||
endif
|
||||
|
||||
# CryptoAssetsList key
|
||||
ifneq (,$(filter $(DEFINES),HAVE_CAL_TEST_KEY))
|
||||
ifneq (, $(filter $(DEFINES),HAVE_CAL_STAGING_KEY))
|
||||
# Can't use both the staging and testing keys
|
||||
$(error Multiple alternative CAL keys set at once)
|
||||
endif
|
||||
endif
|
||||
@@ -102,11 +102,11 @@ static void eth_plugin_perform_init_default(uint8_t *contractAddress,
|
||||
static bool eth_plugin_perform_init_old_internal(uint8_t *contractAddress,
|
||||
ethPluginInitContract_t *init) {
|
||||
uint8_t i, j;
|
||||
const uint8_t **selectors;
|
||||
const uint8_t *const *selectors;
|
||||
|
||||
// Search internal plugin list
|
||||
for (i = 0;; i++) {
|
||||
selectors = (const uint8_t **) PIC(INTERNAL_ETH_PLUGINS[i].selectors);
|
||||
selectors = (const uint8_t *const *) PIC(INTERNAL_ETH_PLUGINS[i].selectors);
|
||||
if (selectors == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ const uint8_t* const ETH2_SELECTORS[NUM_ETH2_SELECTORS] = {ETH2_DEPOSIT_SELECTOR
|
||||
// All internal alias names start with 'minus'
|
||||
|
||||
const internalEthPlugin_t INTERNAL_ETH_PLUGINS[] = {
|
||||
{NULL, (const uint8_t**) ERC20_SELECTORS, NUM_ERC20_SELECTORS, "-erc20", erc20_plugin_call},
|
||||
{NULL, ERC20_SELECTORS, NUM_ERC20_SELECTORS, "-erc20", erc20_plugin_call},
|
||||
|
||||
#ifdef HAVE_ETH2
|
||||
|
||||
{NULL, (const uint8_t**) ETH2_SELECTORS, NUM_ETH2_SELECTORS, "-eth2", eth2_plugin_call},
|
||||
{NULL, ETH2_SELECTORS, NUM_ETH2_SELECTORS, "-eth2", eth2_plugin_call},
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
void erc721_plugin_call(int message, void* parameters);
|
||||
void erc1155_plugin_call(int message, void* parameters);
|
||||
|
||||
typedef bool (*PluginAvailableCheck)(void);
|
||||
typedef bool (*const PluginAvailableCheck)(void);
|
||||
typedef void (*PluginCall)(int, void*);
|
||||
|
||||
typedef struct internalEthPlugin_t {
|
||||
PluginAvailableCheck availableCheck;
|
||||
const uint8_t** selectors;
|
||||
const uint8_t* const* selectors;
|
||||
uint8_t num_selectors;
|
||||
char alias[10];
|
||||
PluginCall impl;
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
#include "os.h"
|
||||
#include "shared_context.h"
|
||||
#include "string.h"
|
||||
#include "lib_standard_app/crypto_helpers.h"
|
||||
#include "crypto_helpers.h"
|
||||
|
||||
#define ZERO(x) explicit_bzero(&x, sizeof(x))
|
||||
|
||||
void handle_check_address(check_address_parameters_t* params, chain_config_t* chain_config) {
|
||||
void handle_check_address(check_address_parameters_t* params, const chain_config_t* chain_config) {
|
||||
params->result = 0;
|
||||
PRINTF("Params on the address %d\n", (unsigned int) params);
|
||||
PRINTF("Address to check %s\n", params->address_to_check);
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
#include "chainConfig.h"
|
||||
|
||||
void handle_check_address(check_address_parameters_t* check_address_params,
|
||||
chain_config_t* chain_config);
|
||||
const chain_config_t* chain_config);
|
||||
|
||||
#endif // _HANDLE_CHECK_ADDRESS_H_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
static uint8_t* G_swap_sign_return_value_address;
|
||||
|
||||
bool copy_transaction_parameters(create_transaction_parameters_t* sign_transaction_params,
|
||||
chain_config_t* config) {
|
||||
const chain_config_t* config) {
|
||||
// first copy parameters to stack, and then to global data.
|
||||
// We need this "trick" as the input data position can overlap with app-ethereum globals
|
||||
txStringProperties_t stack_data;
|
||||
@@ -80,7 +80,7 @@ void __attribute__((noreturn)) finalize_exchange_sign_transaction(bool is_succes
|
||||
os_lib_end();
|
||||
}
|
||||
|
||||
void __attribute__((noreturn)) handle_swap_sign_transaction(chain_config_t* config) {
|
||||
void __attribute__((noreturn)) handle_swap_sign_transaction(const chain_config_t* config) {
|
||||
#ifdef HAVE_NBGL
|
||||
// On Stax, display a spinner at startup
|
||||
UX_INIT();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "chainConfig.h"
|
||||
|
||||
bool copy_transaction_parameters(create_transaction_parameters_t* sign_transaction_params,
|
||||
chain_config_t* config);
|
||||
const chain_config_t* config);
|
||||
|
||||
void __attribute__((noreturn)) handle_swap_sign_transaction(chain_config_t* config);
|
||||
void __attribute__((noreturn)) handle_swap_sign_transaction(const chain_config_t* config);
|
||||
|
||||
void __attribute__((noreturn)) finalize_exchange_sign_transaction(bool is_success);
|
||||
|
||||
14
src/main.c
@@ -31,7 +31,7 @@
|
||||
#include "commands_712.h"
|
||||
#include "challenge.h"
|
||||
#include "domain_name.h"
|
||||
#include "lib_standard_app/crypto_helpers.h"
|
||||
#include "crypto_helpers.h"
|
||||
|
||||
unsigned char G_io_seproxyhal_spi_buffer[IO_SEPROXYHAL_BUFFER_SIZE_B];
|
||||
|
||||
@@ -67,7 +67,7 @@ const internalStorage_t N_storage_real;
|
||||
#ifdef HAVE_NBGL
|
||||
caller_app_t *caller_app = NULL;
|
||||
#endif
|
||||
chain_config_t *chainConfig = NULL;
|
||||
const chain_config_t *chainConfig;
|
||||
|
||||
void reset_app_context() {
|
||||
// PRINTF("!!RESET_APP_CONTEXT\n");
|
||||
@@ -114,7 +114,7 @@ unsigned short io_exchange_al(unsigned char channel, unsigned short tx_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
extraInfo_t *getKnownToken(uint8_t *contractAddress) {
|
||||
extraInfo_t *getKnownToken(const uint8_t *contractAddress) {
|
||||
union extraInfo_t *currentItem = NULL;
|
||||
// Works for ERC-20 & NFT tokens since both structs in the union have the
|
||||
// contract address aligned
|
||||
@@ -456,7 +456,7 @@ void app_main(void) {
|
||||
// override point, but nothing more to do
|
||||
#ifdef HAVE_BAGL
|
||||
void io_seproxyhal_display(const bagl_element_t *element) {
|
||||
io_seproxyhal_display_default((bagl_element_t *) element);
|
||||
io_seproxyhal_display_default(element);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -526,7 +526,7 @@ void init_coin_config(chain_config_t *coin_config) {
|
||||
coin_config->chainId = CHAIN_ID;
|
||||
}
|
||||
|
||||
void coin_main(libargs_t *args) {
|
||||
__attribute__((noreturn)) void coin_main(libargs_t *args) {
|
||||
chain_config_t config;
|
||||
if (args) {
|
||||
if (args->chain_config != NULL) {
|
||||
@@ -612,10 +612,10 @@ void coin_main(libargs_t *args) {
|
||||
}
|
||||
END_TRY;
|
||||
}
|
||||
app_exit();
|
||||
os_sched_exit(-1);
|
||||
}
|
||||
|
||||
void library_main(libargs_t *args) {
|
||||
__attribute__((noreturn)) void library_main(libargs_t *args) {
|
||||
chain_config_t coin_config;
|
||||
if (args->chain_config == NULL) {
|
||||
// We have been started directly by Exchange, not by a Clone. Init default chain
|
||||
|
||||
@@ -147,7 +147,7 @@ typedef union {
|
||||
strDataTmp_t tmp;
|
||||
} strings_t;
|
||||
|
||||
extern chain_config_t *chainConfig;
|
||||
extern const chain_config_t *chainConfig;
|
||||
|
||||
extern tmpCtx_t tmpCtx;
|
||||
extern txContext_t txContext;
|
||||
|
||||
@@ -26,6 +26,6 @@ void ui_warning_contract_data(void);
|
||||
|
||||
void io_seproxyhal_send_status(uint32_t sw);
|
||||
void finalizeParsing(bool direct);
|
||||
extraInfo_t *getKnownToken(uint8_t *contractAddress);
|
||||
extraInfo_t *getKnownToken(const uint8_t *contractAddress);
|
||||
|
||||
#endif // _UI_CALLBACKS_H_
|
||||
|
||||
@@ -53,11 +53,9 @@ void shiftl128(const uint128_t *const number, uint32_t value, uint128_t *const t
|
||||
} else if (value < 64) {
|
||||
UPPER_P(target) = (UPPER_P(number) << value) + (LOWER_P(number) >> (64 - value));
|
||||
LOWER_P(target) = (LOWER_P(number) << value);
|
||||
} else if ((128 > value) && (value > 64)) {
|
||||
} else {
|
||||
UPPER_P(target) = LOWER_P(number) << (value - 64);
|
||||
LOWER_P(target) = 0;
|
||||
} else {
|
||||
clear128(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +72,9 @@ void shiftr128(const uint128_t *const number, uint32_t value, uint128_t *const t
|
||||
UPPER(result) = UPPER_P(number) >> value;
|
||||
LOWER(result) = (UPPER_P(number) << (64 - value)) + (LOWER_P(number) >> value);
|
||||
copy128(target, &result);
|
||||
} else if ((128 > value) && (value > 64)) {
|
||||
} else {
|
||||
LOWER_P(target) = UPPER_P(number) >> (value - 64);
|
||||
UPPER_P(target) = 0;
|
||||
} else {
|
||||
clear128(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,11 +59,9 @@ void shiftl256(const uint256_t *const number, uint32_t value, uint256_t *const t
|
||||
add128(&tmp1, &tmp2, &UPPER(result));
|
||||
shiftl128(&LOWER_P(number), value, &LOWER(result));
|
||||
copy256(target, &result);
|
||||
} else if ((256 > value) && (value > 128)) {
|
||||
} else {
|
||||
shiftl128(&LOWER_P(number), (value - 128), &UPPER_P(target));
|
||||
clear128(&LOWER_P(target));
|
||||
} else {
|
||||
clear256(target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +82,9 @@ void shiftr256(const uint256_t *const number, uint32_t value, uint256_t *const t
|
||||
shiftl128(&UPPER_P(number), (128 - value), &tmp2);
|
||||
add128(&tmp1, &tmp2, &LOWER(result));
|
||||
copy256(target, &result);
|
||||
} else if ((256 > value) && (value > 128)) {
|
||||
} else {
|
||||
shiftr128(&UPPER_P(number), (value - 128), &LOWER_P(target));
|
||||
clear128(&UPPER_P(target));
|
||||
} else {
|
||||
clear256(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,3 +58,20 @@ void reverseString(char *const str, uint32_t length) {
|
||||
str[j] = c;
|
||||
}
|
||||
}
|
||||
|
||||
int bytes_to_string(char *out, size_t outl, const void *value, size_t len) {
|
||||
if (outl <= 2) {
|
||||
// Need at least '0x' and 1 digit
|
||||
return -1;
|
||||
}
|
||||
if (strlcpy(out, "0x", outl) != 2) {
|
||||
goto err;
|
||||
}
|
||||
if (format_hex(value, len, out + 2, outl - 2) < 0) {
|
||||
goto err;
|
||||
}
|
||||
return 0;
|
||||
err:
|
||||
*out = '\0';
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#define _UINT_COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "format.h"
|
||||
|
||||
#define UPPER_P(x) x->elements[0]
|
||||
#define LOWER_P(x) x->elements[1]
|
||||
@@ -32,4 +35,6 @@ void read_u64_be(const uint8_t *const in, uint64_t *const out);
|
||||
uint64_t readUint64BE(const uint8_t *const buffer);
|
||||
void reverseString(char *const str, uint32_t length);
|
||||
|
||||
int bytes_to_string(char *out, size_t outl, const void *value, size_t len);
|
||||
|
||||
#endif //_UINT_COMMON_H_
|
||||
|
||||
@@ -2,9 +2,13 @@
|
||||
|
||||
#include "shared_context.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "uint_common.h"
|
||||
|
||||
void prepare_eth2_public_key() {
|
||||
snprintf(strings.tmp.tmp, 100, "0x%.*H", 48, tmpCtx.publicKeyContext.publicKey.W);
|
||||
bytes_to_string(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
tmpCtx.publicKeyContext.publicKey.W,
|
||||
48);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
@@ -57,7 +57,7 @@ UX_STEP_INIT(
|
||||
UX_STEP_CB(
|
||||
ux_712_step_approve,
|
||||
pb,
|
||||
ui_712_approve(NULL),
|
||||
ui_712_approve(),
|
||||
{
|
||||
&C_icon_validate_14,
|
||||
"Approve",
|
||||
@@ -65,7 +65,7 @@ UX_STEP_CB(
|
||||
UX_STEP_CB(
|
||||
ux_712_step_reject,
|
||||
pb,
|
||||
ui_712_reject(NULL),
|
||||
ui_712_reject(),
|
||||
{
|
||||
&C_icon_crossmark,
|
||||
"Reject",
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
#include "shared_context.h"
|
||||
#include "ui_callbacks.h"
|
||||
#include "common_712.h"
|
||||
#include "uint_common.h"
|
||||
|
||||
void prepare_domain_hash_v0() {
|
||||
snprintf(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
"0x%.*H",
|
||||
KECCAK256_HASH_BYTESIZE,
|
||||
tmpCtx.messageSigningContext712.domainHash);
|
||||
bytes_to_string(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
tmpCtx.messageSigningContext712.domainHash,
|
||||
KECCAK256_HASH_BYTESIZE);
|
||||
}
|
||||
|
||||
void prepare_message_hash_v0() {
|
||||
snprintf(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
"0x%.*H",
|
||||
KECCAK256_HASH_BYTESIZE,
|
||||
tmpCtx.messageSigningContext712.messageHash);
|
||||
bytes_to_string(strings.tmp.tmp,
|
||||
sizeof(strings.tmp.tmp),
|
||||
tmpCtx.messageSigningContext712.messageHash,
|
||||
KECCAK256_HASH_BYTESIZE);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
@@ -46,7 +45,7 @@ UX_STEP_NOCB_INIT(
|
||||
UX_STEP_CB(
|
||||
ux_sign_712_v0_flow_4_step,
|
||||
pbb,
|
||||
ui_712_approve_cb(NULL),
|
||||
ui_712_approve_cb(),
|
||||
{
|
||||
&C_icon_validate_14,
|
||||
"Sign",
|
||||
@@ -55,7 +54,7 @@ UX_STEP_CB(
|
||||
UX_STEP_CB(
|
||||
ux_sign_712_v0_flow_5_step,
|
||||
pbb,
|
||||
ui_712_reject_cb(NULL),
|
||||
ui_712_reject_cb(),
|
||||
{
|
||||
&C_icon_crossmark,
|
||||
"Cancel",
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Ledger Ethereum App
|
||||
* (c) 2016-2019 Ledger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "common_utils.h"
|
||||
|
||||
// NFT
|
||||
|
||||
#define COLLECTION_NAME_MAX_LEN 70
|
||||
|
||||
typedef struct nftInfo_t {
|
||||
uint8_t contractAddress[ADDRESS_LENGTH]; // must be first item
|
||||
char collectionName[COLLECTION_NAME_MAX_LEN + 1];
|
||||
} nftInfo_t;
|
||||
|
||||
// TOKENS
|
||||
|
||||
#define MAX_TICKER_LEN 11 // 10 characters + '\0'
|
||||
#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
|
||||
char ticker[MAX_TICKER_LEN];
|
||||
uint8_t decimals;
|
||||
} tokenDefinition_t;
|
||||
|
||||
// UNION
|
||||
|
||||
typedef union extraInfo_t {
|
||||
tokenDefinition_t token;
|
||||
nftInfo_t nft;
|
||||
} extraInfo_t;
|
||||
@@ -1,34 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Ledger Ethereum App
|
||||
* (c) 2016-2019 Ledger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef HAVE_NBGL
|
||||
#include "ux.h"
|
||||
#endif
|
||||
|
||||
typedef enum { CALLER_TYPE_CLONE, CALLER_TYPE_PLUGIN } e_caller_type;
|
||||
|
||||
typedef struct caller_app_t {
|
||||
const char *name;
|
||||
#ifdef HAVE_NBGL
|
||||
const nbgl_icon_details_t *icon;
|
||||
#endif
|
||||
char type; // does not have to be set by the caller app
|
||||
} caller_app_t;
|
||||
|
||||
extern caller_app_t *caller_app;
|
||||
@@ -1,311 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Ledger Ethereum App
|
||||
* (c) 2016-2019 Ledger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "asset_info.h"
|
||||
#include "common_utils.h"
|
||||
#include "lcx_ecfp.h"
|
||||
#include "lcx_sha3.h"
|
||||
|
||||
void array_hexstr(char *strbuf, const void *bin, unsigned int len) {
|
||||
while (len--) {
|
||||
*strbuf++ = HEXDIGITS[((*((char *) bin)) >> 4) & 0xF];
|
||||
*strbuf++ = HEXDIGITS[(*((char *) bin)) & 0xF];
|
||||
bin = (const void *) ((unsigned int) bin + 1);
|
||||
}
|
||||
*strbuf = 0; // EOS
|
||||
}
|
||||
|
||||
uint64_t u64_from_BE(const uint8_t *in, uint8_t size) {
|
||||
uint8_t i = 0;
|
||||
uint64_t res = 0;
|
||||
|
||||
while (i < size && i < sizeof(res)) {
|
||||
res <<= 8;
|
||||
res |= in[i];
|
||||
i++;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool u64_to_string(uint64_t src, char *dst, uint8_t dst_size) {
|
||||
// Copy the numbers in ASCII format.
|
||||
uint8_t i = 0;
|
||||
do {
|
||||
// Checking `i + 1` to make sure we have enough space for '\0'.
|
||||
if (i + 1 >= dst_size) {
|
||||
return false;
|
||||
}
|
||||
dst[i] = src % 10 + '0';
|
||||
src /= 10;
|
||||
i++;
|
||||
} while (src);
|
||||
|
||||
// Null terminate string
|
||||
dst[i] = '\0';
|
||||
|
||||
// Revert the string
|
||||
i--;
|
||||
uint8_t j = 0;
|
||||
while (j < i) {
|
||||
char tmp = dst[i];
|
||||
dst[i] = dst[j];
|
||||
dst[j] = tmp;
|
||||
i--;
|
||||
j++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool uint256_to_decimal(const uint8_t *value, size_t value_len, char *out, size_t out_len) {
|
||||
if (value_len > INT256_LENGTH) {
|
||||
// value len is bigger than INT256_LENGTH ?!
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t n[16] = {0};
|
||||
// Copy and right-align the number
|
||||
memcpy((uint8_t *) n + INT256_LENGTH - value_len, value, value_len);
|
||||
|
||||
// Special case when value is 0
|
||||
if (allzeroes(n, INT256_LENGTH)) {
|
||||
if (out_len < 2) {
|
||||
// Not enough space to hold "0" and \0.
|
||||
return false;
|
||||
}
|
||||
strlcpy(out, "0", out_len);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint16_t *p = n;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
n[i] = __builtin_bswap16(*p++);
|
||||
}
|
||||
int pos = out_len;
|
||||
while (!allzeroes(n, sizeof(n))) {
|
||||
if (pos == 0) {
|
||||
return false;
|
||||
}
|
||||
pos -= 1;
|
||||
unsigned int carry = 0;
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int rem = ((carry << 16) | n[i]) % 10;
|
||||
n[i] = ((carry << 16) | n[i]) / 10;
|
||||
carry = rem;
|
||||
}
|
||||
out[pos] = '0' + carry;
|
||||
}
|
||||
memmove(out, out + pos, out_len - pos);
|
||||
out[out_len - pos] = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool adjustDecimals(const char *src,
|
||||
size_t srcLength,
|
||||
char *target,
|
||||
size_t targetLength,
|
||||
uint8_t decimals) {
|
||||
uint32_t startOffset;
|
||||
uint32_t lastZeroOffset = 0;
|
||||
uint32_t offset = 0;
|
||||
if ((srcLength == 1) && (*src == '0')) {
|
||||
if (targetLength < 2) {
|
||||
return false;
|
||||
}
|
||||
target[0] = '0';
|
||||
target[1] = '\0';
|
||||
return true;
|
||||
}
|
||||
if (srcLength <= decimals) {
|
||||
uint32_t delta = decimals - srcLength;
|
||||
if (targetLength < srcLength + 1 + 2 + delta) {
|
||||
return false;
|
||||
}
|
||||
target[offset++] = '0';
|
||||
target[offset++] = '.';
|
||||
for (uint32_t i = 0; i < delta; i++) {
|
||||
target[offset++] = '0';
|
||||
}
|
||||
startOffset = offset;
|
||||
for (uint32_t i = 0; i < srcLength; i++) {
|
||||
target[offset++] = src[i];
|
||||
}
|
||||
target[offset] = '\0';
|
||||
} else {
|
||||
uint32_t sourceOffset = 0;
|
||||
uint32_t delta = srcLength - decimals;
|
||||
if (targetLength < srcLength + 1 + 1) {
|
||||
return false;
|
||||
}
|
||||
while (offset < delta) {
|
||||
target[offset++] = src[sourceOffset++];
|
||||
}
|
||||
if (decimals != 0) {
|
||||
target[offset++] = '.';
|
||||
}
|
||||
startOffset = offset;
|
||||
while (sourceOffset < srcLength) {
|
||||
target[offset++] = src[sourceOffset++];
|
||||
}
|
||||
target[offset] = '\0';
|
||||
}
|
||||
for (uint32_t i = startOffset; i < offset; i++) {
|
||||
if (target[i] == '0') {
|
||||
if (lastZeroOffset == 0) {
|
||||
lastZeroOffset = i;
|
||||
}
|
||||
} else {
|
||||
lastZeroOffset = 0;
|
||||
}
|
||||
}
|
||||
if (lastZeroOffset != 0) {
|
||||
target[lastZeroOffset] = '\0';
|
||||
if (target[lastZeroOffset - 1] == '.') {
|
||||
target[lastZeroOffset - 1] = '\0';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool amountToString(const uint8_t *amount,
|
||||
uint8_t amount_size,
|
||||
uint8_t decimals,
|
||||
const char *ticker,
|
||||
char *out_buffer,
|
||||
size_t out_buffer_size) {
|
||||
char tmp_buffer[100] = {0};
|
||||
|
||||
if (uint256_to_decimal(amount, amount_size, tmp_buffer, sizeof(tmp_buffer)) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t amount_len = strnlen(tmp_buffer, sizeof(tmp_buffer));
|
||||
uint8_t ticker_len = strnlen(ticker, MAX_TICKER_LEN);
|
||||
|
||||
if (ticker_len > 0) {
|
||||
if (out_buffer_size <= ticker_len + 1) {
|
||||
return false;
|
||||
}
|
||||
memcpy(out_buffer, ticker, ticker_len);
|
||||
out_buffer[ticker_len++] = ' ';
|
||||
}
|
||||
|
||||
if (adjustDecimals(tmp_buffer,
|
||||
amount_len,
|
||||
out_buffer + ticker_len,
|
||||
out_buffer_size - ticker_len - 1,
|
||||
decimals) == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
out_buffer[out_buffer_size - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
|
||||
void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
|
||||
uint8_t out[static ADDRESS_LENGTH]) {
|
||||
uint8_t hashAddress[CX_KECCAK_256_SIZE];
|
||||
CX_ASSERT(cx_keccak_256_hash(raw_pubkey + 1, 64, hashAddress));
|
||||
memmove(out, hashAddress + 12, ADDRESS_LENGTH);
|
||||
}
|
||||
|
||||
void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
|
||||
char out[static ADDRESS_LENGTH * 2],
|
||||
uint64_t chainId) {
|
||||
uint8_t hashAddress[CX_KECCAK_256_SIZE];
|
||||
CX_ASSERT(cx_keccak_256_hash(raw_pubkey + 1, 64, hashAddress));
|
||||
getEthAddressStringFromBinary(hashAddress + 12, out, chainId);
|
||||
}
|
||||
|
||||
bool getEthAddressStringFromBinary(uint8_t *address,
|
||||
char out[static ADDRESS_LENGTH * 2],
|
||||
uint64_t chainId) {
|
||||
// save some precious stack space
|
||||
union locals_union {
|
||||
uint8_t hashChecksum[INT256_LENGTH];
|
||||
uint8_t tmp[51];
|
||||
} locals_union;
|
||||
|
||||
uint8_t i;
|
||||
bool eip1191 = false;
|
||||
uint32_t offset = 0;
|
||||
switch (chainId) {
|
||||
case 30:
|
||||
case 31:
|
||||
eip1191 = true;
|
||||
break;
|
||||
}
|
||||
if (eip1191) {
|
||||
if (!u64_to_string(chainId, (char *) locals_union.tmp, sizeof(locals_union.tmp))) {
|
||||
return false;
|
||||
}
|
||||
offset = strnlen((char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
strlcat((char *) locals_union.tmp + offset, "0x", sizeof(locals_union.tmp) - offset);
|
||||
offset = strnlen((char *) locals_union.tmp, sizeof(locals_union.tmp));
|
||||
}
|
||||
for (i = 0; i < 20; i++) {
|
||||
uint8_t digit = address[i];
|
||||
locals_union.tmp[offset + 2 * i] = HEXDIGITS[(digit >> 4) & 0x0f];
|
||||
locals_union.tmp[offset + 2 * i + 1] = HEXDIGITS[digit & 0x0f];
|
||||
}
|
||||
if (cx_keccak_256_hash(locals_union.tmp, offset + 40, locals_union.hashChecksum) != CX_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < 40; i++) {
|
||||
uint8_t digit = address[i / 2];
|
||||
if ((i % 2) == 0) {
|
||||
digit = (digit >> 4) & 0x0f;
|
||||
} else {
|
||||
digit = digit & 0x0f;
|
||||
}
|
||||
if (digit < 10) {
|
||||
out[i] = HEXDIGITS[digit];
|
||||
} else {
|
||||
int v = (locals_union.hashChecksum[i / 2] >> (4 * (1 - i % 2))) & 0x0f;
|
||||
if (v >= 8) {
|
||||
out[i] = HEXDIGITS[digit] - 'a' + 'A';
|
||||
} else {
|
||||
out[i] = HEXDIGITS[digit];
|
||||
}
|
||||
}
|
||||
}
|
||||
out[40] = '\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Fills the `out` buffer with the lowercase string representation of the pubkey passed in as binary
|
||||
format by `in`. (eg: uint8_t*:0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB ->
|
||||
char*:"0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB\0" ).*/
|
||||
bool getEthDisplayableAddress(uint8_t *in, char *out, size_t out_len, uint64_t chainId) {
|
||||
if (out_len < 43) {
|
||||
strlcpy(out, "ERROR", out_len);
|
||||
return false;
|
||||
}
|
||||
out[0] = '0';
|
||||
out[1] = 'x';
|
||||
if (!getEthAddressStringFromBinary(in, out + 2, chainId)) {
|
||||
strlcpy(out, "ERROR", out_len);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* Ledger Ethereum App
|
||||
* (c) 2016-2019 Ledger
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
********************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "os.h"
|
||||
#include "cx.h"
|
||||
|
||||
#define WEI_TO_ETHER 18
|
||||
|
||||
#define ADDRESS_LENGTH 20
|
||||
#define INT128_LENGTH 16
|
||||
#define INT256_LENGTH 32
|
||||
|
||||
#define KECCAK256_HASH_BYTESIZE 32
|
||||
|
||||
static const char HEXDIGITS[] = "0123456789abcdef";
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
void array_hexstr(char *strbuf, const void *bin, unsigned int len);
|
||||
|
||||
uint64_t u64_from_BE(const uint8_t *in, uint8_t size);
|
||||
|
||||
bool u64_to_string(uint64_t src, char *dst, uint8_t dst_size);
|
||||
|
||||
bool uint256_to_decimal(const uint8_t *value, size_t value_len, char *out, size_t out_len);
|
||||
|
||||
bool amountToString(const uint8_t *amount,
|
||||
uint8_t amount_len,
|
||||
uint8_t decimals,
|
||||
const char *ticker,
|
||||
char *out_buffer,
|
||||
size_t out_buffer_size);
|
||||
|
||||
bool adjustDecimals(const char *src,
|
||||
size_t srcLength,
|
||||
char *target,
|
||||
size_t targetLength,
|
||||
uint8_t decimals);
|
||||
|
||||
void getEthAddressFromRawKey(const uint8_t raw_pubkey[static 65],
|
||||
uint8_t out[static ADDRESS_LENGTH]);
|
||||
|
||||
void getEthAddressStringFromRawKey(const uint8_t raw_pubkey[static 65],
|
||||
char out[static ADDRESS_LENGTH * 2],
|
||||
uint64_t chainId);
|
||||
|
||||
bool getEthAddressStringFromBinary(uint8_t *address,
|
||||
char out[static ADDRESS_LENGTH * 2],
|
||||
uint64_t chainId);
|
||||
|
||||
bool getEthDisplayableAddress(uint8_t *in, char *out, size_t out_len, uint64_t chainId);
|
||||
|
||||
static __attribute__((no_instrument_function)) inline int allzeroes(const void *buf, size_t n) {
|
||||
uint8_t *p = (uint8_t *) buf;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
if (p[i]) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
static __attribute__((no_instrument_function)) inline int ismaxint(uint8_t *buf, int n) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
if (buf[i] != 0xff) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@@ -1,224 +0,0 @@
|
||||
// clang-format off
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "os.h"
|
||||
#include "cx.h"
|
||||
|
||||
// Include other header compatible with plugins
|
||||
#include "asset_info.h"
|
||||
#include "caller_api.h"
|
||||
#include "common_utils.h"
|
||||
#include "plugin_utils.h"
|
||||
#include "tx_content.h"
|
||||
|
||||
/*************************************************************************************************
|
||||
* Comments provided in this file are quick reminders on the usage of the plugin interface *
|
||||
* Reading the real plugin documentation is GREATLY recommended. *
|
||||
* You can find the latest version here: *
|
||||
* https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp_plugins.adoc *
|
||||
*************************************************************************************************/
|
||||
|
||||
// Interface version. Will be updated every time a breaking change in the interface is introduced.
|
||||
typedef enum eth_plugin_interface_version_e {
|
||||
ETH_PLUGIN_INTERFACE_VERSION_1 = 1,
|
||||
ETH_PLUGIN_INTERFACE_VERSION_2 = 2,
|
||||
ETH_PLUGIN_INTERFACE_VERSION_3 = 3,
|
||||
ETH_PLUGIN_INTERFACE_VERSION_4 = 4,
|
||||
ETH_PLUGIN_INTERFACE_VERSION_5 = 5,
|
||||
ETH_PLUGIN_INTERFACE_VERSION_LATEST = 6,
|
||||
} eth_plugin_interface_version_t;
|
||||
|
||||
|
||||
// Codes for the different requests Ethereum can send to the plugin
|
||||
// The dispatch is handled by the SDK itself, the plugin code does not have to handle it
|
||||
typedef enum eth_plugin_msg_e {
|
||||
// Codes for actions the Ethereum app can ask the plugin to perform
|
||||
ETH_PLUGIN_INIT_CONTRACT = 0x0101,
|
||||
ETH_PLUGIN_PROVIDE_PARAMETER = 0x0102,
|
||||
ETH_PLUGIN_FINALIZE = 0x0103,
|
||||
ETH_PLUGIN_PROVIDE_INFO = 0x0104,
|
||||
ETH_PLUGIN_QUERY_CONTRACT_ID = 0x0105,
|
||||
ETH_PLUGIN_QUERY_CONTRACT_UI = 0x0106,
|
||||
|
||||
// Special request: the Ethereum app is checking if we are installed on the device
|
||||
ETH_PLUGIN_CHECK_PRESENCE = 0x01FF,
|
||||
} eth_plugin_msg_t;
|
||||
|
||||
|
||||
// Reply codes when responding to the Ethereum application
|
||||
typedef enum eth_plugin_result_e {
|
||||
// Unsuccessful return values
|
||||
ETH_PLUGIN_RESULT_ERROR = 0x00,
|
||||
ETH_PLUGIN_RESULT_UNAVAILABLE = 0x01,
|
||||
ETH_PLUGIN_RESULT_UNSUCCESSFUL = 0x02, // Used for comparison
|
||||
|
||||
// Successful return values
|
||||
ETH_PLUGIN_RESULT_SUCCESSFUL = 0x03, // Used for comparison
|
||||
ETH_PLUGIN_RESULT_OK = 0x04,
|
||||
ETH_PLUGIN_RESULT_OK_ALIAS = 0x05,
|
||||
ETH_PLUGIN_RESULT_FALLBACK = 0x06,
|
||||
} eth_plugin_result_t;
|
||||
|
||||
|
||||
// Format of UI the Ethereum application has to use for this plugin
|
||||
typedef enum eth_ui_type_e {
|
||||
// If uiType is UI_AMOUNT_ADDRESS, Ethereum will use the amount/address UI
|
||||
// the amount and address provided by the plugin will be used
|
||||
// If tokenLookup1 is set, the amount is provided for this token
|
||||
ETH_UI_TYPE_AMOUNT_ADDRESS = 0x01,
|
||||
|
||||
// If uiType is UI_TYPE_GENERIC, Ethereum will use the dedicated ETH plugin UI
|
||||
// the ETH application provides tokens if requested then prompts for each UI field
|
||||
// The first field is forced by the ETH app to be the name + version of the plugin handling the
|
||||
// request. The last field is the fee amount
|
||||
ETH_UI_TYPE_GENERIC = 0x02,
|
||||
} eth_ui_type_t;
|
||||
|
||||
|
||||
// Scratch objects and utilities available to the plugin READ-WRITE
|
||||
typedef struct ethPluginSharedRW_s {
|
||||
cx_sha3_t *sha3;
|
||||
} ethPluginSharedRW_t;
|
||||
|
||||
|
||||
// Transaction data available to the plugin READ-ONLY
|
||||
typedef struct ethPluginSharedRO_s {
|
||||
txContent_t *txContent;
|
||||
} ethPluginSharedRO_t;
|
||||
|
||||
|
||||
// Plugin-only memory allocated by the Ethereum application and used by the plugin.
|
||||
#define PLUGIN_CONTEXT_SIZE (5 * INT256_LENGTH)
|
||||
// It is recommended to cast the raw uin8_t array to a structure meaningful for your plugin
|
||||
// Helper to check that the actual plugin context structure is not bigger than the allocated memory
|
||||
#define ASSERT_SIZEOF_PLUGIN_CONTEXT(s) \
|
||||
_Static_assert(sizeof(s) <= PLUGIN_CONTEXT_SIZE, "Plugin context structure is too big.")
|
||||
|
||||
|
||||
/*
|
||||
* HANDLERS AND PARAMETERS
|
||||
* Parameters associated with the requests the Ethereum application can ask the plugin to perform
|
||||
* The plugin SDK will automatically call the relevant handler for the received code, so the plugin
|
||||
* has to define each of the handler functions declared below.
|
||||
*/
|
||||
|
||||
|
||||
// Init Contract
|
||||
|
||||
typedef struct ethPluginInitContract_s {
|
||||
eth_plugin_interface_version_t interfaceVersion;
|
||||
eth_plugin_result_t result;
|
||||
|
||||
// in
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
uint8_t *pluginContext;
|
||||
size_t pluginContextLength;
|
||||
const uint8_t *selector; // 4 bytes selector
|
||||
size_t dataSize;
|
||||
|
||||
char *alias; // 29 bytes alias if ETH_PLUGIN_RESULT_OK_ALIAS set
|
||||
|
||||
} ethPluginInitContract_t;
|
||||
// void handle_init_contract(ethPluginInitContract_t *parameters);
|
||||
|
||||
|
||||
// Provide parameter
|
||||
|
||||
typedef struct ethPluginProvideParameter_s {
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
|
||||
const uint8_t *parameter; // 32 bytes parameter
|
||||
uint32_t parameterOffset;
|
||||
|
||||
eth_plugin_result_t result;
|
||||
|
||||
} ethPluginProvideParameter_t;
|
||||
// void handle_provide_parameter(ethPluginProvideParameter_t *parameters);
|
||||
|
||||
|
||||
// Finalize
|
||||
|
||||
typedef struct ethPluginFinalize_s {
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
|
||||
|
||||
uint8_t *tokenLookup1; // set by the plugin if a token should be looked up
|
||||
uint8_t *tokenLookup2;
|
||||
|
||||
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
|
||||
|
||||
eth_ui_type_t uiType;
|
||||
uint8_t numScreens; // ignored if uiType is UI_AMOUNT_ADDRESS
|
||||
eth_plugin_result_t result;
|
||||
|
||||
} ethPluginFinalize_t;
|
||||
// void handle_finalize(ethPluginFinalize_t *parameters);
|
||||
|
||||
|
||||
// Provide token
|
||||
|
||||
typedef struct ethPluginProvideInfo_s {
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
|
||||
|
||||
union extraInfo_t *item1; // set by the ETH application, to be saved by the plugin
|
||||
union extraInfo_t *item2;
|
||||
|
||||
uint8_t additionalScreens; // Used by the plugin if it needs to display additional screens
|
||||
// based on the information received from the token definitions.
|
||||
|
||||
eth_plugin_result_t result;
|
||||
|
||||
} ethPluginProvideInfo_t;
|
||||
// void handle_provide_token(ethPluginProvideInfo_t *parameters);
|
||||
|
||||
|
||||
// Query Contract name and version
|
||||
|
||||
// This is always called on the non aliased contract
|
||||
|
||||
typedef struct ethQueryContractID_s {
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
|
||||
|
||||
char *name;
|
||||
size_t nameLength;
|
||||
char *version;
|
||||
size_t versionLength;
|
||||
|
||||
eth_plugin_result_t result;
|
||||
|
||||
} ethQueryContractID_t;
|
||||
// void handle_query_contract_id(ethQueryContractID_t *parameters);
|
||||
|
||||
|
||||
// Query Contract UI
|
||||
|
||||
typedef struct ethQueryContractUI_s {
|
||||
ethPluginSharedRW_t *pluginSharedRW;
|
||||
ethPluginSharedRO_t *pluginSharedRO;
|
||||
union extraInfo_t *item1;
|
||||
union extraInfo_t *item2;
|
||||
char network_ticker[MAX_TICKER_LEN];
|
||||
uint8_t *pluginContext; // PLUGIN_CONTEXT_SIZE
|
||||
uint8_t screenIndex;
|
||||
|
||||
char *title;
|
||||
size_t titleLength;
|
||||
char *msg;
|
||||
size_t msgLength;
|
||||
|
||||
eth_plugin_result_t result;
|
||||
|
||||
} ethQueryContractUI_t;
|
||||
// void handle_query_contract_ui(ethQueryContractUI_t *parameters);
|
||||
|
||||
// clang-format on
|
||||
@@ -1,42 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "common_utils.h"
|
||||
#include "plugin_utils.h"
|
||||
|
||||
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, const uint8_t* parameter, uint8_t dst_size) {
|
||||
uint8_t copy_size = MIN(dst_size, PARAMETER_LENGTH);
|
||||
memmove(dst, parameter, copy_size);
|
||||
}
|
||||
|
||||
bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value) {
|
||||
if (allzeroes(parameter, PARAMETER_LENGTH - sizeof(uint16_t))) {
|
||||
*value = U2BE(parameter, PARAMETER_LENGTH - sizeof(uint16_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value) {
|
||||
if (allzeroes(parameter, PARAMETER_LENGTH - sizeof(uint32_t))) {
|
||||
*value = U4BE(parameter, PARAMETER_LENGTH - sizeof(uint32_t));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool find_selector(uint32_t selector, const uint32_t* array, size_t size, size_t* idx) {
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
if (selector == array[i]) {
|
||||
if (idx != NULL) *idx = i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Ledger
|
||||
* (c) 2023 Ledger SAS
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "eth_plugin_interface.h"
|
||||
|
||||
#define SELECTOR_SIZE 4
|
||||
#define PARAMETER_LENGTH 32
|
||||
|
||||
void copy_address(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
|
||||
|
||||
void copy_parameter(uint8_t* dst, const uint8_t* parameter, uint8_t dst_size);
|
||||
|
||||
// Get the value from the beginning of the parameter (right to left) and check if the rest of it is
|
||||
// zero
|
||||
bool U2BE_from_parameter(const uint8_t* parameter, uint16_t* value);
|
||||
bool U4BE_from_parameter(const uint8_t* parameter, uint32_t* value);
|
||||
|
||||
bool find_selector(uint32_t selector, const uint32_t* array, size_t size, size_t* idx);
|
||||