Embedded SDK
Embedded SDK
Loading...
Searching...
No Matches
swap_entrypoints.h
Go to the documentation of this file.
1/*******************************************************************************
2 * (c) 2023 Ledger
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 ********************************************************************************/
16#pragma once
17
18#include <stddef.h>
19#include <stdbool.h>
20#include <stdint.h>
21
22#include "swap_lib_calls.h"
23
24// ################################################################################################
25
26/*
27--8<-- [start:coin_api_intro]
28The handle functions must be defined by each Coin application implementing the SWAP feature.
29
30Handlers are called by Exchange through the `os_lib_call` API, and their commands must be fulfilled
31by the Coin application.
32
33The Exchange application is responsible for handling the flow and sequencing of the SWAP.
34--8<-- [end:coin_api_intro]
35*/
36
37// ################################################################################################
38
39/*
40--8<-- [start:swap_entry_point_intro]
41## C applications
42For C applications, the lib_standard_app dispatches the command through the `main()` and
43`library_app_main()` functions to the Coin application defined handler.
44--8<-- [end:swap_entry_point_intro]
45*/
46
47// ################################################################################################
48
49/*
50--8<-- [start:swap_handle_check_address_brief]
51This handle is called when the Exchange application wants to ensure that a
52given address belongs to the device.
53
54If the address does belong to the device, result is set to 1. Otherwise it
55is set to 0.
56--8<-- [end:swap_handle_check_address_brief]
57*/
58
59// ################################################################################################
60
61// --8<-- [start:swap_handle_check_address]
62// This callback must be defined in Coin Applications that use the SWAP feature.
63
65// --8<-- [end:swap_handle_check_address]
66
67/*
68--8<-- [start:swap_handle_get_printable_amount_brief]
69This handle is called when the Exchange application wants to format for
70display an amount + ticker of a currency known by this application
71
72If the formatting succeeds, result is set to the formatted string. Otherwise
73it is set to '\0'.
74--8<-- [end:swap_handle_get_printable_amount_brief]
75*/
76
77// --8<-- [start:swap_handle_get_printable_amount]
78// This callback must be defined in Coin Applications that use the SWAP feature.
80// --8<-- [end:swap_handle_get_printable_amount]
81
82// --8<-- [start:swap_copy_transaction_parameters]
83/* This handle is called when the user has validated on screen the transaction
84 * proposal sent by the partner and started the FROM Coin application to sign
85 * the payment transaction.
86 *
87 * This handler needs to save in the heap the details of what has been validated
88 * in Exchange. These elements will be checked against the received transaction
89 * upon its reception from the Ledger Live.
90 *
91 * return false on error, true otherwise
92 */
94// --8<-- [end:swap_copy_transaction_parameters]
void swap_handle_get_printable_amount(get_printable_amount_parameters_t *params)
void swap_handle_check_address(check_address_parameters_t *params)
bool swap_copy_transaction_parameters(create_transaction_parameters_t *sign_transaction_params)