@bithomp/xrpl-api 3.2.19 → 3.2.21
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/parse/ledger/amount.js +1 -1
- package/lib/parse/outcome/nftoken_changes.js +61 -2
- package/lib/parse/specification/nftoken-modify.d.ts +3 -0
- package/lib/parse/specification/nftoken-modify.js +56 -0
- package/lib/parse/transaction.d.ts +2 -2
- package/lib/parse/transaction.js +3 -0
- package/lib/types/nftokens.d.ts +5 -0
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ function parseAmount(amount) {
|
|
|
9
9
|
value: (0, common_1.dropsToXrp)(amount),
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
|
-
if ("value" in amount && "currency" in amount && "issuer" in amount) {
|
|
12
|
+
if (amount && "value" in amount && "currency" in amount && "issuer" in amount) {
|
|
13
13
|
return {
|
|
14
14
|
issuer: amount.issuer,
|
|
15
15
|
currency: amount.currency,
|
|
@@ -55,8 +55,13 @@ class NFTokenChanges {
|
|
|
55
55
|
if (this.hasAffectedNodes() === false) {
|
|
56
56
|
return this.changes;
|
|
57
57
|
}
|
|
58
|
-
this.
|
|
59
|
-
|
|
58
|
+
if (this.tx.TransactionType === "NFTokenModify") {
|
|
59
|
+
this.parseNFTokensURIChanges();
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.parseAffectedNodes();
|
|
63
|
+
this.parseNFTokensChanges();
|
|
64
|
+
}
|
|
60
65
|
return this.changes;
|
|
61
66
|
}
|
|
62
67
|
hasAffectedNodes() {
|
|
@@ -172,4 +177,58 @@ class NFTokenChanges {
|
|
|
172
177
|
}
|
|
173
178
|
return undefined;
|
|
174
179
|
}
|
|
180
|
+
parseNFTokensURIChanges() {
|
|
181
|
+
const nftokenID = this.tx.NFTokenID;
|
|
182
|
+
const nftokenChanges = this.findNFTokenChangedNode(nftokenID);
|
|
183
|
+
if (!nftokenChanges) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
const [currentTokenNode, previousTokenNode] = nftokenChanges;
|
|
187
|
+
const uri = currentTokenNode?.URI;
|
|
188
|
+
const previousURI = previousTokenNode?.URI;
|
|
189
|
+
if (uri === previousURI) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
this.addChange(currentTokenNode.account, {
|
|
193
|
+
status: "modified",
|
|
194
|
+
nftokenID,
|
|
195
|
+
uri,
|
|
196
|
+
previousURI,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
findNFTokenChangedNode(nftokenID) {
|
|
200
|
+
let currentTokenNode;
|
|
201
|
+
let previousTokenNode;
|
|
202
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
203
|
+
const node = affectedNode.ModifiedNode;
|
|
204
|
+
if (node?.LedgerEntryType === "NFTokenPage") {
|
|
205
|
+
if (Array.isArray(node.FinalFields?.NFTokens)) {
|
|
206
|
+
for (const tokenNode of node.FinalFields?.NFTokens) {
|
|
207
|
+
if (tokenNode.NFToken.NFTokenID === nftokenID) {
|
|
208
|
+
currentTokenNode = tokenNode.NFToken;
|
|
209
|
+
const account = AddressCodec.encodeAccountID(Buffer.from(node?.LedgerIndex.slice(0, 40), "hex"));
|
|
210
|
+
currentTokenNode.account = account;
|
|
211
|
+
if (currentTokenNode && previousTokenNode) {
|
|
212
|
+
return [currentTokenNode, previousTokenNode];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (Array.isArray(node.PreviousFields?.NFTokens)) {
|
|
218
|
+
for (const tokenNode of node.PreviousFields?.NFTokens) {
|
|
219
|
+
if (tokenNode.NFToken.NFTokenID === nftokenID) {
|
|
220
|
+
previousTokenNode = tokenNode.NFToken;
|
|
221
|
+
if (currentTokenNode && previousTokenNode) {
|
|
222
|
+
return [currentTokenNode, previousTokenNode];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (!currentTokenNode || !previousTokenNode) {
|
|
230
|
+
return undefined;
|
|
231
|
+
}
|
|
232
|
+
return [currentTokenNode, previousTokenNode];
|
|
233
|
+
}
|
|
175
234
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const assert = __importStar(require("assert"));
|
|
37
|
+
const common_1 = require("../../common");
|
|
38
|
+
const emit_details_1 = require("../ledger/emit_details");
|
|
39
|
+
const memos_1 = require("../ledger/memos");
|
|
40
|
+
const signers_1 = require("../ledger/signers");
|
|
41
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
42
|
+
const source_1 = require("../ledger/source");
|
|
43
|
+
function parseNFTokenModify(tx) {
|
|
44
|
+
assert.ok(tx.TransactionType === "NFTokenModify");
|
|
45
|
+
return (0, common_1.removeUndefined)({
|
|
46
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
47
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
48
|
+
source: (0, source_1.parseSource)(tx),
|
|
49
|
+
nftokenID: tx.NFTokenID,
|
|
50
|
+
owner: tx.Owner,
|
|
51
|
+
uri: tx.URI,
|
|
52
|
+
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
53
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
exports.default = parseNFTokenModify;
|
|
@@ -11,7 +11,7 @@ import { FormattedPaymentSpecification } from "../types/payments";
|
|
|
11
11
|
import { FormattedPaymentChannelClaimSpecification, FormattedPaymentChannelCreateSpecification, FormattedPaymentChannelFundSpecification } from "../types/payment_channels";
|
|
12
12
|
import { FormattedTicketCreateSpecification } from "../types/tickets";
|
|
13
13
|
import { FormattedTrustlineSpecification } from "../types/trustlines";
|
|
14
|
-
import { FormattedNFTokenBurnSpecification, FormattedNFTokenMintSpecification, FormattedNFTokenCancelOfferSpecification, FormattedNFTokenCreateOfferSpecification, FormattedNFTokenAcceptOfferSpecification } from "../types/nftokens";
|
|
14
|
+
import { FormattedNFTokenBurnSpecification, FormattedNFTokenMintSpecification, FormattedNFTokenModifySpecification, FormattedNFTokenCancelOfferSpecification, FormattedNFTokenCreateOfferSpecification, FormattedNFTokenAcceptOfferSpecification } from "../types/nftokens";
|
|
15
15
|
import { FormattedURITokenBurnSpecification, FormattedURITokenBuySpecification, FormattedURITokenCreateSellOfferSpecification, FormattedURITokenCancelSellOfferSpecification, FormattedURITokenMintSpecification } from "../types/uritokens";
|
|
16
16
|
import { FormattedImportSpecification } from "../types/import";
|
|
17
17
|
import { FormattedInvokeSpecification } from "../types/invoke";
|
|
@@ -26,7 +26,7 @@ import { FormattedGenesisMintSpecification } from "../types/genesis_mint";
|
|
|
26
26
|
import { FormattedAmendmentSpecification } from "../types/amendments";
|
|
27
27
|
import { FormattedFeeUpdateSpecification } from "../types/fees";
|
|
28
28
|
declare function parseTransactionType(type: string): string;
|
|
29
|
-
export type FormattedSpecification = FormattedUnrecognizedParserSpecification | FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedClawbackSpecification | FormattedAmmBidSpecification | FormattedAmmCreateSpecification | FormattedAmmDeleteSpecification | FormattedAmmDepositSpecification | FormattedAmmWithdrawSpecification | FormattedAmmVoteSpecification | FormattedAmmClawbackSpecification | FormattedGenesisMintSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification | FormattedDIDSetSpecification | FormattedDIDDeleteSpecification | FormattedOracleSetSpecification | FormattedOracleDeleteSpecification | FormattedMPTokenIssuanceCreateSpecification | FormattedMPTokenAuthorizeSpecification | FormattedMPTokenIssuanceSetSpecification | FormattedMPTokenIssuanceDestroySpecification;
|
|
29
|
+
export type FormattedSpecification = FormattedUnrecognizedParserSpecification | FormattedSettingsSpecification | FormattedAccountDeleteSpecification | FormattedCheckCancelSpecification | FormattedCheckCashSpecification | FormattedCheckCreateSpecification | FormattedDepositPreauthSpecification | FormattedEscrowCancelSpecification | FormattedEscrowCreateSpecification | FormattedEscrowFinishSpecification | FormattedOfferCancelSpecification | FormattedOfferCreateSpecification | FormattedPaymentSpecification | FormattedPaymentChannelClaimSpecification | FormattedPaymentChannelCreateSpecification | FormattedPaymentChannelFundSpecification | FormattedTicketCreateSpecification | FormattedTrustlineSpecification | FormattedNFTokenBurnSpecification | FormattedNFTokenMintSpecification | FormattedNFTokenModifySpecification | FormattedNFTokenCancelOfferSpecification | FormattedNFTokenCreateOfferSpecification | FormattedNFTokenAcceptOfferSpecification | FormattedURITokenBurnSpecification | FormattedURITokenBuySpecification | FormattedURITokenCreateSellOfferSpecification | FormattedURITokenCancelSellOfferSpecification | FormattedURITokenMintSpecification | FormattedImportSpecification | FormattedInvokeSpecification | FormattedUNLReportSpecification | FormattedRemitsSpecification | FormattedClawbackSpecification | FormattedAmmBidSpecification | FormattedAmmCreateSpecification | FormattedAmmDeleteSpecification | FormattedAmmDepositSpecification | FormattedAmmWithdrawSpecification | FormattedAmmVoteSpecification | FormattedAmmClawbackSpecification | FormattedGenesisMintSpecification | FormattedAmendmentSpecification | FormattedFeeUpdateSpecification | FormattedDIDSetSpecification | FormattedDIDDeleteSpecification | FormattedOracleSetSpecification | FormattedOracleDeleteSpecification | FormattedMPTokenIssuanceCreateSpecification | FormattedMPTokenAuthorizeSpecification | FormattedMPTokenIssuanceSetSpecification | FormattedMPTokenIssuanceDestroySpecification;
|
|
30
30
|
export interface FormattedTransaction {
|
|
31
31
|
type: string;
|
|
32
32
|
address: string;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -28,6 +28,7 @@ const ticket_create_1 = __importDefault(require("./specification/ticket-create")
|
|
|
28
28
|
const trustline_1 = __importDefault(require("./specification/trustline"));
|
|
29
29
|
const nftoken_burn_1 = __importDefault(require("./specification/nftoken-burn"));
|
|
30
30
|
const nftoken_mint_1 = __importDefault(require("./specification/nftoken-mint"));
|
|
31
|
+
const nftoken_modify_1 = __importDefault(require("./specification/nftoken-modify"));
|
|
31
32
|
const nftoken_cancel_offer_1 = __importDefault(require("./specification/nftoken-cancel-offer"));
|
|
32
33
|
const nftoken_create_offer_1 = __importDefault(require("./specification/nftoken-create-offer"));
|
|
33
34
|
const nftoken_accept_offer_1 = __importDefault(require("./specification/nftoken-accept-offer"));
|
|
@@ -81,6 +82,7 @@ const transactionTypeToType = {
|
|
|
81
82
|
TrustSet: "trustline",
|
|
82
83
|
NFTokenBurn: "nftokenBurn",
|
|
83
84
|
NFTokenMint: "nftokenMint",
|
|
85
|
+
NFTokenModify: "NFTokenModify",
|
|
84
86
|
NFTokenCancelOffer: "nftokenCancelOffer",
|
|
85
87
|
NFTokenCreateOffer: "nftokenCreateOffer",
|
|
86
88
|
NFTokenAcceptOffer: "nftokenAcceptOffer",
|
|
@@ -136,6 +138,7 @@ const parserTypeFunc = {
|
|
|
136
138
|
trustline: trustline_1.default,
|
|
137
139
|
nftokenBurn: nftoken_burn_1.default,
|
|
138
140
|
nftokenMint: nftoken_mint_1.default,
|
|
141
|
+
NFTokenModify: nftoken_modify_1.default,
|
|
139
142
|
nftokenCancelOffer: nftoken_cancel_offer_1.default,
|
|
140
143
|
nftokenCreateOffer: nftoken_create_offer_1.default,
|
|
141
144
|
nftokenAcceptOffer: nftoken_accept_offer_1.default,
|
package/lib/types/nftokens.d.ts
CHANGED
|
@@ -36,6 +36,11 @@ export type FormattedNFTokenMintSpecification = {
|
|
|
36
36
|
destination?: FormattedDestinationAddress;
|
|
37
37
|
expiration?: number;
|
|
38
38
|
} & FormattedBaseSpecification;
|
|
39
|
+
export type FormattedNFTokenModifySpecification = {
|
|
40
|
+
nftokenID: string;
|
|
41
|
+
owner?: string;
|
|
42
|
+
uri?: string;
|
|
43
|
+
} & FormattedBaseSpecification;
|
|
39
44
|
export type FormattedNFTokenCancelOfferSpecification = {
|
|
40
45
|
nftokenOffers: string[];
|
|
41
46
|
} & 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.21",
|
|
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",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"@types/mocha": "^10.0.10",
|
|
70
70
|
"@types/nconf": "^0.10.7",
|
|
71
71
|
"@types/node": "^22.14.1",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
73
|
-
"@typescript-eslint/parser": "^8.
|
|
72
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
73
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
74
74
|
"chai": "^4.5.0",
|
|
75
75
|
"chai-as-promised": "^7.1.2",
|
|
76
76
|
"eslint": "^9.24.0",
|