Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 27, 2025

Problem

The ConfigBuilder.build() method was returning { options: WalletFixtureOptions } while BaseWalletBuilder.build() (used by wallet-specific builders like MetaMaskConfigBuilder) was returning WalletFixtureOptions directly. This created an inconsistent API where users would theoretically need to call:

// Inconsistent - if using ConfigBuilder directly
createOnchainTest(configure().build().options)

// vs. Normal usage - using wallet-specific builders  
createOnchainTest(configure().withMetaMask().build())

Root Cause

The issue was in the ConfigBuilder.build() method implementation:

// Before: Incorrect wrapper
build(): { options: WalletFixtureOptions } {
  // ...
  return {
    options: { wallets } as WalletFixtureOptions,
  }
}

// After: Consistent with BaseWalletBuilder
build(): WalletFixtureOptions {
  // ...
  return { wallets, nodeConfig: this.nodeConfig } as WalletFixtureOptions
}

Solution

Changed ConfigBuilder.build() to return WalletFixtureOptions directly, making it consistent with BaseWalletBuilder.build(). This ensures a uniform API where createOnchainTest(config.build()) works regardless of the configuration path taken.

Impact

  • Backward Compatible: The old { options } pattern wasn't used anywhere in the codebase
  • API Consistency: Both configuration paths now return the same type
  • Developer Experience: Cleaner, more intuitive API usage
  • No Breaking Changes: All existing tests and examples continue to work

Verification

  • All tests pass (3/3)
  • Build completes successfully
  • Linting passes with no issues
  • Example applications work correctly
  • Manual testing confirms both normal and edge case usage work as expected
Original prompt

This section details on the original issue you should resolve

<issue_title>[BUG]</issue_title>
<issue_description>## Bug Description
A clear and concise description of what the bug is.

Steps to Reproduce

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Behavior

A clear and concise description of what you expected to happen.

Actual Behavior

A clear and concise description of what actually happened.

Environment Information

  • Onchain Test Kit Version: [e.g., 1.2.0]
  • Node.js Version: [e.g., 18.17.0]
  • Operating System: [e.g., macOS 13.4, Windows 11, Ubuntu 20.04]
  • Browser: [e.g., Chrome 115, Firefox 116]
  • Wallet: [e.g., MetaMask, Coinbase Wallet, Phantom]

Configuration Used

// Paste your configuration code here
const config = configure()
  .withMetaMask()
  // ... other configuration
  .build();

Error Logs

Paste any error messages, stack traces, or relevant logs here

Code Sample

// Minimal code example that reproduces the issue
import { createOnchainTest, configure } from '@coinbase/onchaintestkit';

const test = createOnchainTest(/* your config */);

test('failing test', async ({ page, metamask }) => {
  // Steps that cause the bug
});

Screenshots

If applicable, add screenshots to help explain your problem.

Additional Context

Add any other context about the problem here.

Possible Solution

If you have suggestions on how to fix the bug, please describe them here.

Checklist

  • I have searched for existing issues that describe this bug
  • I have included all the required environment information
  • I have provided a minimal code example that reproduces the issue
  • I have included relevant error messages and logs</issue_description>

<agent_instructions><issue_title>copilot-setup-steps</issue_title>
<issue_description>/.github/copilot-instructions.md
/.github/instructions/**/*.instructions.md
**/AGENTS.md
/CLAUDE.md
/GEMINI.md</issue_description></agent_instructions>

Comments on the Issue (you are @copilot in this section)

Fixes #84

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: joe10832 <103850533+joe10832@users.noreply.github.com>
Copilot AI changed the title [WIP] [BUG] Fix ConfigBuilder.build() API inconsistency Sep 27, 2025
Copilot AI requested a review from joe10832 September 27, 2025 21:36
Copy link
Member

@joe10832 joe10832 left a comment

Choose a reason for hiding this comment

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

@joe10832 joe10832 marked this pull request as ready for review September 27, 2025 21:56
Copilot AI review requested due to automatic review settings September 27, 2025 21:56
@joe10832 joe10832 merged commit ee72c71 into main Sep 27, 2025
2 checks passed
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an API inconsistency in the ConfigBuilder.build() method to ensure it returns the same type as BaseWalletBuilder.build(). The change eliminates the need for users to access a nested .options property when using ConfigBuilder directly.

  • Standardizes return type across all builder implementations
  • Removes unnecessary object wrapper from ConfigBuilder.build()
  • Includes nodeConfig in the returned configuration object

Copy link
Member

@joe10832 joe10832 left a comment

Choose a reason for hiding this comment

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

@joe10832 joe10832 removed their assignment Sep 27, 2025
Copy link
Member

@joe10832 joe10832 left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@joe10832 joe10832 left a comment

Choose a reason for hiding this comment

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

@joe10832
Copy link
Member

joe10832 commented Oct 1, 2025

@copilot

1 similar comment
@joe10832
Copy link
Member

joe10832 commented Oct 1, 2025

@copilot

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.

[BUG]

2 participants