Skip to content

fix: correct code examples in Base Account SDK and payment READMEs#355

Open
erhnysr wants to merge 1 commit into
base:masterfrom
erhnysr:fix/payment-readme-code-examples
Open

fix: correct code examples in Base Account SDK and payment READMEs#355
erhnysr wants to merge 1 commit into
base:masterfrom
erhnysr:fix/payment-readme-code-examples

Conversation

@erhnysr

@erhnysr erhnysr commented Jul 8, 2026

Copy link
Copy Markdown

What

Fixes several code examples in the README files that don't match the actual SDK API and would fail if copy-pasted.

Changes

  1. provider.request() signature (README.md, packages/account-sdk/README.md) — the "Basic Usage" example called provider.request('personal_sign', [...]) with positional arguments. The method signature is request(args: RequestArguments): Promise<unknown> and the runtime validation (checkErrorForInvalidRequestArgs) throws Expected a single, non-array, object argument. for anything that isn't a single object. Changed to provider.request({ method: 'personal_sign', params: [...] }), matching the eth_requestAccounts example just above it.

  2. Missing await (both READMEs) — const addresses = provider.request({ method: 'eth_requestAccounts' }) returned a Promise, so the next step's addresses[0] was indexing a Promise (undefined). Added await.

  3. 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).

  4. Align payment examples with the real APIpay() resolves on success and throws on failure (PaymentResult is PaymentSuccess only), so the if (payment.success) ... else payment.error branch was dead code referencing a non-existent payment.error. Simplified to reflect the throw-on-failure contract. Also PaymentStatus exposes reason, not error, so status.errorstatus.reason (and the API Reference entry updated to match).

  5. Typo — "Base Accunt" → "Base Account".

Notes

Docs-only change. No code or public API is modified.

- 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'
@cb-heimdall

Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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.

2 participants