diff --git a/packages/ethers/src.ts/utils.ts b/packages/ethers/src.ts/utils.ts index 048a8b6374..87b4e9e34a 100644 --- a/packages/ethers/src.ts/utils.ts +++ b/packages/ethers/src.ts/utils.ts @@ -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, diff --git a/packages/sha2/src.ts/browser.ts b/packages/sha2/src.ts/browser.ts index 7dd0d19d68..fba6525056 100644 --- a/packages/sha2/src.ts/browser.ts +++ b/packages/sha2/src.ts/browser.ts @@ -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 diff --git a/packages/sha2/src.ts/index.ts b/packages/sha2/src.ts/index.ts index a9f18dcda7..7c6733fbc9 100644 --- a/packages/sha2/src.ts/index.ts +++ b/packages/sha2/src.ts/index.ts @@ -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