@bithomp/xrpl-api 3.2.8 → 3.2.9
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_lines.d.ts +1 -1
- package/lib/ledger/account_lines.js +11 -2
- package/lib/ledger/currency.d.ts +1 -0
- package/lib/ledger/currency.js +4 -2
- package/lib/models/book_offers.d.ts +3 -3
- package/lib/models/book_offers.js +1 -1
- package/lib/parse/ledger/amount.d.ts +2 -2
- package/lib/parse/ledger/amount.js +1 -0
- package/lib/parse/ledger/asset.d.ts +1 -1
- package/lib/parse/ledger/asset.js +1 -0
- package/lib/parse/ledger/gateway-balances.js +4 -4
- package/lib/parse/ledger/ledger.js +12 -8
- package/lib/parse/outcome/amm_changes.js +4 -2
- package/lib/parse/outcome/balance_changes.d.ts +2 -1
- package/lib/parse/outcome/balance_changes.js +5 -3
- package/lib/parse/outcome/locked_balance_changes.d.ts +2 -1
- package/lib/parse/outcome/locked_balance_changes.js +2 -1
- package/lib/parse/outcome.js +3 -2
- package/lib/parse/specification/payment-channel-claim.js +3 -3
- package/lib/parse/specification/payment-channel-create.js +2 -2
- package/lib/parse/specification/payment-channel-fund.js +2 -2
- package/lib/parse/utils.d.ts +2 -2
- package/lib/parse/utils.js +3 -0
- package/lib/types/adjustments.d.ts +4 -4
- package/lib/types/amounts.d.ts +1 -1
- package/lib/types/gateway_balances.d.ts +3 -3
- package/lib/types/ledger.d.ts +1 -0
- package/lib/types/outcome.d.ts +1 -0
- package/lib/v1/transaction/payment.js +14 -2
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@ import { LedgerIndex } from "../models/ledger";
|
|
|
2
2
|
import { AccountLinesResponse } from "../models/account_lines";
|
|
3
3
|
import { ErrorResponse } from "../models/base_model";
|
|
4
4
|
export interface GetAccountLinesOptions {
|
|
5
|
-
|
|
5
|
+
issuer?: string;
|
|
6
6
|
currency?: string;
|
|
7
7
|
ledgerIndex?: LedgerIndex;
|
|
8
8
|
limit?: number;
|
|
@@ -46,8 +46,6 @@ async function getAccountLines(account, options = {}) {
|
|
|
46
46
|
const response = await connection.request({
|
|
47
47
|
command: "account_lines",
|
|
48
48
|
account,
|
|
49
|
-
counterparty: options.counterparty,
|
|
50
|
-
currency: options.currency,
|
|
51
49
|
ledger_index: options.ledgerIndex || "validated",
|
|
52
50
|
limit: options.limit,
|
|
53
51
|
marker: options.marker,
|
|
@@ -71,6 +69,17 @@ async function getAccountLines(account, options = {}) {
|
|
|
71
69
|
};
|
|
72
70
|
}
|
|
73
71
|
const result = response.result;
|
|
72
|
+
if (options.currency || options.issuer) {
|
|
73
|
+
result.lines = result.lines.filter((line) => {
|
|
74
|
+
if (options.currency && line.currency !== options.currency) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
if (options.issuer && line.account !== options.issuer) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return true;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
74
83
|
const newMarker = (0, utils_1.createMarker)(connection.hash, result.marker);
|
|
75
84
|
if (newMarker) {
|
|
76
85
|
result.marker = newMarker;
|
package/lib/ledger/currency.d.ts
CHANGED
package/lib/ledger/currency.js
CHANGED
|
@@ -38,6 +38,7 @@ const Client = __importStar(require("../client"));
|
|
|
38
38
|
const utils_1 = require("../parse/utils");
|
|
39
39
|
const transaction_1 = require("../parse/transaction");
|
|
40
40
|
const client_1 = require("../client");
|
|
41
|
+
const common_1 = require("../common");
|
|
41
42
|
const maxLength = 12;
|
|
42
43
|
async function parseCurrencyInformation(currency) {
|
|
43
44
|
if (!currency || typeof currency !== "string") {
|
|
@@ -90,14 +91,15 @@ async function decodeXlf15d(currencyCode) {
|
|
|
90
91
|
if (transaction.metaData.TransactionIndex === ctiTxIndex) {
|
|
91
92
|
const { Account: account, Destination: destination, LimitAmount: limit, Memos: memos, hash: hash, } = transaction;
|
|
92
93
|
const type = (0, transaction_1.parseTransactionType)(transaction.TransactionType);
|
|
93
|
-
ctiTx = {
|
|
94
|
+
ctiTx = (0, common_1.removeUndefined)({
|
|
94
95
|
type,
|
|
95
96
|
account,
|
|
96
97
|
destination,
|
|
98
|
+
issuer: limit?.issuer,
|
|
97
99
|
counterparty: limit?.issuer,
|
|
98
100
|
hash,
|
|
99
101
|
memos,
|
|
100
|
-
};
|
|
102
|
+
});
|
|
101
103
|
break;
|
|
102
104
|
}
|
|
103
105
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FormattedIssuedCurrency } from "../types";
|
|
1
|
+
import { IssuedCurrency, FormattedIssuedCurrency } from "../types";
|
|
2
2
|
export type OrderbookInfo = {
|
|
3
|
-
base: FormattedIssuedCurrency;
|
|
4
|
-
counter: FormattedIssuedCurrency;
|
|
3
|
+
base: IssuedCurrency | FormattedIssuedCurrency;
|
|
4
|
+
counter: IssuedCurrency | FormattedIssuedCurrency;
|
|
5
5
|
};
|
|
6
6
|
export declare function formatBidsAndAsks(orderbook: OrderbookInfo, offers: any[]): {
|
|
7
7
|
bids: any[];
|
|
@@ -8,7 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
9
|
const orderbook_order_1 = require("../parse/ledger/orderbook-order");
|
|
10
10
|
function isSameIssue(a, b) {
|
|
11
|
-
return a.currency === b.currency && a.
|
|
11
|
+
return a.currency === b.currency && a.issuer === b.issuer;
|
|
12
12
|
}
|
|
13
13
|
function directionFilter(direction, order) {
|
|
14
14
|
return order.specification.direction === direction;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount, Amount } from "../../types";
|
|
2
|
-
declare function parseAmount(amount: Amount): FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
1
|
+
import { IssuedCurrencyAmount, FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount, Amount } from "../../types";
|
|
2
|
+
declare function parseAmount(amount: Amount): IssuedCurrencyAmount | FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
3
3
|
export default parseAmount;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { FormattedIssuedCurrency, IssuedCurrency } from "../../types";
|
|
2
|
-
declare function parseAsset(asset: IssuedCurrency): FormattedIssuedCurrency | undefined;
|
|
2
|
+
declare function parseAsset(asset: IssuedCurrency): IssuedCurrency | FormattedIssuedCurrency | undefined;
|
|
3
3
|
export default parseAsset;
|
|
@@ -5,22 +5,22 @@ function parseGatewayBalances(balanceSheet) {
|
|
|
5
5
|
const result = {};
|
|
6
6
|
if (typeof balanceSheet.balances === "object") {
|
|
7
7
|
Object.entries(balanceSheet.balances).forEach((entry) => {
|
|
8
|
-
const [
|
|
8
|
+
const [issuer, balances] = entry;
|
|
9
9
|
balances.forEach((balance) => {
|
|
10
10
|
if (!result.balances) {
|
|
11
11
|
result.balances = [];
|
|
12
12
|
}
|
|
13
|
-
result.balances.push(Object.assign({ counterparty }, balance));
|
|
13
|
+
result.balances.push(Object.assign({ issuer, counterparty: issuer }, balance));
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
if (typeof balanceSheet.assets === "object") {
|
|
18
|
-
Object.entries(balanceSheet.assets).forEach(([
|
|
18
|
+
Object.entries(balanceSheet.assets).forEach(([issuer, assets]) => {
|
|
19
19
|
assets.forEach((balance) => {
|
|
20
20
|
if (!result.assets) {
|
|
21
21
|
result.assets = [];
|
|
22
22
|
}
|
|
23
|
-
result.assets.push(Object.assign({ counterparty }, balance));
|
|
23
|
+
result.assets.push(Object.assign({ issuer, counterparty: issuer }, balance));
|
|
24
24
|
});
|
|
25
25
|
});
|
|
26
26
|
}
|
|
@@ -8,21 +8,24 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const common_1 = require("../../common");
|
|
9
9
|
const models_1 = require("../../models");
|
|
10
10
|
const transaction_1 = require("../transaction");
|
|
11
|
-
function parseTransactionWrapper(
|
|
11
|
+
function parseTransactionWrapper(ledgerIndex, includeRawTransaction, tx) {
|
|
12
12
|
const transaction = Object.assign({}, lodash_1.default.omit(tx, "metaData"), {
|
|
13
13
|
meta: tx.metaData,
|
|
14
|
-
ledger_index:
|
|
14
|
+
ledger_index: ledgerIndex,
|
|
15
15
|
});
|
|
16
16
|
const result = (0, transaction_1.parseTransaction)(transaction, includeRawTransaction);
|
|
17
17
|
if (!result.outcome) {
|
|
18
18
|
result.outcome = {};
|
|
19
19
|
}
|
|
20
|
+
if (!result.outcome.ledgerIndex) {
|
|
21
|
+
result.outcome.ledgerIndex = ledgerIndex;
|
|
22
|
+
}
|
|
20
23
|
if (!result.outcome.ledgerVersion) {
|
|
21
|
-
result.outcome.ledgerVersion =
|
|
24
|
+
result.outcome.ledgerVersion = ledgerIndex;
|
|
22
25
|
}
|
|
23
26
|
return result;
|
|
24
27
|
}
|
|
25
|
-
function parseTransactions(transactions,
|
|
28
|
+
function parseTransactions(transactions, ledgerIndex, includeRawTransactions) {
|
|
26
29
|
if (lodash_1.default.isEmpty(transactions)) {
|
|
27
30
|
return {};
|
|
28
31
|
}
|
|
@@ -30,7 +33,7 @@ function parseTransactions(transactions, ledgerVersion, includeRawTransactions)
|
|
|
30
33
|
return { transactionHashes: transactions };
|
|
31
34
|
}
|
|
32
35
|
return {
|
|
33
|
-
transactions: transactions.map(lodash_1.default.partial(parseTransactionWrapper,
|
|
36
|
+
transactions: transactions.map(lodash_1.default.partial(parseTransactionWrapper, ledgerIndex, includeRawTransactions)),
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
function parseState(state) {
|
|
@@ -43,7 +46,7 @@ function parseState(state) {
|
|
|
43
46
|
return { rawState: JSON.stringify(state) };
|
|
44
47
|
}
|
|
45
48
|
function parseLedger(ledger, includeRawTransactions) {
|
|
46
|
-
const
|
|
49
|
+
const ledgerIndex = parseInt(ledger.ledger_index, 10);
|
|
47
50
|
return (0, common_1.removeUndefined)(Object.assign({
|
|
48
51
|
stateHash: ledger.account_hash,
|
|
49
52
|
close_time: (0, models_1.ledgerTimeToUnixTime)(ledger.close_time),
|
|
@@ -51,10 +54,11 @@ function parseLedger(ledger, includeRawTransactions) {
|
|
|
51
54
|
closeTimeResolution: ledger.close_time_resolution,
|
|
52
55
|
closeFlags: ledger.close_flags,
|
|
53
56
|
ledgerHash: ledger.ledger_hash,
|
|
54
|
-
|
|
57
|
+
ledgerIndex: ledgerIndex,
|
|
58
|
+
ledgerVersion: ledgerIndex,
|
|
55
59
|
parentLedgerHash: ledger.parent_hash,
|
|
56
60
|
parentCloseTime: (0, models_1.ledgerTimeToISO8601)(ledger.parent_close_time),
|
|
57
61
|
totalDrops: ledger.total_coins,
|
|
58
62
|
transactionHash: ledger.transaction_hash,
|
|
59
|
-
}, parseTransactions(ledger.transactions,
|
|
63
|
+
}, parseTransactions(ledger.transactions, ledgerIndex, includeRawTransactions), parseState(ledger.accountState)));
|
|
60
64
|
}
|
|
@@ -104,10 +104,11 @@ function summarizeActionSlotChanges(node) {
|
|
|
104
104
|
if (final.AuctionSlot.Price.value !== prev.AuctionSlot.Price.value) {
|
|
105
105
|
changes.priceChange = {
|
|
106
106
|
currency: final.AuctionSlot.Price.currency,
|
|
107
|
-
|
|
107
|
+
issuer: final.AuctionSlot.Price.issuer,
|
|
108
108
|
value: new bignumber_js_1.default(final.AuctionSlot.Price.value)
|
|
109
109
|
.minus(new bignumber_js_1.default(prev.AuctionSlot.Price.value))
|
|
110
110
|
.toString(10),
|
|
111
|
+
counterparty: final.AuctionSlot.Price.issuer,
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
if (final.AuctionSlot.TimeInterval !== prev.AuctionSlot.TimeInterval) {
|
|
@@ -184,8 +185,9 @@ function summarizeAmm(node) {
|
|
|
184
185
|
if (prev.LPTokenBalance) {
|
|
185
186
|
summary.lpTokenBalanceChange = {
|
|
186
187
|
currency: final.LPTokenBalance.currency,
|
|
187
|
-
|
|
188
|
+
issuer: final.LPTokenBalance.issuer,
|
|
188
189
|
value: new bignumber_js_1.default(final.LPTokenBalance.value).minus(new bignumber_js_1.default(prev.LPTokenBalance.value)).toString(10),
|
|
190
|
+
counterparty: final.LPTokenBalance.issuer,
|
|
189
191
|
};
|
|
190
192
|
}
|
|
191
193
|
if (prev.VoteSlots) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TransactionMetadata } from "xrpl";
|
|
2
2
|
interface BalanceChangeQuantity {
|
|
3
|
-
|
|
3
|
+
issuer?: string;
|
|
4
4
|
currency?: string;
|
|
5
5
|
value: string;
|
|
6
|
+
counterparty?: string;
|
|
6
7
|
mpt_issuance_id?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface AddressBalanceChangeQuantity {
|
|
@@ -73,11 +73,12 @@ function parseXRPQuantity(node, valueParser, nativeCurrency) {
|
|
|
73
73
|
function flipTrustlinePerspective(quantity) {
|
|
74
74
|
const negatedBalance = new bignumber_js_1.default(quantity.balance.value).negated();
|
|
75
75
|
return {
|
|
76
|
-
address: quantity.balance.
|
|
76
|
+
address: quantity.balance.issuer,
|
|
77
77
|
balance: {
|
|
78
|
-
|
|
78
|
+
issuer: quantity.address,
|
|
79
79
|
currency: quantity.balance.currency,
|
|
80
80
|
value: negatedBalance.toString(),
|
|
81
|
+
counterparty: quantity.address,
|
|
81
82
|
},
|
|
82
83
|
};
|
|
83
84
|
}
|
|
@@ -90,9 +91,10 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
90
91
|
const result = {
|
|
91
92
|
address: fields.LowLimit.issuer,
|
|
92
93
|
balance: {
|
|
93
|
-
|
|
94
|
+
issuer: fields.HighLimit.issuer,
|
|
94
95
|
currency: fields.Balance.currency,
|
|
95
96
|
value: value.toString(),
|
|
97
|
+
counterparty: fields.HighLimit.issuer,
|
|
96
98
|
},
|
|
97
99
|
};
|
|
98
100
|
return [result, flipTrustlinePerspective(result)];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { TransactionMetadata } from "xrpl";
|
|
2
2
|
interface LockedBalanceChangeQuantity {
|
|
3
|
-
|
|
3
|
+
issuer: string;
|
|
4
4
|
currency: string;
|
|
5
5
|
value: string;
|
|
6
|
+
counterparty: string;
|
|
6
7
|
}
|
|
7
8
|
export interface AddressLockedBalanceChangeQuantity {
|
|
8
9
|
address: string;
|
|
@@ -53,9 +53,10 @@ function parseTrustlineQuantity(node, valueParser) {
|
|
|
53
53
|
const result = {
|
|
54
54
|
address: fields.LowLimit.issuer,
|
|
55
55
|
lockedBalance: {
|
|
56
|
-
|
|
56
|
+
issuer: LockedBalanceFields.LockedBalance.issuer,
|
|
57
57
|
currency: LockedBalanceFields.LockedBalance.currency,
|
|
58
58
|
value: value.toString(),
|
|
59
|
+
counterparty: LockedBalanceFields.LockedBalance.issuer,
|
|
59
60
|
},
|
|
60
61
|
};
|
|
61
62
|
return [result];
|
package/lib/parse/outcome.js
CHANGED
|
@@ -31,7 +31,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
31
31
|
result: tx.meta.TransactionResult,
|
|
32
32
|
timestamp: (0, utils_1.parseTimestamp)(tx.date),
|
|
33
33
|
fee: (0, common_1.dropsToXrp)(tx.Fee),
|
|
34
|
-
balanceChanges,
|
|
34
|
+
balanceChanges: Object.keys(balanceChanges).length > 0 ? balanceChanges : undefined,
|
|
35
35
|
lockedBalanceChanges: Object.keys(lockedBalanceChanges).length > 0 ? lockedBalanceChanges : undefined,
|
|
36
36
|
orderbookChanges: Object.keys(orderbookChanges).length > 0 ? orderbookChanges : undefined,
|
|
37
37
|
channelChanges,
|
|
@@ -49,7 +49,8 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
49
49
|
unlReportChanges,
|
|
50
50
|
hooksExecutions,
|
|
51
51
|
emittedTxns,
|
|
52
|
-
|
|
52
|
+
ledgerIndex: tx.ledger_index || tx.inLedger,
|
|
53
|
+
ledgerVersion: tx.ledger_index || tx.inLedger,
|
|
53
54
|
indexInLedger: tx.meta.TransactionIndex,
|
|
54
55
|
deliveredAmount: (0, index_1.parseDeliveredAmount)(tx),
|
|
55
56
|
});
|
|
@@ -39,15 +39,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const assert = __importStar(require("assert"));
|
|
40
40
|
const xrpl_1 = require("xrpl");
|
|
41
41
|
const common_1 = require("../../common");
|
|
42
|
-
const
|
|
42
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
43
43
|
const emit_details_1 = require("../ledger/emit_details");
|
|
44
44
|
const memos_1 = require("../ledger/memos");
|
|
45
45
|
function parsePaymentChannelClaim(tx) {
|
|
46
46
|
assert.ok(tx.TransactionType === "PaymentChannelClaim");
|
|
47
47
|
return (0, common_1.removeUndefined)({
|
|
48
48
|
channel: tx.Channel,
|
|
49
|
-
balance: (0,
|
|
50
|
-
amount: (0,
|
|
49
|
+
balance: (0, amount_1.default)(tx.Balance),
|
|
50
|
+
amount: (0, amount_1.default)(tx.Amount),
|
|
51
51
|
signature: tx.Signature,
|
|
52
52
|
publicKey: tx.PublicKey,
|
|
53
53
|
renew: Boolean(tx.Flags & xrpl_1.PaymentChannelClaimFlags.tfRenew) || undefined,
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const assert = __importStar(require("assert"));
|
|
40
40
|
const common_1 = require("../../common");
|
|
41
41
|
const utils_1 = require("../utils");
|
|
42
|
-
const
|
|
42
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
43
43
|
const emit_details_1 = require("../ledger/emit_details");
|
|
44
44
|
const memos_1 = require("../ledger/memos");
|
|
45
45
|
const account_1 = require("../ledger/account");
|
|
@@ -56,7 +56,7 @@ function parsePaymentChannelCreate(tx) {
|
|
|
56
56
|
return (0, common_1.removeUndefined)({
|
|
57
57
|
source: (0, common_1.removeUndefined)(source),
|
|
58
58
|
destination: (0, common_1.removeUndefined)(destination),
|
|
59
|
-
amount: (0,
|
|
59
|
+
amount: (0, amount_1.default)(tx.Amount),
|
|
60
60
|
settleDelay: tx.SettleDelay,
|
|
61
61
|
publicKey: tx.PublicKey,
|
|
62
62
|
cancelAfter: tx.CancelAfter && (0, utils_1.parseTimestamp)(tx.CancelAfter),
|
|
@@ -39,14 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const assert = __importStar(require("assert"));
|
|
40
40
|
const common_1 = require("../../common");
|
|
41
41
|
const utils_1 = require("../utils");
|
|
42
|
-
const
|
|
42
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
43
43
|
const emit_details_1 = require("../ledger/emit_details");
|
|
44
44
|
const memos_1 = require("../ledger/memos");
|
|
45
45
|
function parsePaymentChannelFund(tx) {
|
|
46
46
|
assert.ok(tx.TransactionType === "PaymentChannelFund");
|
|
47
47
|
return (0, common_1.removeUndefined)({
|
|
48
48
|
channel: tx.Channel,
|
|
49
|
-
amount: (0,
|
|
49
|
+
amount: (0, amount_1.default)(tx.Amount),
|
|
50
50
|
expiration: tx.Expiration && (0, utils_1.parseTimestamp)(tx.Expiration),
|
|
51
51
|
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
52
52
|
memos: (0, memos_1.parseMemos)(tx),
|
package/lib/parse/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TransactionMetadata } from "xrpl";
|
|
2
|
-
import { FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount } from "../types";
|
|
2
|
+
import { IssuedCurrencyAmount, FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount } from "../types";
|
|
3
3
|
declare function adjustQualityForXRP(quality: string, takerGetsCurrency: string, takerPaysCurrency: string): string;
|
|
4
4
|
declare function parseQuality(quality?: number | null): number | undefined;
|
|
5
5
|
declare function parseTimestamp(rippleTime?: number | null): string | undefined;
|
|
6
6
|
declare function isPartialPayment(tx: any): boolean;
|
|
7
|
-
declare function removeGenericCounterparty(amount: FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount, address: string): FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
7
|
+
declare function removeGenericCounterparty(amount: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount, address: string): FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
8
8
|
declare function normalizeNodes(metadata: TransactionMetadata): any[];
|
|
9
9
|
declare function hexToString(hex: string | undefined): string | undefined;
|
|
10
10
|
declare function stringToHex(value: string | undefined): string | undefined;
|
package/lib/parse/utils.js
CHANGED
|
@@ -45,6 +45,9 @@ function removeGenericCounterparty(amount, address) {
|
|
|
45
45
|
if ("counterparty" in amount) {
|
|
46
46
|
return amount.counterparty === address ? lodash_1.default.omit(amount, "counterparty") : amount;
|
|
47
47
|
}
|
|
48
|
+
if ("issuer" in amount) {
|
|
49
|
+
return amount.issuer === address ? lodash_1.default.omit(amount, "issuer") : amount;
|
|
50
|
+
}
|
|
48
51
|
return amount;
|
|
49
52
|
}
|
|
50
53
|
function normalizeNode(affectedNode) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { FormattedIssuedCurrencyAmount } from "./amounts";
|
|
1
|
+
import { IssuedCurrencyAmount, FormattedIssuedCurrencyAmount } from "./amounts";
|
|
2
2
|
export type Adjustment = {
|
|
3
3
|
address: string;
|
|
4
|
-
amount: FormattedIssuedCurrencyAmount;
|
|
4
|
+
amount: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount;
|
|
5
5
|
tag?: number;
|
|
6
6
|
};
|
|
7
7
|
export type MaxAdjustment = {
|
|
8
8
|
address: string;
|
|
9
|
-
maxAmount: FormattedIssuedCurrencyAmount;
|
|
9
|
+
maxAmount: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount;
|
|
10
10
|
tag?: number;
|
|
11
11
|
};
|
|
12
12
|
export type MinAdjustment = {
|
|
13
13
|
address: string;
|
|
14
|
-
minAmount: FormattedIssuedCurrencyAmount;
|
|
14
|
+
minAmount: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount;
|
|
15
15
|
tag?: number;
|
|
16
16
|
};
|
package/lib/types/amounts.d.ts
CHANGED
|
@@ -17,4 +17,4 @@ export interface FormattedIssuedMPTAmount {
|
|
|
17
17
|
value: string;
|
|
18
18
|
}
|
|
19
19
|
export type Amount = IssuedCurrencyAmount | FormattedIssuedMPTAmount | string;
|
|
20
|
-
export type FormattedAmount = FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount | string;
|
|
20
|
+
export type FormattedAmount = IssuedCurrency | FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount | string;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { FormattedIssuedCurrency } from "./amounts";
|
|
1
|
+
import { IssuedCurrency, FormattedIssuedCurrency } from "./amounts";
|
|
2
2
|
type FormattedGatewayBalanceObligations = {
|
|
3
3
|
currency: string;
|
|
4
4
|
value: string;
|
|
5
5
|
};
|
|
6
6
|
export type FormattedGatewayBalances = {
|
|
7
|
-
balances?: FormattedIssuedCurrency[];
|
|
8
|
-
assets?: FormattedIssuedCurrency[];
|
|
7
|
+
balances?: IssuedCurrency[] | FormattedIssuedCurrency[];
|
|
8
|
+
assets?: IssuedCurrency[] | FormattedIssuedCurrency[];
|
|
9
9
|
obligations?: FormattedGatewayBalanceObligations[];
|
|
10
10
|
};
|
|
11
11
|
export {};
|
package/lib/types/ledger.d.ts
CHANGED
package/lib/types/outcome.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { LockedBalanceChanges } from "../parse/outcome/locked_balance_changes";
|
|
|
3
3
|
import { BalanceChanges } from "../parse/outcome/balance_changes";
|
|
4
4
|
export type Outcome = {
|
|
5
5
|
result?: string;
|
|
6
|
+
ledgerIndex?: number;
|
|
6
7
|
ledgerVersion?: number;
|
|
7
8
|
indexInLedger?: number;
|
|
8
9
|
fee?: string;
|
|
@@ -26,13 +26,25 @@ function isXRPToXRPPayment(payment) {
|
|
|
26
26
|
(destinationCurrency === (0, client_1.getNativeCurrency)() || destinationCurrency === "drops"));
|
|
27
27
|
}
|
|
28
28
|
function isIOUWithoutCounterparty(amount) {
|
|
29
|
-
|
|
29
|
+
if (typeof amount === "object") {
|
|
30
|
+
if ("currency" in amount && amount.currency !== (0, client_1.getNativeCurrency)() && amount.currency !== "drops") {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if ("mpt_issuance_id" in amount && amount.mpt_issuance_id) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (amount.issuer == null &&
|
|
37
|
+
amount.counterparty == null) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return false;
|
|
30
42
|
}
|
|
31
43
|
function applyAnyCounterpartyEncoding(payment) {
|
|
32
44
|
[payment.source, payment.destination].forEach((adjustment) => {
|
|
33
45
|
["amount", "minAmount", "maxAmount"].forEach((key) => {
|
|
34
46
|
if (isIOUWithoutCounterparty(adjustment[key])) {
|
|
35
|
-
adjustment[key].
|
|
47
|
+
adjustment[key].issuer = adjustment.address;
|
|
36
48
|
}
|
|
37
49
|
});
|
|
38
50
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.9",
|
|
4
4
|
"description": "A Bithomp JavaScript/TypeScript library for interacting with the XRP Ledger",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
44
44
|
"lint": "eslint",
|
|
45
45
|
"prepare": "npm run build",
|
|
46
|
-
"prepublishOnly": "npm test && npm run lint",
|
|
46
|
+
"-prepublishOnly": "npm test && npm run lint",
|
|
47
47
|
"preversion": "npm run lint",
|
|
48
48
|
"version": "npm run format && git add -A src",
|
|
49
49
|
"postversion": "git push && git push --tags"
|