refactor: use buffer-layout to clean up buffer encoding

This commit is contained in:
Michael Vines
2018-10-06 11:13:58 -07:00
parent a596e99b4a
commit 17b73306fe
7 changed files with 137 additions and 85 deletions

18
web3.js/src/layout.js Normal file
View File

@ -0,0 +1,18 @@
// @flow
import * as BufferLayout from 'buffer-layout';
/**
* Layout for a public key
*/
export const publicKey = (property: string = 'publicKey'): Object => {
return BufferLayout.blob(32, property);
};
/**
* Layout for a 256bit unsigned value
*/
export const uint256 = (property: string = 'uint256'): Object => {
return BufferLayout.blob(32, property);
};