Fix various Linter issues and mispelling

This commit is contained in:
Charles-Edouard de la Vergne
2024-03-18 17:28:51 +01:00
parent 36ae183a1c
commit f5ea9c51c2
100 changed files with 229 additions and 220 deletions

View File

@@ -19,8 +19,8 @@ Describe your issue in as much detail as possible here.
## Steps to reproduce
* Tell us how to reproduce this issue <br />
* Where the issue is, if you know <br />
* Tell us how to reproduce this issue
* Where the issue is, if you know
* Which commands triggered the issue, if any
## Expected behaviour
@@ -37,4 +37,5 @@ Please paste any logs here that demonstrate the issue, if they exist
## Proposed solution
If you have an idea of how to fix this issue, please write it down here, so we can begin discussing it
If you have an idea of how to fix this issue, please write it down here,
so we can begin discussing it

View File

@@ -8,6 +8,7 @@ assignees: ''
---
## Description
- [ ] Symbol:
- [ ] ChainId:
- [ ] Website:

4
.gitignore vendored
View File

@@ -1,10 +1,6 @@
# Compilation of Ledger's app
src/glyphs.c
src/glyphs.h
bin/
debug/
dep/
obj/
build/
# Python

View File

@@ -211,7 +211,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added
- Provide network ticker to plugins (especialy helpful for Paraswap plugin)
- Provide network ticker to plugins (especially helpful for Paraswap plugin)
- Polygon variant
## [1.9.10](https://github.com/ledgerhq/app-ethereum/compare/1.9.9...1.9.10) - 2021-10-08

View File

