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

Farzin/R&D/80379/Extract cashier hooks into packages #6854

Conversation

farzin-deriv
Copy link
Contributor

@farzin-deriv farzin-deriv commented Nov 4, 2022

Changes:

Please include a summary of the change and which issue is fixed below:

  • ...

When you need to add unit test

  • If this change disrupt current flow
  • If this change is adding new flow

When you need to add integration test

  • If components from external libraries are being used to define the flow, e.g. @deriv/components
  • If it relies on a very specific set of props with no default behavior for the current component.

Test coverage checklist (for reviewer)

  • Ensure utility / function has a test case
  • Ensure all the tests are passing

Type of change

  • Bug fix
  • New feature
  • Update feature
  • Refactor code
  • Translation to code
  • Translation to crowdin
  • Script configuration
  • Improve performance
  • Style only
  • Dependency update
  • Documentation update
  • Release

@vercel
Copy link

vercel bot commented Nov 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
deriv-app ✅ Ready (Inspect) Visit Preview Nov 29, 2022 at 6:09AM (UTC)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2022

A production App ID was automatically generated for this PR. (log)

Click here to copy & paste above information.
- **PR**: [https://github.com/binary-com/deriv-app/pull/6854](https://github.com/binary-com/deriv-app/pull/6854)
- **URLs**:
    - **w/ App ID + Server**: https://deriv-app-git-fork-farzin-deriv-farzin-rdextractcashierh-ca37a7.binary.sx?qa_server=frontend.binaryws.com&app_id=24096
    - **Original**: https://deriv-app-git-fork-farzin-deriv-farzin-rdextractcashierh-ca37a7.binary.sx
- **App ID**: `24096`

@farzin-deriv farzin-deriv changed the base branch from master to develop November 4, 2022 06:03
@@ -0,0 +1,16 @@
{
"name": "@deriv/api",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package will be replaced by @deriv/deriv-api in the future as we move to TS and probably will have useWS and useSubscription hooks inside the @deriv/deriv-api package itself.

I've extracted useWS and useSubscription hooks from the cashier to this package so other packages can reuse these hooks.

declare module '@deriv/stores' {
export function useStore(): TRootStore & {
modules: {
cashier: CashierStore;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we override the TRootStore type that is returned from the useStore hook to add CashierStore types to it.

In the future cashier will have its own stores scoped to cashier instead of putting them in the root store so we will be removing this part.

Comment on lines +4 to +8
export type TRootStore = TRootStoreBase & {
modules: {
cashier: CashierStore;
};
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, We override the TRootStore type from the @deriv/stores package to add CashierStore types to it.
Once we removed the connect method in cashier we will be able to remove this part.

Comment on lines +10 to +12
export type TClientStore = TRootStore['client'];
export type TCommonStore = TRootStore['common'];
export type TUiStore = TRootStore['ui'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just re-exporting the types as they are used directly inside cashier components, Once we remove the connect method we can remove this part as well.

@@ -0,0 +1,16 @@
{
"name": "@deriv/hooks",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add all generic and reusable hooks inside this package to be accessible by other workspaces.

@@ -0,0 +1,15 @@
{
"name": "@deriv/stores",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future we will be moving all the global states (aka RootStore) to this package, Then other workspaces will be able to just install this package and have access to the stores instead of injecting the stores as a prop to each package.

toggleCashier: () => void;
};

export type TRootStore = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since for now, the root store exists in the core package, We cannot just infer the type and we have to manually type everything, As we gradually move stores from core to this package we will be able to remove these types and just infer the types instead.

@farzin-deriv farzin-deriv changed the title Farzin/R&D/Extract cashier hooks into packages Farzin/R&D/80379/Extract cashier hooks into packages Nov 4, 2022
@farzin-deriv farzin-deriv marked this pull request as ready for review November 4, 2022 07:36
@codecov-commenter
Copy link

codecov-commenter commented Nov 8, 2022

Codecov Report

Merging #6854 (b44ad0b) into develop (0984f5c) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #6854      +/-   ##
===========================================
- Coverage    21.65%   21.63%   -0.02%     
===========================================
  Files         1454     1457       +3     
  Lines        33493    33499       +6     
  Branches      5794     5795       +1     
===========================================
- Hits          7252     7249       -3     
- Misses       25772    25780       +8     
- Partials       469      470       +1     
Impacted Files Coverage Δ
packages/api/jest.config.js 0.00% <0.00%> (ø)
packages/api/src/useSubscription.ts 78.26% <0.00%> (ø)
packages/api/src/useWS.ts 87.50% <ø> (ø)
packages/cashier/src/app.jsx 0.00% <ø> (ø)
...er/account-transfer-form/account-transfer-form.tsx 75.36% <ø> (ø)
...ccount-transfer-locked/account-transfer-locked.tsx 100.00% <ø> (ø)
...ransfer-no-account/account-transfer-no-account.tsx 100.00% <ø> (ø)
...ount-transfer-receipt/account-transfer-receipt.tsx 93.10% <ø> (ø)
...er/src/pages/account-transfer/account-transfer.tsx 100.00% <ø> (ø)
...rc/pages/deposit/crypto-deposit/crypto-deposit.tsx 94.20% <ø> (ø)
... and 19 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sonarcloud
Copy link

sonarcloud bot commented Nov 29, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@farrah-deriv farrah-deriv merged commit 63e3f2d into binary-com:develop Nov 29, 2022
@farzin-deriv farzin-deriv deleted the farzin/r&d/extract_cashier_hooks_into_packages branch November 29, 2022 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants