evernode-js-client 0.6.20 → 0.6.21-definition-1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
|
package/index.js
CHANGED
@@ -9149,7 +9149,7 @@ module.exports = { mask, unmask };
|
|
9149
9149
|
|
9150
9150
|
|
9151
9151
|
try {
|
9152
|
-
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.
|
9152
|
+
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi1.node");
|
9153
9153
|
} catch (e) {
|
9154
9154
|
module.exports = __nccwpck_require__(2567);
|
9155
9155
|
}
|
@@ -33340,7 +33340,7 @@ module.exports = isValidUTF8;
|
|
33340
33340
|
|
33341
33341
|
|
33342
33342
|
try {
|
33343
|
-
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.
|
33343
|
+
module.exports = require(__nccwpck_require__.ab + "prebuilds/linux-x64/node.napi.node");
|
33344
33344
|
} catch (e) {
|
33345
33345
|
module.exports = __nccwpck_require__(9372);
|
33346
33346
|
}
|
@@ -51832,7 +51832,7 @@ const { XrplApi } = __nccwpck_require__(1850);
|
|
51832
51832
|
const { XrplAccount } = __nccwpck_require__(9329);
|
51833
51833
|
const { XrplApiEvents, XrplConstants } = __nccwpck_require__(3307);
|
51834
51834
|
const { EvernodeEvents, EventTypes, MemoFormats, EvernodeConstants, HookStateKeys, HookParamKeys, RegExp } = __nccwpck_require__(9849);
|
51835
|
-
const {
|
51835
|
+
const { Defaults } = __nccwpck_require__(8262);
|
51836
51836
|
const { EncryptionHelper } = __nccwpck_require__(4832);
|
51837
51837
|
const { EventEmitter } = __nccwpck_require__(6170);
|
51838
51838
|
const { UtilHelpers } = __nccwpck_require__(6687);
|
@@ -51861,10 +51861,10 @@ class BaseEvernodeClient {
|
|
51861
51861
|
constructor(xrpAddress, xrpSecret, watchEvents, autoSubscribe = false, options = {}) {
|
51862
51862
|
|
51863
51863
|
this.connected = false;
|
51864
|
-
this.governorAddress = options.governorAddress ||
|
51864
|
+
this.governorAddress = options.governorAddress || Defaults.values.governorAddress;
|
51865
51865
|
|
51866
|
-
this.xrplApi = options.xrplApi ||
|
51867
|
-
if (!options.xrplApi && !
|
51866
|
+
this.xrplApi = options.xrplApi || Defaults.values.xrplApi || new XrplApi(options.rippledServer);
|
51867
|
+
if (!options.xrplApi && !Defaults.values.xrplApi)
|
51868
51868
|
this.#ownsXrplApi = true;
|
51869
51869
|
|
51870
51870
|
this.xrplAcc = new XrplAccount(xrpAddress, xrpSecret, { xrplApi: this.xrplApi });
|
@@ -53036,7 +53036,7 @@ module.exports = {
|
|
53036
53036
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
53037
53037
|
|
53038
53038
|
const { BaseEvernodeClient } = __nccwpck_require__(6263);
|
53039
|
-
const {
|
53039
|
+
const { Defaults } = __nccwpck_require__(8262);
|
53040
53040
|
const { EvernodeEvents } = __nccwpck_require__(9849);
|
53041
53041
|
|
53042
53042
|
const GovernorEvents = {
|
@@ -53055,7 +53055,7 @@ const GovernorEvents = {
|
|
53055
53055
|
|
53056
53056
|
class GovernorClient extends BaseEvernodeClient {
|
53057
53057
|
constructor(options = {}) {
|
53058
|
-
super((options.governorAddress ||
|
53058
|
+
super((options.governorAddress || Defaults.values.governorAddress), null, Object.values(GovernorEvents), false, options);
|
53059
53059
|
}
|
53060
53060
|
}
|
53061
53061
|
|
@@ -54355,16 +54355,22 @@ module.exports = {
|
|
54355
54355
|
/***/ }),
|
54356
54356
|
|
54357
54357
|
/***/ 8262:
|
54358
|
-
/***/ ((module) => {
|
54358
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
54359
|
+
|
54360
|
+
const DefinitionsPath = './resources/definitions.json';
|
54361
|
+
|
54362
|
+
const Definitions = __nccwpck_require__(4626);
|
54359
54363
|
|
54360
54364
|
const DefaultValues = {
|
54361
|
-
governorAddress: 'rGVHr1PrfL93UAjyw3DWZoi9adz2sLp2yL',
|
54362
|
-
rippledServer: 'wss://hooks-testnet-v3.xrpl-labs.com',
|
54363
54365
|
xrplApi: null,
|
54364
|
-
stateIndexId: 'evernodeindex',
|
54365
|
-
networkID: 21338
|
54366
54366
|
}
|
54367
54367
|
|
54368
|
+
const RequiredInfoKeys = [
|
54369
|
+
"governorAddress",
|
54370
|
+
"stateIndexId",
|
54371
|
+
"networkID"
|
54372
|
+
]
|
54373
|
+
|
54368
54374
|
const HookTypes = {
|
54369
54375
|
governor: 'GOVERNOR',
|
54370
54376
|
registry: 'REGISTRY',
|
@@ -54372,6 +54378,17 @@ const HookTypes = {
|
|
54372
54378
|
}
|
54373
54379
|
|
54374
54380
|
class Defaults {
|
54381
|
+
/**
|
54382
|
+
* Load defaults from the public definitions json.
|
54383
|
+
* @param {string} network Network to choose the info.
|
54384
|
+
*/
|
54385
|
+
static useNetwork(network) {
|
54386
|
+
if (!Definitions[network])
|
54387
|
+
throw 'Invalid network';
|
54388
|
+
|
54389
|
+
this.set(Definitions[network]);
|
54390
|
+
}
|
54391
|
+
|
54375
54392
|
/**
|
54376
54393
|
* Override Evernode default configs.
|
54377
54394
|
* @param {object} newDefaults Configurations to override `{ governorAddress: '{string} governor xrpl address', rippledServer: '{string} rippled server url', xrplApi: '{XrplApi} xrpl instance', stateIndexId: '{string} firestore index', networkID: '{number} rippled network id' }`
|
@@ -54384,13 +54401,18 @@ class Defaults {
|
|
54384
54401
|
* Read Evernode default configs.
|
54385
54402
|
* @returns The Object of Evernode configs
|
54386
54403
|
*/
|
54387
|
-
static get() {
|
54404
|
+
static get values() {
|
54405
|
+
var notFound = RequiredInfoKeys.find(k => !DefaultValues[k]);
|
54406
|
+
if (notFound)
|
54407
|
+
throw `Value for ${notFound} is not set.`;
|
54408
|
+
else if (!DefaultValues.rippledServer && (!DefaultValues.fallbackRippledServers || !DefaultValues.fallbackRippledServers.length))
|
54409
|
+
throw 'Either rippledServer or fallbackRippledServers required.';
|
54410
|
+
|
54388
54411
|
return { ...DefaultValues };
|
54389
54412
|
}
|
54390
54413
|
}
|
54391
54414
|
|
54392
54415
|
module.exports = {
|
54393
|
-
DefaultValues,
|
54394
54416
|
Defaults,
|
54395
54417
|
HookTypes
|
54396
54418
|
}
|
@@ -55075,7 +55097,7 @@ module.exports = {
|
|
55075
55097
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
55076
55098
|
|
55077
55099
|
const https = __nccwpck_require__(5687);
|
55078
|
-
const {
|
55100
|
+
const { Defaults } = __nccwpck_require__(8262);
|
55079
55101
|
|
55080
55102
|
const FirestoreOperations = {
|
55081
55103
|
EQUAL: 'EQUAL',
|
@@ -55087,8 +55109,8 @@ class FirestoreHandler {
|
|
55087
55109
|
#collectionPrefix = null;
|
55088
55110
|
|
55089
55111
|
constructor(options = {}) {
|
55090
|
-
this.#projectId = options.stateIndexId ||
|
55091
|
-
this.#collectionPrefix = options.collectionPrefix ||
|
55112
|
+
this.#projectId = options.stateIndexId || Defaults.values.stateIndexId;
|
55113
|
+
this.#collectionPrefix = options.collectionPrefix || Defaults.values.governorAddress;
|
55092
55114
|
}
|
55093
55115
|
|
55094
55116
|
/**
|
@@ -56450,7 +56472,7 @@ const crypto = __nccwpck_require__(6113);
|
|
56450
56472
|
const { XrplConstants, XrplTransactionTypes } = __nccwpck_require__(3307);
|
56451
56473
|
const { TransactionHelper } = __nccwpck_require__(7071);
|
56452
56474
|
const { EventEmitter } = __nccwpck_require__(6170);
|
56453
|
-
const {
|
56475
|
+
const { Defaults } = __nccwpck_require__(8262);
|
56454
56476
|
|
56455
56477
|
class XrplAccount {
|
56456
56478
|
|
@@ -56464,7 +56486,7 @@ class XrplAccount {
|
|
56464
56486
|
|
56465
56487
|
this.address = address;
|
56466
56488
|
this.secret = secret;
|
56467
|
-
this.xrplApi = options.xrplApi ||
|
56489
|
+
this.xrplApi = options.xrplApi || Defaults.values.xrplApi;
|
56468
56490
|
|
56469
56491
|
if (!this.xrplApi)
|
56470
56492
|
throw "XrplAccount: xrplApi not specified.";
|
@@ -57186,7 +57208,7 @@ class XrplAccount {
|
|
57186
57208
|
Sequence: options.sequence || await this.getSequence(),
|
57187
57209
|
SigningPubKey: '', // This field is required for fee calculation.
|
57188
57210
|
Fee: '0', // This field is required for fee calculation.
|
57189
|
-
NetworkID:
|
57211
|
+
NetworkID: Defaults.values.networkID
|
57190
57212
|
}
|
57191
57213
|
|
57192
57214
|
Object.assign(tx, txOptions);
|
@@ -57244,11 +57266,11 @@ module.exports = {
|
|
57244
57266
|
const xrpl = __nccwpck_require__(4666);
|
57245
57267
|
const kp = __nccwpck_require__(8150);
|
57246
57268
|
const { EventEmitter } = __nccwpck_require__(6170);
|
57247
|
-
const {
|
57269
|
+
const { Defaults } = __nccwpck_require__(8262);
|
57248
57270
|
const { TransactionHelper } = __nccwpck_require__(7071);
|
57249
57271
|
const { XrplApiEvents } = __nccwpck_require__(3307);
|
57250
57272
|
const { XrplAccount } = __nccwpck_require__(9329);
|
57251
|
-
const {XrplHelpers} = __nccwpck_require__(3189)
|
57273
|
+
const { XrplHelpers } = __nccwpck_require__(3189)
|
57252
57274
|
|
57253
57275
|
const MAX_PAGE_LIMIT = 400;
|
57254
57276
|
const API_REQ_TYPE = {
|
@@ -57264,29 +57286,58 @@ const LEDGER_CLOSE_TIME = 1000
|
|
57264
57286
|
|
57265
57287
|
class XrplApi {
|
57266
57288
|
|
57267
|
-
#
|
57289
|
+
#primaryServer;
|
57290
|
+
#fallbackServers;
|
57268
57291
|
#client;
|
57269
57292
|
#events = new EventEmitter();
|
57270
57293
|
#addressSubscriptions = [];
|
57271
57294
|
#initialConnectCalled = false;
|
57272
57295
|
#isPermanentlyDisconnected = false;
|
57296
|
+
#isClientLocked = false;
|
57297
|
+
#isPrimaryServerConnected = false;
|
57298
|
+
#isFallbackServerConnected = false;
|
57299
|
+
#isAttemptingConnection = false;
|
57300
|
+
#xrplClientOptions;
|
57273
57301
|
#autoReconnect;
|
57274
57302
|
|
57275
|
-
constructor(rippledServer =
|
57276
|
-
|
57277
|
-
|
57303
|
+
constructor(rippledServer = '-', options = {}) {
|
57304
|
+
if (rippledServer == '-') {
|
57305
|
+
this.#primaryServer = null;
|
57306
|
+
} else {
|
57307
|
+
this.#primaryServer = rippledServer || Defaults.values.rippledServer;
|
57308
|
+
}
|
57309
|
+
this.#fallbackServers = options.fallbackRippledServers || Defaults.values.fallbackRippledServers || [];
|
57310
|
+
|
57311
|
+
if (!this.#primaryServer && (!this.#fallbackServers || !this.#fallbackServers.length))
|
57312
|
+
throw 'Either primaryServer or fallbackServers required.';
|
57313
|
+
|
57314
|
+
this.#xrplClientOptions = options.xrplClientOptions;
|
57315
|
+
const initServer = this.#primaryServer || this.#fallbackServers[0];
|
57316
|
+
const client = new xrpl.Client(initServer, this.#xrplClientOptions);
|
57317
|
+
this.#initXrplClient(client);
|
57278
57318
|
this.#autoReconnect = options.autoReconnect ?? true;
|
57279
57319
|
}
|
57280
57320
|
|
57281
|
-
async #
|
57282
|
-
|
57321
|
+
async #setClient(client, removeCurrentClient = false) {
|
57322
|
+
while (this.#isClientLocked) {
|
57323
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
57324
|
+
}
|
57325
|
+
if (removeCurrentClient) {
|
57326
|
+
this.#isClientLocked = true;
|
57283
57327
|
this.#client.removeAllListeners(); // Remove existing event listeners to avoid them getting called from the old client object.
|
57284
57328
|
await this.#client.disconnect();
|
57285
|
-
this.#
|
57329
|
+
this.#isClientLocked = false;
|
57330
|
+
}
|
57331
|
+
this.#client = client;
|
57332
|
+
}
|
57333
|
+
|
57334
|
+
async #initXrplClient(client) {
|
57335
|
+
if (this.#client) { // If the client already exists, clean it up.
|
57336
|
+
await this.#setClient(null, true);
|
57286
57337
|
}
|
57287
57338
|
|
57288
57339
|
try {
|
57289
|
-
this.#client
|
57340
|
+
await this.#setClient(client);
|
57290
57341
|
}
|
57291
57342
|
catch (e) {
|
57292
57343
|
console.log("Error occurred in Client initiation:", e)
|
@@ -57298,10 +57349,10 @@ class XrplApi {
|
|
57298
57349
|
|
57299
57350
|
this.#client.on('disconnected', (code) => {
|
57300
57351
|
if (this.#autoReconnect && !this.#isPermanentlyDisconnected) {
|
57301
|
-
console.log(`Connection failure for ${this.#
|
57352
|
+
console.log(`Connection failure for ${this.#client.url} (code:${code})`);
|
57302
57353
|
console.log("Re-initializing xrpl client.");
|
57303
57354
|
try {
|
57304
|
-
this.#initXrplClient().then(() => this.#connectXrplClient(true));
|
57355
|
+
this.#initXrplClient(this.#client).then(() => this.#connectXrplClient(true));
|
57305
57356
|
}
|
57306
57357
|
catch (e) {
|
57307
57358
|
console.log("Error occurred while re-initializing", e)
|
@@ -57359,40 +57410,113 @@ class XrplApi {
|
|
57359
57410
|
});
|
57360
57411
|
}
|
57361
57412
|
|
57362
|
-
async #
|
57413
|
+
async #attemptFallbackServerReconnect(maxRounds, attemptsPerServer = 3) {
|
57414
|
+
const fallbackServers = this.#fallbackServers;
|
57415
|
+
let round = 0;
|
57416
|
+
while (fallbackServers?.length > 0 && !this.#isPermanentlyDisconnected && !this.#isPrimaryServerConnected && !this.#isFallbackServerConnected && (!maxRounds || round < maxRounds)) { // Keep attempting until consumer calls disconnect() manually or if the primary server is disconnected.
|
57417
|
+
++round;
|
57418
|
+
serverIterator:
|
57419
|
+
for (let serverIndex in fallbackServers) {
|
57420
|
+
const server = fallbackServers[serverIndex];
|
57421
|
+
for (let attempt = 0; attempt < attemptsPerServer;) {
|
57422
|
+
if (this.#isPrimaryServerConnected || this.#isPermanentlyDisconnected) {
|
57423
|
+
break serverIterator;
|
57424
|
+
}
|
57425
|
+
console.log(`Fallback server ${server} reconnection attempt ${++attempt}`);
|
57426
|
+
try {
|
57427
|
+
while (this.#isAttemptingConnection) {
|
57428
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
57429
|
+
}
|
57430
|
+
this.#isAttemptingConnection = true;
|
57431
|
+
const client = new xrpl.Client(server, this.#xrplClientOptions);
|
57432
|
+
if (!this.#isPrimaryServerConnected) {
|
57433
|
+
await this.#handleClientConnect(client);
|
57434
|
+
await this.#initXrplClient(client);
|
57435
|
+
this.#isFallbackServerConnected = true;
|
57436
|
+
console.log(`Successfully connected to the fallback server ${server}`)
|
57437
|
+
}
|
57438
|
+
this.#isAttemptingConnection = false;
|
57439
|
+
break serverIterator;
|
57440
|
+
}
|
57441
|
+
catch (e) {
|
57442
|
+
console.log(`Error occurred while connecting to fallback server ${server}`, e)
|
57443
|
+
this.#isAttemptingConnection = false;
|
57444
|
+
if (!this.#isPermanentlyDisconnected) {
|
57445
|
+
if (!maxRounds || round < maxRounds)
|
57446
|
+
console.log(`Fallback server ${server} connection attempt ${attempt} failed. Retrying in ${2 * round}s...`);
|
57447
|
+
else
|
57448
|
+
console.log(`Fallback server ${server} connection attempt failed.`);
|
57449
|
+
await new Promise(resolve => setTimeout(resolve, 2 * round * 1000));
|
57450
|
+
}
|
57451
|
+
}
|
57452
|
+
}
|
57453
|
+
}
|
57363
57454
|
|
57364
|
-
|
57365
|
-
|
57366
|
-
|
57367
|
-
|
57368
|
-
|
57369
|
-
|
57370
|
-
|
57455
|
+
}
|
57456
|
+
}
|
57457
|
+
|
57458
|
+
async #attemptPrimaryServerReconnect() {
|
57459
|
+
let attempt = 0;
|
57460
|
+
while (!this.#isPermanentlyDisconnected && !this.#isPrimaryServerConnected) { // Keep attempting until consumer calls disconnect() manually.
|
57461
|
+
console.log(`Primary server reconnection attempt ${++attempt}`);
|
57462
|
+
try {
|
57463
|
+
const client = new xrpl.Client(this.#primaryServer, this.#xrplClientOptions);
|
57464
|
+
while (this.#isAttemptingConnection) {
|
57465
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
57371
57466
|
}
|
57372
|
-
|
57373
|
-
|
57374
|
-
|
57375
|
-
|
57376
|
-
|
57377
|
-
|
57378
|
-
|
57467
|
+
this.#isAttemptingConnection = true;
|
57468
|
+
await this.#handleClientConnect(client);
|
57469
|
+
await this.#initXrplClient(client);
|
57470
|
+
this.#isFallbackServerConnected = false;
|
57471
|
+
this.#isPrimaryServerConnected = true;
|
57472
|
+
console.log("Successfully connected to the primary server");
|
57473
|
+
this.#isAttemptingConnection = false;
|
57474
|
+
break;
|
57475
|
+
}
|
57476
|
+
catch (e) {
|
57477
|
+
console.log("Error occurred while re-connecting to the primary server", e)
|
57478
|
+
this.#isAttemptingConnection = false;
|
57479
|
+
if (!this.#isPermanentlyDisconnected) {
|
57480
|
+
const delaySec = 2 * attempt; // Retry with backoff delay.
|
57481
|
+
console.log(`Attempt ${attempt} failed. Retrying in ${delaySec}s...`);
|
57482
|
+
await new Promise(resolve => setTimeout(resolve, delaySec * 1000));
|
57379
57483
|
}
|
57380
57484
|
}
|
57381
57485
|
}
|
57486
|
+
}
|
57487
|
+
|
57488
|
+
async #connectXrplClient(reconnect = false) {
|
57489
|
+
if (reconnect) {
|
57490
|
+
if (this.#primaryServer) {
|
57491
|
+
Promise.all([this.#attemptFallbackServerReconnect(), this.#attemptPrimaryServerReconnect()]);
|
57492
|
+
} else {
|
57493
|
+
this.#attemptFallbackServerReconnect();
|
57494
|
+
}
|
57495
|
+
await this.#waitForReconnection();
|
57496
|
+
}
|
57382
57497
|
else {
|
57383
57498
|
// Single attempt and throw error. Used for initial connect() call.
|
57384
|
-
|
57499
|
+
try {
|
57500
|
+
await this.#handleClientConnect();
|
57501
|
+
this.#isPrimaryServerConnected = true;
|
57502
|
+
} catch {
|
57503
|
+
await this.#attemptFallbackServerReconnect(1, 1);
|
57504
|
+
if (this.#isFallbackServerConnected)
|
57505
|
+
await this.#attemptPrimaryServerReconnect();
|
57506
|
+
}
|
57385
57507
|
}
|
57386
57508
|
|
57387
57509
|
// After connection established, check again whether maintainConnections has become false.
|
57388
57510
|
// This is in case the consumer has called disconnect() while connection is being established.
|
57389
57511
|
if (!this.#isPermanentlyDisconnected) {
|
57512
|
+
this.#isClientLocked = true;
|
57390
57513
|
this.ledgerIndex = await this.#client.getLedgerIndex();
|
57514
|
+
this.#isClientLocked = false;
|
57391
57515
|
this.#subscribeToStream('ledger');
|
57392
57516
|
|
57393
57517
|
// Re-subscribe to existing account address subscriptions (in case this is a reconnect)
|
57394
57518
|
if (this.#addressSubscriptions.length > 0)
|
57395
|
-
await this.#
|
57519
|
+
await this.#handleClientRequest({ command: 'subscribe', accounts: this.#addressSubscriptions.map(s => s.address) });
|
57396
57520
|
}
|
57397
57521
|
else {
|
57398
57522
|
await this.disconnect();
|
@@ -57412,7 +57536,7 @@ class XrplApi {
|
|
57412
57536
|
requestObj.marker = resp?.result?.marker;
|
57413
57537
|
else
|
57414
57538
|
delete requestObj.marker;
|
57415
|
-
resp = (await this.#
|
57539
|
+
resp = (await this.#handleClientRequest(requestObj));
|
57416
57540
|
if (resp?.result && resp?.result[requestType])
|
57417
57541
|
res.push(...resp.result[requestType]);
|
57418
57542
|
if (count)
|
@@ -57422,6 +57546,23 @@ class XrplApi {
|
|
57422
57546
|
return res;
|
57423
57547
|
}
|
57424
57548
|
|
57549
|
+
async #handleClientRequest(request = {}) {
|
57550
|
+
while (this.#isAttemptingConnection) {
|
57551
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
57552
|
+
}
|
57553
|
+
this.#isClientLocked = true;
|
57554
|
+
const response = await this.#client.request(request);
|
57555
|
+
|
57556
|
+
this.#isClientLocked = false;
|
57557
|
+
return response;
|
57558
|
+
}
|
57559
|
+
|
57560
|
+
async #handleClientConnect(client = this.#client) {
|
57561
|
+
this.#isClientLocked = true;
|
57562
|
+
await client.connect();
|
57563
|
+
this.#isClientLocked = false;
|
57564
|
+
}
|
57565
|
+
|
57425
57566
|
on(event, handler) {
|
57426
57567
|
this.#events.on(event, handler);
|
57427
57568
|
}
|
@@ -57434,23 +57575,34 @@ class XrplApi {
|
|
57434
57575
|
this.#events.off(event, handler);
|
57435
57576
|
}
|
57436
57577
|
|
57578
|
+
async #waitForReconnection() {
|
57579
|
+
while (!(this.#isPrimaryServerConnected || this.#isFallbackServerConnected)) {
|
57580
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
57581
|
+
}
|
57582
|
+
return true;
|
57583
|
+
}
|
57584
|
+
|
57437
57585
|
async connect() {
|
57438
57586
|
if (this.#initialConnectCalled) {
|
57439
57587
|
return
|
57440
57588
|
}
|
57441
|
-
this.#initialConnectCalled = true
|
57442
|
-
this.#isPermanentlyDisconnected = false
|
57589
|
+
this.#initialConnectCalled = true;
|
57590
|
+
this.#isPermanentlyDisconnected = false;
|
57443
57591
|
await this.#connectXrplClient();
|
57444
|
-
const definitions = await this.#
|
57592
|
+
const definitions = await this.#handleClientRequest({ command: 'server_definitions' })
|
57445
57593
|
this.xrplHelper = new XrplHelpers(definitions.result);
|
57446
57594
|
}
|
57447
57595
|
|
57448
57596
|
async disconnect() {
|
57449
57597
|
this.#initialConnectCalled = false;
|
57450
|
-
this.#isPermanentlyDisconnected = true
|
57598
|
+
this.#isPermanentlyDisconnected = true;
|
57451
57599
|
|
57452
57600
|
if (this.#client.isConnected()) {
|
57601
|
+
this.#isClientLocked = true;
|
57453
57602
|
await this.#client.disconnect().catch(console.error);
|
57603
|
+
this.#isClientLocked = false;
|
57604
|
+
this.#isPrimaryServerConnected = false;
|
57605
|
+
this.#isFallbackServerConnected = false;
|
57454
57606
|
}
|
57455
57607
|
}
|
57456
57608
|
|
@@ -57470,7 +57622,7 @@ class XrplApi {
|
|
57470
57622
|
|
57471
57623
|
async isAccountExists(address) {
|
57472
57624
|
try {
|
57473
|
-
await this.#
|
57625
|
+
await this.#handleClientRequest({ command: 'account_info', account: address });
|
57474
57626
|
return true;
|
57475
57627
|
}
|
57476
57628
|
catch (e) {
|
@@ -57480,12 +57632,12 @@ class XrplApi {
|
|
57480
57632
|
}
|
57481
57633
|
|
57482
57634
|
async getAccountInfo(address) {
|
57483
|
-
const resp = (await this.#
|
57635
|
+
const resp = (await this.#handleClientRequest({ command: 'account_info', account: address }));
|
57484
57636
|
return resp?.result?.account_data;
|
57485
57637
|
}
|
57486
57638
|
|
57487
57639
|
async getServerDefinition() {
|
57488
|
-
const resp = (await this.#
|
57640
|
+
const resp = (await this.#handleClientRequest({ command: 'server_definitions' }));
|
57489
57641
|
return resp?.result;
|
57490
57642
|
}
|
57491
57643
|
|
@@ -57529,7 +57681,7 @@ class XrplApi {
|
|
57529
57681
|
|
57530
57682
|
async getLedgerEntry(index, options) {
|
57531
57683
|
try {
|
57532
|
-
const resp = (await this.#
|
57684
|
+
const resp = (await this.#handleClientRequest({ command: 'ledger_entry', index: index, ledger_index: "validated", ...options }));
|
57533
57685
|
return resp?.result?.node;
|
57534
57686
|
|
57535
57687
|
} catch (e) {
|
@@ -57540,13 +57692,13 @@ class XrplApi {
|
|
57540
57692
|
}
|
57541
57693
|
|
57542
57694
|
async getTxnInfo(txnHash, options) {
|
57543
|
-
const resp = (await this.#
|
57695
|
+
const resp = (await this.#handleClientRequest({ command: 'tx', transaction: txnHash, binary: false, ...options }));
|
57544
57696
|
return resp?.result;
|
57545
57697
|
}
|
57546
57698
|
|
57547
57699
|
async subscribeToAddress(address, handler) {
|
57548
57700
|
this.#addressSubscriptions.push({ address: address, handler: handler });
|
57549
|
-
await this.#
|
57701
|
+
await this.#handleClientRequest({ command: 'subscribe', accounts: [address] });
|
57550
57702
|
}
|
57551
57703
|
|
57552
57704
|
async unsubscribeFromAddress(address, handler) {
|
@@ -57555,16 +57707,16 @@ class XrplApi {
|
|
57555
57707
|
if (sub.address === address && sub.handler === handler)
|
57556
57708
|
this.#addressSubscriptions.splice(i, 1);
|
57557
57709
|
}
|
57558
|
-
await this.#
|
57710
|
+
await this.#handleClientRequest({ command: 'unsubscribe', accounts: [address] });
|
57559
57711
|
}
|
57560
57712
|
|
57561
57713
|
async getTransactionFee(txBlob) {
|
57562
|
-
const fees = await this.#
|
57714
|
+
const fees = await this.#handleClientRequest({ command: 'fee', tx_blob: txBlob });
|
57563
57715
|
return fees?.result?.drops?.base_fee;
|
57564
57716
|
}
|
57565
57717
|
|
57566
57718
|
async #subscribeToStream(streamName) {
|
57567
|
-
await this.#
|
57719
|
+
await this.#handleClientRequest({ command: 'subscribe', streams: [streamName] });
|
57568
57720
|
}
|
57569
57721
|
|
57570
57722
|
/**
|
@@ -57580,7 +57732,9 @@ class XrplApi {
|
|
57580
57732
|
|
57581
57733
|
await new Promise(r => setTimeout(r, LEDGER_CLOSE_TIME));
|
57582
57734
|
|
57735
|
+
this.#isClientLocked = true;
|
57583
57736
|
const latestLedger = await this.#client.getLedgerIndex();
|
57737
|
+
this.#isClientLocked = false;
|
57584
57738
|
|
57585
57739
|
if (lastLedger < latestLedger) {
|
57586
57740
|
throw `The latest ledger sequence ${latestLedger} is greater than the transaction's LastLedgerSequence (${lastLedger}).\n` +
|
@@ -57647,7 +57801,7 @@ class XrplApi {
|
|
57647
57801
|
*/
|
57648
57802
|
async submitMultisignedAndWait(tx) {
|
57649
57803
|
tx.SigningPubKey = "";
|
57650
|
-
const submissionResult = await this.#
|
57804
|
+
const submissionResult = await this.#handleClientRequest({ command: 'submit_multisigned', tx_json: tx });
|
57651
57805
|
return await this.#prepareResponse(tx, submissionResult);
|
57652
57806
|
}
|
57653
57807
|
|
@@ -57658,7 +57812,7 @@ class XrplApi {
|
|
57658
57812
|
*/
|
57659
57813
|
async submitMultisigned(tx) {
|
57660
57814
|
tx.SigningPubKey = "";
|
57661
|
-
return await this.#
|
57815
|
+
return await this.#handleClientRequest({ command: 'submit_multisigned', tx_json: tx });
|
57662
57816
|
}
|
57663
57817
|
|
57664
57818
|
/**
|
@@ -57667,7 +57821,7 @@ class XrplApi {
|
|
57667
57821
|
* @returns response object of the validated transaction.
|
57668
57822
|
*/
|
57669
57823
|
async submitAndWait(tx, tx_blob) {
|
57670
|
-
const submissionResult = await this.#
|
57824
|
+
const submissionResult = await this.#handleClientRequest({ command: 'submit', tx_blob: tx_blob });
|
57671
57825
|
return await this.#prepareResponse(tx, submissionResult);
|
57672
57826
|
}
|
57673
57827
|
|
@@ -57677,7 +57831,7 @@ class XrplApi {
|
|
57677
57831
|
* @returns response object of the submitted transaction.
|
57678
57832
|
*/
|
57679
57833
|
async submit(tx_blob) {
|
57680
|
-
return await this.#
|
57834
|
+
return await this.#handleClientRequest({ command: 'submit', tx_blob: tx_blob });
|
57681
57835
|
}
|
57682
57836
|
|
57683
57837
|
/**
|
@@ -57777,6 +57931,14 @@ module.exports = {
|
|
57777
57931
|
XrplHelpers
|
57778
57932
|
}
|
57779
57933
|
|
57934
|
+
/***/ }),
|
57935
|
+
|
57936
|
+
/***/ 4626:
|
57937
|
+
/***/ ((module) => {
|
57938
|
+
|
57939
|
+
module.exports = eval("require")("./resources/definitions.json");
|
57940
|
+
|
57941
|
+
|
57780
57942
|
/***/ }),
|
57781
57943
|
|
57782
57944
|
/***/ 9491:
|
package/package.json
CHANGED
Binary file
|
Binary file
|