You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/eth_contract_support_embedded.adoc
+5-54Lines changed: 5 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,24 @@ Application version 1.3.0 - 05th of July 2020
6
6
## 1.3.0
7
7
- Initial release
8
8
9
-
## About
9
+
## About
10
10
11
11
This document described how a specific device UI for a smart contract can be added in the current version of the Ethereum application, before plugins are added
12
12
13
13
## Standard support
14
14
15
-
The applications already includes dedicated UI support for those specific contract calls :
15
+
The applications already includes dedicated UI support for those specific contract calls :
16
16
17
17
* ERC 20 approve(address, uint256) - implementation in *src_features/erc20_approval*
18
18
* ERC 20 transfer(address, uint256) - implementation in *src_features/signTx*
19
19
20
20
## Requirements
21
21
22
-
The following data is necessary for a specific contract support
22
+
The following data is necessary for a specific contract support
23
23
24
24
* Smart contract ABI (at least for calls that are to be supported by the application)
25
25
26
-
The following data is optional for a specific contract support
26
+
The following data is optional for a specific contract support
27
27
28
28
* Contract address (can be optional if supported by multiple instances)
29
29
@@ -38,60 +38,11 @@ The first four bytes of the call data for a function call specifies the function
38
38
The following online tool can be used to compute selectors https://emn178.github.io/online-tools/keccak_256.html
39
39
40
40
41
-
## Limitations
42
-
43
-
* The total number of parameters of a contract call is 4 (as defined in *src/shared_context.h* for tokenContext_t.data, each parameter being encoded as an uint256). Additional parameters can be supported if not required to handle the displaying logic (see "Also handle exception that only need to process the beginning of data" in *src_features/signTx/logic_signTx.c* for CONTRACT_STARKWARE_VERIFY_ESCAPE and CONTRACT_STARKWARE_REGISTER)
44
-
45
-
* Non fixed size types (dynamic sized byte sequences, dynamic sized strings, variable length arrays) are not directly supported
46
-
47
-
## Sample implementation of a function call
48
-
49
-
This example describes how to implement a specific UI for a contract call. This exemple is using Starkex token deposit - *deposit(uint256 tokenId, uint256 vaultId, uint256 quantizedAmount)*
50
-
51
-
52
-
* Implement the specific UI logic in a new *src_features* subdirectory - note that strings.common.maxFee will be provisioned with the maximum fee to pay for this call
53
-
54
-
```
55
-
See src_features/stark_contract_deposit for this example
* Add an entry to the contract_call_t enum of *src/shared_context.h* for this function call
66
-
67
-
```
68
-
CONTRACT_STARKWARE_DEPOSIT_TOKEN
69
-
```
70
-
71
-
* Check for the selector being called and the arguments size in *src_features/signTx/logic_signTx.c* customProcessor function - additional logic can be applied (quantumSet in this example)
72
-
73
-
```C
74
-
if ((context->currentFieldLength == STARKWARE_DEPOSIT_TOKEN_DATA_SIZE) &&
A UI implementation might want to convert an ERC 20 token contract address to a ticker for easier validation
93
44
94
-
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
45
+
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
95
46
96
47
The same mechanism will be extended to support well known contract addresses in the future
0 commit comments