First compilation with the standard SWAP
Enable the SWAP feature
In the Makefile, set the variable ENABLE_SWAP = 1
or ENABLE_TESTING_SWAP = 1
of the standard Makefile, as shown in the example below:
ifeq ($(APPNAME), "Boilerplate")
# Two flags exist for enabling the SWAP
# - ENABLE_SWAP will lead to the enabling of the swap related C code of the standard_app
# AND will lead to the enabling of the APP_LOAD_PARAM required for os_lib_call working on device
# - ENABLE_TESTING_SWAP: will lead to the enabling of the swap related C code of the standard_app
# ONLY works on Speculos, not on device
# Testing only SWAP flag
ENABLE_TESTING_SWAP = 1
# Production enabled SWAP flag
# ENABLE_SWAP = 1
endif
Then compile your application, you may encounter the following error if you do not have a recent Boilerplate fork:
ld.lld: error: undefined symbol: swap_copy_transaction_parameters
>>> referenced by main.c
>>> build/nanox/obj/sdk/lib_standard_app/main.o:(library_app_main)
ld.lld: error: undefined symbol: swap_handle_get_printable_amount
>>> referenced by main.c
>>> build/nanox/obj/sdk/lib_standard_app/main.o:(library_app_main)
ld.lld: error: undefined symbol: swap_handle_check_address
>>> referenced by main.c
>>> build/nanox/obj/sdk/lib_standard_app/main.o:(library_app_main)
These errors are caused by the missing handler definitions. For more information about what the handlers do, refer to the handler documentation.
Fix compilation errors if any
If the compilation succeeds, you can skip this section.
For now, we will declare the handlers in the simplest possible way.
Add the following files to your application (it is recommended to follow the Boilerplate file structure):
$> ls app-boilerplate/src/swap/
handle_check_address.c handle_get_printable_amount.c handle_swap.h handle_swap_sign_transaction.c
Add the function declarations in the .h
files and the function definitions in the .c
files. Define empty functions for now:
#include "os.h"
#include "swap_lib_calls.h"
void swap_handle_check_address(check_address_parameters_t *params) {
// Accept all addresses
params->result = 1;
}
void swap_handle_get_printable_amount(get_printable_amount_parameters_t* params) {
// Format all amounts as 10
strcpy(params->printable_amount, "10");
}
bool swap_copy_transaction_parameters(create_transaction_parameters_t* params) {
// Do nothing successfully
return true;
}