private async Task <ResultWrapper <Keccak> > SendTx(Transaction tx, TxHandlingOptions txHandlingOptions = TxHandlingOptions.None) { try { (Keccak txHash, AcceptTxResult? acceptTxResult) = await _txSender.SendTransaction(tx, txHandlingOptions | TxHandlingOptions.PersistentBroadcast); return(acceptTxResult.Equals(AcceptTxResult.Accepted) ? ResultWrapper <Keccak> .Success(txHash) : ResultWrapper <Keccak> .Fail(acceptTxResult?.ToString() ?? string.Empty, ErrorCodes.TransactionRejected)); } catch (SecurityException e) { return(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.AccountLocked)); } catch (Exception e) { if (_logger.IsError) { _logger.Error("Failed to send transaction.", e); } return(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.TransactionRejected)); } }
public void Timestamp_is_set_on_transactions() { Transaction tx = Build.A.Transaction.Signed(new EthereumEcdsa(ChainId.Mainnet, LimboLogs.Instance), TestItem.PrivateKeyA).TestObject; _txSender.SendTransaction(tx, TxHandlingOptions.PersistentBroadcast); _txPool.Received().SubmitTx(Arg.Is <Transaction>(tx => tx.Timestamp != UInt256.Zero), TxHandlingOptions.PersistentBroadcast); }
public Keccak SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { // TODO: Move to Uint256 when we support division ulong minGasPrice = (ulong)CurrentMinGasPrice(); tx.GasPrice = minGasPrice * _percentDelta / 100; return(_txSender.SendTransaction(tx, txHandlingOptions)); }
public ValueTask <Keccak> SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { UInt256 minGasPrice = CurrentMinGasPrice(); UInt256 txGasPrice = minGasPrice * _percentDelta / 100; tx.GasPrice = UInt256.Max(txGasPrice, _miningConfig.MinGasPrice); return(_txSender.SendTransaction(tx, txHandlingOptions)); }
public ValueTask <(Keccak, AcceptTxResult?)> SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { UInt256 gasPriceEstimated = _gasPriceOracle.GetGasPriceEstimate() * _percentDelta / 100; tx.DecodedMaxFeePerGas = gasPriceEstimated; tx.GasPrice = gasPriceEstimated; return(_txSender.SendTransaction(tx, txHandlingOptions)); }
private static void SendTransaction(ReportType reportType, ITxSender txSender, Transaction transaction) { TxHandlingOptions handlingOptions = reportType switch { ReportType.Benign => TxHandlingOptions.ManagedNonce, ReportType.Malicious => TxHandlingOptions.ManagedNonce | TxHandlingOptions.PersistentBroadcast, _ => TxHandlingOptions.ManagedNonce }; txSender.SendTransaction(transaction, handlingOptions); }
public async Task send_own_transaction_should_invoke_blockchain_bridge_send_transaction_and_return_hash() { var transaction = Build.A.Transaction.TestObject; var hash = TestItem.KeccakA; _txSender.SendTransaction(transaction, TxHandlingOptions.PersistentBroadcast | TxHandlingOptions.ManagedNonce).Returns(hash); var result = await _ndmBridge.SendOwnTransactionAsync(transaction); _txSender.Received().SendTransaction(transaction, TxHandlingOptions.PersistentBroadcast | TxHandlingOptions.ManagedNonce); result.Should().Be(hash); }
public Keccak SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { try { return(_txSender.SendTransaction(tx, txHandlingOptions)); } catch (SecurityException e) { throw new SecurityException("Your account is locked. Unlock the account via CLI, personal_unlockAccount or use Trusted Signer.", e); } }
public ValueTask <Keccak> SendTransaction(Transaction tx, TxHandlingOptions txHandlingOptions) { (UInt256 minFeeCap, UInt256 minGasPremium) = CurrentMinGas(); UInt256 txFeeCap = minFeeCap * _percentDelta / 100; UInt256 txGasPremium = minGasPremium * _percentDelta / 100; tx.DecodedFeeCap = UInt256.Max(txFeeCap, _miningConfig.MinGasPrice); tx.GasPrice = txGasPremium; tx.Type = TxType.EIP1559; return(_txSender.SendTransaction(tx, txHandlingOptions)); }
private async Task <Keccak> DeployBytecode(Address address, string contractType, byte[] bytecode) { Transaction tx = new(); tx.Value = 0; tx.Data = bytecode; tx.GasLimit = 1000000; tx.GasPrice = 20.GWei(); tx.SenderAddress = address; Keccak txHash = await _txSender.SendTransaction(tx, TxHandlingOptions); _logger.Info($"Sent transaction at price {tx.GasPrice} to {tx.SenderAddress}"); _logger.Info($"Contract {contractType} has been deployed"); return(txHash); }
private async Task <ResultWrapper <Keccak> > SendTx(Transaction tx) { try { Keccak txHash = await _txSender.SendTransaction(tx, TxHandlingOptions.PersistentBroadcast); return(ResultWrapper <Keccak> .Success(txHash)); } catch (SecurityException e) { return(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.AccountLocked)); } catch (Exception e) { return(ResultWrapper <Keccak> .Fail(e.Message, ErrorCodes.TransactionRejected)); } }
public ValueTask <Keccak?> SendOwnTransactionAsync(Transaction transaction) => _txSender.SendTransaction(transaction, TxHandlingOptions.ManagedNonce | TxHandlingOptions.PersistentBroadcast);
private static void SendTransaction(ITxSender txSender, Transaction transaction) { txSender.SendTransaction(transaction, TxHandlingOptions.ManagedNonce | TxHandlingOptions.PersistentBroadcast); }