mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 04:05:52 +00:00
clean up code
This commit is contained in:
@@ -27,7 +27,9 @@ function isoCodeFromHex(code: Buffer): string | undefined {
|
||||
const iso = code.toString();
|
||||
console.log(iso);
|
||||
if (iso === "XRP") {
|
||||
throw new Error("Disallowed currency code: to indicate the currency XRP you must use 20 bytes of 0s");
|
||||
throw new Error(
|
||||
"Disallowed currency code: to indicate the currency XRP you must use 20 bytes of 0s"
|
||||
);
|
||||
}
|
||||
if (isIsoCode(iso)) {
|
||||
return iso;
|
||||
@@ -81,24 +83,10 @@ function bytesFromRepresentation(input: string): Buffer {
|
||||
class Currency extends Hash160 {
|
||||
static readonly XRP = new Currency(Buffer.alloc(20));
|
||||
private readonly _iso?: string;
|
||||
// private readonly _isNative: boolean;
|
||||
|
||||
constructor(byteBuf: Buffer) {
|
||||
super(byteBuf ?? Currency.XRP.bytes);
|
||||
|
||||
// let onlyISO = true;
|
||||
|
||||
// const bytes = this.bytes;
|
||||
const code = this.bytes.slice(12, 15);
|
||||
// const iso = code.toString();
|
||||
|
||||
|
||||
// for (let i = bytes.length - 1; i >= 0; i--) {
|
||||
// if (bytes[i] !== 0 && !(i === 12 || i === 13 || i === 14)) {
|
||||
// onlyISO = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
if (this.bytes[0] !== 0 && this.bytes[0] !== 0) {
|
||||
this._iso = undefined;
|
||||
@@ -107,21 +95,8 @@ class Currency extends Hash160 {
|
||||
} else {
|
||||
this._iso = isoCodeFromHex(code);
|
||||
}
|
||||
|
||||
// const lossLessISO = onlyISO && iso !== "XRP" && ISO_REGEX.test(iso);
|
||||
// this._isNative = onlyISO && code.toString("hex") === "000000";
|
||||
// this._iso = this._isNative ? "XRP" : lossLessISO ? iso : undefined;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Tells if this currency is native
|
||||
// *
|
||||
// * @returns true if native, false if not
|
||||
// */
|
||||
// isNative(): boolean {
|
||||
// return this._isNative;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Return the ISO code of this currency
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user