Activate flow
This commit is contained in:
@ -8,7 +8,9 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"test": {
|
"test": {
|
||||||
"presets": [
|
"presets": [
|
||||||
"env"
|
"env",
|
||||||
|
"stage-0",
|
||||||
|
"flow"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2,15 +2,19 @@
|
|||||||
<PROJECT_ROOT>/node_modules/*
|
<PROJECT_ROOT>/node_modules/*
|
||||||
<PROJECT_ROOT>/lib/.*
|
<PROJECT_ROOT>/lib/.*
|
||||||
<PROJECT_ROOT>/internals/.*
|
<PROJECT_ROOT>/internals/.*
|
||||||
<PROJECT_ROOT>/test/.*
|
|
||||||
|
|
||||||
[include]
|
[include]
|
||||||
|
|
||||||
[options]
|
[options]
|
||||||
module.system.node.resolve_dirname=./src
|
|
||||||
esproposal.class_static_fields=enable
|
emoji=true
|
||||||
esproposal.class_instance_fields=enable
|
esproposal.class_instance_fields=enable
|
||||||
esproposal.export_star_as=enable
|
esproposal.class_static_fields=enable
|
||||||
esproposal.decorators=ignore
|
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\\)*\\$FlowFixMe
|
||||||
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue
|
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue
|
5
web3.js/flow-typed/bs58.js
vendored
Normal file
5
web3.js/flow-typed/bs58.js
vendored
Normal 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
13
web3.js/flow-typed/tweetnacl.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
declare module "tweetnacl" {
|
||||||
|
declare type KeyPair = {
|
||||||
|
publicKey: Buffer;
|
||||||
|
secretKey: Buffer;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare module.exports: {
|
||||||
|
sign: {
|
||||||
|
keyPair(): KeyPair;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
38
web3.js/package-lock.json
generated
38
web3.js/package-lock.json
generated
@ -1802,9 +1802,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"big-integer": {
|
"big-integer": {
|
||||||
"version": "1.6.28",
|
"version": "1.6.34",
|
||||||
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.28.tgz",
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.34.tgz",
|
||||||
"integrity": "sha512-OJT3rzgtsYca/5WmmEuFJDPMwROVh5SSjoEX9wIrpfbbWJ4KqRzShs8Cj6jWHaatBYAeWngBA+kmmrcHSklT1g==",
|
"integrity": "sha512-+w6B0Uo0ZvTSzDkXjoBCTNK0oe+aVL+yPi7kwGZm8hd8+Nj1AFPoxoq1Bl/mEu/G/ivOkUc1LRqVR0XeWFUzuA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"binary": {
|
"binary": {
|
||||||
@ -2739,7 +2739,7 @@
|
|||||||
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
|
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"mimic-response": "1.0.0"
|
"mimic-response": "1.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"deep-is": {
|
"deep-is": {
|
||||||
@ -4011,7 +4011,7 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"babel-polyfill": "6.26.0",
|
"babel-polyfill": "6.26.0",
|
||||||
"colors": "1.2.1",
|
"colors": "1.3.2",
|
||||||
"fs-extra": "5.0.0",
|
"fs-extra": "5.0.0",
|
||||||
"github": "0.2.4",
|
"github": "0.2.4",
|
||||||
"glob": "7.1.2",
|
"glob": "7.1.2",
|
||||||
@ -4022,7 +4022,7 @@
|
|||||||
"semver": "5.5.0",
|
"semver": "5.5.0",
|
||||||
"table": "4.0.2",
|
"table": "4.0.2",
|
||||||
"through": "2.3.8",
|
"through": "2.3.8",
|
||||||
"unzipper": "0.8.13",
|
"unzipper": "0.8.14",
|
||||||
"which": "1.3.0",
|
"which": "1.3.0",
|
||||||
"yargs": "4.8.1"
|
"yargs": "4.8.1"
|
||||||
},
|
},
|
||||||
@ -4045,9 +4045,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"colors": {
|
"colors": {
|
||||||
"version": "1.2.1",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.2.tgz",
|
||||||
"integrity": "sha512-s8+wktIuDSLffCywiwSxQOMqtPxML11a/dtHE17tMn4B1MSWw/C22EKf7M2KGUBcDaVFEGT+S8N02geDXeuNKg==",
|
"integrity": "sha512-rhP0JSBGYvpcNQj4s5AdShMeE5ahMop96cTeDl/v9qQQm2fYClE2QXZRi8wLzc+GmXSxdIqqbOIAhyObEXDbfQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"find-up": {
|
"find-up": {
|
||||||
@ -7507,9 +7507,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"mimic-response": {
|
"mimic-response": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
|
||||||
"integrity": "sha1-3z02Uqc/3ta5sLJBRub9BSNTRY4=",
|
"integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"minimalistic-assert": {
|
"minimalistic-assert": {
|
||||||
@ -7645,6 +7645,12 @@
|
|||||||
"semver": "5.5.0"
|
"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": {
|
"node-int64": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||||
@ -10508,12 +10514,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"unzipper": {
|
"unzipper": {
|
||||||
"version": "0.8.13",
|
"version": "0.8.14",
|
||||||
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.8.13.tgz",
|
"resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.8.14.tgz",
|
||||||
"integrity": "sha512-mG0xHx7PjIQs4+JXBV2dWO205E8RiJ9fNjbYdEPvZhehAOiW9uNK432X+rWL7iNLVDg1Dl9nJY/d6zVh8/9MgA==",
|
"integrity": "sha512-8rFtE7EP5ssOwGpN2dt1Q4njl0N1hUXJ7sSPz0leU2hRdq6+pra57z4YPBlVqm40vcgv6ooKZEAx48fMTv9x4w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"big-integer": "1.6.28",
|
"big-integer": "1.6.34",
|
||||||
"binary": "0.3.0",
|
"binary": "0.3.0",
|
||||||
"bluebird": "3.4.7",
|
"bluebird": "3.4.7",
|
||||||
"buffer-indexof-polyfill": "1.0.1",
|
"buffer-indexof-polyfill": "1.0.1",
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
"browser": "lib/index.iife.js",
|
"browser": "lib/index.iife.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"clean": "rimraf ./coverage ./lib",
|
"clean": "rimraf ./coverage ./lib",
|
||||||
|
"postinstall": "flow-typed install jest@22",
|
||||||
"dev": "cross-env NODE_ENV=development rollup -c",
|
"dev": "cross-env NODE_ENV=development rollup -c",
|
||||||
"build": "cross-env NODE_ENV=production rollup -c",
|
"build": "cross-env NODE_ENV=production rollup -c",
|
||||||
"doc": "esdoc",
|
"doc": "esdoc",
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
// @flow
|
||||||
import nacl from 'tweetnacl';
|
import nacl from 'tweetnacl';
|
||||||
import bs58 from 'bs58';
|
import bs58 from 'bs58';
|
||||||
|
import type {KeyPair} from 'tweetnacl';
|
||||||
|
|
||||||
export class Account {
|
export class Account {
|
||||||
|
_keypair: KeyPair;
|
||||||
|
|
||||||
constructor(secretKey: ?Buffer = null) {
|
constructor(secretKey: ?Buffer = null) {
|
||||||
if (secretKey) {
|
if (secretKey) {
|
||||||
this._keypair = nacl.sign.keyPair.fromSecretKey(secretKey);
|
this._keypair = nacl.sign.keyPair.fromSecretKey(secretKey);
|
||||||
@ -14,7 +18,7 @@ export class Account {
|
|||||||
return bs58.encode(this._keypair.publicKey);
|
return bs58.encode(this._keypair.publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
get secretKey(): string {
|
get secretKey(): Buffer {
|
||||||
return this._keypair.secretKey;
|
return this._keypair.secretKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @flow
|
||||||
import {Account} from '../src/account';
|
import {Account} from '../src/account';
|
||||||
|
|
||||||
test('generate new account', () => {
|
test('generate new account', () => {
|
||||||
|
Reference in New Issue
Block a user