public UInt256 ReadDepositBalance(Address onBehalfOf, Keccak depositId) { var txData = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.DepositBalanceAbiSig, depositId.Bytes); Transaction transaction = new Transaction(); transaction.Value = 0; transaction.Data = txData; transaction.To = _contractAddress; transaction.SenderAddress = onBehalfOf; transaction.GasLimit = 100000; transaction.GasPrice = 0.GWei(); transaction.Nonce = (UInt256)_blockchainBridge.GetNonce(onBehalfOf); _wallet.Sign(transaction, _blockchainBridge.GetNetworkId()); BlockchainBridge.CallOutput callOutput = _blockchainBridge.Call(_blockchainBridge.Head, transaction); return((callOutput.OutputData ?? new byte[] { 0 }).ToUInt256()); }
public async Task get_network_id_should_invoke_blockchain_bridge_get_network_id() { const int networkId = 1; _blockchainBridge.GetNetworkId().Returns(networkId); var result = await _ndmBridge.GetNetworkIdAsync(); _blockchainBridge.Received().GetNetworkId(); result.Should().Be(networkId); }
public Keccak ClaimRefund(Address onBehalfOf, RefundClaim refundClaim) { byte[] txData = _abiEncoder.Encode(AbiEncodingStyle.IncludeSignature, ContractData.ClaimRefundSig, refundClaim.AssetId.Bytes, refundClaim.Units, refundClaim.Value, refundClaim.ExpiryTime, refundClaim.Pepper, refundClaim.Provider, onBehalfOf); Transaction transaction = new Transaction(); transaction.Value = 0; transaction.Data = txData; transaction.To = _contractAddress; transaction.SenderAddress = onBehalfOf; transaction.GasLimit = 90000; // check transaction.GasPrice = 20.GWei(); transaction.Nonce = _txPool.ReserveOwnTransactionNonce(onBehalfOf); _wallet.Sign(transaction, _blockchainBridge.GetNetworkId()); if (_logger.IsInfo) { _logger.Info($"Sending a refund claim transaction for {refundClaim.DepositId} to be refunded to {refundClaim.RefundTo}"); } return(_blockchainBridge.SendTransaction(transaction, true)); }
public Task <int> GetNetworkIdAsync() => Task.FromResult(_blockchainBridge.GetNetworkId());