fetchai/agents-aea

When dealing with cosmos based tokens, set fee denom and tx denom seperately

Opened this issue · 1 comments

Is your feature request related to a problem? Please describe.
I am using fetch aea to tx mobix,

There is no way to set the denom of the fees seperately from the denom of the tx.

This requires some cerative tx manipulation to get the desired result.

Please see below;

aea config-override


public_id: fetchai/ledger:0.18.0
type: connection
config:
ledger_apis:
fetchai:
address: https://rest-andromeda.fetch.ai:443
denom: nanomobx
chain_id: andromeda-1
ethereum:
address: https://hidden-bold-glitter.matic.quiknode.pro/878802d4df1c01517caa777f1e82f23d806b3fb5/
gas_price_api_key: null

ledger_api_handler hack

def _handle_raw_transaction(
    self, ledger_api_msg: LedgerApiMessage, ledger_api_dialogue: LedgerApiDialogue
) -> None:
    """
    Handle a message of raw_transaction performative.

    :param ledger_api_message: the ledger api message
    :param ledger_api_dialogue: the ledger api dialogue
    """
    ledger_api_msg.raw_transaction.body['fee'] = {'amount': [{'amount': '1', 'denom': 'atestfet'}], 'gas': '80000'} # oh god why???
    self.context.logger.info("received raw transaction={}".format(ledger_api_msg))
    signing_dialogues = cast(SigningDialogues, self.context.signing_dialogues)
    signing_msg, signing_dialogue = signing_dialogues.create(
        counterparty=self.context.decision_maker_address,
        performative=SigningMessage.Performative.SIGN_TRANSACTION,
        raw_transaction=ledger_api_msg.raw_transaction,
        terms=ledger_api_dialogue.associated_fipa_dialogue.terms,
    )
    signing_dialogue = cast(SigningDialogue, signing_dialogue)
    signing_dialogue.associated_ledger_api_dialogue = ledger_api_dialogue
    self.context.decision_maker_message_queue.put_nowait(signing_msg)
    self.context.logger.info(
        "proposing the transaction to the decision maker. Waiting for confirmation ..."
    )

Describe the solution you'd like
Ideally, within the ledger api you would be able to specify the denom of the fee currency as well.

Ok so the issue is that the denom of the tx fee and the amount are not the same. This means we need to differentiate between the two in the kwargs here (https://github.com/fetchai/agents-aea/blob/develop/plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py). Should be a simple fix :)