Skip to content

Commit

Permalink
Merge pull request #7 from LedgerHQ/develop
Browse files Browse the repository at this point in the history
re-align versions Blooo vs Ledger
  • Loading branch information
n4l5u0r authored Aug 9, 2022
2 parents 89cfdae + b230a65 commit 848a2fa
Show file tree
Hide file tree
Showing 19 changed files with 78 additions and 298 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop

jobs:
job_build_debug:
Expand All @@ -24,6 +26,7 @@ jobs:

- name: Build Ledger NFT plugin
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make DEBUG=1
- name: Upload Ledger NFT binary
Expand All @@ -45,6 +48,7 @@ jobs:

- name: Build with Clang Static Analyzer
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
scan-build --use-cc=clang -analyze-headers -enable-checker security -enable-checker unix -enable-checker valist -o scan-build --status-bugs make default
- uses: actions/upload-artifact@v2
Expand All @@ -66,6 +70,7 @@ jobs:

- name: Build with cov-build
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
cov-build --dir cov-int make default
- name: Submit the result to Coverity Scan
Expand Down Expand Up @@ -93,6 +98,7 @@ jobs:
submodules: recursive
- name: Build plugin for Nano S
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make BOLOS_SDK=$NANOS_SDK
- name: Move binary to test directory
Expand All @@ -117,6 +123,7 @@ jobs:
submodules: recursive
- name: Build plugin for Nano S+
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make BOLOS_SDK=$NANOSP_SDK
- name: Move binary to test directory
Expand All @@ -141,6 +148,7 @@ jobs:
submodules: recursive
- name: Build plugin for Nano X
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make BOLOS_SDK=$NANOX_SDK
- name: Move binary to test directory
Expand All @@ -167,6 +175,7 @@ jobs:
submodules: recursive
- name: Build ethereum
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOS_SDK CHAIN=ethereum ALLOW_DATA=1
- name: Move binary to test directory
Expand All @@ -193,6 +202,7 @@ jobs:
submodules: recursive
- name: Build ethereum
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOSP_SDK CHAIN=ethereum ALLOW_DATA=1
- name: Move binary to test directory
Expand All @@ -219,6 +229,7 @@ jobs:
submodules: recursive
- name: Build ethereum
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
make clean
make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK=$NANOX_SDK CHAIN=ethereum ALLOW_DATA=1
- name: Move binary to test directory
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ APP_LOAD_PARAMS += $(COMMON_LOAD_PARAMS)

APPVERSION_M = 1
APPVERSION_N = 0
APPVERSION_P = 0
APPVERSION_P = 1
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)

APPNAME = "LedgerNFT"
APPNAME = "[ L ] Market"

#prepare hsm generation
ifeq ($(TARGET_NAME), TARGET_NANOS)
Expand Down
19 changes: 19 additions & 0 deletions src/contract.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "ledger_nft_plugin.h"

// Function: mint
// Selector: 0x1249c58b
static const uint8_t MINT_SELECTOR[SELECTOR_SIZE] = {0x12, 0x49, 0xc5, 0x8b};
// Function: preSaleMint
// Selector: 0xc111fb91
static const uint8_t PRE_SALE_MINT_SELECTOR[SELECTOR_SIZE] = {0xc1, 0x11, 0xfb, 0x91};

// Plugin uses 0x00000 as a dummy address to reprecent ETH.
const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

