@bithomp/xrpl-api 2.6.6 → 2.6.7
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/lib/ledger/account_objects.d.ts +3 -3
- package/lib/ledger/account_offers.d.ts +6 -1
- package/lib/ledger/account_offers.js +63 -1
- package/lib/models/account_object.d.ts +1 -1
- package/lib/parse/ledger/account-order.d.ts +8 -0
- package/lib/parse/outcome.js +4 -4
- package/lib/v1/common/types/commands/account_objects.d.ts +1 -1
- package/lib/v1/common/types/commands/account_offers.d.ts +5 -13
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountObjectType,
|
|
1
|
+
import { AccountObjectType, AccountObjects, AccountNFTObjectsResponse, AccountURITokensObjectsResponse } from "../models/account_object";
|
|
2
2
|
import { AccountLinesResponse } from "../models/account_lines";
|
|
3
3
|
import { ErrorResponse } from "../models/base_model";
|
|
4
4
|
import { LedgerIndex } from "../models/ledger";
|
|
@@ -9,11 +9,11 @@ export interface GetAccountObjectsOptions {
|
|
|
9
9
|
limit?: number;
|
|
10
10
|
marker?: string;
|
|
11
11
|
}
|
|
12
|
-
export declare function getAccountObjects(account: string, options?: GetAccountObjectsOptions): Promise<
|
|
12
|
+
export declare function getAccountObjects(account: string, options?: GetAccountObjectsOptions): Promise<AccountObjects | ErrorResponse>;
|
|
13
13
|
export interface GetAccountAllObjectsOptions extends GetAccountObjectsOptions {
|
|
14
14
|
timeout?: number;
|
|
15
15
|
}
|
|
16
|
-
export declare function getAccountAllObjects(account: string, options?: GetAccountAllObjectsOptions): Promise<
|
|
16
|
+
export declare function getAccountAllObjects(account: string, options?: GetAccountAllObjectsOptions): Promise<AccountObjects | ErrorResponse>;
|
|
17
17
|
export interface GetAccountLinesObjectsOptions {
|
|
18
18
|
ledgerHash?: string;
|
|
19
19
|
ledgerIndex?: LedgerIndex;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { LedgerIndex } from "../models/ledger";
|
|
2
2
|
import { ErrorResponse } from "../models/base_model";
|
|
3
|
+
import { FormattedAccountOrders } from "../parse/ledger/account-order";
|
|
4
|
+
import { AccountOffers } from "../v1/common/types/commands/account_offers";
|
|
3
5
|
export interface GetAccountOffers {
|
|
4
6
|
ledgerIndex?: LedgerIndex;
|
|
5
7
|
limit?: number;
|
|
6
8
|
marker?: any;
|
|
9
|
+
legacy?: boolean;
|
|
10
|
+
formatted?: boolean;
|
|
7
11
|
}
|
|
8
|
-
export declare function getAccountOffers(account: string, options?: GetAccountOffers): Promise<
|
|
12
|
+
export declare function getAccountOffers(account: string, options?: GetAccountOffers): Promise<AccountOffers | FormattedAccountOrders | ErrorResponse>;
|
|
13
|
+
export declare function getAccountAllOffers(account: string, options?: GetAccountOffers): Promise<AccountOffers | FormattedAccountOrders | ErrorResponse>;
|
|
@@ -22,11 +22,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
25
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getAccountOffers = void 0;
|
|
29
|
+
exports.getAccountAllOffers = exports.getAccountOffers = void 0;
|
|
30
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
27
31
|
const Client = __importStar(require("../client"));
|
|
28
32
|
const utils_1 = require("../common/utils");
|
|
33
|
+
const account_order_1 = require("../parse/ledger/account-order");
|
|
34
|
+
const OFFERS_LIMIT_MAX = 400;
|
|
29
35
|
async function getAccountOffers(account, options = {}) {
|
|
36
|
+
const formatted = options.legacy === true || options.formatted === true;
|
|
30
37
|
const { hash, marker } = (0, utils_1.parseMarker)(options.marker);
|
|
31
38
|
options.marker = marker;
|
|
32
39
|
const connection = Client.findConnection(undefined, undefined, undefined, hash);
|
|
@@ -62,6 +69,61 @@ async function getAccountOffers(account, options = {}) {
|
|
|
62
69
|
if (newMarker) {
|
|
63
70
|
result.marker = newMarker;
|
|
64
71
|
}
|
|
72
|
+
if (formatted === true) {
|
|
73
|
+
result.offers = formatResponse(account, result.offers);
|
|
74
|
+
}
|
|
65
75
|
return result;
|
|
66
76
|
}
|
|
67
77
|
exports.getAccountOffers = getAccountOffers;
|
|
78
|
+
async function getAccountAllOffers(account, options = {}) {
|
|
79
|
+
const limit = options.limit;
|
|
80
|
+
let response;
|
|
81
|
+
const accountOffers = [];
|
|
82
|
+
while (true) {
|
|
83
|
+
if (options.limit && limit) {
|
|
84
|
+
const left = limit - accountOffers.length;
|
|
85
|
+
const parts = Math.floor(left / OFFERS_LIMIT_MAX);
|
|
86
|
+
if (parts === 0) {
|
|
87
|
+
options.limit = left;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
options.limit = left;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
response = await getAccountOffers(account, options);
|
|
94
|
+
if (response.error) {
|
|
95
|
+
return response;
|
|
96
|
+
}
|
|
97
|
+
accountOffers.push(...response.offers);
|
|
98
|
+
if (limit && accountOffers.length >= limit) {
|
|
99
|
+
response.limit = accountOffers.length;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
if (response.marker) {
|
|
103
|
+
options.marker = response.marker;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (response.error) {
|
|
110
|
+
const { error, error_code, error_message, status, validated } = response;
|
|
111
|
+
return {
|
|
112
|
+
account,
|
|
113
|
+
error,
|
|
114
|
+
error_code,
|
|
115
|
+
error_message,
|
|
116
|
+
status,
|
|
117
|
+
validated,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
response.offers = accountOffers;
|
|
121
|
+
return response;
|
|
122
|
+
}
|
|
123
|
+
exports.getAccountAllOffers = getAccountAllOffers;
|
|
124
|
+
function formatResponse(address, offers) {
|
|
125
|
+
const orders = offers.map((offer) => {
|
|
126
|
+
return (0, account_order_1.parseAccountOrder)(address, offer);
|
|
127
|
+
});
|
|
128
|
+
return lodash_1.default.sortBy(orders, (order) => order.properties.sequence);
|
|
129
|
+
}
|
|
@@ -3,7 +3,7 @@ import { Trustline } from "./account_lines";
|
|
|
3
3
|
import { Amount } from "../v1/common/types/objects";
|
|
4
4
|
export type AccountObject = LedgerEntry.Check | LedgerEntry.DepositPreauth | LedgerEntry.Escrow | LedgerEntry.Offer | LedgerEntry.PayChannel | LedgerEntry.SignerList | LedgerEntry.Ticket | LedgerEntry.RippleState;
|
|
5
5
|
export type AccountObjectType = "check" | "escrow" | "offer" | "payment_channel" | "signer_list" | "state" | "ticket" | "nft_offer";
|
|
6
|
-
export interface
|
|
6
|
+
export interface AccountObjects {
|
|
7
7
|
account: string;
|
|
8
8
|
account_objects: AccountObject[];
|
|
9
9
|
ledger_hash?: string;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { FormattedOfferCreateSpecification } from "../../v1/common/types/objects";
|
|
2
|
+
export type FormattedAccountOrders = {
|
|
3
|
+
account: string;
|
|
4
|
+
offers?: FormattedAccountOrder[];
|
|
5
|
+
ledger_current_index?: number;
|
|
6
|
+
ledger_index?: number;
|
|
7
|
+
ledger_hash?: string;
|
|
8
|
+
marker?: unknown;
|
|
9
|
+
};
|
|
2
10
|
export type FormattedAccountOrder = {
|
|
3
11
|
specification: FormattedOfferCreateSpecification;
|
|
4
12
|
properties: {
|
package/lib/parse/outcome.js
CHANGED
|
@@ -84,11 +84,11 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
84
84
|
timestamp: (0, utils_1.parseTimestamp)(tx.date),
|
|
85
85
|
fee: (0, common_1.dropsToXrp)(tx.Fee),
|
|
86
86
|
balanceChanges,
|
|
87
|
-
lockedBalanceChanges,
|
|
88
|
-
orderbookChanges,
|
|
87
|
+
lockedBalanceChanges: Object.keys(lockedBalanceChanges).length > 0 ? lockedBalanceChanges : undefined,
|
|
88
|
+
orderbookChanges: Object.keys(orderbookChanges).length > 0 ? orderbookChanges : undefined,
|
|
89
89
|
channelChanges,
|
|
90
|
-
nftokenChanges,
|
|
91
|
-
nftokenOfferChanges,
|
|
90
|
+
nftokenChanges: Object.keys(nftokenChanges).length > 0 ? nftokenChanges : undefined,
|
|
91
|
+
nftokenOfferChanges: Object.keys(nftokenOfferChanges).length > 0 ? nftokenOfferChanges : undefined,
|
|
92
92
|
uritokenChanges: Object.keys(uritokenChanges).length > 0 ? uritokenChanges : undefined,
|
|
93
93
|
uritokenSellOfferChanges: Object.keys(uritokenSellOfferChanges).length > 0 ? uritokenSellOfferChanges : undefined,
|
|
94
94
|
affectedObjects: affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined,
|
|
@@ -14,7 +14,7 @@ export interface AccountObjectsRequest {
|
|
|
14
14
|
limit?: number;
|
|
15
15
|
marker?: string;
|
|
16
16
|
}
|
|
17
|
-
export interface
|
|
17
|
+
export interface AccountObjects {
|
|
18
18
|
account: string;
|
|
19
19
|
account_objects: Array<CheckLedgerEntry | RippleStateLedgerEntry | OfferLedgerEntry | SignerListLedgerEntry | EscrowLedgerEntry | PayChannelLedgerEntry | DepositPreauthLedgerEntry>;
|
|
20
20
|
ledger_hash?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AccountOffer } from "xrpl";
|
|
2
2
|
export interface AccountOffersRequest {
|
|
3
3
|
account: string;
|
|
4
4
|
ledger_hash?: string;
|
|
@@ -6,19 +6,11 @@ export interface AccountOffersRequest {
|
|
|
6
6
|
limit?: number;
|
|
7
7
|
marker?: any;
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface AccountOffers {
|
|
10
10
|
account: string;
|
|
11
|
-
|
|
11
|
+
offers?: AccountOffer[];
|
|
12
12
|
ledger_current_index?: number;
|
|
13
13
|
ledger_index?: number;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
export interface AccountOffer {
|
|
18
|
-
seq: number;
|
|
19
|
-
flags: number;
|
|
20
|
-
taker_gets: Amount;
|
|
21
|
-
taker_pays: Amount;
|
|
22
|
-
quality: string;
|
|
23
|
-
expiration?: number;
|
|
14
|
+
ledger_hash?: string;
|
|
15
|
+
marker?: unknown;
|
|
24
16
|
}
|