Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated ethereum sdk + snapshots #34

Merged
merged 2 commits into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethereum-plugin-sdk
Submodule ethereum-plugin-sdk updated 39 files
+1 −1 .github/workflows/build_and_test.yml
+44 −0 .github/workflows/publish_doc_website.yml
+2 −0 .gitignore
+3 −2 README.md
+1 −0 docs/CNAME
+ docs/img/Ledger-logo-696.webp
+51 −0 docs/index.md
+4 −0 docs/requirements.txt
+57 −0 docs/technical_informations/diagram.md
+15 −0 docs/technical_informations/globals.md
+11 −0 docs/technical_informations/handlers/handle_finalize.md
+11 −0 docs/technical_informations/handlers/handle_init_contract.md
+11 −0 docs/technical_informations/handlers/handle_provide_parameter.md
+19 −0 docs/technical_informations/handlers/handle_provide_token.md
+11 −0 docs/technical_informations/handlers/handle_query_contract_id.md
+19 −0 docs/technical_informations/handlers/handle_query_contract_ui.md
+10 −0 docs/technical_informations/handlers/index.md
+3 −0 docs/technical_informations/index.md
+5 −0 docs/technical_informations/tx_content.md
+3 −0 docs/technical_informations/utils/common_utils.md
+3 −0 docs/technical_informations/utils/index.md
+3 −0 docs/technical_informations/utils/plugin_utils.md
+1 −0 docs/test_framework/ci.md
+1 −0 docs/test_framework/fuzzing.md
+9 −0 docs/test_framework/index.md
+1 −0 docs/test_framework/ragger.md
+ docs/walkthrough/img/uniswap.webp
+52 −0 docs/walkthrough/index.md
+75 −0 mkdocs.yml
+2 −3 src/asset_info.h
+9 −0 src/bip32_utils.h
+44 −12 src/common_utils.c
+212 −31 src/common_utils.h
+4 −2 src/eth_internals.h
+297 −57 src/eth_plugin_interface.h
+3 −10 src/main.c
+8 −5 src/plugin_utils.c
+81 −9 src/plugin_utils.h
+15 −3 src/tx_content.h
3 changes: 1 addition & 2 deletions src/handle_finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ static bool set_ticker_withdraw_for_mapped_token(plugin_parameters_t *context,
return false;
}

