Thanks for taking the time to contribute. This package is small, so the process is light.
git clone https://github.com/p2pdotme/widgets.git
cd widgets
npm install
npm run verifynpm run verify chains typecheck → typecheck:examples → test → build and
mirrors what CI runs.
src/widgets/— the three React widgets (Checkout,Cashout,PaymentHistory). Each gets a subpath entry barrel insrc/(src/checkout.ts,src/cashout.ts,src/payment-history.ts) which tsup builds as a separate package entry.src/core/— state machines, error system, contract helpers, currency metadata. Unit-tested.src/ui/— primitives + theme.src/hooks/— public hooks (useUserTxLimit).src/types.ts— public prop types. Treat changes here as API changes.src/index.ts— public exports. The single source of truth for what ships in the package.examples/basic-checkout.tsx— canonical host integration. Must typecheck against the current public types (CI gates this).docs/— long-form runbooks (post-mortems, smoke-test recipes).
- Branch from
main. - Run
npm run verifylocally before pushing. - Open a PR against
main. CI will re-run the same checks on Node 18 + 20. - Add a
[Unreleased]entry toCHANGELOG.mddescribing the change.
- No source comments that explain what the code does — well-named identifiers handle that. Reserve comments for why: a non-obvious invariant, a subtle workaround, a constraint that's not in the code.
- No dead code or commented-out blocks. Delete it; git remembers.
- Public types live in
src/types.ts. If you add a prop, update the README's API reference table in the same PR. - Errors flow through
src/core/errors.ts. Don'tthrow new Error(...)with a raw string from a catch site — usetoP2PError(err, ctx)or one of the pre-built constructors (noEligibleMerchantsError,missingRoutingInputsError, …). This keeps the host-sideonErrorsurface consistent. - Tests use
node:test+node --experimental-strip-types— no Jest / Vitest. Co-locate tests next to the module:foo.ts↔foo.test.ts.
npm version <patch|minor|major>
git push --follow-tags
npm publishprepublishOnly runs clean → build automatically; only dist/ ships.
Open an issue at
github.com/p2pdotme/widgets/issues.
Include: widget version, peer-dep versions (React, viem, @p2pdotme/sdk),
chain ID, and the structured [p2p-widget:<flow>] CODE console log if
there is one.
For security-sensitive reports, see SECURITY.md.