Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solana loadable tokens definitions & rent fee #4638

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 72 additions & 22 deletions common/defs/solana/programs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1623,7 +1623,8 @@
{
"name": "mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "account_to_mint",
Expand All @@ -1637,9 +1638,13 @@
}
],
"ui_properties": [
{
"account": "mint",
"display_name": "Mint token"
},
{
"parameter": "amount",
"display_name": "Mint tokens"
"display_name": "Mint amount"
},
{
"account": "account_to_mint",
Expand Down Expand Up @@ -1672,7 +1677,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "owner",
Expand All @@ -1681,9 +1687,13 @@
}
],
"ui_properties": [
{
"account": "token_mint",
"display_name": "Burn token"
},
{
"parameter": "amount",
"display_name": "Burn tokens"
"display_name": "Burn amount"
},
{
"account": "account_to_burn_from",
Expand Down Expand Up @@ -1746,7 +1756,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "freeze_authority",
Expand All @@ -1759,6 +1770,10 @@
"account": "account_to_freeze",
"display_name": "Freeze account"
},
{
"account": "token_mint",
"display_name": "Token"
},
{
"account": "freeze_authority",
"display_name": "Owner"
Expand All @@ -1779,7 +1794,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "freeze_authority",
Expand All @@ -1792,6 +1808,10 @@
"account": "account_to_freeze",
"display_name": "Thaw account"
},
{
"account": "token_mint",
"display_name": "Token"
},
{
"account": "freeze_authority",
"display_name": "Owner"
Expand Down Expand Up @@ -1823,7 +1843,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "destination_account",
Expand Down Expand Up @@ -1884,7 +1905,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "delegate",
Expand Down Expand Up @@ -1940,7 +1962,8 @@
{
"name": "mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "account_to_mint",
Expand Down Expand Up @@ -1997,7 +2020,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "owner",
Expand Down Expand Up @@ -2414,7 +2438,8 @@
{
"name": "mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "account_to_mint",
Expand All @@ -2428,9 +2453,13 @@
}
],
"ui_properties": [
{
"account": "mint",
"display_name": "Mint token"
},
{
"parameter": "amount",
"display_name": "Mint tokens"
"display_name": "Mint amount"
},
{
"account": "account_to_mint",
Expand Down Expand Up @@ -2463,7 +2492,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "owner",
Expand All @@ -2472,9 +2502,13 @@
}
],
"ui_properties": [
{
"account": "token_mint",
"display_name": "Burn token"
},
{
"parameter": "amount",
"display_name": "Burn tokens"
"display_name": "Burn amount"
},
{
"account": "account_to_burn_from",
Expand Down Expand Up @@ -2537,7 +2571,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "freeze_authority",
Expand All @@ -2550,6 +2585,10 @@
"account": "account_to_freeze",
"display_name": "Freeze account"
},
{
"account": "token_mint",
"display_name": "Token"
},
{
"account": "freeze_authority",
"display_name": "Owner"
Expand All @@ -2570,7 +2609,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "freeze_authority",
Expand All @@ -2583,6 +2623,10 @@
"account": "account_to_freeze",
"display_name": "Thaw account"
},
{
"account": "token_mint",
"display_name": "Token"
},
{
"account": "freeze_authority",
"display_name": "Owner"
Expand Down Expand Up @@ -2614,7 +2658,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "destination_account",
Expand Down Expand Up @@ -2675,7 +2720,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "delegate",
Expand Down Expand Up @@ -2731,7 +2777,8 @@
{
"name": "mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "account_to_mint",
Expand Down Expand Up @@ -2788,7 +2835,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "owner",
Expand Down Expand Up @@ -2965,7 +3013,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "system_program",
Expand Down Expand Up @@ -3027,7 +3076,8 @@
{
"name": "token_mint",
"is_authority": false,
"optional": false
"optional": false,
"is_token_mint": true
},
{
"name": "system_program",
Expand Down
2 changes: 1 addition & 1 deletion common/protob/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
check: messages.pb messages-binance.pb messages-bitcoin.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb messages-eos.pb
check: messages.pb messages-binance.pb messages-bitcoin.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb messages-eos.pb messages-solana.pb messages-definitions.pb

%.pb: %.proto
protoc -I/usr/include -I. $< -o $@
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
syntax = "proto2";
package hw.trezor.messages.ethereum_definitions;
package hw.trezor.messages.definitions;

// Sugar for easier handling in Java
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageEthereumDefinitions";

option java_outer_classname = "TrezorMessageDefinitions";

/**
* Ethereum definitions type enum.
* Used to check the encoded EthereumNetworkInfo or EthereumTokenInfo message.
* Definitions type enum.
* Used to check the encoded EthereumNetworkInfo/EthereumTokenInfo/SolanaTokenInfo message.
*/
enum EthereumDefinitionType {
NETWORK = 0;
TOKEN = 1;
enum DefinitionType {
ETHEREUM_NETWORK = 0;
ETHEREUM_TOKEN = 1;
SOLANA_TOKEN = 2;
}

/**
Expand Down Expand Up @@ -51,10 +51,16 @@ message EthereumTokenInfo {
}

/**
* Contains an encoded Ethereum network and/or token definition. See ethereum-definitions.md for details.
* Solana 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 different Solana definitions as each other.
*
* @embed
*/
message EthereumDefinitions {
optional bytes encoded_network = 1; // encoded Ethereum network
optional bytes encoded_token = 2; // encoded Ethereum token
message SolanaTokenInfo {
required bytes mint = 1; // token mint - unique token id
required string program_id = 2; // token program id, e.g. token program, token22 program
required string name = 3;
required string ticker = 4;
}
10 changes: 5 additions & 5 deletions common/protob/messages-ethereum-eip712.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package hw.trezor.messages.ethereum_eip712;
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageEthereumEIP712";

import "messages-ethereum-definitions.proto";
import "messages-ethereum.proto";


// Separated from messages-ethereum.proto as it is not implemented on T1 side
Expand All @@ -22,10 +22,10 @@ import "messages-ethereum-definitions.proto";
* @next Failure
*/
message EthereumSignTypedData {
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
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
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
optional bool metamask_v4_compat = 3 [default=true]; // use MetaMask v4 (see https://github.com/MetaMask/eth-sig-util/issues/106)
optional ethereum.EthereumDefinitions definitions = 4; // network and/or token definitions
}

/**
Expand Down
Loading