feat(web3sdk-v2): prefer BUYGDFactoryV3 and bump goodprotocol - #272
Merged
Conversation
…ory initialization to support new contract address structure in useBuyGd hook.
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In
useBuyGd, consider explicitly handling the case where neitherBUYGDFactoryV3norBuyGDFactoryV2is present incontractAddresses[connectedEnv]so that you fail fast with a clear error rather than instantiating aContractwithundefined.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
L03TJ3
approved these changes
Aug 4, 2026
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.
Description
@gooddollar/goodprotocolfrom^2.2.1to^2.3.3so deployment addresses includeBUYGDFactoryV3.useBuyGdto useBUYGDFactoryV3when present, falling back toBuyGDFactoryV2.About # (link your issue here)
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist:
Summary by Sourcery
Prefer BUYGDFactoryV3 in the web3 SDK buy flow while updating protocol dependencies.
New Features:
Enhancements: