Activate flow

This commit is contained in:
Michael Vines 2018-08-23 10:07:30 -07:00
parent bbb8055243
commit 96f8a8620d
8 changed files with 59 additions and 23 deletions

View File

@ -8,7 +8,9 @@
"env": {
"test": {
"presets": [
"env"
"env",
"stage-0",
"flow"
]
}
},

View File

@ -2,15 +2,19 @@
<PROJECT_ROOT>/node_modules/*
<PROJECT_ROOT>/lib/.*
<PROJECT_ROOT>/internals/.*
<PROJECT_ROOT>/test/.*
[include]
[options]
module.system.node.resolve_dirname=./src
esproposal.class_static_fields=enable
emoji=true
esproposal.class_instance_fields=enable
esproposal.export_star_as=enable
esproposal.class_static_fields=enable
esproposal.decorators=ignore
esproposal.export_star_as=enable
module.system.node.resolve_dirname=./src
module.use_strict=true
experimental.const_params=true
include_warnings=true
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

5
web3.js/flow-typed/bs58.js vendored Normal file
View File

@ -0,0 +1,5 @@
declare module "bs58" {
declare module.exports: {
encode(input: Buffer): string;
};
}

13
web3.js/flow-typed/tweetnacl.js vendored Normal file
View File

@ -0,0 +1,13 @@
declare module "tweetnacl" {
declare type KeyPair = {
publicKey: Buffer;
secretKey: Buffer;
};
declare module.exports: {
sign: {
keyPair(): KeyPair;
};
};
}

View File

@ -1802,9 +1802,9 @@
}
},
"big-integer": {
"version": "1.6.28",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.28.tgz",
"integrity": "sha512-OJT3rzgtsYca/5WmmEuFJDPMwROVh5SSjoEX9wIrpfbbWJ4KqRzShs8Cj6jWHaatBYAeWngBA+kmmrcHSklT1g==",
"version": "1.6.34",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.34.tgz",
"integrity": "sha512-+w6B0Uo0ZvTSzDkXjoBCTNK0oe+aVL+yPi7kwGZm8hd8+Nj1AFPoxoq1Bl/mEu/G/ivOkUc1LRqVR0XeWFUzuA==",
"dev": true
},
"binary": {
@ -2739,7 +2739,7 @@
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
"dev": true,
"requires": {
"mimic-response": "1.0.0"
"mimic-response": "1.0.1"
}
},
"deep-is": {
@ -4011,7 +4011,7 @@
"dev": true,
"requires": {
"babel-polyfill": "6.26.0",
"colors": "1.2.1",
"colors": "1.3.2",
"fs-extra": "5.0.0",
"github": "0.2.4",
"glob": "7.1.2",
@ -4022,7 +4022,7 @@
"semver": "5.5.0",
"table": "4.0.2",
"through": "2.3.8",
"unzipper": "0.8.13",
"unzipper": "0.8.14",
"which": "1.3.0",
"yargs": "4.8.1"
},
@ -4045,9 +4045,9 @@
}
},
"colors": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.1.tgz",
"integrity": "sha512-s8+wktIuDSLffCywiwSxQOMqtPxML11a/dtHE17tMn4B1MSWw/C22EKf7M2KGUBcDaVFEGT+S8N02geDXeuNKg==",
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz",
"integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==",
"dev": true
},
"find-up": {
@ -7507,9 +7507,9 @@
"dev": true
},
"mimic-response": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz",
"integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=",
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
"integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==",
"dev": true
},
"minimalistic-assert": {
@ -7645,6 +7645,12 @@
"semver": "5.5.0"
}
},
"node-fetch": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz",
"integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==",
"dev": true
},
"node-int64": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
@ -10508,12 +10514,12 @@
}
},
"unzipper": {
"version": "0.8.13",
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.8.13.tgz",
"integrity": "sha512-mG0xHx7PjIQs4+JXBV2dWO205E8RiJ9fNjbYdEPvZhehAOiW9uNK432X+rWL7iNLVDg1Dl9nJY/d6zVh8/9MgA==",
"version": "0.8.14",
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.8.14.tgz",
"integrity": "sha512-8rFtE7EP5ssOwGpN2dt1Q4njl0N1hUXJ7sSPz0leU2hRdq6+pra57z4YPBlVqm40vcgv6ooKZEAx48fMTv9x4w==",
"dev": true,
"requires": {
"big-integer": "1.6.28",
"big-integer": "1.6.34",
"binary": "0.3.0",
"bluebird": "3.4.7",
"buffer-indexof-polyfill": "1.0.1",

View File

@ -24,6 +24,7 @@
"browser": "lib/index.iife.js",
"scripts": {
"clean": "rimraf ./coverage ./lib",
"postinstall": "flow-typed install jest@22",
"dev": "cross-env NODE_ENV=development rollup -c",
"build": "cross-env NODE_ENV=production rollup -c",
"doc": "esdoc",

View File

@ -1,7 +1,11 @@
// @flow
import nacl from 'tweetnacl';
import bs58 from 'bs58';
import type {KeyPair} from 'tweetnacl';
export class Account {
_keypair: KeyPair;
constructor(secretKey: ?Buffer = null) {
if (secretKey) {
this._keypair = nacl.sign.keyPair.fromSecretKey(secretKey);
@ -14,7 +18,7 @@ export class Account {
return bs58.encode(this._keypair.publicKey);
}
get secretKey(): string {
get secretKey(): Buffer {
return this._keypair.secretKey;
}
}

View File

@ -1,3 +1,4 @@
// @flow
import {Account} from '../src/account';
test('generate new account', () => {