evernode-js-client 0.4.37 → 0.4.40
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +178 -73
- package/package.json +1 -1
package/index.js
CHANGED
@@ -11704,6 +11704,7 @@ exports.Vector256 = Vector256;
|
|
11704
11704
|
/***/ 9595:
|
11705
11705
|
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
11706
11706
|
|
11707
|
+
const codec = __nccwpck_require__(597);
|
11707
11708
|
const { Buffer } = __nccwpck_require__(4300);
|
11708
11709
|
const { XrplApi } = __nccwpck_require__(4346);
|
11709
11710
|
const { XrplAccount } = __nccwpck_require__(8196);
|
@@ -11714,6 +11715,7 @@ const { EncryptionHelper } = __nccwpck_require__(7769);
|
|
11714
11715
|
const { EventEmitter } = __nccwpck_require__(8208);
|
11715
11716
|
const { UtilHelpers } = __nccwpck_require__(1255);
|
11716
11717
|
const { FirestoreHandler } = __nccwpck_require__(4972);
|
11718
|
+
const { XflHelpers } = __nccwpck_require__(5201);
|
11717
11719
|
|
11718
11720
|
class BaseEvernodeClient {
|
11719
11721
|
|
@@ -11807,12 +11809,18 @@ class BaseEvernodeClient {
|
|
11807
11809
|
(h.lastHeartbeatLedger >= (curMomentStartIdx - (this.config.hostHeartbeatFreq * this.config.momentSize))) :
|
11808
11810
|
(h.lastHeartbeatLedger > 0))
|
11809
11811
|
});
|
11810
|
-
return hosts
|
11812
|
+
return hosts;
|
11811
11813
|
}
|
11812
11814
|
|
11813
|
-
async
|
11814
|
-
const
|
11815
|
-
|
11815
|
+
async getHookStates() {
|
11816
|
+
const regAcc = new XrplAccount(this.registryAddress, null, { xrplApi: this.xrplApi });
|
11817
|
+
const hookNamespaces = (await regAcc.getInfo())?.HookNamespaces;
|
11818
|
+
if (hookNamespaces) {
|
11819
|
+
const configs = await regAcc.getNamespaceEntries(hookNamespaces[0]);
|
11820
|
+
return configs.filter(c => c.LedgerEntryType === 'HookState').map(c => { return { key: c.HookStateKey, data: c.HookStateData } });
|
11821
|
+
}
|
11822
|
+
return [];
|
11823
|
+
|
11816
11824
|
}
|
11817
11825
|
|
11818
11826
|
async getMoment(ledgerIndex = null) {
|
@@ -11832,16 +11840,16 @@ class BaseEvernodeClient {
|
|
11832
11840
|
}
|
11833
11841
|
|
11834
11842
|
async #getEvernodeConfig() {
|
11835
|
-
let states = await this.
|
11843
|
+
let states = await this.getHookStates();
|
11836
11844
|
return {
|
11837
|
-
evrIssuerAddress: UtilHelpers.getStateData(states, HookStateKeys.EVR_ISSUER_ADDR),
|
11838
|
-
foundationAddress: UtilHelpers.getStateData(states, HookStateKeys.FOUNDATION_ADDR),
|
11839
|
-
hostRegFee: UtilHelpers.getStateData(states, HookStateKeys.HOST_REG_FEE),
|
11840
|
-
momentSize: UtilHelpers.getStateData(states, HookStateKeys.MOMENT_SIZE),
|
11841
|
-
hostHeartbeatFreq: UtilHelpers.getStateData(states, HookStateKeys.HOST_HEARTBEAT_FREQ),
|
11842
|
-
momentBaseIdx: UtilHelpers.getStateData(states, HookStateKeys.MOMENT_BASE_IDX),
|
11843
|
-
purchaserTargetPrice: UtilHelpers.getStateData(states, HookStateKeys.PURCHASER_TARGET_PRICE),
|
11844
|
-
leaseAcquireWindow: UtilHelpers.getStateData(states, HookStateKeys.LEASE_ACQUIRE_WINDOW)
|
11845
|
+
evrIssuerAddress: codec.encodeAccountID(Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.EVR_ISSUER_ADDR), 'hex')),
|
11846
|
+
foundationAddress: codec.encodeAccountID(Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.FOUNDATION_ADDR), 'hex')),
|
11847
|
+
hostRegFee: Number(Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.HOST_REG_FEE), 'hex').readBigUInt64BE()),
|
11848
|
+
momentSize: Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.MOMENT_SIZE), 'hex').readUInt16BE(),
|
11849
|
+
hostHeartbeatFreq: Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.HOST_HEARTBEAT_FREQ), 'hex').readUInt16BE(),
|
11850
|
+
momentBaseIdx: Number(Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.MOMENT_BASE_IDX), 'hex').readBigInt64BE()),
|
11851
|
+
purchaserTargetPrice: XflHelpers.toString(Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.PURCHASER_TARGET_PRICE), 'hex').readBigInt64BE()),
|
11852
|
+
leaseAcquireWindow: Buffer.from(UtilHelpers.getStateData(states, HookStateKeys.LEASE_ACQUIRE_WINDOW), 'hex').readUInt16BE()
|
11845
11853
|
};
|
11846
11854
|
}
|
11847
11855
|
|
@@ -11862,18 +11870,7 @@ class BaseEvernodeClient {
|
|
11862
11870
|
}
|
11863
11871
|
|
11864
11872
|
async #extractEvernodeEvent(tx) {
|
11865
|
-
if (tx.TransactionType === '
|
11866
|
-
return {
|
11867
|
-
name: EvernodeEvents.NftOfferCreate,
|
11868
|
-
data: {
|
11869
|
-
transaction: tx,
|
11870
|
-
nfTokenId: tx.NFTokenID,
|
11871
|
-
flags: tx.Flags,
|
11872
|
-
hash: tx.hash
|
11873
|
-
}
|
11874
|
-
}
|
11875
|
-
}
|
11876
|
-
else if (tx.TransactionType === 'NFTokenAcceptOffer' && tx.NFTokenSellOffer && tx.Memos.length >= 1 &&
|
11873
|
+
if (tx.TransactionType === 'NFTokenAcceptOffer' && tx.NFTokenSellOffer && tx.Memos.length >= 1 &&
|
11877
11874
|
tx.Memos[0].type === MemoTypes.ACQUIRE_LEASE && tx.Memos[0].format === MemoFormats.BASE64 && tx.Memos[0].data) {
|
11878
11875
|
|
11879
11876
|
// If our account is the destination host account, then decrypt the payload.
|
@@ -11899,6 +11896,20 @@ class BaseEvernodeClient {
|
|
11899
11896
|
}
|
11900
11897
|
}
|
11901
11898
|
}
|
11899
|
+
|
11900
|
+
else if (tx.TransactionType === 'NFTokenAcceptOffer' && tx.NFTokenBuyOffer && tx.Memos.length >= 1 &&
|
11901
|
+
tx.Memos[0].type === MemoTypes.HOST_POST_DEREG && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
|
11902
|
+
return {
|
11903
|
+
name: EvernodeEvents.HostPostDeregistered,
|
11904
|
+
data: {
|
11905
|
+
transaction: tx,
|
11906
|
+
nfTokenId: tx.NFTokenBuyOffer.NFTokenID,
|
11907
|
+
flags: tx.Flags,
|
11908
|
+
hash: tx.hash
|
11909
|
+
}
|
11910
|
+
}
|
11911
|
+
}
|
11912
|
+
|
11902
11913
|
else if (tx.Memos.length >= 2 &&
|
11903
11914
|
tx.Memos[0].type === MemoTypes.ACQUIRE_SUCCESS && tx.Memos[0].data &&
|
11904
11915
|
tx.Memos[1].type === MemoTypes.ACQUIRE_REF && tx.Memos[1].data) {
|
@@ -12032,6 +12043,31 @@ class BaseEvernodeClient {
|
|
12032
12043
|
}
|
12033
12044
|
}
|
12034
12045
|
}
|
12046
|
+
else if (tx.Memos.length >= 1 &&
|
12047
|
+
tx.Memos[0].type === MemoTypes.REGISTRY_INIT && tx.Memos[0].format === MemoFormats.HEX && tx.Memos[0].data) {
|
12048
|
+
|
12049
|
+
return {
|
12050
|
+
name: EvernodeEvents.RegistryInitialized,
|
12051
|
+
data: {
|
12052
|
+
transaction: tx
|
12053
|
+
}
|
12054
|
+
}
|
12055
|
+
}
|
12056
|
+
else if (tx.Memos.length >= 1 &&
|
12057
|
+
tx.Memos[0].type === MemoTypes.HOST_UPDATE_INFO && tx.Memos[0].format === MemoFormats.TEXT && tx.Memos[0].data) {
|
12058
|
+
|
12059
|
+
const specs = tx.Memos[0].data.split(';');
|
12060
|
+
|
12061
|
+
return {
|
12062
|
+
name: EvernodeEvents.HostRegUpdated,
|
12063
|
+
data: {
|
12064
|
+
transaction: tx,
|
12065
|
+
host: tx.Account,
|
12066
|
+
version: specs[specs.length - 1],
|
12067
|
+
specs: specs,
|
12068
|
+
}
|
12069
|
+
}
|
12070
|
+
}
|
12035
12071
|
|
12036
12072
|
return null;
|
12037
12073
|
}
|
@@ -12059,7 +12095,6 @@ const OFFER_WAIT_TIMEOUT = 60;
|
|
12059
12095
|
|
12060
12096
|
const HostEvents = {
|
12061
12097
|
AcquireLease: EvernodeEvents.AcquireLease,
|
12062
|
-
NftOfferCreate: EvernodeEvents.NftOfferCreate,
|
12063
12098
|
ExtendLease: EvernodeEvents.ExtendLease
|
12064
12099
|
}
|
12065
12100
|
|
@@ -12205,41 +12240,42 @@ class HostClient extends BaseEvernodeClient {
|
|
12205
12240
|
[{ type: MemoTypes.HOST_REG, format: MemoFormats.TEXT, data: memoData }],
|
12206
12241
|
options.transactionOptions);
|
12207
12242
|
|
12208
|
-
|
12209
|
-
|
12243
|
+
console.log('Waiting for the sell offer')
|
12244
|
+
const regAcc = new XrplAccount(this.registryAddress, null, { xrplApi: this.xrplApi });
|
12245
|
+
let offer = null;
|
12246
|
+
let attempts = 0;
|
12247
|
+
let offerLedgerIndex = 0;
|
12248
|
+
while (attempts < OFFER_WAIT_TIMEOUT) {
|
12249
|
+
const nft = (await regAcc.getNfts()).find(n => n.URI === `${EvernodeConstants.NFT_PREFIX_HEX}${tx.id}`);
|
12250
|
+
if (nft) {
|
12251
|
+
offer = (await regAcc.getNftOffers()).find(o => o.Destination === this.xrplAcc.address && o.NFTokenID === nft.NFTokenID && o.Flags === 1);
|
12252
|
+
offerLedgerIndex = this.xrplApi.ledgerIndex;
|
12253
|
+
if (offer)
|
12254
|
+
break;
|
12255
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
12256
|
+
attempts++;
|
12257
|
+
}
|
12210
12258
|
|
12211
|
-
|
12259
|
+
}
|
12260
|
+
if (!offer)
|
12261
|
+
throw 'No sell offer found within timeout.';
|
12212
12262
|
|
12213
|
-
|
12263
|
+
console.log('Accepting the sell offer..');
|
12214
12264
|
|
12215
|
-
|
12216
|
-
|
12217
|
-
|
12218
|
-
|
12219
|
-
|
12220
|
-
|
12221
|
-
|
12265
|
+
// Wait until the next ledger after the offer is created.
|
12266
|
+
// Otherwise if the offer accepted in the same legder which it's been created,
|
12267
|
+
// We cannot fetch the offer from registry contract event handler since it's getting deleted immediately.
|
12268
|
+
await new Promise(async resolve => {
|
12269
|
+
while (this.xrplApi.ledgerIndex <= offerLedgerIndex)
|
12270
|
+
await new Promise(resolve2 => setTimeout(resolve2, 1000));
|
12271
|
+
resolve();
|
12272
|
+
});
|
12222
12273
|
|
12223
|
-
|
12224
|
-
throw "No sell offer was found within timeout.";
|
12274
|
+
await this.xrplAcc.buyNft(offer.index);
|
12225
12275
|
|
12226
12276
|
return await this.isRegistered();
|
12227
12277
|
}
|
12228
12278
|
|
12229
|
-
async handleNftOffer(r, tx) {
|
12230
|
-
if (this.xrplAcc.address === r.transaction.Destination) {
|
12231
|
-
const registryAcc = new XrplAccount(this.registryAddress, null, { xrplApi: this.xrplApi });
|
12232
|
-
const nft = (await registryAcc.getNfts()).find(n => n.URI === `${EvernodeConstants.NFT_PREFIX_HEX}${tx.id}`);
|
12233
|
-
if (nft) {
|
12234
|
-
const sellOffer = (await registryAcc.getNftOffers()).find(o => o.NFTokenID === nft.NFTokenID && o.Flags === 1);
|
12235
|
-
if (sellOffer) {
|
12236
|
-
await this.xrplAcc.buyNft(sellOffer.index);
|
12237
|
-
tx.isSellOfferAccepted = true;
|
12238
|
-
}
|
12239
|
-
}
|
12240
|
-
}
|
12241
|
-
}
|
12242
|
-
|
12243
12279
|
async deregister(options = {}) {
|
12244
12280
|
|
12245
12281
|
if (!(await this.isRegistered()))
|
@@ -12267,9 +12303,9 @@ class HostClient extends BaseEvernodeClient {
|
|
12267
12303
|
attempts++;
|
12268
12304
|
}
|
12269
12305
|
if (!offer)
|
12270
|
-
throw 'No offer found within timeout.';
|
12306
|
+
throw 'No buy offer found within timeout.';
|
12271
12307
|
|
12272
|
-
console.log('Accepting buy offer..');
|
12308
|
+
console.log('Accepting the buy offer..');
|
12273
12309
|
|
12274
12310
|
// Wait until the next ledger after the offer is created.
|
12275
12311
|
// Otherwise if the offer accepted in the same legder which it's been created,
|
@@ -12390,7 +12426,11 @@ const { DefaultValues } = __nccwpck_require__(542);
|
|
12390
12426
|
|
12391
12427
|
const RegistryEvents = {
|
12392
12428
|
HostRegistered: EvernodeEvents.HostRegistered,
|
12393
|
-
HostDeregistered: EvernodeEvents.HostDeregistered
|
12429
|
+
HostDeregistered: EvernodeEvents.HostDeregistered,
|
12430
|
+
HostRegUpdated: EvernodeEvents.HostRegUpdated,
|
12431
|
+
RegistryInitialized: EvernodeEvents.RegistryInitialized,
|
12432
|
+
Heartbeat: EvernodeEvents.Heartbeat,
|
12433
|
+
HostPostDeregistered: EvernodeEvents.HostPostDeregistered
|
12394
12434
|
}
|
12395
12435
|
|
12396
12436
|
class RegistryClient extends BaseEvernodeClient {
|
@@ -12400,9 +12440,22 @@ class RegistryClient extends BaseEvernodeClient {
|
|
12400
12440
|
}
|
12401
12441
|
|
12402
12442
|
async getActiveHosts() {
|
12443
|
+
let fullHostList = [];
|
12403
12444
|
const hosts = await this.getHosts();
|
12445
|
+
if (hosts.nextPageToken) {
|
12446
|
+
let currentPageToken = hosts.nextPageToken;
|
12447
|
+
let nextHosts = null;
|
12448
|
+
fullHostList = fullHostList.concat(hosts.data);
|
12449
|
+
while (currentPageToken) {
|
12450
|
+
nextHosts = await this.getHosts(null, null, currentPageToken);
|
12451
|
+
fullHostList = fullHostList.concat(nextHosts.nextPageToken ? nextHosts.data : nextHosts);
|
12452
|
+
currentPageToken = nextHosts.nextPageToken;
|
12453
|
+
}
|
12454
|
+
} else {
|
12455
|
+
fullHostList = fullHostList.concat(hosts);
|
12456
|
+
}
|
12404
12457
|
// Filter only active hosts.
|
12405
|
-
return
|
12458
|
+
return fullHostList.filter(h => h.active);
|
12406
12459
|
}
|
12407
12460
|
}
|
12408
12461
|
|
@@ -12626,9 +12679,9 @@ module.exports = {
|
|
12626
12679
|
|
12627
12680
|
const DefaultValues = {
|
12628
12681
|
registryAddress: 'rDPqJv7zu6DfeXexAYseABNM2hT2j2rpHv',
|
12629
|
-
rippledServer: 'wss://
|
12682
|
+
rippledServer: 'wss://hooks-testnet-v2.xrpl-labs.com',
|
12630
12683
|
xrplApi: null,
|
12631
|
-
stateIndexId: 'evernodeindex'
|
12684
|
+
stateIndexId: 'evernodeindex'
|
12632
12685
|
}
|
12633
12686
|
|
12634
12687
|
class Defaults {
|
@@ -13032,7 +13085,8 @@ const MemoTypes = {
|
|
13032
13085
|
EXTEND_LEASE: 'evnExtendLease',
|
13033
13086
|
EXTEND_SUCCESS: 'evnExtendSuccess',
|
13034
13087
|
EXTEND_ERROR: 'evnExtendError',
|
13035
|
-
EXTEND_REF: 'evnExtendRef'
|
13088
|
+
EXTEND_REF: 'evnExtendRef',
|
13089
|
+
REGISTRY_INIT: 'evnInitialize'
|
13036
13090
|
}
|
13037
13091
|
|
13038
13092
|
const MemoFormats = {
|
@@ -13054,7 +13108,8 @@ const ErrorReasons = {
|
|
13054
13108
|
INTERNAL_ERR: 'INTERNAL_ERR',
|
13055
13109
|
TIMEOUT: 'TIMEOUT',
|
13056
13110
|
HOST_INVALID: 'HOST_INVALID',
|
13057
|
-
HOST_INACTIVE: 'HOST_INACTIVE'
|
13111
|
+
HOST_INACTIVE: 'HOST_INACTIVE',
|
13112
|
+
NO_STATE_KEY: 'NO_STATE_KEY'
|
13058
13113
|
}
|
13059
13114
|
|
13060
13115
|
// All keys are prefixed with 'EVR' (0x455652)
|
@@ -13083,14 +13138,17 @@ const HookStateKeys = {
|
|
13083
13138
|
const EvernodeEvents = {
|
13084
13139
|
HostRegistered: "HostRegistered",
|
13085
13140
|
HostDeregistered: "HostDeregistered",
|
13141
|
+
HostPostDeregistered: "HostPostDeregistered",
|
13086
13142
|
AcquireLease: "AcquireLease",
|
13087
13143
|
AcquireSuccess: "AcquireSuccess",
|
13088
13144
|
AcquireError: "AcquireError",
|
13089
13145
|
Heartbeat: "Heartbeat",
|
13090
|
-
NftOfferCreate: "NftOfferCreate",
|
13091
13146
|
ExtendLease: "ExtendLease",
|
13092
13147
|
ExtendSuccess: "ExtendSuccess",
|
13093
|
-
ExtendError: "ExtendError"
|
13148
|
+
ExtendError: "ExtendError",
|
13149
|
+
HostRegUpdated: "HostRegUpdated",
|
13150
|
+
HostReRegistered: "HostReRegistered",
|
13151
|
+
RegistryInitialized: "RegistryInitialized"
|
13094
13152
|
}
|
13095
13153
|
|
13096
13154
|
module.exports = {
|
@@ -13400,7 +13458,7 @@ const { HostClient, HostEvents } = __nccwpck_require__(2878);
|
|
13400
13458
|
const { XrplApi } = __nccwpck_require__(4346);
|
13401
13459
|
const { XrplApiEvents, XrplConstants } = __nccwpck_require__(2296);
|
13402
13460
|
const { XrplAccount } = __nccwpck_require__(8196);
|
13403
|
-
const { EvernodeConstants } = __nccwpck_require__(5359);
|
13461
|
+
const { EvernodeConstants, HookStateKeys, MemoTypes } = __nccwpck_require__(5359);
|
13404
13462
|
const { XflHelpers } = __nccwpck_require__(5201);
|
13405
13463
|
const { FirestoreHandler } = __nccwpck_require__(4972);
|
13406
13464
|
const { StateHelpers } = __nccwpck_require__(1466);
|
@@ -13422,7 +13480,9 @@ module.exports = {
|
|
13422
13480
|
XflHelpers,
|
13423
13481
|
StateHelpers,
|
13424
13482
|
FirestoreHandler,
|
13425
|
-
UtilHelpers
|
13483
|
+
UtilHelpers,
|
13484
|
+
HookStateKeys,
|
13485
|
+
MemoTypes
|
13426
13486
|
}
|
13427
13487
|
|
13428
13488
|
/***/ }),
|
@@ -13456,6 +13516,14 @@ const HOST_CPU_MICROSEC_OFFSET = 64;
|
|
13456
13516
|
const HOST_RAM_MB_OFFSET = 68;
|
13457
13517
|
const HOST_DISK_MB_OFFSET = 72;
|
13458
13518
|
|
13519
|
+
const STATE_KEY_TYPES = {
|
13520
|
+
TOKEN_ID: 2,
|
13521
|
+
HOST_ADDR: 3
|
13522
|
+
}
|
13523
|
+
|
13524
|
+
const EVERNODE_PREFIX = 'EVR';
|
13525
|
+
const HOST_ADDR_KEY_ZERO_COUNT = 8;
|
13526
|
+
|
13459
13527
|
class StateHelpers {
|
13460
13528
|
static StateTypes = {
|
13461
13529
|
TOKEN_ID: 'tokenId',
|
@@ -13488,7 +13556,7 @@ class StateHelpers {
|
|
13488
13556
|
cpuMicrosec: stateDataBuf.readUInt32BE(HOST_CPU_MICROSEC_OFFSET),
|
13489
13557
|
ramMb: stateDataBuf.readUInt32BE(HOST_RAM_MB_OFFSET),
|
13490
13558
|
diskMb: stateDataBuf.readUInt32BE(HOST_DISK_MB_OFFSET)
|
13491
|
-
|
13559
|
+
}
|
13492
13560
|
}
|
13493
13561
|
|
13494
13562
|
static decodeStateData(stateKey, stateData) {
|
@@ -13608,6 +13676,30 @@ class StateHelpers {
|
|
13608
13676
|
else
|
13609
13677
|
throw { type: 'Validation Error', message: 'Invalid state key.' };
|
13610
13678
|
}
|
13679
|
+
|
13680
|
+
static generateTokenIdStateKey(nfTokenId) {
|
13681
|
+
// 1 byte - Key Type.
|
13682
|
+
let buf = Buffer.allocUnsafe(1);
|
13683
|
+
buf.writeUInt8(STATE_KEY_TYPES.TOKEN_ID);
|
13684
|
+
|
13685
|
+
const nfTokenIdBuf = Buffer.from(nfTokenId, "hex");
|
13686
|
+
const stateKeyBuf = (Buffer.concat([Buffer.from(EVERNODE_PREFIX, "utf-8"), buf, nfTokenIdBuf.slice(4, 32)]));
|
13687
|
+
return stateKeyBuf.toString('hex').toUpperCase();
|
13688
|
+
}
|
13689
|
+
|
13690
|
+
static generateHostAddrStateKey(address) {
|
13691
|
+
// 1 byte - Key Type.
|
13692
|
+
// 8 bytes - Zeros.
|
13693
|
+
let buf = Buffer.allocUnsafe(9);
|
13694
|
+
buf.writeUInt8(STATE_KEY_TYPES.HOST_ADDR);
|
13695
|
+
for (let i = 0; i < HOST_ADDR_KEY_ZERO_COUNT; i++) {
|
13696
|
+
buf.writeUInt8(0, i+1);
|
13697
|
+
}
|
13698
|
+
|
13699
|
+
const addrBuf = Buffer.from(codec.decodeAccountID(address), "hex");
|
13700
|
+
const stateKeyBuf = Buffer.concat([Buffer.from(EVERNODE_PREFIX, "utf-8"), buf, addrBuf]);
|
13701
|
+
return stateKeyBuf.toString('hex').toUpperCase();
|
13702
|
+
}
|
13611
13703
|
}
|
13612
13704
|
|
13613
13705
|
module.exports = {
|
@@ -13689,7 +13781,7 @@ module.exports = {
|
|
13689
13781
|
|
13690
13782
|
const { Buffer } = __nccwpck_require__(4300);
|
13691
13783
|
const { XflHelpers } = __nccwpck_require__(5201);
|
13692
|
-
const { EvernodeConstants } = __nccwpck_require__(5359);
|
13784
|
+
const { EvernodeConstants, ErrorReasons } = __nccwpck_require__(5359);
|
13693
13785
|
|
13694
13786
|
// Utility helper functions.
|
13695
13787
|
class UtilHelpers {
|
@@ -13697,7 +13789,7 @@ class UtilHelpers {
|
|
13697
13789
|
static getStateData(states, key) {
|
13698
13790
|
const state = states.find(s => key === s.key);
|
13699
13791
|
if (!state)
|
13700
|
-
throw `State key '${key}' not found
|
13792
|
+
throw { code: ErrorReasons.NO_STATE_KEY, error: `State key '${key}' not found.` };
|
13701
13793
|
|
13702
13794
|
return state.data;
|
13703
13795
|
}
|
@@ -13990,6 +14082,10 @@ class XrplAccount {
|
|
13990
14082
|
return await this.xrplApi.getAccountObjects(this.address, options);
|
13991
14083
|
}
|
13992
14084
|
|
14085
|
+
async getNamespaceEntries(namespaceId, options = {}) {
|
14086
|
+
return await this.xrplApi.getNamespaceEntries(this.address, namespaceId, options);
|
14087
|
+
}
|
14088
|
+
|
13993
14089
|
async getFlags() {
|
13994
14090
|
return xrpl.parseAccountRootFlags((await this.getInfo()).Flags);
|
13995
14091
|
}
|
@@ -14054,7 +14150,7 @@ class XrplAccount {
|
|
14054
14150
|
if (typeof limit !== 'string')
|
14055
14151
|
throw "Limit must be a string.";
|
14056
14152
|
|
14057
|
-
|
14153
|
+
let tx = {
|
14058
14154
|
TransactionType: 'TrustSet',
|
14059
14155
|
Account: this.address,
|
14060
14156
|
LimitAmount: {
|
@@ -14062,11 +14158,13 @@ class XrplAccount {
|
|
14062
14158
|
issuer: issuer,
|
14063
14159
|
value: limit
|
14064
14160
|
},
|
14065
|
-
Flags: {
|
14066
|
-
tfSetNoRipple: !allowRippling
|
14067
|
-
},
|
14068
14161
|
Memos: TransactionHelper.formatMemos(memos)
|
14069
|
-
}
|
14162
|
+
};
|
14163
|
+
|
14164
|
+
if (!allowRippling)
|
14165
|
+
tx.Flags = 131072; // tfSetNoRipple;
|
14166
|
+
|
14167
|
+
return this.#submitAndVerifyTransaction(tx, options);
|
14070
14168
|
}
|
14071
14169
|
|
14072
14170
|
setRegularKey(regularKey, memos = null, options = {}) {
|
@@ -14530,6 +14628,13 @@ class XrplApi {
|
|
14530
14628
|
return [];
|
14531
14629
|
}
|
14532
14630
|
|
14631
|
+
async getNamespaceEntries(address, namespaceId, options) {
|
14632
|
+
const resp = (await this.#client.request({ command: 'account_namespace', account: address, namespace_id: namespaceId, ...options }));
|
14633
|
+
if (resp?.result?.namespace_entries)
|
14634
|
+
return resp.result.namespace_entries;
|
14635
|
+
return [];
|
14636
|
+
}
|
14637
|
+
|
14533
14638
|
async getNftOffers(address, options) {
|
14534
14639
|
const offers = await this.getAccountObjects(address, options);
|
14535
14640
|
// TODO: Pass rippled filter parameter when xrpl.js supports it.
|