示例#1
0
 /// <summary>
 /// Gets the gas limit for the transfer of this token from the user's address to another address.
 /// </summary>
 /// <param name="receivingAddress"> The address to be receiving the tokens. </param>
 /// <param name="amount"> The amount of tokens to send and test the gas limit for. </param>
 /// <param name="onLimitReceived"> Action to execute when the gas limit has been received. </param>
 public override void GetTransferGasLimit(string receivingAddress, dynamic amount, Action <BigInteger> onLimitReceived)
 {
     GasUtils.EstimateContractGasLimit <ERC20.Messages.Transfer>(erc20TokenContract.ContractAddress,
                                                                 userWalletManager.GetWalletAddress(),
                                                                 receivingAddress,
                                                                 SolidityUtils.ConvertToUInt(amount, AssetDecimals)).OnSuccess(onLimitReceived);
 }
    private void UpdateItemInfo(Hodler.Output.Item item, BigInteger lockedTimeStamp)
    {
        item.LockedTimeStamp = lockedTimeStamp;

        if (item.Unlockable && !item.UnlockableGasLimit.HasValue)
        {
            GasUtils.EstimateContractGasLimit <Hodler.Messages.Release>(hodlerContract.ContractAddress,
                                                                        userWalletManager.GetWalletAddress(),
                                                                        item.Id).OnSuccess(limit => item.UnlockableGasLimit = limit);
        }
    }
示例#3
0
        public async Task EstimateGasLimitTest()
        {
            ERC20.Messages.Transfer transfer = new ERC20.Messages.Transfer
            {
                To    = "0x5831819C84C05DdcD2568dE72963AC9f7e2833b6",
                Value = SolidityUtils.ConvertToUInt(1, 18)
            };

            BigInteger gasLimit = await GasUtils.EstimateContractGasLimit(
                transfer,
                "0x5831819C84C05DdcD2568dE72963AC9f1e6831b6",
                "0xb332Feee826BF44a431Ea3d65819e31578f30446");

            Assert.IsTrue(gasLimit > 0);
        }
    /// <summary>
    /// Gets the gas limit which would be used to lock the curent purpose balance.
    /// </summary>
    /// <param name="prpsBalance"> The output received from the BalanceOf function of the PRPS contract. </param>
    private void GetLockableGasLimit(SimpleOutputs.UInt256 prpsBalance)
    {
        PRPSBalance = SolidityUtils.ConvertFromUInt(prpsBalance.Value, 18);

        if (prpsBalance.Value <= 0)
        {
            return;
        }

        object[] funcParams = new object[] { estimationId, prpsBalance.Value, estimationMonths };
        GasUtils.EstimateContractGasLimit <Hodler.Messages.Hodl>(hodlerContract.ContractAddress,
                                                                 userWalletManager.GetWalletAddress(),
                                                                 funcParams).OnSuccess(limit => GasLimit = limit);

        OnAmountsUpdated?.Invoke();
    }