Skip to content

Zondax/ledger-plugin-swell

Repository files navigation

Ledger Plugin Swell

This is a plugin for the Ethereum application which helps parsing and displaying relevant information when signing a Swell smart contract.

Prerequisite

Clone the plugin to a new folder.

git clone https://github.com/libertify/ledger-plugin-lens.git

Then in the same folder clone the app-ethereum.

git clone --recurse-submodules https://github.com/LedgerHQ/app-ethereum.git     #app-ethereum

Documentation

Need more information about the interface, the architecture, or general stuff about ethereum plugins? You can find more about them in the ethereum-app documentation.

Smart Contracts

Smart contracts covered by this plugin are:

Network Smart Contract Smart Contract Address
Ethereum Deposit Manager & Node Operator Registry 0x46DdC39E780088B1B146Aba8cBBe15DC321A1A1d
Ethereum rswETH 0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0

Functions implemented:

Function Selector Displayed Parameters
addNewValidatorDetails* 0x60ec5216
bytes[] pubkeys
addOperator* 0x54741d6d
string name
address operator
address reward
deleteActiveValidators* 0xeda74e71
bytes[] pubkeys
deletePendingValidators* 0x242eba0e
bytes[] pubkeys
usePubKeysForValidatorSetup* 0xc3953502
bytes[] pubkeys
deposit 0xd0e30db0
amount stake
disableOperator 0xf56408ed
address operator
enableOperator 0xdd307b99
address operator
initialize 0xc4d66de8
address control_manager
updateOperatorControllingAddress 0x32f73258
address operator
address new_operator
updateOperatorRewardAddress 0xe8f28a6c
address operator
address reward
updateOperatorName* 0x9f5db69c
address operator
string name
withdrawERC20 0xf4f3b200
address token

*For strings and byte arrays bigger then 32, plugin is showing the first and last 16 bytes in "16...16" format, due to memory limitations. For addNewValidatorDetails, deleteActiveValidators, deletePendingValidators, usePubKeysForValidatorSetup, plugin can only verify transactions with 4 pubkeys maximum due to memory limitation.

Build

To build the plugin, go to your folder with Ethereum app and plugin. Open a new terminal window and run:

sudo docker run --rm -ti -v "$(realpath .):/app" -v "$(realpath app-ethereum):/plugin_dev/app-ethereum" --user $(id -u $USER):$(id -g $USER) ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest

In the container, go to the plugin repository, then to the tests/ folder.

cd ledger-plugin-swell/tests
./build_local_test_elfs.sh. 

Tests

To test the plugin go to the tests folder from the "ledger-plugin-swell" and run the script "test"

cd ledger-plugin-swell/tests         # go to the tests folder in ledger-plugin-swell
yarn test                       # run the script test