Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
more docs, fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanio committed Sep 30, 2020
1 parent b0aacc0 commit e48478d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
21 changes: 20 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down

0 comments on commit e48478d

Please sign in to comment.