1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-25 07:48:10 +00:00

feat(common): add Solana sign tx messages

This commit is contained in:
gabrielkerekes 2023-08-02 08:25:08 +02:00
parent 489b0987af
commit 54aa5cc35a
6 changed files with 94 additions and 0 deletions

View File

@ -41,3 +41,23 @@ message SolanaGetAddress {
message SolanaAddress {
required string address = 1; // Solana address as Base58 encoded string
}
/**
* Request: Ask device to sign a Solana transaction
* @start
* @next SolanaSignedTx
* @next Failure
*/
message SolanaSignTx {
repeated uint32 signer_path_n = 1; // BIP-32 path to derive the key to sign with
required bytes serialized_tx = 2; // serialized tx to be signed
}
/**
* Response: Contains the hash of the signed transaction and the signature
* @end
*/
message SolanaSignedTx {
required bytes serialized_tx = 1; // the tx which has been signed (the same data which was passed to SolanaSignTx)
required bytes signature = 2; // tx signature
}

View File

@ -365,4 +365,6 @@ enum MessageType {
MessageType_SolanaPublicKey = 901 [(wire_out) = true];
MessageType_SolanaGetAddress = 902 [(wire_in) = true];
MessageType_SolanaAddress = 903 [(wire_out) = true];
MessageType_SolanaSignTx = 904 [(wire_in) = true];
MessageType_SolanaSignedTx = 905 [(wire_out) = true];
}

View File

@ -237,3 +237,5 @@ if not utils.BITCOIN_ONLY:
SolanaPublicKey = 901
SolanaGetAddress = 902
SolanaAddress = 903
SolanaSignTx = 904
SolanaSignedTx = 905

View File

@ -255,6 +255,8 @@ if TYPE_CHECKING:
SolanaPublicKey = 901
SolanaGetAddress = 902
SolanaAddress = 903
SolanaSignTx = 904
SolanaSignedTx = 905
class FailureType(IntEnum):
UnexpectedMessage = 1

View File

@ -5164,6 +5164,38 @@ if TYPE_CHECKING:
def is_type_of(cls, msg: Any) -> TypeGuard["SolanaAddress"]:
return isinstance(msg, cls)
class SolanaSignTx(protobuf.MessageType):
signer_path_n: "list[int]"
serialized_tx: "bytes"
def __init__(
self,
*,
serialized_tx: "bytes",
signer_path_n: "list[int] | None" = None,
) -> None:
pass
@classmethod
def is_type_of(cls, msg: Any) -> TypeGuard["SolanaSignTx"]:
return isinstance(msg, cls)
class SolanaSignedTx(protobuf.MessageType):
serialized_tx: "bytes"
signature: "bytes"
def __init__(
self,
*,
serialized_tx: "bytes",
signature: "bytes",
) -> None:
pass
@classmethod
def is_type_of(cls, msg: Any) -> TypeGuard["SolanaSignedTx"]:
return isinstance(msg, cls)
class StellarAsset(protobuf.MessageType):
type: "StellarAssetType"
code: "str | None"

View File

@ -263,6 +263,8 @@ class MessageType(IntEnum):
SolanaPublicKey = 901
SolanaGetAddress = 902
SolanaAddress = 903
SolanaSignTx = 904
SolanaSignedTx = 905
class FailureType(IntEnum):
@ -6588,6 +6590,40 @@ class SolanaAddress(protobuf.MessageType):
self.address = address
class SolanaSignTx(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 904
FIELDS = {
1: protobuf.Field("signer_path_n", "uint32", repeated=True, required=False, default=None),
2: protobuf.Field("serialized_tx", "bytes", repeated=False, required=True),
}
def __init__(
self,
*,
serialized_tx: "bytes",
signer_path_n: Optional[Sequence["int"]] = None,
) -> None:
self.signer_path_n: Sequence["int"] = signer_path_n if signer_path_n is not None else []
self.serialized_tx = serialized_tx
class SolanaSignedTx(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 905
FIELDS = {
1: protobuf.Field("serialized_tx", "bytes", repeated=False, required=True),
2: protobuf.Field("signature", "bytes", repeated=False, required=True),
}
def __init__(
self,
*,
serialized_tx: "bytes",
signature: "bytes",
) -> None:
self.serialized_tx = serialized_tx
self.signature = signature
class StellarAsset(protobuf.MessageType):
MESSAGE_WIRE_TYPE = None
FIELDS = {