evernode-js-client 0.6.29 → 0.6.30
Sign up to get free protection for your applications and to get access to all the features.
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.napi.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.napi1.node");
|
33344
33344
|
} catch (e) {
|
33345
33345
|
module.exports = __nccwpck_require__(9372);
|
33346
33346
|
}
|
@@ -53354,12 +53354,22 @@ const VOTE_VALIDATION_ERR = "VOTE_VALIDATION_ERR";
|
|
53354
53354
|
|
53355
53355
|
const IPV6_FAMILY = 6;
|
53356
53356
|
|
53357
|
+
const MAX_HOST_LEDGER_OFFSET = 30;
|
53358
|
+
|
53357
53359
|
class HostClient extends BaseEvernodeClient {
|
53358
53360
|
|
53359
53361
|
constructor(xrpAddress, xrpSecret, options = {}) {
|
53360
53362
|
super(xrpAddress, xrpSecret, Object.values(HostEvents), true, options);
|
53361
53363
|
}
|
53362
53364
|
|
53365
|
+
/**
|
53366
|
+
* Get max ledger sequence for host client.
|
53367
|
+
* @returns Max ledger sequence number.
|
53368
|
+
*/
|
53369
|
+
#getMaxLedgerSequence() {
|
53370
|
+
return (this.xrplApi.ledgerIndex + MAX_HOST_LEDGER_OFFSET);
|
53371
|
+
}
|
53372
|
+
|
53363
53373
|
/**
|
53364
53374
|
* Get registration URI token info.
|
53365
53375
|
* @returns The registration URI token object.
|
@@ -53421,10 +53431,10 @@ class HostClient extends BaseEvernodeClient {
|
|
53421
53431
|
{ ...accountSetFields, Domain: domain } : accountSetFields;
|
53422
53432
|
|
53423
53433
|
if (Object.keys(accountSetFields).length !== 0)
|
53424
|
-
await this.xrplAcc.setAccountFields(accountSetFields);
|
53434
|
+
await this.xrplAcc.setAccountFields(accountSetFields, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53425
53435
|
|
53426
53436
|
if (trustLines.length === 0)
|
53427
|
-
await this.xrplAcc.setTrustLine(EvernodeConstants.EVR, this.config.evrIssuerAddress, "99999999999999");
|
53437
|
+
await this.xrplAcc.setTrustLine(EvernodeConstants.EVR, this.config.evrIssuerAddress, "99999999999999", null, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53428
53438
|
}
|
53429
53439
|
|
53430
53440
|
/**
|
@@ -53486,15 +53496,15 @@ class HostClient extends BaseEvernodeClient {
|
|
53486
53496
|
const uri = uriBuf.toString('base64');
|
53487
53497
|
|
53488
53498
|
try {
|
53489
|
-
await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false });
|
53499
|
+
await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53490
53500
|
} catch (e) {
|
53491
53501
|
// Re-minting the URIToken after burning that sold URIToken.
|
53492
53502
|
if (e.code === "tecDUPLICATE") {
|
53493
53503
|
const uriTokenId = this.xrplAcc.generateIssuedURITokenId(uri);
|
53494
53504
|
console.log(`Burning URIToken related to a previously sold lease.`);
|
53495
|
-
await this.xrplAcc.burnURIToken(uriTokenId);
|
53505
|
+
await this.xrplAcc.burnURIToken(uriTokenId, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53496
53506
|
console.log("Re-mint the URIToken for the new lease offer.")
|
53497
|
-
await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false });
|
53507
|
+
await this.xrplAcc.mintURIToken(uri, null, { isBurnable: true, isHexUri: false }, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53498
53508
|
}
|
53499
53509
|
}
|
53500
53510
|
|
@@ -53505,7 +53515,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53505
53515
|
await this.xrplAcc.sellURIToken(uriToken.index,
|
53506
53516
|
leaseAmount.toString(),
|
53507
53517
|
EvernodeConstants.EVR,
|
53508
|
-
this.config.evrIssuerAddress);
|
53518
|
+
this.config.evrIssuerAddress, null, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53509
53519
|
}
|
53510
53520
|
|
53511
53521
|
/**
|
@@ -53513,7 +53523,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53513
53523
|
* @param {string} uriTokenId Hex URI token id of the lease.
|
53514
53524
|
*/
|
53515
53525
|
async expireLease(uriTokenId) {
|
53516
|
-
await this.xrplAcc.burnURIToken(uriTokenId);
|
53526
|
+
await this.xrplAcc.burnURIToken(uriTokenId, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53517
53527
|
}
|
53518
53528
|
|
53519
53529
|
/**
|
@@ -53567,7 +53577,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53567
53577
|
if (existingLeaseURITokens) {
|
53568
53578
|
console.log("Burning unsold URITokens related to the previous leases.");
|
53569
53579
|
for (const uriToken of existingLeaseURITokens) {
|
53570
|
-
await this.xrplAcc.burnURIToken(uriToken.index);
|
53580
|
+
await this.xrplAcc.burnURIToken(uriToken.index, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53571
53581
|
}
|
53572
53582
|
}
|
53573
53583
|
|
@@ -53582,7 +53592,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53582
53592
|
const sellOffer = (await registryAcc.getURITokens()).find(o => o.index == regInfo.uriTokenId && o.Amount);
|
53583
53593
|
console.log('sell offer')
|
53584
53594
|
if (sellOffer) {
|
53585
|
-
await this.xrplAcc.buyURIToken(sellOffer);
|
53595
|
+
await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53586
53596
|
console.log("Registration was successfully completed after acquiring the NFT.");
|
53587
53597
|
return await this.isRegistered();
|
53588
53598
|
}
|
@@ -53632,6 +53642,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53632
53642
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REG },
|
53633
53643
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
|
53634
53644
|
],
|
53645
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53635
53646
|
...options.transactionOptions
|
53636
53647
|
});
|
53637
53648
|
|
@@ -53670,7 +53681,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53670
53681
|
resolve();
|
53671
53682
|
});
|
53672
53683
|
|
53673
|
-
await this.xrplAcc.buyURIToken(sellOffer);
|
53684
|
+
await this.xrplAcc.buyURIToken(sellOffer, null, { maxLedgerIndex: this.#getMaxLedgerSequence() });
|
53674
53685
|
return await this.isRegistered();
|
53675
53686
|
}
|
53676
53687
|
|
@@ -53703,6 +53714,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53703
53714
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_DEREG },
|
53704
53715
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex').toUpperCase() }
|
53705
53716
|
],
|
53717
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53706
53718
|
...options.transactionOptions
|
53707
53719
|
});
|
53708
53720
|
|
@@ -53764,6 +53776,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53764
53776
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_UPDATE_INFO },
|
53765
53777
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramBuf.toString('hex') }
|
53766
53778
|
],
|
53779
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53767
53780
|
...options.transactionOptions
|
53768
53781
|
});
|
53769
53782
|
}
|
@@ -53795,6 +53808,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53795
53808
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HEARTBEAT },
|
53796
53809
|
...(data ? [{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: data }] : [])
|
53797
53810
|
],
|
53811
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53798
53812
|
...options.transactionOptions
|
53799
53813
|
});
|
53800
53814
|
return res;
|
@@ -53861,6 +53875,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53861
53875
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.ACQUIRE_SUCCESS },
|
53862
53876
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
|
53863
53877
|
],
|
53878
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53864
53879
|
...options.transactionOptions
|
53865
53880
|
});
|
53866
53881
|
}
|
@@ -53888,6 +53903,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53888
53903
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.ACQUIRE_ERROR },
|
53889
53904
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
|
53890
53905
|
],
|
53906
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53891
53907
|
...options.transactionOptions
|
53892
53908
|
});
|
53893
53909
|
}
|
@@ -53916,6 +53932,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53916
53932
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.EXTEND_SUCCESS },
|
53917
53933
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
|
53918
53934
|
],
|
53935
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53919
53936
|
...options.transactionOptions
|
53920
53937
|
});
|
53921
53938
|
}
|
@@ -53944,6 +53961,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53944
53961
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.EXTEND_ERROR },
|
53945
53962
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
|
53946
53963
|
],
|
53964
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53947
53965
|
...options.transactionOptions
|
53948
53966
|
});
|
53949
53967
|
}
|
@@ -53969,6 +53987,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53969
53987
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.REFUND },
|
53970
53988
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: txHash }
|
53971
53989
|
],
|
53990
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53972
53991
|
...options.transactionOptions
|
53973
53992
|
});
|
53974
53993
|
}
|
@@ -53990,6 +54009,7 @@ class HostClient extends BaseEvernodeClient {
|
|
53990
54009
|
hookParams: [
|
53991
54010
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_REBATE }
|
53992
54011
|
],
|
54012
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
53993
54013
|
...options.transactionOptions
|
53994
54014
|
});
|
53995
54015
|
}
|
@@ -54027,6 +54047,7 @@ class HostClient extends BaseEvernodeClient {
|
|
54027
54047
|
{ name: HookParamKeys.PARAM_EVENT_TYPE_KEY, value: EventTypes.HOST_TRANSFER },
|
54028
54048
|
{ name: HookParamKeys.PARAM_EVENT_DATA1_KEY, value: paramData.toString('hex') }
|
54029
54049
|
],
|
54050
|
+
maxLedgerIndex: this.#getMaxLedgerSequence(),
|
54030
54051
|
...options.transactionOptions
|
54031
54052
|
});
|
54032
54053
|
|
@@ -54073,6 +54094,7 @@ class HostClient extends BaseEvernodeClient {
|
|
54073
54094
|
if (!(await this.isRegistered()))
|
54074
54095
|
throw 'Host should be registered to propose candidates.';
|
54075
54096
|
|
54097
|
+
options.transactionOptions = { maxLedgerIndex: this.#getMaxLedgerSequence(), ...(options.transactionOptions || {}) }
|
54076
54098
|
return await super._propose(hashes, shortName, options);
|
54077
54099
|
}
|
54078
54100
|
|
@@ -54086,6 +54108,7 @@ class HostClient extends BaseEvernodeClient {
|
|
54086
54108
|
if (!(await this.isRegistered()))
|
54087
54109
|
throw 'Host should be registered to withdraw candidates.';
|
54088
54110
|
|
54111
|
+
options.transactionOptions = { maxLedgerIndex: this.#getMaxLedgerSequence(), ...(options.transactionOptions || {}) }
|
54089
54112
|
return await super._withdraw(candidateId, options);
|
54090
54113
|
}
|
54091
54114
|
|
@@ -54099,6 +54122,7 @@ class HostClient extends BaseEvernodeClient {
|
|
54099
54122
|
if (!(await this.isRegistered()))
|
54100
54123
|
throw 'Host should be registered to report dud hosts.';
|
54101
54124
|
|
54125
|
+
options.transactionOptions = { maxLedgerIndex: this.#getMaxLedgerSequence(), ...(options.transactionOptions || {}) }
|
54102
54126
|
return await this._reportDudHost(hostAddress, options);
|
54103
54127
|
}
|
54104
54128
|
}
|
@@ -55707,6 +55731,7 @@ const HOST_LAST_VOTE_TIMESTAMP_OFFSET = 116;
|
|
55707
55731
|
const HOST_SUPPORT_VOTE_FLAG_OFFSET = 124;
|
55708
55732
|
const HOST_REPUTATION_OFFSET = 125;
|
55709
55733
|
const HOST_FLAGS_OFFSET = 126;
|
55734
|
+
const HOST_TRANSFER_TIMESTAMP_OFFSET = 127;
|
55710
55735
|
|
55711
55736
|
const HOST_ADDRESS_OFFSET = 0;
|
55712
55737
|
const HOST_CPU_MODEL_NAME_OFFSET = 20;
|
@@ -55818,6 +55843,9 @@ class StateHelpers {
|
|
55818
55843
|
const flags = stateDataBuf.readUInt8(HOST_FLAGS_OFFSET);
|
55819
55844
|
data.reputedOnHeartbeat = !!(flags & HOST_FLAGS.REPUTED_ON_HEARTBEAT);
|
55820
55845
|
}
|
55846
|
+
if (stateDataBuf.length > HOST_TRANSFER_TIMESTAMP_OFFSET) {
|
55847
|
+
data.transferTimestamp = Number(stateDataBuf.readBigUInt64LE(HOST_TRANSFER_TIMESTAMP_OFFSET));
|
55848
|
+
}
|
55821
55849
|
return data;
|
55822
55850
|
}
|
55823
55851
|
|
@@ -57517,6 +57545,8 @@ class XrplApi {
|
|
57517
57545
|
});
|
57518
57546
|
|
57519
57547
|
client.on('disconnected', async (code) => {
|
57548
|
+
this.#events.emit(XrplApiEvents.DISCONNECTED, code);
|
57549
|
+
|
57520
57550
|
this.#isPrimaryServerConnected = false;
|
57521
57551
|
this.#isFallbackServerConnected = false;
|
57522
57552
|
|
@@ -57939,30 +57969,25 @@ class XrplApi {
|
|
57939
57969
|
* @returns prepared response of the transaction result.
|
57940
57970
|
*/
|
57941
57971
|
async #prepareResponse(tx, submissionResult) {
|
57942
|
-
const
|
57943
|
-
|
57944
|
-
|
57945
|
-
|
57946
|
-
|
57947
|
-
|
57948
|
-
details: result
|
57949
|
-
};
|
57972
|
+
const result = await this.#waitForFinalTransactionOutcome(submissionResult.result.tx_json.hash, tx.LastLedgerSequence, submissionResult);
|
57973
|
+
const txResult = {
|
57974
|
+
id: result?.hash,
|
57975
|
+
code: result?.meta?.TransactionResult,
|
57976
|
+
details: result
|
57977
|
+
};
|
57950
57978
|
|
57951
|
-
|
57952
|
-
|
57953
|
-
|
57954
|
-
|
57955
|
-
|
57956
|
-
|
57957
|
-
|
57958
|
-
|
57959
|
-
|
57960
|
-
|
57961
|
-
else
|
57962
|
-
throw { ...txResult, ...(hookExecRes ? { hookExecutionResult: hookExecRes } : {}) };
|
57963
|
-
}
|
57979
|
+
console.log("Transaction result: " + txResult.code);
|
57980
|
+
const hookExecRes = txResult.details?.meta?.HookExecutions?.map(o => {
|
57981
|
+
return {
|
57982
|
+
result: o.HookExecution?.HookResult,
|
57983
|
+
returnCode: parseInt(o.HookExecution?.HookReturnCode, 16),
|
57984
|
+
message: TransactionHelper.hexToASCII(o.HookExecution?.HookReturnString).replace(/\x00+$/, '')
|
57985
|
+
}
|
57986
|
+
});
|
57987
|
+
if (txResult.code === "tesSUCCESS")
|
57988
|
+
return { ...txResult, ...(hookExecRes ? { hookExecutionResult: hookExecRes } : {}) };
|
57964
57989
|
else
|
57965
|
-
throw
|
57990
|
+
throw { ...txResult, ...(hookExecRes ? { hookExecutionResult: hookExecRes } : {}) };
|
57966
57991
|
|
57967
57992
|
}
|
57968
57993
|
|
@@ -58032,6 +58057,7 @@ module.exports = {
|
|
58032
58057
|
|
58033
58058
|
const XrplApiEvents = {
|
58034
58059
|
LEDGER: 'ledger',
|
58060
|
+
DISCONNECTED: 'disconnected',
|
58035
58061
|
PAYMENT: 'payment',
|
58036
58062
|
NFT_OFFER_CREATE: 'nftokencreateoffer',
|
58037
58063
|
NFT_OFFER_ACCEPT: 'nftokenacceptoffer',
|
package/package.json
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
],
|
7
7
|
"homepage": "https://github.com/HotPocketDev/evernode-js-client",
|
8
8
|
"license": "SEE LICENSE IN https://raw.githubusercontent.com/EvernodeXRPL/evernode-resources/main/license/evernode-license.pdf",
|
9
|
-
"version": "0.6.
|
9
|
+
"version": "0.6.30",
|
10
10
|
"dependencies": {
|
11
11
|
"elliptic": "6.5.4",
|
12
12
|
"libsodium-wrappers": "0.7.10",
|
Binary file
|
Binary file
|