Compare commits

..

7 Commits

Author SHA1 Message Date
Richard Moore
6372a46b1b Allow null type in transaction receipt for legacy type 0 networks (#3459). 2023-02-12 22:12:12 -05:00
Richard Moore
2ba4a17255 Fixed events when slicing immutable Result (#3765). 2023-02-12 22:06:39 -05:00
Richard Moore
37bf4fb555 More robust support on networks which throw when filters are not supported (#3767). 2023-02-12 22:04:20 -05:00
Richard Moore
400d57621b Fixed ignored polling override for JsonRpcApiProvider. 2023-02-12 22:03:37 -05:00
Richard Moore
314595113c docs: added more jsdocs and examples 2023-02-12 21:21:11 -05:00
Richard Moore
0bf53d7804 admin: updated dist files 2023-02-04 08:27:45 -05:00
Richard Moore
ef84706312 docs: added post-build folder docs copying to scripts 2023-02-04 08:26:56 -05:00
47 changed files with 200 additions and 141 deletions

22
dist/README.md vendored Normal file
View File

@@ -0,0 +1,22 @@
Distribution Folder
===================
The contents of this folder are for using `import` in ESM
browser-base projects.
The `ethers.js` (and `ethers.min.js`) files only include the
English wordlist to conserve space.
For additional Wordlist support, the `wordlist-extra.js` (and
`wordlist-extra.min.js`) should be imported too.
Notes
-----
The contents are generated via the `npm build dist` target using
`rollup` and the `/rollup.config.js` configuration.
Do not modify the files in this folder. They are deleted on `build-clean`.
To modify this `README.md`, see the `/output/post-build/dist`.

9
dist/ethers.js vendored
View File

@@ -1,4 +1,4 @@
const version = "6.0.1";
const version = "6.0.2";
/**
* Property helper functions.
@@ -1065,17 +1065,14 @@ class FetchCancelSignal {
});
}
addListener(listener) {
assert$1(this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
assert$1(!this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
operation: "fetchCancelSignal.addCancelListener"
});
this.#listeners.push(listener);
}
get cancelled() { return this.#cancelled; }
checkSignal() {
if (!this.cancelled) {
return;
}
assert$1(false, "cancelled", "CANCELLED", {});
assert$1(!this.cancelled, "cancelled", "CANCELLED", {});
}
}
// Check the signal, throwing if it is cancelled

2
dist/ethers.js.map vendored

File diff suppressed because one or more lines are too long

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -145,7 +145,7 @@ const u64 = {
add, add3L, add3H, add4L, add4H, add5H, add5L,
};
const version = "6.0.1";
const version = "6.0.2";
/**
* Property helper functions.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,16 @@
CommonJS Generated Files
========================
CommonJS Files
==============
The contents of this folder are for using `require` in CommonJS
projects.
Notes
-----
The contents are generated via the `npm run build-commonjs` target
using `tsc` and the `/tsconfig.commonjs.json` configuration.
Do not modify the files in this folder. They are deleted on `build-clean`.
These files are generated from the `/tsconfig.commonjs.json`
To modify this `README.md`, see the `/output/post-build/lib.commonjs`.

View File

@@ -1,5 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = void 0;
exports.version = "6.0.1";
exports.version = "6.0.2";
//# sourceMappingURL=_version.js.map

View File

@@ -80,17 +80,14 @@ class FetchCancelSignal {
});
}
addListener(listener) {
(0, errors_js_1.assert)(this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
(0, errors_js_1.assert)(!this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
operation: "fetchCancelSignal.addCancelListener"
});
this.#listeners.push(listener);
}
get cancelled() { return this.#cancelled; }
checkSignal() {
if (!this.cancelled) {
return;
}
(0, errors_js_1.assert)(false, "cancelled", "CANCELLED", {});
(0, errors_js_1.assert)(!this.cancelled, "cancelled", "CANCELLED", {});
}
}
exports.FetchCancelSignal = FetchCancelSignal;

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,16 @@
ESM Generated Files
===================
ESM Files
=========
The contents of this folder are for using `import` in ESM
projects.
Notes
-----
The contents are generated via the `npm run build` target
using `tsc` and the `/tsconfig.esm.json` configuration.
Do not modify the files in this folder. They are deleted on `build-clean`.
These files are generated from the `/tsconfig.esm.json`
To modify this `README.md`, see the `/output/post-build/lib.esm`.

View File

@@ -1,2 +1,2 @@
export const version = "6.0.1";
export const version = "6.0.2";
//# sourceMappingURL=_version.js.map

View File

@@ -77,17 +77,14 @@ export class FetchCancelSignal {
});
}
addListener(listener) {
assert(this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
assert(!this.#cancelled, "singal already cancelled", "UNSUPPORTED_OPERATION", {
operation: "fetchCancelSignal.addCancelListener"
});
this.#listeners.push(listener);
}
get cancelled() { return this.#cancelled; }
checkSignal() {
if (!this.cancelled) {
return;
}
assert(false, "cancelled", "CANCELLED", {});
assert(!this.cancelled, "cancelled", "CANCELLED", {});
}
}
// Check the signal, throwing if it is cancelled

File diff suppressed because one or more lines are too long

View File

@@ -104,7 +104,7 @@
"url": "https://www.buymeacoffee.com/ricmoo"
}
],
"gitHead": "faa556c1e5f727105ec6cdc5ed25de30095108d6",
"gitHead": "6c338c1c5b4013db9754c9d1a33dcbf54330e5c7",
"homepage": "https://ethers.org",
"keywords": [
"ethereum",
@@ -125,7 +125,7 @@
},
"scripts": {
"_build-clean": "npm run clean && node lib.esm/_admin/update-version-const && npm run build-all && npm run _build-dist",
"_build-dist": "rollup -c && uglifyjs ./dist/ethers.js -o ./dist/ethers.min.js && uglifyjs ./dist/wordlists-extra.js -o ./dist/wordlists-extra.min.js",
"_build-dist": "rollup -c && uglifyjs ./dist/ethers.js -o ./dist/ethers.min.js && uglifyjs ./dist/wordlists-extra.js -o ./dist/wordlists-extra.min.js && cp ./output/post-build/dist/* ./dist/",
"_dist-stats": "gzip -k9f -S '.gz' ./dist/ethers.min.js && gzip -k9f -S '.gz' ./dist/wordlists-extra.min.js && du -hs ./dist/*.gz && echo '' && du -hs ./dist/*.js",
"auto-build": "npm run build -- -w",
"build": "tsc --project tsconfig.esm.json",
@@ -134,7 +134,7 @@
"build-commonjs": "tsc --project tsconfig.commonjs.json && cp ./output/post-build/lib.commonjs/* ./lib.commonjs/",
"build-dist": "npm run build && npm run _build-dist && npm run _dist-stats",
"build-docs": "echo 'foo'",
"build-types": "tsc --project tsconfig.types.json",
"build-types": "tsc --project tsconfig.types.json && cp ./output/post-build/types/* ./types/",
"clean": "rm -rf dist lib.esm lib.commonjs types",
"stats": "echo 'Dependencies' && npm ls --all --omit=dev",
"test": "npm run test-esm",
@@ -145,5 +145,5 @@
"sideEffects": false,
"type": "module",
"types": "./types/index.d.ts",
"version": "6.0.1"
"version": "6.0.2"
}

View File

@@ -1 +1 @@
export const version: string = "6.0.1";
export const version: string = "6.0.2";

View File

@@ -219,7 +219,7 @@ export class AbiCoder {
}
/**
* Returns an ethers-compatible [[CALL_EXCEPTION]] Error for the given
* Returns an ethers-compatible [[CallExceptionError]] Error for the given
* result %%data%% for the [[CallExceptionAction]] %%action%% against
* the Transaction %%tx%%.
*/

View File

@@ -1,7 +1,7 @@
/**
* About frgaments...
*
* @_subsection api/abi/abi-coder:Fragments
* @_subsection api/abi/abi-coder:Fragments [about-fragments]
*/
import {
@@ -537,29 +537,28 @@ export class ParamType {
/**
* True if the parameters is indexed.
*
* For non-indexable types (see [[ParamType_isIndexable]]) this
* is ``null``.
* For non-indexable types this is ``null``.
*/
readonly indexed!: null | boolean;
/**
* The components for the tuple.
*
* For non-tuple types (see [[ParamType_isTuple]]) this is ``null``.
* For non-tuple types this is ``null``.
*/
readonly components!: null | ReadonlyArray<ParamType>;
/**
* The array length, or ``-1`` for dynamic-lengthed arrays.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
readonly arrayLength!: null | number;
/**
* The type of each child in the array.
*
* For non-array types (see [[ParamType_isArray]]) this is ``null``.
* For non-array types this is ``null``.
*/
readonly arrayChildren!: null | ParamType;

View File

@@ -1,7 +1,7 @@
/**
* Explain about ABI here...
*
* @_section api/abi:Application Binary Interface [abi]
* @_section api/abi:Application Binary Interface [about-abi]
* @_navTitle: ABI
*/

View File

@@ -660,7 +660,7 @@ export class Interface {
* specified error (see [[getError]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/
@@ -742,7 +742,7 @@ export class Interface {
* specified function (see [[getFunction]] for valid values for
* %%key%%).
*
* Most developers should prefer the [[parseResult]] method instead,
* Most developers should prefer the [[parseCallResult]] method instead,
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
* corresponding error.
*/

View File

@@ -10,7 +10,7 @@
* These functions help convert between various formats, validate
* addresses and safely resolve ENS names.
*
* @_section: api/address:Addresses [addresses]
* @_section: api/address:Addresses [about-addresses]
*/
null;

View File

@@ -1,7 +1,7 @@
/**
* Some common constants useful for Ethereum.
*
* @_section: api/constants: Constants [constants]
* @_section: api/constants: Constants [about-constants]
*/
export { ZeroAddress } from "./addresses.js";

View File

@@ -586,7 +586,7 @@ async function _emit(contract: BaseContract, event: ContractEventName, args: Arr
const count = sub.listeners.length;
sub.listeners = sub.listeners.filter(({ listener, once }) => {
const passArgs = args.slice();
const passArgs = Array.from(args);
if (payloadFunc) {
passArgs.push(payloadFunc(once ? null: listener));
}

View File

@@ -1,7 +1,7 @@
/**
* About contracts...
*
* @_section: api/contract:Contracts [contracts]
* @_section: api/contract:Contracts [about-contracts]
*/
export {
BaseContract, Contract

View File

@@ -2,7 +2,7 @@
* A fundamental building block of Ethereum is the underlying
* cryptographic primitives.
*
* @_section: api/crypto:Cryptographic Functions [crypto]
* @_section: api/crypto:Cryptographic Functions [about-crypto]
*/
null

View File

@@ -9,6 +9,8 @@ import type { BytesLike } from "../utils/index.js";
* UI or provide programatic access to the progress.
*
* The %%percent%% is a value between ``0`` and ``1``.
*
* @_docloc: api/crypto:Passwords
*/
export type ProgressCallback = (percent: number) => void;

View File

@@ -1,3 +1,4 @@
import { ZeroHash } from "../constants/index.js";
import {
concat, dataLength, getBigInt, getBytes, getNumber, hexlify,
@@ -22,6 +23,12 @@ const BN_35 = BigInt(35);
const _guard = { };
// @TODO: Allow Uint8Array
/**
* A SignatureLike
*
* @_docloc: api/crypto:Signing
*/
export type SignatureLike = Signature | string | {
r: string;
s: string;
@@ -48,6 +55,9 @@ function toUint256(value: BigNumberish): string {
/**
* A Signature @TODO
*
*
* @_docloc: api/crypto:Signing
*/
export class Signature {
#r: string;

View File

@@ -1,3 +1,8 @@
/**
* Add details about signing here.
*
* @_subsection: api/crypto:Signing [about-signing]
*/
import * as secp256k1 from "@noble/secp256k1";

View File

@@ -1,7 +1,7 @@
/**
* About hashing here...
*
* @_section: api/hashing:Hashing Utilities [hashing]
* @_section: api/hashing:Hashing Utilities [about-hashing]
*/
export { id } from "./id.js"

View File

@@ -168,7 +168,7 @@ const _formatTransactionReceipt = object({
cumulativeGasUsed: getBigInt,
effectiveGasPrice: allowNull(getBigInt),
status: allowNull(getNumber),
type: getNumber
type: allowNull(getNumber, 0)
}, {
effectiveGasPrice: [ "gasPrice" ],
hash: [ "transactionHash" ],

View File

@@ -1,7 +1,7 @@
/**
* About providers.
*
* @_section: api/providers:Providers [providers]
* @_section: api/providers:Providers [about-providers]
*/

View File

@@ -23,6 +23,7 @@ import { AbstractProvider, UnmanagedSubscriber } from "./abstract-provider.js";
import { AbstractSigner } from "./abstract-signer.js";
import { Network } from "./network.js";
import { FilterIdEventSubscriber, FilterIdPendingSubscriber } from "./subscriber-filterid.js";
import { PollingEventSubscriber } from "./subscriber-polling.js";
import type { TypedDataDomain, TypedDataField } from "../hash/index.js";
import type { TransactionLike } from "../transaction/index.js";
@@ -628,6 +629,9 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
if (sub.type === "pending") { return new FilterIdPendingSubscriber(this); }
if (sub.type === "event") {
if (this._getOption("polling")) {
return new PollingEventSubscriber(this, sub.filter);
}
return new FilterIdEventSubscriber(this, sub.filter);
}
@@ -806,74 +810,6 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
);
e.info = { error, payload };
return e;
/*
let message = "missing revert data during JSON-RPC call";
const action = <"call" | "estimateGas" | "unknown">(({ eth_call: "call", eth_estimateGas: "estimateGas" })[method] || "unknown");
let data: null | string = null;
let reason: null | string = null;
const transaction = <{ from: string, to: string, data: string }>((<any>payload).params[0]);
const invocation = null;
let revert: null | { signature: string, name: string, args: Array<any> } = null;
if (result) {
// @TODO: Extract errorSignature, errorName, errorArgs, reason if
// it is Error(string) or Panic(uint25)
message = "execution reverted during JSON-RPC call";
data = result.data;
let bytes = getBytes(data);
if (bytes.length % 32 !== 4) {
message += " (could not parse reason; invalid data length)";
} else if (data.substring(0, 10) === "0x08c379a0") {
// Error(string)
try {
if (bytes.length < 68) { throw new Error("bad length"); }
bytes = bytes.slice(4);
const pointer = getNumber(hexlify(bytes.slice(0, 32)));
bytes = bytes.slice(pointer);
if (bytes.length < 32) { throw new Error("overrun"); }
const length = getNumber(hexlify(bytes.slice(0, 32)));
bytes = bytes.slice(32);
if (bytes.length < length) { throw new Error("overrun"); }
reason = toUtf8String(bytes.slice(0, length));
revert = {
signature: "Error(string)",
name: "Error",
args: [ reason ]
};
message += `: ${ JSON.stringify(reason) }`;
} catch (error) {
console.log(error);
message += " (could not parse reason; invalid data length)";
}
} else if (data.substring(0, 10) === "0x4e487b71") {
// Panic(uint256)
try {
if (bytes.length !== 36) { throw new Error("bad length"); }
const arg = getNumber(hexlify(bytes.slice(4)));
revert = {
signature: "Panic(uint256)",
name: "Panic",
args: [ arg ]
};
reason = `Panic due to ${ PanicReasons.get(Number(arg)) || "UNKNOWN" }(${ arg })`;
message += `: ${ reason }`;
} catch (error) {
console.log(error);
message += " (could not parse panic reason)";
}
}
}
return makeError(message, "CALL_EXCEPTION", {
action, data, reason, transaction, invocation, revert,
info: { payload, error }
});
*/
}
// Only estimateGas and call can return arbitrary contract-defined text, so now we
@@ -904,7 +840,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
if (message.match(/insufficient funds|base fee exceeds gas limit/i)) {
return makeError("insufficient funds for intrinsic transaction cost", "INSUFFICIENT_FUNDS", {
transaction
transaction, info: { error }
});
}
@@ -926,7 +862,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvider {
if (message.match(/the method .* does not exist/i)) {
return makeError("unsupported operation", "UNSUPPORTED_OPERATION", {
operation: payload.method
operation: payload.method, info: { error }
});
}

View File

@@ -1,3 +1,5 @@
import { isError } from "../utils/index.js";
import { PollingEventSubscriber } from "./subscriber-polling.js";
import type { AbstractProvider, Subscriber } from "./abstract-provider.js";
@@ -5,7 +7,6 @@ import type { Network } from "./network.js";
import type { EventFilter } from "./provider.js";
import type { JsonRpcApiProvider } from "./provider-jsonrpc.js";
function copy(obj: any): any {
return JSON.parse(JSON.stringify(obj));
}
@@ -59,12 +60,25 @@ export class FilterIdSubscriber implements Subscriber {
async #poll(blockNumber: number): Promise<void> {
try {
// Subscribe if necessary
if (this.#filterIdPromise == null) {
this.#filterIdPromise = this._subscribe(this.#provider);
}
const filterId = await this.#filterIdPromise;
// Get the Filter ID
let filterId: null | string = null;
try {
filterId = await this.#filterIdPromise;
} catch (error) {
if (!isError(error, "UNSUPPORTED_OPERATION") || error.operation !== "eth_newFilter") {
throw error;
}
}
// The backend does not support Filter ID; downgrade to
// polling
if (filterId == null) {
this.#filterIdPromise = null;
this.#provider._recoverSubscriber(this, this._recover(this.#provider));
return;
}

View File

@@ -1,7 +1,7 @@
/**
* Transactions..
*
* @_section api/transaction:Transactions [transactions]
* @_section api/transaction:Transactions [about-transactions]
*/
null;

View File

@@ -13,6 +13,19 @@ import type { BytesLike } from "./data.js";
/**
* Decodes the base-64 encoded %%value%%.
*
* @example:
* // The decoded value is always binary data...
* result = decodeBase64("SGVsbG8gV29ybGQhIQ==")
* //_result:
*
* // ...use toUtf8String to convert it to a string.
* toUtf8String(result)
* //_result:
*
* // Decoding binary data
* decodeBase64("EjQ=")
* //_result:
*/
export function decodeBase64(value: string): Uint8Array {
return getBytesCopy(Buffer.from(value, "base64"));
@@ -20,6 +33,23 @@ export function decodeBase64(value: string): Uint8Array {
/**
* Encodes %%data%% as a base-64 encoded string.
*
* @example:
* // Encoding binary data as a hexstring
* encodeBase64("0x1234")
* //_result:
*
* // Encoding binary data as a Uint8Array
* encodeBase64(new Uint8Array([ 0x12, 0x34 ]))
* //_result:
*
* // The input MUST be data...
* encodeBase64("Hello World!!")
* //_error:
*
* // ...use toUtf8Bytes for this.
* encodeBase64(toUtf8Bytes("Hello World!!"))
* //_result:
*/
export function encodeBase64(data: BytesLike): string {
return Buffer.from(getBytes(data)).toString("base64");

View File

@@ -174,7 +174,7 @@ function zeroPad(data: BytesLike, length: number, left: boolean): string {
* Return the [[DataHexString]] of %%data%% padded on the **left**
* to %%length%% bytes.
*
* If %%data%% already exceeds %%length%%, a [[BufferOverrun]] is
* If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is
* thrown.
*
* This pads data the same as **values** are in Solidity
@@ -188,7 +188,7 @@ export function zeroPadValue(data: BytesLike, length: number): string {
* Return the [[DataHexString]] of %%data%% padded on the **right**
* to %%length%% bytes.
*
* If %%data%% already exceeds %%length%%, a [[BufferOverrun]] is
* If %%data%% already exceeds %%length%%, a [[BufferOverrunError]] is
* thrown.
*
* This pads data the same as **bytes** are in Solidity

View File

@@ -3,7 +3,7 @@
* Ethereum and to simplify the library, without increasing
* the library dependencies for simple functions.
*
* @_section api/utils:Utilities [utils]
* @_section api/utils:Utilities [about-utils]
*/
export { decodeBase58, encodeBase58 } from "./base58.js";

View File

@@ -89,7 +89,7 @@ export function mask(_value: BigNumberish, _bits: Numeric): bigint {
}
/**
* Gets a [[BigInt]] from %%value%%. If it is an invalid value for
* Gets a BigInt from %%value%%. If it is an invalid value for
* a BigInt, then an ArgumentError will be thrown for %%name%%.
*/
export function getBigInt(value: BigNumberish, name?: string): bigint {

View File

@@ -56,7 +56,7 @@ export function formatUnits(value: BigNumberish, unit?: string | Numeric): strin
}
/**
* Converts the //decimal string// %%value%% to a [[BigInt]], assuming
* Converts the //decimal string// %%value%% to a BigInt, assuming
* %%unit%% decimal places. The %%unit%% may the number of decimal places
* or the name of a unit (e.g. ``"gwei"`` for 9 decimal places).
*/
@@ -83,7 +83,7 @@ export function formatEther(wei: BigNumberish): string {
}
/**
* Converts the //decimal string// %%ether%% to a [[BigInt]], using 18
* Converts the //decimal string// %%ether%% to a BigInt, using 18
* decimal places.
*/
export function parseEther(ether: string): bigint {

View File

@@ -120,7 +120,21 @@ function replaceFunc(reason: Utf8ErrorReason, offset: number, bytes: Uint8Array,
return ignoreFunc(reason, offset, bytes, output, badCodepoint);
}
// Common error handing strategies
/**
* A handful of popular, built-in UTF-8 error handling strategies.
*
* **``"error"``** - throws on ANY illegal UTF-8 sequence or
* non-canonical (overlong) codepoints (this is the default)
*
* **``"ignore"``** - silently drops any illegal UTF-8 sequence
* and accepts non-canonical (overlong) codepoints
*
* **``"replace"``** - replace any illegal UTF-8 sequence with the
* UTF-8 replacement character (i.e. `\ufffd`) and accepts
* non-canonical (overlong) codepoints
*
* @returns: Record<"error" | "ignore" | "replace", Utf8ErrorFunc>
*/
export const Utf8ErrorFuncs: Readonly<Record<"error" | "ignore" | "replace", Utf8ErrorFunc>> = Object.freeze({
error: errorFunc,
ignore: ignoreFunc,
@@ -293,7 +307,7 @@ function _toUtf8String(codePoints: Array<number>): string {
*
* When %%onError%% function is specified, it is called on UTF-8
* errors allowing recovery using the [[Utf8ErrorFunc]] API.
* (default: [error](Utf8ErrorFuncs-error))
* (default: [error](Utf8ErrorFuncs))
*/
export function toUtf8String(bytes: BytesLike, onError?: Utf8ErrorFunc): string {
return _toUtf8String(getUtf8CodePoints(bytes, onError));

View File

@@ -14,7 +14,7 @@
* low-level details of how an HD wallets are derived, exported
* or imported.
*
* @_section: api/wallet:Wallets [wallets]
* @_section: api/wallet:Wallets [about-wallets]
*/
export { BaseWallet } from "./base-wallet.js";

View File

@@ -102,7 +102,7 @@ function entropyToMnemonic(entropy: Uint8Array, wordlist?: null | Wordlist): str
const _guard = { };
/**
* A **Mnemonic** wraps all properties required to compute [[link-bip39]]
* A **Mnemonic** wraps all properties required to compute [[link-bip-39]]
* seeds and convert between phrases and entropy.
*/
export class Mnemonic {
@@ -188,7 +188,7 @@ export class Mnemonic {
}
/**
* Returns true if %%phrase%% is a valid [[link-bip39]] phrase.
* Returns true if %%phrase%% is a valid [[link-bip-39]] phrase.
*
* This checks all the provided words belong to the %%wordlist%%,
* that the length is valid and the checksum is correct.

View File

@@ -15,7 +15,7 @@
* languages, but for maximal compatibility, the
* [English Wordlist](LangEn) is recommended.
*
* @_section: api/wordlists:Wordlists [wordlists]
* @_section: api/wordlists:Wordlists [about-wordlists]
*/
export { Wordlist } from "./wordlist.js";
export { LangEn } from "./lang-en.js";

View File

@@ -2,7 +2,7 @@ import { defineProperties } from "../utils/index.js";
/**
* A Wordlist represents a collection of language-specific
* words used to encode and devoce [[BIP-39]] encoded data
* words used to encode and devoce [[link-bip-39]] encoded data
* by mapping words to 11-bit values and vice versa.
*/
export abstract class Wordlist {

16
types/README.md Normal file
View File

@@ -0,0 +1,16 @@
TypeScript Type Definitions
===========================
The contents of this folder are the TypeScript definirtions for
TypeScript projects.
Notes
-----
The contents are generated via the `npm run build-types` target
using `tsc` and the `/tsconfig.types.json` configuration.
Do not modify the files in this folder. They are deleted on `build-clean`.
To modify this `README.md`, see the `/output/post-build/types`.

View File

@@ -1 +1 @@
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src.ts/utils/fetch.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,cAAc,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,IAAI,GAAG,UAAU,CAAA;CAC1B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AACF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY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