diamante-base
Version:
Low-level support library for the Diamante network.
1,397 lines (1,311 loc) • 327 kB
JavaScript
"use strict";
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var XDR = _interopRequireWildcard(require("diamante-js-xdr"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
// Automatically generated by xdrgen
// DO NOT EDIT or your changes may be overwritten
/* jshint maxstatements:2147483647 */
/* jshint esnext:true */
var types = XDR.config(function (xdr) {
// Workaround for https://github.com/diamante/xdrgen/issues/152
//
// The "correct" way would be to replace bare instances of each constant with
// xdr.lookup("..."), but that's more error-prone.
var SCSYMBOL_LIMIT = 32;
var SC_SPEC_DOC_LIMIT = 1024;
// === xdr source ============================================================
//
// typedef opaque Value<>;
//
// ===========================================================================
xdr.typedef("Value", xdr.varOpaque());
// === xdr source ============================================================
//
// struct SCPBallot
// {
// uint32 counter; // n
// Value value; // x
// };
//
// ===========================================================================
xdr.struct("ScpBallot", [["counter", xdr.lookup("Uint32")], ["value", xdr.lookup("Value")]]);
// === xdr source ============================================================
//
// enum SCPStatementType
// {
// SCP_ST_PREPARE = 0,
// SCP_ST_CONFIRM = 1,
// SCP_ST_EXTERNALIZE = 2,
// SCP_ST_NOMINATE = 3
// };
//
// ===========================================================================
xdr["enum"]("ScpStatementType", {
scpStPrepare: 0,
scpStConfirm: 1,
scpStExternalize: 2,
scpStNominate: 3
});
// === xdr source ============================================================
//
// struct SCPNomination
// {
// Hash quorumSetHash; // D
// Value votes<>; // X
// Value accepted<>; // Y
// };
//
// ===========================================================================
xdr.struct("ScpNomination", [["quorumSetHash", xdr.lookup("Hash")], ["votes", xdr.varArray(xdr.lookup("Value"), 2147483647)], ["accepted", xdr.varArray(xdr.lookup("Value"), 2147483647)]]);
// === xdr source ============================================================
//
// struct
// {
// Hash quorumSetHash; // D
// SCPBallot ballot; // b
// SCPBallot* prepared; // p
// SCPBallot* preparedPrime; // p'
// uint32 nC; // c.n
// uint32 nH; // h.n
// }
//
// ===========================================================================
xdr.struct("ScpStatementPrepare", [["quorumSetHash", xdr.lookup("Hash")], ["ballot", xdr.lookup("ScpBallot")], ["prepared", xdr.option(xdr.lookup("ScpBallot"))], ["preparedPrime", xdr.option(xdr.lookup("ScpBallot"))], ["nC", xdr.lookup("Uint32")], ["nH", xdr.lookup("Uint32")]]);
// === xdr source ============================================================
//
// struct
// {
// SCPBallot ballot; // b
// uint32 nPrepared; // p.n
// uint32 nCommit; // c.n
// uint32 nH; // h.n
// Hash quorumSetHash; // D
// }
//
// ===========================================================================
xdr.struct("ScpStatementConfirm", [["ballot", xdr.lookup("ScpBallot")], ["nPrepared", xdr.lookup("Uint32")], ["nCommit", xdr.lookup("Uint32")], ["nH", xdr.lookup("Uint32")], ["quorumSetHash", xdr.lookup("Hash")]]);
// === xdr source ============================================================
//
// struct
// {
// SCPBallot commit; // c
// uint32 nH; // h.n
// Hash commitQuorumSetHash; // D used before EXTERNALIZE
// }
//
// ===========================================================================
xdr.struct("ScpStatementExternalize", [["commit", xdr.lookup("ScpBallot")], ["nH", xdr.lookup("Uint32")], ["commitQuorumSetHash", xdr.lookup("Hash")]]);
// === xdr source ============================================================
//
// union switch (SCPStatementType type)
// {
// case SCP_ST_PREPARE:
// struct
// {
// Hash quorumSetHash; // D
// SCPBallot ballot; // b
// SCPBallot* prepared; // p
// SCPBallot* preparedPrime; // p'
// uint32 nC; // c.n
// uint32 nH; // h.n
// } prepare;
// case SCP_ST_CONFIRM:
// struct
// {
// SCPBallot ballot; // b
// uint32 nPrepared; // p.n
// uint32 nCommit; // c.n
// uint32 nH; // h.n
// Hash quorumSetHash; // D
// } confirm;
// case SCP_ST_EXTERNALIZE:
// struct
// {
// SCPBallot commit; // c
// uint32 nH; // h.n
// Hash commitQuorumSetHash; // D used before EXTERNALIZE
// } externalize;
// case SCP_ST_NOMINATE:
// SCPNomination nominate;
// }
//
// ===========================================================================
xdr.union("ScpStatementPledges", {
switchOn: xdr.lookup("ScpStatementType"),
switchName: "type",
switches: [["scpStPrepare", "prepare"], ["scpStConfirm", "confirm"], ["scpStExternalize", "externalize"], ["scpStNominate", "nominate"]],
arms: {
prepare: xdr.lookup("ScpStatementPrepare"),
confirm: xdr.lookup("ScpStatementConfirm"),
externalize: xdr.lookup("ScpStatementExternalize"),
nominate: xdr.lookup("ScpNomination")
}
});
// === xdr source ============================================================
//
// struct SCPStatement
// {
// NodeID nodeID; // v
// uint64 slotIndex; // i
//
// union switch (SCPStatementType type)
// {
// case SCP_ST_PREPARE:
// struct
// {
// Hash quorumSetHash; // D
// SCPBallot ballot; // b
// SCPBallot* prepared; // p
// SCPBallot* preparedPrime; // p'
// uint32 nC; // c.n
// uint32 nH; // h.n
// } prepare;
// case SCP_ST_CONFIRM:
// struct
// {
// SCPBallot ballot; // b
// uint32 nPrepared; // p.n
// uint32 nCommit; // c.n
// uint32 nH; // h.n
// Hash quorumSetHash; // D
// } confirm;
// case SCP_ST_EXTERNALIZE:
// struct
// {
// SCPBallot commit; // c
// uint32 nH; // h.n
// Hash commitQuorumSetHash; // D used before EXTERNALIZE
// } externalize;
// case SCP_ST_NOMINATE:
// SCPNomination nominate;
// }
// pledges;
// };
//
// ===========================================================================
xdr.struct("ScpStatement", [["nodeId", xdr.lookup("NodeId")], ["slotIndex", xdr.lookup("Uint64")], ["pledges", xdr.lookup("ScpStatementPledges")]]);
// === xdr source ============================================================
//
// struct SCPEnvelope
// {
// SCPStatement statement;
// Signature signature;
// };
//
// ===========================================================================
xdr.struct("ScpEnvelope", [["statement", xdr.lookup("ScpStatement")], ["signature", xdr.lookup("Signature")]]);
// === xdr source ============================================================
//
// struct SCPQuorumSet
// {
// uint32 threshold;
// NodeID validators<>;
// SCPQuorumSet innerSets<>;
// };
//
// ===========================================================================
xdr.struct("ScpQuorumSet", [["threshold", xdr.lookup("Uint32")], ["validators", xdr.varArray(xdr.lookup("NodeId"), 2147483647)], ["innerSets", xdr.varArray(xdr.lookup("ScpQuorumSet"), 2147483647)]]);
// === 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 opaque DataValue<64>;
//
// ===========================================================================
xdr.typedef("DataValue", xdr.varOpaque(64));
// === xdr source ============================================================
//
// typedef Hash PoolID;
//
// ===========================================================================
xdr.typedef("PoolId", xdr.lookup("Hash"));
// === 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,
// ASSET_TYPE_POOL_SHARE = 3
// };
//
// ===========================================================================
xdr["enum"]("AssetType", {
assetTypeNative: 0,
assetTypeCreditAlphanum4: 1,
assetTypeCreditAlphanum12: 2,
assetTypePoolShare: 3
});
// === 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 AlphaNum4
// {
// AssetCode4 assetCode;
// AccountID issuer;
// };
//
// ===========================================================================
xdr.struct("AlphaNum4", [["assetCode", xdr.lookup("AssetCode4")], ["issuer", xdr.lookup("AccountId")]]);
// === xdr source ============================================================
//
// struct AlphaNum12
// {
// AssetCode12 assetCode;
// AccountID issuer;
// };
//
// ===========================================================================
xdr.struct("AlphaNum12", [["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:
// AlphaNum4 alphaNum4;
//
// case ASSET_TYPE_CREDIT_ALPHANUM12:
// AlphaNum12 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("AlphaNum4"),
alphaNum12: xdr.lookup("AlphaNum12")
}
});
// === 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,
// LIQUIDITY_POOL = 5,
// CONTRACT_DATA = 6,
// CONTRACT_CODE = 7,
// CONFIG_SETTING = 8,
// TTL = 9
// };
//
// ===========================================================================
xdr["enum"]("LedgerEntryType", {
account: 0,
trustline: 1,
offer: 2,
data: 3,
claimableBalance: 4,
liquidityPool: 5,
contractData: 6,
contractCode: 7,
configSetting: 8,
ttl: 9
});
// === 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_V17 = 0xF;
//
// ===========================================================================
xdr["const"]("MASK_ACCOUNT_FLAGS_V17", 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 ============================================================
//
// struct AccountEntryExtensionV3
// {
// // We can use this to add more fields, or because it is first, to
// // change AccountEntryExtensionV3 into a union.
// ExtensionPoint ext;
//
// // Ledger number at which `seqNum` took on its present value.
// uint32 seqLedger;
//
// // Time at which `seqNum` took on its present value.
// TimePoint seqTime;
// };
//
// ===========================================================================
xdr.struct("AccountEntryExtensionV3", [["ext", xdr.lookup("ExtensionPoint")], ["seqLedger", xdr.lookup("Uint32")], ["seqTime", xdr.lookup("TimePoint")]]);
// === xdr source ============================================================
//
// union switch (int v)
// {
// case 0:
// void;
// case 3:
// AccountEntryExtensionV3 v3;
// }
//
// ===========================================================================
xdr.union("AccountEntryExtensionV2Ext", {
switchOn: xdr["int"](),
switchName: "v",
switches: [[0, xdr["void"]()], [3, "v3"]],
arms: {
v3: xdr.lookup("AccountEntryExtensionV3")
}
});
// === xdr source ============================================================
//
// struct AccountEntryExtensionV2
// {
// uint32 numSponsored;
// uint32 numSponsoring;
// SponsorshipDescriptor signerSponsoringIDs<MAX_SIGNERS>;
//
// union switch (int v)
// {
// case 0:
// void;
// case 3:
// AccountEntryExtensionV3 v3;
// }
// 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 stroops
// 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_V17 = 7;
//
// ===========================================================================
xdr["const"]("MASK_TRUSTLINE_FLAGS_V17", 7);
// === xdr source ============================================================
//
// enum LiquidityPoolType
// {
// LIQUIDITY_POOL_CONSTANT_PRODUCT = 0
// };
//
// ===========================================================================
xdr["enum"]("LiquidityPoolType", {
liquidityPoolConstantProduct: 0
});
// === xdr source ============================================================
//
// union TrustLineAsset switch (AssetType type)
// {
// case ASSET_TYPE_NATIVE: // Not credit
// void;
//
// case ASSET_TYPE_CREDIT_ALPHANUM4:
// AlphaNum4 alphaNum4;
//
// case ASSET_TYPE_CREDIT_ALPHANUM12:
// AlphaNum12 alphaNum12;
//
// case ASSET_TYPE_POOL_SHARE:
// PoolID liquidityPoolID;
//
// // add other asset types here in the future
// };
//
// ===========================================================================
xdr.union("TrustLineAsset", {
switchOn: xdr.lookup("AssetType"),
switchName: "type",
switches: [["assetTypeNative", xdr["void"]()], ["assetTypeCreditAlphanum4", "alphaNum4"], ["assetTypeCreditAlphanum12", "alphaNum12"], ["assetTypePoolShare", "liquidityPoolId"]],
arms: {
alphaNum4: xdr.lookup("AlphaNum4"),
alphaNum12: xdr.lookup("AlphaNum12"),
liquidityPoolId: xdr.lookup("PoolId")
}
});
// === xdr source ============================================================
//
// union switch (int v)
// {
// case 0:
// void;
// }
//
// ===========================================================================
xdr.union("TrustLineEntryExtensionV2Ext", {
switchOn: xdr["int"](),
switchName: "v",
switches: [[0, xdr["void"]()]],
arms: {}
});
// === xdr source ============================================================
//
// struct TrustLineEntryExtensionV2
// {
// int32 liquidityPoolUseCount;
//
// union switch (int v)
// {
// case 0:
// void;
// }
// ext;
// };
//
// ===========================================================================
xdr.struct("TrustLineEntryExtensionV2", [["liquidityPoolUseCount", xdr.lookup("Int32")], ["ext", xdr.lookup("TrustLineEntryExtensionV2Ext")]]);
// === xdr source ============================================================
//
// union switch (int v)
// {
// case 0:
// void;
// case 2:
// TrustLineEntryExtensionV2 v2;
// }
//
// ===========================================================================
xdr.union("TrustLineEntryV1Ext", {
switchOn: xdr["int"](),
switchName: "v",
switches: [[0, xdr["void"]()], [2, "v2"]],
arms: {
v2: xdr.lookup("TrustLineEntryExtensionV2")
}
});
// === xdr source ============================================================
//
// struct
// {
// Liabilities liabilities;
//
// union switch (int v)
// {
// case 0:
// void;
// case 2:
// TrustLineEntryExtensionV2 v2;
// }
// 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;
// case 2:
// TrustLineEntryExtensionV2 v2;
// }
// 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
// TrustLineAsset 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;
// case 2:
// TrustLineEntryExtensionV2 v2;
// }
// ext;
// } v1;
// }
// ext;
// };
//
// ===========================================================================
xdr.struct("TrustLineEntry", [["accountId", xdr.lookup("AccountId")], ["asset", xdr.lookup("TrustLineAsset")], ["balance", xdr.lookup("Int64")], ["limit", xdr.lookup("Int64")], ["flags", xdr.lookup("Uint32")], ["ext", xdr.lookup("TrustLineEntryExt")]]);
// === xdr source ============================================================
//
// enum OfferEntryFlags
// {
// // an offer with this flag will not act on and take a reverse offer of equal
// // price
// 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 ============================================================
//
// struct LiquidityPoolConstantProductParameters
// {
// Asset assetA; // assetA < assetB
// Asset assetB;
// int32 fee; // Fee is in basis points, so the actual rate is (fee/100)%
// };
//
// ===========================================================================
xdr.struct("LiquidityPoolConstantProductParameters", [["assetA", xdr.lookup("Asset")], ["assetB", xdr.lookup("Asset")], ["fee", xdr.lookup("Int32")]]);
// === xdr source ============================================================
//
// struct
// {
// LiquidityPoolConstantProductParameters params;
//
// int64 reserveA; // amount of A in the pool
// int64 reserveB; // amount of B in the pool
// int64 totalPoolShares; // total number of pool shares issued
// int64 poolSharesTrustLineCount; // number of trust lines for the
// // associated pool shares
// }
//
// ===========================================================================
xdr.struct("LiquidityPoolEntryConstantProduct", [["params", xdr.lookup("LiquidityPoolConstantProductParameters")], ["reserveA", xdr.lookup("Int64")], ["reserveB", xdr.lookup("Int64")], ["totalPoolShares", xdr.lookup("Int64")], ["poolSharesTrustLineCount", xdr.lookup("Int64")]]);
// === xdr source ============================================================
//
// union switch (LiquidityPoolType type)
// {
// case LIQUIDITY_POOL_CONSTANT_PRODUCT:
// struct
// {
// LiquidityPoolConstantProductParameters params;
//
// int64 reserveA; // amount of A in the pool
// int64 reserveB; // amount of B in the pool
// int64 totalPoolShares; // total number of pool shares issued
// int64 poolSharesTrustLineCount; // number of trust lines for the
// // associated pool shares
// } constantProduct;
// }
//
// ===========================================================================
xdr.union("LiquidityPoolEntryBody", {
switchOn: xdr.lookup("LiquidityPoolType"),
switchName: "type",
switches: [["liquidityPoolConstantProduct", "constantProduct"]],
arms: {
constantProduct: xdr.lookup("LiquidityPoolEntryConstantProduct")
}
});
// === xdr source ============================================================
//
// struct LiquidityPoolEntry
// {
// PoolID liquidityPoolID;
//
// union switch (LiquidityPoolType type)
// {
// case LIQUIDITY_POOL_CONSTANT_PRODUCT:
// struct
// {
// LiquidityPoolConstantProductParameters params;
//
// int64 reserveA; // amount of A in the pool
// int64 reserveB; // amount of B in the pool
// int64 totalPoolShares; // total number of pool shares issued
// int64 poolSharesTrustLineCount; // number of trust lines for the
// // associated pool shares
// } constantProduct;
// }
// body;
// };
//
// ===========================================================================
xdr.struct("LiquidityPoolEntry", [["liquidityPoolId", xdr.lookup("PoolId")], ["body", xdr.lookup("LiquidityPoolEntryBody")]]);
// === xdr source ============================================================
//
// enum ContractDataDurability {
// TEMPORARY = 0,
// PERSISTENT = 1
// };
//
// ===========================================================================
xdr["enum"]("ContractDataDurability", {
temporary: 0,
persistent: 1
});
// === xdr source ============================================================
//
// struct ContractDataEntry {
// ExtensionPoint ext;
//
// SCAddress contract;
// SCVal key;
// ContractDataDurability durability;
// SCVal val;
// };
//
// ===========================================================================
xdr.struct("ContractDataEntry", [["ext", xdr.lookup("ExtensionPoint")], ["contract", xdr.lookup("ScAddress")], ["key", xdr.lookup("ScVal")], ["durability", xdr.lookup("ContractDataDurability")], ["val", xdr.lookup("ScVal")]]);
// === xdr source ============================================================
//
// struct ContractCodeEntry {
// ExtensionPoint ext;
//
// Hash hash;
// opaque code<>;
// };
//
// ===========================================================================
xdr.struct("ContractCodeEntry", [["ext", xdr.lookup("ExtensionPoint")], ["hash", xdr.lookup("Hash")], ["code", xdr.varOpaque()]]);
// === xdr source ============================================================
//
// struct TTLEntry {
// // Hash of the LedgerKey that is associated with this TTLEntry
// Hash keyHash;
// uint32 liveUntilLedgerSeq;
// };
//
// ===========================================================================
xdr.struct("TtlEntry", [["keyHash", xdr.lookup("Hash")], ["liveUntilLedgerSeq", xdr.lookup("Uint32")]]);
// === 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:
// AccountE