Пример #1
0
        public static Operation FromXDR(Generated.Operation xdr)
        {
            var       body      = xdr.Body;
            Operation operation = null;

            switch (body.Discriminant.InnerValue)
            {
            case Generated.OperationType.OperationTypeEnum.CREATE_ACCOUNT:
                operation = new CreateAccountOperation.Builder(body.CreateAccountOp).Build();
                break;

            case Generated.OperationType.OperationTypeEnum.PAYMENT:
                operation = new PaymentOperation.Builder(body.PaymentOp).Build();
                break;

            case Generated.OperationType.OperationTypeEnum.PATH_PAYMENT:
                //operation = new PathPaymentOperation.Builder(body.getPathPaymentOp()).build();
                break;

            case Generated.OperationType.OperationTypeEnum.MANAGE_OFFER:
                //operation = new ManagerOfferOperation.Builder(body.getManageOfferOp()).build();
                break;

            case Generated.OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER:
                //operation = new CreatePassiveOfferOperation.Builder(body.getCreatePassiveOfferOp()).build();
                break;

            case Generated.OperationType.OperationTypeEnum.SET_OPTIONS:
                //operation = new SetOptionsOperation.Builder(body.getSetOptionsOp()).build();
                break;

            case Generated.OperationType.OperationTypeEnum.CHANGE_TRUST:
                operation = new ChangeTrustOperation.Builder(body.ChangeTrustOp).Build();
                break;

            case Generated.OperationType.OperationTypeEnum.ALLOW_TRUST:
                //operation = new AllowTrustOperation.Builder(body.getAllowTrustOp()).build();
                break;

            case Generated.OperationType.OperationTypeEnum.ACCOUNT_MERGE:
                //operation = new AccountMergeOperation.Builder(body).build();
                break;

            default:
                throw new Exception("Unknown operation body " + body.Discriminant.InnerValue);
            }
            if (xdr.SourceAccount != null)
            {
                operation.SourceAccount = KeyPair.FromXdrPublicKey(xdr.SourceAccount.InnerValue);
            }
            return(operation);
        }
Пример #2
0
        public static Asset FromXDR(Generated.Asset asset)
        {
            switch (asset.Discriminant.InnerValue)
            {
            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_NATIVE:
                return(new Asset());

            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4:
                return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum4.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum4.Issuer.InnerValue)));

            case Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12:
                return(new Asset(Encoding.ASCII.GetString(asset.AlphaNum12.AssetCode), KeyPair.FromXdrPublicKey(asset.AlphaNum12.Issuer.InnerValue)));

            default:
                throw new ArgumentException("无效地资产");
            }
        }
Пример #3
0
 public Builder(Generated.CreateAccountOp op)
 {
     Destination     = KeyPair.FromXdrPublicKey(op.Destination.InnerValue);
     StartingBalance = op.StartingBalance.InnerValue;
 }
Пример #4
0
 public Builder(Generated.PaymentOp op)
 {
     Destination = KeyPair.FromXdrPublicKey(op.Destination.InnerValue);
     Asset       = Asset.FromXDR(op.Asset);
     Amount      = op.Amount.InnerValue;
 }