Skip to content

Include API responses in submit_tx method #185

Closed
@bhatt-deep

Description

@bhatt-deep

Is your feature request related to a problem? Please describe.
Yes, When a transaction is submitted, If there's an error in any part of it, the response from APIs will be helpful in decoding and re-submitting.

Describe the solution you'd like
Modify the submit_tx method to capture the API response and include it in the return value. Here's an example of how this could be done:

from blockfrost import ApiError

def submit_tx(self, cbor: Union[bytes, str]) -> dict:
    if isinstance(cbor, str):
        cbor = bytes.fromhex(cbor)
    with tempfile.NamedTemporaryFile(delete=False) as f:
        f.write(cbor)
    try:
        response: dict = self.api.tx_submit(f.name)
    except ApiError as e:
        os.remove(f.name)
        raise ValueError(f"Failed to submit transaction. Error code: {e.status_code}. Error message: {e.message}")
    os.remove(f.name)
    return {
        'response': response,
    }

Describe alternatives you've considered
None

Additional context
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions