Ejemplo n.º 1
0
        public async Task TransferToVestingOperationTest()
        {
            var op       = new TransferToVestingOperation(User.Login, User.Login, new Asset(1, Config.SteemAssetNumSteem));
            var response = Post(User.ActiveKeys, false, op);

            Assert.IsFalse(response.IsError, response.GetErrorMessage());
        }
Ejemplo n.º 2
0
        public override async Task <OperationResult <VoidResponse> > PowerUpOrDown(PowerUpDownModel model, CancellationToken ct)
        {
            var isConnected = await TryReconnectChain(ct);

            if (!isConnected)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.EnableConnectToBlockchain)));
            }

            var keys = ToKeyArr(model.ActiveKey);

            if (keys == null)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.WrongPrivateActimeKey)));
            }

            var result = new OperationResult <VoidResponse>();

            BaseOperation op;

            Asset asset;

            if (model.PowerAction == PowerAction.PowerUp)
            {
                asset = new Asset($"{model.Value.ToString(CultureInfo.InvariantCulture)} GOLOS");
                op    = new TransferToVestingOperation(model.From, model.To, asset);
            }
            else
            {
                var vestsExchangeRatio = await GetVestsExchangeRatio(ct);

                if (!vestsExchangeRatio.IsSuccess)
                {
                    return(new OperationResult <VoidResponse>(vestsExchangeRatio.Exception));
                }

                asset = new Asset($"{(model.Value / vestsExchangeRatio.Result).ToString("F6", CultureInfo.InvariantCulture)} GESTS");
                op    = new WithdrawVestingOperation(model.From, asset);
            }

            var resp = await _operationManager.BroadcastOperationsSynchronous(keys, ct, op);

            if (resp.IsError)
            {
                result.Exception = new RequestException(resp);
            }
            else
            {
                result.Result = new VoidResponse();
            }
            return(result);
        }
Ejemplo n.º 3
0
        public override async Task <OperationResult <VoidResponse> > PowerUpOrDown(PowerUpDownModel model, CancellationToken ct)
        {
            var isConnected = await TryReconnectChain(ct);

            if (!isConnected)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.EnableConnectToBlockchain)));
            }

            var keys = ToKeyArr(model.ActiveKey);

            if (keys == null)
            {
                return(new OperationResult <VoidResponse>(new ValidationException(LocalizationKeys.WrongPrivateActimeKey)));
            }

            var asset = new Asset();

            BaseOperation op;

            if (model.PowerAction == PowerAction.PowerUp)
            {
                asset.FromOldFormat($"{model.Value.ToString(CultureInfo.InvariantCulture)} {Config.Steem}");
                op = new TransferToVestingOperation(model.From, model.To, asset);
            }
            else
            {
                var vestsExchangeRatio = await GetVestsExchangeRatio(ct);

                if (!vestsExchangeRatio.IsSuccess)
                {
                    return(new OperationResult <VoidResponse>(vestsExchangeRatio.Exception));
                }

                asset.FromOldFormat($"{(model.Value / vestsExchangeRatio.Result).ToString("F6", CultureInfo.InvariantCulture)} {Config.Vests}");
                op = new WithdrawVestingOperation(model.Login, asset);
            }

            return(await Broadcast(keys, new[] { op }, ct));
        }
Ejemplo n.º 4
0
        public async Task TransferToVestingOperationTest()
        {
            var op = new TransferToVestingOperation(User.Login, User.Login, new Asset(1, Config.SteemAssetNumSteem));

            await Post(User.ActiveKeys, false, op).ConfigureAwait(false);
        }
Ejemplo n.º 5
0
        public async Task TransferToVestingOperationTest()
        {
            var op = new TransferToVestingOperation(User.Login, User.Login, new Asset("0.001 GOLOS"));

            await Post(User.ActiveKeys, false, op).ConfigureAwait(false);
        }
Ejemplo n.º 6
0
 public TransferTable(long blockNum, short trxNum, short opNum, DateTime timestamp, TransferToVestingOperation operation)
     : base(blockNum, trxNum, opNum, timestamp)
 {
     From          = operation.From;
     To            = operation.To;
     Quantity      = operation.Amount.Amount;
     AssetNum      = (int)operation.Amount.Symbol.AssetNum;
     OperationType = operation.Type;
 }