mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
make code uglify-compatible - do not use Function.name
This commit is contained in:
@@ -12,7 +12,7 @@ const {sha512Half, transactionID} = require('./hashes');
|
|||||||
|
|
||||||
const makeParser = bytes => new BinaryParser(bytes);
|
const makeParser = bytes => new BinaryParser(bytes);
|
||||||
const readJSON = parser => parser.readType(types.STObject).toJSON();
|
const readJSON = parser => parser.readType(types.STObject).toJSON();
|
||||||
const binaryToJSON = (bytes) => readJSON(makeParser(bytes));
|
const binaryToJSON = bytes => readJSON(makeParser(bytes));
|
||||||
|
|
||||||
function serializeObject(object, opts = {}) {
|
function serializeObject(object, opts = {}) {
|
||||||
const {prefix, suffix, signingFieldsOnly = false} = opts;
|
const {prefix, suffix, signingFieldsOnly = false} = opts;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ const {
|
|||||||
const FULL_CANONICAL_SIGNATURE = 0x80000000;
|
const FULL_CANONICAL_SIGNATURE = 0x80000000;
|
||||||
|
|
||||||
const toHex = v => bytesToHex(v);
|
const toHex = v => bytesToHex(v);
|
||||||
const getSigner = (o) => AccountID.from(o.Signer.Account);
|
const getSigner = o => AccountID.from(o.Signer.Account);
|
||||||
const signerComparator = (a, b) => getSigner(a).compareTo(getSigner(b));
|
const signerComparator = (a, b) => getSigner(a).compareTo(getSigner(b));
|
||||||
|
|
||||||
function setCanonicalSignatureFlag(tx_json) {
|
function setCanonicalSignatureFlag(tx_json) {
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ module.exports = function makeClass(klass_, definition_) {
|
|||||||
klass = function() {};
|
klass = function() {};
|
||||||
}
|
}
|
||||||
const proto = klass.prototype;
|
const proto = klass.prototype;
|
||||||
function addFunc(original, wrapper) {
|
function addFunc(original, name, wrapper) {
|
||||||
proto[original.name] = wrapper || original;
|
proto[name] = wrapper || original;
|
||||||
}
|
}
|
||||||
(definition.getters || []).forEach(k => {
|
(definition.getters || []).forEach(k => {
|
||||||
const key = '_' + k;
|
const key = '_' + k;
|
||||||
@@ -47,24 +47,24 @@ module.exports = function makeClass(klass_, definition_) {
|
|||||||
return this[key];
|
return this[key];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
forEach(definition.virtuals, f => {
|
forEach(definition.virtuals, (f, n) => {
|
||||||
addFunc(f, function() {
|
addFunc(f, n, function() {
|
||||||
throw new Error('unimplemented');
|
throw new Error('unimplemented');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
forEach(definition.methods, addFunc);
|
forEach(definition.methods, addFunc);
|
||||||
forEach(definition, f => {
|
forEach(definition, (f, n) => {
|
||||||
if (_.isFunction(f) && f !== klass) {
|
if (_.isFunction(f) && f !== klass) {
|
||||||
addFunc(f);
|
addFunc(f, n);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_.assign(klass, definition.statics);
|
_.assign(klass, definition.statics);
|
||||||
if (typeof klass.init === 'function') {
|
if (typeof klass.init === 'function') {
|
||||||
klass.init();
|
klass.init();
|
||||||
}
|
}
|
||||||
forEach(definition.cached, f => {
|
forEach(definition.cached, (f, n) => {
|
||||||
const key = '_' + f.name;
|
const key = '_' + n;
|
||||||
addFunc(f, function() {
|
addFunc(f, n, function() {
|
||||||
let value = this[key];
|
let value = this[key];
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
value = this[key] = f.call(this);
|
value = this[key] = f.call(this);
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ function UIntTest() {
|
|||||||
|
|
||||||
|
|
||||||
function parseLedger4320278() {
|
function parseLedger4320278() {
|
||||||
it(`can parse object`, (done) => {
|
it(`can parse object`, done => {
|
||||||
this.timeout(30e3);
|
this.timeout(30e3);
|
||||||
const json = loadFixture('as-ledger-4320278.json');
|
const json = loadFixture('as-ledger-4320278.json');
|
||||||
json.forEach((e) => {
|
json.forEach(e => {
|
||||||
assertRecycles(e.binary);
|
assertRecycles(e.binary);
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
|
|||||||
Reference in New Issue
Block a user