evernode-js-client 0.5.1 → 0.5.2
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.
- package/index.js +74 -54
- package/package.json +1 -1
package/index.js
CHANGED
@@ -12804,41 +12804,47 @@ class TenantClient extends BaseEvernodeClient {
|
|
12804
12804
|
* @returns An object including transaction details,instance info, and acquireReference Id.
|
12805
12805
|
*/
|
12806
12806
|
async watchAcquireResponse(tx, options = {}) {
|
12807
|
-
|
12807
|
+
console.log(`Waiting for acquire response... (txHash: ${tx.id})`);
|
12808
12808
|
|
12809
|
+
return new Promise(async (resolve, reject) => {
|
12810
|
+
let rejected = false;
|
12809
12811
|
const failTimeout = setTimeout(() => {
|
12810
|
-
|
12812
|
+
rejected = true;
|
12813
|
+
reject({ error: ErrorCodes.ACQUIRE_ERR, reason: ErrorReasons.TIMEOUT });
|
12811
12814
|
}, options.timeout || DEFAULT_WAIT_TIMEOUT);
|
12812
|
-
|
12815
|
+
|
12813
12816
|
let relevantTx = null;
|
12814
|
-
while (!relevantTx) {
|
12817
|
+
while (!rejected && !relevantTx) {
|
12815
12818
|
const txList = await this.xrplAcc.getAccountTrx(tx.details.ledger_index);
|
12816
12819
|
for (let t of txList) {
|
12817
12820
|
t.tx.Memos = TransactionHelper.deserializeMemos(t.tx?.Memos);
|
12818
|
-
|
12819
|
-
|
12820
|
-
|
12821
|
-
|
12822
|
-
|
12823
|
-
|
12821
|
+
const res = await this.extractEvernodeEvent(t.tx);
|
12822
|
+
if ((res?.name === EvernodeEvents.AcquireSuccess || res?.name === EvernodeEvents.AcquireError) && res?.data?.acquireRefId === tx.id) {
|
12823
|
+
clearTimeout(failTimeout);
|
12824
|
+
relevantTx = res;
|
12825
|
+
break;
|
12826
|
+
}
|
12824
12827
|
}
|
12825
|
-
await new Promise(
|
12828
|
+
await new Promise(resolveSleep => setTimeout(resolveSleep, 2000));
|
12826
12829
|
}
|
12827
|
-
|
12828
|
-
if (
|
12829
|
-
|
12830
|
-
|
12831
|
-
|
12832
|
-
|
12833
|
-
|
12834
|
-
|
12835
|
-
|
12836
|
-
|
12837
|
-
|
12838
|
-
|
12839
|
-
|
12840
|
-
|
12830
|
+
|
12831
|
+
if (!rejected) {
|
12832
|
+
if (relevantTx?.name === TenantEvents.AcquireSuccess) {
|
12833
|
+
resolve({
|
12834
|
+
transaction: relevantTx?.data.transaction,
|
12835
|
+
instance: relevantTx?.data.payload.content,
|
12836
|
+
acquireRefId: relevantTx?.data.acquireRefId
|
12837
|
+
});
|
12838
|
+
} else if (relevantTx?.name === TenantEvents.AcquireError) {
|
12839
|
+
reject({
|
12840
|
+
error: ErrorCodes.ACQUIRE_ERR,
|
12841
|
+
transaction: relevantTx?.data.transaction,
|
12842
|
+
reason: relevantTx?.data.reason,
|
12843
|
+
acquireRefId: relevantTx?.data.acquireRefId
|
12844
|
+
});
|
12845
|
+
}
|
12841
12846
|
}
|
12847
|
+
});
|
12842
12848
|
}
|
12843
12849
|
|
12844
12850
|
/**
|
@@ -12887,38 +12893,44 @@ class TenantClient extends BaseEvernodeClient {
|
|
12887
12893
|
async watchExtendResponse(tx, options = {}) {
|
12888
12894
|
console.log(`Waiting for extend lease response... (txHash: ${tx.id})`);
|
12889
12895
|
|
12890
|
-
|
12891
|
-
|
12892
|
-
|
12893
|
-
|
12894
|
-
|
12895
|
-
|
12896
|
-
|
12897
|
-
|
12898
|
-
|
12899
|
-
const
|
12900
|
-
|
12901
|
-
|
12902
|
-
|
12903
|
-
|
12896
|
+
return new Promise(async (resolve, reject) => {
|
12897
|
+
let rejected = false;
|
12898
|
+
const failTimeout = setTimeout(() => {
|
12899
|
+
rejected = true;
|
12900
|
+
reject({ error: ErrorCodes.EXTEND_ERR, reason: ErrorReasons.TIMEOUT });
|
12901
|
+
}, options.timeout || DEFAULT_WAIT_TIMEOUT);
|
12902
|
+
|
12903
|
+
let relevantTx = null;
|
12904
|
+
while (!rejected && !relevantTx) {
|
12905
|
+
const txList = await this.xrplAcc.getAccountTrx(tx.details.ledger_index);
|
12906
|
+
for (let t of txList) {
|
12907
|
+
t.tx.Memos = TransactionHelper.deserializeMemos(t.tx.Memos);
|
12908
|
+
const res = await this.extractEvernodeEvent(t.tx);
|
12909
|
+
if ((res?.name === TenantEvents.ExtendSuccess || res?.name === TenantEvents.ExtendError) && res?.data?.extendRefId === tx.id) {
|
12910
|
+
clearTimeout(failTimeout);
|
12911
|
+
relevantTx = res;
|
12912
|
+
break;
|
12913
|
+
}
|
12904
12914
|
}
|
12915
|
+
await new Promise(resolveSleep => setTimeout(resolveSleep, 1000));
|
12905
12916
|
}
|
12906
|
-
await new Promise(resolve => setTimeout(resolve, 1000));
|
12907
|
-
}
|
12908
12917
|
|
12909
|
-
|
12910
|
-
|
12911
|
-
|
12912
|
-
|
12913
|
-
|
12914
|
-
|
12915
|
-
|
12916
|
-
|
12917
|
-
|
12918
|
-
|
12919
|
-
|
12920
|
-
|
12921
|
-
|
12918
|
+
if (!rejected) {
|
12919
|
+
if (relevantTx?.name === TenantEvents.ExtendSuccess) {
|
12920
|
+
resolve({
|
12921
|
+
transaction: relevantTx?.data.transaction,
|
12922
|
+
expiryMoment: relevantTx?.data.expiryMoment,
|
12923
|
+
extendeRefId: relevantTx?.data.extendRefId
|
12924
|
+
});
|
12925
|
+
} else if (relevantTx?.name === TenantEvents.ExtendError) {
|
12926
|
+
reject({
|
12927
|
+
error: ErrorCodes.EXTEND_ERR,
|
12928
|
+
transaction: relevantTx?.data.transaction,
|
12929
|
+
reason: relevantTx?.data.reason
|
12930
|
+
});
|
12931
|
+
}
|
12932
|
+
}
|
12933
|
+
});
|
12922
12934
|
}
|
12923
12935
|
|
12924
12936
|
/**
|
@@ -15110,6 +15122,14 @@ class XrplApi {
|
|
15110
15122
|
return this.#requestWithPaging({ command: 'account_offers', account: address, ledger_index: "validated", ...options }, API_REQ_TYPE.OFFERS);
|
15111
15123
|
}
|
15112
15124
|
|
15125
|
+
async getSellOffers(nfTokenId, options = {}) {
|
15126
|
+
return this.#requestWithPaging({ command: 'nft_sell_offers', nft_id: nfTokenId, ledger_index: "validated", ...options }, API_REQ_TYPE.OFFERS);
|
15127
|
+
}
|
15128
|
+
|
15129
|
+
async getBuyOffers(nfTokenId, options = {}) {
|
15130
|
+
return this.#requestWithPaging({ command: 'nft_buy_offers', nft_id: nfTokenId, ledger_index: "validated", ...options }, API_REQ_TYPE.OFFERS);
|
15131
|
+
}
|
15132
|
+
|
15113
15133
|
async getLedgerEntry(index, options) {
|
15114
15134
|
const resp = (await this.#client.request({ command: 'ledger_entry', index: index, ledger_index: "validated", ...options }));
|
15115
15135
|
return resp?.result?.node;
|