mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-21 23:18:13 +00:00
feat(common): protobuf messages for Ethereum definitions
This commit is contained in:
parent
e42e87174f
commit
5be6d07693
60
common/protob/messages-ethereum-definitions.proto
Normal file
60
common/protob/messages-ethereum-definitions.proto
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
syntax = "proto2";
|
||||||
|
package hw.trezor.messages.ethereum_definitions;
|
||||||
|
|
||||||
|
// Sugar for easier handling in Java
|
||||||
|
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||||
|
option java_outer_classname = "TrezorMessageEthereumDefinitions";
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ethereum definitions type enum.
|
||||||
|
* Used to check the encoded EthereumNetworkInfo or EthereumTokenInfo message.
|
||||||
|
*/
|
||||||
|
enum EthereumDefinitionType {
|
||||||
|
NETWORK = 0;
|
||||||
|
TOKEN = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ethereum network definition. Used to (de)serialize the definition.
|
||||||
|
*
|
||||||
|
* Definition types should not be cross-parseable, i.e., it should not be possible to
|
||||||
|
* incorrectly parse network info as token info or vice versa.
|
||||||
|
* To achieve that, the first field is wire type varint while the second field is wire type
|
||||||
|
* length-delimited. Both are a mismatch for the token definition.
|
||||||
|
*
|
||||||
|
* @embed
|
||||||
|
*/
|
||||||
|
message EthereumNetworkInfo {
|
||||||
|
required uint64 chain_id = 1;
|
||||||
|
required string symbol = 2;
|
||||||
|
required uint32 slip44 = 3;
|
||||||
|
required string name = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ethereum token definition. Used to (de)serialize the definition.
|
||||||
|
*
|
||||||
|
* Definition types should not be cross-parseable, i.e., it should not be possible to
|
||||||
|
* incorrectly parse network info as token info or vice versa.
|
||||||
|
* To achieve that, the first field is wire type length-delimited while the second field
|
||||||
|
* is wire type varint. Both are a mismatch for the network definition.
|
||||||
|
*
|
||||||
|
* @embed
|
||||||
|
*/
|
||||||
|
message EthereumTokenInfo {
|
||||||
|
required bytes address = 1;
|
||||||
|
required uint64 chain_id = 2;
|
||||||
|
required string symbol = 3;
|
||||||
|
required uint32 decimals = 4;
|
||||||
|
required string name = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains an encoded Ethereum network and/or token definition. See ethereum-definitions.md for details.
|
||||||
|
* @embed
|
||||||
|
*/
|
||||||
|
message EthereumDefinitions {
|
||||||
|
optional bytes encoded_network = 1; // encoded Ethereum network
|
||||||
|
optional bytes encoded_token = 2; // encoded Ethereum token
|
||||||
|
}
|
@ -5,6 +5,8 @@ package hw.trezor.messages.ethereum_eip712;
|
|||||||
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
||||||
option java_outer_classname = "TrezorMessageEthereumEIP712";
|
option java_outer_classname = "TrezorMessageEthereumEIP712";
|
||||||
|
|
||||||
|
import "messages-ethereum-definitions.proto";
|
||||||
|
|
||||||
|
|
||||||
// Separated from messages-ethereum.proto as it is not implemented on T1 side
|
// Separated from messages-ethereum.proto as it is not implemented on T1 side
|
||||||
// and defining all the messages and fields could be even impossible as recursive
|
// and defining all the messages and fields could be even impossible as recursive
|
||||||
@ -20,9 +22,10 @@ option java_outer_classname = "TrezorMessageEthereumEIP712";
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumSignTypedData {
|
message EthereumSignTypedData {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
required string primary_type = 2; // name of the root message struct
|
required string primary_type = 2; // name of the root message struct
|
||||||
optional bool metamask_v4_compat = 3 [default=true]; // use MetaMask v4 (see https://github.com/MetaMask/eth-sig-util/issues/106)
|
optional bool metamask_v4_compat = 3 [default=true]; // use MetaMask v4 (see https://github.com/MetaMask/eth-sig-util/issues/106)
|
||||||
|
optional ethereum_definitions.EthereumDefinitions definitions = 4; // network and/or token definitions
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,6 +6,7 @@ option java_package = "com.satoshilabs.trezor.lib.protobuf";
|
|||||||
option java_outer_classname = "TrezorMessageEthereum";
|
option java_outer_classname = "TrezorMessageEthereum";
|
||||||
|
|
||||||
import "messages-common.proto";
|
import "messages-common.proto";
|
||||||
|
import "messages-ethereum-definitions.proto";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -15,8 +16,8 @@ import "messages-common.proto";
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumGetPublicKey {
|
message EthereumGetPublicKey {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
optional bool show_display = 2; // optionally show on display before sending the result
|
optional bool show_display = 2; // optionally show on display before sending the result
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,8 +36,9 @@ message EthereumPublicKey {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumGetAddress {
|
message EthereumGetAddress {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
optional bool show_display = 2; // optionally show on display before sending the result
|
optional bool show_display = 2; // optionally show on display before sending the result
|
||||||
|
optional bytes encoded_network = 3; // encoded Ethereum network, see ethereum-definitions.md for details
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,16 +60,17 @@ message EthereumAddress {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumSignTx {
|
message EthereumSignTx {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
optional bytes nonce = 2 [default='']; // <=256 bit unsigned big endian
|
optional bytes nonce = 2 [default='']; // <=256 bit unsigned big endian
|
||||||
required bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
|
required bytes gas_price = 3; // <=256 bit unsigned big endian (in wei)
|
||||||
required bytes gas_limit = 4; // <=256 bit unsigned big endian
|
required bytes gas_limit = 4; // <=256 bit unsigned big endian
|
||||||
optional string to = 11 [default='']; // recipient address
|
optional string to = 11 [default='']; // recipient address
|
||||||
optional bytes value = 6 [default='']; // <=256 bit unsigned big endian (in wei)
|
optional bytes value = 6 [default='']; // <=256 bit unsigned big endian (in wei)
|
||||||
optional bytes data_initial_chunk = 7 [default='']; // The initial data chunk (<= 1024 bytes)
|
optional bytes data_initial_chunk = 7 [default='']; // The initial data chunk (<= 1024 bytes)
|
||||||
optional uint32 data_length = 8 [default=0]; // Length of transaction payload
|
optional uint32 data_length = 8 [default=0]; // Length of transaction payload
|
||||||
required uint64 chain_id = 9; // Chain Id for EIP 155
|
required uint64 chain_id = 9; // Chain Id for EIP 155
|
||||||
optional uint32 tx_type = 10; // Used for Wanchain
|
optional uint32 tx_type = 10; // Used for Wanchain
|
||||||
|
optional ethereum_definitions.EthereumDefinitions definitions = 12; // network and/or token definitions for tx
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,17 +81,18 @@ message EthereumSignTx {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumSignTxEIP1559 {
|
message EthereumSignTxEIP1559 {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
required bytes nonce = 2; // <=256 bit unsigned big endian
|
required bytes nonce = 2; // <=256 bit unsigned big endian
|
||||||
required bytes max_gas_fee = 3; // <=256 bit unsigned big endian (in wei)
|
required bytes max_gas_fee = 3; // <=256 bit unsigned big endian (in wei)
|
||||||
required bytes max_priority_fee = 4; // <=256 bit unsigned big endian (in wei)
|
required bytes max_priority_fee = 4; // <=256 bit unsigned big endian (in wei)
|
||||||
required bytes gas_limit = 5; // <=256 bit unsigned big endian
|
required bytes gas_limit = 5; // <=256 bit unsigned big endian
|
||||||
optional string to = 6 [default='']; // recipient address
|
optional string to = 6 [default='']; // recipient address
|
||||||
required bytes value = 7; // <=256 bit unsigned big endian (in wei)
|
required bytes value = 7; // <=256 bit unsigned big endian (in wei)
|
||||||
optional bytes data_initial_chunk = 8 [default='']; // The initial data chunk (<= 1024 bytes)
|
optional bytes data_initial_chunk = 8 [default='']; // The initial data chunk (<= 1024 bytes)
|
||||||
required uint32 data_length = 9; // Length of transaction payload
|
required uint32 data_length = 9; // Length of transaction payload
|
||||||
required uint64 chain_id = 10; // Chain Id for EIP 155
|
required uint64 chain_id = 10; // Chain Id for EIP 155
|
||||||
repeated EthereumAccessList access_list = 11; // Access List
|
repeated EthereumAccessList access_list = 11; // Access List
|
||||||
|
optional ethereum_definitions.EthereumDefinitions definitions = 12; // network and/or token definitions for tx
|
||||||
|
|
||||||
message EthereumAccessList {
|
message EthereumAccessList {
|
||||||
required string address = 1;
|
required string address = 1;
|
||||||
@ -125,8 +129,9 @@ message EthereumTxAck {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumSignMessage {
|
message EthereumSignMessage {
|
||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
required bytes message = 2; // message to be signed
|
required bytes message = 2; // message to be signed
|
||||||
|
optional bytes encoded_network = 3; // encoded Ethereum network, see ethereum-definitions.md for details
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,9 +150,9 @@ message EthereumMessageSignature {
|
|||||||
* @next Failure
|
* @next Failure
|
||||||
*/
|
*/
|
||||||
message EthereumVerifyMessage {
|
message EthereumVerifyMessage {
|
||||||
required bytes signature = 2; // signature to verify
|
required bytes signature = 2; // signature to verify
|
||||||
required bytes message = 3; // message to verify
|
required bytes message = 3; // message to verify
|
||||||
required string address = 4; // address to verify
|
required string address = 4; // address to verify
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,6 +165,7 @@ message EthereumSignTypedHash {
|
|||||||
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
||||||
required bytes domain_separator_hash = 2; // Hash of domainSeparator of typed data to be signed
|
required bytes domain_separator_hash = 2; // Hash of domainSeparator of typed data to be signed
|
||||||
optional bytes message_hash = 3; // Hash of the data of typed data to be signed (empty if domain-only data)
|
optional bytes message_hash = 3; // Hash of the data of typed data to be signed (empty if domain-only data)
|
||||||
|
optional bytes encoded_network = 4; // encoded Ethereum network, see ethereum-definitions.md for details
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user