strangelove-ventures / lens

⚛️❤️👁 Brought to you by the LensCrafters
Apache License 2.0
168 stars 82 forks source link

Creation of new keyserver for transaction signing #101

Open boojamya opened 2 years ago

boojamya commented 2 years ago

Current sign flow:

Desired direction:

frumioj commented 2 years ago
  1. Signing

lens/client/tx.go -> cosmos-sdk/client/tx/tx.go

https://github.com/cosmos/cosmos-sdk/blob/450cd7fc8708ccb0fa21f05e251d9804a2063b79/client/tx/tx.go#L308

-> cosmos-sdk/crypto/keyring

https://github.com/cosmos/cosmos-sdk/blob/450cd7fc8708ccb0fa21f05e251d9804a2063b79/crypto/keyring/keyring.go#L328

  1. Adding a key

lens/cmd/keys.go -> lens/client/keys.go -> cosmos-sdk/crypto/keyring

https://github.com/cosmos/cosmos-sdk/blob/450cd7fc8708ccb0fa21f05e251d9804a2063b79/crypto/keyring/keyring.go#L558

Looks to me like keystone client should replace the code that is in cosmos-sdk/crypto/keyring, adding any necessary functions not in keystone already (related to bc-specific addresses).

Note: AFAICT, there appear to be explicit dependencies in lens and cosmos for "local" (file-based) keys, despite the possibility of non-file backends being otherwise in use - am I misunderstanding these things?

For example, what does NewLocalRecord/writeLocalKey do if there is not a file-based keyring in use?:

https://github.com/cosmos/cosmos-sdk/blob/450cd7fc8708ccb0fa21f05e251d9804a2063b79/crypto/keyring/keyring.go#L759

And why is there a local directory assumed in the lens/client/chain_client.go?

ccc.KeyDirectory = keysDir(homepath, ccc.ChainID)

https://github.com/strangelove-ventures/lens/blob/ce29236971a0167f2ebe8c1a0e21a2851fea6710/client/chain_client.go#L48

Neither of these assumptions should be made for a keystone key, since the private key bytes are not going to be in a file accessible in this way to the client code.

frumioj commented 2 years ago

Under heavy development (this week, lol)...

https://github.com/cosmos/keystone