MeshJS / mesh

An open-source library to advance Web3 development on Cardano
https://meshjs.dev
Apache License 2.0
208 stars 57 forks source link

BUG: serializer get_error() returns empty #299

Open BenElferink opened 2 weeks ago

BenElferink commented 2 weeks ago

I was testing UX for TX errors in my app.

When I triggered a TX that failed to build due to "Insufficient funds for lovelace", the message was logged as a "warning" (as seen here), but the error in my catch-block resolved with an empty message:

try {
    const unsignedTx = await tx.build() // <--- console.warn triggered by Mesh
    const signedTx = await wallet.signTx(unsignedTx)
    const txHash = await wallet.submitTx(signedTx)
} catch (error: any) {
    console.error(error)
    // Error: txBuildResult error: 
    // at CSLSerializer.serializeTxBody (index.js:1076:13)
    // at MeshTxBuilder.complete (index.js:1391:33)

    console.error(error?.message)
    // txBuildResult error: 
}

Versions:

{
    "@meshsdk/core": "^1.7.3",
    "@meshsdk/react": "^1.7.3",
}
BenElferink commented 1 week ago

After digging further, I can confirm the source of the error is here: https://github.com/MeshJS/mesh/blob/b35b4646c6e412840b3f9bca61b4c1cefbf33129/packages/mesh-core-csl/src/core/serializer.ts#L74

It seems the get_error() method does not work, or resolves with an empty string.