fix: correct code examples in Base Account SDK and payment READMEs#355
Open
erhnysr wants to merge 1 commit into
Open
fix: correct code examples in Base Account SDK and payment READMEs#355erhnysr wants to merge 1 commit into
erhnysr wants to merge 1 commit into
Conversation
- Fix provider.request() to use the single RequestArguments object
signature ({ method, params }) instead of positional args
- Add missing await on eth_requestAccounts so addresses is resolved
before indexing addresses[0]
- Fix payment README import path (@base/account-sdk -> @base-org/account)
- Align examples with the real API: pay() throws on failure (no
success:false/error branch); PaymentStatus uses reason, not error
- Fix 'Base Accunt' typo -> 'Base Account'
Collaborator
🟡 Heimdall Review Status
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes several code examples in the README files that don't match the actual SDK API and would fail if copy-pasted.
Changes
provider.request()signature (README.md,packages/account-sdk/README.md) — the "Basic Usage" example calledprovider.request('personal_sign', [...])with positional arguments. The method signature isrequest(args: RequestArguments): Promise<unknown>and the runtime validation (checkErrorForInvalidRequestArgs) throwsExpected a single, non-array, object argument.for anything that isn't a single object. Changed toprovider.request({ method: 'personal_sign', params: [...] }), matching theeth_requestAccountsexample just above it.Missing
await(both READMEs) —const addresses = provider.request({ method: 'eth_requestAccounts' })returned a Promise, so the next step'saddresses[0]was indexing a Promise (undefined). Addedawait.Wrong import path (
packages/account-sdk/src/interface/payment/README.md) —import { getPaymentStatus } from '@base/account-sdk'referenced a non-existent package. Corrected to@base-org/account(consistent with the other imports in the same file).Align payment examples with the real API —
pay()resolves on success and throws on failure (PaymentResultisPaymentSuccessonly), so theif (payment.success) ... else payment.errorbranch was dead code referencing a non-existentpayment.error. Simplified to reflect the throw-on-failure contract. AlsoPaymentStatusexposesreason, noterror, sostatus.error→status.reason(and the API Reference entry updated to match).Typo — "Base Accunt" → "Base Account".
Notes
Docs-only change. No code or public API is modified.