Skip to content

Commit

Permalink
refactor: use @arkecosystem/utils through @arkecosystem/core-kernel
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Faust committed Sep 29, 2019
1 parent b37233e commit 6645c13
Show file tree
Hide file tree
Showing 15 changed files with 208 additions and 368 deletions.
8 changes: 0 additions & 8 deletions __tests__/unit/core/common/__fixtures__/latest-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,11 @@ export const versionLatest = {
"@types/bip39": "^2.4.2",
"@types/bytebuffer": "^5.0.40",
"@types/cli-progress": "^1.8.1",
"@types/execa": "^0.9.0",
"@types/fast-levenshtein": "^0.0.1",
"@types/fs-extra": "^8.0.0",
"@types/got": "^9.6.1",
"@types/latest-version": "^4.0.1",
"@types/listr": "^0.14.0",
"@types/lodash.minby": "^4.6.6",
"@types/log-symbols": "^3.0.0",
"@types/pretty-bytes": "^5.1.0",
"@types/pretty-ms": "^4.0.0",
"@types/prompts": "^2.4.0",
"@types/semver": "^6.0.1",
Expand Down Expand Up @@ -306,15 +302,11 @@ export const versionNext = {
"@types/bip39": "^2.4.2",
"@types/bytebuffer": "^5.0.40",
"@types/cli-progress": "^1.8.1",
"@types/execa": "^0.9.0",
"@types/fast-levenshtein": "^0.0.1",
"@types/fs-extra": "^8.0.0",
"@types/got": "^9.6.1",
"@types/latest-version": "^4.0.1",
"@types/listr": "^0.14.0",
"@types/lodash.minby": "^4.6.6",
"@types/log-symbols": "^3.0.0",
"@types/pretty-bytes": "^5.1.0",
"@types/pretty-ms": "^4.0.0",
"@types/prompts": "^2.4.0",
"@types/semver": "^6.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/core-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@arkecosystem/core-kernel": "^3.0.0-next.0",
"@arkecosystem/core-transaction-pool": "^3.0.0-next.0",
"@arkecosystem/crypto": "^3.0.0-next.0",
"@arkecosystem/utils": "^0.4.0",
"@hapi/boom": "^7.4.3",
"@hapi/hapi": "^18.3.2",
"@hapi/joi": "^15.1.1",
Expand Down
1 change: 0 additions & 1 deletion packages/core-database-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
"@arkecosystem/core-state": "^3.0.0-next.0",
"@arkecosystem/core-transactions": "^3.0.0-next.0",
"@arkecosystem/crypto": "^3.0.0-next.0",
"@arkecosystem/utils": "^0.4.0",
"bluebird": "^3.5.5",
"dayjs": "^1.8.15",
"pg-promise": "^8.7.4",
Expand Down
3 changes: 1 addition & 2 deletions packages/core-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"@arkecosystem/core-kernel": "^3.0.0-next.0",
"@arkecosystem/core-state": "^3.0.0-next.0",
"@arkecosystem/core-transactions": "^3.0.0-next.0",
"@arkecosystem/crypto": "^3.0.0-next.0",
"@arkecosystem/utils": "^0.4.0"
"@arkecosystem/crypto": "^3.0.0-next.0"
},
"engines": {
"node": ">=10.x"
Expand Down
5 changes: 2 additions & 3 deletions packages/core-database/src/repositories/utils/sort-entries.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Contracts } from "@arkecosystem/core-kernel";
import { Contracts, Utils as AppUtils } from "@arkecosystem/core-kernel";
import { Utils } from "@arkecosystem/crypto";
import { orderBy } from "@arkecosystem/utils";

import { getProperty } from "./get-property";

Expand All @@ -16,5 +15,5 @@ export const sortEntries = (params: Contracts.Database.Parameters, entries: Cont
});
}

