Refactor some enum names and add UTF-8 error support to the umbrella package.

This commit is contained in:
Richard Moore 2020-01-20 19:29:06 -05:00
parent 5878b54d6e
commit 931da2f774
No known key found for this signature in database
GPG Key ID: 665176BE8E9DC651
3 changed files with 16 additions and 11 deletions

View File

@ -15,7 +15,7 @@ import { randomBytes } from "@ethersproject/random";
import { checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties";
import * as RLP from "@ethersproject/rlp";
import { computePublicKey, recoverPublicKey, SigningKey } from "@ethersproject/signing-key";
import { formatBytes32String, nameprep, parseBytes32String, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String } from "@ethersproject/strings";
import { formatBytes32String, nameprep, parseBytes32String, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, Utf8ErrorFuncs } from "@ethersproject/strings";
import { computeAddress, parse as parseTransaction, recoverAddress, serialize as serializeTransaction } from "@ethersproject/transactions";
import { commify, formatEther, parseEther, formatUnits, parseUnits } from "@ethersproject/units";
import { verifyMessage } from "@ethersproject/wallet";
@ -24,8 +24,8 @@ import { fetchJson, poll } from "@ethersproject/web";
////////////////////////
// Enums
import { SupportedAlgorithms } from "@ethersproject/sha2";
import { UnicodeNormalizationForm } from "@ethersproject/strings";
import { SupportedAlgorithm } from "@ethersproject/sha2";
import { UnicodeNormalizationForm, Utf8ErrorReason } from "@ethersproject/strings";
////////////////////////
@ -35,6 +35,7 @@ import { CoerceFunc } from "@ethersproject/abi";
import { Bytes, BytesLike, Hexable } from "@ethersproject/bytes"
import { Mnemonic } from "@ethersproject/hdnode";
import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets";
import { Utf8ErrorFunc } from "@ethersproject/strings";
import { ConnectionInfo, FetchJsonResponse, OnceBlockable, PollOptions } from "@ethersproject/web";
////////////////////////
@ -91,6 +92,7 @@ export {
toUtf8Bytes,
toUtf8CodePoints,
toUtf8String,
Utf8ErrorFuncs,
formatBytes32String,
parseBytes32String,
@ -148,9 +150,10 @@ export {
////////////////////////
// Enums
SupportedAlgorithms,
UnicodeNormalizationForm,
SupportedAlgorithm,
UnicodeNormalizationForm,
Utf8ErrorReason,
////////////////////////
// Types
@ -165,6 +168,8 @@ export {
Mnemonic,
Utf8ErrorFunc,
ConnectionInfo,
OnceBlockable,
PollOptions,

View File

@ -8,7 +8,7 @@ import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
export enum SupportedAlgorithms { sha256 = "sha256", sha512 = "sha512" };
export enum SupportedAlgorithm { sha256 = "sha256", sha512 = "sha512" };
export function ripemd160(data: BytesLike): string {
return "0x" + (hash.ripemd160().update(arrayify(data)).digest("hex"));
@ -23,8 +23,8 @@ export function sha512(data: BytesLike): string {
}
export function computeHmac(algorithm: SupportedAlgorithms, key: BytesLike, data: BytesLike): string {
if (!SupportedAlgorithms[algorithm]) {
export function computeHmac(algorithm: SupportedAlgorithm, key: BytesLike, data: BytesLike): string {
if (!SupportedAlgorithm[algorithm]) {
logger.throwError("unsupported algorithm " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, {
operation: "hmac",
algorithm: algorithm

View File

@ -8,7 +8,7 @@ import { Logger } from "@ethersproject/logger";
import { version } from "./_version";
const logger = new Logger(version);
export enum SupportedAlgorithms { sha256 = "sha256", sha512 = "sha512" };
export enum SupportedAlgorithm { sha256 = "sha256", sha512 = "sha512" };
export function ripemd160(data: BytesLike): string {
@ -24,8 +24,8 @@ export function sha512(data: BytesLike): string {
}
export function computeHmac(algorithm: SupportedAlgorithms, key: BytesLike, data: BytesLike): string {
if (!SupportedAlgorithms[algorithm]) {
export function computeHmac(algorithm: SupportedAlgorithm, key: BytesLike, data: BytesLike): string {
if (!SupportedAlgorithm[algorithm]) {
logger.throwError("unsupported algorithm - " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, {
operation: "computeHmac",
algorithm: algorithm