trustwallet / wallet-core

Cross-platform, cross-blockchain wallet library.
https://developer.trustwallet.com/wallet-core
Apache License 2.0
2.83k stars 1.58k forks source link

Improvement: API update for TW_Cosmos_Proto_SigningOutput #2566

Closed rsrbk closed 2 years ago

rsrbk commented 2 years ago

When using JSON signing mode for cosmos, an example of the output we receive is:

{
  "mode": "block",
  "tx": {
    "fee": {
      "amount": [
        {
          "amount": "0",
          "denom": "uosmo"
        }
      ],
      "gas": "250000"
    },
    "memo": "",
    "msg": [
      {
        "type": "osmosis/gamm/swap-exact-amount-in",
        "value": {
          "routes": [
            {
              "poolId": "1",
              "tokenOutDenom": "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2"
            }
          ],
          "sender": "osmo15jetnnj03usvx4naz2lzdw7vxysu2g43546dvf",
          "tokenIn": {
            "amount": "100000",
            "denom": "uosmo"
          },
          "tokenOutMinAmount": "8873"
        }
      }
    ],
    "signatures": [
      {
        "pub_key": {
          "type": "tendermint/PubKeySecp256k1",
          "value": "AzI5lC/562WeXfc7mCAL5fy2u9CopbOeRiJbbnXpIC4m"
        },
        "signature": "+S8kqrU31NKBDTrTzIIjsrj5xynrWaUER+TTNG33ZCEIucYPp47eZWc2JmbFewF7vKFPq23QBLEZXAiQijEQ/A=="
      }
    ]
  }
}

Currently we have two properties: output.json will return the whole JSON and output.signature will return the signature itself (+S8kqrU31NKBDTrTzIIjsrj5xynrWaUER+TTNG33ZCEIucYPp47eZWc2JmbFewF7vKFPq23QBLEZXAiQijEQ/A==).

DApps expect the full signature format (signatures property) and currently we have to construct it ourselves on the client: https://github.com/trustwallet/trust-web3-provider/blob/0697a61211e671b894b0c47e6d1ff28cedac084e/ios/TrustWeb3Provider/DAppWebViewController.swift#L731-L737

Would be nice if we can have it built directly from wallet-core.

hewigovens commented 2 years ago

Sounds like we can return one more signatureJSON field

rsrbk commented 2 years ago

Would also love to have it for both JSON and Protobuf signing types.