return orderBy(entries, [iteratee], [order as "desc" | "asc"]);
return AppUtils.orderBy(entries, [iteratee], [order as "desc" | "asc"]);
};
1 change: 0 additions & 1 deletion packages/core-jest-matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"dependencies": {
"@arkecosystem/core-kernel": "^3.0.0-next.0",
"@arkecosystem/crypto": "^3.0.0-next.0",
"@arkecosystem/utils": "^0.4.0",
"bip39": "^3.0.2",
"got": "^9.6.0",
"jest-extended": "^0.11.2",
Expand Down
5 changes: 2 additions & 3 deletions packages/core-jest-matchers/src/api/block.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -13,7 +12,7 @@ declare global {
}

const isValidBlock = block => {
const allowedKeys = sortBy([
const allowedKeys = Utils.sortBy([
"blockSignature",
"createdAt",
"generatorPublicKey",
Expand All @@ -33,7 +32,7 @@ const isValidBlock = block => {
]);
const actualKeys = Object.keys(block).filter(key => allowedKeys.includes(key));

return Utils.isEqual(sortBy(actualKeys), allowedKeys);
return Utils.isEqual(Utils.sortBy(actualKeys), allowedKeys);
};

expect.extend({
Expand Down
5 changes: 2 additions & 3 deletions packages/core-jest-matchers/src/api/peer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -13,10 +12,10 @@ declare global {
}

const isValidPeer = peer => {
const allowedKeys = sortBy(["ip", "port"]);
const allowedKeys = Utils.sortBy(["ip", "port"]);
const actualKeys = Object.keys(peer).filter(key => allowedKeys.includes(key));

return Utils.isEqual(sortBy(actualKeys), allowedKeys);
return Utils.isEqual(Utils.sortBy(actualKeys), allowedKeys);
};

expect.extend({
Expand Down
5 changes: 2 additions & 3 deletions packages/core-jest-matchers/src/api/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -14,7 +13,7 @@ declare global {
expect.extend({
toBeApiTransaction: (actual, expected) => {
// TODO based on type
const allowedKeys = sortBy([
const allowedKeys = Utils.sortBy([
"id",
"blockid",
"type",
Expand All @@ -31,7 +30,7 @@ expect.extend({

return {
message: () => `Expected ${JSON.stringify(actual)} to be a valid transaction`,
pass: Utils.isEqual(sortBy(actualKeys), allowedKeys),
pass: Utils.isEqual(Utils.sortBy(actualKeys), allowedKeys),
};
},
});
3 changes: 1 addition & 2 deletions packages/core-jest-matchers/src/models/delegate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -15,7 +14,7 @@ expect.extend({
toBeDelegate: actual => {
return {
message: () => "Expected value to be a valid delegate",
pass: Utils.isEqual(sortBy(Object.keys(actual)), ["address", "publicKey", "username"]),
pass: Utils.isEqual(Utils.sortBy(Object.keys(actual)), ["address", "publicKey", "username"]),
};
},
});
5 changes: 2 additions & 3 deletions packages/core-jest-matchers/src/models/transaction.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -14,12 +13,12 @@ declare global {
expect.extend({
toBeTransaction: actual => {
// TODO based on type
const allowedKeys = sortBy(["id", "type", "amount", "fee", "timestamp", "signature"]);
const allowedKeys = Utils.sortBy(["id", "type", "amount", "fee", "timestamp", "signature"]);
const actualKeys = Object.keys(actual).filter(key => allowedKeys.includes(key));

return {
message: () => "Expected value to be a valid transaction",
pass: Utils.isEqual(sortBy(actualKeys), allowedKeys),
pass: Utils.isEqual(Utils.sortBy(actualKeys), allowedKeys),
};
},
});
3 changes: 1 addition & 2 deletions packages/core-jest-matchers/src/models/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Utils } from "@arkecosystem/core-kernel";
import { sortBy } from "@arkecosystem/utils";

export {};

Expand All @@ -15,7 +14,7 @@ expect.extend({
toBeWallet: actual => {
return {
message: () => "Expected value to be a valid wallet",
pass: Utils.isEqual(sortBy(Object.keys(actual)), ["address", "publicKey"]),
pass: Utils.isEqual(Utils.sortBy(Object.keys(actual)), ["address", "publicKey"]),
};
},
});
2 changes: 1 addition & 1 deletion packages/core-p2p/src/utils/is-valid-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const isValidVersion = (peer: Contracts.P2P.Peer): boolean => {
if (p2p && Array.isArray(p2p.minimumVersions) && p2p.minimumVersions.length > 0) {
minimumVersions = p2p.minimumVersions;
} else {
minimumVersions = app.get<any>("p2p.options").minimumVersions;
minimumVersions = app.get<{ minimumVersions: string[] }>("p2p.options").minimumVersions;
}

return minimumVersions.some((minimumVersion: string) => semver.satisfies(peer.version, minimumVersion));
Expand Down
4 changes: 0 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,10 @@
"@types/bip39": "^2.4.2",
"@types/bytebuffer": "^5.0.40",
"@types/cli-progress": "^1.8.1",
"@types/execa": "^2.0.0",
"@types/fast-levenshtein": "^0.0.1",
"@types/fs-extra": "^8.0.0",
"@types/got": "^9.6.7",
"@types/latest-version": "^4.0.1",
"@types/listr": "^0.14.2",
"@types/log-symbols": "^3.0.0",
"@types/pretty-bytes": "^5.2.0",
"@types/prompts": "^2.4.0",
"@types/semver": "^6.0.2",
"@types/wif": "^2.0.1"
Expand Down
Loading

0 comments on commit 6645c13

Please sign in to comment.