public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.ManageOfferOp();

            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            var amount = new sdkxdr.Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            var price = stellar_dotnet_sdk.Price.FromString(Price);

            op.Price = price.ToXdr();
            var offerId = new sdkxdr.Uint64();

            offerId.InnerValue = OfferId;
            op.OfferID         = offerId;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.MANAGE_OFFER);
            body.ManageOfferOp = op;

            return(body);
        }
Ejemplo n.º 2
0
 public static void Encode(XdrDataOutputStream stream, ManageOfferOp encodedManageOfferOp)
 {
     Asset.Encode(stream, encodedManageOfferOp.Selling);
     Asset.Encode(stream, encodedManageOfferOp.Buying);
     Int64.Encode(stream, encodedManageOfferOp.Amount);
     Price.Encode(stream, encodedManageOfferOp.Price);
     Uint64.Encode(stream, encodedManageOfferOp.OfferID);
 }
Ejemplo n.º 3
0
            public static OperationBody Decode(XdrDataInputStream stream)
            {
                OperationBody decodedOperationBody = new OperationBody();
                OperationType discriminant         = OperationType.Decode(stream);

                decodedOperationBody.Discriminant = discriminant;
                switch (decodedOperationBody.Discriminant.InnerValue)
                {
                case OperationType.OperationTypeEnum.CREATE_ACCOUNT:
                    decodedOperationBody.CreateAccountOp = CreateAccountOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.PAYMENT:
                    decodedOperationBody.PaymentOp = PaymentOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT:
                    decodedOperationBody.PathPaymentOp = PathPaymentOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_OFFER:
                    decodedOperationBody.ManageOfferOp = ManageOfferOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER:
                    decodedOperationBody.CreatePassiveOfferOp = CreatePassiveOfferOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.SET_OPTIONS:
                    decodedOperationBody.SetOptionsOp = SetOptionsOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CHANGE_TRUST:
                    decodedOperationBody.ChangeTrustOp = ChangeTrustOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.ALLOW_TRUST:
                    decodedOperationBody.AllowTrustOp = AllowTrustOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.ACCOUNT_MERGE:
                    decodedOperationBody.Destination = AccountID.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.INFLATION:
                    break;

                case OperationType.OperationTypeEnum.MANAGE_DATA:
                    decodedOperationBody.ManageDataOp = ManageDataOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.BUMP_SEQUENCE:
                    decodedOperationBody.BumpSequenceOp = BumpSequenceOp.Decode(stream);
                    break;
                }
                return(decodedOperationBody);
            }
            /// <summary>
            ///     Construct a new CreateAccount builder from a CreateAccountOp XDR.
            /// </summary>
            /// <param name="op">
            ///     <see cref="sdkxdr.ManageOfferOp" />
            /// </param>
            public Builder(sdkxdr.ManageOfferOp op)
            {
                _Selling = Asset.FromXdr(op.Selling);
                _Buying  = Asset.FromXdr(op.Buying);
                _Amount  = FromXdrAmount(op.Amount.InnerValue);
                var n = new decimal(op.Price.N.InnerValue);
                var d = new decimal(op.Price.D.InnerValue);

                _Price  = decimal.Divide(n, d).ToString();
                offerId = op.OfferID.InnerValue;
            }
Ejemplo n.º 5
0
        public static ManageOfferOp Decode(XdrDataInputStream stream)
        {
            ManageOfferOp decodedManageOfferOp = new ManageOfferOp();

            decodedManageOfferOp.Selling = Asset.Decode(stream);
            decodedManageOfferOp.Buying  = Asset.Decode(stream);
            decodedManageOfferOp.Amount  = Int64.Decode(stream);
            decodedManageOfferOp.Price   = Price.Decode(stream);
            decodedManageOfferOp.OfferID = Uint64.Decode(stream);
            return(decodedManageOfferOp);
        }
Ejemplo n.º 6
0
            public static void Encode(XdrDataOutputStream stream, OperationBody encodedOperationBody)
            {
                stream.WriteInt((int)encodedOperationBody.Discriminant.InnerValue);
                switch (encodedOperationBody.Discriminant.InnerValue)
                {
                case OperationType.OperationTypeEnum.CREATE_ACCOUNT:
                    CreateAccountOp.Encode(stream, encodedOperationBody.CreateAccountOp);
                    break;

                case OperationType.OperationTypeEnum.PAYMENT:
                    PaymentOp.Encode(stream, encodedOperationBody.PaymentOp);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT:
                    PathPaymentOp.Encode(stream, encodedOperationBody.PathPaymentOp);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_OFFER:
                    ManageOfferOp.Encode(stream, encodedOperationBody.ManageOfferOp);
                    break;

                case OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER:
                    CreatePassiveOfferOp.Encode(stream, encodedOperationBody.CreatePassiveOfferOp);
                    break;

                case OperationType.OperationTypeEnum.SET_OPTIONS:
                    SetOptionsOp.Encode(stream, encodedOperationBody.SetOptionsOp);
                    break;

                case OperationType.OperationTypeEnum.CHANGE_TRUST:
                    ChangeTrustOp.Encode(stream, encodedOperationBody.ChangeTrustOp);
                    break;

                case OperationType.OperationTypeEnum.ALLOW_TRUST:
                    AllowTrustOp.Encode(stream, encodedOperationBody.AllowTrustOp);
                    break;

                case OperationType.OperationTypeEnum.ACCOUNT_MERGE:
                    AccountID.Encode(stream, encodedOperationBody.Destination);
                    break;

                case OperationType.OperationTypeEnum.INFLATION:
                    break;

                case OperationType.OperationTypeEnum.MANAGE_DATA:
                    ManageDataOp.Encode(stream, encodedOperationBody.ManageDataOp);
                    break;

                case OperationType.OperationTypeEnum.BUMP_SEQUENCE:
                    BumpSequenceOp.Encode(stream, encodedOperationBody.BumpSequenceOp);
                    break;
                }
            }