Skip to content

Refactor react package to re-export from core#142

Open
TaprootFreak wants to merge 5 commits intodevelopfrom
feature/react-reexport-from-core
Open

Refactor react package to re-export from core#142
TaprootFreak wants to merge 5 commits intodevelopfrom
feature/react-reexport-from-core

Conversation

@TaprootFreak
Copy link
Copy Markdown
Contributor

@TaprootFreak TaprootFreak commented Mar 19, 2026

Summary

  • Eliminates code duplication: Replaces all duplicated definition files, utils, and validations in @dfx.swiss/react with thin re-exports from @dfx.swiss/core
  • Establishes @dfx.swiss/core as single source of truth for all types, enums, utilities, and validation logic
  • Fixes missing barrel exports in @dfx.swiss/reactcloses Missing barrel exports in @dfx.swiss/react index.ts #148
  • Net result: -1971 lines, +291 lines — mostly removing duplicate code

Changes

Core (@dfx.swiss/core)

  • Extended Utils with 3 methods previously only in react: createRules, formatIban, toBase64
  • Added STOPPED to TransactionState enum
  • Added missing re-exports in src/index.ts: CheckStatus, AmlReason, KycStepCancelable, SupportIssueInternalState, Department

React (@dfx.swiss/react)

  • Added @dfx.swiss/core as dependency (^0.2.0-beta.7), removed ibantools/libphonenumber-js (now transitive via core)
  • Added TypeScript project reference to core in tsconfig.build.json
  • Replaced all 24 definition files + utils.ts + validations.ts with re-exports from core
  • Deleted duplicate blocked-iban.json
  • Updated kyc.hook.ts: KycUrl (process.env) → buildKycUrl(defaultUrl) (framework-agnostic), fixed kycUrl in all useCallback dependency arrays
  • Updated sell.hook.ts/swap.hook.ts: string-replace URL pattern → function call (SellUrl.confirm(id))
  • Added 19 missing barrel exports to src/index.ts (closes Missing barrel exports in @dfx.swiss/react index.ts #148): AssetUrl, AuthUrl, AuthWalletType, BankUrl, BankAccountUrl, BuyUrl, CountryUrl, FiatUrl, buildKycUrl, LanguageUrl, PaymentRoutesUrl, PaymentLinksUrl, SellUrl, SettingsUrl, SupportUrl, SwapUrl, TransactionUrl, UserUrl, UpdateUser, ApiKey, and the SignMessage type

Breaking Changes

None. The public API surface of @dfx.swiss/react is identical (plus the newly exposed barrel exports listed above).

Test plan

  • @dfx.swiss/core builds successfully
  • @dfx.swiss/react builds successfully
  • @dfx.swiss/react-components builds successfully
  • CI passes (build, test, lint)
  • Merged with current develop — no stale conflicts
  • @dfx.swiss/services-react builds against updated react package (tsc --noEmit: 0 errors; webpack dev build: 0 errors, only pre-existing source-map warnings)
  • Smoke test Buy/Sell/Swap/KYC flows in services app — all routes render without JS errors; Buy flow navigates Home → Chains → EVM → Ethereum → Assets; Sell/Swap/KYC correctly redirect to /login; bundle contains buildKycUrl (9×) and all other *Url exports (138×)

Closes #148

Replace duplicated definitions, utils, and validations in the react
package with thin re-exports from @dfx.swiss/core. This eliminates
code duplication across the two packages and establishes core as the
single source of truth for types and utilities.

- Add missing Utils methods to core (createRules, formatIban, toBase64)
- Replace 19 definition files with re-exports from core
- Replace utils.ts and validations.ts with re-exports from core
- Update kyc.hook to use buildKycUrl(apiUrl) instead of process.env
- Update sell.hook and swap.hook to use function-style confirm URLs
- Remove redundant ibantools/libphonenumber-js deps from react
- Delete duplicate blocked-iban.json from react
- No breaking changes to the public API
Merge origin/develop into feature branch, resolving conflicts by
keeping re-export pattern. Sync new additions from develop:

- Add STOPPED to TransactionState in core
- Add KycStepCancelable, SupportIssueInternalState, Department
  exports to core/src/index.ts
- Add CheckStatus, AmlReason exports to core/src/index.ts
- Replace react/definitions/aml.ts with re-export from core
The previous range ^0.1.1-beta.1 does not match the current core
version 0.2.0-beta.7, causing npm install to fail in CI.
The kycUrl memoized value was used in 12 callbacks without being
listed as a dependency. While defaultUrl never changes at runtime,
correct dependency arrays are required for React hooks consistency.
@TaprootFreak TaprootFreak marked this pull request as ready for review April 20, 2026 17:58
Re-exports all *Url values, buildKycUrl, AuthWalletType, UpdateUser,
ApiKey and the SignMessage type so consumers can import from the
package root instead of definition sub-paths.

Closes #148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing barrel exports in @dfx.swiss/react index.ts

1 participant