Skip to content

Conversation

@SpectreMercury
Copy link
Contributor

@SpectreMercury SpectreMercury commented Jan 22, 2026

  • update docs for js sdk

Summary by CodeRabbit

  • Documentation
    • Enhanced Morph SDK documentation with clearer terminology and improved organization.
    • Added new Wallet Compatibility section detailing supported wallets and capability detection patterns.
    • Updated Quick Start guide to reflect current workflow for Alt Fee transactions and token registry interactions.
    • Reorganized adapter-specific sections with revised examples and fallback guidance.

✏️ Tip: You can customize this high-level summary in your review settings.

@SpectreMercury SpectreMercury requested a review from a team as a code owner January 22, 2026 14:50
@SpectreMercury SpectreMercury requested review from Web3Jumb0 and removed request for a team January 22, 2026 14:50
@coderabbitai
Copy link

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

The JavaScript SDK documentation was rewritten to clarify terminology, add a new Wallet Compatibility section with capability detection examples, and update Quick Start content and examples to reflect Alt Fee Transaction support detection, token registry interactions, and gas parameter handling.

Changes

Cohort / File(s) Summary
SDK Documentation Update
docs/build-on-morph/sdk/js-sdk.md
Extensive content revision: replaced generic phrasing with precise terminology ("Morph SDK Documentation", "Why Choose Morph SDK"); restructured feature comparison tables contrasting "Using Native Libraries" vs "Using Morph SDK"; added new Wallet Compatibility section with supported wallets and detectMorphCapabilities examples; reorganized Quick Start with Alt Fee detection workflow, token registry access, gas parameter retrieval, and updated transaction handling (feeTokenID, feeLimit parameters); refined viem/ethers/ethers5 adapter sections with clarified guidance and revised example blocks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Feat jssdk doc #121: Updates the same docs/build-on-morph/sdk/js-sdk.md documentation file with related SDK content revisions.
  • feat: add js sdk docs #120: Modifies the same JavaScript SDK documentation file that this PR refines and extends.

Suggested reviewers

  • Web3Jumb0
  • tomatoishealthy

Poem

🐰 Hop skip through SDK docs we go,
With Alt Fees and wallets all aglow,
Clearer paths for devs to find,
Better guides, a sharper mind!
Documentation hops anew,

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix sdk docs' is vague and overly generic—it does not convey the specific nature of the changes (documentation rewrite with wallet compatibility updates, Alt Fee transaction guidance, and workflow restructuring). Use a more descriptive title that reflects the primary changes, such as 'Update JS SDK documentation with wallet compatibility and Alt Fee transaction guidance' or 'Rewrite JS SDK docs with improved examples and wallet support details'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/build-on-morph/sdk/js-sdk.md (1)

44-74: Specify language for the fenced code block.

The ASCII diagram should have a language identifier to satisfy linting rules and improve rendering.

Proposed fix
-```
+```text
 ┌─────────────────────────────────────────────────────────┐

Based on static analysis hints.

🤖 Fix all issues with AI agents
In `@docs/build-on-morph/sdk/js-sdk.md`:
- Around line 229-256: Change the fenced formula block to include a language
identifier so it renders consistently with the TypeScript example; specifically
replace the opening ``` before the formula with ```typescript (and keep the
closing ```), so the formula and the subsequent calculateFeeLimit function
example are both marked as TypeScript and render with consistent highlighting;
check the formula fence and the calculateFeeLimit function block to ensure both
use the same ```typescript tag.
🧹 Nitpick comments (1)
docs/build-on-morph/sdk/js-sdk.md (1)

315-317: Consider adding a note about L1 Data Fee estimation.

While the comment acknowledges this is simplified, users might not realize that omitting L1 Data Fee could cause transactions to fail. Consider adding guidance on how to estimate or include a buffer.

Suggested enhancement

Add a comment suggesting a safety buffer:

 // 7. Calculate feeLimit (simplified, without L1 Data Fee)
 const estimatedEthCost = maxFeePerGas * gasLimit;
-const feeLimit = (estimatedEthCost * tokenScale) / feeRate;
+// Add 20% buffer to account for L1 Data Fee and price fluctuations
+const feeLimit = ((estimatedEthCost * tokenScale) / feeRate) * 120n / 100n;

Comment on lines +229 to +256
```
feeLimit >= (maxFeePerGas × gasLimit + L1DataFee) × tokenScale / feeRate
```

Where:
- `maxFeePerGas`: Maximum gas price (from RPC)
- `gasLimit`: Gas limit (from `estimateGas`)
- `L1DataFee`: L1 data fee (from receipt or estimated)
- `tokenScale`: Token precision coefficient (from `getTokenInfo`)
- `feeRate`: Token price ratio (from `priceRatio`)

```typescript
import { createPublicClient, createWalletClient, http, parseEther } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { morphHoodiTestnet } from "@morph-network/viem";
/**
* Calculate theoretical minimum feeLimit
*/
function calculateFeeLimit(
maxFeePerGas: bigint,
gasLimit: bigint,
l1DataFee: bigint,
tokenScale: bigint,
feeRate: bigint
): bigint {
const l2Fee = maxFeePerGas * gasLimit;
const totalFee = l2Fee + l1DataFee;
// Round up
return (totalFee * tokenScale + feeRate - 1n) / feeRate;
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Specify language for the fenced code block.

The formula block should have a language identifier. Consider using typescript since the code example below is TypeScript.

Proposed fix
-```
+```text
 feeLimit >= (maxFeePerGas × gasLimit + L1DataFee) × tokenScale / feeRate

-typescript + +Or specify `typescript` for the entire block including the formula: + +diff
+- ++typescript

  • /**
    • Calculate theoretical minimum feeLimit
</details>

Based on static analysis hints.

<!-- suggestion_start -->

<details>
<summary>📝 Committable suggestion</summary>

> ‼️ **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.

```suggestion

🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

229-229: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In `@docs/build-on-morph/sdk/js-sdk.md` around lines 229 - 256, Change the fenced
formula block to include a language identifier so it renders consistently with
the TypeScript example; specifically replace the opening ``` before the formula
with ```typescript (and keep the closing ```), so the formula and the subsequent
calculateFeeLimit function example are both marked as TypeScript and render with
consistent highlighting; check the formula fence and the calculateFeeLimit
function block to ensure both use the same ```typescript tag.

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