@bithomp/xrpl-api 3.2.11 → 3.2.13
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/faucet.js +34 -1
- package/lib/models/account_nfts.js +34 -1
- package/lib/models/mptoken.js +34 -1
- package/lib/parse/outcome/channel_changes.d.ts +16 -6
- package/lib/parse/outcome/channel_changes.js +18 -5
- package/lib/parse/outcome/check_changes.d.ts +17 -0
- package/lib/parse/outcome/check_changes.js +63 -0
- package/lib/parse/outcome/index.d.ts +1 -0
- package/lib/parse/outcome/index.js +3 -1
- package/lib/parse/outcome/nftoken_changes.js +34 -1
- package/lib/parse/outcome.js +171 -36
- package/lib/types/checks.d.ts +4 -5
- package/package.json +6 -6
package/lib/faucet.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -9,7 +42,7 @@ exports.foundWallet = foundWallet;
|
|
|
9
42
|
exports.getAxiosFaucetOptions = getAxiosFaucetOptions;
|
|
10
43
|
exports.xrplLabsToXrplResponse = xrplLabsToXrplResponse;
|
|
11
44
|
const axios_1 = __importDefault(require("axios"));
|
|
12
|
-
const AddressCodec = require("ripple-address-codec");
|
|
45
|
+
const AddressCodec = __importStar(require("ripple-address-codec"));
|
|
13
46
|
exports.FaucetNetworks = {
|
|
14
47
|
test: {
|
|
15
48
|
url: "https://faucet.altnet.rippletest.net/accounts",
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -8,7 +41,7 @@ exports.cipheredTaxon = cipheredTaxon;
|
|
|
8
41
|
exports.parseNFTokenID = parseNFTokenID;
|
|
9
42
|
exports.buildNFTokenID = buildNFTokenID;
|
|
10
43
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
-
const AddressCodec = require("ripple-address-codec");
|
|
44
|
+
const AddressCodec = __importStar(require("ripple-address-codec"));
|
|
12
45
|
const utils_1 = require("../parse/utils");
|
|
13
46
|
function sortHelperAccountNFToken(a, b) {
|
|
14
47
|
const cmpIssuer = a.Issuer.localeCompare(b.Issuer);
|
package/lib/models/mptoken.js
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -6,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
39
|
exports.buildMPTokenIssuanceID = buildMPTokenIssuanceID;
|
|
7
40
|
exports.parseMPTokenIssuanceID = parseMPTokenIssuanceID;
|
|
8
41
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
-
const AddressCodec = require("ripple-address-codec");
|
|
42
|
+
const AddressCodec = __importStar(require("ripple-address-codec"));
|
|
10
43
|
const utils_1 = require("../parse/utils");
|
|
11
44
|
function buildMPTokenIssuanceID(sequence, issuer) {
|
|
12
45
|
return (new bignumber_js_1.default(sequence).toString(16).padStart(8, "0").toUpperCase() +
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { TransactionMetadata } from "xrpl";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../types/account";
|
|
3
|
+
import { IssuedCurrencyAmount } from "../../types/amounts";
|
|
4
|
+
interface FormattedChannelSummaryInterface {
|
|
5
|
+
status?: "created" | "modified" | "deleted";
|
|
4
6
|
channelId: string;
|
|
5
|
-
source
|
|
6
|
-
destination
|
|
7
|
+
source?: FormattedSourceAddress;
|
|
8
|
+
destination?: FormattedDestinationAddress;
|
|
7
9
|
channelAmountDrops: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
amount: IssuedCurrencyAmount;
|
|
11
|
+
channelBalanceDrops?: string;
|
|
12
|
+
balance?: IssuedCurrencyAmount;
|
|
13
|
+
channelAmountChangeDrops?: string;
|
|
14
|
+
amountChange?: IssuedCurrencyAmount;
|
|
15
|
+
channelBalanceChangeDrops?: string;
|
|
16
|
+
balanceChange?: IssuedCurrencyAmount;
|
|
17
|
+
previousTxnID?: string;
|
|
18
|
+
}
|
|
19
|
+
declare function parseChannelChanges(metadata: TransactionMetadata): FormattedChannelSummaryInterface | undefined;
|
|
10
20
|
export { parseChannelChanges };
|
|
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseChannelChanges = parseChannelChanges;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
9
|
+
const source_1 = require("../ledger/source");
|
|
10
|
+
const destination_1 = require("../ledger/destination");
|
|
8
11
|
const utils_1 = require("../utils");
|
|
9
12
|
function parsePaymentChannelStatus(node) {
|
|
10
13
|
if (node.diffType === "CreatedNode") {
|
|
@@ -24,20 +27,30 @@ function summarizePaymentChannel(node) {
|
|
|
24
27
|
const summary = {
|
|
25
28
|
status: parsePaymentChannelStatus(node),
|
|
26
29
|
channelId: node.ledgerIndex,
|
|
27
|
-
source: final
|
|
28
|
-
destination: final
|
|
30
|
+
source: (0, source_1.parseSource)(final),
|
|
31
|
+
destination: (0, destination_1.parseDestination)(final),
|
|
29
32
|
channelAmountDrops: new bignumber_js_1.default(final.Amount || 0).toString(10),
|
|
30
|
-
|
|
33
|
+
amount: (0, amount_1.default)(final.Amount),
|
|
31
34
|
};
|
|
35
|
+
if (final.Balance) {
|
|
36
|
+
summary.channelBalanceDrops = new bignumber_js_1.default(final.Balance || 0).toString(10);
|
|
37
|
+
summary.balance = (0, amount_1.default)(final.Balance);
|
|
38
|
+
}
|
|
32
39
|
if (prev.Amount) {
|
|
33
|
-
summary.channelAmountChangeDrops = new bignumber_js_1.default(final.Amount)
|
|
34
|
-
|
|
40
|
+
summary.channelAmountChangeDrops = new bignumber_js_1.default(final.Amount).minus(new bignumber_js_1.default(prev.Amount || 0)).toString(10);
|
|
41
|
+
summary.amountChange = (0, amount_1.default)(prev.Amount);
|
|
42
|
+
summary.amountChange.value = new bignumber_js_1.default(summary.amountChange.value)
|
|
43
|
+
.minus(new bignumber_js_1.default(summary.amount.value))
|
|
35
44
|
.toString(10);
|
|
36
45
|
}
|
|
37
46
|
if (prev.Balance) {
|
|
38
47
|
summary.channelBalanceChangeDrops = new bignumber_js_1.default(final.Balance)
|
|
39
48
|
.minus(new bignumber_js_1.default(prev.Balance || 0))
|
|
40
49
|
.toString(10);
|
|
50
|
+
summary.balanceChange = (0, amount_1.default)(prev.Balance);
|
|
51
|
+
summary.balanceChange.value = new bignumber_js_1.default(summary.balanceChange.value)
|
|
52
|
+
.minus(new bignumber_js_1.default(summary.balance?.value || 0))
|
|
53
|
+
.toString(10);
|
|
41
54
|
}
|
|
42
55
|
if (node.PreviousTxnID) {
|
|
43
56
|
summary.previousTxnID = node.PreviousTxnID;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../types/account";
|
|
3
|
+
import { IssuedCurrencyAmount, FormattedIssuedMPTAmount } from "../../types/amounts";
|
|
4
|
+
interface FormattedCheckSummaryInterface {
|
|
5
|
+
status?: "created" | "modified" | "deleted";
|
|
6
|
+
checkID: string;
|
|
7
|
+
source?: FormattedSourceAddress;
|
|
8
|
+
destination?: FormattedDestinationAddress;
|
|
9
|
+
sendMax: IssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
10
|
+
expiration?: number;
|
|
11
|
+
invoiceID?: string;
|
|
12
|
+
sequence?: number;
|
|
13
|
+
sendMaxChange?: IssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
14
|
+
previousTxnID?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function parseCheckChanges(metadata: TransactionMetadata): FormattedCheckSummaryInterface | undefined;
|
|
17
|
+
export { parseCheckChanges };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.parseCheckChanges = parseCheckChanges;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const amount_1 = __importDefault(require("../ledger/amount"));
|
|
9
|
+
const source_1 = require("../ledger/source");
|
|
10
|
+
const destination_1 = require("../ledger/destination");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const models_1 = require("../../models");
|
|
13
|
+
function parseCheckStatus(node) {
|
|
14
|
+
if (node.diffType === "CreatedNode") {
|
|
15
|
+
return "created";
|
|
16
|
+
}
|
|
17
|
+
if (node.diffType === "ModifiedNode") {
|
|
18
|
+
return "modified";
|
|
19
|
+
}
|
|
20
|
+
if (node.diffType === "DeletedNode") {
|
|
21
|
+
return "deleted";
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function summarizeCheck(node) {
|
|
26
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
27
|
+
const prev = node.previousFields;
|
|
28
|
+
const summary = {
|
|
29
|
+
status: parseCheckStatus(node),
|
|
30
|
+
checkID: node.ledgerIndex,
|
|
31
|
+
source: (0, source_1.parseSource)(final),
|
|
32
|
+
destination: (0, destination_1.parseDestination)(final),
|
|
33
|
+
sendMax: (0, amount_1.default)(final.SendMax),
|
|
34
|
+
sequence: final.Sequence,
|
|
35
|
+
};
|
|
36
|
+
if (final.Expiration) {
|
|
37
|
+
summary.expiration = (0, models_1.ledgerTimeToUnixTime)(final.Expiration);
|
|
38
|
+
}
|
|
39
|
+
if (final.InvoiceID) {
|
|
40
|
+
summary.invoiceID = final.InvoiceID;
|
|
41
|
+
}
|
|
42
|
+
if (prev.SendMax) {
|
|
43
|
+
summary.sendMaxChange = (0, amount_1.default)(prev.SendMax);
|
|
44
|
+
summary.sendMaxChange.value = new bignumber_js_1.default(summary.sendMaxChange.value)
|
|
45
|
+
.minus(new bignumber_js_1.default(summary.sendMax.value))
|
|
46
|
+
.toString(10);
|
|
47
|
+
}
|
|
48
|
+
if (node.PreviousTxnID) {
|
|
49
|
+
summary.previousTxnID = node.PreviousTxnID;
|
|
50
|
+
}
|
|
51
|
+
return summary;
|
|
52
|
+
}
|
|
53
|
+
function parseCheckChanges(metadata) {
|
|
54
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
55
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
56
|
+
return node.LedgerEntryType === "Check";
|
|
57
|
+
});
|
|
58
|
+
if (affectedNodes.length !== 1) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const normalizedNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
62
|
+
return summarizeCheck(normalizedNode);
|
|
63
|
+
}
|
|
@@ -6,6 +6,7 @@ export { parseURITokenSellOfferChanges } from "./uritoken_sell_offer_changes";
|
|
|
6
6
|
export { parseBalanceChanges } from "./balance_changes";
|
|
7
7
|
export { parseLockedBalanceChanges } from "./locked_balance_changes";
|
|
8
8
|
export { parseChannelChanges } from "./channel_changes";
|
|
9
|
+
export { parseCheckChanges } from "./check_changes";
|
|
9
10
|
export { parseOrderbookChanges } from "./orderbook_changes";
|
|
10
11
|
export { parseHooksExecutions } from "./hooks_executions";
|
|
11
12
|
export { parseEmittedTxns } from "./emitted_txns";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
3
|
+
exports.parseMPTokenChanges = exports.parseMPTokenIssuanceChanges = exports.parseDeliveredAmount = exports.parseOracleChanges = exports.parseDIDChanges = exports.parseAmmChanges = exports.parseUNLReportChanges = exports.parseEscrowChanges = exports.parseEmittedTxns = exports.parseHooksExecutions = exports.parseOrderbookChanges = exports.parseCheckChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
4
4
|
var affected_objects_1 = require("./affected_objects");
|
|
5
5
|
Object.defineProperty(exports, "parseAffectedObjects", { enumerable: true, get: function () { return affected_objects_1.parseAffectedObjects; } });
|
|
6
6
|
var nftoken_changes_1 = require("./nftoken_changes");
|
|
@@ -17,6 +17,8 @@ var locked_balance_changes_1 = require("./locked_balance_changes");
|
|
|
17
17
|
Object.defineProperty(exports, "parseLockedBalanceChanges", { enumerable: true, get: function () { return locked_balance_changes_1.parseLockedBalanceChanges; } });
|
|
18
18
|
var channel_changes_1 = require("./channel_changes");
|
|
19
19
|
Object.defineProperty(exports, "parseChannelChanges", { enumerable: true, get: function () { return channel_changes_1.parseChannelChanges; } });
|
|
20
|
+
var check_changes_1 = require("./check_changes");
|
|
21
|
+
Object.defineProperty(exports, "parseCheckChanges", { enumerable: true, get: function () { return check_changes_1.parseCheckChanges; } });
|
|
20
22
|
var orderbook_changes_1 = require("./orderbook_changes");
|
|
21
23
|
Object.defineProperty(exports, "parseOrderbookChanges", { enumerable: true, get: function () { return orderbook_changes_1.parseOrderbookChanges; } });
|
|
22
24
|
var hooks_executions_1 = require("./hooks_executions");
|
|
@@ -1,11 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.parseNFTokenChanges = parseNFTokenChanges;
|
|
7
40
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const AddressCodec = require("ripple-address-codec");
|
|
41
|
+
const AddressCodec = __importStar(require("ripple-address-codec"));
|
|
9
42
|
const common_1 = require("../../common");
|
|
10
43
|
function parseNFTokenChanges(tx) {
|
|
11
44
|
return new NFTokenChanges(tx).call();
|
package/lib/parse/outcome.js
CHANGED
|
@@ -1,57 +1,192 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseOutcome = parseOutcome;
|
|
4
|
+
const client_1 = require("../client");
|
|
4
5
|
const index_1 = require("./outcome/index");
|
|
5
6
|
const utils_1 = require("./utils");
|
|
6
7
|
const common_1 = require("../common");
|
|
8
|
+
const ESCROW_TYPES = ["EscrowFinish", "EscrowCreate", "EscrowCancel"];
|
|
9
|
+
const CHANNEL_TYPES = ["PaymentChannelCreate", "PaymentChannelFund", "PaymentChannelClaim"];
|
|
10
|
+
const CHECK_TYPES = ["CheckCreate", "CheckCash", "CheckCancel"];
|
|
11
|
+
const NFTOKEN_TYPES = ["NFTokenMint", "NFTokenBurn", "NFTokenCreateOffer", "NFTokenCancelOffer", "NFTokenAcceptOffer"];
|
|
12
|
+
const URITOKEN_TYPES = [
|
|
13
|
+
"Remit",
|
|
14
|
+
"URITokenMint",
|
|
15
|
+
"URITokenBurn",
|
|
16
|
+
"URITokenBuy",
|
|
17
|
+
"URITokenCreateSellOffer",
|
|
18
|
+
"URITokenCancelSellOffer",
|
|
19
|
+
];
|
|
20
|
+
const AMM_TYPES = ["AMMBid", "AMMCreate", "AMMDelete", "AMMDeposit", "AMMWithdraw", "AMMVote", "AMMClawback"];
|
|
21
|
+
const DID_TYPES = ["DIDSet", "DIDDelete"];
|
|
22
|
+
const ORACLE_TYPES = ["OracleSet", "OracleDelete"];
|
|
23
|
+
const UNL_REPORT_TYPES = ["UNLReport"];
|
|
24
|
+
const MPTOKEN_TYPES = [
|
|
25
|
+
"MPTokenIssuanceCreate",
|
|
26
|
+
"MPTokenAuthorize",
|
|
27
|
+
"MPTokenIssuanceSet",
|
|
28
|
+
"MPTokenIssuanceDestroy",
|
|
29
|
+
"Payment",
|
|
30
|
+
"Clawback",
|
|
31
|
+
];
|
|
7
32
|
function parseOutcome(tx, nativeCurrency, definitions) {
|
|
8
33
|
const metadata = tx.meta || tx.metaData;
|
|
9
34
|
if (!metadata) {
|
|
10
35
|
return undefined;
|
|
11
36
|
}
|
|
12
|
-
const balanceChanges = (0, index_1.parseBalanceChanges)(metadata, nativeCurrency);
|
|
13
|
-
const lockedBalanceChanges = (0, index_1.parseLockedBalanceChanges)(metadata);
|
|
14
|
-
const orderbookChanges = (0, index_1.parseOrderbookChanges)(metadata);
|
|
15
|
-
const channelChanges = (0, index_1.parseChannelChanges)(metadata);
|
|
16
|
-
const escrowChanges = (0, index_1.parseEscrowChanges)(tx);
|
|
17
|
-
const nftokenChanges = (0, index_1.parseNFTokenChanges)(tx);
|
|
18
|
-
const nftokenOfferChanges = (0, index_1.parseNFTokenOfferChanges)(tx);
|
|
19
|
-
const uritokenChanges = (0, index_1.parseURITokenChanges)(tx);
|
|
20
|
-
const uritokenSellOfferChanges = (0, index_1.parseURITokenSellOfferChanges)(tx);
|
|
21
|
-
const affectedObjects = (0, index_1.parseAffectedObjects)(tx);
|
|
22
|
-
const hooksExecutions = (0, index_1.parseHooksExecutions)(tx);
|
|
23
|
-
const emittedTxns = (0, index_1.parseEmittedTxns)(tx, definitions);
|
|
24
|
-
const unlReportChanges = (0, index_1.parseUNLReportChanges)(tx);
|
|
25
|
-
const ammChanges = (0, index_1.parseAmmChanges)(metadata);
|
|
26
|
-
const didChanges = (0, index_1.parseDIDChanges)(metadata);
|
|
27
|
-
const oracleChanges = (0, index_1.parseOracleChanges)(metadata);
|
|
28
|
-
const mptokenIssuanceChanges = (0, index_1.parseMPTokenIssuanceChanges)(tx);
|
|
29
|
-
const mptokenChanges = (0, index_1.parseMPTokenChanges)(tx);
|
|
30
37
|
return (0, common_1.removeUndefined)({
|
|
31
38
|
result: tx.meta.TransactionResult,
|
|
32
39
|
timestamp: (0, utils_1.parseTimestamp)(tx.date),
|
|
33
40
|
fee: (0, common_1.dropsToXrp)(tx.Fee),
|
|
34
|
-
balanceChanges:
|
|
35
|
-
lockedBalanceChanges:
|
|
36
|
-
orderbookChanges:
|
|
37
|
-
channelChanges,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
41
|
+
balanceChanges: getBalanceChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
42
|
+
lockedBalanceChanges: getLockedBalanceChanges(tx),
|
|
43
|
+
orderbookChanges: getOrderbookChanges(tx),
|
|
44
|
+
channelChanges: getChannelChanges(tx),
|
|
45
|
+
checkChanges: getCheckChanges(tx),
|
|
46
|
+
escrowChanges: getEscrowChanges(tx),
|
|
47
|
+
nftokenChanges: getNFTokenChanges(tx),
|
|
48
|
+
nftokenOfferChanges: getNFTokenOfferChanges(tx),
|
|
49
|
+
uritokenChanges: getURITokenChanges(tx),
|
|
50
|
+
uritokenSellOfferChanges: getURITokenSellOfferChanges(tx),
|
|
51
|
+
affectedObjects: getAffectedObjects(tx),
|
|
52
|
+
ammChanges: getAmmChanges(tx),
|
|
53
|
+
didChanges: getDIDChanges(tx),
|
|
54
|
+
oracleChanges: getOracleChanges(tx),
|
|
55
|
+
mptokenIssuanceChanges: getMPTokenIssuanceChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
56
|
+
mptokenChanges: getMPTokenChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
57
|
+
unlReportChanges: getUNLReportChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
58
|
+
hooksExecutions: getHooksExecutions(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
59
|
+
emittedTxns: getEmittedTxns(tx, nativeCurrency || (0, client_1.getNativeCurrency)(), definitions),
|
|
52
60
|
ledgerIndex: tx.ledger_index || tx.inLedger,
|
|
53
61
|
ledgerVersion: tx.ledger_index || tx.inLedger,
|
|
54
62
|
indexInLedger: tx.meta.TransactionIndex,
|
|
55
63
|
deliveredAmount: (0, index_1.parseDeliveredAmount)(tx),
|
|
56
64
|
});
|
|
57
65
|
}
|
|
66
|
+
function getBalanceChanges(tx, nativeCurrency) {
|
|
67
|
+
const balanceChanges = (0, index_1.parseBalanceChanges)(tx.meta, nativeCurrency);
|
|
68
|
+
return Object.keys(balanceChanges).length > 0 ? balanceChanges : undefined;
|
|
69
|
+
}
|
|
70
|
+
function getLockedBalanceChanges(tx) {
|
|
71
|
+
if (!ESCROW_TYPES.includes(tx.TransactionType)) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
const lockedBalanceChanges = (0, index_1.parseLockedBalanceChanges)(tx.meta);
|
|
75
|
+
return Object.keys(lockedBalanceChanges).length > 0 ? lockedBalanceChanges : undefined;
|
|
76
|
+
}
|
|
77
|
+
function getOrderbookChanges(tx) {
|
|
78
|
+
const orderbookChanges = (0, index_1.parseOrderbookChanges)(tx.meta);
|
|
79
|
+
return Object.keys(orderbookChanges).length > 0 ? orderbookChanges : undefined;
|
|
80
|
+
}
|
|
81
|
+
function getChannelChanges(tx) {
|
|
82
|
+
if (!CHANNEL_TYPES.includes(tx.TransactionType)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
return (0, index_1.parseChannelChanges)(tx.meta);
|
|
86
|
+
}
|
|
87
|
+
function getCheckChanges(tx) {
|
|
88
|
+
if (!CHECK_TYPES.includes(tx.TransactionType)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return (0, index_1.parseCheckChanges)(tx.meta);
|
|
92
|
+
}
|
|
93
|
+
function getEscrowChanges(tx) {
|
|
94
|
+
if (!ESCROW_TYPES.includes(tx.TransactionType)) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return (0, index_1.parseEscrowChanges)(tx);
|
|
98
|
+
}
|
|
99
|
+
function getAffectedObjects(tx) {
|
|
100
|
+
if (!NFTOKEN_TYPES.includes(tx.TransactionType) && !URITOKEN_TYPES.includes(tx.TransactionType)) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
const affectedObjects = (0, index_1.parseAffectedObjects)(tx);
|
|
104
|
+
return affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined;
|
|
105
|
+
}
|
|
106
|
+
function getNFTokenChanges(tx) {
|
|
107
|
+
if (!NFTOKEN_TYPES.includes(tx.TransactionType)) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const nftokenChanges = (0, index_1.parseNFTokenChanges)(tx);
|
|
111
|
+
return Object.keys(nftokenChanges).length > 0 ? nftokenChanges : undefined;
|
|
112
|
+
}
|
|
113
|
+
function getNFTokenOfferChanges(tx) {
|
|
114
|
+
if (!NFTOKEN_TYPES.includes(tx.TransactionType)) {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
const nftokenOfferChanges = (0, index_1.parseNFTokenOfferChanges)(tx);
|
|
118
|
+
return Object.keys(nftokenOfferChanges).length > 0 ? nftokenOfferChanges : undefined;
|
|
119
|
+
}
|
|
120
|
+
function getURITokenChanges(tx) {
|
|
121
|
+
if (!URITOKEN_TYPES.includes(tx.TransactionType)) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const uritokenChanges = (0, index_1.parseURITokenChanges)(tx);
|
|
125
|
+
return Object.keys(uritokenChanges).length > 0 ? uritokenChanges : undefined;
|
|
126
|
+
}
|
|
127
|
+
function getURITokenSellOfferChanges(tx) {
|
|
128
|
+
if (!URITOKEN_TYPES.includes(tx.TransactionType)) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const uritokenSellOfferChanges = (0, index_1.parseURITokenSellOfferChanges)(tx);
|
|
132
|
+
return Object.keys(uritokenSellOfferChanges).length > 0 ? uritokenSellOfferChanges : undefined;
|
|
133
|
+
}
|
|
134
|
+
function getHooksExecutions(tx, nativeCurrency) {
|
|
135
|
+
if (nativeCurrency !== "XAH") {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
return (0, index_1.parseHooksExecutions)(tx);
|
|
139
|
+
}
|
|
140
|
+
function getEmittedTxns(tx, nativeCurrency, definitions) {
|
|
141
|
+
if (nativeCurrency !== "XAH") {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
return (0, index_1.parseEmittedTxns)(tx, definitions);
|
|
145
|
+
}
|
|
146
|
+
function getAmmChanges(tx) {
|
|
147
|
+
if (!AMM_TYPES.includes(tx.TransactionType)) {
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
const ammChanges = (0, index_1.parseAmmChanges)(tx.meta);
|
|
151
|
+
return ammChanges ? (0, common_1.removeUndefined)(ammChanges) : undefined;
|
|
152
|
+
}
|
|
153
|
+
function getDIDChanges(tx) {
|
|
154
|
+
if (!DID_TYPES.includes(tx.TransactionType)) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
const didChanges = (0, index_1.parseDIDChanges)(tx.meta);
|
|
158
|
+
return didChanges ? (0, common_1.removeUndefined)(didChanges) : undefined;
|
|
159
|
+
}
|
|
160
|
+
function getOracleChanges(tx) {
|
|
161
|
+
if (!ORACLE_TYPES.includes(tx.TransactionType)) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const oracleChanges = (0, index_1.parseOracleChanges)(tx.meta);
|
|
165
|
+
return oracleChanges ? (0, common_1.removeUndefined)(oracleChanges) : undefined;
|
|
166
|
+
}
|
|
167
|
+
function getUNLReportChanges(tx, nativeCurrency) {
|
|
168
|
+
if (nativeCurrency !== "XAH") {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
if (!UNL_REPORT_TYPES.includes(tx.TransactionType)) {
|
|
172
|
+
return undefined;
|
|
173
|
+
}
|
|
174
|
+
return (0, index_1.parseUNLReportChanges)(tx);
|
|
175
|
+
}
|
|
176
|
+
function getMPTokenChanges(tx, nativeCurrency) {
|
|
177
|
+
if (nativeCurrency !== "XRP") {
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
if (!MPTOKEN_TYPES.includes(tx.TransactionType)) {
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
const mptokenChanges = (0, index_1.parseMPTokenChanges)(tx);
|
|
184
|
+
return Object.keys(mptokenChanges).length > 0 ? mptokenChanges : undefined;
|
|
185
|
+
}
|
|
186
|
+
function getMPTokenIssuanceChanges(tx, nativeCurrency) {
|
|
187
|
+
if (nativeCurrency !== "XRP") {
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
const mptokenIssuanceChanges = (0, index_1.parseMPTokenIssuanceChanges)(tx);
|
|
191
|
+
return Object.keys(mptokenIssuanceChanges).length > 0 ? mptokenIssuanceChanges : undefined;
|
|
192
|
+
}
|
package/lib/types/checks.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { FormattedBaseSpecification } from "./specification";
|
|
2
|
-
import { FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount } from "./amounts";
|
|
2
|
+
import { IssuedCurrencyAmount, FormattedIssuedCurrencyAmount, FormattedIssuedMPTAmount } from "./amounts";
|
|
3
3
|
import { FormattedSourceAddress, FormattedDestinationAddress } from "./account";
|
|
4
4
|
export type FormattedCheckCancelSpecification = {
|
|
5
5
|
checkID: string;
|
|
6
6
|
} & FormattedBaseSpecification;
|
|
7
7
|
export type FormattedCheckCashSpecification = {
|
|
8
8
|
checkID: string;
|
|
9
|
-
amount: FormattedIssuedCurrencyAmount;
|
|
10
|
-
deliverMin: FormattedIssuedCurrencyAmount;
|
|
9
|
+
amount: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount;
|
|
10
|
+
deliverMin: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount;
|
|
11
11
|
} & FormattedBaseSpecification;
|
|
12
12
|
export type FormattedCheckCreateSpecification = {
|
|
13
13
|
source?: FormattedSourceAddress;
|
|
14
14
|
destination?: FormattedDestinationAddress;
|
|
15
|
-
sendMax: FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
15
|
+
sendMax: IssuedCurrencyAmount | FormattedIssuedCurrencyAmount | FormattedIssuedMPTAmount;
|
|
16
16
|
expiration?: string;
|
|
17
|
-
invoiceID?: string;
|
|
18
17
|
} & FormattedBaseSpecification;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.13",
|
|
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",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
"@eslint/eslintrc": "^3.2.0",
|
|
66
66
|
"@types/chai": "^5.0.1",
|
|
67
67
|
"@types/chai-as-promised": "^8.0.1",
|
|
68
|
-
"@types/lodash": "^4.17.
|
|
68
|
+
"@types/lodash": "^4.17.15",
|
|
69
69
|
"@types/mocha": "^10.0.10",
|
|
70
70
|
"@types/nconf": "^0.10.7",
|
|
71
|
-
"@types/node": "^22.13.
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
73
|
-
"@typescript-eslint/parser": "^8.
|
|
71
|
+
"@types/node": "^22.13.1",
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.23.0",
|
|
73
|
+
"@typescript-eslint/parser": "^8.23.0",
|
|
74
74
|
"chai": "^4.5.0",
|
|
75
75
|
"chai-as-promised": "^7.1.2",
|
|
76
|
-
"eslint": "^9.
|
|
76
|
+
"eslint": "^9.20.0",
|
|
77
77
|
"eslint-config-prettier": "^10.0.1",
|
|
78
78
|
"eslint-plugin-chai-friendly": "^1.0.1",
|
|
79
79
|
"eslint-plugin-import": "^2.31.0",
|