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

Commit

Permalink
♻️ Update constants to lisk-constants and move package specific const…
Browse files Browse the repository at this point in the history
…ants to each packages
  • Loading branch information
shuse2 committed Mar 9, 2018
1 parent f9034ba commit 764fe52
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/api/apiMethod.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from './constants';
import { solveURLParams, toQueryString } from './utils';

// Bind to resource class
Expand Down
26 changes: 26 additions & 0 deletions src/api/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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.
*
*/

export const LIVE_PORT = '8000';
export const TEST_PORT = '7000';
export const SSL_PORT = '443';

export const GET = 'GET';
export const POST = 'POST';

export const TESTNET_NETHASH =
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba';
export const MAINNET_NETHASH =
'ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511';
2 changes: 1 addition & 1 deletion src/api/liskApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
TEST_PORT,
TESTNET_NETHASH,
MAINNET_NETHASH,
} from 'constants';
} from './constants';
import config from '../../config.json';
import * as resources from './resources';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import APIResource from '../apiResource';
import apiMethod from '../apiMethod';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/dapps.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/signatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { POST } from 'constants';
import { POST } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET, POST } from 'constants';
import { GET, POST } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/voters.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
2 changes: 1 addition & 1 deletion src/api/resources/votes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { GET } from 'constants';
import { GET } from '../constants';
import apiMethod from '../apiMethod';
import APIResource from '../apiResource';

Expand Down
3 changes: 0 additions & 3 deletions src/constants/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions src/constants/index.js → src/lisk-constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,7 @@ export const EPOCH_TIME = new Date(Date.UTC(2016, 4, 24, 17, 0, 0, 0));
export const EPOCH_TIME_MILLISECONDS = EPOCH_TIME.getTime();
export const EPOCH_TIME_SECONDS = Math.floor(EPOCH_TIME.getTime() / 1000);

export const LIVE_PORT = '8000';
export const TEST_PORT = '7000';
export const SSL_PORT = '443';

export const GET = 'GET';
export const POST = 'POST';

// Largest possible address. Derived from bignum.fromBuffer(Buffer.from(new Array(8).fill(255))).
export const MAX_ADDRESS_NUMBER = '18446744073709551615';
// Largest possible amount. Derived from bignum.fromBuffer(Buffer.from(new Array(8).fill(255))).
export const MAX_TRANSACTION_AMOUNT = '18446744073709551615';

export const TESTNET_NETHASH =
'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba';
export const MAINNET_NETHASH =
'ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511';
3 changes: 3 additions & 0 deletions src/lisk-constants/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "lisk-constants"
}
2 changes: 1 addition & 1 deletion src/transactions/0_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { TRANSFER_FEE, DATA_FEE } from 'constants';
import { TRANSFER_FEE, DATA_FEE } from 'lisk-constants';
import {
getAddressAndPublicKeyFromRecipientData,
wrapTransactionCreator,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/1_registerSecondPassphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/
import cryptography from 'cryptography';
import { SIGNATURE_FEE } from 'constants';
import { SIGNATURE_FEE } from 'lisk-constants';
import { wrapTransactionCreator } from './utils';

const registerSecondPassphrase = ({ secondPassphrase }) => {
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/2_registerDelegate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { DELEGATE_FEE } from 'constants';
import { DELEGATE_FEE } from 'lisk-constants';
import { wrapTransactionCreator } from './utils';

const registerDelegate = ({ username }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/3_castVotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/
import cryptography from 'cryptography';
import { VOTE_FEE } from 'constants';
import { VOTE_FEE } from 'lisk-constants';
import {
prependMinusToPublicKeys,
prependPlusToPublicKeys,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/4_registerMultisignatureAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { MULTISIGNATURE_FEE } from 'constants';
import { MULTISIGNATURE_FEE } from 'lisk-constants';
import {
prependPlusToPublicKeys,
validateKeysgroup,
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/5_createDapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { DAPP_FEE } from 'constants';
import { DAPP_FEE } from 'lisk-constants';
import { wrapTransactionCreator } from './utils';

const isInt = n => parseInt(n, 10) === n;
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/6_transferIntoDapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { IN_TRANSFER_FEE } from 'constants';
import { IN_TRANSFER_FEE } from 'lisk-constants';
import { wrapTransactionCreator } from './utils';

const transferIntoDapp = ({ amount, dappId }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/7_transferOutOfDapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Removal or modification of this copyright notice is prohibited.
*
*/
import { OUT_TRANSFER_FEE } from 'constants';
import { OUT_TRANSFER_FEE } from 'lisk-constants';
import { wrapTransactionCreator } from './utils';

const transferOutOfDapp = ({ amount, dappId, transactionId, recipientId }) => ({
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/getTransactionBytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
import bignum from 'browserify-bignum';
import cryptography from 'cryptography';
import { MAX_TRANSACTION_AMOUNT } from 'constants';
import { MAX_TRANSACTION_AMOUNT } from 'lisk-constants';

export const isValidValue = value => ![undefined, false, NaN].includes(value);

Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/time.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

import { EPOCH_TIME_MILLISECONDS } from 'constants';
import { EPOCH_TIME_MILLISECONDS } from 'lisk-constants';

export const getTimeFromBlockchainEpoch = givenTimestamp => {
const startingPoint = givenTimestamp || new Date().getTime();
Expand Down
2 changes: 1 addition & 1 deletion src/transactions/utils/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
import bignum from 'browserify-bignum';
import { hexToBuffer } from 'cryptography/convert';
import { MAX_ADDRESS_NUMBER } from 'constants';
import { MAX_ADDRESS_NUMBER } from 'lisk-constants';

export const validatePublicKey = publicKey => {
const publicKeyBuffer = hexToBuffer(publicKey);
Expand Down
4 changes: 2 additions & 2 deletions test/constants/constants.js → test/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {
EPOCH_TIME_MILLISECONDS,
MAX_ADDRESS_NUMBER,
MAX_TRANSACTION_AMOUNT,
} from 'constants';
} from 'lisk-constants';

describe('constants', () => {
describe('lisk-constants', () => {
it('FIXED_POINT should be an integer', () => {
return FIXED_POINT.should.be.an.integer;
});
Expand Down

0 comments on commit 764fe52

Please sign in to comment.