@stellar/stellar-base
Version:
Low-level support library for the Stellar network.
1,487 lines (1,348 loc) • 1.29 MB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("StellarBase", [], factory);
else if(typeof exports === 'object')
exports["StellarBase"] = factory();
else
root["StellarBase"] = factory();
})(self, () => {
return /******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 41:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var $defineProperty = __webpack_require__(655);
var $SyntaxError = __webpack_require__(8068);
var $TypeError = __webpack_require__(9675);
var gopd = __webpack_require__(5795);
/** @type {import('.')} */
module.exports = function defineDataProperty(
obj,
property,
value
) {
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
throw new $TypeError('`obj` must be an object or a function`');
}
if (typeof property !== 'string' && typeof property !== 'symbol') {
throw new $TypeError('`property` must be a string or a symbol`');
}
if (arguments.length > 3 && typeof arguments[3] !== 'boolean' && arguments[3] !== null) {
throw new $TypeError('`nonEnumerable`, if provided, must be a boolean or null');
}
if (arguments.length > 4 && typeof arguments[4] !== 'boolean' && arguments[4] !== null) {
throw new $TypeError('`nonWritable`, if provided, must be a boolean or null');
}
if (arguments.length > 5 && typeof arguments[5] !== 'boolean' && arguments[5] !== null) {
throw new $TypeError('`nonConfigurable`, if provided, must be a boolean or null');
}
if (arguments.length > 6 && typeof arguments[6] !== 'boolean') {
throw new $TypeError('`loose`, if provided, must be a boolean');
}
var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
var nonWritable = arguments.length > 4 ? arguments[4] : null;
var nonConfigurable = arguments.length > 5 ? arguments[5] : null;
var loose = arguments.length > 6 ? arguments[6] : false;
/* @type {false | TypedPropertyDescriptor<unknown>} */
var desc = !!gopd && gopd(obj, property);
if ($defineProperty) {
$defineProperty(obj, property, {
configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,
enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,
value: value,
writable: nonWritable === null && desc ? desc.writable : !nonWritable
});
} else if (loose || (!nonEnumerable && !nonWritable && !nonConfigurable)) {
// must fall back to [[Set]], and was not explicitly asked to make non-enumerable, non-writable, or non-configurable
obj[property] = value; // eslint-disable-line no-param-reassign
} else {
throw new $SyntaxError('This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.');
}
};
/***/ }),
/***/ 76:
/***/ ((module) => {
"use strict";
/** @type {import('./functionCall')} */
module.exports = Function.prototype.call;
/***/ }),
/***/ 251:
/***/ ((__unused_webpack_module, exports) => {
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
exports.read = function (buffer, offset, isLE, mLen, nBytes) {
var e, m
var eLen = (nBytes * 8) - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var nBits = -7
var i = isLE ? (nBytes - 1) : 0
var d = isLE ? -1 : 1
var s = buffer[offset + i]
i += d
e = s & ((1 << (-nBits)) - 1)
s >>= (-nBits)
nBits += eLen
for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
m = e & ((1 << (-nBits)) - 1)
e >>= (-nBits)
nBits += mLen
for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
if (e === 0) {
e = 1 - eBias
} else if (e === eMax) {
return m ? NaN : ((s ? -1 : 1) * Infinity)
} else {
m = m + Math.pow(2, mLen)
e = e - eBias
}
return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
}
exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
var e, m, c
var eLen = (nBytes * 8) - mLen - 1
var eMax = (1 << eLen) - 1
var eBias = eMax >> 1
var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
var i = isLE ? 0 : (nBytes - 1)
var d = isLE ? 1 : -1
var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
value = Math.abs(value)
if (isNaN(value) || value === Infinity) {
m = isNaN(value) ? 1 : 0
e = eMax
} else {
e = Math.floor(Math.log(value) / Math.LN2)
if (value * (c = Math.pow(2, -e)) < 1) {
e--
c *= 2
}
if (e + eBias >= 1) {
value += rt / c
} else {
value += rt * Math.pow(2, 1 - eBias)
}
if (value * c >= 2) {
e++
c /= 2
}
if (e + eBias >= eMax) {
m = 0
e = eMax
} else if (e + eBias >= 1) {
m = ((value * c) - 1) * Math.pow(2, mLen)
e = e + eBias
} else {
m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
e = 0
}
}
for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
e = (e << mLen) | m
eLen += mLen
for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
buffer[offset + i - d] |= s * 128
}
/***/ }),
/***/ 392:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var Buffer = (__webpack_require__(2861).Buffer);
var toBuffer = __webpack_require__(5377);
// prototype class for hash functions
function Hash(blockSize, finalSize) {
this._block = Buffer.alloc(blockSize);
this._finalSize = finalSize;
this._blockSize = blockSize;
this._len = 0;
}
Hash.prototype.update = function (data, enc) {
/* eslint no-param-reassign: 0 */
data = toBuffer(data, enc || 'utf8');
var block = this._block;
var blockSize = this._blockSize;
var length = data.length;
var accum = this._len;
for (var offset = 0; offset < length;) {
var assigned = accum % blockSize;
var remainder = Math.min(length - offset, blockSize - assigned);
for (var i = 0; i < remainder; i++) {
block[assigned + i] = data[offset + i];
}
accum += remainder;
offset += remainder;
if ((accum % blockSize) === 0) {
this._update(block);
}
}
this._len += length;
return this;
};
Hash.prototype.digest = function (enc) {
var rem = this._len % this._blockSize;
this._block[rem] = 0x80;
/*
* zero (rem + 1) trailing bits, where (rem + 1) is the smallest
* non-negative solution to the equation (length + 1 + (rem + 1)) === finalSize mod blockSize
*/
this._block.fill(0, rem + 1);
if (rem >= this._finalSize) {
this._update(this._block);
this._block.fill(0);
}
var bits = this._len * 8;
// uint32
if (bits <= 0xffffffff) {
this._block.writeUInt32BE(bits, this._blockSize - 4);
// uint64
} else {
var lowBits = (bits & 0xffffffff) >>> 0;
var highBits = (bits - lowBits) / 0x100000000;
this._block.writeUInt32BE(highBits, this._blockSize - 8);
this._block.writeUInt32BE(lowBits, this._blockSize - 4);
}
this._update(this._block);
var hash = this._hash();
return enc ? hash.toString(enc) : hash;
};
Hash.prototype._update = function () {
throw new Error('_update must be implemented by subclass');
};
module.exports = Hash;
/***/ }),
/***/ 414:
/***/ ((module) => {
"use strict";
/** @type {import('./round')} */
module.exports = Math.round;
/***/ }),
/***/ 448:
/***/ ((module, __webpack_exports__, __webpack_require__) => {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, {
Account: () => (/* reexport */ Account),
Address: () => (/* reexport */ Address),
Asset: () => (/* reexport */ Asset),
AuthClawbackEnabledFlag: () => (/* reexport */ AuthClawbackEnabledFlag),
AuthImmutableFlag: () => (/* reexport */ AuthImmutableFlag),
AuthRequiredFlag: () => (/* reexport */ AuthRequiredFlag),
AuthRevocableFlag: () => (/* reexport */ AuthRevocableFlag),
BASE_FEE: () => (/* reexport */ BASE_FEE),
Claimant: () => (/* reexport */ Claimant),
Contract: () => (/* reexport */ Contract),
FeeBumpTransaction: () => (/* reexport */ FeeBumpTransaction),
Hyper: () => (/* reexport */ xdr.Hyper),
Int128: () => (/* reexport */ Int128),
Int256: () => (/* reexport */ Int256),
Keypair: () => (/* reexport */ Keypair),
LiquidityPoolAsset: () => (/* reexport */ LiquidityPoolAsset),
LiquidityPoolFeeV18: () => (/* reexport */ LiquidityPoolFeeV18),
LiquidityPoolId: () => (/* reexport */ LiquidityPoolId),
Memo: () => (/* reexport */ Memo),
MemoHash: () => (/* reexport */ MemoHash),
MemoID: () => (/* reexport */ MemoID),
MemoNone: () => (/* reexport */ MemoNone),
MemoReturn: () => (/* reexport */ MemoReturn),
MemoText: () => (/* reexport */ MemoText),
MuxedAccount: () => (/* reexport */ MuxedAccount),
Networks: () => (/* reexport */ Networks),
Operation: () => (/* reexport */ Operation),
ScInt: () => (/* reexport */ ScInt),
SignerKey: () => (/* reexport */ SignerKey),
Soroban: () => (/* reexport */ Soroban),
SorobanDataBuilder: () => (/* reexport */ SorobanDataBuilder),
StrKey: () => (/* reexport */ StrKey),
TimeoutInfinite: () => (/* reexport */ TimeoutInfinite),
Transaction: () => (/* reexport */ Transaction),
TransactionBase: () => (/* reexport */ TransactionBase),
TransactionBuilder: () => (/* reexport */ TransactionBuilder),
Uint128: () => (/* reexport */ Uint128),
Uint256: () => (/* reexport */ Uint256),
UnsignedHyper: () => (/* reexport */ xdr.UnsignedHyper),
XdrLargeInt: () => (/* reexport */ XdrLargeInt),
authorizeEntry: () => (/* reexport */ authorizeEntry),
authorizeInvocation: () => (/* reexport */ authorizeInvocation),
buildInvocationTree: () => (/* reexport */ buildInvocationTree),
cereal: () => (/* reexport */ jsxdr),
decodeAddressToMuxedAccount: () => (/* reexport */ decodeAddressToMuxedAccount),
"default": () => (/* binding */ src),
encodeMuxedAccount: () => (/* reexport */ encodeMuxedAccount),
encodeMuxedAccountToAddress: () => (/* reexport */ encodeMuxedAccountToAddress),
extractBaseAddress: () => (/* reexport */ extractBaseAddress),
getLiquidityPoolId: () => (/* reexport */ getLiquidityPoolId),
hash: () => (/* reexport */ hashing_hash),
humanizeEvents: () => (/* reexport */ humanizeEvents),
nativeToScVal: () => (/* reexport */ nativeToScVal),
scValToBigInt: () => (/* reexport */ scValToBigInt),
scValToNative: () => (/* reexport */ scValToNative),
sign: () => (/* reexport */ signing_sign),
verify: () => (/* reexport */ signing_verify),
walkInvocationTree: () => (/* reexport */ walkInvocationTree),
xdr: () => (/* reexport */ src_xdr)
});
// EXTERNAL MODULE: ./node_modules/@stellar/js-xdr/dist/xdr.js
var xdr = __webpack_require__(3740);
;// ./src/generated/curr_generated.js
// 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/stellar/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 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 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
// };
//
// ==========================================================