// Array of all the different nft selectors.
const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS] = {
MINT_SELECTOR,
PRE_SALE_MINT_SELECTOR,
};
2 changes: 1 addition & 1 deletion src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void handle_query_contract_id(void *parameters) {
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
context_t *context = (context_t *) msg->pluginContext;

strlcpy(msg->name, "[L] Market", msg->nameLength);
strlcpy(msg->name, "[ L ] Market", msg->nameLength);

switch (context->selectorIndex) {
case MINT:
Expand Down
4 changes: 2 additions & 2 deletions src/handle_query_contract_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ static void set_amount_ui(ethQueryContractUI_t *msg, context_t *context) {
}

// Helper function that returns the enum corresponding to the screen that should be displayed.
static screens_t get_screen(const ethQueryContractUI_t *msg, const context_t *context) {
static screens_t get_screen(const ethQueryContractUI_t *msg,
const context_t *context __attribute__((unused))) {
uint8_t index = msg->screenIndex;

switch (index) {
case 0:
return AMOUNT_SCREEN;
default:
return ERROR;
break;
}
}

Expand Down
18 changes: 0 additions & 18 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,6 @@

#include "ledger_nft_plugin.h"

// Function: mint
// Selector: 0x1249c58b
static const uint8_t MINT_SELECTOR[SELECTOR_SIZE] = {0x12, 0x49, 0xc5, 0x8b};
// Function: preSaleMint
// Selector: 0xc111fb91
static const uint8_t PRE_SALE_MINT_SELECTOR[SELECTOR_SIZE] = {0xc1, 0x11, 0xfb, 0x91};

// Plugin uses 0x00000 as a dummy address to reprecent ETH.
const uint8_t NULL_ETH_ADDRESS[ADDRESS_LENGTH] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

// Array of all the different nft selectors.
const uint8_t *const LEDGER_NFT_SELECTORS[NUM_SELECTORS] = {
MINT_SELECTOR,
PRE_SALE_MINT_SELECTOR,
};

// Function to dispatch calls from the ethereum app.
void dispatch_plugin_calls(int message, void *parameters) {
switch (message) {
Expand Down
2 changes: 1 addition & 1 deletion tests/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ module.exports = {
// Path of the file where tests can be """decorated"""
setupFilesAfterEnv: ['<rootDir>/setupTests.js'],

// Stop immediatly when a test fail
// Stop immediately when a test fail
bail: true,
};
17 changes: 4 additions & 13 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,12 @@
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@ledgerhq/hw-app-eth": "^6.27.1",
"@ledgerhq/hw-transport-http": "^6.27.1",
"@ledgerhq/logs": "^6.2.0",
"@zondax/zemu": "^0.29.0",
"bignumber.js": "^9.0.0",
"bip32-path": "^0.4.2",
"core-js": "^3.7.0",
"ethereum-tx-decoder": "^3.0.0",
"@zondax/zemu": "^0.32.0",
"ethers": "^5.4.7",
"fs-extra": "^10.0.0",
"google-protobuf": "^3.11.0",
"jest": "^26.6.3",
"jest-serial-runner": "^1.1.0",
"js-sha256": "^0.9.0",
"regenerator-runtime": "^0.13.7",
"secp256k1": "^3.7.1"
"regenerator-runtime": "^0.13.7"
},
"devDependencies": {
"@babel/cli": "^7.7.0",
Expand All @@ -36,7 +28,6 @@
"@babel/preset-flow": "^7.0.0",
"@babel/preset-stage-0": "^7.0.0",
"@babel/register": "^7.7.0",
"flow-bin": "^0.112.0",
"jest": "^26.6.3"
"flow-bin": "^0.112.0"
}
}
Binary file modified tests/snapshots/ethereum_nanos_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/ethereum_nanos_pre_sale_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/ethereum_nanosp_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/ethereum_nanosp_pre_sale_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/ethereum_nanox_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/snapshots/ethereum_nanox_pre_sale_mint/00001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion tests/src/generate_plugin_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function generate_plugin_config(testNetwork) {
var fs = require('fs');
var files = fs.readdirSync(`networks/${testNetwork}/${pluginFolder}/abis/`);

// `contracts_to_abis` holds a maping of contract addresses to abis
// `contracts_to_abis` holds a mapping of contract addresses to abis
let contracts_to_abis = {};
for (let abiFileName of files) {
assert(abiFileName.toLocaleLowerCase() == abiFileName, `FAILED: File ${abiFileName} should be lower case.`);
Expand Down
2 changes: 0 additions & 2 deletions tests/src/mint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const value = "12.0";
// Create serializedTx and remove the "0x" prefix
const serializedTx = populateTransaction(contractAddr, inputData, chainID, value);


populateTransaction
const devices = [
{
name: "nanos",
Expand Down
2 changes: 0 additions & 2 deletions tests/src/preSaleMint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ const inputData = selector + signature;
// Create serializedTx and remove the "0x" prefix
const serializedTx = populateTransaction(contractAddr, inputData, chainID, value);


populateTransaction
const devices = [
{
name: "nanos",
Expand Down
2 changes: 1 addition & 1 deletion tests/src/test.fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function zemu(device, func, testNetwork, signed = false) {
}

/**
* Process the trasaction through the full test process in interaction with the simulator
* Process the transaction through the full test process in interaction with the simulator
* @param {Eth} eth Device to test (nanos, nanox)
* @param {function} sim Zemu simulator
* @param {int} steps Number of steps to push right button
Expand Down
Loading

0 comments on commit 848a2fa

Please sign in to comment.