@bithomp/xrpl-api 2.5.7 → 2.6.0
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/client.d.ts +2 -0
- package/lib/client.js +9 -1
- package/lib/ledger/account_objects.js +1 -1
- package/lib/ledger/ledger_entry.d.ts +1 -1
- package/lib/ledger/transaction.js +6 -1
- package/lib/models/account_object.d.ts +1 -1
- package/lib/models/account_uritokens.d.ts +11 -0
- package/lib/models/account_uritokens.js +2 -0
- package/lib/models/index.d.ts +3 -1
- package/lib/models/index.js +6 -2
- package/lib/models/transaction.d.ts +1 -0
- package/lib/parse/ledger/amount.js +2 -1
- package/lib/parse/ledger/uri-token-flags.d.ts +1 -1
- package/lib/parse/ledger/uri-token-flags.js +2 -2
- package/lib/parse/ledger/uritoken-flags.d.ts +5 -0
- package/lib/parse/ledger/uritoken-flags.js +8 -0
- package/lib/parse/outcome/affected_objects.d.ts +1 -0
- package/lib/parse/outcome/affected_objects.js +39 -0
- package/lib/parse/outcome/balance_changes.js +2 -1
- package/lib/parse/outcome/index.d.ts +2 -0
- package/lib/parse/outcome/index.js +5 -1
- package/lib/parse/outcome/locked_balance_changes.js +2 -1
- package/lib/parse/outcome/orderbook_changes.js +3 -2
- package/lib/parse/outcome/orderbook_quality.js +3 -2
- package/lib/parse/outcome/uritoken_changes.d.ts +1 -0
- package/lib/parse/outcome/uritoken_changes.js +84 -0
- package/lib/parse/outcome/uritoken_sell_offer_changes.d.ts +1 -0
- package/lib/parse/outcome/uritoken_sell_offer_changes.js +99 -0
- package/lib/parse/outcome.js +4 -0
- package/lib/parse/specification/uritoken-burn.d.ts +3 -0
- package/lib/parse/specification/uritoken-burn.js +39 -0
- package/lib/parse/specification/uritoken-buy.d.ts +3 -0
- package/lib/parse/specification/uritoken-buy.js +40 -0
- package/lib/parse/specification/uritoken-cancel-sell-offer.d.ts +3 -0
- package/lib/parse/specification/uritoken-cancel-sell-offer.js +39 -0
- package/lib/parse/specification/uritoken-create-sell-offer.d.ts +3 -0
- package/lib/parse/specification/uritoken-create-sell-offer.js +41 -0
- package/lib/parse/specification/uritoken-mint.d.ts +3 -0
- package/lib/parse/specification/uritoken-mint.js +44 -0
- package/lib/parse/transaction.js +15 -0
- package/lib/parse/utils.js +3 -2
- package/lib/v1/common/types/objects/nftokens.d.ts +2 -1
- package/lib/v1/common/types/objects/uritokens.d.ts +36 -0
- package/lib/v1/common/types/objects/uritokens.js +6 -0
- package/lib/v1/common/utils.js +2 -1
- package/lib/v1/transaction/payment.js +5 -4
- package/lib/wallet.d.ts +1 -1
- package/lib/wallet.js +6 -4
- package/package.json +6 -6
package/lib/client.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface ClientOptions extends ConnectionOptions {
|
|
|
6
6
|
feeCushion?: number;
|
|
7
7
|
maxFeeXRP?: string;
|
|
8
8
|
logger?: any;
|
|
9
|
+
nativeCurrency?: "XRP" | "XAH";
|
|
9
10
|
loadBalancing?: boolean;
|
|
10
11
|
}
|
|
11
12
|
export interface ClientConnection {
|
|
@@ -18,4 +19,5 @@ export interface ClientConnection {
|
|
|
18
19
|
export declare function setup(servers: ClientConnection[], options?: ClientOptions): void;
|
|
19
20
|
export declare function connect(): Promise<void>;
|
|
20
21
|
export declare function disconnect(): void;
|
|
22
|
+
export declare function getNativeCurrency(): string;
|
|
21
23
|
export declare function findConnection(type?: string, url?: string, strongFilter?: boolean, hash?: string, networkID?: number): Connection | null;
|
package/lib/client.js
CHANGED
|
@@ -14,12 +14,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.findConnection = exports.disconnect = exports.connect = exports.setup = exports.logger = exports.feeCushion = void 0;
|
|
17
|
+
exports.findConnection = exports.getNativeCurrency = exports.disconnect = exports.connect = exports.setup = exports.logger = exports.feeCushion = void 0;
|
|
18
18
|
const connection_1 = require("./connection");
|
|
19
19
|
__exportStar(require("./ledger"), exports);
|
|
20
20
|
exports.feeCushion = 1.3;
|
|
21
21
|
let clientConnections = [];
|
|
22
22
|
let loadBalancing = false;
|
|
23
|
+
let nativeCurrency = "XRP";
|
|
23
24
|
function setup(servers, options = {}) {
|
|
24
25
|
exports.logger = options.logger;
|
|
25
26
|
exports.logger?.debug({
|
|
@@ -41,6 +42,9 @@ function setup(servers, options = {}) {
|
|
|
41
42
|
if (options.feeCushion) {
|
|
42
43
|
exports.feeCushion = options.feeCushion;
|
|
43
44
|
}
|
|
45
|
+
if (options.nativeCurrency) {
|
|
46
|
+
nativeCurrency = options.nativeCurrency;
|
|
47
|
+
}
|
|
44
48
|
loadBalancing = options.loadBalancing === true;
|
|
45
49
|
}
|
|
46
50
|
exports.setup = setup;
|
|
@@ -64,6 +68,10 @@ function disconnect() {
|
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
exports.disconnect = disconnect;
|
|
71
|
+
function getNativeCurrency() {
|
|
72
|
+
return nativeCurrency || "XRP";
|
|
73
|
+
}
|
|
74
|
+
exports.getNativeCurrency = getNativeCurrency;
|
|
67
75
|
function findConnection(type, url, strongFilter, hash, networkID) {
|
|
68
76
|
if (!strongFilter) {
|
|
69
77
|
if (clientConnections.length === 0) {
|
|
@@ -184,7 +184,7 @@ async function getAccountURITokensObjects(account, options = {}) {
|
|
|
184
184
|
ledger_hash: response.ledger_hash,
|
|
185
185
|
ledger_index: response.ledger_index,
|
|
186
186
|
validated: response.validated,
|
|
187
|
-
|
|
187
|
+
uritokens: uriTokens,
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
exports.getAccountURITokensObjects = getAccountURITokensObjects;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Connection } from "../connection";
|
|
2
2
|
import { LedgerIndex } from "../models/ledger";
|
|
3
|
-
import { URITokenInterface } from "../models/
|
|
3
|
+
import { URITokenInterface } from "../models/account_uritokens";
|
|
4
4
|
import { ErrorResponse } from "../models/base_model";
|
|
5
5
|
export interface GetLedgerEntryOptions {
|
|
6
6
|
ledgerIndex?: LedgerIndex;
|
|
@@ -197,12 +197,16 @@ async function legacyPayment(data, definitions) {
|
|
|
197
197
|
transaction.Sequence = paymentParams.sequence;
|
|
198
198
|
transaction.LastLedgerSequence = paymentParams.lastLedgerSequence;
|
|
199
199
|
const wallet = xrpl.Wallet.fromSeed(data.secret);
|
|
200
|
-
const signedTransaction = (0, wallet_1.
|
|
200
|
+
const signedTransaction = (0, wallet_1.signTransaction)(wallet, transaction, false, definitions).tx_blob;
|
|
201
201
|
return await submit(signedTransaction, { connection, definitions });
|
|
202
202
|
}
|
|
203
203
|
exports.legacyPayment = legacyPayment;
|
|
204
204
|
async function getAccountPaymentParams(account, connection) {
|
|
205
205
|
try {
|
|
206
|
+
connection = connection || Client.findConnection("submit") || undefined;
|
|
207
|
+
if (!connection) {
|
|
208
|
+
throw new Error("There is no connection");
|
|
209
|
+
}
|
|
206
210
|
const feePromise = new Promise(async (resolve) => {
|
|
207
211
|
const baseFee = await Client.getFee({ connection });
|
|
208
212
|
let fee = parseFloat(baseFee);
|
|
@@ -233,6 +237,7 @@ async function getAccountPaymentParams(account, connection) {
|
|
|
233
237
|
fee: result[0],
|
|
234
238
|
sequence: result[1],
|
|
235
239
|
lastLedgerSequence: result[2],
|
|
240
|
+
networkID: connection.getNetworkID(),
|
|
236
241
|
};
|
|
237
242
|
}
|
|
238
243
|
catch (e) {
|
|
@@ -48,7 +48,7 @@ export interface AccountURITokensInterface {
|
|
|
48
48
|
}
|
|
49
49
|
export interface AccountURITokensObjectsResponse {
|
|
50
50
|
account: string;
|
|
51
|
-
|
|
51
|
+
uritokens: AccountURITokensInterface[];
|
|
52
52
|
ledger_hash?: string;
|
|
53
53
|
ledger_index?: number;
|
|
54
54
|
ledger_current_index?: number;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -6,11 +6,13 @@ export * from "./manifest";
|
|
|
6
6
|
export * from "./transaction";
|
|
7
7
|
export * from "./account_lines";
|
|
8
8
|
export * from "./account_namespace";
|
|
9
|
-
export * from "./
|
|
9
|
+
export * from "./account_uritokens";
|
|
10
10
|
export * from "./vl";
|
|
11
11
|
export { parseAffectedObjects } from "../parse/outcome/affected_objects";
|
|
12
12
|
export { parseNFTokenChanges } from "../parse/outcome/nftoken_changes";
|
|
13
13
|
export { parseNFTokenOfferChanges } from "../parse/outcome/nftoken_offer_changes";
|
|
14
|
+
export { parseURITokenChanges } from "../parse/outcome/uritoken_changes";
|
|
15
|
+
export { parseURITokenSellOfferChanges } from "../parse/outcome/uritoken_sell_offer_changes";
|
|
14
16
|
export { parseBalanceChanges } from "../parse/outcome/balance_changes";
|
|
15
17
|
export { parseLockedBalanceChanges } from "../parse/outcome/locked_balance_changes";
|
|
16
18
|
export { parseChannelChanges } from "../parse/outcome/channel_changes";
|
package/lib/models/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.parseURITokenFlags = exports.parseNFTokenCreateOffer = exports.parseNFTokenCancelOffer = exports.parseNFTokenAcceptOffer = exports.parseNFTOfferFlags = exports.parseNFTokenFlags = exports.parseNFTokenBurn = exports.parseNFTokenMint = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
20
|
+
exports.parseURITokenFlags = exports.parseNFTokenCreateOffer = exports.parseNFTokenCancelOffer = exports.parseNFTokenAcceptOffer = exports.parseNFTOfferFlags = exports.parseNFTokenFlags = exports.parseNFTokenBurn = exports.parseNFTokenMint = exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseURITokenSellOfferChanges = exports.parseURITokenChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
21
21
|
__exportStar(require("./account_info"), exports);
|
|
22
22
|
__exportStar(require("./account_nfts"), exports);
|
|
23
23
|
__exportStar(require("./account_object"), exports);
|
|
@@ -26,7 +26,7 @@ __exportStar(require("./manifest"), exports);
|
|
|
26
26
|
__exportStar(require("./transaction"), exports);
|
|
27
27
|
__exportStar(require("./account_lines"), exports);
|
|
28
28
|
__exportStar(require("./account_namespace"), exports);
|
|
29
|
-
__exportStar(require("./
|
|
29
|
+
__exportStar(require("./account_uritokens"), exports);
|
|
30
30
|
__exportStar(require("./vl"), exports);
|
|
31
31
|
var affected_objects_1 = require("../parse/outcome/affected_objects");
|
|
32
32
|
Object.defineProperty(exports, "parseAffectedObjects", { enumerable: true, get: function () { return affected_objects_1.parseAffectedObjects; } });
|
|
@@ -34,6 +34,10 @@ var nftoken_changes_1 = require("../parse/outcome/nftoken_changes");
|
|
|
34
34
|
Object.defineProperty(exports, "parseNFTokenChanges", { enumerable: true, get: function () { return nftoken_changes_1.parseNFTokenChanges; } });
|
|
35
35
|
var nftoken_offer_changes_1 = require("../parse/outcome/nftoken_offer_changes");
|
|
36
36
|
Object.defineProperty(exports, "parseNFTokenOfferChanges", { enumerable: true, get: function () { return nftoken_offer_changes_1.parseNFTokenOfferChanges; } });
|
|
37
|
+
var uritoken_changes_1 = require("../parse/outcome/uritoken_changes");
|
|
38
|
+
Object.defineProperty(exports, "parseURITokenChanges", { enumerable: true, get: function () { return uritoken_changes_1.parseURITokenChanges; } });
|
|
39
|
+
var uritoken_sell_offer_changes_1 = require("../parse/outcome/uritoken_sell_offer_changes");
|
|
40
|
+
Object.defineProperty(exports, "parseURITokenSellOfferChanges", { enumerable: true, get: function () { return uritoken_sell_offer_changes_1.parseURITokenSellOfferChanges; } });
|
|
37
41
|
var balance_changes_1 = require("../parse/outcome/balance_changes");
|
|
38
42
|
Object.defineProperty(exports, "parseBalanceChanges", { enumerable: true, get: function () { return balance_changes_1.parseBalanceChanges; } });
|
|
39
43
|
var locked_balance_changes_1 = require("../parse/outcome/locked_balance_changes");
|
|
@@ -30,6 +30,7 @@ export interface AccountPaymentParamsInterface {
|
|
|
30
30
|
fee?: string;
|
|
31
31
|
sequence?: number;
|
|
32
32
|
lastLedgerSequence?: number;
|
|
33
|
+
networkID?: number;
|
|
33
34
|
}
|
|
34
35
|
export declare function getTxDetails(tx: TransactionResponse, includeRawTransaction: boolean): FormattedTransaction;
|
|
35
36
|
export declare function getAccountTxDetails(tx: AccountTransaction, includeRawTransaction: boolean): FormattedTransaction;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const common_1 = require("../../common");
|
|
4
|
+
const client_1 = require("../../client");
|
|
4
5
|
function parseAmount(amount) {
|
|
5
6
|
if (typeof amount === "string") {
|
|
6
7
|
return {
|
|
7
|
-
currency:
|
|
8
|
+
currency: (0, client_1.getNativeCurrency)(),
|
|
8
9
|
value: (0, common_1.dropsToXrp)(amount),
|
|
9
10
|
};
|
|
10
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { URITokenFlagsKeysInterface } from "../../v1/common/types/objects/
|
|
1
|
+
import { URITokenFlagsKeysInterface } from "../../v1/common/types/objects/uritokens";
|
|
2
2
|
declare function parseURITokenFlags(value: number, options?: {
|
|
3
3
|
excludeFalse?: boolean;
|
|
4
4
|
}): URITokenFlagsKeysInterface;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const uritokens_1 = require("../../v1/common/types/objects/uritokens");
|
|
4
4
|
const flags_1 = require("./flags");
|
|
5
5
|
function parseURITokenFlags(value, options = {}) {
|
|
6
|
-
return (0, flags_1.parseFlags)(value,
|
|
6
|
+
return (0, flags_1.parseFlags)(value, uritokens_1.URITokenFlagsKeys, options);
|
|
7
7
|
}
|
|
8
8
|
exports.default = parseURITokenFlags;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const uritokens_1 = require("../../v1/common/types/objects/uritokens");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseURITokenFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, uritokens_1.URITokenFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseURITokenFlags;
|
|
@@ -9,6 +9,8 @@ const nftoken_offer_changes_1 = require("./nftoken_offer_changes");
|
|
|
9
9
|
const account_nfts_1 = require("../../models/account_nfts");
|
|
10
10
|
const nftoken_flags_1 = __importDefault(require("../ledger/nftoken-flags"));
|
|
11
11
|
const nftoken_offer_flags_1 = __importDefault(require("../ledger/nftoken-offer-flags"));
|
|
12
|
+
const uri_token_flags_1 = __importDefault(require("../ledger/uri-token-flags"));
|
|
13
|
+
const common_1 = require("../../common");
|
|
12
14
|
function parseAffectedObjects(tx) {
|
|
13
15
|
return new AffectedObjects(tx).call();
|
|
14
16
|
}
|
|
@@ -23,6 +25,7 @@ class AffectedObjects {
|
|
|
23
25
|
call() {
|
|
24
26
|
this.parseNFTokens();
|
|
25
27
|
this.parseNFTokenOffers();
|
|
28
|
+
this.parseURITokenChanges();
|
|
26
29
|
if (Object.keys(this.affectedObjects).length > 0) {
|
|
27
30
|
return this.affectedObjects;
|
|
28
31
|
}
|
|
@@ -106,4 +109,40 @@ class AffectedObjects {
|
|
|
106
109
|
this.affectedObjects.nftokenOffers = nftokenOffers;
|
|
107
110
|
}
|
|
108
111
|
}
|
|
112
|
+
parseURITokenChanges() {
|
|
113
|
+
const uritokens = {};
|
|
114
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
115
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
116
|
+
if (node?.LedgerEntryType === "URIToken" && node?.LedgerIndex) {
|
|
117
|
+
const uritokenID = node.LedgerIndex;
|
|
118
|
+
if (affectedNode.CreatedNode) {
|
|
119
|
+
uritokens[uritokenID] = (0, common_1.removeUndefined)({
|
|
120
|
+
uritokenID,
|
|
121
|
+
flags: (0, uri_token_flags_1.default)(node.NewFields.Flags),
|
|
122
|
+
uri: node.NewFields.URI,
|
|
123
|
+
digest: node.NewFields.Digest,
|
|
124
|
+
issuer: node.NewFields.Issuer,
|
|
125
|
+
owner: node.NewFields.Owner,
|
|
126
|
+
amount: node.NewFields.Amount,
|
|
127
|
+
destination: node.NewFields.Destination,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
if (affectedNode.ModifiedNode || affectedNode.DeletedNode) {
|
|
131
|
+
uritokens[uritokenID] = (0, common_1.removeUndefined)({
|
|
132
|
+
uritokenID,
|
|
133
|
+
flags: (0, uri_token_flags_1.default)(node.FinalFields.Flags),
|
|
134
|
+
uri: node.FinalFields.URI,
|
|
135
|
+
digest: node.FinalFields.Digest,
|
|
136
|
+
issuer: node.FinalFields.Issuer,
|
|
137
|
+
owner: node.FinalFields.Owner,
|
|
138
|
+
amount: node.FinalFields.Amount,
|
|
139
|
+
destination: node.FinalFields.Destination,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (Object.keys(uritokens).length > 0) {
|
|
145
|
+
this.affectedObjects.uritokens = uritokens;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
109
148
|
}
|
|
@@ -8,6 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
const utils_1 = require("../../v1/common/utils");
|
|
11
|
+
const client_1 = require("../../client");
|
|
11
12
|
function groupByAddress(balanceChanges) {
|
|
12
13
|
var grouped = lodash_1.default.groupBy(balanceChanges, function (node) {
|
|
13
14
|
return node.address;
|
|
@@ -49,7 +50,7 @@ function parseXRPQuantity(node, valueParser) {
|
|
|
49
50
|
address: node.finalFields.Account || node.newFields.Account,
|
|
50
51
|
balance: {
|
|
51
52
|
counterparty: "",
|
|
52
|
-
currency:
|
|
53
|
+
currency: (0, client_1.getNativeCurrency)(),
|
|
53
54
|
value: (0, common_1.dropsToXrp)(value).toString(),
|
|
54
55
|
},
|
|
55
56
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export { parseAffectedObjects } from "./affected_objects";
|
|
2
2
|
export { parseNFTokenChanges } from "./nftoken_changes";
|
|
3
3
|
export { parseNFTokenOfferChanges } from "./nftoken_offer_changes";
|
|
4
|
+
export { parseURITokenChanges } from "./uritoken_changes";
|
|
5
|
+
export { parseURITokenSellOfferChanges } from "./uritoken_sell_offer_changes";
|
|
4
6
|
export { parseBalanceChanges } from "./balance_changes";
|
|
5
7
|
export { parseLockedBalanceChanges } from "./locked_balance_changes";
|
|
6
8
|
export { parseChannelChanges } from "./channel_changes";
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseOrderbookChanges = exports.parseChannelChanges = exports.parseLockedBalanceChanges = exports.parseBalanceChanges = exports.parseNFTokenOfferChanges = exports.parseNFTokenChanges = exports.parseAffectedObjects = void 0;
|
|
3
|
+
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");
|
|
7
7
|
Object.defineProperty(exports, "parseNFTokenChanges", { enumerable: true, get: function () { return nftoken_changes_1.parseNFTokenChanges; } });
|
|
8
8
|
var nftoken_offer_changes_1 = require("./nftoken_offer_changes");
|
|
9
9
|
Object.defineProperty(exports, "parseNFTokenOfferChanges", { enumerable: true, get: function () { return nftoken_offer_changes_1.parseNFTokenOfferChanges; } });
|
|
10
|
+
var uritoken_changes_1 = require("./uritoken_changes");
|
|
11
|
+
Object.defineProperty(exports, "parseURITokenChanges", { enumerable: true, get: function () { return uritoken_changes_1.parseURITokenChanges; } });
|
|
12
|
+
var uritoken_sell_offer_changes_1 = require("./uritoken_sell_offer_changes");
|
|
13
|
+
Object.defineProperty(exports, "parseURITokenSellOfferChanges", { enumerable: true, get: function () { return uritoken_sell_offer_changes_1.parseURITokenSellOfferChanges; } });
|
|
10
14
|
var balance_changes_1 = require("./balance_changes");
|
|
11
15
|
Object.defineProperty(exports, "parseBalanceChanges", { enumerable: true, get: function () { return balance_changes_1.parseBalanceChanges; } });
|
|
12
16
|
var locked_balance_changes_1 = require("./locked_balance_changes");
|
|
@@ -8,6 +8,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
8
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
9
|
const common_1 = require("../../common");
|
|
10
10
|
const utils_1 = require("../../v1/common/utils");
|
|
11
|
+
const client_1 = require("../../client");
|
|
11
12
|
function groupByAddress(lockedBalanceChanges) {
|
|
12
13
|
const grouped = lodash_1.default.groupBy(lockedBalanceChanges, function (node) {
|
|
13
14
|
return node.address;
|
|
@@ -49,7 +50,7 @@ function parseXRPQuantity(node, valueParser) {
|
|
|
49
50
|
address: node.finalFields.Account || node.newFields.Account,
|
|
50
51
|
lockedBalance: {
|
|
51
52
|
counterparty: "",
|
|
52
|
-
currency:
|
|
53
|
+
currency: (0, client_1.getNativeCurrency)(),
|
|
53
54
|
value: (0, common_1.dropsToXrp)(value).toString(),
|
|
54
55
|
},
|
|
55
56
|
};
|
|
@@ -12,6 +12,7 @@ const models_1 = require("../../models");
|
|
|
12
12
|
const utils_1 = require("../../v1/common/utils");
|
|
13
13
|
const orderbook_quality_1 = require("./orderbook_quality");
|
|
14
14
|
const currency_amount_1 = __importDefault(require("../ledger/currency-amount"));
|
|
15
|
+
const client_1 = require("../../client");
|
|
15
16
|
const lsfSell = 0x00020000;
|
|
16
17
|
function convertOrderChange(order) {
|
|
17
18
|
var takerGets = order.taker_gets;
|
|
@@ -39,8 +40,8 @@ function getExpirationTime(node) {
|
|
|
39
40
|
function getQuality(node) {
|
|
40
41
|
var takerGets = node.finalFields.TakerGets || node.newFields.TakerGets;
|
|
41
42
|
var takerPays = node.finalFields.TakerPays || node.newFields.TakerPays;
|
|
42
|
-
var takerGetsCurrency = takerGets.currency ||
|
|
43
|
-
var takerPaysCurrency = takerPays.currency ||
|
|
43
|
+
var takerGetsCurrency = takerGets.currency || (0, client_1.getNativeCurrency)();
|
|
44
|
+
var takerPaysCurrency = takerPays.currency || (0, client_1.getNativeCurrency)();
|
|
44
45
|
var bookDirectory = node.finalFields.BookDirectory || node.newFields.BookDirectory;
|
|
45
46
|
var qualityHex = bookDirectory.substring(bookDirectory.length - 16);
|
|
46
47
|
return (0, orderbook_quality_1.parseOrderbookQuality)(qualityHex, takerGetsCurrency, takerPaysCurrency);
|
|
@@ -29,9 +29,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.parseOrderbookQuality = void 0;
|
|
30
30
|
const assert = __importStar(require("assert"));
|
|
31
31
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
32
|
+
const client_1 = require("../../client");
|
|
32
33
|
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
|
|
33
|
-
var numeratorShift = takerPaysCurrency ===
|
|
34
|
-
var denominatorShift = takerGetsCurrency ===
|
|
34
|
+
var numeratorShift = takerPaysCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
35
|
+
var denominatorShift = takerGetsCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
35
36
|
var shift = numeratorShift - denominatorShift;
|
|
36
37
|
return shift === 0 ? new bignumber_js_1.default(quality).toString() : new bignumber_js_1.default(quality).shiftedBy(shift).toString();
|
|
37
38
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseURITokenChanges(tx: object): object;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseURITokenChanges = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
function parseURITokenChanges(tx) {
|
|
6
|
+
return new URITokenChanges(tx).call();
|
|
7
|
+
}
|
|
8
|
+
exports.parseURITokenChanges = parseURITokenChanges;
|
|
9
|
+
class URITokenChanges {
|
|
10
|
+
constructor(tx) {
|
|
11
|
+
this.tx = tx;
|
|
12
|
+
this.changes = {};
|
|
13
|
+
}
|
|
14
|
+
call() {
|
|
15
|
+
if (this.hasAffectedNodes() === false) {
|
|
16
|
+
return this.changes;
|
|
17
|
+
}
|
|
18
|
+
this.parseAffectedNodes();
|
|
19
|
+
return this.changes;
|
|
20
|
+
}
|
|
21
|
+
hasAffectedNodes() {
|
|
22
|
+
if (this.tx.meta?.AffectedNodes === undefined) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (this.tx.meta?.AffectedNodes?.length === 0) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
addChange(account, change) {
|
|
31
|
+
if (!this.changes[account]) {
|
|
32
|
+
this.changes[account] = [];
|
|
33
|
+
}
|
|
34
|
+
this.changes[account].push((0, common_1.removeUndefined)(change));
|
|
35
|
+
}
|
|
36
|
+
parseAffectedNodes() {
|
|
37
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
38
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
39
|
+
if (node?.LedgerEntryType === "URIToken" && node?.LedgerIndex) {
|
|
40
|
+
const uritokenID = node.LedgerIndex;
|
|
41
|
+
if (affectedNode.CreatedNode) {
|
|
42
|
+
this.addChange(node.NewFields.Owner, {
|
|
43
|
+
status: "added",
|
|
44
|
+
flags: node.NewFields.Flags,
|
|
45
|
+
uritokenID,
|
|
46
|
+
uri: node.NewFields.URI,
|
|
47
|
+
digest: node.NewFields.Digest,
|
|
48
|
+
issuer: node.NewFields.Issuer,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (affectedNode.ModifiedNode) {
|
|
52
|
+
if (node.PreviousFields.Owner && node.PreviousFields.Owner !== node.FinalFields.Owner) {
|
|
53
|
+
this.addChange(node.PreviousFields.Owner, {
|
|
54
|
+
status: "removed",
|
|
55
|
+
flags: node.FinalFields.Flags,
|
|
56
|
+
uritokenID,
|
|
57
|
+
uri: node.FinalFields.URI,
|
|
58
|
+
digest: node.FinalFields.Digest,
|
|
59
|
+
issuer: node.FinalFields.Issuer,
|
|
60
|
+
});
|
|
61
|
+
this.addChange(node.FinalFields.Owner, {
|
|
62
|
+
status: "added",
|
|
63
|
+
flags: node.FinalFields.Flags,
|
|
64
|
+
uritokenID,
|
|
65
|
+
uri: node.FinalFields.URI,
|
|
66
|
+
digest: node.FinalFields.Digest,
|
|
67
|
+
issuer: node.FinalFields.Issuer,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (affectedNode.DeletedNode) {
|
|
72
|
+
this.addChange(node.FinalFields.Owner, {
|
|
73
|
+
status: "removed",
|
|
74
|
+
flags: node.FinalFields.Flags,
|
|
75
|
+
uritokenID,
|
|
76
|
+
uri: node.FinalFields.URI,
|
|
77
|
+
digest: node.FinalFields.Digest,
|
|
78
|
+
issuer: node.FinalFields.Issuer,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseURITokenSellOfferChanges(tx: object): object;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseURITokenSellOfferChanges = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
function parseURITokenSellOfferChanges(tx) {
|
|
6
|
+
return new URITokenSellOfferChanges(tx).call();
|
|
7
|
+
}
|
|
8
|
+
exports.parseURITokenSellOfferChanges = parseURITokenSellOfferChanges;
|
|
9
|
+
class URITokenSellOfferChanges {
|
|
10
|
+
constructor(tx) {
|
|
11
|
+
this.tx = tx;
|
|
12
|
+
this.changes = {};
|
|
13
|
+
}
|
|
14
|
+
call() {
|
|
15
|
+
if (this.hasAffectedNodes() === false) {
|
|
16
|
+
return this.changes;
|
|
17
|
+
}
|
|
18
|
+
this.parseAffectedNodes();
|
|
19
|
+
return this.changes;
|
|
20
|
+
}
|
|
21
|
+
hasAffectedNodes() {
|
|
22
|
+
if (this.tx.meta?.AffectedNodes === undefined) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (this.tx.meta?.AffectedNodes?.length === 0) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
addChange(account, change) {
|
|
31
|
+
if (!this.changes[account]) {
|
|
32
|
+
this.changes[account] = [];
|
|
33
|
+
}
|
|
34
|
+
this.changes[account].push((0, common_1.removeUndefined)(change));
|
|
35
|
+
}
|
|
36
|
+
parseAffectedNodes() {
|
|
37
|
+
for (const affectedNode of this.tx.meta.AffectedNodes) {
|
|
38
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
39
|
+
if (node?.LedgerEntryType === "URIToken" && node?.LedgerIndex) {
|
|
40
|
+
const uritokenID = node.LedgerIndex;
|
|
41
|
+
if (affectedNode.CreatedNode) {
|
|
42
|
+
if (node.NewFields.Amount || node.NewFields.Destination) {
|
|
43
|
+
this.addChange(node.NewFields.Owner, {
|
|
44
|
+
status: "created",
|
|
45
|
+
uritokenID,
|
|
46
|
+
amount: node.NewFields.Amount,
|
|
47
|
+
destination: node.NewFields.Destination,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (affectedNode.ModifiedNode) {
|
|
52
|
+
if (node.PreviousFields.Amount !== node.FinalFields.Amount ||
|
|
53
|
+
node.PreviousFields.Destination !== node.FinalFields.Destination) {
|
|
54
|
+
if (node.PreviousFields.Amount || node.PreviousFields.Destination) {
|
|
55
|
+
let owner;
|
|
56
|
+
if (node.PreviousFields.hasOwnProperty("Owner")) {
|
|
57
|
+
owner = node.PreviousFields.Owner;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
owner = node.FinalFields.Owner;
|
|
61
|
+
}
|
|
62
|
+
let destination;
|
|
63
|
+
if (node.PreviousFields.hasOwnProperty("Destination")) {
|
|
64
|
+
destination = node.PreviousFields.Destination;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
destination = node.FinalFields.Destination;
|
|
68
|
+
}
|
|
69
|
+
this.addChange(owner, {
|
|
70
|
+
status: "deleted",
|
|
71
|
+
uritokenID,
|
|
72
|
+
amount: node.PreviousFields.Amount,
|
|
73
|
+
destination,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (node.FinalFields.Amount || node.FinalFields.Destination) {
|
|
77
|
+
this.addChange(node.FinalFields.Owner, {
|
|
78
|
+
status: "created",
|
|
79
|
+
uritokenID,
|
|
80
|
+
amount: node.FinalFields.Amount,
|
|
81
|
+
destination: node.FinalFields.Destination,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (affectedNode.DeletedNode) {
|
|
87
|
+
if (node.FinalFields.Amount || node.FinalFields.Destination) {
|
|
88
|
+
this.addChange(node.FinalFields.Owner, {
|
|
89
|
+
status: "deleted",
|
|
90
|
+
uritokenID,
|
|
91
|
+
amount: node.FinalFields.Amount,
|
|
92
|
+
destination: node.FinalFields.Destination,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
package/lib/parse/outcome.js
CHANGED
|
@@ -57,6 +57,8 @@ function parseOutcome(tx) {
|
|
|
57
57
|
const channelChanges = (0, index_1.parseChannelChanges)(metadata);
|
|
58
58
|
const nftokenChanges = (0, index_1.parseNFTokenChanges)(tx);
|
|
59
59
|
const nftokenOfferChanges = (0, index_1.parseNFTokenOfferChanges)(tx);
|
|
60
|
+
const uritokenChanges = (0, index_1.parseURITokenChanges)(tx);
|
|
61
|
+
const uritokenSellOfferChanges = (0, index_1.parseURITokenSellOfferChanges)(tx);
|
|
60
62
|
const affectedObjects = (0, index_1.parseAffectedObjects)(tx);
|
|
61
63
|
removeEmptyCounterpartyInBalanceChanges(balanceChanges);
|
|
62
64
|
removeEmptyCounterpartyInBalanceChanges(lockedBalanceChanges);
|
|
@@ -71,6 +73,8 @@ function parseOutcome(tx) {
|
|
|
71
73
|
channelChanges,
|
|
72
74
|
nftokenChanges,
|
|
73
75
|
nftokenOfferChanges,
|
|
76
|
+
uritokenChanges: Object.keys(uritokenChanges).length > 0 ? uritokenChanges : undefined,
|
|
77
|
+
uritokenSellOfferChanges: Object.keys(uritokenSellOfferChanges).length > 0 ? uritokenSellOfferChanges : undefined,
|
|
74
78
|
affectedObjects: affectedObjects ? (0, common_1.removeUndefined)(affectedObjects) : undefined,
|
|
75
79
|
ledgerVersion: tx.ledger_index,
|
|
76
80
|
indexInLedger: tx.meta.TransactionIndex,
|
|
@@ -0,0 +1,39 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
function parseNFTokenBurn(tx) {
|
|
33
|
+
assert.ok(tx.TransactionType === "URITokenBurn");
|
|
34
|
+
return (0, common_1.removeUndefined)({
|
|
35
|
+
uritokenID: tx.URITokenID,
|
|
36
|
+
memos: (0, memos_1.default)(tx),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.default = parseNFTokenBurn;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
function parseNFTokenBurn(tx) {
|
|
33
|
+
assert.ok(tx.TransactionType === "URITokenBuy");
|
|
34
|
+
return (0, common_1.removeUndefined)({
|
|
35
|
+
uritokenID: tx.URITokenID,
|
|
36
|
+
amount: tx.Amount,
|
|
37
|
+
memos: (0, memos_1.default)(tx),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
exports.default = parseNFTokenBurn;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
function parseNFTokenBurn(tx) {
|
|
33
|
+
assert.ok(tx.TransactionType === "URITokenCancelSellOffer");
|
|
34
|
+
return (0, common_1.removeUndefined)({
|
|
35
|
+
uritokenID: tx.URITokenID,
|
|
36
|
+
memos: (0, memos_1.default)(tx),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.default = parseNFTokenBurn;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
function parseNFTokenBurn(tx) {
|
|
33
|
+
assert.ok(tx.TransactionType === "URITokenCreateSellOffer");
|
|
34
|
+
return (0, common_1.removeUndefined)({
|
|
35
|
+
uritokenID: tx.URITokenID,
|
|
36
|
+
amount: tx.Amount,
|
|
37
|
+
destination: tx.Destination,
|
|
38
|
+
memos: (0, memos_1.default)(tx),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.default = parseNFTokenBurn;
|
|
@@ -0,0 +1,44 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const assert = __importStar(require("assert"));
|
|
30
|
+
const common_1 = require("../../common");
|
|
31
|
+
const memos_1 = __importDefault(require("../ledger/memos"));
|
|
32
|
+
const uritoken_flags_1 = __importDefault(require("../ledger/uritoken-flags"));
|
|
33
|
+
function parseNFTokenBurn(tx) {
|
|
34
|
+
assert.ok(tx.TransactionType === "URITokenMint");
|
|
35
|
+
return (0, common_1.removeUndefined)({
|
|
36
|
+
uri: tx.URI,
|
|
37
|
+
flags: (0, uritoken_flags_1.default)(tx.Flags),
|
|
38
|
+
digest: tx.Digest,
|
|
39
|
+
amount: tx.Amount,
|
|
40
|
+
destination: tx.Destination,
|
|
41
|
+
memos: (0, memos_1.default)(tx),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.default = parseNFTokenBurn;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -28,6 +28,11 @@ const nftoken_mint_1 = __importDefault(require("./specification/nftoken-mint"));
|
|
|
28
28
|
const nftoken_cancel_offer_1 = __importDefault(require("./specification/nftoken-cancel-offer"));
|
|
29
29
|
const nftoken_create_offer_1 = __importDefault(require("./specification/nftoken-create-offer"));
|
|
30
30
|
const nftoken_accept_offer_1 = __importDefault(require("./specification/nftoken-accept-offer"));
|
|
31
|
+
const uritoken_burn_1 = __importDefault(require("./specification/uritoken-burn"));
|
|
32
|
+
const uritoken_buy_1 = __importDefault(require("./specification/uritoken-buy"));
|
|
33
|
+
const uritoken_cancel_sell_offer_1 = __importDefault(require("./specification/uritoken-cancel-sell-offer"));
|
|
34
|
+
const uritoken_create_sell_offer_1 = __importDefault(require("./specification/uritoken-create-sell-offer"));
|
|
35
|
+
const uritoken_mint_1 = __importDefault(require("./specification/uritoken-mint"));
|
|
31
36
|
const amendment_1 = __importDefault(require("./specification/amendment"));
|
|
32
37
|
const fee_update_1 = __importDefault(require("./specification/fee-update"));
|
|
33
38
|
const transactionTypeToType = {
|
|
@@ -55,6 +60,11 @@ const transactionTypeToType = {
|
|
|
55
60
|
NFTokenCancelOffer: "nftokenCancelOffer",
|
|
56
61
|
NFTokenCreateOffer: "nftokenCreateOffer",
|
|
57
62
|
NFTokenAcceptOffer: "nftokenAcceptOffer",
|
|
63
|
+
URITokenMint: "uritokenMint",
|
|
64
|
+
URITokenBurn: "uritokenBurn",
|
|
65
|
+
URITokenCreateSellOffer: "uritokenCreateSellOffer",
|
|
66
|
+
URITokenCancelSellOffer: "uritokenCancelSellOffer",
|
|
67
|
+
URITokenBuy: "uritokenBuy",
|
|
58
68
|
EnableAmendment: "amendment",
|
|
59
69
|
SetFee: "feeUpdate",
|
|
60
70
|
};
|
|
@@ -85,6 +95,11 @@ const parserTypeFunc = {
|
|
|
85
95
|
nftokenCancelOffer: nftoken_cancel_offer_1.default,
|
|
86
96
|
nftokenCreateOffer: nftoken_create_offer_1.default,
|
|
87
97
|
nftokenAcceptOffer: nftoken_accept_offer_1.default,
|
|
98
|
+
uritokenBurn: uritoken_burn_1.default,
|
|
99
|
+
uritokenBuy: uritoken_buy_1.default,
|
|
100
|
+
uritokenCreateSellOffer: uritoken_create_sell_offer_1.default,
|
|
101
|
+
uritokenCancelSellOffer: uritoken_cancel_sell_offer_1.default,
|
|
102
|
+
uritokenMint: uritoken_mint_1.default,
|
|
88
103
|
amendment: amendment_1.default,
|
|
89
104
|
feeUpdate: fee_update_1.default,
|
|
90
105
|
};
|
package/lib/parse/utils.js
CHANGED
|
@@ -7,9 +7,10 @@ exports.isPartialPayment = exports.adjustQualityForXRP = exports.parseTimestamp
|
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
const xrpl_1 = require("xrpl");
|
|
9
9
|
const models_1 = require("../models");
|
|
10
|
+
const client_1 = require("../client");
|
|
10
11
|
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
|
|
11
|
-
const numeratorShift = takerPaysCurrency ===
|
|
12
|
-
const denominatorShift = takerGetsCurrency ===
|
|
12
|
+
const numeratorShift = takerPaysCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
13
|
+
const denominatorShift = takerGetsCurrency === (0, client_1.getNativeCurrency)() ? -6 : 0;
|
|
13
14
|
const shift = numeratorShift - denominatorShift;
|
|
14
15
|
return shift === 0 ? quality : new bignumber_js_1.default(quality).shiftedBy(shift).toString();
|
|
15
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NFTokenMintFlags, NFTokenCreateOfferFlags } from "xrpl";
|
|
2
2
|
import { FormattedBaseSpecification } from "./specification";
|
|
3
|
+
import { Amount } from "../../../../types";
|
|
3
4
|
export declare const NFTokenFlagsKeys: {
|
|
4
5
|
burnable: NFTokenMintFlags;
|
|
5
6
|
onlyXRP: NFTokenMintFlags;
|
|
@@ -34,7 +35,7 @@ export type FormattedNFTokenCancelOfferSpecification = {
|
|
|
34
35
|
} & FormattedBaseSpecification;
|
|
35
36
|
export type FormattedNFTokenCreateOfferSpecification = {
|
|
36
37
|
nftokenID: string;
|
|
37
|
-
amount:
|
|
38
|
+
amount: Amount;
|
|
38
39
|
owner?: string;
|
|
39
40
|
destination?: string;
|
|
40
41
|
expiration?: number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { URITokenMintFlags } from "../../../../models/transactions/URITokenMint";
|
|
2
|
+
import { FormattedBaseSpecification } from "./specification";
|
|
3
|
+
import { Amount } from "../../../../types";
|
|
4
|
+
export declare const URITokenFlagsKeys: {
|
|
5
|
+
burnable: URITokenMintFlags;
|
|
6
|
+
};
|
|
7
|
+
export interface URITokenFlagsKeysInterface {
|
|
8
|
+
burnable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type FormattedURITokenBurnSpecification = {
|
|
11
|
+
uritokenID: string;
|
|
12
|
+
} & FormattedBaseSpecification;
|
|
13
|
+
export type FormattedURITokenBuySpecification = {
|
|
14
|
+
uritokenID: string;
|
|
15
|
+
amount: string;
|
|
16
|
+
} & FormattedBaseSpecification;
|
|
17
|
+
export type FormattedURITokenMintSpecification = {
|
|
18
|
+
uri?: string;
|
|
19
|
+
flags?: URITokenFlagsKeysInterface;
|
|
20
|
+
digest?: string;
|
|
21
|
+
amount: Amount;
|
|
22
|
+
destination?: string;
|
|
23
|
+
} & FormattedBaseSpecification;
|
|
24
|
+
export type FormattedURITokenCancelSellOfferSpecification = {
|
|
25
|
+
uritokenID: string;
|
|
26
|
+
} & FormattedBaseSpecification;
|
|
27
|
+
export type FormattedURITokenCreateSellOfferSpecification = {
|
|
28
|
+
uritokenID: string;
|
|
29
|
+
amount: string;
|
|
30
|
+
destination?: string;
|
|
31
|
+
} & FormattedBaseSpecification;
|
|
32
|
+
export type FormattedURITokenAcceptOfferSpecification = {
|
|
33
|
+
nftokenSellOffer?: string;
|
|
34
|
+
nftokenBuyOffer?: string;
|
|
35
|
+
nftokenBrokerFee?: string;
|
|
36
|
+
} & FormattedBaseSpecification;
|
package/lib/v1/common/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.normalizeNodes = exports.isValidSecret = exports.iso8601ToRippleTime = exports.toRippledAmount = void 0;
|
|
4
4
|
const ripple_keypairs_1 = require("ripple-keypairs");
|
|
5
5
|
const common_1 = require("../../common");
|
|
6
|
+
const client_1 = require("../../client");
|
|
6
7
|
function isValidSecret(secret) {
|
|
7
8
|
try {
|
|
8
9
|
(0, ripple_keypairs_1.deriveKeypair)(secret);
|
|
@@ -16,7 +17,7 @@ exports.isValidSecret = isValidSecret;
|
|
|
16
17
|
function toRippledAmount(amount) {
|
|
17
18
|
if (typeof amount === "string")
|
|
18
19
|
return amount;
|
|
19
|
-
if (amount.currency ===
|
|
20
|
+
if (amount.currency === (0, client_1.getNativeCurrency)()) {
|
|
20
21
|
return (0, common_1.xrpToDrops)(amount.value);
|
|
21
22
|
}
|
|
22
23
|
if (amount.currency === "drops") {
|
|
@@ -9,6 +9,7 @@ const xrpl_1 = require("xrpl");
|
|
|
9
9
|
const common_1 = require("../common");
|
|
10
10
|
const common_2 = require("../../common");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const client_1 = require("../../client");
|
|
12
13
|
function isMaxAdjustment(source) {
|
|
13
14
|
return source.maxAmount != null;
|
|
14
15
|
}
|
|
@@ -21,11 +22,11 @@ function isXRPToXRPPayment(payment) {
|
|
|
21
22
|
const destinationCurrency = isMinAdjustment(destination)
|
|
22
23
|
? destination.minAmount.currency
|
|
23
24
|
: destination.amount.currency;
|
|
24
|
-
return ((sourceCurrency ===
|
|
25
|
-
(destinationCurrency ===
|
|
25
|
+
return ((sourceCurrency === (0, client_1.getNativeCurrency)() || sourceCurrency === "drops") &&
|
|
26
|
+
(destinationCurrency === (0, client_1.getNativeCurrency)() || destinationCurrency === "drops"));
|
|
26
27
|
}
|
|
27
28
|
function isIOUWithoutCounterparty(amount) {
|
|
28
|
-
return amount && amount.currency !==
|
|
29
|
+
return amount && amount.currency !== (0, client_1.getNativeCurrency)() && amount.currency !== "drops" && amount.counterparty == null;
|
|
29
30
|
}
|
|
30
31
|
function applyAnyCounterpartyEncoding(payment) {
|
|
31
32
|
[payment.source, payment.destination].forEach((adjustment) => {
|
|
@@ -40,7 +41,7 @@ function createMaximalAmount(amount) {
|
|
|
40
41
|
const maxXRPValue = "100000000000";
|
|
41
42
|
const maxIOUValue = "999999999999999900000000000000000000000000000000000000000000000000000000000000000000000000000000";
|
|
42
43
|
let maxValue;
|
|
43
|
-
if (amount.currency ===
|
|
44
|
+
if (amount.currency === (0, client_1.getNativeCurrency)()) {
|
|
44
45
|
maxValue = maxXRPValue;
|
|
45
46
|
}
|
|
46
47
|
else if (amount.currency === "drops") {
|
package/lib/wallet.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ interface GenerateAddressInterface {
|
|
|
10
10
|
export declare function generateAddress(): GenerateAddressInterface;
|
|
11
11
|
export declare function isValidClassicAddress(address: string): boolean;
|
|
12
12
|
export declare function checksumClassicAddress(buffer: Buffer): Buffer;
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function signTransaction(wallet: Wallet, transaction: Transaction, multisign?: boolean | string, definitions?: XrplDefinitionsBase, validateTx?: boolean): {
|
|
14
14
|
tx_blob: string;
|
|
15
15
|
hash: string;
|
|
16
16
|
};
|
package/lib/wallet.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.DEFAULT_DEFINITIONS = exports.XrplDefinitions = exports.XrplDefinitionsBase = exports.
|
|
29
|
+
exports.DEFAULT_DEFINITIONS = exports.XrplDefinitions = exports.XrplDefinitionsBase = exports.signTransaction = exports.checksumClassicAddress = exports.isValidClassicAddress = exports.generateAddress = void 0;
|
|
30
30
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
31
31
|
const omitBy_1 = __importDefault(require("lodash/omitBy"));
|
|
32
32
|
const Crypto = __importStar(require("crypto"));
|
|
@@ -74,7 +74,7 @@ function checksumClassicAddress(buffer) {
|
|
|
74
74
|
return checksum;
|
|
75
75
|
}
|
|
76
76
|
exports.checksumClassicAddress = checksumClassicAddress;
|
|
77
|
-
function
|
|
77
|
+
function signTransaction(wallet, transaction, multisign, definitions, validateTx) {
|
|
78
78
|
let multisignAddress = false;
|
|
79
79
|
if (typeof multisign === "string" && multisign.startsWith("X")) {
|
|
80
80
|
multisignAddress = multisign;
|
|
@@ -87,7 +87,9 @@ function singTransaction(wallet, transaction, multisign, definitions) {
|
|
|
87
87
|
throw new xrpl_1.ValidationError('txJSON must not contain "TxnSignature" or "Signers" properties');
|
|
88
88
|
}
|
|
89
89
|
removeTrailingZeros(tx);
|
|
90
|
-
(
|
|
90
|
+
if (validateTx !== false) {
|
|
91
|
+
(0, xrpl_1.validate)(tx);
|
|
92
|
+
}
|
|
91
93
|
const txToSignAndEncode = { ...tx };
|
|
92
94
|
txToSignAndEncode.SigningPubKey = multisignAddress ? "" : wallet.publicKey;
|
|
93
95
|
if (multisignAddress) {
|
|
@@ -107,7 +109,7 @@ function singTransaction(wallet, transaction, multisign, definitions) {
|
|
|
107
109
|
hash: hashSignedTx(serialized, definitions),
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
|
-
exports.
|
|
112
|
+
exports.signTransaction = signTransaction;
|
|
111
113
|
function computeSignature(tx, privateKey, signAs, definitions) {
|
|
112
114
|
if (signAs) {
|
|
113
115
|
const classicAddress = (0, ripple_address_codec_1.isValidXAddress)(signAs) ? (0, ripple_address_codec_1.xAddressToClassicAddress)(signAs).classicAddress : signAs;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bithomp/xrpl-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
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",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"ripple-address-codec": "^4.3.1",
|
|
54
54
|
"ripple-binary-codec": "^1.10.0",
|
|
55
|
-
"xrpl": "^2.
|
|
55
|
+
"xrpl": "^2.13.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/chai": "^4.3.9",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"@types/lodash": "^4.14.200",
|
|
61
61
|
"@types/mocha": "^10.0.3",
|
|
62
62
|
"@types/nconf": "^0.10.5",
|
|
63
|
-
"@types/node": "^20.8.
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
65
|
-
"@typescript-eslint/parser": "^6.
|
|
63
|
+
"@types/node": "^20.8.9",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
65
|
+
"@typescript-eslint/parser": "^6.9.0",
|
|
66
66
|
"chai": "^4.3.10",
|
|
67
67
|
"chai-as-promised": "^7.1.1",
|
|
68
68
|
"mocha": "^10.2.0",
|
|
69
|
-
"nconf": "^0.12.
|
|
69
|
+
"nconf": "^0.12.1",
|
|
70
70
|
"prettier": "2.8.8",
|
|
71
71
|
"ts-jest": "^29.1.1",
|
|
72
72
|
"ts-node": "^10.9.1",
|