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

Commit 45512f8

Browse files
committed
Moved TransformableToArray, TransformableToBuffer interfaces to types
1 parent e280340 commit 45512f8

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ For more info see the documentation or examples of usage in `test/account.spec.t
3838
A new file with helpful TypeScript types has been added to the exports of this project.
3939

4040
In this release it contains `BNLike`, `BufferLike`, and `TransformableToBuffer`.
41+
4142
### Address.toBuffer()
4243

4344
The Address class has as a new method `address.toBuffer()` that will give you a copy of the underlying `address.buf`.

src/bytes.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
import * as BN from 'bn.js'
22
import { intToBuffer, stripHexPrefix, padToEven, isHexString, isHexPrefixed } from 'ethjs-util'
3+
import { TransformableToArray, TransformableToBuffer } from './types'
34
import { assertIsBuffer, assertIsArray, assertIsHexString } from './helpers'
45

5-
// These can be moved to './types' when PR#275 is merged.
6-
export interface TransformableToArray {
7-
toArray(): Uint8Array
8-
toBuffer?(): Buffer
9-
}
10-
export interface TransformableToBuffer {
11-
toBuffer(): Buffer
12-
toArray?(): Uint8Array
13-
}
14-
156
/**
167
* Returns a buffer filled with 0s.
178
* @param bytes the number of bytes the buffer should be

src/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,20 @@ export type BufferLike =
2323
*/
2424
export type PrefixedHexString = string
2525

26+
/*
27+
* A type that represents an object that has a `toArray()` method.
28+
*/
29+
export interface TransformableToArray {
30+
toArray(): Uint8Array
31+
toBuffer?(): Buffer
32+
}
33+
2634
/*
2735
* A type that represents an object that has a `toBuffer()` method.
2836
*/
2937
export interface TransformableToBuffer {
3038
toBuffer(): Buffer
39+
toArray?(): Uint8Array
3140
}
3241

3342
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy