UNPKG

xdb-digitalbits-base

Version:
1,463 lines (1,372 loc) 185 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _jsXdr = require("js-xdr"); var XDR = _interopRequireWildcard(_jsXdr); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } var types = XDR.config(function (xdr) { // === xdr source ============================================================ // // typedef PublicKey AccountID; // // =========================================================================== xdr.typedef("AccountId", xdr.lookup("PublicKey")); // === xdr source ============================================================ // // typedef opaque Thresholds[4]; // // =========================================================================== xdr.typedef("Thresholds", xdr.opaque(4)); // === xdr source ============================================================ // // typedef string string32<32>; // // =========================================================================== xdr.typedef("String32", xdr.string(32)); // === xdr source ============================================================ // // typedef string string64<64>; // // =========================================================================== xdr.typedef("String64", xdr.string(64)); // === xdr source ============================================================ // // typedef int64 SequenceNumber; // // =========================================================================== xdr.typedef("SequenceNumber", xdr.lookup("Int64")); // === xdr source ============================================================ // // typedef uint64 TimePoint; // // =========================================================================== xdr.typedef("TimePoint", xdr.lookup("Uint64")); // === xdr source ============================================================ // // typedef opaque DataValue<64>; // // =========================================================================== xdr.typedef("DataValue", xdr.varOpaque(64)); // === xdr source ============================================================ // // typedef opaque AssetCode4[4]; // // =========================================================================== xdr.typedef("AssetCode4", xdr.opaque(4)); // === xdr source ============================================================ // // typedef opaque AssetCode12[12]; // // =========================================================================== xdr.typedef("AssetCode12", xdr.opaque(12)); // === xdr source ============================================================ // // enum AssetType // { // ASSET_TYPE_NATIVE = 0, // ASSET_TYPE_CREDIT_ALPHANUM4 = 1, // ASSET_TYPE_CREDIT_ALPHANUM12 = 2 // }; // // =========================================================================== xdr.enum("AssetType", { assetTypeNative: 0, assetTypeCreditAlphanum4: 1, assetTypeCreditAlphanum12: 2 }); // === xdr source ============================================================ // // union AssetCode switch (AssetType type) // { // case ASSET_TYPE_CREDIT_ALPHANUM4: // AssetCode4 assetCode4; // // case ASSET_TYPE_CREDIT_ALPHANUM12: // AssetCode12 assetCode12; // // // add other asset types here in the future // }; // // =========================================================================== xdr.union("AssetCode", { switchOn: xdr.lookup("AssetType"), switchName: "type", switches: [["assetTypeCreditAlphanum4", "assetCode4"], ["assetTypeCreditAlphanum12", "assetCode12"]], arms: { assetCode4: xdr.lookup("AssetCode4"), assetCode12: xdr.lookup("AssetCode12") } }); // === xdr source ============================================================ // // struct // { // AssetCode4 assetCode; // AccountID issuer; // } // // =========================================================================== xdr.struct("AssetAlphaNum4", [["assetCode", xdr.lookup("AssetCode4")], ["issuer", xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // struct // { // AssetCode12 assetCode; // AccountID issuer; // } // // =========================================================================== xdr.struct("AssetAlphaNum12", [["assetCode", xdr.lookup("AssetCode12")], ["issuer", xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // union Asset switch (AssetType type) // { // case ASSET_TYPE_NATIVE: // Not credit // void; // // case ASSET_TYPE_CREDIT_ALPHANUM4: // struct // { // AssetCode4 assetCode; // AccountID issuer; // } alphaNum4; // // case ASSET_TYPE_CREDIT_ALPHANUM12: // struct // { // AssetCode12 assetCode; // AccountID issuer; // } alphaNum12; // // // add other asset types here in the future // }; // // =========================================================================== xdr.union("Asset", { switchOn: xdr.lookup("AssetType"), switchName: "type", switches: [["assetTypeNative", xdr.void()], ["assetTypeCreditAlphanum4", "alphaNum4"], ["assetTypeCreditAlphanum12", "alphaNum12"]], arms: { alphaNum4: xdr.lookup("AssetAlphaNum4"), alphaNum12: xdr.lookup("AssetAlphaNum12") } }); // === xdr source ============================================================ // // struct Price // { // int32 n; // numerator // int32 d; // denominator // }; // // =========================================================================== xdr.struct("Price", [["n", xdr.lookup("Int32")], ["d", xdr.lookup("Int32")]]); // === xdr source ============================================================ // // struct Liabilities // { // int64 buying; // int64 selling; // }; // // =========================================================================== xdr.struct("Liabilities", [["buying", xdr.lookup("Int64")], ["selling", xdr.lookup("Int64")]]); // === xdr source ============================================================ // // enum ThresholdIndexes // { // THRESHOLD_MASTER_WEIGHT = 0, // THRESHOLD_LOW = 1, // THRESHOLD_MED = 2, // THRESHOLD_HIGH = 3 // }; // // =========================================================================== xdr.enum("ThresholdIndices", { thresholdMasterWeight: 0, thresholdLow: 1, thresholdMed: 2, thresholdHigh: 3 }); // === xdr source ============================================================ // // enum LedgerEntryType // { // ACCOUNT = 0, // TRUSTLINE = 1, // OFFER = 2, // DATA = 3, // CLAIMABLE_BALANCE = 4 // }; // // =========================================================================== xdr.enum("LedgerEntryType", { account: 0, trustline: 1, offer: 2, data: 3, claimableBalance: 4 }); // === xdr source ============================================================ // // struct Signer // { // SignerKey key; // uint32 weight; // really only need 1 byte // }; // // =========================================================================== xdr.struct("Signer", [["key", xdr.lookup("SignerKey")], ["weight", xdr.lookup("Uint32")]]); // === xdr source ============================================================ // // enum AccountFlags // { // masks for each flag // // // Flags set on issuer accounts // // TrustLines are created with authorized set to "false" requiring // // the issuer to set it for each TrustLine // AUTH_REQUIRED_FLAG = 0x1, // // If set, the authorized flag in TrustLines can be cleared // // otherwise, authorization cannot be revoked // AUTH_REVOCABLE_FLAG = 0x2, // // Once set, causes all AUTH_* flags to be read-only // AUTH_IMMUTABLE_FLAG = 0x4, // // Trustlines are created with clawback enabled set to "true", // // and claimable balances created from those trustlines are created // // with clawback enabled set to "true" // AUTH_CLAWBACK_ENABLED_FLAG = 0x8 // }; // // =========================================================================== xdr.enum("AccountFlags", { authRequiredFlag: 1, authRevocableFlag: 2, authImmutableFlag: 4, authClawbackEnabledFlag: 8 }); // === xdr source ============================================================ // // const MASK_ACCOUNT_FLAGS = 0x7; // // =========================================================================== xdr.const("MASK_ACCOUNT_FLAGS", 0x7); // === xdr source ============================================================ // // const MASK_ACCOUNT_FLAGS_V16 = 0xF; // // =========================================================================== xdr.const("MASK_ACCOUNT_FLAGS_V16", 0xF); // === xdr source ============================================================ // // const MAX_SIGNERS = 20; // // =========================================================================== xdr.const("MAX_SIGNERS", 20); // === xdr source ============================================================ // // typedef AccountID* SponsorshipDescriptor; // // =========================================================================== xdr.typedef("SponsorshipDescriptor", xdr.option(xdr.lookup("AccountId"))); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("AccountEntryExtensionV2Ext", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct AccountEntryExtensionV2 // { // uint32 numSponsored; // uint32 numSponsoring; // SponsorshipDescriptor signerSponsoringIDs<MAX_SIGNERS>; // // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("AccountEntryExtensionV2", [["numSponsored", xdr.lookup("Uint32")], ["numSponsoring", xdr.lookup("Uint32")], ["signerSponsoringIDs", xdr.varArray(xdr.lookup("SponsorshipDescriptor"), xdr.lookup("MAX_SIGNERS"))], ["ext", xdr.lookup("AccountEntryExtensionV2Ext")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // case 2: // AccountEntryExtensionV2 v2; // } // // =========================================================================== xdr.union("AccountEntryExtensionV1Ext", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()], [2, "v2"]], arms: { v2: xdr.lookup("AccountEntryExtensionV2") } }); // === xdr source ============================================================ // // struct AccountEntryExtensionV1 // { // Liabilities liabilities; // // union switch (int v) // { // case 0: // void; // case 2: // AccountEntryExtensionV2 v2; // } // ext; // }; // // =========================================================================== xdr.struct("AccountEntryExtensionV1", [["liabilities", xdr.lookup("Liabilities")], ["ext", xdr.lookup("AccountEntryExtensionV1Ext")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // case 1: // AccountEntryExtensionV1 v1; // } // // =========================================================================== xdr.union("AccountEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()], [1, "v1"]], arms: { v1: xdr.lookup("AccountEntryExtensionV1") } }); // === xdr source ============================================================ // // struct AccountEntry // { // AccountID accountID; // master public key for this account // int64 balance; // in nibbs // SequenceNumber seqNum; // last sequence number used for this account // uint32 numSubEntries; // number of sub-entries this account has // // drives the reserve // AccountID* inflationDest; // Account to vote for during inflation // uint32 flags; // see AccountFlags // // string32 homeDomain; // can be used for reverse federation and memo lookup // // // fields used for signatures // // thresholds stores unsigned bytes: [weight of master|low|medium|high] // Thresholds thresholds; // // Signer signers<MAX_SIGNERS>; // possible signers for this account // // // reserved for future use // union switch (int v) // { // case 0: // void; // case 1: // AccountEntryExtensionV1 v1; // } // ext; // }; // // =========================================================================== xdr.struct("AccountEntry", [["accountId", xdr.lookup("AccountId")], ["balance", xdr.lookup("Int64")], ["seqNum", xdr.lookup("SequenceNumber")], ["numSubEntries", xdr.lookup("Uint32")], ["inflationDest", xdr.option(xdr.lookup("AccountId"))], ["flags", xdr.lookup("Uint32")], ["homeDomain", xdr.lookup("String32")], ["thresholds", xdr.lookup("Thresholds")], ["signers", xdr.varArray(xdr.lookup("Signer"), xdr.lookup("MAX_SIGNERS"))], ["ext", xdr.lookup("AccountEntryExt")]]); // === xdr source ============================================================ // // enum TrustLineFlags // { // // issuer has authorized account to perform transactions with its credit // AUTHORIZED_FLAG = 1, // // issuer has authorized account to maintain and reduce liabilities for its // // credit // AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG = 2, // // issuer has specified that it may clawback its credit, and that claimable // // balances created with its credit may also be clawed back // TRUSTLINE_CLAWBACK_ENABLED_FLAG = 4 // }; // // =========================================================================== xdr.enum("TrustLineFlags", { authorizedFlag: 1, authorizedToMaintainLiabilitiesFlag: 2, trustlineClawbackEnabledFlag: 4 }); // === xdr source ============================================================ // // const MASK_TRUSTLINE_FLAGS = 1; // // =========================================================================== xdr.const("MASK_TRUSTLINE_FLAGS", 1); // === xdr source ============================================================ // // const MASK_TRUSTLINE_FLAGS_V13 = 3; // // =========================================================================== xdr.const("MASK_TRUSTLINE_FLAGS_V13", 3); // === xdr source ============================================================ // // const MASK_TRUSTLINE_FLAGS_V16 = 7; // // =========================================================================== xdr.const("MASK_TRUSTLINE_FLAGS_V16", 7); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("TrustLineEntryV1Ext", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct // { // Liabilities liabilities; // // union switch (int v) // { // case 0: // void; // } // ext; // } // // =========================================================================== xdr.struct("TrustLineEntryV1", [["liabilities", xdr.lookup("Liabilities")], ["ext", xdr.lookup("TrustLineEntryV1Ext")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // case 1: // struct // { // Liabilities liabilities; // // union switch (int v) // { // case 0: // void; // } // ext; // } v1; // } // // =========================================================================== xdr.union("TrustLineEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()], [1, "v1"]], arms: { v1: xdr.lookup("TrustLineEntryV1") } }); // === xdr source ============================================================ // // struct TrustLineEntry // { // AccountID accountID; // account this trustline belongs to // Asset asset; // type of asset (with issuer) // int64 balance; // how much of this asset the user has. // // Asset defines the unit for this; // // int64 limit; // balance cannot be above this // uint32 flags; // see TrustLineFlags // // // reserved for future use // union switch (int v) // { // case 0: // void; // case 1: // struct // { // Liabilities liabilities; // // union switch (int v) // { // case 0: // void; // } // ext; // } v1; // } // ext; // }; // // =========================================================================== xdr.struct("TrustLineEntry", [["accountId", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")], ["balance", xdr.lookup("Int64")], ["limit", xdr.lookup("Int64")], ["flags", xdr.lookup("Uint32")], ["ext", xdr.lookup("TrustLineEntryExt")]]); // === xdr source ============================================================ // // enum OfferEntryFlags // { // // issuer has authorized account to perform transactions with its credit // PASSIVE_FLAG = 1 // }; // // =========================================================================== xdr.enum("OfferEntryFlags", { passiveFlag: 1 }); // === xdr source ============================================================ // // const MASK_OFFERENTRY_FLAGS = 1; // // =========================================================================== xdr.const("MASK_OFFERENTRY_FLAGS", 1); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("OfferEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct OfferEntry // { // AccountID sellerID; // int64 offerID; // Asset selling; // A // Asset buying; // B // int64 amount; // amount of A // // /* price for this offer: // price of A in terms of B // price=AmountB/AmountA=priceNumerator/priceDenominator // price is after fees // */ // Price price; // uint32 flags; // see OfferEntryFlags // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("OfferEntry", [["sellerId", xdr.lookup("AccountId")], ["offerId", xdr.lookup("Int64")], ["selling", xdr.lookup("Asset")], ["buying", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")], ["price", xdr.lookup("Price")], ["flags", xdr.lookup("Uint32")], ["ext", xdr.lookup("OfferEntryExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("DataEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct DataEntry // { // AccountID accountID; // account this data belongs to // string64 dataName; // DataValue dataValue; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("DataEntry", [["accountId", xdr.lookup("AccountId")], ["dataName", xdr.lookup("String64")], ["dataValue", xdr.lookup("DataValue")], ["ext", xdr.lookup("DataEntryExt")]]); // === xdr source ============================================================ // // enum ClaimPredicateType // { // CLAIM_PREDICATE_UNCONDITIONAL = 0, // CLAIM_PREDICATE_AND = 1, // CLAIM_PREDICATE_OR = 2, // CLAIM_PREDICATE_NOT = 3, // CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME = 4, // CLAIM_PREDICATE_BEFORE_RELATIVE_TIME = 5 // }; // // =========================================================================== xdr.enum("ClaimPredicateType", { claimPredicateUnconditional: 0, claimPredicateAnd: 1, claimPredicateOr: 2, claimPredicateNot: 3, claimPredicateBeforeAbsoluteTime: 4, claimPredicateBeforeRelativeTime: 5 }); // === xdr source ============================================================ // // union ClaimPredicate switch (ClaimPredicateType type) // { // case CLAIM_PREDICATE_UNCONDITIONAL: // void; // case CLAIM_PREDICATE_AND: // ClaimPredicate andPredicates<2>; // case CLAIM_PREDICATE_OR: // ClaimPredicate orPredicates<2>; // case CLAIM_PREDICATE_NOT: // ClaimPredicate* notPredicate; // case CLAIM_PREDICATE_BEFORE_ABSOLUTE_TIME: // int64 absBefore; // Predicate will be true if closeTime < absBefore // case CLAIM_PREDICATE_BEFORE_RELATIVE_TIME: // int64 relBefore; // Seconds since closeTime of the ledger in which the // // ClaimableBalanceEntry was created // }; // // =========================================================================== xdr.union("ClaimPredicate", { switchOn: xdr.lookup("ClaimPredicateType"), switchName: "type", switches: [["claimPredicateUnconditional", xdr.void()], ["claimPredicateAnd", "andPredicates"], ["claimPredicateOr", "orPredicates"], ["claimPredicateNot", "notPredicate"], ["claimPredicateBeforeAbsoluteTime", "absBefore"], ["claimPredicateBeforeRelativeTime", "relBefore"]], arms: { andPredicates: xdr.varArray(xdr.lookup("ClaimPredicate"), 2), orPredicates: xdr.varArray(xdr.lookup("ClaimPredicate"), 2), notPredicate: xdr.option(xdr.lookup("ClaimPredicate")), absBefore: xdr.lookup("Int64"), relBefore: xdr.lookup("Int64") } }); // === xdr source ============================================================ // // enum ClaimantType // { // CLAIMANT_TYPE_V0 = 0 // }; // // =========================================================================== xdr.enum("ClaimantType", { claimantTypeV0: 0 }); // === xdr source ============================================================ // // struct // { // AccountID destination; // The account that can use this condition // ClaimPredicate predicate; // Claimable if predicate is true // } // // =========================================================================== xdr.struct("ClaimantV0", [["destination", xdr.lookup("AccountId")], ["predicate", xdr.lookup("ClaimPredicate")]]); // === xdr source ============================================================ // // union Claimant switch (ClaimantType type) // { // case CLAIMANT_TYPE_V0: // struct // { // AccountID destination; // The account that can use this condition // ClaimPredicate predicate; // Claimable if predicate is true // } v0; // }; // // =========================================================================== xdr.union("Claimant", { switchOn: xdr.lookup("ClaimantType"), switchName: "type", switches: [["claimantTypeV0", "v0"]], arms: { v0: xdr.lookup("ClaimantV0") } }); // === xdr source ============================================================ // // enum ClaimableBalanceIDType // { // CLAIMABLE_BALANCE_ID_TYPE_V0 = 0 // }; // // =========================================================================== xdr.enum("ClaimableBalanceIdType", { claimableBalanceIdTypeV0: 0 }); // === xdr source ============================================================ // // union ClaimableBalanceID switch (ClaimableBalanceIDType type) // { // case CLAIMABLE_BALANCE_ID_TYPE_V0: // Hash v0; // }; // // =========================================================================== xdr.union("ClaimableBalanceId", { switchOn: xdr.lookup("ClaimableBalanceIdType"), switchName: "type", switches: [["claimableBalanceIdTypeV0", "v0"]], arms: { v0: xdr.lookup("Hash") } }); // === xdr source ============================================================ // // enum ClaimableBalanceFlags // { // // If set, the issuer account of the asset held by the claimable balance may // // clawback the claimable balance // CLAIMABLE_BALANCE_CLAWBACK_ENABLED_FLAG = 0x1 // }; // // =========================================================================== xdr.enum("ClaimableBalanceFlags", { claimableBalanceClawbackEnabledFlag: 1 }); // === xdr source ============================================================ // // const MASK_CLAIMABLE_BALANCE_FLAGS = 0x1; // // =========================================================================== xdr.const("MASK_CLAIMABLE_BALANCE_FLAGS", 0x1); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("ClaimableBalanceEntryExtensionV1Ext", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct ClaimableBalanceEntryExtensionV1 // { // union switch (int v) // { // case 0: // void; // } // ext; // // uint32 flags; // see ClaimableBalanceFlags // }; // // =========================================================================== xdr.struct("ClaimableBalanceEntryExtensionV1", [["ext", xdr.lookup("ClaimableBalanceEntryExtensionV1Ext")], ["flags", xdr.lookup("Uint32")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // case 1: // ClaimableBalanceEntryExtensionV1 v1; // } // // =========================================================================== xdr.union("ClaimableBalanceEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()], [1, "v1"]], arms: { v1: xdr.lookup("ClaimableBalanceEntryExtensionV1") } }); // === xdr source ============================================================ // // struct ClaimableBalanceEntry // { // // Unique identifier for this ClaimableBalanceEntry // ClaimableBalanceID balanceID; // // // List of claimants with associated predicate // Claimant claimants<10>; // // // Any asset including native // Asset asset; // // // Amount of asset // int64 amount; // // // reserved for future use // union switch (int v) // { // case 0: // void; // case 1: // ClaimableBalanceEntryExtensionV1 v1; // } // ext; // }; // // =========================================================================== xdr.struct("ClaimableBalanceEntry", [["balanceId", xdr.lookup("ClaimableBalanceId")], ["claimants", xdr.varArray(xdr.lookup("Claimant"), 10)], ["asset", xdr.lookup("Asset")], ["amount", xdr.lookup("Int64")], ["ext", xdr.lookup("ClaimableBalanceEntryExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("LedgerEntryExtensionV1Ext", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct LedgerEntryExtensionV1 // { // SponsorshipDescriptor sponsoringID; // // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerEntryExtensionV1", [["sponsoringId", xdr.lookup("SponsorshipDescriptor")], ["ext", xdr.lookup("LedgerEntryExtensionV1Ext")]]); // === xdr source ============================================================ // // union switch (LedgerEntryType type) // { // case ACCOUNT: // AccountEntry account; // case TRUSTLINE: // TrustLineEntry trustLine; // case OFFER: // OfferEntry offer; // case DATA: // DataEntry data; // case CLAIMABLE_BALANCE: // ClaimableBalanceEntry claimableBalance; // } // // =========================================================================== xdr.union("LedgerEntryData", { switchOn: xdr.lookup("LedgerEntryType"), switchName: "type", switches: [["account", "account"], ["trustline", "trustLine"], ["offer", "offer"], ["data", "data"], ["claimableBalance", "claimableBalance"]], arms: { account: xdr.lookup("AccountEntry"), trustLine: xdr.lookup("TrustLineEntry"), offer: xdr.lookup("OfferEntry"), data: xdr.lookup("DataEntry"), claimableBalance: xdr.lookup("ClaimableBalanceEntry") } }); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // case 1: // LedgerEntryExtensionV1 v1; // } // // =========================================================================== xdr.union("LedgerEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()], [1, "v1"]], arms: { v1: xdr.lookup("LedgerEntryExtensionV1") } }); // === xdr source ============================================================ // // struct LedgerEntry // { // uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed // // union switch (LedgerEntryType type) // { // case ACCOUNT: // AccountEntry account; // case TRUSTLINE: // TrustLineEntry trustLine; // case OFFER: // OfferEntry offer; // case DATA: // DataEntry data; // case CLAIMABLE_BALANCE: // ClaimableBalanceEntry claimableBalance; // } // data; // // // reserved for future use // union switch (int v) // { // case 0: // void; // case 1: // LedgerEntryExtensionV1 v1; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerEntry", [["lastModifiedLedgerSeq", xdr.lookup("Uint32")], ["data", xdr.lookup("LedgerEntryData")], ["ext", xdr.lookup("LedgerEntryExt")]]); // === xdr source ============================================================ // // struct // { // AccountID accountID; // } // // =========================================================================== xdr.struct("LedgerKeyAccount", [["accountId", xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // struct // { // AccountID accountID; // Asset asset; // } // // =========================================================================== xdr.struct("LedgerKeyTrustLine", [["accountId", xdr.lookup("AccountId")], ["asset", xdr.lookup("Asset")]]); // === xdr source ============================================================ // // struct // { // AccountID sellerID; // int64 offerID; // } // // =========================================================================== xdr.struct("LedgerKeyOffer", [["sellerId", xdr.lookup("AccountId")], ["offerId", xdr.lookup("Int64")]]); // === xdr source ============================================================ // // struct // { // AccountID accountID; // string64 dataName; // } // // =========================================================================== xdr.struct("LedgerKeyData", [["accountId", xdr.lookup("AccountId")], ["dataName", xdr.lookup("String64")]]); // === xdr source ============================================================ // // struct // { // ClaimableBalanceID balanceID; // } // // =========================================================================== xdr.struct("LedgerKeyClaimableBalance", [["balanceId", xdr.lookup("ClaimableBalanceId")]]); // === xdr source ============================================================ // // union LedgerKey switch (LedgerEntryType type) // { // case ACCOUNT: // struct // { // AccountID accountID; // } account; // // case TRUSTLINE: // struct // { // AccountID accountID; // Asset asset; // } trustLine; // // case OFFER: // struct // { // AccountID sellerID; // int64 offerID; // } offer; // // case DATA: // struct // { // AccountID accountID; // string64 dataName; // } data; // // case CLAIMABLE_BALANCE: // struct // { // ClaimableBalanceID balanceID; // } claimableBalance; // }; // // =========================================================================== xdr.union("LedgerKey", { switchOn: xdr.lookup("LedgerEntryType"), switchName: "type", switches: [["account", "account"], ["trustline", "trustLine"], ["offer", "offer"], ["data", "data"], ["claimableBalance", "claimableBalance"]], arms: { account: xdr.lookup("LedgerKeyAccount"), trustLine: xdr.lookup("LedgerKeyTrustLine"), offer: xdr.lookup("LedgerKeyOffer"), data: xdr.lookup("LedgerKeyData"), claimableBalance: xdr.lookup("LedgerKeyClaimableBalance") } }); // === xdr source ============================================================ // // enum EnvelopeType // { // ENVELOPE_TYPE_TX_V0 = 0, // ENVELOPE_TYPE_SCP = 1, // ENVELOPE_TYPE_TX = 2, // ENVELOPE_TYPE_AUTH = 3, // ENVELOPE_TYPE_SCPVALUE = 4, // ENVELOPE_TYPE_TX_FEE_BUMP = 5, // ENVELOPE_TYPE_OP_ID = 6 // }; // // =========================================================================== xdr.enum("EnvelopeType", { envelopeTypeTxV0: 0, envelopeTypeScp: 1, envelopeTypeTx: 2, envelopeTypeAuth: 3, envelopeTypeScpvalue: 4, envelopeTypeTxFeeBump: 5, envelopeTypeOpId: 6 }); // === xdr source ============================================================ // // typedef opaque UpgradeType<128>; // // =========================================================================== xdr.typedef("UpgradeType", xdr.varOpaque(128)); // === xdr source ============================================================ // // enum DigitalBitsValueType // { // DIGITALBITS_VALUE_BASIC = 0, // DIGITALBITS_VALUE_SIGNED = 1 // }; // // =========================================================================== xdr.enum("DigitalBitsValueType", { digitalBitsValueBasic: 0, digitalBitsValueSigned: 1 }); // === xdr source ============================================================ // // struct LedgerCloseValueSignature // { // NodeID nodeID; // which node introduced the value // Signature signature; // nodeID's signature // }; // // =========================================================================== xdr.struct("LedgerCloseValueSignature", [["nodeId", xdr.lookup("NodeId")], ["signature", xdr.lookup("Signature")]]); // === xdr source ============================================================ // // union switch (DigitalBitsValueType v) // { // case DIGITALBITS_VALUE_BASIC: // void; // case DIGITALBITS_VALUE_SIGNED: // LedgerCloseValueSignature lcValueSignature; // } // // =========================================================================== xdr.union("DigitalBitsValueExt", { switchOn: xdr.lookup("DigitalBitsValueType"), switchName: "v", switches: [["digitalBitsValueBasic", xdr.void()], ["digitalBitsValueSigned", "lcValueSignature"]], arms: { lcValueSignature: xdr.lookup("LedgerCloseValueSignature") } }); // === xdr source ============================================================ // // struct DigitalBitsValue // { // Hash txSetHash; // transaction set to apply to previous ledger // TimePoint closeTime; // network close time // // // upgrades to apply to the previous ledger (usually empty) // // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop // // unknown steps during consensus if needed. // // see notes below on 'LedgerUpgrade' for more detail // // max size is dictated by number of upgrade types (+ room for future) // UpgradeType upgrades<6>; // // // reserved for future use // union switch (DigitalBitsValueType v) // { // case DIGITALBITS_VALUE_BASIC: // void; // case DIGITALBITS_VALUE_SIGNED: // LedgerCloseValueSignature lcValueSignature; // } // ext; // }; // // =========================================================================== xdr.struct("DigitalBitsValue", [["txSetHash", xdr.lookup("Hash")], ["closeTime", xdr.lookup("TimePoint")], ["upgrades", xdr.varArray(xdr.lookup("UpgradeType"), 6)], ["ext", xdr.lookup("DigitalBitsValueExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("LedgerHeaderExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct LedgerHeader // { // uint32 ledgerVersion; // the protocol version of the ledger // Hash previousLedgerHash; // hash of the previous ledger header // DigitalBitsValue scpValue; // what consensus agreed to // Hash txSetResultHash; // the TransactionResultSet that led to this ledger // Hash bucketListHash; // hash of the ledger state // // uint32 ledgerSeq; // sequence number of this ledger // // int64 totalCoins; // total number of nibbs in existence. // // 10,000,000 nibbs in 1 XDB // // int64 feePool; // fees burned since last inflation run // uint32 inflationSeq; // inflation sequence number // // uint64 idPool; // last used global ID, used for generating objects // // uint32 baseFee; // base fee per operation in nibbs // uint32 baseReserve; // account base reserve in nibbs // // uint32 maxTxSetSize; // maximum size a transaction set can be // // Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back // // in time without walking the chain back ledger by ledger // // each slot contains the oldest ledger that is mod of // // either 50 5000 50000 or 500000 depending on index // // skipList[0] mod(50), skipList[1] mod(5000), etc // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerHeader", [["ledgerVersion", xdr.lookup("Uint32")], ["previousLedgerHash", xdr.lookup("Hash")], ["scpValue", xdr.lookup("DigitalBitsValue")], ["txSetResultHash", xdr.lookup("Hash")], ["bucketListHash", xdr.lookup("Hash")], ["ledgerSeq", xdr.lookup("Uint32")], ["totalCoins", xdr.lookup("Int64")], ["feePool", xdr.lookup("Int64")], ["inflationSeq", xdr.lookup("Uint32")], ["idPool", xdr.lookup("Uint64")], ["baseFee", xdr.lookup("Uint32")], ["baseReserve", xdr.lookup("Uint32")], ["maxTxSetSize", xdr.lookup("Uint32")], ["skipList", xdr.array(xdr.lookup("Hash"), 4)], ["ext", xdr.lookup("LedgerHeaderExt")]]); // === xdr source ============================================================ // // enum LedgerUpgradeType // { // LEDGER_UPGRADE_VERSION = 1, // LEDGER_UPGRADE_BASE_FEE = 2, // LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3, // LEDGER_UPGRADE_BASE_RESERVE = 4 // }; // // =========================================================================== xdr.enum("LedgerUpgradeType", { ledgerUpgradeVersion: 1, ledgerUpgradeBaseFee: 2, ledgerUpgradeMaxTxSetSize: 3, ledgerUpgradeBaseReserve: 4 }); // === xdr source ============================================================ // // union LedgerUpgrade switch (LedgerUpgradeType type) // { // case LEDGER_UPGRADE_VERSION: // uint32 newLedgerVersion; // update ledgerVersion // case LEDGER_UPGRADE_BASE_FEE: // uint32 newBaseFee; // update baseFee // case LEDGER_UPGRADE_MAX_TX_SET_SIZE: // uint32 newMaxTxSetSize; // update maxTxSetSize // case LEDGER_UPGRADE_BASE_RESERVE: // uint32 newBaseReserve; // update baseReserve // }; // // =========================================================================== xdr.union("LedgerUpgrade", { switchOn: xdr.lookup("LedgerUpgradeType"), switchName: "type", switches: [["ledgerUpgradeVersion", "newLedgerVersion"], ["ledgerUpgradeBaseFee", "newBaseFee"], ["ledgerUpgradeMaxTxSetSize", "newMaxTxSetSize"], ["ledgerUpgradeBaseReserve", "newBaseReserve"]], arms: { newLedgerVersion: xdr.lookup("Uint32"), newBaseFee: xdr.lookup("Uint32"), newMaxTxSetSize: xdr.lookup("Uint32"), newBaseReserve: xdr.lookup("Uint32") } }); // === xdr source ============================================================ // // enum BucketEntryType // { // METAENTRY = // -1, // At-and-after protocol 11: bucket metadata, should come first. // LIVEENTRY = 0, // Before protocol 11: created-or-updated; // // At-and-after protocol 11: only updated. // DEADENTRY = 1, // INITENTRY = 2 // At-and-after protocol 11: only created. // }; // // =========================================================================== xdr.enum("BucketEntryType", { metaentry: -1, liveentry: 0, deadentry: 1, initentry: 2 }); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("BucketMetadataExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.void()]], arms: {} }); // === xdr source ============================================================ // // struct BucketMetadata // { // // Indicates the protocol version used to create / merge this bucket. // uint32 ledgerVersion; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("BucketMetadata", [["ledgerVersion", xdr.lookup("Uint32")], ["ext", xdr.lookup("BucketMetadataExt")]]); // === xdr source ============================================================ // // union BucketEntry switch (BucketEntryType type) // { // case LIVEENTRY: // case INITENTRY: // LedgerEntry liveEntry; // // case DEADENTRY: // LedgerKey deadEntry; // case METAENTRY: // BucketMetadata metaEntry; // }; // // =========================================================================== xdr.union("BucketEntry", { switchOn: xdr.lookup("BucketEntryType"), switchName: "type", switches: [["liveentry", "liveEntry"], ["initentry", "liveEntry"], ["deadentry", "deadEntry"], ["metaentry", "metaEntry"]], arms: { liveEntry: xdr.lookup("LedgerEntry"), deadEntry: xdr.lookup("LedgerKey"), metaEntry: xdr.lookup("BucketMetadata") } }); // === xdr source ============================================================ // // struct TransactionSet // { // Hash previousLedgerHash; // TransactionEnvelope txs<>; // }; // // =========================================================================== xdr.struct("TransactionSet", [["previousLedgerHash", xdr.lookup("Hash")], ["txes", xdr.varArray(xdr.lookup("TransactionEnvelope"), 2147483647)]]); // === xdr source ============================================================ // // struct TransactionResultPair // { // Hash transactionHash; // TransactionResult result; // result for the transaction // }; // // =========================================================================== xdr.struct("TransactionResultPair", [["transactionHash", xdr.lookup("Hash")], ["result", xdr.lookup("TransactionResult")]]); // === xdr source ============================================================ // // struct TransactionResultSet // { // TransactionResultPair results<>; // }; // // =========================================================================== xdr.struct("TransactionResultSet", [["results", xdr.varArray(xdr.lookup("TransactionResultPair"), 2147483647)]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("TransactionHistoryEntryExt", { switchOn: xdr.int(), switchName: "v", switches: [[0, xdr.