def submit_transaction( transaction: Transaction, client: Client, ) -> Response: """ Submits a transaction to the ledger. Args: transaction: the Transaction to be submitted. client: the network client with which to submit the transaction. Returns: The response from the ledger. Raises: XRPLRequestFailureException: if the rippled API call fails. """ transaction_json = transaction.to_xrpl() transaction_blob = encode(transaction_json) response = client.request(SubmitOnly(tx_blob=transaction_blob)) if response.is_successful(): return response result = cast(Dict[str, Any], response.result) raise XRPLRequestFailureException(result)
def test_from_dict_submit(self): blob = "SOISUSF9SD0839W8U98J98SF" id_val = "submit_786514" request = { "method": "submit", "tx_blob": blob, "fail_hard": False, "id": id_val, } expected = SubmitOnly(tx_blob=blob, id=id_val) actual = Request.from_dict(request) self.assertEqual(actual, expected)
def submit_transaction_blob( transaction_blob: str, client: Client, ) -> Response: """ Submits a transaction blob to the ledger. Args: transaction_blob: the transaction blob to be submitted. client: the network client with which to submit the transaction. Returns: The response from the ledger. """ submit_request = SubmitOnly(tx_blob=transaction_blob) return client.request(submit_request)
def from_dict(cls: Type[Submit], value: Dict[str, Any]) -> Submit: """ Construct a new Submit from a dictionary of parameters. Args: value: The value to construct the Submit from. Returns: A new Submit object, constructed using the given parameters. Raises: XRPLModelException: If the dictionary provided is invalid. """ from xrpl.models.requests import SignAndSubmit, SubmitOnly if cls.__name__ == "Submit": if "tx_blob" in value: return SubmitOnly.from_dict(value) return SignAndSubmit.from_dict(value) return cast(Submit, super(Submit, cls).from_dict(value))
def test_basic_functionality(self): response = JSON_RPC_CLIENT.request(SubmitOnly(tx_blob=TX_BLOB, )) self.assertTrue(response.is_successful())