mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-27 23:55:49 +00:00
attempted test fix
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { Hash160 } from "./hash-160";
|
import { Hash160 } from "./hash-160";
|
||||||
import { Buffer } from "buffer/";
|
import { Buffer } from "buffer/";
|
||||||
|
|
||||||
const ISO_REGEX = /^[A-Z0-9]{3}$/;
|
const ISO_REGEX = /^[A-Za-z0-9]{3}$/;
|
||||||
const HEX_REGEX = /^[A-F0-9]{40}$/;
|
const HEX_REGEX = /^[A-F0-9]{40}$/;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,7 +25,6 @@ function isIsoCode(iso: string): boolean {
|
|||||||
|
|
||||||
function isoCodeFromHex(code: Buffer): string | undefined {
|
function isoCodeFromHex(code: Buffer): string | undefined {
|
||||||
const iso = code.toString();
|
const iso = code.toString();
|
||||||
console.log(iso);
|
|
||||||
if (iso === "XRP") {
|
if (iso === "XRP") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"Disallowed currency code: to indicate the currency XRP you must use 20 bytes of 0s"
|
"Disallowed currency code: to indicate the currency XRP you must use 20 bytes of 0s"
|
||||||
@@ -62,6 +61,7 @@ function isBytesArray(bytes: Buffer): boolean {
|
|||||||
* Ensures that a value is a valid representation of a currency
|
* Ensures that a value is a valid representation of a currency
|
||||||
*/
|
*/
|
||||||
function isValidRepresentation(input: Buffer | string): boolean {
|
function isValidRepresentation(input: Buffer | string): boolean {
|
||||||
|
console.log(input, input instanceof Buffer);
|
||||||
return input instanceof Buffer
|
return input instanceof Buffer
|
||||||
? isBytesArray(input)
|
? isBytesArray(input)
|
||||||
: isStringRepresentation(input);
|
: isStringRepresentation(input);
|
||||||
@@ -71,6 +71,7 @@ function isValidRepresentation(input: Buffer | string): boolean {
|
|||||||
* Generate bytes from a string or buffer representation of a currency
|
* Generate bytes from a string or buffer representation of a currency
|
||||||
*/
|
*/
|
||||||
function bytesFromRepresentation(input: string): Buffer {
|
function bytesFromRepresentation(input: string): Buffer {
|
||||||
|
console.log(input);
|
||||||
if (!isValidRepresentation(input)) {
|
if (!isValidRepresentation(input)) {
|
||||||
throw new Error(`Unsupported Currency representation: ${input}`);
|
throw new Error(`Unsupported Currency representation: ${input}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user