void handle_finalize(void *parameters) {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
void handle_finalize(ethPluginFinalize_t *msg) {
plugin_parameters_t *context = (plugin_parameters_t *) msg->pluginContext;

msg->uiType = ETH_UI_TYPE_GENERIC;
Expand Down
4 changes: 1 addition & 3 deletions src/handle_init_contract.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "stakekit_plugin.h"

// Called once to init.
void handle_init_contract(void *parameters) {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;

void handle_init_contract(ethPluginInitContract_t *msg) {
if (msg->interfaceVersion != ETH_PLUGIN_INTERFACE_VERSION_LATEST) {
msg->result = ETH_PLUGIN_RESULT_UNAVAILABLE;
return;
Expand Down
3 changes: 1 addition & 2 deletions src/handle_provide_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,7 @@ static void handle_lido_claim_withdrawal(ethPluginProvideParameter_t *msg,
}
}

void handle_provide_parameter(void *parameters) {
ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters;
void handle_provide_parameter(ethPluginProvideParameter_t *msg) {
plugin_parameters_t *context = (plugin_parameters_t *) msg->pluginContext;

// We use `%.*H`: it's a utility function to print bytes. You first give
Expand Down
3 changes: 1 addition & 2 deletions src/handle_provide_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ static void network_token(plugin_parameters_t *context) {
}
}

void handle_provide_token(void *parameters) {
ethPluginProvideInfo_t *msg = (ethPluginProvideInfo_t *) parameters;
void handle_provide_token(ethPluginProvideInfo_t *msg) {
plugin_parameters_t *context = (plugin_parameters_t *) msg->pluginContext;
PRINTF("Plugin provide tokens : 0x%p, 0x%p\n", msg->item1, msg->item2);

Expand Down
3 changes: 1 addition & 2 deletions src/handle_query_contract_id.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "stakekit_plugin.h"

// Function to display the method name on the device.
void handle_query_contract_id(void *parameters) {
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
void handle_query_contract_id(ethQueryContractID_t *msg) {
plugin_parameters_t *context = (plugin_parameters_t *) msg->pluginContext;

strlcpy(msg->name, PLUGIN_NAME, msg->nameLength);
Expand Down
119 changes: 40 additions & 79 deletions tests/build_local_test_elfs.sh
Original file line number Diff line number Diff line change
@@ -1,87 +1,48 @@
#!/bin/bash

# FILL THESE WITH YOUR OWN SDKs PATHS and APP-ETHEREUM's ROOT
NANOS_SDK=$NANOS_SDK
NANOX_SDK=$NANOX_SDK
NANOSP_SDK=$NANOSP_SDK
APP_ETHEREUM=${APP_ETHEREUM:-"/app/app-ethereum"}

set -e

build_plugin() {
# arguments: <SDK letter>
echo "** Building app-plugin for Nano $1..."
local target="$(realpath './elfs/')/plugin_nano${1,,}.elf"
if [ "$1" == "S" ];
then
local sdk=$NANOS_SDK
elif [ "$1" == "SP" ];
then
local sdk=$NANOSP_SDK
elif [ "$1" == "X" ];
then
local sdk=$NANOX_SDK
else
echo "Unknown SDK '$1'"
exit 1
fi
cd ..
make clean BOLOS_SDK="$sdk"
make -j DEBUG=1 BOLOS_SDK="$sdk"
cp bin/app.elf "$target"
cd -
#NANOS_SDK=
#NANOX_SDK=
#NANOSP_SDK=
#FLEX_SDK=
#STAX_SDK=
APP_ETHEREUM=/plugin_dev/app-ethereum

# Create elfs folder if it doesn't exist
mkdir -p elfs

# Function to build both plugin and ethereum apps for a specific device
build_device_elfs() {
local device=$1
local sdk_var="${device}_SDK"

echo "*Building elfs for ${device}..."
export BOLOS_SDK="${!sdk_var}"

# Build plugin
echo "**Building app-paraswap for ${device}..."
make clean
make -j DEBUG=1
cp bin/app.elf "tests/elfs/plugin_${device,,}.elf"

# Build ethereum app
echo "**Building app-ethereum for ${device}..."
cd "$APP_ETHEREUM" || exit
make clean BOLOS_SDK="${!sdk_var}"
make -j DEBUG=1 BOLOS_SDK="${!sdk_var}" CHAIN=ethereum BYPASS_SIGNATURES=1 ALLOW_DATA=1
cd - || exit
cp "${APP_ETHEREUM}/bin/app.elf" "tests/elfs/ethereum_${device,,}.elf"
}

build_ethereum() {
# arguments: <SDK letter>
echo "** Building app-ethereum for Nano $1..."
local target="$(realpath './elfs/')/ethereum_nano${1,,}.elf"
if [ "$1" == "S" ];
then
local sdk=$NANOS_SDK
elif [ "$1" == "SP" ];
then
local sdk=$NANOSP_SDK
elif [ "$1" == "X" ];
then
local sdk="$NANOX_SDK"
else
echo "Unknown SDK '$1'"
exit 1
fi
cd "$APP_ETHEREUM"
make clean BOLOS_SDK="$sdk"
make -j DEBUG=1 BYPASS_SIGNATURES=1 BOLOS_SDK="$sdk" CHAIN=ethereum
cp bin/app.elf "$target"
cd -
}


main() {
# create elfs folder if it doesn't exist
mkdir -p elfs
# Move to repo's root to build apps
cd ..

if [ $# -ne 0 ];
then
test -d "$1" ||
(echo "Provided argument '$1' is expected to be the app-ethereum repository path, but is not a directory" && exit 1);
APP_ETHEREUM="$1"
fi

echo "* Building elfs for Nano S..."
build_plugin "S"
build_ethereum "S"

echo "* Building elfs for Nano S Plus..."
build_plugin "SP"
build_ethereum "SP"

echo "* Building elfs for Nano X..."
build_plugin "X"
build_ethereum "X"

echo "* Done"
}
# List of supported devices
DEVICES=("NANOS" "NANOX" "NANOSP" "FLEX" "STAX")

# Build for each device
for device in "${DEVICES[@]}"; do
build_device_elfs "$device"
done

main "$@"
echo "done"
4 changes: 2 additions & 2 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@ledgerhq/hw-app-eth": "6.34.3",
"@zondax/zemu": "^0.44.0",
"@zondax/zemu": "0.53.0",
"ethers": "^5.4.7",
"fs-extra": "^10.0.0",
"jest": "^29.6.4",
Expand All @@ -30,4 +30,4 @@
"@babel/preset-stage-0": "^7.0.0",
"@babel/register": "^7.22.5"
}
}
}
Binary file modified tests/snapshots/arbitrum_nanosp_arbitrum_angle_deposit/00005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/arbitrum_nanox_arbitrum_angle_deposit/00005.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/arbitrum_nanox_arbitrum_angle_deposit/00007.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/arbitrum_nanox_arbitrum_angle_withdraw/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/avalanche_nanosp_avalanche_redeem_1/00002.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/avalanche_nanosp_avalanche_redeem_1/00004.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/avalanche_nanosp_avalanche_redeem_1/00006.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/avalanche_nanosp_avalanche_redeem_2/00004.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/avalanche_nanosp_avalanche_redeem_2/00006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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/avalanche_nanosp_avalanche_submit/00002.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/avalanche_nanosp_avalanche_submit/00004.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/avalanche_nanosp_avalanche_submit/00006.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/avalanche_nanox_avalanche_redeem_1/00002.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/avalanche_nanox_avalanche_redeem_1/00004.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_redeem_1/00006.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_redeem_2/00004.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_redeem_2/00006.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_submit/00002.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_submit/00004.png
Binary file modified tests/snapshots/avalanche_nanox_avalanche_submit/00006.png
Binary file modified tests/snapshots/bsc_nanosp_bsc_transfer_out/00005.png
Binary file modified tests/snapshots/bsc_nanosp_bsc_transfer_out/00007.png
Binary file modified tests/snapshots/bsc_nanox_bsc_transfer_out/00005.png
Binary file modified tests/snapshots/bsc_nanox_bsc_transfer_out/00007.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_angle_deposit/00004.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_buy_voucher/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_buy_voucher/00005.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_claim_tokens/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_claim_tokens/00005.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_comet_supply/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_comet_supply/00005.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_enter/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_enter/00005.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_grt_delegate/00004.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_grt_delegate/00006.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_leave/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_leave/00005.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_stake/00003.png
Binary file modified tests/snapshots/ethereum_nanosp_ethereum_stake/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_angle_deposit/00004.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_angle_deposit/00006.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_angle_withdraw/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_buy_voucher/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_buy_voucher/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_claim_tokens/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_claim_tokens/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_comet_supply/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_comet_supply/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_enter/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_enter/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_grt_delegate/00004.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_grt_delegate/00006.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_grt_undelegate/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_leave/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_leave/00005.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_stake/00003.png
Binary file modified tests/snapshots/ethereum_nanox_ethereum_stake/00005.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_1/00002.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_1/00004.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_1/00006.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_2/00004.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_2/00006.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_3/00005.png
Binary file modified tests/snapshots/fantom_nanosp_yearn_vault_deposit_3/00007.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_1/00002.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_1/00004.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_1/00006.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_2/00004.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_2/00006.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_3/00005.png
Binary file modified tests/snapshots/fantom_nanox_yearn_vault_deposit_3/00007.png
Binary file modified tests/snapshots/polygon_nanos_polygon_aave_v3_supply/00009.png
Binary file modified tests/snapshots/polygon_nanos_polygon_aave_v3_withdraw/00007.png
Binary file modified tests/snapshots/polygon_nanos_polygon_comet_claim/00009.png
Binary file modified tests/snapshots/polygon_nanos_polygon_comet_withdraw/00004.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_aave_v3_supply/00005.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_aave_v3_supply/00007.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_comet_claim/00003.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_comet_claim/00005.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_comet_claim/00007.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_comet_withdraw/00004.png
Binary file modified tests/snapshots/polygon_nanosp_polygon_comet_withdraw/00006.png
Binary file modified tests/snapshots/polygon_nanox_polygon_aave_v3_supply/00005.png
Binary file modified tests/snapshots/polygon_nanox_polygon_aave_v3_supply/00007.png
Binary file modified tests/snapshots/polygon_nanox_polygon_aave_v3_withdraw/00005.png
Binary file modified tests/snapshots/polygon_nanox_polygon_comet_claim/00003.png
Binary file modified tests/snapshots/polygon_nanox_polygon_comet_claim/00005.png
Binary file modified tests/snapshots/polygon_nanox_polygon_comet_claim/00007.png
Binary file modified tests/snapshots/polygon_nanox_polygon_comet_withdraw/00004.png
Binary file modified tests/snapshots/polygon_nanox_polygon_comet_withdraw/00006.png
Binary file modified tests/snapshots/tomochain_nanosp_tomochain_vic_vote_1/00004.png
Binary file modified tests/snapshots/tomochain_nanosp_tomochain_vic_vote_1/00006.png
Binary file modified tests/snapshots/tomochain_nanox_tomochain_vic_resign_1/00004.png
Binary file modified tests/snapshots/tomochain_nanox_tomochain_vic_unvote_1/00005.png
Binary file modified tests/snapshots/tomochain_nanox_tomochain_vic_vote_1/00004.png
Binary file modified tests/snapshots/tomochain_nanox_tomochain_vic_vote_1/00006.png
Loading
Loading