Skip to content

Feat/js sdk#9

Open
mbagalwa wants to merge 3 commits into
Safrochain-Org:mainfrom
mbagalwa:feat/js-sdk
Open

Feat/js sdk#9
mbagalwa wants to merge 3 commits into
Safrochain-Org:mainfrom
mbagalwa:feat/js-sdk

Conversation

@mbagalwa

@mbagalwa mbagalwa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add the JavaScript / TypeScript SDK (packages/js@safrochaindev/safhandle): read client (SafHandleClient) and signing client (SafHandleSigningClient) for registerName / transferName / releaseName, client-side validation that mirrors the contract, pinned network presets, dual ESM + CommonJS build with type declarations, examples and unit tests.
  • Add the Dart / Flutter SDK (packages/dartsafhandle): a feature-parity port with the same public surface (SafHandleClient, SafHandleSigningClient + pluggable SafHandleSigner), validation mirroring the contract's validation.rs, dependency-free bech32 checksum verification, examples and unit tests.
  • Pin the deployed mainnet contract on safrochain-1 in both SDKs (replacing the addr_saf_MAIN_NET placeholder); point the Dart mainnet preset at rpc/api.safrochain.network with gas price 0.15usaf. Cut 0.1.1-beta to npm and pub.dev.

Why

  • Ship first-class client libraries so wallets and dApps can resolve .saf names and register handles through a published SDK instead of hand-rolling CosmWasm query/execute payloads — with the same validation as the on-chain contract, so bad input is rejected before it costs gas.
  • Closes #

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Documentation update
  • CI / tooling

Test plan

  • npm run verify passes locally
  • Unit tests added or updated
  • Manual test on safro-testnet-1 (if on-chain behavior changed)

Steps:

  1. JScd packages/js && npm ci && npm test && npm run build (Vitest green, ESM+CJS+types emitted).
  2. Dartcd packages/dart && dart pub get && dart analyze && dart test (analyzer clean, all tests pass).
  3. On-chain — resolve/register a name against the pinned safro-testnet-1 contract (JS: SAFHANDLE_INTEGRATION=1 npm run test:integration; Dart: example/resolve.dart + example/register.dart).

Security checklist

  • No API keys, secrets, or private keys in code or commits

  • Phone numbers are not logged in production code paths

  • Contract address changes documented in config JSON

    SDK note: contract addresses are pinned in packages/js/src/constants.ts and packages/dart/lib/src/constants.dart (the SDKs' equivalent of config) and recorded in the Dart CHANGELOG.md. Phone links are Phase 2 and not part of these SDKs.

Documentation

  • README.md or docs/ updated (if user-facing)

  • CHANGELOG.md updated under [Unreleased]

    Dart packages/dart/CHANGELOG.md updated (0.1.1-beta section, SemVer-per-version rather than [Unreleased]). The JS package has no per-package changelog yet.

  • .env.example updated (if new env vars) — N/A, no new env vars.

  • Impact on safhandle-contract noted (if API changed) — N/A, the contract's query/execute API is unchanged; the SDKs consume it as-is.

Summary by CodeRabbit

  • New Features

    • Updated the Dart package to 0.1.1-beta and documented the initial SDK release history.
    • Refreshed the mainnet configuration with the latest contract address, RPC/REST endpoints, and gas price.
  • Documentation

    • Updated the README installation example to use the new package version.
  • Tests

    • Kept the existing test coverage intact with formatting updates only.

mbagalwa added 3 commits July 8, 2026 19:07
- Run `dart format .` over lib/, test/, and example/ (publish-ready style).
- Trim the pubspec description to 164 chars (within pub.dev's 60–180 range).

No behavior change; `dart analyze` clean and all 28 tests pass.
Bump the Dart SDK to a stable 0.1.0 for its first pub.dev publish (was
0.2.1-beta). Update the README install snippet and CHANGELOG heading to match.
@mbagalwa
mbagalwa requested a review from danbaruka July 9, 2026 16:19
@mbagalwa mbagalwa self-assigned this Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updates the Dart SDK's pinned SafHandle mainnet contract address and network preset (RPC/REST endpoints, gas price), bumps package version to 0.1.1-beta with updated description and changelog, updates README install snippet, and reformats multiple line-wrapping style changes across library, test, and example files without altering logic.

Changes

Dart SDK mainnet pinning and reformatting

Layer / File(s) Summary
Mainnet contract pinning, version bump, and changelog/README updates
packages/dart/lib/src/constants.dart, packages/dart/pubspec.yaml, packages/dart/CHANGELOG.md, packages/dart/README.md
Pins the real deployed mainnet contract address in contractAddresses and safrochainMainnet, updates RPC/REST endpoints and gas price, bumps package version to 0.1.1-beta with new description, adds changelog entries, and updates the README install snippet to ^0.1.0.
Library source formatting reflow
packages/dart/lib/src/client.dart, packages/dart/lib/src/signing_client.dart, packages/dart/lib/src/types.dart, packages/dart/lib/src/validation.dart
Reformats query/return statements, constructor declarations, method signatures, and validation expressions into multi-line layouts with no functional changes.
Test and example formatting reflow
packages/dart/test/client_test.dart, packages/dart/test/signing_client_test.dart, packages/dart/test/validation_test.dart, packages/dart/example/resolve.dart
Rewraps assertions, test declarations, and a print statement across multiple lines, preserving existing test logic and output.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: danbaruka

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is related to the PR but too generic to explain the main change. Use a specific title like 'Add JavaScript and Dart SDKs for SafHandle and pin mainnet contract addresses'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the template and includes the required sections with substantial detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mbagalwa mbagalwa added the enhancement New feature or request label Jul 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/dart/README.md`:
- Line 26: The README install snippet is out of sync with the published Dart
release line, so update the dependency version shown under the install example
to match the current package version used in pubspec.yaml. Adjust the dependency
entry in the README so users are directed to the same release line as the
published package, keeping the docs aligned with the package’s actual version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1ccef3c1-d0f2-41fa-8aed-93eb9c18707f

📥 Commits

Reviewing files that changed from the base of the PR and between 5201e13 and aa3d041.

📒 Files selected for processing (12)
  • packages/dart/CHANGELOG.md
  • packages/dart/README.md
  • packages/dart/example/resolve.dart
  • packages/dart/lib/src/client.dart
  • packages/dart/lib/src/constants.dart
  • packages/dart/lib/src/signing_client.dart
  • packages/dart/lib/src/types.dart
  • packages/dart/lib/src/validation.dart
  • packages/dart/pubspec.yaml
  • packages/dart/test/client_test.dart
  • packages/dart/test/signing_client_test.dart
  • packages/dart/test/validation_test.dart

Comment thread packages/dart/README.md
# pubspec.yaml
dependencies:
safhandle: ^0.2.1-beta
safhandle: ^0.1.0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Sync the install snippet with the release version.

pubspec.yaml now publishes 0.1.1-beta, but the README still tells users to install ^0.1.0. That leaves the published docs pointing at the wrong release line.

Suggested fix
-  safhandle: ^0.1.0
+  safhandle: ^0.1.1-beta
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
safhandle: ^0.1.0
safhandle: ^0.1.1-beta
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dart/README.md` at line 26, The README install snippet is out of
sync with the published Dart release line, so update the dependency version
shown under the install example to match the current package version used in
pubspec.yaml. Adjust the dependency entry in the README so users are directed to
the same release line as the published package, keeping the docs aligned with
the package’s actual version.

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant