Skip to content

Refactor react package to re-export from core#142

Draft
TaprootFreak wants to merge 1 commit intodevelopfrom
feature/react-reexport-from-core
Draft

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

Conversation

@TaprootFreak
Copy link
Contributor

Summary

  • Eliminates code duplication: Replaces 19 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
  • Net result: -1877 lines, +251 lines — mostly removing duplicate code

Changes

Core (@dfx.swiss/core)

  • Extended Utils with 3 methods previously only in react: createRules, formatIban, toBase64

React (@dfx.swiss/react)

  • Added @dfx.swiss/core as dependency, removed ibantools/libphonenumber-js (now transitive via core)
  • Added TypeScript project reference to core in tsconfig.build.json
  • Replaced all 19 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)
  • Updated sell.hook.ts/swap.hook.ts: string-replace URL pattern → function call (SellUrl.confirm(id))

Breaking Changes

None. The public API surface of @dfx.swiss/react is identical.

Test plan

  • @dfx.swiss/core builds successfully
  • @dfx.swiss/react builds successfully
  • dist/index.d.ts exports are identical to before
  • Verify @dfx.swiss/services-react builds against updated react package
  • Smoke test KYC, Buy, Sell, Swap flows in services app

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
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.

1 participant