Ejemplo n.º 1
0
        public static LedgerKey Decode(XdrDataInputStream stream)
        {
            LedgerKey       decodedLedgerKey = new LedgerKey();
            LedgerEntryType discriminant     = LedgerEntryType.Decode(stream);

            decodedLedgerKey.Discriminant = discriminant;
            switch (decodedLedgerKey.Discriminant.InnerValue)
            {
            case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                decodedLedgerKey.Account = LedgerKeyAccount.Decode(stream);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                decodedLedgerKey.TrustLine = LedgerKeyTrustLine.Decode(stream);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                decodedLedgerKey.Offer = LedgerKeyOffer.Decode(stream);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                decodedLedgerKey.Data = LedgerKeyData.Decode(stream);
                break;
            }

            return(decodedLedgerKey);
        }
Ejemplo n.º 2
0
        public static void Encode(XdrDataOutputStream stream, LedgerKey encodedLedgerKey)
        {
            stream.WriteInt((int)encodedLedgerKey.Discriminant.InnerValue);
            switch (encodedLedgerKey.Discriminant.InnerValue)
            {
            case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                LedgerKeyAccount.Encode(stream, encodedLedgerKey.Account);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                LedgerKeyTrustLine.Encode(stream, encodedLedgerKey.TrustLine);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                LedgerKeyOffer.Encode(stream, encodedLedgerKey.Offer);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                LedgerKeyData.Encode(stream, encodedLedgerKey.Data);
                break;

            case LedgerEntryType.LedgerEntryTypeEnum.CLAIMABLE_BALANCE:
                LedgerKeyClaimableBalance.Encode(stream, encodedLedgerKey.ClaimableBalance);
                break;
            }
        }
Ejemplo n.º 3
0
        public static LedgerEntryChange Decode(XdrDataInputStream stream)
        {
            LedgerEntryChange     decodedLedgerEntryChange = new LedgerEntryChange();
            LedgerEntryChangeType discriminant             = LedgerEntryChangeType.Decode(stream);

            decodedLedgerEntryChange.Discriminant = discriminant;
            switch (decodedLedgerEntryChange.Discriminant.InnerValue)
            {
            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_CREATED:
                decodedLedgerEntryChange.Created = LedgerEntry.Decode(stream);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_UPDATED:
                decodedLedgerEntryChange.Updated = LedgerEntry.Decode(stream);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_REMOVED:
                decodedLedgerEntryChange.Removed = LedgerKey.Decode(stream);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_STATE:
                decodedLedgerEntryChange.State = LedgerEntry.Decode(stream);
                break;
            }
            return(decodedLedgerEntryChange);
        }
Ejemplo n.º 4
0
        public static void Encode(XdrDataOutputStream stream, RevokeSponsorshipOp encodedRevokeSponsorshipOp)
        {
            stream.WriteInt((int)encodedRevokeSponsorshipOp.Discriminant.InnerValue);
            switch (encodedRevokeSponsorshipOp.Discriminant.InnerValue)
            {
            case RevokeSponsorshipType.RevokeSponsorshipTypeEnum.REVOKE_SPONSORSHIP_LEDGER_ENTRY:
                LedgerKey.Encode(stream, encodedRevokeSponsorshipOp.LedgerKey);
                break;

            case RevokeSponsorshipType.RevokeSponsorshipTypeEnum.REVOKE_SPONSORSHIP_SIGNER:
                RevokeSponsorshipOpSigner.Encode(stream, encodedRevokeSponsorshipOp.Signer);
                break;
            }
        }
Ejemplo n.º 5
0
        public static void Encode(XdrDataOutputStream stream, BucketEntry encodedBucketEntry)
        {
            stream.WriteInt((int)encodedBucketEntry.Discriminant.InnerValue);
            switch (encodedBucketEntry.Discriminant.InnerValue)
            {
            case BucketEntryType.BucketEntryTypeEnum.LIVEENTRY:
                LedgerEntry.Encode(stream, encodedBucketEntry.LiveEntry);
                break;

            case BucketEntryType.BucketEntryTypeEnum.DEADENTRY:
                LedgerKey.Encode(stream, encodedBucketEntry.DeadEntry);
                break;
            }
        }
