Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDW-940] Use the new faker.js npm module #2855

Merged
merged 11 commits into from
Mar 22, 2022
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

### Chores

- Using new faker.js ([PR 2855](https://github.com/input-output-hk/daedalus/pull/2855))
- Removed `dockutil` due compatibility issues with MacOs Monterey 12.3 ([PR 2929](https://github.com/input-output-hk/daedalus/pull/2929))
- Fixed spelling issues and typos ([PR 2915](https://github.com/input-output-hk/daedalus/pull/2915))
- Removed SASS ts-lint ignore comments ([PR 2870](https://github.com/input-output-hk/daedalus/pull/2870))
- Enabled debugging of the main process ([PR 2893](https://github.com/input-output-hk/daedalus/pull/2893))
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@babel/preset-typescript": "^7.16.7",
"@babel/register": "7.0.0",
"@dump247/storybook-state": "1.6.1",
"@faker-js/faker": "6.0.0",
"@storybook/addon-actions": "5.3.21",
"@storybook/addon-knobs": "5.3.21",
"@storybook/addon-links": "5.3.21",
Expand Down Expand Up @@ -136,7 +137,6 @@
"eslint-plugin-react": "7.21.2",
"eslint-plugin-react-hooks": "4.1.2",
"esm": "3.2.25",
"faker": "5.1.0",
"fast-sass-loader": "1.5.0",
"file-loader": "4.2.0",
"gulp-shell": "0.8.0",
Expand Down
6 changes: 3 additions & 3 deletions source/renderer/app/components/wallet/WalletSendForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState } from 'react';
import { addLocaleData } from 'react-intl';
import BigNumber from 'bignumber.js';
import { Provider as MobxProvider } from 'mobx-react';
import faker from 'faker';
import faker from '@faker-js/faker';
import {
render,
fireEvent,
Expand All @@ -28,12 +28,12 @@ describe('wallet/Wallet Send Form', () => {
const currencyMaxFractionalDigits = 6;

function createAssets(index: number) {
const id = `${faker.random.uuid()}:${index}`;
const id = `${faker.datatype.uuid()}:${index}`;
return {
policyId: id,
assetName: faker.internet.domainWord(),
uniqueId: id,
fingerprint: faker.random.uuid(),
fingerprint: faker.datatype.uuid(),
quantity: new BigNumber(faker.finance.amount()),
decimals: 0,
recommendedDecimals: null,
Expand Down
33 changes: 15 additions & 18 deletions source/renderer/app/config/generateStakePoolFakeData.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
/**
* It generates stake pool dummy json content
* Command to run: node source/renderer/app/config/generateStakePoolFakeData.js
* Command to run: yarn ts-node source/renderer/app/config/generateStakePoolFakeData.ts
*/
const faker = require('faker');
import faker from '@faker-js/faker';
import fs from 'fs';
import path from 'path';
import BigNumber from 'bignumber.js';

// const fs = require('fs');
const path = require('path');

const BigNumber = require('bignumber.js');

function generatStakePoolsFakeData() {
function generateStakePoolsFakeData() {
const stakePools = [];

for (let i = 1; i <= 300; i++) {
const relativeStake = faker.random.number(100);
const cost = new BigNumber(faker.random.number(100));
const relativeStake = faker.datatype.number(100);
const cost = new BigNumber(faker.datatype.number(100));
const createdAt = faker.date.recent();
const description = faker.lorem.words();
const homepage = faker.internet.url();
const id = faker.random.alphaNumeric(64);
const isCharity = faker.random.boolean();
const isCharity = faker.datatype.boolean();
const name = faker.name.findName();
const performance = faker.random.number(100);
const pledge = new BigNumber(faker.random.number(100));
const producedBlocks = faker.random.number(10000000);
const profitMargin = faker.random.number(100);
const performance = faker.datatype.number(100);
const pledge = new BigNumber(faker.datatype.number(100));
const producedBlocks = faker.datatype.number(10000000);
const profitMargin = faker.datatype.number(100);
const ranking = i;
const retiring = null;
const saturation = faker.random.number({
const saturation = faker.datatype.number({
min: 0,
max: 120,
precision: 0.01,
Expand Down Expand Up @@ -56,11 +54,10 @@ function generatStakePoolsFakeData() {
return stakePools;
}

const fakeStakePools = generatStakePoolsFakeData();
const fakeStakePools = generateStakePoolsFakeData();
// @TODO - remove flow fix and move fs to main process

/* eslint-disable no-undef */
// @ts-ignore
fs.writeFileSync(
`${path.join(__dirname, '/')}stakingStakePools.dummy.json`,
JSON.stringify(fakeStakePools, null, '\t')
Expand Down
2 changes: 1 addition & 1 deletion storybook/stories/_support/StoryProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
// @ts-ignore ts-migrate(2305) FIXME: Module '"react"' has no exported member 'Node'.
import type { Node } from 'react';
import { Provider, observer } from 'mobx-react';
import faker from 'faker';
import faker from '@faker-js/faker';
import { observable, computed, runInAction } from 'mobx';
import BigNumber from 'bignumber.js';
import moment from 'moment';
Expand Down
4 changes: 2 additions & 2 deletions storybook/stories/_support/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hash from 'hash.js';
import faker from 'faker';
import faker from '@faker-js/faker';
import JSONBigInt from 'json-bigint';
import moment from 'moment';
import { get } from 'lodash';
Expand Down Expand Up @@ -200,7 +200,7 @@ export const generateTransaction = (
metadata: TransactionMetadata = EXAMPLE_METADATA
) =>
new WalletTransaction({
id: faker.random.uuid(),
id: faker.datatype.uuid(),
title: '',
type,
amount: amount.plus(fee),
Expand Down
2 changes: 1 addition & 1 deletion storybook/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = async ({ config }) => {
'bs58',
'classnames',
'es6-error',
'faker',
'@faker-js/faker',
'humanize-duration',
'lodash',
'mobx',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2011,6 +2011,10 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@faker-js/faker@6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-6.0.0.tgz#b613ebf5f5ebb2ab987afb567d8b7fe860199c13"

"@icons/material@^0.2.4":
version "0.2.4"
resolved "https://registry.yarnpkg.com/@icons/material/-/material-0.2.4.tgz#e90c9f71768b3736e76d7dd6783fc6c2afa88bc8"
Expand Down Expand Up @@ -8196,10 +8200,6 @@ extsprintf@^1.2.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f"

faker@5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/faker/-/faker-5.1.0.tgz#e10fa1dec4502551aee0eb771617a7e7b94692e8"

falafel@^2.1.0:
version "2.2.4"
resolved "https://registry.yarnpkg.com/falafel/-/falafel-2.2.4.tgz#b5d86c060c2412a43166243cb1bce44d1abd2819"
Expand Down