Skip to content

Fix savings SDK stake flow/errors and add dedicated savings widget demo app#47

Closed
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-savings-sdk-bugs
Closed

Fix savings SDK stake flow/errors and add dedicated savings widget demo app#47
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-savings-sdk-bugs

Conversation

Copilot AI commented May 8, 2026

Copy link
Copy Markdown
Contributor

Integrating savings-sdk in GoodDapp exposed three gaps: noisy RPC stack traces surfaced directly to users, stake attempts racing after approval flow, and weekly rewards showing 0 despite active rewards. This PR tightens SDK transaction/state handling, improves widget error UX including wrong-chain behavior, and adds a focused demo app for savings-widget integration.

  • Savings SDK: approval→stake correctness and reward computation

    • In packages/savings-sdk/src/viem-sdk.ts, stake() now enforces a stricter allowance path:
      • wait for approval receipt,
      • require successful approval status,
      • re-check allowance before proceeding to stake.
    • Weekly rewards logic now computes from refreshed global stats when needed and avoids invalid division paths.
    • Added explicit wallet runtime chain check before tx submission to fail fast with a clean wrong-network error.
  • Savings Widget: clean user-facing errors + chain-switch UX

    • In packages/savings-widget/src/GooddollarSavingsWidget.ts, transaction errors are normalized to a concise first-line message (stripping contract call/docs/detail noise).
    • Added wrong-chain handling for stake/unstake/claim actions:
      • attempts wallet_switchEthereumChain to Celo (0xa4ec),
      • falls back to clear user messaging if switching fails.
    • Tightened internal error typing and kept messages focused on actionable outcomes (rejected tx, insufficient gas funds, wrong network).
  • New demo app for savings-widget

    • Added apps/demo-savings-widget (Vite) to exercise savings widget flows with an injected EIP-1193 wallet.
    • Includes connect wiring, account/chain change handling, and direct provider assignment to <gooddollar-savings-widget>.
  • Docs update

    • Added apps/demo-savings-widget to the root workspace demo list in README.md.
// packages/savings-sdk/src/viem-sdk.ts (conceptual flow)
if (allowance < amount) {
  const approvalReceipt = await submitAndWait(approveTx)
  if (approvalReceipt.status !== "success") throw new Error("Approval transaction failed")

  const updatedAllowance = await readAllowance()
  if (updatedAllowance < amount) {
    throw new Error("Approval is still insufficient. Please wait for confirmation and try staking again.")
  }
}

return submitAndWait(stakeTx)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • binaries.soliditylang.org
    • Triggering command: /usr/local/bin/node /usr/local/bin/node /home/REDACTED/work/GoodSDKs/GoodSDKs/packages/engagement-contracts/node_modules/hardhat/internal/cli/bootstrap.js compile (dns block)
  • forno.celo.org
    • Triggering command: /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-linux64/chrome-headless-shell /home/REDACTED/.cache/ms-playwright/chromium_headless_shell-1217/chrome-headless-shell-linux64/chrome-headless-shell --disable-field-trial-config --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AvoidUnnecessaryBeforeUnloadCheckSync,BoundaryEventDispatchTracksNodeRemoval,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Transl in/dist/ripgrep/--disable-client-side-phishing-detection (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@github-project-automation github-project-automation Bot moved this to Ready-For-Assignment in GoodBounties May 8, 2026
Copilot AI linked an issue May 8, 2026 that may be closed by this pull request
6 tasks
Copilot AI changed the title [WIP] Fix issues in savings-sdk integration and create demo Fix savings SDK stake flow/errors and add dedicated savings widget demo app May 8, 2026
Copilot finished work on behalf of L03TJ3 May 8, 2026 11:39
Copilot AI requested a review from L03TJ3 May 8, 2026 11:39
@edehvictor

edehvictor commented May 8, 2026

Copy link
Copy Markdown
Contributor

GM @L03TJ3 please kindly assign to me. I can work on this. I'm an experienced open source contributor.

@Franklivania

Copy link
Copy Markdown

Hello @L03TJ3, I am able to take up this task, and improve the functionality on the three gaps. I actively contribute to the stellar ecosystem, and is able to execute with proper cleanup.

Thank you

@L03TJ3 L03TJ3 moved this from Ready-For-Assignment to In Progress in GoodBounties May 18, 2026
@L03TJ3 L03TJ3 moved this from In Progress to Blocked in GoodBounties May 18, 2026
@kadiray34

Copy link
Copy Markdown
Contributor

@L03TJ3 We have submitted new PR that contains these changes also.
#49
This can be closed.

@L03TJ3 L03TJ3 removed this from GoodBounties May 22, 2026
@L03TJ3

L03TJ3 commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Changes proposed are included in this PR: #49
so closing

@L03TJ3 L03TJ3 closed this May 26, 2026
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.

Fix: resolve savings sdk bugs and create demo

5 participants