Ejemplo n.º 1
0
 public static void Encode(XdrDataOutputStream stream, CreatePassiveOfferOp encodedCreatePassiveOfferOp)
 {
     Asset.Encode(stream, encodedCreatePassiveOfferOp.Selling);
     Asset.Encode(stream, encodedCreatePassiveOfferOp.Buying);
     Int64.Encode(stream, encodedCreatePassiveOfferOp.Amount);
     Price.Encode(stream, encodedCreatePassiveOfferOp.Price);
 }
Ejemplo n.º 2
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 CreatePassiveOffer builder from a CreatePassiveOfferOp XDR.
            /// </summary>
            /// <param name="op"></param>
            public Builder(sdkxdr.CreatePassiveOfferOp 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();
            }
Ejemplo n.º 4
0
        public static CreatePassiveOfferOp Decode(XdrDataInputStream stream)
        {
            CreatePassiveOfferOp decodedCreatePassiveOfferOp = new CreatePassiveOfferOp();

            decodedCreatePassiveOfferOp.Selling = Asset.Decode(stream);
            decodedCreatePassiveOfferOp.Buying  = Asset.Decode(stream);
            decodedCreatePassiveOfferOp.Amount  = Int64.Decode(stream);
            decodedCreatePassiveOfferOp.Price   = Price.Decode(stream);
            return(decodedCreatePassiveOfferOp);
        }
Ejemplo n.º 5
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;
                }
            }
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.CreatePassiveOfferOp();

            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 body = new sdkxdr.Operation.OperationBody();

            body.Discriminant         = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER);
            body.CreatePassiveOfferOp = op;

            return(body);
        }