Closed Pitasi closed 1 week ago
steps:
cp -r contracts/contracts/ethereum-analyzer contracts/contracts/osmosis-analyzer
ethereum-analyzer
occurences into osmosis-analyzer
ethereum.rs
to osmosis.rs
and change the parse(bytes: Binary)
to parse the input as a json and return a new struct called OsmosisTransaction
OsmosisTransaction
struct must have a signature_hash
field that is calculated as sha256sum(sorted_json)
where sorted_json
is the json serialized with all the fields sorted alphabetically by keys and without any extra space in itanalyze(input: Binary)
in contract.rs
to return an AnalyzeResult
that contains the signature_hash describe in the previous steptest case:
osmosis.rs
's parse()
function with this case:
input:
{
"chain_id": "osmosis-1",
"account_number": "2037934",
"sequence": "0",
"fee": {
"gas": "583061",
"amount": [
{
"amount": "259",
"denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
}
]
},
"msgs": [
{
"type": "osmosis/poolmanager/swap-exact-amount-in",
"value": {
"sender": "osmo16hmn8nh3fn79ce53fxdmp6p7fpp4mdnc3t80dw",
"routes": [
{
"pool_id": "1400",
"token_out_denom": "uosmo"
}
],
"token_in": {
"denom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2",
"amount": "500000"
},
"token_out_min_amount": "4227660"
}
}
],
"memo": "FE",
"timeout_height": "14705680"
}
expected signature_hash (hex encoded for showing here on github):
858a2e13af1c1d6a89357d2408fa68a6e17fa5a97437c95c44fafae1746bc203
Hello @Pitasi 👋🏻 May I take care of this issue?
Like for #266, we can implement a smart contract that takes the binary payload representing an osmosis transactions and returns the "data_for_signing" (i.e. the hash to be signed).
Basically we need to reimplement this logic in Rust: https://github.com/warden-protocol/wardenprotocol/blob/2787d9d988d067dce0fafd6d45615837881b0d7f/warden/x/warden/types/v1beta2/sign_method_handler_osmosis.go#L24-L41.