Skip to content

Commit

Permalink
feat(cosmos_signer): support pre-hash for evm cosmos chain(s) (#3399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milerius authored Aug 29, 2023
1 parent 76595fd commit af05a96
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Cosmos/Signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ Proto::SigningOutput Signer::sign(const Proto::SigningInput& input, TWCoinType c
}

std::string Signer::signaturePreimage(const Proto::SigningInput& input, const Data& publicKey, TWCoinType coin) const {
auto isEvmCosmosChain = [coin]() {
return coin == TWCoinTypeNativeInjective || coin == TWCoinTypeEvmos || coin == TWCoinTypeNativeCanto;
};
switch (input.signing_mode()) {
case Proto::JSON:
return Json::signaturePreimageJSON(input).dump();

case Proto::Protobuf:
default:
auto pbk = PublicKey(publicKey, TWPublicKeyTypeSECP256k1);
auto pbk = isEvmCosmosChain() ? PublicKey(publicKey, TWPublicKeyTypeSECP256k1Extended) : PublicKey(publicKey, TWPublicKeyTypeSECP256k1);
return Protobuf::signaturePreimageProto(input, pbk, coin);
}
}
Expand Down

0 comments on commit af05a96

Please sign in to comment.