neo-convertor
Version:
A tool to convert neo smart contract data to human-readable one
26 lines (25 loc) • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const UintVariable_1 = require("./UintVariable");
const libs_1 = require("../libs");
class Uint160 extends UintVariable_1.UintVariable {
constructor(value = new ArrayBuffer(20)) {
super(new Uint32Array(value));
if (value.byteLength !== 20) {
throw new RangeError();
}
}
}
Uint160.Zero = new Uint160();
Uint160.parse = (str) => {
if (str.length !== 40) {
throw new RangeError();
}
let x = libs_1.hexToBytes(str);
let y = new Uint8Array(x.length);
for (let i = 0; i < y.length; i++) {
y[i] = x[x.length - i - 1];
}
return new Uint160(y.buffer);
};
exports.Uint160 = Uint160;