@@ -38,9 +38,9 @@ APPVERSION_P = 1
APPVERSION = $(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-dev
APP_LOAD_FLAGS = --appFlags 0xa40 --dep Ethereum:$(APPVERSION)
###########################
# Set Chain environnement #
###########################
#########################
# Set Chain environment #
#########################
ifeq ($(CHAIN),)
CHAIN = ethereum

View File

@@ -31,13 +31,12 @@
- [Running all tests](#running-all-tests)
- [With Makefile](#with-makefile)
- [With yarn](#with-yarn)
- [Running a specific tests](#running-a-specific-tests)
- [Running a specific test](#running-a-specific-test)
- [Adding tests](#adding-tests)
- [Zemu](#zemu)
- [Update binaries](#update-binaries)
- [Contributing](#contributing)
</details>
## About the project
@@ -55,6 +54,7 @@ To compile it and load it on a device, please check out our [developer portal](h
We have the concept of plugins in the ETH app.
Find the documentations here:
- [Blog Ethereum plugins](https://blog.ledger.com/ethereum-plugins/)
- [Ethereum application Plugins : Technical Specifications](https://github.com/LedgerHQ/app-ethereum/blob/master/doc/ethapp_plugins.asc)
- [Plugin guide](https://hackmd.io/300Ukv5gSbCbVcp3cZuwRQ)
@@ -68,15 +68,17 @@ Testing is done via the open-source framework [zemu](https://github.com/Zondax/z
- [nodeJS == 16](https://github.com/nvm-sh/nvm)
- [yarn](https://classic.yarnpkg.com/lang/en/docs/install/#debian-stable)
- [build environnement](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
- [build environment](https://github.com/LedgerHQ/ledger-app-builder/blob/master/Dockerfile)
#### Build the applications required by the test suite
1. Add your BOLOS SDKs path to:
- `NANOS_SDK` and `NANOX_SDK`
`NANOS_SDK` and `NANOX_SDK`
2. Go to the `tests` folder and run `./build_local_test_elfs.sh`
- ```sh
```sh
cd tests
# This helper script will build the applications required by the test suite and move them at the right place.
yarn install
@@ -84,33 +86,38 @@ Testing is done via the open-source framework [zemu](https://github.com/Zondax/z
```
### Running all tests
#### With Makefile
1. Then you can install and run tests by simply running on the `root` of the repo:
- ```sh
```sh
make test
# This will run `make install_tests` and `make run_tests`
```
- This will run `make install_tests` and `make run_tests`
#### With yarn
1. Go to the `tests` folder and run:
- ```sh
```sh
yarn test
```
### Running a specific tests
### Running a specific test
1. Go to the `tests` folder and run:
- ```sh
```sh
yarn jest --runInBand --detectOpenHandles {YourTestFile}
```
2. For example with the `send test`:
- ```sh
```sh
yarn jest --runInBand --detectOpenHandles src/send.test.js
```
### Adding tests
#### Zemu
@@ -128,7 +135,7 @@ Finally make sure you adapt the expected signature!
#### Update binaries
Don't forget to update the binaries in the test folder. To do so, compile with those environement variables:
Don't forget to update the binaries in the test folder. To do so, compile with those environment variables:
```sh
make DEBUG=1 ALLOW_DATA=1
@@ -142,10 +149,9 @@ cp bin/app.elf tests/elfs/ethereum_nanos.elf
Repeat the operation for a binary compiled with nanoX SDK and change for `ethereum_nanox.elf`.
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag `enhancement`.

View File

@@ -12,7 +12,7 @@ This document described how a specific device UI for a smart contract can be add
## Standard support
The applications already includes dedicated UI support for those specific contract calls :
The application already includes dedicated UI support for those specific contract calls :
* ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval*
* ERC 20 transfer(address, uint256) - implementation in *src_features/signTx*
@@ -45,4 +45,3 @@ A UI implementation might want to convert an ERC 20 token contract address to a
2 tickers can be temporarily provisioned to the application by using the PROVIDE ERC 20 TOKEN INFORMATION APDU, described in *src_features/provideErc20TokenInformation* - the UI can then iterate on the provisioned tickers to display relevant information to the user
The same mechanism will be extended to support well known contract addresses in the future

View File

@@ -801,7 +801,7 @@ None
This command provides a trusted way of deciding what information from the JSON data to show and replace some values by more meaningful ones.
This mode can be overriden by the in-app setting to fully clear-sign EIP-712 messages.
This mode can be overridden by the in-app setting to fully clear-sign EIP-712 messages.
For the signatures :

View File

@@ -518,7 +518,7 @@ static parserStatus_e processTxInternal(txContext_t *context) {
PRINTF("parsing is done\n");
return USTREAM_FINISHED;
}
// Old style transaction (pre EIP-155). Transations could just skip `v,r,s` so we needed to
// Old style transaction (pre EIP-155). Transactions could just skip `v,r,s` so we needed to
// cut parsing here. commandLength == 0 could happen in two cases :
// 1. We are in an old style transaction : just return `USTREAM_FINISHED`.
// 2. We are at the end of an APDU in a multi-apdu process. This would make us return

View File

@@ -412,7 +412,7 @@ void handleApdu(unsigned int *flags, unsigned int *tx) {
// If we are in swap mode and have validated a TX, we send it and immediately quit
if (quit_now) {
if (io_exchange(CHANNEL_APDU | IO_RETURN_AFTER_TX, *tx) == 0) {
// In case of success, the apdu is sent immediatly and eth exits
// In case of success, the apdu is sent immediately and eth exits
// Reaching this code means we encountered an error
finalize_exchange_sign_transaction(false);
} else {

View File

@@ -13,7 +13,7 @@ typedef struct network_info_s {
static const char *unknown_ticker = "???";
// Mappping of chain ids to networks.
// Mapping of chain ids to networks.
static const network_info_t NETWORK_MAPPING[] = {
{.chain_id = 1, .name = "Ethereum", .ticker = "ETH"},
{.chain_id = 3, .name = "Ropsten", .ticker = "ETH"},
@@ -153,7 +153,7 @@ const char *get_displayable_ticker(const uint64_t *chain_id, const chain_config_
}
/**
* Checks wether the app can support the given chain ID
* Checks whether the app can support the given chain ID
*
* - If the given chain ID is the same as the app's one
* - If both chain IDs are present in the array of Ethereum-compatible networks

View File

@@ -90,7 +90,7 @@ typedef struct ethPluginSharedRO_s {
// 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 meaningfull for your plugin
// 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.")

View File

@@ -444,7 +444,7 @@ static bool check_found_tlv_tags(s_tlv_handler *handlers, int handler_count) {
// prevent missing or duplicated tags
for (int idx = 0; idx < handler_count; ++idx) {
if (handlers[idx].found != 1) {
PRINTF("Found %u occurence(s) of tag 0x%x in TLV!\n",
PRINTF("Found %u occurrence(s) of tag 0x%x in TLV!\n",
handlers[idx].found,
handlers[idx].tag);
return false;

View File

@@ -174,7 +174,7 @@ void handleProvideNFTInformation(uint8_t p1,
}
uint8_t signatureLen = workBuffer[offset];
PRINTF("Sigature len: %d\n", signatureLen);
PRINTF("Signature len: %d\n", signatureLen);
if (signatureLen < MIN_DER_SIG_SIZE || signatureLen > MAX_DER_SIG_SIZE) {
PRINTF("SignatureLen too big or too small. Must be between %d and %d, got %d\n",
MIN_DER_SIG_SIZE,

View File

@@ -58,7 +58,7 @@ typedef bool verificationAlgo(const cx_ecfp_public_key_t *,
// Returns the plugin type of a given plugin name.
// If the plugin name is not a specific known internal plugin, this function default return value is
// `EXERNAL`.
// `EXTERNAL`.
static pluginType_t getPluginType(char *pluginName, uint8_t pluginNameLength) {
if (pluginNameLength == sizeof(ERC721_STR) - 1 &&
strncmp(pluginName, ERC721_STR, pluginNameLength) == 0) {

View File

@@ -173,7 +173,7 @@ static void field_hash_feed_parent(e_type field_type, const uint8_t *const hash)
* @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value
* @param[in] data_length the value length
* @return whether an error occured or not
* @return whether an error occurred or not
*/
static bool field_hash_domain_special_fields(const void *const field_ptr,
const uint8_t *const data,
@@ -202,7 +202,7 @@ static bool field_hash_domain_special_fields(const void *const field_ptr,
* @param[in] field_ptr pointer to the struct field definition
* @param[in] data the field value
* @param[in] data_length the value length
* @return whether an error occured or not
* @return whether an error occurred or not
*/
static bool field_hash_finalize(const void *const field_ptr,
const uint8_t *const data,

View File

@@ -115,7 +115,7 @@ const void *path_get_field(void) {
/**
* Go down (add) a depth level.
*
* @return whether the push was succesful
* @return whether the push was successful
*/
static bool path_depth_list_push(void) {
if (path_struct == NULL) {

View File

@@ -51,7 +51,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
struct_name = get_struct_name(struct_ptr, &struct_name_length);
hash_nbytes((uint8_t *) struct_name, struct_name_length, (cx_hash_t *) &global_sha3);
// opening struct parenthese
// opening struct parentheses
hash_byte('(', (cx_hash_t *) &global_sha3);
field_ptr = get_struct_fields_array(struct_ptr, &fields_count);
@@ -67,7 +67,7 @@ static bool encode_and_hash_type(const void *const struct_ptr) {
field_ptr = get_next_struct_field(field_ptr);
}
// closing struct parenthese
// closing struct parentheses
hash_byte(')', (cx_hash_t *) &global_sha3);
return true;
@@ -107,7 +107,7 @@ static void sort_dependencies(uint8_t deps_count, const void **deps) {
/**
* Find all the dependencies from a given structure
*
* @param[out] deps_count count of how many struct dependencie pointers
* @param[out] deps_count count of how many struct dependency pointers
* @param[in] first_dep pointer to the first dependency pointer
* @param[in] struct_ptr pointer to the struct we are getting the dependencies of
* @return pointer to the first found dependency, \ref NULL otherwise

View File

@@ -48,7 +48,7 @@ static bool ui_712_field_shown(void) {
* @param[in] src_length source buffer size
* @param[in] dst destination buffer
* @param[in] dst_length destination buffer length
* @param[in] explicit_trunc if truncation should be explicitely shown
* @param[in] explicit_trunc if truncation should be explicitly shown
*/
static void ui_712_set_buf(const char *const src,
size_t src_length,
@@ -194,7 +194,7 @@ static void ui_712_format_str(const uint8_t *const data, uint8_t length) {
static const char *get_address_token_ticker(const uint8_t *addr) {
tokenDefinition_t *token;
// Loop over the received token informations
// Loop over the received token information
for (uint8_t token_idx = 0; token_idx < MAX_ITEMS; ++token_idx) {
if (tmpCtx.transactionContext.tokenSet[token_idx] == 1) {
token = &tmpCtx.transactionContext.extraInfo[token_idx].token;

View File

@@ -296,7 +296,7 @@ static void get_public_key(uint8_t *out, uint8_t outLength) {
getEthAddressFromRawKey(raw_pubkey, out);
}
/* Local implmentation of strncasecmp, workaround of the segfaulting base implem
/* Local implementation of strncasecmp, workaround of the segfaulting base implem
* Remove once strncasecmp is fixed
*/
static int strcasecmp_workaround(const char *str1, const char *str2) {

View File

@@ -8,6 +8,7 @@ These tests are implemented in Python with the `SpeculosClient` interface which
- [pip](https://pip.pypa.io/en/stable/installation/)
### Dependencies
Python dependencies are listed in [requirements.txt](requirements.txt)
```shell
@@ -19,6 +20,7 @@ python3 -m pip install -r requirements.txt
### Compilation app
Go to the root of the repository:
```sh
make DEBUG=1 NFT_TESTING_KEY=1 BOLOS_SDK=$NANOX_SDK
mv bin/app.elf tests/speculos/<some name>.elf
@@ -26,12 +28,13 @@ mv bin/app.elf tests/speculos/<some name>.elf
Given the requirements are installed, just do (by default command):
```
```shell
cd tests/speculos/
pytest
```
### Custom options
- **--model:** "nanos", "nanox", "nanosp" | default: "nanos"
- **--display:** "qt", "headless" | default: "qt"
- **--path:** the path of the binary app | default: path of makefile compilation
@@ -39,6 +42,7 @@ pytest
## Example
With `nanox` binary app:
```sh
# the --path is variable to where you put your binary

View File

@@ -32,6 +32,7 @@
## Ethereum_client
### Ethereum_cmd_builder
```py
def chunked(size, source)
@@ -49,6 +50,7 @@ class EthereumCommandBuilder:
```
### Ethereum_cmd
```py
class EthereumCommand:
# Sending apdu and parsing the response in the right form
@@ -61,16 +63,14 @@ class EthereumCommand:
def simple_sign_tx(self, bip32_path: str, transaction: Transaction, result: List = list()) -> None:
def sign_eip712(self, bip32_path: str, transaction: EIP712, result: List = list()) -> None:
def personal_sign_tx(self, bip32_path: str, transaction: PersonalTransaction, result: List = list()) -> None:
# Allows to send an apdu without return of speculos
def send_apdu(self, apdu: bytes) -> bytes:
# Allows to send an apdu with return of speculos
def send_apdu_context(self, apdu: bytes, result: List = list()) -> bytes:
```
### Utils
```py
def save_screenshot(cmd, path: str):
def compare_screenshot(cmd, path: str):
@@ -80,16 +80,18 @@ def packed_bip32_path_from_string(path: str) -> bytes:
def write_varint(n: int) -> bytes:
def read_varint(buf: BytesIO, prefix: Optional[bytes] = None) -> int:
def read(buf: BytesIO, size: int) -> bytes:
def read_uint(buf: BytesIO,
def read_uint(buf: BytesIO, bit_len: int, byteorder: Literal['big', 'little'] = 'little') -> int:
```
## Tests new apdu
If a new instruction is programmed it will be necessary to create 2 new functions.
one in `ethereum_cmd_builder`:
- Creation of the raw apdu you can find some examples in this same file
and one in `ethereum_cmd`:
- Send the apdu to speculos and parse the answer in a `list` named result you can find some examples in this same file
## Example for write new tests
@@ -130,4 +132,3 @@ def test_some_error(cmd):
pass
assert error.args[0] == '0x6a80'
```

View File

@@ -221,6 +221,3 @@ class EthereumCommand:
result.append(v)
result.append(r)
result.append(s)

View File

@@ -171,7 +171,7 @@ class EthereumCommandBuilder:
bip32_path : str
String representation of BIP32 path.
Third party public key on Curve25519 : 32 bytes
Optionnal if returning the shared secret
Optional if returning the shared secret
"""
cdata = packed_bip32_path_from_string(bip32_path)

View File

@@ -98,7 +98,7 @@ def read(buf: BytesIO, size: int) -> bytes:
b: bytes = buf.read(size)
if len(b) < size:
raise ValueError(f"Cant read {size} bytes in buffer!")
raise ValueError(f"Can't read {size} bytes in buffer!")
return b

View File

@@ -47,7 +47,7 @@ def test_transfer_erc1155(cmd):
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00000.png")
cmd.client.press_and_release('right')
# NFT Transfert
# NFT Transfer
compare_screenshot(cmd, f"screenshots/erc1155/{PATH_IMG[cmd.model]}/transfer_erc1155/00001.png")
cmd.client.press_and_release('right')

View File

@@ -9,7 +9,8 @@ We use the library [**cmocka**](https://cmocka.org/#features)
- [CMake >= 3.10](https://cmake.org/download/)
- [lcov >= 1.14](http://ltp.sourceforge.net/coverage/lcov.php)
Don't worry, you don't necessarily need to install the `cmocka library` because the **cmakelist automatically fetches** the library
Don't worry, you don't necessarily need to install the `cmocka library`
because the **cmakelist automatically fetches** the library
## Add new test
@@ -27,12 +28,15 @@ The `default rules` of makefile will compile the tests and run them.
make
```
The `coverage rule` will launch the default rules and generate the coverage and you will be **automatically redirected** to the generated .html
The `coverage rule` will launch the default rules and generate the coverage
and you will be **automatically redirected** to the generated .html
```sh
make coverage
```
The `clean rule` will delete the folders and files generated
```sh
make clean
```

View File

@@ -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,
};