doiim / tikua

Isomorphic JS Cartesi package designed for seamless integration with any visual library on both Browser and Terminal environments. The SDK supports any provider or network, offering complete configurability to define applications with multiple chain support. It adapts to specific configurations and provides warnings for unsupported provider chains
Apache License 2.0
2 stars 1 forks source link

Check transaction status #8

Closed OsmanRodrigues closed 1 month ago

OsmanRodrigues commented 4 months ago

Hi everybody!

What do you think about develop a way to check a specific transaction status by the transaction hash (txHash, returned by sendInput)?

filipesoccol commented 4 months ago

Will keep here noted as a possible implementation for next versions. Usually web3 devs prefer to use its own Lib for this kind of tasks like Ethers/Viem, but yeah I think would be helpful to have a faster way to grab the responses. I was also thinking on maybe add an optional callback to the sendInput/deposits/executeVoucher so that function would be called with the transactionReceipt. What do you think?

OsmanRodrigues commented 4 months ago

Will keep here noted as a possible implementation for next versions. Usually web3 devs prefer to use its own Lib for this kind of tasks like Ethers/Viem, but yeah I think would be helpful to have a faster way to grab the responses. I was also thinking on maybe add an optional callback to the sendInput/deposits/executeVoucher so that function would be called with the transactionReceipt. What do you think?

Great, man!

Thanks for answer :pray:

I was thinking about a stuff like what you mentioned, returning a transaction receipt with all 32bytes data converted to utf8, but something independently of transactions sender methods in order to keep the separation of concerns, according to (S)OLID - SRP. Some getTransactionReceiptById method or anything like that. :thinking:

It makes sense? :thinking:

filipesoccol commented 3 months ago

Sure. We can work with it. I just disagree with the convertion to utf8 because there is no readable data on hash.

getTransactionReceiptByHash could work for a matter of simplification. So we could use with any features that Tikua supports, like sendInput, approvals, deposits, executeVoucher, etc...

public getTransactionReceiptByHash = async (hash: string) => {
  return await publicClient.waitForTransactionReceipt( 
    { hash }
  )
}
OsmanRodrigues commented 3 months ago

Sure. We can work with it. I just disagree with the convertion to utf8 because there is no readable data on hash.

getTransactionReceiptByHash could work for a matter of simplification. So we could use with any features that Tikua supports, like sendInput, approvals, deposits, executeVoucher, etc...

public getTransactionReceiptByHash = async (hash: string) => {
  return await publicClient.waitForTransactionReceipt( 
    { hash }
  )
}

It seems cool, dude! :star_struck:

About the conversion, I expressed myself badly, what I meant is that have some readable data as possible, for example, if I not mistaken, the transaction status property that can be 0x0 or 0x1, for reject/fail or success status respectively, right? :thinking:

Well, despite the conversion being considerable or not, I will eagerly await this feature! Just rocks it! :man_singer: :rocket:

filipesoccol commented 3 months ago

Got it. As far as I know when you use waitForTransactionReceipt Viem already decode recognized data automatically (like transaction status). Anyway, unfortunatelly SendInput function from Cartesi InputBox never reject the transaction. Because it is only processed on Cartesi Machine after transaction confirmed inside blockchain. So there is no much thing to grab from there. But I can also think on a function to try decode all events inside logs after execute a voucher or something like this.

Will take a look into it for you and return here as soon as possible.

filipesoccol commented 1 month ago

11 Created a pull request to monitor transaction and decode logs and input.