TxResult and BridgeResult for deposit/withdraw feedback#35
Conversation
| @dataclass | ||
| class TxResult: | ||
| tx_hash: str | ||
| tx_receipt: AttributeDict | None | ||
| exception: Exception | None | ||
|
|
||
| @property | ||
| def status(self) -> TxStatus: | ||
| if self.tx_receipt is not None: | ||
| return TxStatus(int(self.tx_receipt.status)) # ∈ {0, 1} (EIP-658) | ||
| if isinstance(self.exception, TimeoutError): | ||
| return TxStatus.PENDING | ||
| return TxStatus.ERROR |
There was a problem hiding this comment.
the BridgeClient returns this from it's methods to deposit / withdraw with help of the send_and_confirm_tx function
| @dataclass | ||
| class BridgeResult: | ||
| source_chain: ChainID | ||
| target_chain: ChainID | ||
| source_token: Currency | ||
| target_token: Currency | ||
| amount: int | ||
| receiver: Address | ||
| tx_result: TxResult |
There was a problem hiding this comment.
The BaseClient returns this from it's methods to deposit / withdraw. Keeping BridgeResult as a pure data container means we can cleanly add a method on BaseClient like check_bridge_result() to poll the latest tx status. This avoids forcing the caller to handle Web3 setup or determine RPC endpoints themselves.
| line-length = 120 | ||
| skip-string-normalization = true | ||
| target-version = ['py37', 'py38', 'py39'] | ||
| target-version = ['py310'] |
There was a problem hiding this comment.
we don't support 3.7 and 3.8. It looks like we support 3.9,
Line 10 in 73d197b
but we are not compatible with 3.9 and we also don't run that in CI
derive_client/.github/workflows/common_check.yaml
Lines 21 to 23 in 73d197b
There was a problem hiding this comment.
updated to include all the versions of python we do support
This PR introduces
TxResultandBridgeResultto provide structured feedback for deposit and withdrawal operations to the callerTxResultencapsulates transaction status and relevant transaction data.BridgeResultwraps theTxResultand context (source and target chain, token, plus receiver and amount).We could expose a method for clients to provide their
BridgeResultto for a status update in caseTxResult.statusisTxStatus.PENDING. It contains all the necessary information for the Derive client to do so and removes the need for the caller (i.e.AssetBridgingInterface) to instantiate their own w3 instance and provide a correct RPC URL