-
Notifications
You must be signed in to change notification settings - Fork 4
Add exitOffer method to agoricWalletConnection for seamless offer exits #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: turadg <[email protected]>
Deploying ui-kit with
|
| Latest commit: |
531b365
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://edbac240.ui-kit-dwm.pages.dev |
| Branch Preview URL: | https://copilot-add-exit-offer-metho.ui-kit-dwm.pages.dev |
Co-authored-by: turadg <[email protected]>
|
@copilot add a section to the index page for |
Co-authored-by: turadg <[email protected]>
Added an "Exit Offer" section to the example app index page (commit 531b365). The section includes:
The UI displays below the "Test Transaction" button with a clear visual separator. 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:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. Needs @samsiegart review before merging.
There was a problem hiding this 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 adds an exitOffer method to agoricWalletConnection to allow dapp users to exit long-standing offers directly from dapp UIs. This addresses the problem where dapp developers previously had to either create complex contract methods or build custom interactive signers.
- Implements
exitOffermethod that accepts offer IDs and createstryExitOfferspend actions - Exposes the functionality through React components context
- Adds comprehensive test coverage and example UI implementation
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/web-components/src/wallet-connection/walletConnection.ts | Core implementation of exitOffer method |
| packages/web-components/test/wallet-connection/walletConnection.test.js | Test coverage for string/numeric offer IDs and error handling |
| packages/react-components/src/lib/context/AgoricContext.ts | Type definition for exitOffer in React context |
| packages/react-components/src/lib/context/AgoricProvider.tsx | Exposes exitOffer through React provider |
| packages/example/src/components/WalletDetails.tsx | Example UI implementation with input field and status display |
| README.md | Documentation with usage examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

What is the Problem Being Solved?
Dapp developers want their users to be able to exit long-standing offers directly from their dapp UI to provide a seamless experience. Previously, this required either:
waived: nullflag (which breaks wallet-app), orBoth approaches are cumbersome and error-prone for dapp developers.
Description of the Design
This PR adds an
exitOffermethod tomakeAgoricWalletConnectionin the web-components package. The implementation:offerIdparameter (string or number)tryExitOfferspend action using the wallet's marshallersubmitSpendActioninfrastructureThis approach keeps the functionality restricted and less error-prone while providing dapp developers with a simple, clean API.
Usage Example
Dapp developers can watch offer status updates using the existing
walletUpdatesNotifierfrom the wallet connection to track when offers are successfully exited.Implementation Details
The
exitOffermethod creates a spend action that maps to theTryExitOfferActionbridge action type from@agoric/smart-wallet:This calls
tryExit()on the offer's seat in the smart wallet contract, following the same secure transaction flow asmakeOffer.Changes Made
Web Components Package
exitOffermethod tomakeAgoricWalletConnectioninsrc/wallet-connection/walletConnection.tsReact Components Package
exitOfferto AgoricState type insrc/lib/context/AgoricContext.tsexitOfferin AgoricProvider to make it available through the React contextExample App
src/components/WalletDetails.tsxdemonstrating the feature:Security Considerations
submitSpendActioninfrastructureTest Plan
Fixes #44
Original prompt
Fixes #44
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.