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

Added sample Flow setup - Discussion for #417 #556

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .babelrc
@@ -1,5 +1,5 @@
{
"presets": ["env"],
"presets": ["env", "flow"],
"plugins": [
"transform-runtime",
["module-resolver", {
Expand Down
2 changes: 2 additions & 0 deletions .eslintignore
Expand Up @@ -3,3 +3,5 @@ dist-*/
docs/
browsertest/browsertest.js
browsertest/browsertest.min.js
flow-typed/
flow/
5 changes: 5 additions & 0 deletions .eslintrc.json
Expand Up @@ -3,12 +3,17 @@
"globals": {
"naclInstance": true
},
"parser": "babel-eslint",
"plugins": [
"flowtype"
],
"rules": {
"arrow-parens": ["error", "as-needed"],
"curly": "off",
"indent": "off",
"no-confusing-arrow": "off",
"no-mixed-operators": "off",
"flowtype/define-flow-type": 2,
"import/no-extraneous-dependencies": [
"error", {
"devDependencies": [
Expand Down
14 changes: 14 additions & 0 deletions .flowconfig
@@ -0,0 +1,14 @@
[include]

[ignore]
.*/node_modules/cypress/dist/*

[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=./src

[libs]
flow/

[version]
^0.65.0
32 changes: 32 additions & 0 deletions flow-typed/npm/browserify-bignum_vx.x.x.js
@@ -0,0 +1,32 @@
// flow-typed signature: 17becd1d346f1153761ee64bc67040bf
// flow-typed version: <<STUB>>/browserify-bignum_v1.2.0-2/flow_v0.65.0

/**
* This is an autogenerated libdef stub for:
*
* 'browserify-bignum'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'browserify-bignum' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'browserify-bignum/bignumber' {
declare module.exports: any;
}

// Filename aliases
declare module 'browserify-bignum/bignumber.js' {
declare module.exports: $Exports<'browserify-bignum/bignumber'>;
}
39 changes: 39 additions & 0 deletions flow-typed/npm/ed2curve_vx.x.x.js
@@ -0,0 +1,39 @@
// flow-typed signature: 1feaec8cb9a0c548abb19b409471318d
// flow-typed version: <<STUB>>/ed2curve_v0.2.1/flow_v0.65.0

/**
* This is an autogenerated libdef stub for:
*
* 'ed2curve'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare module 'ed2curve' {
declare module.exports: any;
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'ed2curve/ed2curve' {
declare module.exports: any;
}

declare module 'ed2curve/ed2curve.min' {
declare module.exports: any;
}

// Filename aliases
declare module 'ed2curve/ed2curve.js' {
declare module.exports: $Exports<'ed2curve/ed2curve'>;
}
declare module 'ed2curve/ed2curve.min.js' {
declare module.exports: $Exports<'ed2curve/ed2curve.min'>;
}
101 changes: 101 additions & 0 deletions flow-typed/npm/js-nacl_vx.x.x.js
@@ -0,0 +1,101 @@
// flow-typed signature: a76fc4797b92c528b2d521ba3753bd43
// flow-typed version: <<STUB>>/js-nacl_vjs-nacl#6dc1417/flow_v0.65.0

/**
* This is an autogenerated libdef stub for:
*
* 'js-nacl'
*
* Fill this stub out by replacing all the `any` types.
*
* Once filled out, we encourage you to share your work with the
* community by sending a pull request to:
* https://github.com/flowtype/flow-typed
*/

declare type NaclKeyPair = {
signPk: Uint8Array,
signSk: Uint8Array,
};

declare export class NaclInstance {
to_hex: (Uint8Array) => string,
from_hex: (string) => Uint8Array,
encode_utf8: (string) => Uint8Array,
encode_latin1: (string) => Uint8Array,
decode_utf8: (Uint8Array) => string,
crypto_box: (
ciphertextBin: Uint8Array,
nonceBin: Uint8Array,
senderPublicKeyBin: Uint8Array,
recipientSecretKeyBin: Uint8Array,
) => Uint8Array,
crypto_box_open: (ciphertextBin: Uint8Array,
nonceBin: Uint8Array,
senderPublicKeyBin: Uint8Array,
recipientSecretKeyBin: Uint8Array,
) => Uint8Array,
crypto_box_random_nonce: () => Uint8Array,
crypto_hash_sha256: (Uint8Array) => Uint8Array,
crypto_sign_seed_keypair: (Uint8Array) => NaclKeyPair,
crypto_sign_detached: (msgBin: Uint8Array, signerSecretKey: Uint8Array) => Uint8Array,
crypto_sign_BYTES: number,
crypto_sign_verify_detached:
(detachedSignatureBin: Uint8Array, msgBin: Uint8Array, signerPublicKey: Uint8Array)
=> boolean,
}

declare module 'js-nacl' {
declare module.exports: {
instantiate((nacl: NaclInstance) => void): void,
};
}

/**
* We include stubs for each file inside this npm package in case you need to
* require those files directly. Feel free to delete any files that aren't
* needed.
*/
declare module 'js-nacl/benchmark' {
declare module.exports: any;
}

declare module 'js-nacl/lib/nacl_factory' {
declare module.exports: any;
}

declare module 'js-nacl/nacl_cooked_prefix' {
declare module.exports: any;
}

declare module 'js-nacl/nacl_cooked_suffix' {
declare module.exports: any;
}

declare module 'js-nacl/nacl_cooked' {
declare module.exports: any;
}

declare module 'js-nacl/test/tests' {
declare module.exports: any;
}

// Filename aliases
declare module 'js-nacl/benchmark.js' {
declare module.exports: $Exports<'js-nacl/benchmark'>;
}
declare module 'js-nacl/lib/nacl_factory.js' {
declare module.exports: $Exports<'js-nacl/lib/nacl_factory'>;
}
declare module 'js-nacl/nacl_cooked_prefix.js' {
declare module.exports: $Exports<'js-nacl/nacl_cooked_prefix'>;
}
declare module 'js-nacl/nacl_cooked_suffix.js' {
declare module.exports: $Exports<'js-nacl/nacl_cooked_suffix'>;
}
declare module 'js-nacl/nacl_cooked.js' {
declare module.exports: $Exports<'js-nacl/nacl_cooked'>;
}
declare module 'js-nacl/test/tests.js' {
declare module.exports: $Exports<'js-nacl/test/tests'>;
}
43 changes: 43 additions & 0 deletions flow/types.js
@@ -0,0 +1,43 @@
/*
* Copyright © 2017 Lisk Foundation
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation,
* no part of this software, including this file, may be copied, modified,
* propagated, or distributed except according to the terms contained in the
* LICENSE file.
*
* Removal or modification of this copyright notice is prohibited.
*
* @flow
*/

declare type Options = {
ssl: boolean,
node: string,
randomPeer: boolean,
testnet: boolean,
port: string,
bannedPeers: Array<string>,
nethash: NethashOption,
};

declare type NethashOption = {
'Content-Type': string,
nethash: string,
broadhash: string,
os: string,
version: string,
minVersion: string,
port: string,
Accept: string,
};

declare type NethashOptions = {
mainnet: NethashOption,
testnet: NethashOption,
};

declare var naclInstance: NaclInstance;