Ejemplo n.º 6
0
        public static RevokeSponsorshipOp Decode(XdrDataInputStream stream)
        {
            RevokeSponsorshipOp   decodedRevokeSponsorshipOp = new RevokeSponsorshipOp();
            RevokeSponsorshipType discriminant = RevokeSponsorshipType.Decode(stream);

            decodedRevokeSponsorshipOp.Discriminant = discriminant;
            switch (decodedRevokeSponsorshipOp.Discriminant.InnerValue)
            {
            case RevokeSponsorshipType.RevokeSponsorshipTypeEnum.REVOKE_SPONSORSHIP_LEDGER_ENTRY:
                decodedRevokeSponsorshipOp.LedgerKey = LedgerKey.Decode(stream);
                break;

            case RevokeSponsorshipType.RevokeSponsorshipTypeEnum.REVOKE_SPONSORSHIP_SIGNER:
                decodedRevokeSponsorshipOp.Signer = RevokeSponsorshipOpSigner.Decode(stream);
                break;
            }
            return(decodedRevokeSponsorshipOp);
        }
Ejemplo n.º 7
0
        public static BucketEntry Decode(XdrDataInputStream stream)
        {
            BucketEntry     decodedBucketEntry = new BucketEntry();
            BucketEntryType discriminant       = BucketEntryType.Decode(stream);

            decodedBucketEntry.Discriminant = discriminant;
            switch (decodedBucketEntry.Discriminant.InnerValue)
            {
            case BucketEntryType.BucketEntryTypeEnum.LIVEENTRY:
                decodedBucketEntry.LiveEntry = LedgerEntry.Decode(stream);
                break;

            case BucketEntryType.BucketEntryTypeEnum.DEADENTRY:
                decodedBucketEntry.DeadEntry = LedgerKey.Decode(stream);
                break;
            }
            return(decodedBucketEntry);
        }
Ejemplo n.º 8
0
        public static void Encode(XdrDataOutputStream stream, LedgerEntryChange encodedLedgerEntryChange)
        {
            stream.WriteInt((int)encodedLedgerEntryChange.Discriminant.InnerValue);
            switch (encodedLedgerEntryChange.Discriminant.InnerValue)
            {
            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_CREATED:
                LedgerEntry.Encode(stream, encodedLedgerEntryChange.Created);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_UPDATED:
                LedgerEntry.Encode(stream, encodedLedgerEntryChange.Updated);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_REMOVED:
                LedgerKey.Encode(stream, encodedLedgerEntryChange.Removed);
                break;

            case LedgerEntryChangeType.LedgerEntryChangeTypeEnum.LEDGER_ENTRY_STATE:
                LedgerEntry.Encode(stream, encodedLedgerEntryChange.State);
                break;
            }
        }
Ejemplo n.º 9
0
        public static LedgerKey FromXdr(xdr.LedgerKey xdr)
        {
            switch (xdr.Discriminant.InnerValue)
            {
            case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                return(LedgerKeyAccount.FromXdr(xdr.Account));

            case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                return(LedgerKeyData.FromXdr(xdr.Data));

            case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                return(LedgerKeyOffer.FromXdr(xdr.Offer));

            case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                return(LedgerKeyTrustline.FromXdr(xdr.TrustLine));

            case LedgerEntryType.LedgerEntryTypeEnum.CLAIMABLE_BALANCE:
                return(LedgerKeyClaimableBalance.FromXdr(xdr.ClaimableBalance));

            default:
                throw new Exception("Unknown ledger key " + xdr.Discriminant.InnerValue);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 ///     Construct a new RevokeLedgerEntrySponsorshipOperation builder from a LedgerKey XDR.
 /// </summary>
 /// <param name="ledgerKey"></param>
 public Builder(xdr.LedgerKey ledgerKey)
 {
     _ledgerKey = LedgerKey.FromXdr(ledgerKey);
 }