-
Notifications
You must be signed in to change notification settings - Fork 60
Fix sdk docs #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix sdk docs #125
Conversation
📝 WalkthroughWalkthroughThe 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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this 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;
| ``` | ||
| 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; | ||
| } | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.