Skip to content

V2 keysign message - DO NOT MERGE#11

Open
johnnyluo wants to merge 3 commits into
mainfrom
v2
Open

V2 keysign message - DO NOT MERGE#11
johnnyluo wants to merge 3 commits into
mainfrom
v2

Conversation

@johnnyluo
Copy link
Copy Markdown
Contributor

This is the first design draft of KeysignMessage v2 , the goal of

  1. V1 KeysignMessage is a bit confusing, and also pass some information that is not required.
  2. for future proof, if third party integrate with Vultisign , they are working with some swaps that Vultisig doesn't aware of , make sure they can still fold their requirement into KeysignPayload support by Vultisig, thus Vultisig can co-sign it

Copy link
Copy Markdown
Contributor

@enriquesouza enriquesouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum TransactionType {
TRANSACTION_TYPE_UNSPECIFIED = 0;
TRANSACTION_TYPE_VOTE = 1;
TRANSACTION_TYPE_PROPOSAL = 2;
}
TransactionType transaction_type = 7;

Maybe we can use this and add swap, send, and deposit to all chains, in case we need to add more options in the future.

@johnnyluo
Copy link
Copy Markdown
Contributor Author

enum TransactionType { TRANSACTION_TYPE_UNSPECIFIED = 0; TRANSACTION_TYPE_VOTE = 1; TRANSACTION_TYPE_PROPOSAL = 2; } TransactionType transaction_type = 7;

Maybe we can use this and add swap, send, and deposit to all chains, in case we need to add more options in the future.

The problem is VOTE, PROPOSAL is only relevant for cosmos chain , not the others

@johnnyluo johnnyluo changed the title V2 keysign message V2 keysign message - DO NOT MERGE Aug 5, 2024
Comment on lines +22 to +23
string to_address = 2;
string to_amount = 3;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should add coin, to_address, to_amount to a KeysignPayload, and reuse it from there? Seems like it repeated for each Transaction

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, quite a bunch of the information is repeated for each Transaction , if I move it to KeysignPayload , then it will end up more like v1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, is it bad though for these two fields?

Comment thread proto/vultisig/keysign/v2/keysign_message.proto Outdated
uint64 account_number = 4;
uint64 sequence = 5;
uint64 fee = 6;
string is_deposit = 7; // probably don't need it , because when `to_address` is empty , it's a deposit , still keep it to make it specific
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if to address can be empty, would be great to mark it as optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fields in protobuf is optional by default

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, we can deprecate isDeposit

Copy link
Copy Markdown
Contributor

@yvebe yvebe Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fields in protobuf is optional by default

Code generators may not know that, so it's probably better to specify it, also that's self documenting

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's part of protobuf standard

optional string memo = 10;
}

// SwapInfo is mostly for display purpose
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any usecase for them when constructing transaction?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for example , when we construct a swap transaction , swap itself will be put into transaction, for example , EVM chain swaps , at the end of the day , it is a standard transaction , or a smart contract call , which is also a standard transaction , but has some special data field

However , on the UI part , we often need to show user some additional information , like provider , fee , slippage , and final output amount etc. Those will go to swap_info.

swap_info is also optional , when it is empty , then it is just a standard send transaction

int64 nonce = 6;
string gas_limit = 7;
optional string memo = 8;
optional vultisig.keysign.v1.Erc20ApprovePayload erc20_approve_payload = 9;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something wrong here ig. ERC20 approve also regular evm tx. We need to cover case when we're need to generate two keysing messages. First - erc20 approve and second - erc20 transfer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// when swap_info is not empty , then the pair device shoudl treat it as a swap
// 1. Show swap verify screen
// 2. for EVM chain , need to construct a generic smart contract transaction
optional SwapInfo swap_info = 20;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's make enum for display purposes that we can use for all UI cases?

enum Action {
  case transfer(TransferInfo)
  case swap(SwapInfo)
  case transferWithApproval(TransferWithApprovalInfo)
  case thorchainDeposit(ThorchainDepositInfo)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should save space for transactions, where this info is not needed. (e.g.: if all info for send tx available from already existing payload, we don't want to store more info)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly as what @yvebe mentioned , for Send , all the information is already in the transaction , only for swap , we need to have some additional information.
For those information already in the send transaction , we don't want to store it again here

string target_amount = 5;
}
message KeysignPayload {
oneof transaction {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be an array of oneof transaction to support multiple signatures? Eg. erc20 transfer with approve or any other multiple tx signings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do that , because if it is an array , it need to be the same type , but in our case , the transaction are all different types

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants