init
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
import { Payment } from '../models';
|
||||
export default function createCrossChainPayment(payment: Payment, destAccount: string): Payment;
|
||||
//# sourceMappingURL=createCrossChainPayment.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"createCrossChainPayment.d.ts","sourceRoot":"","sources":["../../../src/utils/createCrossChainPayment.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAmBnC,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAC7C,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,MAAM,GAClB,OAAO,CAgBT"}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const errors_1 = require("../errors");
|
||||
const stringConversion_1 = require("./stringConversion");
|
||||
function createCrossChainPayment(payment, destAccount) {
|
||||
var _a;
|
||||
const destAccountHex = (0, stringConversion_1.convertStringToHex)(destAccount);
|
||||
const destAccountMemo = { Memo: { MemoData: destAccountHex } };
|
||||
const memos = (_a = payment.Memos) !== null && _a !== void 0 ? _a : [];
|
||||
if (memos.length > 2) {
|
||||
throw new errors_1.XrplError('Cannot have more than 2 memos in a cross-chain transaction.');
|
||||
}
|
||||
const newMemos = [destAccountMemo, ...memos];
|
||||
const newPayment = Object.assign(Object.assign({}, payment), { Memos: newMemos });
|
||||
delete newPayment.TxnSignature;
|
||||
return newPayment;
|
||||
}
|
||||
exports.default = createCrossChainPayment;
|
||||
//# sourceMappingURL=createCrossChainPayment.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"createCrossChainPayment.js","sourceRoot":"","sources":["../../../src/utils/createCrossChainPayment.ts"],"names":[],"mappings":";;AAAA,sCAAqC;AAIrC,yDAAuD;AAgBvD,SAAwB,uBAAuB,CAC7C,OAAgB,EAChB,WAAmB;;IAEnB,MAAM,cAAc,GAAG,IAAA,qCAAkB,EAAC,WAAW,CAAC,CAAA;IACtD,MAAM,eAAe,GAAS,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,CAAA;IAEpE,MAAM,KAAK,GAAG,MAAA,OAAO,CAAC,KAAK,mCAAI,EAAE,CAAA;IACjC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QACpB,MAAM,IAAI,kBAAS,CACjB,6DAA6D,CAC9D,CAAA;KACF;IACD,MAAM,QAAQ,GAAG,CAAC,eAAe,EAAE,GAAG,KAAK,CAAC,CAAA;IAE5C,MAAM,UAAU,mCAAQ,OAAO,KAAE,KAAK,EAAE,QAAQ,GAAE,CAAA;IAClD,OAAO,UAAU,CAAC,YAAY,CAAA;IAE9B,OAAO,UAAU,CAAA;AACnB,CAAC;AAnBD,0CAmBC"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { deriveKeypair, deriveAddress } from 'ripple-keypairs';
|
||||
declare function deriveXAddress(options: {
|
||||
publicKey: string;
|
||||
tag: number | false;
|
||||
test: boolean;
|
||||
}): string;
|
||||
export { deriveKeypair, deriveAddress, deriveXAddress };
|
||||
//# sourceMappingURL=derive.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../../src/utils/derive.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAY9D,iBAAS,cAAc,CAAC,OAAO,EAAE;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,GAAG,EAAE,MAAM,GAAG,KAAK,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;CACd,GAAG,MAAM,CAGT;AAED,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,CAAA"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.deriveXAddress = exports.deriveAddress = exports.deriveKeypair = void 0;
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
Object.defineProperty(exports, "deriveKeypair", { enumerable: true, get: function () { return ripple_keypairs_1.deriveKeypair; } });
|
||||
Object.defineProperty(exports, "deriveAddress", { enumerable: true, get: function () { return ripple_keypairs_1.deriveAddress; } });
|
||||
function deriveXAddress(options) {
|
||||
const classicAddress = (0, ripple_keypairs_1.deriveAddress)(options.publicKey);
|
||||
return (0, ripple_address_codec_1.classicAddressToXAddress)(classicAddress, options.tag, options.test);
|
||||
}
|
||||
exports.deriveXAddress = deriveXAddress;
|
||||
//# sourceMappingURL=derive.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"derive.js","sourceRoot":"","sources":["../../../src/utils/derive.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,qDAA8D;AAqBrD,8FArBA,+BAAa,OAqBA;AAAE,8FArBA,+BAAa,OAqBA;AATrC,SAAS,cAAc,CAAC,OAIvB;IACC,MAAM,cAAc,GAAG,IAAA,+BAAa,EAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACvD,OAAO,IAAA,+CAAwB,EAAC,cAAc,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;AAC5E,CAAC;AAEsC,wCAAc"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { TransactionMetadata } from '../models/transactions/metadata';
|
||||
export default function getBalanceChanges(metadata: TransactionMetadata): Array<{
|
||||
account: string;
|
||||
balances: Array<{
|
||||
currency: string;
|
||||
issuer?: string;
|
||||
value: string;
|
||||
}>;
|
||||
}>;
|
||||
//# sourceMappingURL=getBalanceChanges.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getBalanceChanges.d.ts","sourceRoot":"","sources":["../../../src/utils/getBalanceChanges.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAQ,MAAM,iCAAiC,CAAA;AA6J3E,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,QAAQ,EAAE,mBAAmB,GAC5B,KAAK,CAAC;IACP,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,KAAK,CAAC;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,MAAM,CAAA;KACd,CAAC,CAAA;CACH,CAAC,CAmBD"}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const flatten_1 = __importDefault(require("lodash/flatten"));
|
||||
const groupBy_1 = __importDefault(require("lodash/groupBy"));
|
||||
const xrpConversion_1 = require("./xrpConversion");
|
||||
function normalizeNode(affectedNode) {
|
||||
const diffType = Object.keys(affectedNode)[0];
|
||||
const node = affectedNode[diffType];
|
||||
return Object.assign(Object.assign({}, node), { NodeType: diffType, LedgerEntryType: node.LedgerEntryType, LedgerIndex: node.LedgerIndex, NewFields: node.NewFields, FinalFields: node.FinalFields, PreviousFields: node.PreviousFields });
|
||||
}
|
||||
function normalizeNodes(metadata) {
|
||||
if (metadata.AffectedNodes.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return metadata.AffectedNodes.map(normalizeNode);
|
||||
}
|
||||
function groupByAccount(balanceChanges) {
|
||||
const grouped = (0, groupBy_1.default)(balanceChanges, (node) => node.account);
|
||||
return Object.entries(grouped).map(([account, items]) => {
|
||||
return { account, balances: items.map((item) => item.balance) };
|
||||
});
|
||||
}
|
||||
function getValue(balance) {
|
||||
if (typeof balance === 'string') {
|
||||
return new bignumber_js_1.default(balance);
|
||||
}
|
||||
return new bignumber_js_1.default(balance.value);
|
||||
}
|
||||
function computeBalanceChange(node) {
|
||||
var _a, _b, _c;
|
||||
let value = null;
|
||||
if ((_a = node.NewFields) === null || _a === void 0 ? void 0 : _a.Balance) {
|
||||
value = getValue(node.NewFields.Balance);
|
||||
}
|
||||
else if (((_b = node.PreviousFields) === null || _b === void 0 ? void 0 : _b.Balance) && ((_c = node.FinalFields) === null || _c === void 0 ? void 0 : _c.Balance)) {
|
||||
value = getValue(node.FinalFields.Balance).minus(getValue(node.PreviousFields.Balance));
|
||||
}
|
||||
if (value === null || value.isZero()) {
|
||||
return null;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
function getXRPQuantity(node) {
|
||||
var _a, _b, _c;
|
||||
const value = computeBalanceChange(node);
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
account: ((_b = (_a = node.FinalFields) === null || _a === void 0 ? void 0 : _a.Account) !== null && _b !== void 0 ? _b : (_c = node.NewFields) === null || _c === void 0 ? void 0 : _c.Account),
|
||||
balance: {
|
||||
currency: 'XRP',
|
||||
value: (0, xrpConversion_1.dropsToXrp)(value).toString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
function flipTrustlinePerspective(balanceChange) {
|
||||
const negatedBalance = new bignumber_js_1.default(balanceChange.balance.value).negated();
|
||||
return {
|
||||
account: balanceChange.balance.issuer,
|
||||
balance: {
|
||||
issuer: balanceChange.account,
|
||||
currency: balanceChange.balance.currency,
|
||||
value: negatedBalance.toString(),
|
||||
},
|
||||
};
|
||||
}
|
||||
function getTrustlineQuantity(node) {
|
||||
var _a, _b;
|
||||
const value = computeBalanceChange(node);
|
||||
if (value === null) {
|
||||
return null;
|
||||
}
|
||||
const fields = node.NewFields == null ? node.FinalFields : node.NewFields;
|
||||
const result = {
|
||||
account: (_a = fields === null || fields === void 0 ? void 0 : fields.LowLimit) === null || _a === void 0 ? void 0 : _a.issuer,
|
||||
balance: {
|
||||
issuer: (_b = fields === null || fields === void 0 ? void 0 : fields.HighLimit) === null || _b === void 0 ? void 0 : _b.issuer,
|
||||
currency: (fields === null || fields === void 0 ? void 0 : fields.Balance).currency,
|
||||
value: value.toString(),
|
||||
},
|
||||
};
|
||||
return [result, flipTrustlinePerspective(result)];
|
||||
}
|
||||
function getBalanceChanges(metadata) {
|
||||
const quantities = normalizeNodes(metadata).map((node) => {
|
||||
if (node.LedgerEntryType === 'AccountRoot') {
|
||||
const xrpQuantity = getXRPQuantity(node);
|
||||
if (xrpQuantity == null) {
|
||||
return [];
|
||||
}
|
||||
return [xrpQuantity];
|
||||
}
|
||||
if (node.LedgerEntryType === 'RippleState') {
|
||||
const trustlineQuantity = getTrustlineQuantity(node);
|
||||
if (trustlineQuantity == null) {
|
||||
return [];
|
||||
}
|
||||
return trustlineQuantity;
|
||||
}
|
||||
return [];
|
||||
});
|
||||
return groupByAccount((0, flatten_1.default)(quantities));
|
||||
}
|
||||
exports.default = getBalanceChanges;
|
||||
//# sourceMappingURL=getBalanceChanges.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getBalanceChanges.js","sourceRoot":"","sources":["../../../src/utils/getBalanceChanges.ts"],"names":[],"mappings":";;;;;AAAA,gEAAoC;AACpC,6DAAoC;AACpC,6DAAoC;AAKpC,mDAA4C;AAiC5C,SAAS,aAAa,CAAC,YAAkB;IACvC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAE7C,MAAM,IAAI,GAAG,YAAY,CAAC,QAAQ,CAAmB,CAAA;IACrD,uCACK,IAAI,KACP,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,IAAI,CAAC,eAAe,EACrC,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,SAAS,EAAE,IAAI,CAAC,SAAS,EACzB,WAAW,EAAE,IAAI,CAAC,WAAW,EAC7B,cAAc,EAAE,IAAI,CAAC,cAAc,IACpC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,QAA6B;IACnD,IAAI,QAAQ,CAAC,aAAa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zE,MAAM,MAAM,GAAG;QAEb,OAAO,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,0CAAE,MAAgB;QAC3C,OAAO,EAAE;YACP,MAAM,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,0CAAE,MAAM;YAEjC,QAAQ,EAAE,CAAC,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAgC,CAAA,CAAC,QAAQ;YAC5D,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE;SACxB;KACF,CAAA;IACD,OAAO,CAAC,MAAM,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC,CAAA;AACnD,CAAC;AAUD,SAAwB,iBAAiB,CACvC,QAA6B;IAS7B,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACvD,IAAI,IAAI,CAAC,eAAe,KAAK,aAAa,EAAE;YAC1C,MAAM,WAAW,GAAG,cAAc,CAAC,IAAI,CAAC,CAAA;YACxC,IAAI,WAAW,IAAI,IAAI,EAAE;gBACvB,OAAO,EAAE,CAAA;aACV;YACD,OAAO,CAAC,WAAW,CAAC,CAAA;SACrB;QACD,IAAI,IAAI,CAAC,eAAe,KAAK,aAAa,EAAE;YAC1C,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAA;YACpD,IAAI,iBAAiB,IAAI,IAAI,EAAE;gBAC7B,OAAO,EAAE,CAAA;aACV;YACD,OAAO,iBAAiB,CAAA;SACzB;QACD,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;IACF,OAAO,cAAc,CAAC,IAAA,iBAAO,EAAC,UAAU,CAAC,CAAC,CAAA;AAC5C,CAAC;AA5BD,oCA4BC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { TransactionMetadata } from '../models/transactions/metadata';
|
||||
export default function getNFTokenID(meta: TransactionMetadata): string | undefined;
|
||||
//# sourceMappingURL=getNFTokenID.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getNFTokenID.d.ts","sourceRoot":"","sources":["../../../src/utils/getNFTokenID.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,mBAAmB,EACpB,MAAM,iCAAiC,CAAA;AAgBxC,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,IAAI,EAAE,mBAAmB,GACxB,MAAM,GAAG,SAAS,CA0DpB"}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
||||
const metadata_1 = require("../models/transactions/metadata");
|
||||
function getNFTokenID(meta) {
|
||||
if (meta.AffectedNodes === undefined) {
|
||||
throw new TypeError(`Unable to parse the parameter given to getNFTokenID.
|
||||
'meta' must be the metadata from an NFTokenMint transaction. Received ${JSON.stringify(meta)} instead.`);
|
||||
}
|
||||
const affectedNodes = meta.AffectedNodes.filter((node) => {
|
||||
var _a;
|
||||
if ((0, metadata_1.isCreatedNode)(node)) {
|
||||
return node.CreatedNode.LedgerEntryType === 'NFTokenPage';
|
||||
}
|
||||
if ((0, metadata_1.isModifiedNode)(node)) {
|
||||
return (node.ModifiedNode.LedgerEntryType === 'NFTokenPage' &&
|
||||
Boolean((_a = node.ModifiedNode.PreviousFields) === null || _a === void 0 ? void 0 : _a.NFTokens));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const previousTokenIDSet = new Set((0, flatMap_1.default)(affectedNodes, (node) => {
|
||||
var _a;
|
||||
const nftokens = (0, metadata_1.isModifiedNode)(node)
|
||||
? (_a = node.ModifiedNode.PreviousFields) === null || _a === void 0 ? void 0 : _a.NFTokens
|
||||
: [];
|
||||
return nftokens.map((token) => token.NFToken.NFTokenID);
|
||||
}).filter((id) => Boolean(id)));
|
||||
const finalTokenIDs = (0, flatMap_1.default)(affectedNodes, (node) => {
|
||||
var _a, _b, _c, _d, _e, _f;
|
||||
return ((_f = ((_c = (_b = (_a = node.ModifiedNode) === null || _a === void 0 ? void 0 : _a.FinalFields) === null || _b === void 0 ? void 0 : _b.NFTokens) !== null && _c !== void 0 ? _c : (_e = (_d = node.CreatedNode) === null || _d === void 0 ? void 0 : _d.NewFields) === null || _e === void 0 ? void 0 : _e.NFTokens)) !== null && _f !== void 0 ? _f : []).map((token) => token.NFToken.NFTokenID);
|
||||
}).filter((nftokenID) => Boolean(nftokenID));
|
||||
const nftokenID = finalTokenIDs.find((id) => !previousTokenIDSet.has(id));
|
||||
return nftokenID;
|
||||
}
|
||||
exports.default = getNFTokenID;
|
||||
//# sourceMappingURL=getNFTokenID.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"getNFTokenID.js","sourceRoot":"","sources":["../../../src/utils/getNFTokenID.ts"],"names":[],"mappings":";;;;;AAAA,6DAAoC;AAEpC,8DAMwC;AAgBxC,SAAwB,YAAY,CAClC,IAAyB;IAGzB,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE;QACpC,MAAM,IAAI,SAAS,CAAC;4EACoD,IAAI,CAAC,SAAS,CACpF,IAAI,CACL,WAAW,CAAC,CAAA;KACd;IAeD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;;QACvD,IAAI,IAAA,wBAAa,EAAC,IAAI,CAAC,EAAE;YACvB,OAAO,IAAI,CAAC,WAAW,CAAC,eAAe,KAAK,aAAa,CAAA;SAC1D;QACD,IAAI,IAAA,yBAAc,EAAC,IAAI,CAAC,EAAE;YACxB,OAAO,CACL,IAAI,CAAC,YAAY,CAAC,eAAe,KAAK,aAAa;gBACnD,OAAO,CAAC,MAAA,IAAI,CAAC,YAAY,CAAC,cAAc,0CAAE,QAAQ,CAAC,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
|
||||
TRANSACTION_ID = 1415073280,
|
||||
TRANSACTION_NODE = 1397638144,
|
||||
INNER_NODE = 1296649728,
|
||||
LEAF_NODE = 1296846336,
|
||||
TRANSACTION_SIGN = 1398036480,
|
||||
TRANSACTION_SIGN_TESTNET = 1937012736,
|
||||
TRANSACTION_MULTISIGN = 1397576704,
|
||||
LEDGER = 1280791040
|
||||
}
|
||||
export default HashPrefix;
|
||||
//# sourceMappingURL=HashPrefix.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HashPrefix.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashes/HashPrefix.ts"],"names":[],"mappings":"AAaA,aAAK,UAAU;IAEb,cAAc,aAAa;IAG3B,gBAAgB,aAAa;IAG7B,UAAU,aAAa;IAGvB,SAAS,aAAa;IAGtB,gBAAgB,aAAa;IAG7B,wBAAwB,aAAa;IAGrC,qBAAqB,aAAa;IAGlC,MAAM,aAAa;CACpB;AAED,eAAe,UAAU,CAAA"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var HashPrefix;
|
||||
(function (HashPrefix) {
|
||||
HashPrefix[HashPrefix["TRANSACTION_ID"] = 1415073280] = "TRANSACTION_ID";
|
||||
HashPrefix[HashPrefix["TRANSACTION_NODE"] = 1397638144] = "TRANSACTION_NODE";
|
||||
HashPrefix[HashPrefix["INNER_NODE"] = 1296649728] = "INNER_NODE";
|
||||
HashPrefix[HashPrefix["LEAF_NODE"] = 1296846336] = "LEAF_NODE";
|
||||
HashPrefix[HashPrefix["TRANSACTION_SIGN"] = 1398036480] = "TRANSACTION_SIGN";
|
||||
HashPrefix[HashPrefix["TRANSACTION_SIGN_TESTNET"] = 1937012736] = "TRANSACTION_SIGN_TESTNET";
|
||||
HashPrefix[HashPrefix["TRANSACTION_MULTISIGN"] = 1397576704] = "TRANSACTION_MULTISIGN";
|
||||
HashPrefix[HashPrefix["LEDGER"] = 1280791040] = "LEDGER";
|
||||
})(HashPrefix || (HashPrefix = {}));
|
||||
exports.default = HashPrefix;
|
||||
//# sourceMappingURL=HashPrefix.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"HashPrefix.js","sourceRoot":"","sources":["../../../../src/utils/hashes/HashPrefix.ts"],"names":[],"mappings":";;AAaA,IAAK,UAwBJ;AAxBD,WAAK,UAAU;IAEb,wEAA2B,CAAA;IAG3B,4EAA6B,CAAA;IAG7B,gEAAuB,CAAA;IAGvB,8DAAsB,CAAA;IAGtB,4EAA6B,CAAA;IAG7B,4FAAqC,CAAA;IAGrC,sFAAkC,CAAA;IAGlC,wDAAmB,CAAA;AACrB,CAAC,EAxBI,UAAU,KAAV,UAAU,QAwBd;AAED,kBAAe,UAAU,CAAA"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { NodeType, Node } from './node';
|
||||
declare class InnerNode extends Node {
|
||||
leaves: {
|
||||
[slot: number]: Node | undefined;
|
||||
};
|
||||
type: NodeType;
|
||||
depth: number;
|
||||
empty: boolean;
|
||||
constructor(depth?: number);
|
||||
get hash(): string;
|
||||
addItem(tag: string, node: Node): void;
|
||||
setNode(slot: number, node: Node): void;
|
||||
getNode(slot: number): Node | undefined;
|
||||
}
|
||||
export default InnerNode;
|
||||
//# sourceMappingURL=InnerNode.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"InnerNode.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/InnerNode.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAWvC,cAAM,SAAU,SAAQ,IAAI;IACnB,MAAM,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;KAAE,CAAA;IAC5C,IAAI,EAAE,QAAQ,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,OAAO,CAAA;gBAOF,KAAK,SAAI;IAa5B,IAAW,IAAI,IAAI,MAAM,CAaxB;IASM,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAsCtC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAevC,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;CAM/C;AAED,eAAe,SAAS,CAAA"}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const errors_1 = require("../../../errors");
|
||||
const HashPrefix_1 = __importDefault(require("../HashPrefix"));
|
||||
const sha512Half_1 = __importDefault(require("../sha512Half"));
|
||||
const LeafNode_1 = __importDefault(require("./LeafNode"));
|
||||
const node_1 = require("./node");
|
||||
const HEX_ZERO = '0000000000000000000000000000000000000000000000000000000000000000';
|
||||
const SLOT_MAX = 15;
|
||||
const HEX = 16;
|
||||
class InnerNode extends node_1.Node {
|
||||
constructor(depth = 0) {
|
||||
super();
|
||||
this.leaves = {};
|
||||
this.type = node_1.NodeType.INNER;
|
||||
this.depth = depth;
|
||||
this.empty = true;
|
||||
}
|
||||
get hash() {
|
||||
if (this.empty) {
|
||||
return HEX_ZERO;
|
||||
}
|
||||
let hex = '';
|
||||
for (let iter = 0; iter <= SLOT_MAX; iter++) {
|
||||
const child = this.leaves[iter];
|
||||
const hash = child == null ? HEX_ZERO : child.hash;
|
||||
hex += hash;
|
||||
}
|
||||
const prefix = HashPrefix_1.default.INNER_NODE.toString(HEX);
|
||||
return (0, sha512Half_1.default)(prefix + hex);
|
||||
}
|
||||
addItem(tag, node) {
|
||||
const existingNode = this.getNode(parseInt(tag[this.depth], HEX));
|
||||
if (existingNode === undefined) {
|
||||
this.setNode(parseInt(tag[this.depth], HEX), node);
|
||||
return;
|
||||
}
|
||||
if (existingNode instanceof InnerNode) {
|
||||
existingNode.addItem(tag, node);
|
||||
}
|
||||
else if (existingNode instanceof LeafNode_1.default) {
|
||||
if (existingNode.tag === tag) {
|
||||
throw new errors_1.XrplError('Tried to add a node to a SHAMap that was already in there.');
|
||||
}
|
||||
else {
|
||||
const newInnerNode = new InnerNode(this.depth + 1);
|
||||
newInnerNode.addItem(existingNode.tag, existingNode);
|
||||
newInnerNode.addItem(tag, node);
|
||||
this.setNode(parseInt(tag[this.depth], HEX), newInnerNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
setNode(slot, node) {
|
||||
if (slot < 0 || slot > SLOT_MAX) {
|
||||
throw new errors_1.XrplError('Invalid slot: slot must be between 0-15.');
|
||||
}
|
||||
this.leaves[slot] = node;
|
||||
this.empty = false;
|
||||
}
|
||||
getNode(slot) {
|
||||
if (slot < 0 || slot > SLOT_MAX) {
|
||||
throw new errors_1.XrplError('Invalid slot: slot must be between 0-15.');
|
||||
}
|
||||
return this.leaves[slot];
|
||||
}
|
||||
}
|
||||
exports.default = InnerNode;
|
||||
//# sourceMappingURL=InnerNode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"InnerNode.js","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/InnerNode.ts"],"names":[],"mappings":";;;;;AAAA,4CAA2C;AAC3C,+DAAsC;AACtC,+DAAsC;AAEtC,0DAAiC;AACjC,iCAAuC;AAEvC,MAAM,QAAQ,GACZ,kEAAkE,CAAA;AAEpE,MAAM,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAM,GAAG,GAAG,EAAE,CAAA;AAKd,MAAM,SAAU,SAAQ,WAAI;IAW1B,YAAmB,KAAK,GAAG,CAAC;QAC1B,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,eAAQ,CAAC,KAAK,CAAA;Q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DAA4D,CAC7D,CAAA;aACF;iBAAM;gBACL,MAAM,YAAY,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;gBAGlD,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;gBACpD,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;gBAG/B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,EAAE,YAAY,CAAC,CAAA;aAC3D;SACF;IACH,CAAC;IASM,OAAO,CAAC,IAAY,EAAE,IAAU;QACrC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,QAAQ,EAAE;YAC/B,MAAM,IAAI,kBAAS,CAAC,0CAA0C,CAAC,CAAA;SAChE;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;QACxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IASM,OAAO,CAAC,IAAY;QACzB,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,QAAQ,EAAE;YAC/B,MAAM,IAAI,kBAAS,CAAC,0CAA0C,CAAC,CAAA;SAChE;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1B,CAAC;CACF;AAED,kBAAe,SAAS,CAAA"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { NodeType, Node } from './node';
|
||||
declare class LeafNode extends Node {
|
||||
tag: string;
|
||||
type: NodeType;
|
||||
data: string;
|
||||
constructor(tag: string, data: string, type: NodeType);
|
||||
get hash(): string;
|
||||
addItem(tag: string, node: Node): void;
|
||||
}
|
||||
export default LeafNode;
|
||||
//# sourceMappingURL=LeafNode.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LeafNode.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/LeafNode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAOvC,cAAM,QAAS,SAAQ,IAAI;IAClB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;gBASA,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ;IAa5D,IAAW,IAAI,IAAI,MAAM,CAiBxB;IASM,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;CAI9C;AAED,eAAe,QAAQ,CAAA"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const errors_1 = require("../../../errors");
|
||||
const HashPrefix_1 = __importDefault(require("../HashPrefix"));
|
||||
const sha512Half_1 = __importDefault(require("../sha512Half"));
|
||||
const node_1 = require("./node");
|
||||
const HEX = 16;
|
||||
class LeafNode extends node_1.Node {
|
||||
constructor(tag, data, type) {
|
||||
super();
|
||||
this.tag = tag;
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
get hash() {
|
||||
switch (this.type) {
|
||||
case node_1.NodeType.ACCOUNT_STATE: {
|
||||
const leafPrefix = HashPrefix_1.default.LEAF_NODE.toString(HEX);
|
||||
return (0, sha512Half_1.default)(leafPrefix + this.data + this.tag);
|
||||
}
|
||||
case node_1.NodeType.TRANSACTION_NO_METADATA: {
|
||||
const txIDPrefix = HashPrefix_1.default.TRANSACTION_ID.toString(HEX);
|
||||
return (0, sha512Half_1.default)(txIDPrefix + this.data);
|
||||
}
|
||||
case node_1.NodeType.TRANSACTION_METADATA: {
|
||||
const txNodePrefix = HashPrefix_1.default.TRANSACTION_NODE.toString(HEX);
|
||||
return (0, sha512Half_1.default)(txNodePrefix + this.data + this.tag);
|
||||
}
|
||||
default:
|
||||
throw new errors_1.XrplError('Tried to hash a SHAMap node of unknown type.');
|
||||
}
|
||||
}
|
||||
addItem(tag, node) {
|
||||
throw new errors_1.XrplError('Cannot call addItem on a LeafNode');
|
||||
this.addItem(tag, node);
|
||||
}
|
||||
}
|
||||
exports.default = LeafNode;
|
||||
//# sourceMappingURL=LeafNode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LeafNode.js","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/LeafNode.ts"],"names":[],"mappings":";;;;;AAAA,4CAA2C;AAC3C,+DAAsC;AACtC,+DAAsC;AAEtC,iCAAuC;AAEvC,MAAM,GAAG,GAAG,EAAE,CAAA;AAKd,MAAM,QAAS,SAAQ,WAAI;IAYzB,YAAmB,GAAW,EAAE,IAAY,EAAE,IAAc;QAC1D,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAQD,IAAW,IAAI;QACb,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,eAAQ,CAAC,aAAa,CAAC,CAAC;gBAC3B,MAAM,UAAU,GAAG,oBAAU,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBACrD,OAAO,IAAA,oBAAU,EAAC,UAAU,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;aACrD;YACD,KAAK,eAAQ,CAAC,uBAAuB,CAAC,CAAC;gBACrC,MAAM,UAAU,GAAG,oBAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBAC1D,OAAO,IAAA,oBAAU,EAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAA;aAC1C;YACD,KAAK,eAAQ,CAAC,oBAAoB,CAAC,CAAC;gBAClC,MAAM,YAAY,GAAG,oBAAU,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;gBAC9D,OAAO,IAAA,oBAAU,EAAC,YAAY,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;aACvD;YACD;gBACE,MAAM,IAAI,kBAAS,CAAC,8CAA8C,CAAC,CAAA;SACtE;IACH,CAAC;IASM,OAAO,CAAC,GAAW,EAAE,IAAU;QACpC,MAAM,IAAI,kBAAS,CAAC,mCAAmC,CAAC,CAAA;QACxD,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IACzB,CAAC;CACF;AAED,kBAAe,QAAQ,CAAA"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import InnerNode from './InnerNode';
|
||||
import { NodeType } from './node';
|
||||
declare class SHAMap {
|
||||
root: InnerNode;
|
||||
constructor();
|
||||
get hash(): string;
|
||||
addItem(tag: string, data: string, type: NodeType): void;
|
||||
}
|
||||
export * from './node';
|
||||
export default SHAMap;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAMjC,cAAM,MAAM;IACH,IAAI,EAAE,SAAS,CAAA;;IActB,IAAW,IAAI,IAAI,MAAM,CAExB;IASM,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI;CAGhE;AAED,cAAc,QAAQ,CAAA;AACtB,eAAe,MAAM,CAAA"}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const InnerNode_1 = __importDefault(require("./InnerNode"));
|
||||
const LeafNode_1 = __importDefault(require("./LeafNode"));
|
||||
class SHAMap {
|
||||
constructor() {
|
||||
this.root = new InnerNode_1.default(0);
|
||||
}
|
||||
get hash() {
|
||||
return this.root.hash;
|
||||
}
|
||||
addItem(tag, data, type) {
|
||||
this.root.addItem(tag, new LeafNode_1.default(tag, data, type));
|
||||
}
|
||||
}
|
||||
__exportStar(require("./node"), exports);
|
||||
exports.default = SHAMap;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,4DAAmC;AACnC,0DAAiC;AAOjC,MAAM,MAAM;IAMV;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAA;IAC9B,CAAC;IAOD,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAA;IACvB,CAAC;IASM,OAAO,CAAC,GAAW,EAAE,IAAY,EAAE,IAAc;QACtD,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,kBAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACvD,CAAC;CACF;AAED,yCAAsB;AACtB,kBAAe,MAAM,CAAA"}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
export declare enum NodeType {
|
||||
INNER = 1,
|
||||
TRANSACTION_NO_METADATA = 2,
|
||||
TRANSACTION_METADATA = 3,
|
||||
ACCOUNT_STATE = 4
|
||||
}
|
||||
export declare abstract class Node {
|
||||
abstract get hash(): string;
|
||||
abstract addItem(_tag: string, _node: Node): void;
|
||||
}
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/node.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,uBAAuB,IAAI;IAC3B,oBAAoB,IAAI;IACxB,aAAa,IAAI;CAClB;AAKD,8BAAsB,IAAI;IACxB,aAAoB,IAAI,IAAI,MAAM,CAAA;aAClB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI;CACzD"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Node = exports.NodeType = void 0;
|
||||
var NodeType;
|
||||
(function (NodeType) {
|
||||
NodeType[NodeType["INNER"] = 1] = "INNER";
|
||||
NodeType[NodeType["TRANSACTION_NO_METADATA"] = 2] = "TRANSACTION_NO_METADATA";
|
||||
NodeType[NodeType["TRANSACTION_METADATA"] = 3] = "TRANSACTION_METADATA";
|
||||
NodeType[NodeType["ACCOUNT_STATE"] = 4] = "ACCOUNT_STATE";
|
||||
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
||||
class Node {
|
||||
}
|
||||
exports.Node = Node;
|
||||
//# sourceMappingURL=node.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../../src/utils/hashes/SHAMap/node.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,yCAAS,CAAA;IACT,6EAA2B,CAAA;IAC3B,uEAAwB,CAAA;IACxB,yDAAiB,CAAA;AACnB,CAAC,EALW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAKnB;AAKD,MAAsB,IAAI;CAGzB;AAHD,oBAGC"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import type { Ledger } from '../../models/ledger';
|
||||
import { LedgerEntry } from '../../models/ledger';
|
||||
import { Transaction, TransactionMetadata } from '../../models/transactions';
|
||||
export declare function hashSignedTx(tx: Transaction | string): string;
|
||||
export declare function hashLedgerHeader(ledgerHeader: Ledger): string;
|
||||
export declare function hashTxTree(transactions: Array<Transaction & {
|
||||
metaData?: TransactionMetadata;
|
||||
}>): string;
|
||||
export declare function hashStateTree(entries: LedgerEntry[]): string;
|
||||
declare function hashLedger(ledger: Ledger, options?: {
|
||||
computeTreeHashes?: boolean;
|
||||
}): string;
|
||||
export default hashLedger;
|
||||
//# sourceMappingURL=hashLedger.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hashLedger.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashes/hashLedger.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AA8D5E,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,CAkB7D;AASD,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAgB7D;AASD,wBAAgB,UAAU,CACxB,YAAY,EAAE,KAAK,CAAC,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,mBAAmB,CAAA;CAAE,CAAC,GACpE,MAAM,CAWR;AASD,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAS5D;AAkED,iBAAS,UAAU,CACjB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IACP,iBAAiB,CAAC,EAAE,OAAO,CAAA;CACvB,GACL,MAAM,CAMR;AAED,eAAe,UAAU,CAAA"}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hashStateTree = exports.hashTxTree = exports.hashLedgerHeader = exports.hashSignedTx = void 0;
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const errors_1 = require("../../errors");
|
||||
const HashPrefix_1 = __importDefault(require("./HashPrefix"));
|
||||
const sha512Half_1 = __importDefault(require("./sha512Half"));
|
||||
const SHAMap_1 = __importStar(require("./SHAMap"));
|
||||
const HEX = 16;
|
||||
function intToHex(integer, byteLength) {
|
||||
const foo = Number(integer)
|
||||
.toString(HEX)
|
||||
.padStart(byteLength * 2, '0');
|
||||
return foo;
|
||||
}
|
||||
function bytesToHex(bytes) {
|
||||
return Buffer.from(bytes).toString('hex');
|
||||
}
|
||||
function bigintToHex(integerString, byteLength) {
|
||||
const hex = new bignumber_js_1.default(integerString).toString(HEX);
|
||||
return hex.padStart(byteLength * 2, '0');
|
||||
}
|
||||
function addLengthPrefix(hex) {
|
||||
const length = hex.length / 2;
|
||||
if (length <= 192) {
|
||||
return bytesToHex([length]) + hex;
|
||||
}
|
||||
if (length <= 12480) {
|
||||
const prefix = length - 193;
|
||||
return bytesToHex([193 + (prefix >>> 8), prefix & 0xff]) + hex;
|
||||
}
|
||||
if (length <= 918744) {
|
||||
const prefix = length - 12481;
|
||||
return (bytesToHex([
|
||||
241 + (prefix >>> 16),
|
||||
(prefix >>> 8) & 0xff,
|
||||
prefix & 0xff,
|
||||
]) + hex);
|
||||
}
|
||||
throw new errors_1.XrplError('Variable integer overflow.');
|
||||
}
|
||||
function hashSignedTx(tx) {
|
||||
let txBlob;
|
||||
let txObject;
|
||||
if (typeof tx === 'string') {
|
||||
txBlob = tx;
|
||||
txObject = (0, ripple_binary_codec_1.decode)(tx);
|
||||
}
|
||||
else {
|
||||
txBlob = (0, ripple_binary_codec_1.encode)(tx);
|
||||
txObject = tx;
|
||||
}
|
||||
if (txObject.TxnSignature === undefined && txObject.Signers === undefined) {
|
||||
throw new errors_1.ValidationError('The transaction must be signed to hash it.');
|
||||
}
|
||||
const prefix = HashPrefix_1.default.TRANSACTION_ID.toString(16).toUpperCase();
|
||||
return (0, sha512Half_1.default)(prefix.concat(txBlob));
|
||||
}
|
||||
exports.hashSignedTx = hashSignedTx;
|
||||
function hashLedgerHeader(ledgerHeader) {
|
||||
const prefix = HashPrefix_1.default.LEDGER.toString(HEX).toUpperCase();
|
||||
const ledger = prefix +
|
||||
intToHex(Number(ledgerHeader.ledger_index), 4) +
|
||||
bigintToHex(ledgerHeader.total_coins, 8) +
|
||||
ledgerHeader.parent_hash +
|
||||
ledgerHeader.transaction_hash +
|
||||
ledgerHeader.account_hash +
|
||||
intToHex(ledgerHeader.parent_close_time, 4) +
|
||||
intToHex(ledgerHeader.close_time, 4) +
|
||||
intToHex(ledgerHeader.close_time_resolution, 1) +
|
||||
intToHex(ledgerHeader.close_flags, 1);
|
||||
return (0, sha512Half_1.default)(ledger);
|
||||
}
|
||||
exports.hashLedgerHeader = hashLedgerHeader;
|
||||
function hashTxTree(transactions) {
|
||||
var _a;
|
||||
const shamap = new SHAMap_1.default();
|
||||
for (const txJSON of transactions) {
|
||||
const txBlobHex = (0, ripple_binary_codec_1.encode)(txJSON);
|
||||
const metaHex = (0, ripple_binary_codec_1.encode)((_a = txJSON.metaData) !== null && _a !== void 0 ? _a : {});
|
||||
const txHash = hashSignedTx(txBlobHex);
|
||||
const data = addLengthPrefix(txBlobHex) + addLengthPrefix(metaHex);
|
||||
shamap.addItem(txHash, data, SHAMap_1.NodeType.TRANSACTION_METADATA);
|
||||
}
|
||||
return shamap.hash;
|
||||
}
|
||||
exports.hashTxTree = hashTxTree;
|
||||
function hashStateTree(entries) {
|
||||
const shamap = new SHAMap_1.default();
|
||||
entries.forEach((ledgerEntry) => {
|
||||
const data = (0, ripple_binary_codec_1.encode)(ledgerEntry);
|
||||
shamap.addItem(ledgerEntry.index, data, SHAMap_1.NodeType.ACCOUNT_STATE);
|
||||
});
|
||||
return shamap.hash;
|
||||
}
|
||||
exports.hashStateTree = hashStateTree;
|
||||
function computeTransactionHash(ledger, options) {
|
||||
const { transaction_hash } = ledger;
|
||||
if (!options.computeTreeHashes) {
|
||||
return transaction_hash;
|
||||
}
|
||||
if (ledger.transactions == null) {
|
||||
throw new errors_1.ValidationError('transactions is missing from the ledger');
|
||||
}
|
||||
const transactionHash = hashTxTree(ledger.transactions);
|
||||
if (transaction_hash !== transactionHash) {
|
||||
throw new errors_1.ValidationError('transactionHash in header' +
|
||||
' does not match computed hash of transactions', {
|
||||
transactionHashInHeader: transaction_hash,
|
||||
computedHashOfTransactions: transactionHash,
|
||||
});
|
||||
}
|
||||
return transactionHash;
|
||||
}
|
||||
function computeStateHash(ledger, options) {
|
||||
const { account_hash } = ledger;
|
||||
if (!options.computeTreeHashes) {
|
||||
return account_hash;
|
||||
}
|
||||
if (ledger.accountState == null) {
|
||||
throw new errors_1.ValidationError('accountState is missing from the ledger');
|
||||
}
|
||||
const stateHash = hashStateTree(ledger.accountState);
|
||||
if (account_hash !== stateHash) {
|
||||
throw new errors_1.ValidationError('stateHash in header does not match computed hash of state');
|
||||
}
|
||||
return stateHash;
|
||||
}
|
||||
function hashLedger(ledger, options = {}) {
|
||||
const subhashes = {
|
||||
transaction_hash: computeTransactionHash(ledger, options),
|
||||
account_hash: computeStateHash(ledger, options),
|
||||
};
|
||||
return hashLedgerHeader(Object.assign(Object.assign({}, ledger), subhashes));
|
||||
}
|
||||
exports.default = hashLedger;
|
||||
//# sourceMappingURL=hashLedger.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"hashLedger.js","sourceRoot":"","sources":["../../../../src/utils/hashes/hashLedger.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gEAAoC;AACpC,6DAAoD;AAEpD,yCAAyD;AAKzD,8DAAqC;AACrC,8DAAqC;AACrC,mDAA2C;AAE3C,MAAM,GAAG,GAAG,EAAE,CAAA;AAMd,SAAS,QAAQ,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AA"}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import hashLedger, { hashLedgerHeader, hashSignedTx, hashTxTree, hashStateTree } from './hashLedger';
|
||||
export declare function hashTx(txBlobHex: string): string;
|
||||
export declare function hashAccountRoot(address: string): string;
|
||||
export declare function hashSignerListId(address: string): string;
|
||||
export declare function hashOfferId(address: string, sequence: number): string;
|
||||
export declare function hashTrustline(address1: string, address2: string, currency: string): string;
|
||||
export declare function hashEscrow(address: string, sequence: number): string;
|
||||
export declare function hashPaymentChannel(address: string, dstAddress: string, sequence: number): string;
|
||||
export { hashLedgerHeader, hashSignedTx, hashLedger, hashStateTree, hashTxTree };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashes/index.ts"],"names":[],"mappings":"AAQA,OAAO,UAAU,EAAE,EACjB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,aAAa,EACd,MAAM,cAAc,CAAA;AAsCrB,wBAAgB,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGhD;AAgBD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEvD;AAgBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAIxD;AAiBD,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAQrE;AAWD,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,CAcR;AAUD,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAMpE;AAWD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM,CAOR;AAED,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,UAAU,EAAE,CAAA"}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.hashTxTree = exports.hashStateTree = exports.hashLedger = exports.hashSignedTx = exports.hashLedgerHeader = exports.hashPaymentChannel = exports.hashEscrow = exports.hashTrustline = exports.hashOfferId = exports.hashSignerListId = exports.hashAccountRoot = exports.hashTx = void 0;
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const hashLedger_1 = __importStar(require("./hashLedger"));
|
||||
exports.hashLedger = hashLedger_1.default;
|
||||
Object.defineProperty(exports, "hashLedgerHeader", { enumerable: true, get: function () { return hashLedger_1.hashLedgerHeader; } });
|
||||
Object.defineProperty(exports, "hashSignedTx", { enumerable: true, get: function () { return hashLedger_1.hashSignedTx; } });
|
||||
Object.defineProperty(exports, "hashTxTree", { enumerable: true, get: function () { return hashLedger_1.hashTxTree; } });
|
||||
Object.defineProperty(exports, "hashStateTree", { enumerable: true, get: function () { return hashLedger_1.hashStateTree; } });
|
||||
const HashPrefix_1 = __importDefault(require("./HashPrefix"));
|
||||
const ledgerSpaces_1 = __importDefault(require("./ledgerSpaces"));
|
||||
const sha512Half_1 = __importDefault(require("./sha512Half"));
|
||||
const HEX = 16;
|
||||
const BYTE_LENGTH = 4;
|
||||
function addressToHex(address) {
|
||||
return Buffer.from((0, ripple_address_codec_1.decodeAccountID)(address)).toString('hex');
|
||||
}
|
||||
function ledgerSpaceHex(name) {
|
||||
return ledgerSpaces_1.default[name].charCodeAt(0).toString(HEX).padStart(4, '0');
|
||||
}
|
||||
const MASK = 0xff;
|
||||
function currencyToHex(currency) {
|
||||
if (currency.length !== 3) {
|
||||
return currency;
|
||||
}
|
||||
const bytes = Array(20).fill(0);
|
||||
bytes[12] = currency.charCodeAt(0) & MASK;
|
||||
bytes[13] = currency.charCodeAt(1) & MASK;
|
||||
bytes[14] = currency.charCodeAt(2) & MASK;
|
||||
return Buffer.from(bytes).toString('hex');
|
||||
}
|
||||
function hashTx(txBlobHex) {
|
||||
const prefix = HashPrefix_1.default.TRANSACTION_SIGN.toString(HEX).toUpperCase();
|
||||
return (0, sha512Half_1.default)(prefix + txBlobHex);
|
||||
}
|
||||
exports.hashTx = hashTx;
|
||||
function hashAccountRoot(address) {
|
||||
return (0, sha512Half_1.default)(ledgerSpaceHex('account') + addressToHex(address));
|
||||
}
|
||||
exports.hashAccountRoot = hashAccountRoot;
|
||||
function hashSignerListId(address) {
|
||||
return (0, sha512Half_1.default)(`${ledgerSpaceHex('signerList') + addressToHex(address)}00000000`);
|
||||
}
|
||||
exports.hashSignerListId = hashSignerListId;
|
||||
function hashOfferId(address, sequence) {
|
||||
const hexPrefix = ledgerSpaces_1.default.offer
|
||||
.charCodeAt(0)
|
||||
.toString(HEX)
|
||||
.padStart(2, '0');
|
||||
const hexSequence = sequence.toString(HEX).padStart(8, '0');
|
||||
const prefix = `00${hexPrefix}`;
|
||||
return (0, sha512Half_1.default)(prefix + addressToHex(address) + hexSequence);
|
||||
}
|
||||
exports.hashOfferId = hashOfferId;
|
||||
function hashTrustline(address1, address2, currency) {
|
||||
const address1Hex = addressToHex(address1);
|
||||
const address2Hex = addressToHex(address2);
|
||||
const swap = new bignumber_js_1.default(address1Hex, 16).isGreaterThan(new bignumber_js_1.default(address2Hex, 16));
|
||||
const lowAddressHex = swap ? address2Hex : address1Hex;
|
||||
const highAddressHex = swap ? address1Hex : address2Hex;
|
||||
const prefix = ledgerSpaceHex('rippleState');
|
||||
return (0, sha512Half_1.default)(prefix + lowAddressHex + highAddressHex + currencyToHex(currency));
|
||||
}
|
||||
exports.hashTrustline = hashTrustline;
|
||||
function hashEscrow(address, sequence) {
|
||||
return (0, sha512Half_1.default)(ledgerSpaceHex('escrow') +
|
||||
addressToHex(address) +
|
||||
sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'));
|
||||
}
|
||||
exports.hashEscrow = hashEscrow;
|
||||
function hashPaymentChannel(address, dstAddress, sequence) {
|
||||
return (0, sha512Half_1.default)(ledgerSpaceHex('paychan') +
|
||||
addressToHex(address) +
|
||||
addressToHex(dstAddress) +
|
||||
sequence.toString(HEX).padStart(BYTE_LENGTH * 2, '0'));
|
||||
}
|
||||
exports.hashPaymentChannel = hashPaymentChannel;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/utils/hashes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,gEAAoC;AACpC,+DAAsD;AAEt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BAAS,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,aAAa,CACvD,IAAI,sBAAS,CAAC,WAAW,EAAE,EAAE,CAAC,CAC/B,CAAA;IACD,MAAM,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAA;IACtD,MAAM,cAAc,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAA;IAEvD,MAAM,MAAM,GAAG,cAAc,CAAC,aAAa,CAAC,CAAA;IAC5C,OAAO,IAAA,oBAAU,EACf,MAAM,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CAAC,QAAQ,CAAC,CAClE,CAAA;AACH,CAAC;AAlBD,sCAkBC;AAUD,SAAgB,UAAU,CAAC,OAAe,EAAE,QAAgB;IAC1D,OAAO,IAAA,oBAAU,EACf,cAAc,CAAC,QAAQ,CAAC;QACtB,YAAY,CAAC,OAAO,CAAC;QACrB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,EAAE,GAAG,CAAC,CACxD,CAAA;AACH,CAAC;AAND,gCAMC;AAWD,SAAgB,kBAAkB,CAChC,OAAe,EACf,UAAkB,EAClB,QAAgB;IAEhB,OAAO,IAAA,oBAAU,EACf,cAAc,CAAC,SAAS,CAAC;QACvB,YAAY,CAAC,OAAO,CAAC;QACrB,YAAY,CAAC,UAAU,CAAC;QACxB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,WAAW,GAAG,CAAC,EAAE,GAAG,CAAC,CACxD,CAAA;AACH,CAAC;AAXD,gDAWC"}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
declare const ledgerSpaces: {
|
||||
account: string;
|
||||
dirNode: string;
|
||||
generatorMap: string;
|
||||
rippleState: string;
|
||||
offer: string;
|
||||
ownerDir: string;
|
||||
bookDir: string;
|
||||
contract: string;
|
||||
skipList: string;
|
||||
escrow: string;
|
||||
amendment: string;
|
||||
feeSettings: string;
|
||||
ticket: string;
|
||||
signerList: string;
|
||||
paychan: string;
|
||||
check: string;
|
||||
depositPreauth: string;
|
||||
};
|
||||
export default ledgerSpaces;
|
||||
//# sourceMappingURL=ledgerSpaces.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ledgerSpaces.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashes/ledgerSpaces.ts"],"names":[],"mappings":"AAUA,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;CAqBjB,CAAA;AAED,eAAe,YAAY,CAAA"}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ledgerSpaces = {
|
||||
account: 'a',
|
||||
dirNode: 'd',
|
||||
generatorMap: 'g',
|
||||
rippleState: 'r',
|
||||
offer: 'o',
|
||||
ownerDir: 'O',
|
||||
bookDir: 'B',
|
||||
contract: 'c',
|
||||
skipList: 's',
|
||||
escrow: 'u',
|
||||
amendment: 'f',
|
||||
feeSettings: 'e',
|
||||
ticket: 'T',
|
||||
signerList: 'S',
|
||||
paychan: 'x',
|
||||
check: 'C',
|
||||
depositPreauth: 'p',
|
||||
};
|
||||
exports.default = ledgerSpaces;
|
||||
//# sourceMappingURL=ledgerSpaces.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ledgerSpaces.js","sourceRoot":"","sources":["../../../../src/utils/hashes/ledgerSpaces.ts"],"names":[],"mappings":";;AAUA,MAAM,YAAY,GAAG;IACnB,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,GAAG;IACZ,YAAY,EAAE,GAAG;IACjB,WAAW,EAAE,GAAG;IAEhB,KAAK,EAAE,GAAG;IAEV,QAAQ,EAAE,GAAG;IAEb,OAAO,EAAE,GAAG;IACZ,QAAQ,EAAE,GAAG;IACb,QAAQ,EAAE,GAAG;IACb,MAAM,EAAE,GAAG;IACX,SAAS,EAAE,GAAG;IACd,WAAW,EAAE,GAAG;IAChB,MAAM,EAAE,GAAG;IACX,UAAU,EAAE,GAAG;IACf,OAAO,EAAE,GAAG;IACZ,KAAK,EAAE,GAAG;IACV,cAAc,EAAE,GAAG;CACpB,CAAA;AAED,kBAAe,YAAY,CAAA"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
declare function sha512Half(hex: string): string;
|
||||
export default sha512Half;
|
||||
//# sourceMappingURL=sha512Half.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha512Half.d.ts","sourceRoot":"","sources":["../../../../src/utils/hashes/sha512Half.ts"],"names":[],"mappings":"AAUA,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMvC;AAED,eAAe,UAAU,CAAA"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const crypto_1 = require("crypto");
|
||||
const HASH_SIZE = 64;
|
||||
function sha512Half(hex) {
|
||||
return (0, crypto_1.createHash)('sha512')
|
||||
.update(Buffer.from(hex, 'hex'))
|
||||
.digest('hex')
|
||||
.toUpperCase()
|
||||
.slice(0, HASH_SIZE);
|
||||
}
|
||||
exports.default = sha512Half;
|
||||
//# sourceMappingURL=sha512Half.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"sha512Half.js","sourceRoot":"","sources":["../../../../src/utils/hashes/sha512Half.ts"],"names":[],"mappings":";;AAAA,mCAAmC;AAEnC,MAAM,SAAS,GAAG,EAAE,CAAA;AAQpB,SAAS,UAAU,CAAC,GAAW;IAC7B,OAAO,IAAA,mBAAU,EAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC/B,MAAM,CAAC,KAAK,CAAC;SACb,WAAW,EAAE;SACb,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AACxB,CAAC;AAED,kBAAe,UAAU,CAAA"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import { classicAddressToXAddress, decodeAccountID, decodeAccountPublic, decodeNodePublic, decodeSeed, decodeXAddress, encodeAccountID, encodeAccountPublic, encodeNodePublic, encodeSeed, encodeXAddress, isValidClassicAddress, isValidXAddress, xAddressToClassicAddress } from 'ripple-address-codec';
|
||||
import { verify as verifyKeypairSignature } from 'ripple-keypairs';
|
||||
import { LedgerEntry } from '../models/ledger';
|
||||
import { Response } from '../models/methods';
|
||||
import { PaymentChannelClaim } from '../models/transactions/paymentChannelClaim';
|
||||
import { Transaction } from '../models/transactions/transaction';
|
||||
import createCrossChainPayment from './createCrossChainPayment';
|
||||
import { deriveKeypair, deriveAddress, deriveXAddress } from './derive';
|
||||
import getBalanceChanges from './getBalanceChanges';
|
||||
import getNFTokenID from './getNFTokenID';
|
||||
import { hashSignedTx, hashTx, hashAccountRoot, hashSignerListId, hashOfferId, hashTrustline, hashTxTree, hashStateTree, hashLedger, hashLedgerHeader, hashEscrow, hashPaymentChannel } from './hashes';
|
||||
import parseNFTokenID from './parseNFTokenID';
|
||||
import { percentToTransferRate, decimalToTransferRate, transferRateToDecimal, percentToQuality, decimalToQuality, qualityToDecimal } from './quality';
|
||||
import signPaymentChannelClaim from './signPaymentChannelClaim';
|
||||
import { convertHexToString, convertStringToHex } from './stringConversion';
|
||||
import { rippleTimeToISOTime, isoTimeToRippleTime, rippleTimeToUnixTime, unixTimeToRippleTime } from './timeConversion';
|
||||
import verifyPaymentChannelClaim from './verifyPaymentChannelClaim';
|
||||
import { xrpToDrops, dropsToXrp } from './xrpConversion';
|
||||
declare function isValidSecret(secret: string): boolean;
|
||||
declare function encode(object: Transaction | LedgerEntry): string;
|
||||
declare function encodeForSigning(object: Transaction): string;
|
||||
declare function encodeForSigningClaim(object: PaymentChannelClaim): string;
|
||||
declare function encodeForMultiSigning(object: Transaction, signer: string): string;
|
||||
declare function decode(hex: string): Record<string, unknown>;
|
||||
declare function isValidAddress(address: string): boolean;
|
||||
declare function hasNextPage(response: Response): boolean;
|
||||
declare const hashes: {
|
||||
hashSignedTx: typeof hashSignedTx;
|
||||
hashTx: typeof hashTx;
|
||||
hashAccountRoot: typeof hashAccountRoot;
|
||||
hashSignerListId: typeof hashSignerListId;
|
||||
hashOfferId: typeof hashOfferId;
|
||||
hashTrustline: typeof hashTrustline;
|
||||
hashTxTree: typeof hashTxTree;
|
||||
hashStateTree: typeof hashStateTree;
|
||||
hashLedger: typeof hashLedger;
|
||||
hashLedgerHeader: typeof hashLedgerHeader;
|
||||
hashEscrow: typeof hashEscrow;
|
||||
hashPaymentChannel: typeof hashPaymentChannel;
|
||||
};
|
||||
export { getBalanceChanges, dropsToXrp, xrpToDrops, hasNextPage, rippleTimeToISOTime, isoTimeToRippleTime, rippleTimeToUnixTime, unixTimeToRippleTime, percentToQuality, decimalToQuality, percentToTransferRate, decimalToTransferRate, transferRateToDecimal, qualityToDecimal, isValidSecret, isValidAddress, hashes, deriveKeypair, deriveAddress, deriveXAddress, signPaymentChannelClaim, verifyKeypairSignature, verifyPaymentChannelClaim, convertStringToHex, convertHexToString, classicAddressToXAddress, xAddressToClassicAddress, isValidXAddress, isValidClassicAddress, encodeSeed, decodeSeed, encodeAccountID, decodeAccountID, encodeNodePublic, decodeNodePublic, encodeAccountPublic, decodeAccountPublic, encodeXAddress, decodeXAddress, encode, decode, encodeForMultiSigning, encodeForSigning, encodeForSigningClaim, getNFTokenID, createCrossChainPayment, parseNFTokenID, };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,cAAc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 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseNFTokenID = exports.createCrossChainPayment = exports.getNFTokenID = exports.encodeForSigningClaim = exports.encodeForSigning = exports.encodeForMultiSigning = exports.decode = exports.encode = exports.decodeXAddress = exports.encodeXAddress = exports.decodeAccountPublic = exports.encodeAccountPublic = exports.decodeNodePublic = exports.encodeNodePublic = exports.decodeAccountID = exports.encodeAccountID = exports.decodeSeed = exports.encodeSeed = exports.isValidClassicAddress = exports.isValidXAddress = exports.xAddressToClassicAddress = exports.classicAddressToXAddress = exports.convertHexToString = exports.convertStringToHex = exports.verifyPaymentChannelClaim = exports.verifyKeypairSignature = exports.signPaymentChannelClaim = exports.deriveXAddress = exports.deriveAddress = exports.deriveKeypair = exports.hashes = exports.isValidAddress = exports.isValidSecret = exports.qualityToDecimal = exports.transferRateToDecimal = exports.decimalToTransferRate = exports.percentToTransferRate = exports.decimalToQuality = exports.percentToQuality = exports.unixTimeToRippleTime = exports.rippleTimeToUnixTime = exports.isoTimeToRippleTime = exports.rippleTimeToISOTime = exports.hasNextPage = exports.xrpToDrops = exports.dropsToXrp = exports.getBalanceChanges = void 0;
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
Object.defineProperty(exports, "classicAddressToXAddress", { enumerable: true, get: function () { return ripple_address_codec_1.classicAddressToXAddress; } });
|
||||
Object.defineProperty(exports, "decodeAccountID", { enumerable: true, get: function () { return ripple_address_codec_1.decodeAccountID; } });
|
||||
Object.defineProperty(exports, "decodeAccountPublic", { enumerable: true, get: function () { return ripple_address_codec_1.decodeAccountPublic; } });
|
||||
Object.defineProperty(exports, "decodeNodePublic", { enumerable: true, get: function () { return ripple_address_codec_1.decodeNodePublic; } });
|
||||
Object.defineProperty(exports, "decodeSeed", { enumerable: true, get: function () { return ripple_address_codec_1.decodeSeed; } });
|
||||
Object.defineProperty(exports, "decodeXAddress", { enumerable: true, get: function () { return ripple_address_codec_1.decodeXAddress; } });
|
||||
Object.defineProperty(exports, "encodeAccountID", { enumerable: true, get: function () { return ripple_address_codec_1.encodeAccountID; } });
|
||||
Object.defineProperty(exports, "encodeAccountPublic", { enumerable: true, get: function () { return ripple_address_codec_1.encodeAccountPublic; } });
|
||||
Object.defineProperty(exports, "encodeNodePublic", { enumerable: true, get: function () { return ripple_address_codec_1.encodeNodePublic; } });
|
||||
Object.defineProperty(exports, "encodeSeed", { enumerable: true, get: function () { return ripple_address_codec_1.encodeSeed; } });
|
||||
Object.defineProperty(exports, "encodeXAddress", { enumerable: true, get: function () { return ripple_address_codec_1.encodeXAddress; } });
|
||||
Object.defineProperty(exports, "isValidClassicAddress", { enumerable: true, get: function () { return ripple_address_codec_1.isValidClassicAddress; } });
|
||||
Object.defineProperty(exports, "isValidXAddress", { enumerable: true, get: function () { return ripple_address_codec_1.isValidXAddress; } });
|
||||
Object.defineProperty(exports, "xAddressToClassicAddress", { enumerable: true, get: function () { return ripple_address_codec_1.xAddressToClassicAddress; } });
|
||||
const rbc = __importStar(require("ripple-binary-codec"));
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
Object.defineProperty(exports, "verifyKeypairSignature", { enumerable: true, get: function () { return ripple_keypairs_1.verify; } });
|
||||
const createCrossChainPayment_1 = __importDefault(require("./createCrossChainPayment"));
|
||||
exports.createCrossChainPayment = createCrossChainPayment_1.default;
|
||||
const derive_1 = require("./derive");
|
||||
Object.defineProperty(exports, "deriveKeypair", { enumerable: true, get: function () { return derive_1.deriveKeypair; } });
|
||||
Object.defineProperty(exports, "deriveAddress", { enumerable: true, get: function () { return derive_1.deriveAddress; } });
|
||||
Object.defineProperty(exports, "deriveXAddress", { enumerable: true, get: function () { return derive_1.deriveXAddress; } });
|
||||
const getBalanceChanges_1 = __importDefault(require("./getBalanceChanges"));
|
||||
exports.getBalanceChanges = getBalanceChanges_1.default;
|
||||
const getNFTokenID_1 = __importDefault(require("./getNFTokenID"));
|
||||
exports.getNFTokenID = getNFTokenID_1.default;
|
||||
const hashes_1 = require("./hashes");
|
||||
const parseNFTokenID_1 = __importDefault(require("./parseNFTokenID"));
|
||||
exports.parseNFTokenID = parseNFTokenID_1.default;
|
||||
const quality_1 = require("./quality");
|
||||
Object.defineProperty(exports, "percentToTransferRate", { enumerable: true, get: function () { return quality_1.percentToTransferRate; } });
|
||||
Object.defineProperty(exports, "decimalToTransferRate", { enumerable: true, get: function () { return quality_1.decimalToTransferRate; } });
|
||||
Object.defineProperty(exports, "transferRateToDecimal", { enumerable: true, get: function () { return quality_1.transferRateToDecimal; } });
|
||||
Object.defineProperty(exports, "percentToQuality", { enumerable: true, get: function () { return quality_1.percentToQuality; } });
|
||||
Object.defineProperty(exports, "decimalToQuality", { enumerable: true, get: function () { return quality_1.decimalToQuality; } });
|
||||
Object.defineProperty(exports, "qualityToDecimal", { enumerable: true, get: function () { return quality_1.qualityToDecimal; } });
|
||||
const signPaymentChannelClaim_1 = __importDefault(require("./signPaymentChannelClaim"));
|
||||
exports.signPaymentChannelClaim = signPaymentChannelClaim_1.default;
|
||||
const stringConversion_1 = require("./stringConversion");
|
||||
Object.defineProperty(exports, "convertHexToString", { enumerable: true, get: function () { return stringConversion_1.convertHexToString; } });
|
||||
Object.defineProperty(exports, "convertStringToHex", { enumerable: true, get: function () { return stringConversion_1.convertStringToHex; } });
|
||||
const timeConversion_1 = require("./timeConversion");
|
||||
Object.defineProperty(exports, "rippleTimeToISOTime", { enumerable: true, get: function () { return timeConversion_1.rippleTimeToISOTime; } });
|
||||
Object.defineProperty(exports, "isoTimeToRippleTime", { enumerable: true, get: function () { return timeConversion_1.isoTimeToRippleTime; } });
|
||||
Object.defineProperty(exports, "rippleTimeToUnixTime", { enumerable: true, get: function () { return timeConversion_1.rippleTimeToUnixTime; } });
|
||||
Object.defineProperty(exports, "unixTimeToRippleTime", { enumerable: true, get: function () { return timeConversion_1.unixTimeToRippleTime; } });
|
||||
const verifyPaymentChannelClaim_1 = __importDefault(require("./verifyPaymentChannelClaim"));
|
||||
exports.verifyPaymentChannelClaim = verifyPaymentChannelClaim_1.default;
|
||||
const xrpConversion_1 = require("./xrpConversion");
|
||||
Object.defineProperty(exports, "xrpToDrops", { enumerable: true, get: function () { return xrpConversion_1.xrpToDrops; } });
|
||||
Object.defineProperty(exports, "dropsToXrp", { enumerable: true, get: function () { return xrpConversion_1.dropsToXrp; } });
|
||||
function isValidSecret(secret) {
|
||||
try {
|
||||
(0, derive_1.deriveKeypair)(secret);
|
||||
return true;
|
||||
}
|
||||
catch (_err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
exports.isValidSecret = isValidSecret;
|
||||
function encode(object) {
|
||||
return rbc.encode(object);
|
||||
}
|
||||
exports.encode = encode;
|
||||
function encodeForSigning(object) {
|
||||
return rbc.encodeForSigning(object);
|
||||
}
|
||||
exports.encodeForSigning = encodeForSigning;
|
||||
function encodeForSigningClaim(object) {
|
||||
return rbc.encodeForSigningClaim(object);
|
||||
}
|
||||
exports.encodeForSigningClaim = encodeForSigningClaim;
|
||||
function encodeForMultiSigning(object, signer) {
|
||||
return rbc.encodeForMultisigning(object, signer);
|
||||
}
|
||||
exports.encodeForMultiSigning = encodeForMultiSigning;
|
||||
function decode(hex) {
|
||||
return rbc.decode(hex);
|
||||
}
|
||||
exports.decode = decode;
|
||||
function isValidAddress(address) {
|
||||
return (0, ripple_address_codec_1.isValidXAddress)(address) || (0, ripple_address_codec_1.isValidClassicAddress)(address);
|
||||
}
|
||||
exports.isValidAddress = isValidAddress;
|
||||
function hasNextPage(response) {
|
||||
return Boolean(response.result['marker']);
|
||||
}
|
||||
exports.hasNextPage = hasNextPage;
|
||||
const hashes = {
|
||||
hashSignedTx: hashes_1.hashSignedTx,
|
||||
hashTx: hashes_1.hashTx,
|
||||
hashAccountRoot: hashes_1.hashAccountRoot,
|
||||
hashSignerListId: hashes_1.hashSignerListId,
|
||||
hashOfferId: hashes_1.hashOfferId,
|
||||
hashTrustline: hashes_1.hashTrustline,
|
||||
hashTxTree: hashes_1.hashTxTree,
|
||||
hashStateTree: hashes_1.hashStateTree,
|
||||
hashLedger: hashes_1.hashLedger,
|
||||
hashLedgerHeader: hashes_1.hashLedgerHeader,
|
||||
hashEscrow: hashes_1.hashEscrow,
|
||||
hashPaymentChannel: hashes_1.hashPaymentChannel,
|
||||
};
|
||||
exports.hashes = hashes;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAe6B;AA2L3B,yGAzMA,+CAAwB,OAyMA;AAOxB,gGA/MA,sCAAe,OA+MA;AAIf,oGAlNA,0CAAmB,OAkNA;AAFnB,iGA/MA,uCAAgB,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Ae;IACf,gBAAgB,EAAhB,yBAAgB;IAChB,WAAW,EAAX,oBAAW;IACX,aAAa,EAAb,sBAAa;IACb,UAAU,EAAV,mBAAU;IACV,aAAa,EAAb,sBAAa;IACb,UAAU,EAAV,mBAAU;IACV,gBAAgB,EAAhB,yBAAgB;IAChB,UAAU,EAAV,mBAAU;IACV,kBAAkB,EAAlB,2BAAkB;CACnB,CAAA;AAmBC,wBAAM"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export default function parseNFTokenID(nftokenID: string): {
|
||||
NFTokenID: string;
|
||||
Flags: number;
|
||||
TransferFee: number;
|
||||
Issuer: string;
|
||||
Taxon: number;
|
||||
Sequence: number;
|
||||
};
|
||||
//# sourceMappingURL=parseNFTokenID.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parseNFTokenID.d.ts","sourceRoot":"","sources":["../../../src/utils/parseNFTokenID.ts"],"names":[],"mappings":"AAqDA,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG;IACzD,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;CACjB,CAuBA"}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const errors_1 = require("../errors");
|
||||
function unscrambleTaxon(taxon, tokenSeq) {
|
||||
return (taxon ^ (384160001 * tokenSeq + 2459)) % 4294967296;
|
||||
}
|
||||
function parseNFTokenID(nftokenID) {
|
||||
const expectedLength = 64;
|
||||
if (nftokenID.length !== expectedLength) {
|
||||
throw new errors_1.XrplError(`Attempting to parse a nftokenID with length ${nftokenID.length}
|
||||
, but expected a token with length ${expectedLength}`);
|
||||
}
|
||||
const scrambledTaxon = new bignumber_js_1.default(nftokenID.substring(48, 56), 16).toNumber();
|
||||
const sequence = new bignumber_js_1.default(nftokenID.substring(56, 64), 16).toNumber();
|
||||
const NFTokenIDData = {
|
||||
NFTokenID: nftokenID,
|
||||
Flags: new bignumber_js_1.default(nftokenID.substring(0, 4), 16).toNumber(),
|
||||
TransferFee: new bignumber_js_1.default(nftokenID.substring(4, 8), 16).toNumber(),
|
||||
Issuer: (0, ripple_address_codec_1.encodeAccountID)(Buffer.from(nftokenID.substring(8, 48), 'hex')),
|
||||
Taxon: unscrambleTaxon(scrambledTaxon, sequence),
|
||||
Sequence: sequence,
|
||||
};
|
||||
return NFTokenIDData;
|
||||
}
|
||||
exports.default = parseNFTokenID;
|
||||
//# sourceMappingURL=parseNFTokenID.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"parseNFTokenID.js","sourceRoot":"","sources":["../../../src/utils/parseNFTokenID.ts"],"names":[],"mappings":";;;;;AACA,gEAAoC;AACpC,+DAAsD;AAEtD,sCAAqC;AAoBrC,SAAS,eAAe,CAAC,KAAa,EAAE,QAAgB;IAEtD,OAAO,CAAC,KAAK,GAAG,CAAC,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC,GAAG,UAAU,CAAA;AAE7D,CAAC;AAyBD,SAAwB,cAAc,CAAC,SAAiB;IAQtD,MAAM,cAAc,GAAG,EAAE,CAAA;IACzB,IAAI,SAAS,CAAC,MAAM,KAAK,cAAc,EAAE;QACvC,MAAM,IAAI,kBAAS,CAAC,+CAA+C,SAAS,CAAC,MAAM;yCAC9C,cAAc,EAAE,CAAC,CAAA;KACvD;IAED,MAAM,cAAc,GAAG,IAAI,sBAAS,CAClC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAC3B,EAAE,CACH,CAAC,QAAQ,EAAE,CAAA;IACZ,MAAM,QAAQ,GAAG,IAAI,sBAAS,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;IAE1E,MAAM,aAAa,GAAG;QACpB,SAAS,EAAE,SAAS;QACpB,KAAK,EAAE,IAAI,sBAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;QAC9D,WAAW,EAAE,IAAI,sBAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE;QACpE,MAAM,EAAE,IAAA,sCAAe,EAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACvE,KAAK,EAAE,eAAe,CAAC,cAAc,EAAE,QAAQ,CAAC;QAChD,QAAQ,EAAE,QAAQ;KACnB,CAAA;IAED,OAAO,aAAa,CAAA;AACtB,CAAC;AA9BD,iCA8BC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export declare function decimalToTransferRate(decimal: string): number;
|
||||
export declare function percentToTransferRate(percent: string): number;
|
||||
export declare function decimalToQuality(decimal: string): number;
|
||||
export declare function qualityToDecimal(quality: number): string;
|
||||
export declare function transferRateToDecimal(rate: number): string;
|
||||
export declare function percentToQuality(percent: string): number;
|
||||
//# sourceMappingURL=quality.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"quality.d.ts","sourceRoot":"","sources":["../../../src/utils/quality.ts"],"names":[],"mappings":"AA+BA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsB7D;AAWD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAE7D;AAYD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBxD;AAUD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAUD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkB1D;AAYD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD"}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.percentToQuality = exports.transferRateToDecimal = exports.qualityToDecimal = exports.decimalToQuality = exports.percentToTransferRate = exports.decimalToTransferRate = void 0;
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const errors_1 = require("../errors");
|
||||
const BASE_TEN = 10;
|
||||
const ONE_BILLION = '1000000000';
|
||||
const TWO_BILLION = '2000000000';
|
||||
function percentToDecimal(percent) {
|
||||
if (!percent.endsWith('%')) {
|
||||
throw new errors_1.ValidationError(`Value ${percent} must end with %`);
|
||||
}
|
||||
const split = percent.split('%').filter((str) => str !== '');
|
||||
if (split.length !== 1) {
|
||||
throw new errors_1.ValidationError(`Value ${percent} contains too many % signs`);
|
||||
}
|
||||
return new bignumber_js_1.default(split[0]).dividedBy('100').toString(BASE_TEN);
|
||||
}
|
||||
function decimalToTransferRate(decimal) {
|
||||
const rate = new bignumber_js_1.default(decimal).times(ONE_BILLION).plus(ONE_BILLION);
|
||||
if (rate.isLessThan(ONE_BILLION) || rate.isGreaterThan(TWO_BILLION)) {
|
||||
throw new errors_1.ValidationError(`Decimal value must be between 0 and 1.00.`);
|
||||
}
|
||||
const billionths = rate.toString(BASE_TEN);
|
||||
if (billionths === ONE_BILLION) {
|
||||
return 0;
|
||||
}
|
||||
if (billionths === 'NaN') {
|
||||
throw new errors_1.ValidationError(`Value is not a number`);
|
||||
}
|
||||
if (billionths.includes('.')) {
|
||||
throw new errors_1.ValidationError(`Decimal exceeds maximum precision.`);
|
||||
}
|
||||
return Number(billionths);
|
||||
}
|
||||
exports.decimalToTransferRate = decimalToTransferRate;
|
||||
function percentToTransferRate(percent) {
|
||||
return decimalToTransferRate(percentToDecimal(percent));
|
||||
}
|
||||
exports.percentToTransferRate = percentToTransferRate;
|
||||
function decimalToQuality(decimal) {
|
||||
const rate = new bignumber_js_1.default(decimal).times(ONE_BILLION);
|
||||
const billionths = rate.toString(BASE_TEN);
|
||||
if (billionths === 'NaN') {
|
||||
throw new errors_1.ValidationError(`Value is not a number`);
|
||||
}
|
||||
if (billionths.includes('-')) {
|
||||
throw new errors_1.ValidationError('Cannot have negative Quality');
|
||||
}
|
||||
if (billionths === ONE_BILLION) {
|
||||
return 0;
|
||||
}
|
||||
if (billionths.includes('.')) {
|
||||
throw new errors_1.ValidationError(`Decimal exceeds maximum precision.`);
|
||||
}
|
||||
return Number(billionths);
|
||||
}
|
||||
exports.decimalToQuality = decimalToQuality;
|
||||
function qualityToDecimal(quality) {
|
||||
if (!Number.isInteger(quality)) {
|
||||
throw new errors_1.ValidationError('Quality must be an integer');
|
||||
}
|
||||
if (quality < 0) {
|
||||
throw new errors_1.ValidationError('Negative quality not allowed');
|
||||
}
|
||||
if (quality === 0) {
|
||||
return '1';
|
||||
}
|
||||
const decimal = new bignumber_js_1.default(quality).dividedBy(ONE_BILLION);
|
||||
return decimal.toString(BASE_TEN);
|
||||
}
|
||||
exports.qualityToDecimal = qualityToDecimal;
|
||||
function transferRateToDecimal(rate) {
|
||||
if (!Number.isInteger(rate)) {
|
||||
throw new errors_1.ValidationError('Error decoding, transfer Rate must be an integer');
|
||||
}
|
||||
if (rate === 0) {
|
||||
return '0';
|
||||
}
|
||||
const decimal = new bignumber_js_1.default(rate).minus(ONE_BILLION).dividedBy(ONE_BILLION);
|
||||
if (decimal.isLessThan(0)) {
|
||||
throw new errors_1.ValidationError('Error decoding, negative transfer rate');
|
||||
}
|
||||
return decimal.toString(BASE_TEN);
|
||||
}
|
||||
exports.transferRateToDecimal = transferRateToDecimal;
|
||||
function percentToQuality(percent) {
|
||||
return decimalToQuality(percentToDecimal(percent));
|
||||
}
|
||||
exports.percentToQuality = percentToQuality;
|
||||
//# sourceMappingURL=quality.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"quality.js","sourceRoot":"","sources":["../../../src/utils/quality.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AAEpC,sCAA2C;AAE3C,MAAM,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,WAAW,GAAG,YAAY,CAAA;AAEhC,SAAS,gBAAgB,CAAC,OAAe;IACvC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;QAC1B,MAAM,IAAI,wBAAe,CAAC,SAAS,OAAO,kBAAkB,CAAC,CAAA;KAC9D;IAGD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAA;IAC5D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;QACtB,MAAM,IAAI,wBAAe,CAAC,SAAS,OAAO,4BAA4B,CAAC,CAAA;KACxE;IAED,OAAO,IAAI,sBAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACpE,CAAC;AAWD,SAAgB,qBAAqB,CAAC,OAAe;IACnD,MAAM,IAAI,GAAG,IAAI,sBAAS,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAExE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;AAFD,4CAEC"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
declare function signPaymentChannelClaim(channel: string, amount: string, privateKey: string): string;
|
||||
export default signPaymentChannelClaim;
|
||||
//# sourceMappingURL=signPaymentChannelClaim.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"signPaymentChannelClaim.d.ts","sourceRoot":"","sources":["../../../src/utils/signPaymentChannelClaim.ts"],"names":[],"mappings":"AAcA,iBAAS,uBAAuB,CAC9B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,GACjB,MAAM,CAMR;AAED,eAAe,uBAAuB,CAAA"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
const xrpConversion_1 = require("./xrpConversion");
|
||||
function signPaymentChannelClaim(channel, amount, privateKey) {
|
||||
const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
|
||||
channel,
|
||||
amount: (0, xrpConversion_1.xrpToDrops)(amount),
|
||||
});
|
||||
return (0, ripple_keypairs_1.sign)(signingData, privateKey);
|
||||
}
|
||||
exports.default = signPaymentChannelClaim;
|
||||
//# sourceMappingURL=signPaymentChannelClaim.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"signPaymentChannelClaim.js","sourceRoot":"","sources":["../../../src/utils/signPaymentChannelClaim.ts"],"names":[],"mappings":";;AAAA,6DAA2D;AAC3D,qDAAsC;AAEtC,mDAA4C;AAW5C,SAAS,uBAAuB,CAC9B,OAAe,EACf,MAAc,EACd,UAAkB;IAElB,MAAM,WAAW,GAAG,IAAA,2CAAqB,EAAC;QACxC,OAAO;QACP,MAAM,EAAE,IAAA,0BAAU,EAAC,MAAM,CAAC;KAC3B,CAAC,CAAA;IACF,OAAO,IAAA,sBAAI,EAAC,WAAW,EAAE,UAAU,CAAC,CAAA;AACtC,CAAC;AAED,kBAAe,uBAAuB,CAAA"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
declare function convertStringToHex(string: string): string;
|
||||
declare function convertHexToString(hex: string, encoding?: BufferEncoding): string;
|
||||
export { convertHexToString, convertStringToHex };
|
||||
//# sourceMappingURL=stringConversion.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stringConversion.d.ts","sourceRoot":"","sources":["../../../src/utils/stringConversion.ts"],"names":[],"mappings":";AAOA,iBAAS,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAUD,iBAAS,kBAAkB,CACzB,GAAG,EAAE,MAAM,EACX,QAAQ,GAAE,cAAuB,GAChC,MAAM,CAER;AAED,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,CAAA"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.convertStringToHex = exports.convertHexToString = void 0;
|
||||
function convertStringToHex(string) {
|
||||
return Buffer.from(string, 'utf8').toString('hex').toUpperCase();
|
||||
}
|
||||
exports.convertStringToHex = convertStringToHex;
|
||||
function convertHexToString(hex, encoding = 'utf8') {
|
||||
return Buffer.from(hex, 'hex').toString(encoding);
|
||||
}
|
||||
exports.convertHexToString = convertHexToString;
|
||||
//# sourceMappingURL=stringConversion.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"stringConversion.js","sourceRoot":"","sources":["../../../src/utils/stringConversion.ts"],"names":[],"mappings":";;;AAOA,SAAS,kBAAkB,CAAC,MAAc;IACxC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAA;AAClE,CAAC;AAiB4B,gDAAkB;AAP/C,SAAS,kBAAkB,CACzB,GAAW,EACX,WAA2B,MAAM;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;AACnD,CAAC;AAEQ,gDAAkB"}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
declare function rippleTimeToUnixTime(rpepoch: number): number;
|
||||
declare function unixTimeToRippleTime(timestamp: number): number;
|
||||
declare function rippleTimeToISOTime(rippleTime: number): string;
|
||||
declare function isoTimeToRippleTime(iso8601: string | Date): number;
|
||||
export { rippleTimeToUnixTime, unixTimeToRippleTime, rippleTimeToISOTime, isoTimeToRippleTime, };
|
||||
//# sourceMappingURL=timeConversion.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"timeConversion.d.ts","sourceRoot":"","sources":["../../../src/utils/timeConversion.ts"],"names":[],"mappings":"AASA,iBAAS,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAErD;AASD,iBAAS,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvD;AASD,iBAAS,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEvD;AASD,iBAAS,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAG3D;AAED,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,CAAA"}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isoTimeToRippleTime = exports.rippleTimeToISOTime = exports.unixTimeToRippleTime = exports.rippleTimeToUnixTime = void 0;
|
||||
const RIPPLE_EPOCH_DIFF = 0x386d4380;
|
||||
function rippleTimeToUnixTime(rpepoch) {
|
||||
return (rpepoch + RIPPLE_EPOCH_DIFF) * 1000;
|
||||
}
|
||||
exports.rippleTimeToUnixTime = rippleTimeToUnixTime;
|
||||
function unixTimeToRippleTime(timestamp) {
|
||||
return Math.round(timestamp / 1000) - RIPPLE_EPOCH_DIFF;
|
||||
}
|
||||
exports.unixTimeToRippleTime = unixTimeToRippleTime;
|
||||
function rippleTimeToISOTime(rippleTime) {
|
||||
return new Date(rippleTimeToUnixTime(rippleTime)).toISOString();
|
||||
}
|
||||
exports.rippleTimeToISOTime = rippleTimeToISOTime;
|
||||
function isoTimeToRippleTime(iso8601) {
|
||||
const isoDate = typeof iso8601 === 'string' ? new Date(iso8601) : iso8601;
|
||||
return unixTimeToRippleTime(isoDate.getTime());
|
||||
}
|
||||
exports.isoTimeToRippleTime = isoTimeToRippleTime;
|
||||
//# sourceMappingURL=timeConversion.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"timeConversion.js","sourceRoot":"","sources":["../../../src/utils/timeConversion.ts"],"names":[],"mappings":";;;AAAA,MAAM,iBAAiB,GAAG,UAAU,CAAA;AASpC,SAAS,oBAAoB,CAAC,OAAe;IAC3C,OAAO,CAAC,OAAO,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAA;AAC7C,CAAC;AAqCC,oDAAoB;AA5BtB,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,iBAAiB,CAAA;AACzD,CAAC;AA2BC,oDAAoB;AAlBtB,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,OAAO,IAAI,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AACjE,CAAC;AAiBC,kDAAmB;AARrB,SAAS,mBAAmB,CAAC,OAAsB;IACjD,MAAM,OAAO,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;IACzE,OAAO,oBAAoB,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;AAChD,CAAC;AAMC,kDAAmB"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
declare function verifyPaymentChannelClaim(channel: string, amount: string, signature: string, publicKey: string): boolean;
|
||||
export default verifyPaymentChannelClaim;
|
||||
//# sourceMappingURL=verifyPaymentChannelClaim.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"verifyPaymentChannelClaim.d.ts","sourceRoot":"","sources":["../../../src/utils/verifyPaymentChannelClaim.ts"],"names":[],"mappings":"AAgBA,iBAAS,yBAAyB,CAChC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,OAAO,CAMT;AAED,eAAe,yBAAyB,CAAA"}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
const xrpConversion_1 = require("./xrpConversion");
|
||||
function verifyPaymentChannelClaim(channel, amount, signature, publicKey) {
|
||||
const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
|
||||
channel,
|
||||
amount: (0, xrpConversion_1.xrpToDrops)(amount),
|
||||
});
|
||||
return (0, ripple_keypairs_1.verify)(signingData, signature, publicKey);
|
||||
}
|
||||
exports.default = verifyPaymentChannelClaim;
|
||||
//# sourceMappingURL=verifyPaymentChannelClaim.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"verifyPaymentChannelClaim.js","sourceRoot":"","sources":["../../../src/utils/verifyPaymentChannelClaim.ts"],"names":[],"mappings":";;AAAA,6DAA2D;AAC3D,qDAAwC;AAExC,mDAA4C;AAa5C,SAAS,yBAAyB,CAChC,OAAe,EACf,MAAc,EACd,SAAiB,EACjB,SAAiB;IAEjB,MAAM,WAAW,GAAG,IAAA,2CAAqB,EAAC;QACxC,OAAO;QACP,MAAM,EAAE,IAAA,0BAAU,EAAC,MAAM,CAAC;KAC3B,CAAC,CAAA;IACF,OAAO,IAAA,wBAAM,EAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAAC,CAAA;AAClD,CAAC;AAED,kBAAe,yBAAyB,CAAA"}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import BigNumber from 'bignumber.js';
|
||||
export declare function dropsToXrp(dropsToConvert: BigNumber.Value): string;
|
||||
export declare function xrpToDrops(xrpToConvert: BigNumber.Value): string;
|
||||
//# sourceMappingURL=xrpConversion.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"xrpConversion.d.ts","sourceRoot":"","sources":["../../../src/utils/xrpConversion.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAA;AAiBpC,wBAAgB,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,KAAK,GAAG,MAAM,CAoClE;AAUD,wBAAgB,UAAU,CAAC,YAAY,EAAE,SAAS,CAAC,KAAK,GAAG,MAAM,CAwChE"}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.xrpToDrops = exports.dropsToXrp = void 0;
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const errors_1 = require("../errors");
|
||||
const DROPS_PER_XRP = 1000000.0;
|
||||
const MAX_FRACTION_LENGTH = 6;
|
||||
const BASE_TEN = 10;
|
||||
const SANITY_CHECK = /^-?[0-9.]+$/u;
|
||||
function dropsToXrp(dropsToConvert) {
|
||||
const drops = new bignumber_js_1.default(dropsToConvert).toString(BASE_TEN);
|
||||
if (typeof dropsToConvert === 'string' && drops === 'NaN') {
|
||||
throw new errors_1.ValidationError(`dropsToXrp: invalid value '${dropsToConvert}', should be a BigNumber or string-encoded number.`);
|
||||
}
|
||||
if (drops.includes('.')) {
|
||||
throw new errors_1.ValidationError(`dropsToXrp: value '${drops}' has too many decimal places.`);
|
||||
}
|
||||
if (!SANITY_CHECK.exec(drops)) {
|
||||
throw new errors_1.ValidationError(`dropsToXrp: failed sanity check -` +
|
||||
` value '${drops}',` +
|
||||
` does not match (^-?[0-9]+$).`);
|
||||
}
|
||||
return new bignumber_js_1.default(drops).dividedBy(DROPS_PER_XRP).toString(BASE_TEN);
|
||||
}
|
||||
exports.dropsToXrp = dropsToXrp;
|
||||
function xrpToDrops(xrpToConvert) {
|
||||
const xrp = new bignumber_js_1.default(xrpToConvert).toString(BASE_TEN);
|
||||
if (typeof xrpToConvert === 'string' && xrp === 'NaN') {
|
||||
throw new errors_1.ValidationError(`xrpToDrops: invalid value '${xrpToConvert}', should be a BigNumber or string-encoded number.`);
|
||||
}
|
||||
if (!SANITY_CHECK.exec(xrp)) {
|
||||
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}', does not match (^-?[0-9.]+$).`);
|
||||
}
|
||||
const components = xrp.split('.');
|
||||
if (components.length > 2) {
|
||||
throw new errors_1.ValidationError(`xrpToDrops: failed sanity check - value '${xrp}' has too many decimal points.`);
|
||||
}
|
||||
const fraction = components[1] || '0';
|
||||
if (fraction.length > MAX_FRACTION_LENGTH) {
|
||||
throw new errors_1.ValidationError(`xrpToDrops: value '${xrp}' has too many decimal places.`);
|
||||
}
|
||||
return new bignumber_js_1.default(xrp)
|
||||
.times(DROPS_PER_XRP)
|
||||
.integerValue(bignumber_js_1.default.ROUND_FLOOR)
|
||||
.toString(BASE_TEN);
|
||||
}
|
||||
exports.xrpToDrops = xrpToDrops;
|
||||
//# sourceMappingURL=xrpConversion.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"xrpConversion.js","sourceRoot":"","sources":["../../../src/utils/xrpConversion.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AAEpC,sCAA2C;AAE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