Skip to content

feat(web3sdk-v2): prefer BUYGDFactoryV3 and bump goodprotocol - #272

Merged
L03TJ3 merged 2 commits into
masterfrom
feat/buygd-factory-v3
Aug 4, 2026
Merged

feat(web3sdk-v2): prefer BUYGDFactoryV3 and bump goodprotocol#272
L03TJ3 merged 2 commits into
masterfrom
feat/buygd-factory-v3

Conversation

@blueogin

@blueogin blueogin commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Bump @gooddollar/goodprotocol from ^2.2.1 to ^2.3.3 so deployment addresses include BUYGDFactoryV3.
  • Update useBuyGd to use BUYGDFactoryV3 when present, falling back to BuyGDFactoryV2.

About # (link your issue here)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • PR title matches follow: (Feature|Bug|Chore) Task Name
  • My code follows the style guidelines of this project
  • I have followed all the instructions described in the initial task (check Definitions of Done)
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have added reference to a related issue in the repository
  • I have added a detailed description of the changes proposed in the pull request. I am as descriptive as possible, assisting reviewers as much as possible.
  • I have added screenshots related to my pull request (for frontend tasks)
  • I have pasted a gif showing the feature.
  • @mentions of the person or team responsible for reviewing proposed changes

Summary by Sourcery

Prefer BUYGDFactoryV3 in the web3 SDK buy flow while updating protocol dependencies.

New Features:

  • Select BUYGDFactoryV3 for buy operations when available, with automatic fallback to the V2 factory.

Enhancements:

  • Upgrade @gooddollar/goodprotocol dependency to version ^2.3.3 to align deployment addresses with the new factory contract.

…ory initialization to support new contract address structure in useBuyGd hook.
@blueogin
blueogin requested review from a team and L03TJ3 August 3, 2026 12:24

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • In useBuyGd, consider explicitly handling the case where neither BUYGDFactoryV3 nor BuyGDFactoryV2 is present in contractAddresses[connectedEnv] so that you fail fast with a clear error rather than instantiating a Contract with undefined.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `useBuyGd`, consider explicitly handling the case where neither `BUYGDFactoryV3` nor `BuyGDFactoryV2` is present in `contractAddresses[connectedEnv]` so that you fail fast with a clear error rather than instantiating a `Contract` with `undefined`.

## Individual Comments

### Comment 1
<location path="packages/sdk-v2/src/sdk/buygd/react.tsx" line_range="31-32" />
<code_context>
   const devEnv = baseEnv === "fuse" ? "development" : baseEnv;
   const { backend } = Envs[devEnv];
-  const buyGdFactory = new Contract(contractAddresses[connectedEnv].BuyGDFactoryV2, buygdAbi);
+  const buyGdFactory = new Contract(
+    contractAddresses[connectedEnv].BUYGDFactoryV3 || contractAddresses[connectedEnv].BuyGDFactoryV2,
+    buygdAbi
+  );
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider using nullish coalescing and validating the address to avoid subtle fallback issues.

Using `||` means any falsy `BUYGDFactoryV3` (e.g. empty string) will silently fall back to `BuyGDFactoryV2`, which can hide misconfigurations. Prefer a nullish coalescing check and fail fast if neither address is set, e.g.:

```ts
const factoryAddress = contractAddresses[connectedEnv].BUYGDFactoryV3
  ?? contractAddresses[connectedEnv].BuyGDFactoryV2;

if (!factoryAddress) {
  throw new Error(`No BUYGD factory address configured for env ${connectedEnv}`);
}

const buyGdFactory = new Contract(factoryAddress, buygdAbi);
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread packages/sdk-v2/src/sdk/buygd/react.tsx Outdated
@L03TJ3
L03TJ3 merged commit 7c22c05 into master Aug 4, 2026
3 checks passed
@L03TJ3
L03TJ3 deleted the feat/buygd-factory-v3 branch August 4, 2026 06:05
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