From e48478d3449fed6142cd6f611dffab5d4ed46ee3 Mon Sep 17 00:00:00 2001 From: Ryan Ghods Date: Wed, 30 Sep 2020 10:22:44 -0700 Subject: [PATCH] more docs, fixups --- src/account.ts | 8 +++++--- src/types.ts | 21 ++++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/account.ts b/src/account.ts index e7cbb349..e3d2c6df 100644 --- a/src/account.ts +++ b/src/account.ts @@ -109,6 +109,8 @@ export class Account { /** * Returns a `Boolean` determining if the account is empty. + * For more details about account emptiness see [EIP-161](https://eips.ethereum.org/EIPS/eip-161). + * Note: The stateRoot is also checked to be empty since in Frontier it was possible to create a contract with no code where nonce remained 0 but some values were written to storage in the constructor (thus stateRoot is not KECCAK256_RLP). */ isEmpty(): boolean { return ( @@ -133,7 +135,7 @@ export const isValidAddress = function(hexAddress: string): boolean { * * If a eip1191ChainId is provided, the chainId will be included in the checksum calculation. This * has the effect of checksummed addresses for one chain having invalid checksums for others. - * For more details, consult EIP-1191. + * For more details see [EIP-1191](https://eips.ethereum.org/EIPS/eip-1191). * * WARNING: Checksums with and without the chainId will differ. As of 2019-06-26, the most commonly * used variation in Ethereum was without the chainId. This may change in the future. @@ -285,7 +287,7 @@ export const importPublic = function(publicKey: Buffer): Buffer { } /** - * Returns a zero address. + * Returns the zero address. */ export const zeroAddress = function(): string { const addressLength = 20 @@ -294,7 +296,7 @@ export const zeroAddress = function(): string { } /** - * Checks if a given address is a zero address. + * Checks if a given address is the zero address. */ export const isZeroAddress = function(hexAddress: string): boolean { assertIsHexString(hexAddress) diff --git a/src/types.ts b/src/types.ts index 6cb819b4..64ec1a35 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,12 +1,31 @@ import * as BN from 'bn.js' import { unpadBuffer } from './bytes' +/* + * A type that represents a BNLike input that can be converted to a BN. + */ export type BNLike = BN | string | number -export type BufferLike = Buffer | TransformableToBuffer | PrefixedHexString | number +/* + * A type that represents a BufferLike input that can be converted to a Buffer. + */ +export type BufferLike = + | Buffer + | Uint8Array + | number[] + | number + | BN + | TransformableToBuffer + | PrefixedHexString +/* + * A type that represents a `0x`-prefixed hex string. + */ export type PrefixedHexString = string +/* + * A type that represents an object that has a `toBuffer()` method. + */ export interface TransformableToBuffer { toBuffer(): Buffer }