@bithomp/xrpl-api 3.7.16 → 3.7.18
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/connection.js +9 -0
- package/lib/models/account_info.d.ts +2 -0
- package/lib/models/transactions/CronSet.d.ts +3 -0
- package/lib/models/transactions/CronSet.js +2 -0
- package/lib/parse/ledger/account-fields.d.ts +5 -0
- package/lib/parse/ledger/account-fields.js +43 -0
- package/lib/parse/ledger/account-settings-flags.d.ts +2 -0
- package/lib/parse/ledger/account-settings-flags.js +77 -0
- package/lib/parse/ledger/tx-cron-set-flags.d.ts +6 -0
- package/lib/parse/ledger/tx-cron-set-flags.js +8 -0
- package/lib/parse/outcome/account_setting_changes.d.ts +4 -0
- package/lib/parse/outcome/account_setting_changes.js +67 -0
- package/lib/parse/outcome/cron_changes.d.ts +13 -0
- package/lib/parse/outcome/cron_changes.js +72 -0
- package/lib/parse/outcome/index.d.ts +2 -0
- package/lib/parse/outcome/index.js +5 -1
- package/lib/parse/outcome.js +19 -0
- package/lib/parse/specification/cron-set.d.ts +3 -0
- package/lib/parse/specification/cron-set.js +62 -0
- package/lib/parse/specification/cron.d.ts +3 -0
- package/lib/parse/specification/cron.js +47 -0
- package/lib/parse/specification/settings.js +3 -41
- package/lib/parse/transaction.d.ts +4 -0
- package/lib/parse/transaction.js +6 -0
- package/lib/types/cron.d.ts +17 -0
- package/lib/types/cron.js +6 -0
- package/package.json +1 -1
package/lib/connection.js
CHANGED
|
@@ -373,6 +373,15 @@ class Connection extends events_1.EventEmitter {
|
|
|
373
373
|
});
|
|
374
374
|
this.client.on("error", (source, message, error) => {
|
|
375
375
|
try {
|
|
376
|
+
if (source === "noPermission") {
|
|
377
|
+
if (!error.status) {
|
|
378
|
+
error.status = "error";
|
|
379
|
+
}
|
|
380
|
+
if (this.client) {
|
|
381
|
+
this.client.requestManager.handleResponse(error);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
376
385
|
this.logger?.error({
|
|
377
386
|
service: "Bithomp::XRPL::Connection",
|
|
378
387
|
emit: "error",
|
|
@@ -69,7 +69,9 @@ export interface AccountRootFlagsKeysInterface {
|
|
|
69
69
|
disallowIncomingCheck?: boolean;
|
|
70
70
|
disallowIncomingPayChan?: boolean;
|
|
71
71
|
disallowIncomingTrustline?: boolean;
|
|
72
|
+
enableTransactionIDTracking?: boolean;
|
|
72
73
|
allowTrustLineClawback?: boolean;
|
|
74
|
+
allowTrustLineLocking?: boolean;
|
|
73
75
|
tshCollect?: boolean;
|
|
74
76
|
uriTokenIssuer?: boolean;
|
|
75
77
|
disallowIncomingRemit?: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AccountSet, SetRegularKey, SignerListSet } from "xrpl";
|
|
2
|
+
import { AccountFieldParametersInterface } from "../../models/account_info";
|
|
3
|
+
export declare function parseField(info: AccountFieldParametersInterface, value: any): any;
|
|
4
|
+
declare function parseAccountFields(tx: AccountSet | SetRegularKey | SignerListSet): object;
|
|
5
|
+
export default parseAccountFields;
|
|
@@ -0,0 +1,43 @@
|
|
|
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.parseField = parseField;
|
|
7
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const account_info_1 = require("../../models/account_info");
|
|
9
|
+
function parseField(info, value) {
|
|
10
|
+
if (info.encoding === "hex" && !info.length) {
|
|
11
|
+
return Buffer.from(value, "hex").toString("ascii");
|
|
12
|
+
}
|
|
13
|
+
if (info.shift) {
|
|
14
|
+
return new bignumber_js_1.default(value).shiftedBy(-info.shift).toNumber();
|
|
15
|
+
}
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function parseAccountFields(tx) {
|
|
19
|
+
const settings = {};
|
|
20
|
+
for (const fieldName in account_info_1.AccountFields) {
|
|
21
|
+
const fieldValue = tx[fieldName];
|
|
22
|
+
if (fieldValue != null) {
|
|
23
|
+
const info = account_info_1.AccountFields[fieldName];
|
|
24
|
+
settings[info.name] = parseField(info, fieldValue);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (tx.ClearFlag === account_info_1.AccountSetFlags.authorizedMinter && !settings.nftokenMinter) {
|
|
28
|
+
settings.nftokenMinter = "";
|
|
29
|
+
}
|
|
30
|
+
if (tx.SignerEntries && Array.isArray(tx.SignerEntries) && tx.SignerEntries.length > 0) {
|
|
31
|
+
settings.signerEntries = tx.SignerEntries.map((entry) => {
|
|
32
|
+
return {
|
|
33
|
+
account: entry.SignerEntry.Account,
|
|
34
|
+
signerWeight: entry.SignerEntry.SignerWeight,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (tx.SignerQuorum) {
|
|
39
|
+
settings.signerQuorum = tx.SignerQuorum;
|
|
40
|
+
}
|
|
41
|
+
return settings;
|
|
42
|
+
}
|
|
43
|
+
exports.default = parseAccountFields;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseAccountSettingsFlags = parseAccountSettingsFlags;
|
|
4
|
+
const account_info_1 = require("../../models/account_info");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const client_1 = require("../../client");
|
|
7
|
+
function parseAccountSettingsFlags(setFlag, clearFlag) {
|
|
8
|
+
const settings = {};
|
|
9
|
+
if (setFlag === undefined && clearFlag === undefined) {
|
|
10
|
+
return settings;
|
|
11
|
+
}
|
|
12
|
+
const key = setFlag !== undefined ? setFlag : clearFlag;
|
|
13
|
+
const value = setFlag !== undefined ? true : false;
|
|
14
|
+
switch (key) {
|
|
15
|
+
case account_info_1.AccountSetFlags.requireDestinationTag:
|
|
16
|
+
settings.requireDestTag = value;
|
|
17
|
+
break;
|
|
18
|
+
case account_info_1.AccountSetFlags.requireAuthorization:
|
|
19
|
+
settings.requireAuth = value;
|
|
20
|
+
break;
|
|
21
|
+
case account_info_1.AccountSetFlags.depositAuth:
|
|
22
|
+
settings.depositAuth = value;
|
|
23
|
+
break;
|
|
24
|
+
case account_info_1.AccountSetFlags.disallowIncomingXRP:
|
|
25
|
+
settings.disallowXRP = value;
|
|
26
|
+
break;
|
|
27
|
+
case account_info_1.AccountSetFlags.disableMasterKey:
|
|
28
|
+
settings.disableMaster = value;
|
|
29
|
+
break;
|
|
30
|
+
case account_info_1.AccountSetFlags.enableTransactionIDTracking:
|
|
31
|
+
settings.enableTransactionIDTracking = value;
|
|
32
|
+
break;
|
|
33
|
+
case account_info_1.AccountSetFlags.noFreeze:
|
|
34
|
+
settings.noFreeze = value;
|
|
35
|
+
break;
|
|
36
|
+
case account_info_1.AccountSetFlags.globalFreeze:
|
|
37
|
+
settings.globalFreeze = value;
|
|
38
|
+
break;
|
|
39
|
+
case account_info_1.AccountSetFlags.defaultRipple:
|
|
40
|
+
settings.defaultRipple = value;
|
|
41
|
+
break;
|
|
42
|
+
case account_info_1.AccountSetFlags.disallowIncomingNFTokenOffer:
|
|
43
|
+
settings.disallowIncomingNFTokenOffer = value;
|
|
44
|
+
break;
|
|
45
|
+
case account_info_1.AccountSetFlags.disallowIncomingCheck:
|
|
46
|
+
settings.disallowIncomingCheck = value;
|
|
47
|
+
break;
|
|
48
|
+
case account_info_1.AccountSetFlags.disallowIncomingPayChan:
|
|
49
|
+
settings.disallowIncomingPayChan = value;
|
|
50
|
+
break;
|
|
51
|
+
case account_info_1.AccountSetFlags.disallowIncomingTrustline:
|
|
52
|
+
settings.disallowIncomingTrustline = value;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const nativeCurrency = (0, client_1.getNativeCurrency)();
|
|
56
|
+
if (nativeCurrency === common_1.XAHAU_NATIVE_CURRENCY) {
|
|
57
|
+
switch (key) {
|
|
58
|
+
case account_info_1.AccountSetFlags.tshCollect:
|
|
59
|
+
settings.tshCollect = value;
|
|
60
|
+
break;
|
|
61
|
+
case account_info_1.AccountSetFlags.disallowIncomingRemit:
|
|
62
|
+
settings.disallowIncomingRemit = value;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
switch (key) {
|
|
68
|
+
case account_info_1.AccountSetFlags.allowTrustLineClawback:
|
|
69
|
+
settings.allowTrustLineClawback = value;
|
|
70
|
+
break;
|
|
71
|
+
case account_info_1.AccountSetFlags.allowTrustLineLocking:
|
|
72
|
+
settings.allowTrustLineLocking = value;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return settings;
|
|
77
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const cron_1 = require("../../types/cron");
|
|
4
|
+
const flags_1 = require("./flags");
|
|
5
|
+
function parseTxCronSetFlags(value, options = {}) {
|
|
6
|
+
return (0, flags_1.parseFlags)(value, cron_1.CronSetFlagsKeys, options);
|
|
7
|
+
}
|
|
8
|
+
exports.default = parseTxCronSetFlags;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TransactionMetadata } from "xrpl";
|
|
2
|
+
import { AccountRootFlagsKeysInterface } from "../../models/account_info";
|
|
3
|
+
declare function parseAccountSettingChanges(metadata: TransactionMetadata): AccountRootFlagsKeysInterface | undefined;
|
|
4
|
+
export { parseAccountSettingChanges };
|
|
@@ -0,0 +1,67 @@
|
|
|
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.parseAccountSettingChanges = parseAccountSettingChanges;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const account_info_1 = require("../../models/account_info");
|
|
9
|
+
const account_fields_1 = require("../ledger/account-fields");
|
|
10
|
+
function summarizeSetting(modifiedNode) {
|
|
11
|
+
const settings = {};
|
|
12
|
+
const oldFlags = lodash_1.default.get(modifiedNode.PreviousFields, "Flags");
|
|
13
|
+
const newFlags = lodash_1.default.get(modifiedNode.FinalFields, "Flags");
|
|
14
|
+
if (oldFlags != null && newFlags != null) {
|
|
15
|
+
const changedFlags = oldFlags ^ newFlags;
|
|
16
|
+
const setFlags = newFlags & changedFlags;
|
|
17
|
+
const clearedFlags = oldFlags & changedFlags;
|
|
18
|
+
Object.entries((0, account_info_1.getAccountRootFlagsKeys)()).forEach((entry) => {
|
|
19
|
+
const [flagName, flagValue] = entry;
|
|
20
|
+
if (setFlags & flagValue) {
|
|
21
|
+
settings[flagName] = true;
|
|
22
|
+
}
|
|
23
|
+
else if (clearedFlags & flagValue) {
|
|
24
|
+
settings[flagName] = false;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const oldAccountTxnIDField = lodash_1.default.get(modifiedNode.PreviousFields, "AccountTxnID");
|
|
29
|
+
const newAccountTxnIDField = lodash_1.default.get(modifiedNode.FinalFields, "AccountTxnID");
|
|
30
|
+
if (newAccountTxnIDField && !oldAccountTxnIDField) {
|
|
31
|
+
settings.enableTransactionIDTracking = true;
|
|
32
|
+
}
|
|
33
|
+
else if (oldAccountTxnIDField && !newAccountTxnIDField) {
|
|
34
|
+
settings.enableTransactionIDTracking = false;
|
|
35
|
+
}
|
|
36
|
+
for (const fieldName in account_info_1.AccountFields) {
|
|
37
|
+
const oldFieldValue = lodash_1.default.get(modifiedNode.PreviousFields, fieldName);
|
|
38
|
+
const newFieldValue = lodash_1.default.get(modifiedNode.FinalFields, fieldName);
|
|
39
|
+
if (oldFieldValue !== undefined && newFieldValue !== undefined && oldFieldValue !== newFieldValue) {
|
|
40
|
+
const info = account_info_1.AccountFields[fieldName];
|
|
41
|
+
settings[info.name] = (0, account_fields_1.parseField)(info, newFieldValue);
|
|
42
|
+
}
|
|
43
|
+
else if (oldFieldValue !== undefined && newFieldValue === undefined) {
|
|
44
|
+
const info = account_info_1.AccountFields[fieldName];
|
|
45
|
+
settings[info.name] = null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return settings;
|
|
49
|
+
}
|
|
50
|
+
function parseAccountSettingChanges(metadata) {
|
|
51
|
+
const affectedNodes = metadata.AffectedNodes.filter((affectedNode) => {
|
|
52
|
+
if (!affectedNode.ModifiedNode) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const node = affectedNode.ModifiedNode;
|
|
56
|
+
return node.LedgerEntryType === "AccountRoot";
|
|
57
|
+
});
|
|
58
|
+
if (affectedNodes.length !== 1) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const modifiedNode = affectedNodes[0].ModifiedNode;
|
|
62
|
+
const settings = summarizeSetting(modifiedNode);
|
|
63
|
+
if (Object.keys(settings).length === 0) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return settings;
|
|
67
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface FormattedCronSummaryInterface {
|
|
2
|
+
status?: "created" | "cancelled" | "executed" | "modified";
|
|
3
|
+
cronIndex?: string;
|
|
4
|
+
previousCronIndex?: string;
|
|
5
|
+
owner?: string;
|
|
6
|
+
startTime?: number;
|
|
7
|
+
repeatCount?: number;
|
|
8
|
+
delaySeconds?: number;
|
|
9
|
+
previousTxnID?: string;
|
|
10
|
+
previousTxnLgrSeq?: number;
|
|
11
|
+
}
|
|
12
|
+
declare function parseCronChanges(tx: any): FormattedCronSummaryInterface | undefined;
|
|
13
|
+
export { parseCronChanges };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCronChanges = parseCronChanges;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const ledger_1 = require("../../models/ledger");
|
|
7
|
+
function parseCronStatus(tx, currentNode, previousNode) {
|
|
8
|
+
if (tx.TransactionType === "Cron") {
|
|
9
|
+
return "executed";
|
|
10
|
+
}
|
|
11
|
+
if (tx.TransactionType === "CronSet") {
|
|
12
|
+
if (currentNode.diffType === "CreatedNode" && previousNode && previousNode.diffType === "DeletedNode") {
|
|
13
|
+
return "modified";
|
|
14
|
+
}
|
|
15
|
+
if (currentNode.diffType === "CreatedNode" && !previousNode) {
|
|
16
|
+
return "created";
|
|
17
|
+
}
|
|
18
|
+
if (tx.Flags === 1) {
|
|
19
|
+
return "cancelled";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function summarizeCron(tx, currentNode, previousNode) {
|
|
25
|
+
const final = currentNode.diffType === "CreatedNode" ? currentNode.newFields : currentNode.finalFields;
|
|
26
|
+
const summary = {
|
|
27
|
+
status: parseCronStatus(tx, currentNode, previousNode),
|
|
28
|
+
cronIndex: currentNode.ledgerIndex,
|
|
29
|
+
owner: final.Owner,
|
|
30
|
+
startTime: (0, ledger_1.ledgerTimeToTimestamp)(final.StartTime),
|
|
31
|
+
repeatCount: final.RepeatCount,
|
|
32
|
+
delaySeconds: final.DelaySeconds,
|
|
33
|
+
};
|
|
34
|
+
if (previousNode) {
|
|
35
|
+
summary.previousCronIndex = previousNode.ledgerIndex;
|
|
36
|
+
const previous = previousNode.finalFields;
|
|
37
|
+
if (previous.PreviousTxnID) {
|
|
38
|
+
summary.previousTxnID = previous.PreviousTxnID;
|
|
39
|
+
}
|
|
40
|
+
if (previous.PreviousTxnLgrSeq) {
|
|
41
|
+
summary.previousTxnLgrSeq = previous.PreviousTxnLgrSeq;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return (0, common_1.removeUndefined)(summary);
|
|
45
|
+
}
|
|
46
|
+
function parseCronChanges(tx) {
|
|
47
|
+
const affectedNodes = tx.meta.AffectedNodes.filter((affectedNode) => {
|
|
48
|
+
const node = affectedNode.CreatedNode || affectedNode.ModifiedNode || affectedNode.DeletedNode;
|
|
49
|
+
return node.LedgerEntryType === "Cron";
|
|
50
|
+
});
|
|
51
|
+
if (affectedNodes.length > 2) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
let currentNode;
|
|
55
|
+
let previousNode;
|
|
56
|
+
if (affectedNodes.length === 2) {
|
|
57
|
+
const firstNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
58
|
+
const secondNode = (0, utils_1.normalizeNode)(affectedNodes[1]);
|
|
59
|
+
if (firstNode.diffType === "DeletedNode") {
|
|
60
|
+
previousNode = firstNode;
|
|
61
|
+
currentNode = secondNode;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
previousNode = secondNode;
|
|
65
|
+
currentNode = firstNode;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
currentNode = (0, utils_1.normalizeNode)(affectedNodes[0]);
|
|
70
|
+
}
|
|
71
|
+
return summarizeCron(tx, currentNode, previousNode);
|
|
72
|
+
}
|
|
@@ -22,3 +22,5 @@ export { parseCredentialChanges } from "./credential_changes";
|
|
|
22
22
|
export { parseDelegateChanges } from "./delegate_changes";
|
|
23
23
|
export { parseRemarksChanges } from "./remarks_changes";
|
|
24
24
|
export { parseAmendmentChanges } from "./amendment_changes";
|
|
25
|
+
export { parseCronChanges } from "./cron_changes";
|
|
26
|
+
export { parseAccountSettingChanges } from "./account_setting_changes";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseAmendmentChanges = exports.parseRemarksChanges = exports.parseDelegateChanges = exports.parseCredentialChanges = 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;
|
|
3
|
+
exports.parseAccountSettingChanges = exports.parseCronChanges = exports.parseAmendmentChanges = exports.parseRemarksChanges = exports.parseDelegateChanges = exports.parseCredentialChanges = 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");
|
|
@@ -49,3 +49,7 @@ var remarks_changes_1 = require("./remarks_changes");
|
|
|
49
49
|
Object.defineProperty(exports, "parseRemarksChanges", { enumerable: true, get: function () { return remarks_changes_1.parseRemarksChanges; } });
|
|
50
50
|
var amendment_changes_1 = require("./amendment_changes");
|
|
51
51
|
Object.defineProperty(exports, "parseAmendmentChanges", { enumerable: true, get: function () { return amendment_changes_1.parseAmendmentChanges; } });
|
|
52
|
+
var cron_changes_1 = require("./cron_changes");
|
|
53
|
+
Object.defineProperty(exports, "parseCronChanges", { enumerable: true, get: function () { return cron_changes_1.parseCronChanges; } });
|
|
54
|
+
var account_setting_changes_1 = require("./account_setting_changes");
|
|
55
|
+
Object.defineProperty(exports, "parseAccountSettingChanges", { enumerable: true, get: function () { return account_setting_changes_1.parseAccountSettingChanges; } });
|
package/lib/parse/outcome.js
CHANGED
|
@@ -42,7 +42,9 @@ const MPTOKEN_TYPES = [
|
|
|
42
42
|
const CREDENTIAL_TYPES = ["CredentialCreate", "CredentialAccept", "CredentialDelete"];
|
|
43
43
|
const DELEGATE_TYPES = ["DelegateSet"];
|
|
44
44
|
const REMARKS_TYPES = ["SetRemarks"];
|
|
45
|
+
const CRON_TYPES = ["Cron", "CronSet"];
|
|
45
46
|
const AMENDMENT_TYPES = ["EnableAmendment"];
|
|
47
|
+
const ACCOUNT_SETTING_TYPES = ["AccountSet"];
|
|
46
48
|
function parseOutcome(tx, nativeCurrency, definitions) {
|
|
47
49
|
const metadata = tx.meta || tx.metaData;
|
|
48
50
|
if (!metadata) {
|
|
@@ -53,6 +55,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
53
55
|
result: tx.meta.TransactionResult,
|
|
54
56
|
timestamp: (0, utils_1.parseTimestamp)(tx.date),
|
|
55
57
|
fee: (0, common_1.dropsToXrp)(tx.Fee),
|
|
58
|
+
settingsChanges: getSettingsChanges(tx),
|
|
56
59
|
balanceChanges,
|
|
57
60
|
lockedBalanceChanges: getLockedBalanceChanges(tx),
|
|
58
61
|
orderbookChanges: getOrderbookChanges(tx),
|
|
@@ -73,6 +76,7 @@ function parseOutcome(tx, nativeCurrency, definitions) {
|
|
|
73
76
|
credentialChanges: getCredentialChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
74
77
|
delegateChanges: getDelegateChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
75
78
|
remarksChanges: getRemarksChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
79
|
+
cronChanges: getCronChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
76
80
|
unlReportChanges: getUNLReportChanges(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
77
81
|
hooksExecutions: getHooksExecutions(tx, nativeCurrency || (0, client_1.getNativeCurrency)()),
|
|
78
82
|
emittedTxns: getEmittedTxns(tx, nativeCurrency || (0, client_1.getNativeCurrency)(), definitions),
|
|
@@ -122,6 +126,12 @@ function getAmendmentChanges(tx) {
|
|
|
122
126
|
}
|
|
123
127
|
return (0, index_1.parseAmendmentChanges)(tx);
|
|
124
128
|
}
|
|
129
|
+
function getSettingsChanges(tx) {
|
|
130
|
+
if (!ACCOUNT_SETTING_TYPES.includes(tx.TransactionType)) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
return (0, index_1.parseAccountSettingChanges)(tx.meta);
|
|
134
|
+
}
|
|
125
135
|
function getAffectedObjects(tx) {
|
|
126
136
|
if (!NFTOKEN_TYPES.includes(tx.TransactionType) && !URITOKEN_TYPES.includes(tx.TransactionType)) {
|
|
127
137
|
return undefined;
|
|
@@ -243,3 +253,12 @@ function getRemarksChanges(tx, nativeCurrency) {
|
|
|
243
253
|
}
|
|
244
254
|
return (0, index_1.parseRemarksChanges)(tx);
|
|
245
255
|
}
|
|
256
|
+
function getCronChanges(tx, nativeCurrency) {
|
|
257
|
+
if (nativeCurrency !== common_1.XAHAU_NATIVE_CURRENCY) {
|
|
258
|
+
return undefined;
|
|
259
|
+
}
|
|
260
|
+
if (!CRON_TYPES.includes(tx.TransactionType)) {
|
|
261
|
+
return undefined;
|
|
262
|
+
}
|
|
263
|
+
return (0, index_1.parseCronChanges)(tx);
|
|
264
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const assert = __importStar(require("assert"));
|
|
40
|
+
const common_1 = require("../../common");
|
|
41
|
+
const ledger_1 = require("../../models/ledger");
|
|
42
|
+
const tx_cron_set_flags_1 = __importDefault(require("../ledger/tx-cron-set-flags"));
|
|
43
|
+
const emit_details_1 = require("../ledger/emit_details");
|
|
44
|
+
const memos_1 = require("../ledger/memos");
|
|
45
|
+
const signers_1 = require("../ledger/signers");
|
|
46
|
+
const regular_key_1 = require("../ledger/regular-key");
|
|
47
|
+
const source_1 = require("../ledger/source");
|
|
48
|
+
function parseCronSet(tx) {
|
|
49
|
+
assert.ok(tx.TransactionType === "CronSet");
|
|
50
|
+
return (0, common_1.removeUndefined)({
|
|
51
|
+
signers: (0, signers_1.parseSigners)(tx),
|
|
52
|
+
signer: (0, regular_key_1.parseSignerRegularKey)(tx),
|
|
53
|
+
source: (0, source_1.parseSource)(tx),
|
|
54
|
+
startTime: tx.StartTime && (0, ledger_1.ledgerTimeToTimestamp)(tx.StartTime),
|
|
55
|
+
repeatCount: tx.RepeatCount,
|
|
56
|
+
delaySeconds: tx.DelaySeconds,
|
|
57
|
+
flags: (0, tx_cron_set_flags_1.default)(tx.Flags),
|
|
58
|
+
emittedDetails: (0, emit_details_1.parseEmittedDetails)(tx),
|
|
59
|
+
memos: (0, memos_1.parseMemos)(tx),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
exports.default = parseCronSet;
|
|
@@ -0,0 +1,47 @@
|
|
|
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 source_1 = require("../ledger/source");
|
|
39
|
+
const account_1 = require("../ledger/account");
|
|
40
|
+
function parseCron(tx) {
|
|
41
|
+
assert.ok(tx.TransactionType === "Cron");
|
|
42
|
+
return (0, common_1.removeUndefined)({
|
|
43
|
+
source: (0, source_1.parseSource)(tx),
|
|
44
|
+
owner: tx.Owner ? (0, account_1.parseAccount)(tx.Owner) : undefined,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
exports.default = parseCron;
|
|
@@ -36,11 +36,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
40
39
|
const assert = __importStar(require("assert"));
|
|
41
|
-
const account_info_1 = require("../../models/account_info");
|
|
42
40
|
const common_1 = require("../../common");
|
|
43
|
-
const
|
|
41
|
+
const account_fields_1 = __importDefault(require("../ledger/account-fields"));
|
|
44
42
|
const emit_details_1 = require("../ledger/emit_details");
|
|
45
43
|
const tx_account_set_flags_1 = __importDefault(require("../ledger/tx-account-set-flags"));
|
|
46
44
|
const memos_1 = require("../ledger/memos");
|
|
@@ -48,43 +46,7 @@ const signers_1 = require("../ledger/signers");
|
|
|
48
46
|
const regular_key_1 = require("../ledger/regular-key");
|
|
49
47
|
const delegate_1 = require("../ledger/delegate");
|
|
50
48
|
const source_1 = require("../ledger/source");
|
|
51
|
-
|
|
52
|
-
const modifiedNodes = tx.meta.AffectedNodes.filter((node) => node.ModifiedNode?.LedgerEntryType === "AccountRoot");
|
|
53
|
-
assert.ok(modifiedNodes.length === 1);
|
|
54
|
-
return modifiedNodes[0].ModifiedNode;
|
|
55
|
-
}
|
|
56
|
-
function parseSettingsFlags(tx) {
|
|
57
|
-
const settings = {};
|
|
58
|
-
if (tx.TransactionType !== "AccountSet") {
|
|
59
|
-
return settings;
|
|
60
|
-
}
|
|
61
|
-
const node = getAccountRootModifiedNode(tx);
|
|
62
|
-
const oldFlags = lodash_1.default.get(node.PreviousFields, "Flags");
|
|
63
|
-
const newFlags = lodash_1.default.get(node.FinalFields, "Flags");
|
|
64
|
-
if (oldFlags != null && newFlags != null) {
|
|
65
|
-
const changedFlags = oldFlags ^ newFlags;
|
|
66
|
-
const setFlags = newFlags & changedFlags;
|
|
67
|
-
const clearedFlags = oldFlags & changedFlags;
|
|
68
|
-
Object.entries((0, account_info_1.getAccountRootFlagsKeys)()).forEach((entry) => {
|
|
69
|
-
const [flagName, flagValue] = entry;
|
|
70
|
-
if (setFlags & flagValue) {
|
|
71
|
-
settings[flagName] = true;
|
|
72
|
-
}
|
|
73
|
-
else if (clearedFlags & flagValue) {
|
|
74
|
-
settings[flagName] = false;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const oldField = lodash_1.default.get(node.PreviousFields, "AccountTxnID");
|
|
79
|
-
const newField = lodash_1.default.get(node.FinalFields, "AccountTxnID");
|
|
80
|
-
if (newField && !oldField) {
|
|
81
|
-
settings.enableTransactionIDTracking = true;
|
|
82
|
-
}
|
|
83
|
-
else if (oldField && !newField) {
|
|
84
|
-
settings.enableTransactionIDTracking = false;
|
|
85
|
-
}
|
|
86
|
-
return settings;
|
|
87
|
-
}
|
|
49
|
+
const account_settings_flags_1 = require("../ledger/account-settings-flags");
|
|
88
50
|
function parseSettings(tx, nativeCurrency) {
|
|
89
51
|
const txType = tx.TransactionType;
|
|
90
52
|
assert.ok(txType === "AccountSet" || txType === "SetRegularKey" || txType === "SignerListSet");
|
|
@@ -97,6 +59,6 @@ function parseSettings(tx, nativeCurrency) {
|
|
|
97
59
|
flags: (0, tx_account_set_flags_1.default)(tx.Flags, { nativeCurrency }),
|
|
98
60
|
memos: (0, memos_1.parseMemos)(tx),
|
|
99
61
|
});
|
|
100
|
-
return Object.assign(baseSettings,
|
|
62
|
+
return Object.assign(baseSettings, (0, account_fields_1.default)(tx), (0, account_settings_flags_1.parseAccountSettingsFlags)(tx.SetFlag, tx.ClearFlag));
|
|
101
63
|
}
|
|
102
64
|
exports.default = parseSettings;
|
|
@@ -84,6 +84,8 @@ import parseCredentialAccept from "./specification/credential-accept";
|
|
|
84
84
|
import parseCredentialDelete from "./specification/credential-delete";
|
|
85
85
|
import parseGenesisMint from "./specification/genesis-mint";
|
|
86
86
|
import parseBatch from "./specification/batch";
|
|
87
|
+
import parseCron from "./specification/cron";
|
|
88
|
+
import parseCronSet from "./specification/cron-set";
|
|
87
89
|
import parseAmendment from "./specification/amendment";
|
|
88
90
|
import parseFeeUpdate from "./specification/fee-update";
|
|
89
91
|
import parseUNLModify from "./specification/unl-modify";
|
|
@@ -144,6 +146,8 @@ export declare const parserTypeFunc: {
|
|
|
144
146
|
SetRemarks: typeof parseSetRemarks;
|
|
145
147
|
genesisMint: typeof parseGenesisMint;
|
|
146
148
|
Batch: typeof parseBatch;
|
|
149
|
+
Cron: typeof parseCron;
|
|
150
|
+
CronSet: typeof parseCronSet;
|
|
147
151
|
amendment: typeof parseAmendment;
|
|
148
152
|
feeUpdate: typeof parseFeeUpdate;
|
|
149
153
|
UNLModify: typeof parseUNLModify;
|
package/lib/parse/transaction.js
CHANGED
|
@@ -65,6 +65,8 @@ const credential_accept_1 = __importDefault(require("./specification/credential-
|
|
|
65
65
|
const credential_delete_1 = __importDefault(require("./specification/credential-delete"));
|
|
66
66
|
const genesis_mint_1 = __importDefault(require("./specification/genesis-mint"));
|
|
67
67
|
const batch_1 = __importDefault(require("./specification/batch"));
|
|
68
|
+
const cron_1 = __importDefault(require("./specification/cron"));
|
|
69
|
+
const cron_set_1 = __importDefault(require("./specification/cron-set"));
|
|
68
70
|
const amendment_1 = __importDefault(require("./specification/amendment"));
|
|
69
71
|
const fee_update_1 = __importDefault(require("./specification/fee-update"));
|
|
70
72
|
const unl_modify_1 = __importDefault(require("./specification/unl-modify"));
|
|
@@ -126,6 +128,8 @@ const transactionTypeToType = {
|
|
|
126
128
|
SetRemarks: "SetRemarks",
|
|
127
129
|
GenesisMint: "genesisMint",
|
|
128
130
|
Batch: "Batch",
|
|
131
|
+
Cron: "Cron",
|
|
132
|
+
CronSet: "CronSet",
|
|
129
133
|
EnableAmendment: "amendment",
|
|
130
134
|
SetFee: "feeUpdate",
|
|
131
135
|
UNLModify: "UNLModify",
|
|
@@ -189,6 +193,8 @@ exports.parserTypeFunc = {
|
|
|
189
193
|
SetRemarks: set_remarks_1.default,
|
|
190
194
|
genesisMint: genesis_mint_1.default,
|
|
191
195
|
Batch: batch_1.default,
|
|
196
|
+
Cron: cron_1.default,
|
|
197
|
+
CronSet: cron_set_1.default,
|
|
192
198
|
amendment: amendment_1.default,
|
|
193
199
|
feeUpdate: fee_update_1.default,
|
|
194
200
|
UNLModify: unl_modify_1.default,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CronSetFlags } from "../models/transactions/CronSet";
|
|
2
|
+
import { TxGlobalFlagsKeysInterface } from "./global";
|
|
3
|
+
import { FormattedBaseSpecification } from "./specification";
|
|
4
|
+
export declare const CronSetFlagsKeys: {
|
|
5
|
+
cronUnset: CronSetFlags;
|
|
6
|
+
};
|
|
7
|
+
export interface CronSetFlagsKeysInterface extends TxGlobalFlagsKeysInterface {
|
|
8
|
+
cronUnset?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export type FormattedCronSetSpecification = {
|
|
11
|
+
startTime?: number;
|
|
12
|
+
repeatCount?: number;
|
|
13
|
+
delaySeconds?: number;
|
|
14
|
+
} & FormattedBaseSpecification;
|
|
15
|
+
export type FormattedCronSpecification = {
|
|
16
|
+
owner?: string;
|
|
17
|
+
} & FormattedBaseSpecification;
|