@bithomp/xrpl-api 2.6.7 → 2.7.1
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/transaction.d.ts +1 -1
- package/lib/parse/outcome/channel_changes.js +1 -1
- package/lib/parse/outcome/escrow_changes.d.ts +16 -0
- package/lib/parse/outcome/escrow_changes.js +72 -0
- package/lib/parse/outcome/index.d.ts +1 -0
- package/lib/parse/outcome/index.js +3 -1
- package/lib/parse/outcome/nftoken_offer_changes.js +8 -8
- package/lib/parse/outcome.js +2 -0
- package/lib/parse/specification/escrow-cancel.js +6 -1
- package/lib/parse/specification/escrow-create.js +12 -6
- package/lib/parse/specification/escrow-finish.js +6 -1
- package/lib/v1/common/types/objects/escrows.d.ts +7 -5
- package/package.json +4 -4
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "../../v1/common/types/objects/account";
|
|
2
|
+
interface FormattedEscrowInterface {
|
|
3
|
+
status?: string;
|
|
4
|
+
escrowIndex?: number;
|
|
5
|
+
escrowSequence?: number;
|
|
6
|
+
amount?: string;
|
|
7
|
+
condition?: string;
|
|
8
|
+
source?: FormattedSourceAddress;
|
|
9
|
+
destination?: FormattedDestinationAddress;
|
|
10
|
+
allowCancelAfter?: string;
|
|
11
|
+
allowExecuteAfter?: string;
|
|
12
|
+
previousTxnID?: string;
|
|
13
|
+
previousTxnLgrSeq?: number;
|
|
14
|
+
}
|
|
15
|
+
declare function parseEscrowChanges(tx: any): FormattedEscrowInterface | undefined;
|
|
16
|
+
export { parseEscrowChanges };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseEscrowChanges = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const utils_1 = require("../../v1/common/utils");
|
|
6
|
+
const utils_2 = require("../utils");
|
|
7
|
+
function parseEscrowStatus(tx, node) {
|
|
8
|
+
if (node.diffType === "CreatedNode") {
|
|
9
|
+
return "created";
|
|
10
|
+
}
|
|
11
|
+
if (node.diffType === "DeletedNode") {
|
|
12
|
+
if (tx.TransactionType === "EscrowCancel") {
|
|
13
|
+
return "cancelled";
|
|
14
|
+
}
|
|
15
|
+
if (tx.TransactionType === "EscrowFinish") {
|
|
16
|
+
return "executed";
|
|
17
|
+
}
|
|
18
|
+
return "deleted";
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function parseEscrowSequence(tx) {
|
|
23
|
+
if (tx.TransactionType === "EscrowCreate") {
|
|
24
|
+
return tx.Sequence || tx.TicketSequence;
|
|
25
|
+
}
|
|
26
|
+
if (tx.TransactionType === "EscrowCancel" || tx.TransactionType === "EscrowFinish") {
|
|
27
|
+
return tx.OfferSequence;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
function summarizeEscrow(tx, node) {
|
|
32
|
+
const final = node.diffType === "CreatedNode" ? node.newFields : node.finalFields;
|
|
33
|
+
const source = {
|
|
34
|
+
address: final.Account,
|
|
35
|
+
tag: final.SourceTag,
|
|
36
|
+
};
|
|
37
|
+
const destination = {
|
|
38
|
+
address: final.Destination,
|
|
39
|
+
tag: final.DestinationTag,
|
|
40
|
+
};
|
|
41
|
+
const summary = {
|
|
42
|
+
status: parseEscrowStatus(tx, node),
|
|
43
|
+
escrowIndex: node.ledgerIndex,
|
|
44
|
+
escrowSequence: parseEscrowSequence(tx),
|
|
45
|
+
amount: final.Amount,
|
|
46
|
+
condition: final.Condition,
|
|
47
|
+
source: (0, common_1.removeUndefined)(source),
|
|
48
|
+
destination: (0, common_1.removeUndefined)(destination),
|
|
49
|
+
allowCancelAfter: (0, utils_2.parseTimestamp)(final.CancelAfter),
|
|
50
|
+
allowExecuteAfter: (0, utils_2.parseTimestamp)(final.FinishAfter),
|
|
51
|
+
};
|
|
52
|
+
if (final.PreviousTxnID) {
|
|
53
|
+
summary.previousTxnID = final.PreviousTxnID;
|
|
54
|
+
}
|
|
55
|
+
else if (node.diffType === "CreatedNode") {
|
|
56
|
+
summary.previousTxnID = tx.hash;
|
|
57
|
+
}
|
|
58
|
+
if (final.PreviousTxnLgrSeq) {
|
|
59
|
+
summary.previousTxnLgrSeq = final.PreviousTxnLgrSeq;
|
|
60
|
+
}
|
|
61
|
+
else if (node.diffType === "CreatedNode") {
|
|
62
|
+
summary.previousTxnLgrSeq = tx.ledger_index;
|
|
63
|
+
}
|
|
64
|
+
return (0, common_1.removeUndefined)(summary);
|
|
65
|
+
}
|
|
66
|
+
function parseEscrowChanges(tx) {
|
|
67
|
+
const escrows = (0, utils_1.normalizeNodes)(tx.meta).filter((n) => {
|
|
68
|
+
return n.entryType === "Escrow";
|
|
69
|
+
});
|
|
70
|
+
return escrows.length === 1 ? summarizeEscrow(tx, escrows[0]) : undefined;
|
|
71
|
+
}
|
|
72
|
+
exports.parseEscrowChanges = parseEscrowChanges;
|
|
@@ -9,3 +9,4 @@ export { parseChannelChanges } from "./channel_changes";
|
|
|
9
9
|
export { parseOrderbookChanges } from "./orderbook_changes";
|
|
10
10
|
export { parseHooksExecutions } from "./hooks_executions";
|
|
11
11
|
export { parseEmittedTxns } from "./emitted_txns";
|
|
12
|
+
export { parseEscrowChanges } from "./escrow_changes";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
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.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;
|
|
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");
|
|
@@ -23,3 +23,5 @@ var hooks_executions_1 = require("./hooks_executions");
|
|
|
23
23
|
Object.defineProperty(exports, "parseHooksExecutions", { enumerable: true, get: function () { return hooks_executions_1.parseHooksExecutions; } });
|
|
24
24
|
var emitted_txns_1 = require("./emitted_txns");
|
|
25
25
|
Object.defineProperty(exports, "parseEmittedTxns", { enumerable: true, get: function () { return emitted_txns_1.parseEmittedTxns; } });
|
|
26
|
+
var escrow_changes_1 = require("./escrow_changes");
|
|
27
|
+
Object.defineProperty(exports, "parseEscrowChanges", { enumerable: true, get: function () { return escrow_changes_1.parseEscrowChanges; } });
|
|
@@ -55,8 +55,8 @@ class NFTokenOfferChanges {
|
|
|
55
55
|
const owner = affectedNode.CreatedNode.NewFields.Owner;
|
|
56
56
|
const index = affectedNode.CreatedNode.LedgerIndex;
|
|
57
57
|
const destination = affectedNode.CreatedNode.NewFields.Destination;
|
|
58
|
-
const
|
|
59
|
-
const
|
|
58
|
+
const previousTxnID = affectedNode.CreatedNode.NewFields.PreviousTxnID;
|
|
59
|
+
const previousTxnLgrSeq = affectedNode.CreatedNode.NewFields.PreviousTxnLgrSeq;
|
|
60
60
|
let expiration = affectedNode.CreatedNode.NewFields.Expiration;
|
|
61
61
|
if (typeof expiration === "number") {
|
|
62
62
|
expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
|
|
@@ -70,8 +70,8 @@ class NFTokenOfferChanges {
|
|
|
70
70
|
destination,
|
|
71
71
|
expiration,
|
|
72
72
|
index,
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
previousTxnID,
|
|
74
|
+
previousTxnLgrSeq,
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
isNFTokensDeleteOfferNode(affectedNode) {
|
|
@@ -85,8 +85,8 @@ class NFTokenOfferChanges {
|
|
|
85
85
|
const owner = affectedNode.DeletedNode.FinalFields.Owner;
|
|
86
86
|
const index = affectedNode.DeletedNode.LedgerIndex;
|
|
87
87
|
const destination = affectedNode.DeletedNode.FinalFields.Destination;
|
|
88
|
-
const
|
|
89
|
-
const
|
|
88
|
+
const previousTxnID = affectedNode.DeletedNode.FinalFields.PreviousTxnID;
|
|
89
|
+
const previousTxnLgrSeq = affectedNode.DeletedNode.FinalFields.PreviousTxnLgrSeq;
|
|
90
90
|
let expiration = affectedNode.DeletedNode.FinalFields.Expiration;
|
|
91
91
|
if (typeof expiration === "number") {
|
|
92
92
|
expiration = (0, ledger_1.ledgerTimeToUnixTime)(expiration);
|
|
@@ -100,8 +100,8 @@ class NFTokenOfferChanges {
|
|
|
100
100
|
destination,
|
|
101
101
|
expiration,
|
|
102
102
|
index,
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
previousTxnID,
|
|
104
|
+
previousTxnLgrSeq,
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
}
|
package/lib/parse/outcome.js
CHANGED
|
@@ -69,6 +69,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
69
69
|
const lockedBalanceChanges = (0, index_1.parseLockedBalanceChanges)(metadata);
|
|
70
70
|
const orderbookChanges = (0, index_1.parseOrderbookChanges)(metadata);
|
|
71
71
|
const channelChanges = (0, index_1.parseChannelChanges)(metadata);
|
|
72
|
+
const escrowChanges = (0, index_1.parseEscrowChanges)(tx);
|
|
72
73
|
const nftokenChanges = (0, index_1.parseNFTokenChanges)(tx);
|
|
73
74
|
const nftokenOfferChanges = (0, index_1.parseNFTokenOfferChanges)(tx);
|
|
74
75
|
const uritokenChanges = (0, index_1.parseURITokenChanges)(tx);
|
|
@@ -87,6 +88,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
87
88
|
lockedBalanceChanges: Object.keys(lockedBalanceChanges).length > 0 ? lockedBalanceChanges : undefined,
|
|
88
89
|
orderbookChanges: Object.keys(orderbookChanges).length > 0 ? orderbookChanges : undefined,
|
|
89
90
|
channelChanges,
|
|
91
|
+
escrowChanges,
|
|
90
92
|
nftokenChanges: Object.keys(nftokenChanges).length > 0 ? nftokenChanges : undefined,
|
|
91
93
|
nftokenOfferChanges: Object.keys(nftokenOfferChanges).length > 0 ? nftokenOfferChanges : undefined,
|
|
92
94
|
uritokenChanges: Object.keys(uritokenChanges).length > 0 ? uritokenChanges : undefined,
|
|
@@ -31,10 +31,15 @@ const common_1 = require("../../common");
|
|
|
31
31
|
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
32
|
function parseEscrowCancel(tx) {
|
|
33
33
|
assert.ok(tx.TransactionType === "EscrowCancel");
|
|
34
|
+
const source = {
|
|
35
|
+
address: tx.Account,
|
|
36
|
+
tag: tx.SourceTag,
|
|
37
|
+
};
|
|
34
38
|
return (0, common_1.removeUndefined)({
|
|
35
|
-
|
|
39
|
+
source: (0, common_1.removeUndefined)(source),
|
|
36
40
|
owner: tx.Owner,
|
|
37
41
|
escrowSequence: tx.OfferSequence,
|
|
42
|
+
memos: (0, memos_1.default)(tx),
|
|
38
43
|
});
|
|
39
44
|
}
|
|
40
45
|
exports.default = parseEscrowCancel;
|
|
@@ -28,20 +28,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const assert = __importStar(require("assert"));
|
|
30
30
|
const common_1 = require("../../common");
|
|
31
|
-
const ripple_amount_1 = __importDefault(require("../ledger/ripple-amount"));
|
|
32
31
|
const utils_1 = require("../utils");
|
|
33
32
|
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
34
33
|
function parseEscrowCreation(tx) {
|
|
35
34
|
assert.ok(tx.TransactionType === "EscrowCreate");
|
|
35
|
+
const source = {
|
|
36
|
+
address: tx.Account,
|
|
37
|
+
tag: tx.SourceTag,
|
|
38
|
+
};
|
|
39
|
+
const destination = {
|
|
40
|
+
address: tx.Destination,
|
|
41
|
+
tag: tx.DestinationTag,
|
|
42
|
+
};
|
|
36
43
|
return (0, common_1.removeUndefined)({
|
|
37
|
-
amount:
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
amount: tx.Amount,
|
|
45
|
+
source: (0, common_1.removeUndefined)(source),
|
|
46
|
+
destination: (0, common_1.removeUndefined)(destination),
|
|
40
47
|
condition: tx.Condition,
|
|
41
48
|
allowCancelAfter: (0, utils_1.parseTimestamp)(tx.CancelAfter),
|
|
42
49
|
allowExecuteAfter: (0, utils_1.parseTimestamp)(tx.FinishAfter),
|
|
43
|
-
|
|
44
|
-
destinationTag: tx.DestinationTag,
|
|
50
|
+
memos: (0, memos_1.default)(tx),
|
|
45
51
|
});
|
|
46
52
|
}
|
|
47
53
|
exports.default = parseEscrowCreation;
|
|
@@ -31,12 +31,17 @@ const common_1 = require("../../common");
|
|
|
31
31
|
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
32
|
function parseEscrowFinish(tx) {
|
|
33
33
|
assert.ok(tx.TransactionType === "EscrowFinish");
|
|
34
|
+
const source = {
|
|
35
|
+
address: tx.Account,
|
|
36
|
+
tag: tx.SourceTag,
|
|
37
|
+
};
|
|
34
38
|
return (0, common_1.removeUndefined)({
|
|
35
|
-
|
|
39
|
+
source: (0, common_1.removeUndefined)(source),
|
|
36
40
|
owner: tx.Owner,
|
|
37
41
|
escrowSequence: tx.OfferSequence,
|
|
38
42
|
condition: tx.Condition,
|
|
39
43
|
fulfillment: tx.Fulfillment,
|
|
44
|
+
memos: (0, memos_1.default)(tx),
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
exports.default = parseEscrowFinish;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { FormattedBaseSpecification } from "./specification";
|
|
2
|
-
import {
|
|
2
|
+
import { Amount } from "../../../../types";
|
|
3
|
+
import { FormattedSourceAddress, FormattedDestinationAddress } from "./account";
|
|
3
4
|
export type FormattedEscrowCancelSpecification = {
|
|
5
|
+
source: FormattedSourceAddress;
|
|
4
6
|
owner: string;
|
|
5
7
|
escrowSequence: number;
|
|
6
8
|
} & FormattedBaseSpecification;
|
|
7
9
|
export type FormattedEscrowCreateSpecification = {
|
|
8
|
-
amount?:
|
|
9
|
-
|
|
10
|
+
amount?: Amount;
|
|
11
|
+
source: FormattedSourceAddress;
|
|
12
|
+
destination: FormattedDestinationAddress;
|
|
10
13
|
condition: string;
|
|
11
14
|
allowCancelAfter?: string;
|
|
12
15
|
allowExecuteAfter?: string;
|
|
13
|
-
sourceTag?: number;
|
|
14
|
-
destinationTag?: number;
|
|
15
16
|
} & FormattedBaseSpecification;
|
|
16
17
|
export type FormattedEscrowFinishSpecification = {
|
|
18
|
+
source: FormattedSourceAddress;
|
|
17
19
|
owner: string;
|
|
18
20
|
escrowSequence: number;
|
|
19
21
|
condition?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.1",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"lib/**/*"
|
|
48
48
|
],
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"axios": "^1.6.
|
|
50
|
+
"axios": "^1.6.2",
|
|
51
51
|
"base-x": "^4.0.0",
|
|
52
52
|
"bignumber.js": "^9.1.2",
|
|
53
53
|
"elliptic": "^6.5.4",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"@types/mocha": "^10.0.4",
|
|
64
64
|
"@types/nconf": "^0.10.6",
|
|
65
65
|
"@types/node": "^20.9.0",
|
|
66
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
67
|
-
"@typescript-eslint/parser": "^6.
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "^6.11.0",
|
|
67
|
+
"@typescript-eslint/parser": "^6.11.0",
|
|
68
68
|
"chai": "^4.3.10",
|
|
69
69
|
"chai-as-promised": "^7.1.1",
|
|
70
70
|
"mocha": "^10.2.0",
|