Skip to content

Commit

Permalink
Merge pull request #82 from LedgerHQ/cev/B2CA-1838_implement-swap
Browse files Browse the repository at this point in the history
B2CA-1838: Implement swap
  • Loading branch information
cedelavergne-ledger authored Dec 12, 2024
2 parents 711f647 + 861f5bc commit 908f4df
Show file tree
Hide file tree
Showing 343 changed files with 39,489 additions and 31,715 deletions.
18 changes: 18 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
BasedOnStyle: Google
IndentWidth: 4
Language: Cpp
ColumnLimit: 100
PointerAlignment: Right
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AllowAllParametersOfDeclarationOnNextLine: false
SortIncludes: false
SpaceAfterCStyleCast: true
AllowShortCaseLabelsOnASingleLine: false
AllowAllArgumentsOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None
BinPackArguments: false
BinPackParameters: false
---
2 changes: 1 addition & 1 deletion .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ FROM gcr.io/oss-fuzz-base/base-builder:v1
COPY . $SRC/app-cardano
COPY ./.clusterfuzzlite/build.sh $SRC/
COPY --from=LITE_BUILDER /opt/ledger-secure-sdk $SRC/app-cardano/BOLOS_SDK
WORKDIR $SRC/app-cardano
WORKDIR $SRC/app-cardano
2 changes: 1 addition & 1 deletion .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pushd fuzzing
cmake -DBOLOS_SDK=../BOLOS_SDK -Bbuild -H.
make -C build
mv build/*_harness $OUT
popd
popd
2 changes: 1 addition & 1 deletion .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
language: c
language: c
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Checklist

<!-- Put an `x` in each box when you have completed the items. -->

- [ ] App update process has been followed <!-- See comment below -->
- [ ] Target branch is `develop` <!-- unless you have a very good reason -->
- [ ] Application version has been bumped <!-- required if your changes are to be deployed -->

<!-- Make sure you followed the process described in https://developers.ledger.com/docs/device-app/deliver/maintenance before opening your Pull Request.
<!-- Make sure you followed the process described in https://developers.ledger.com/docs/device-app/deliver/maintenance
before opening your Pull Request.
Don't hesitate to contact us directly on Discord if you have any questions ! https://developers.ledger.com/discord -->
41 changes: 41 additions & 0 deletions .github/workflows/build_and_functional_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and run functional tests using ragger through reusable workflow

# This workflow will build the app and then run functional tests using the Ragger framework upon Speculos emulation.
# It calls a reusable workflow developed by Ledger's internal developer team to build the application and upload the
# resulting binaries.
# It then calls another reusable workflow to run the Ragger tests on the compiled application binary.
#
# While this workflow is optional, having functional testing on your application is mandatory and this workflow and
# tooling environment is meant to be easy to use and adapt after forking your application

on:
workflow_dispatch:
inputs:
golden_run:
type: choice
required: true
default: 'Raise an error (default)'
description: CI behavior if the test snapshots are different than expected.
options:
- 'Raise an error (default)'
- 'Open a PR'
push:
branches:
- master
- develop
pull_request:

jobs:
build_application:
name: Build application using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "compiled_app_binaries"

ragger_tests:
name: Run ragger tests using the reusable workflow
needs: build_application
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_ragger_tests.yml@v1
with:
download_app_binaries_artifact: "compiled_app_binaries"
regenerate_snapshots: ${{ inputs.golden_run == 'Open a PR' }}
1 change: 0 additions & 1 deletion .github/workflows/cflite_cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,3 @@ jobs:
fuzz-seconds: 300 # 5 minutes
mode: ${{ matrix.mode }}
sanitizer: ${{ matrix.sanitizer }}

2 changes: 1 addition & 1 deletion .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
# batch fuzzing.
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git
# storage-repo-branch: main # Optional. Defaults to "main"
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_build.yml@v1
with:
upload_app_binaries_artifact: "compiled_app_binaries"

build_and_test:
name: Build and test app for all supported devices
strategy:
Expand All @@ -25,14 +25,14 @@ jobs:
runs-on: ubuntu-latest
container:
image: ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build application in developer + headless mode
id: "build"
shell: bash
run: |
run: |
eval "BOLOS_SDK=\$$(echo ${{ matrix.device }} | tr [:lower:] [:upper:])_SDK" && \
echo "BOLOS_SDK value will be: ${BOLOS_SDK}" && \
BOLOS_SDK=${BOLOS_SDK} DEVEL=1 DEFINES+=HEADLESS make
Expand All @@ -47,7 +47,7 @@ jobs:
run: |
BUILD_DEVICE_NAME="$(echo ${{ matrix.device }} | sed 's/nanosp/nanos2/')"
speculos --model ${{ matrix.device }} build/$BUILD_DEVICE_NAME/bin/app.elf --seed "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about" --display headless &
apk add g++ libusb-dev libusb eudev-dev eudev &&
apk add g++ libusb-dev libusb eudev-dev eudev &&
cd ledgerjs-cardano-shelley &&
yarn install &&
yarn test-speculos
25 changes: 25 additions & 0 deletions .github/workflows/coding_style_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Run coding style check through reusable workflow

# This workflow will run linting checks to ensure a level of uniformization among all Ledger applications.
#
# The presence of this workflow is mandatory as a minimal level of linting is required.
# You are however free to modify the content of the .clang-format file and thus the coding style of your application.
# We simply ask you to not diverge too much from the linting of the Boilerplate application.

on:
workflow_dispatch:
push:
branches:
- master
- main
- develop
pull_request:

jobs:
check_linting:
name: Check linting using the reusable workflow
uses: LedgerHQ/ledger-app-workflows/.github/workflows/reusable_lint.yml@v1
with:
source: './src'
extensions: 'h,c'
version: 11
28 changes: 28 additions & 0 deletions .github/workflows/misspellings_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Misspellings checks

# This workflow performs some misspelling checks on the repository
# It is there to help us maintain a level of quality in our codebase and does not have to be kept on forked
# applications.

on:
workflow_dispatch:
push:
branches:
- master
- develop
pull_request:

jobs:
misspell:
name: Check misspellings
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4

- name: Check misspellings
uses: codespell-project/actions-codespell@v2
with:
builtin: clear,rare
check_filenames: true
ignore_words_list: cips
42 changes: 42 additions & 0 deletions .github/workflows/python_client_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Checks on the Python client

# This workflow performs some checks on the Python client used by the Application tests
# It is there to help us maintain a level of quality in our codebase and does not have to be kept on forked
# applications.

on:
workflow_dispatch:
push:
branches:
- master
- develop
pull_request:

jobs:
lint:
name: Client linting
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Installing PIP dependencies
run: |
pip install pylint
pip install -r tests/requirements.txt
- name: Lint Python code
run: |
pylint --rc tests/setup.cfg tests/application_client/
mypy:
name: Type checking
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Installing PIP dependencies
run: |
pip install mypy
pip install -r tests/requirements.txt
- name: Mypy type checking
run: |
mypy tests/application_client/
17 changes: 17 additions & 0 deletions .github/workflows/swap-ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
name: Swap functional tests

on:
workflow_dispatch:
push:
branches:
- master
- develop
pull_request:

jobs:
job_functional_tests:
uses: LedgerHQ/app-exchange/.github/workflows/reusable_swap_functional_tests.yml@develop
with:
branch_for_cardano: ${{ github.ref }}
test_filter: '"ADA or ada or Cardano or cardano"'
26 changes: 18 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
ledger
bin
# Compilation files of the application
build

# Legacy compilation output
bin
debug
dep
obj
src/u2f_crypto_data.h
src/glyphs.h
src/glyphs.c
.vscode

# Temporary directory with snapshots taken during test runs
tests/snapshots-tmp/

# Fuzzing
fuzz/build
fuzz/corpus
fuzz/coverage

# Python
__pycache__/
venv/

# IDE
.vscode

# Virtual env for sideload (macOS and Windows)
ledger/
11 changes: 11 additions & 0 deletions .mdl.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Style file for mdl
# https://github.com/markdownlint/markdownlint/blob/main/docs/creating_styles.md

# Include all rules
all

# Disable specific rules
#exclude_rule 'MD012'

# Update rules configuration
rule 'MD013', :line_length => 130, :tables => false
13 changes: 13 additions & 0 deletions .mdlrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# markdownlint config file

# Use custom style file
style "#{File.dirname(__FILE__)}/.mdl.rb"

# MD005 - Inconsistent indentation for list items at the same level
# MD007 - Unordered list indentation
# MD014 - Dollar signs used before commands without showing output
# MD024 - Multiple headers with the same content
# MD041 - First line in file should be a top level header
# MD036 - Emphasis used instead of a header
# MD029 - Ordered list item prefix
rules "~MD005,~MD007,~MD014,~MD024,~MD041,~MD036,~MD029"
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# To install hooks, run:
# pre-commit install --hook-type pre-commit
# pre-commit install --hook-type commit-msg

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: mixed-line-ending
- id: check-added-large-files
- id: check-merge-conflict
- id: check-case-conflict

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
args: ['--ignore-words-list', 'cips']

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v11.0.1
hooks:
- id: clang-format
types_or: [c]

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.3.17
hooks:
- id: actionlint
types_or: [yaml]
args: [-shellcheck="" -pyflakes=""]


- repo: https://github.com/markdownlint/markdownlint
rev: v0.13.0
hooks:
- id: markdownlint
types_or: [markdown]

- repo: local
hooks:

# Python scripts
- id: pylint
name: Check python Client
# Only display messages, no score, disable few errors
entry: pylint -j 0 --rc tests/setup.cfg
language: system
types: [python]
files: '^tests\/.*$'
Loading

0 comments on commit 908f4df

Please sign in to comment.