Skip to content

Sync staging#736

Merged
Megha-Dev-19 merged 44 commits intomainfrom
staging
Nov 10, 2025
Merged

Sync staging#736
Megha-Dev-19 merged 44 commits intomainfrom
staging

Conversation

@Megha-Dev-19
Copy link
Collaborator

No description provided.

petersalomonsen and others added 30 commits September 1, 2025 18:42
…API (#666)

## Summary

This PR implements auto-fetching of quotes and backend integration for
the 1Click API feature, building on top of the existing 1Click swap
interface already in staging.



https://github.com/user-attachments/assets/ed96d3f7-f393-454a-ba10-ef69afb65f75



https://github.com/user-attachments/assets/b3213a6b-7f47-4e85-9281-e16267cc2db0


## What's New in This PR

### ✨ Auto-Fetch Quotes
- **Automatic quote fetching**: Quotes now fetch automatically when form
fields change (500ms debounce)
- **Removed "Get Quote" button**: No longer needed - quotes appear
automatically as users fill the form
- **Better UX**: Users see quotes immediately without extra clicks

### 🔒 Backend Security Integration
- **Custom backend endpoint**: `/api/treasury/oneclick-quote` for secure
API calls
- **Dual-path architecture**:
- Preview quotes (`dry: true`) → Direct to 1Click API (no API key
needed)
  - Actual proposals → Through our backend (API key protected)
- **DAO validation**: Backend validates that only sputnik-dao.near
addresses can create proposals
- **API key protection**: Key stored securely on backend, never exposed
to frontend

### 🐛 Bug Fixes & Improvements
- Fixed test to scroll quote display into view before screenshots
- Updated tests to expect "Create Proposal" button instead of "Get
Quote"
- Added proper timeout handling for auto-fetch debouncing
- Ensure deadline from request is included in formatted quotes

## Changes Made

### Code Changes
- Added `useEffect` hook for auto-fetching quotes with 500ms debounce
- Modified quote fetching to support both dry (preview) and real quotes
- Updated form to work without manual quote button
- Added backend endpoint integration for secure proposal creation

### Test Updates
- Updated all test references from "Get Quote" to "Create Proposal"
button
- Added `scrollIntoViewIfNeeded()` before taking screenshots
- Fixed test expectations to match auto-fetch behavior

## Testing

Run the tests:
```bash
npm test -- playwright-tests/tests/intents/oneclick-exchange-form.spec.js --project=treasury-testing
```

## Related PRs

- Backend implementation:
NEAR-DevHub/ref-sdk-api#20
- Original 1Click feature (already in staging): #628

## Deployment Requirements

1. Deploy [backend
PR](NEAR-DevHub/ref-sdk-api#20) first with
`ONECLICK_API_KEY` environment variable
2. Deploy this frontend PR
3. The auto-fetch feature gracefully falls back if backend is
unavailable

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---

## Latest Updates (Test Infrastructure Improvements)

### 🔧 RPC Proxy Enhancements (`playwright-tests/server/rpcproxy.js`)
- **Request Queueing**: Implemented sequential request processing to
prevent overwhelming RPC endpoints
- **Response Caching**: Added 1-second TTL cache for identical POST
bodies to reduce redundant requests
- **429 Error Handling**: Automatic blacklisting of rate-limited nodes
for 30 seconds
- **Removed Incompatible Endpoint**: Removed `near.drpc.org` which
doesn't support the "query" method

### 🐛 Route Handling Fix (`playwright-tests/util/rpcmock.js`)
- Added `await` statements to `route.fulfill()` and `route.fallback()`
calls
- Fixes "Route already handled" errors that were causing test failures

### ✅ Bulk Import Test Fixes
(`playwright-tests/tests/payments/create-bulk-import-request.spec.js`)
- Added `mockNearBalances` to mock sufficient account balance (10 NEAR)
- Prevents "Insufficient Funds" modal from blocking test execution
- All CSV validation tests now passing (comma-separated, tab-separated,
quoted fields)

### 🛠️ Development Server Fixes (`playwright-tests/server/devserver.js`)
- **Fixed startup failures**: Removed `cacheCDN` import that caused
conflicts with test hooks
- **Simplified RPC connection**: Switched from local RPC proxy to
fastnear.com mainnet RPC for improved reliability
- **Documentation**: Added comprehensive README documentation for
devserver usage and storage state configuration

### Test Results After Latest Changes
✅ All OneClick exchange form tests passing
✅ All bulk import CSV validation tests passing
✅ Payment request tests passing with improved stability
✅ Development server starts reliably without dependencies

### Impact
These changes significantly improve test reliability by:
- Preventing RPC rate limiting issues during test runs
- Ensuring proper route handling in Playwright tests
- Eliminating false test failures due to insufficient balance modals
- Reducing test flakiness from concurrent RPC requests
- Enabling reliable local development with preserved authentication
state

---------

Co-authored-by: Claude <noreply@anthropic.com>
- Minor CSS fixes with filters
- Added view request action to all successfully created request toasts

---------

Co-authored-by: Peter Salomonsen <pjsalomonsen@gmail.com>
…pdown balances (#673)

## Summary
This PR refactors the OneClick exchange form to use an iframe
implementation, improving isolation and maintainability. The form now
integrates Web3Icons directly for better performance and adds several UX
improvements.




https://github.com/user-attachments/assets/bfd149d3-9f7a-42ca-9579-83d4e512f508



https://github.com/user-attachments/assets/c4b8eda6-fe1a-42e2-8c7f-15d09e66f3b4


# Screenshots

<img width="576" height="800" alt="02-dark-theme"
src="https://github.com/user-attachments/assets/5fb6df15-6cc4-4f80-bdbb-7e78f52577e6"
/>

<img width="576" height="1116" alt="04-quote-details-expanded"
src="https://github.com/user-attachments/assets/ec387237-feba-47b4-899e-3a6665e91974"
/>

<img width="300" height="350" alt="05-token-icons-in-dropdown"
src="https://github.com/user-attachments/assets/0ce24da0-e53d-463c-9d1b-08006c0a902f"
/>

<img width="576" height="1116" alt="07-quote-with-details-expanded"
src="https://github.com/user-attachments/assets/db54d338-dfb3-4a91-a996-d27eeae62108"
/>


<img width="1280" height="720" alt="07-send-token-dropdown"
src="https://github.com/user-attachments/assets/f7287518-458e-46ee-9443-18cec51e76f5"
/>
<img width="1280" height="720" alt="08-quote-displayed"
src="https://github.com/user-attachments/assets/84b4be62-0327-4bb6-a838-172f6720cd16"
/>
<img width="1280" height="720" alt="09-quote-details-expanded"
src="https://github.com/user-attachments/assets/5438bd93-bef6-4bd9-9b1d-82100708e12a"
/>
<img width="1280" height="720" alt="09-transaction-modal"
src="https://github.com/user-attachments/assets/0c2f2587-7cfa-4c04-8b5e-5c6284d71416"
/>
<img width="1280" height="720" alt="10-pending-requests-page"
src="https://github.com/user-attachments/assets/e989b179-c131-49f1-98f5-3df458d6e436"
/>
<img width="1280" height="720" alt="11-after-approval"
src="https://github.com/user-attachments/assets/3cca7e94-29be-482d-96d2-637002f49146"
/>

<img width="1280" height="720" alt="12-history-tab"
src="https://github.com/user-attachments/assets/f4dcb0fa-7ac8-4605-aee0-8177c279def1"
/>




### Key Changes:
- **Iframe Implementation**: Moved OneClickExchangeForm to iframe-based
architecture for better isolation
- **New Quote Flow**: Added explicit "Get Quote" button that users must
click before seeing quote details and "Create Proposal" button
- **Web3Icons Integration**: Integrated Web3Icons library directly into
iframe for token/network icons and names
- **Token Balance Display**: Shows NEAR Intents balances in dropdown
selections
- **Improved Dropdowns**: Right-aligned dropdowns with search
functionality and visual improvements
- **Form Locking**: Fields are locked after obtaining a quote to prevent
changes
- **Quote Details**: Shows deposit address, minimum received amount, and
expiration time

### Technical Details:
- Removed unnecessary changes to DropDownWithSearchAndManualRequest
component
- Deleted old OneClickExchangeForm.jsx file (non-iframe version)
- Direct backend API calls from iframe without going through parent
component
- Preserves nep141: prefix in token IDs for proper mt_transfer
operations

### User Flow:
1. User selects send token, receive token, and network
2. User enters amount to exchange
3. Preview amount appears in receive field
4. User clicks "Get Quote" button to fetch actual quote from backend
5. Quote details are displayed with all relevant information
6. User clicks "Create Proposal" to submit the exchange request

### Testing:
- All Playwright tests updated for new iframe implementation and quote
flow
- Added deposit address verification in tests
- Tests cover both light and dark themes
- Comprehensive test coverage for search, icons, and form validation

resolves #640

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
…shboard (#694)

## Summary

This PR implements intelligent token decimal display formatting
throughout the treasury dashboard, showing only meaningful precision
based on USD value while removing unnecessary trailing zeros.

## Screenshots

### Dashboard

View of token balances in the NEAR Intents portfolio dashboard widget

<img width="526" height="460" alt="image"
src="https://github.com/user-attachments/assets/0c8ed460-8053-4b99-bbb3-e2a88fb364b0"
/>

### Payment request detail

<img width="297" height="334" alt="image"
src="https://github.com/user-attachments/assets/4b847d2f-af02-4037-a744-6a857d1302cc"
/>

### NEAR Intents asset exchange

<img width="363" height="688" alt="image"
src="https://github.com/user-attachments/assets/02b14306-3cde-4e0a-8f1b-083575a7ff95"
/>

### Asset exchange table

<img width="1073" height="621" alt="image"
src="https://github.com/user-attachments/assets/62192ec5-6d3b-4c05-a485-242eba3afd42"
/>

### Asset exchange details

<img width="467" height="349" alt="image"
src="https://github.com/user-attachments/assets/a6312cc6-041d-42f6-be7c-452dae3531c8"
/>

### Payment request table

<img width="574" height="246" alt="image"
src="https://github.com/user-attachments/assets/5c89cf5e-2d01-426a-94a6-30d57b120e71"
/>

## What's Changed

### Core Implementation
- **New tokenDisplay library** - Implements intelligent formatting with
0.01 USD precision threshold
- **TokenAmount component updates** - Integrated intelligent formatting
that dynamically adjusts decimal precision based on token price
- **TokenAmountAndIcon component** - Added intelligent formatting
support
- **OneClick Exchange form** - Display token balances with appropriate
precision in dropdowns

### Key Features
- Shows only meaningful decimals based on USD value (±0.01 precision
threshold)
- Removes unnecessary trailing zeros from whole numbers (e.g., 100.00 →
100)
- Maintains thousand separators for readability (e.g., 2500 → 2,500)
- Handles NEAR Intents token format by stripping 'nep141:' prefix for
proper price fetching
- Works across all token types: NEAR, wNEAR, BTC, ETH, USDC, etc.

### Areas Affected
- OneClick Exchange form token balance displays
- Payment requests table
- Asset exchange table  
- Dashboard portfolio views (IntentsPortfolio)
- Payment request detail pages
- Asset exchange detail pages
- Insufficient balance modals

### Test Updates
All tests have been updated to match the new formatting behavior:
-  - Updated balance display expectations
-  - Updated funding amount expectations
-  - Validates intelligent formatting behavior
-  - Updated token amount expectations
-  - Updated for new formatting

### Technical Details
- BOS VM compatibility maintained (no ES6 default parameters, no
destructuring with defaults)
- Price fetching optimized to support intelligent formatting
- Backward compatible - existing functionality preserved

## Testing
- ✅ All playwright tests passing
- ✅ Intelligent formatting verified across all components
- ✅ NEAR Intents tokens (BTC, ETH, USDC) display correctly
- ✅ Thousand separators and precision thresholds working as expected

## Screenshots
The formatting follows the rules demonstrated at
https://petersalomonsen.github.io/tokendecimalsdisplay/

Closes #661

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
)

## Summary
- Fixed Bitcoin network name display issue where "Btc" was shown instead
of "Bitcoin"
- Added proper network ID mapping for Web3Icons compatibility
- Made all token and network icons rounded to match deposit modal
styling
- Added icon support for wrapped and variant tokens (WETH, wNEAR, xBTC,
etc.)
- Enhanced test coverage for network name and icon display

<img width="401" height="485" alt="image"
src="https://github.com/user-attachments/assets/1916774b-90c0-402a-9ffb-fbe261c7b8c5"
/>


## Problem
1. The OneClick Exchange form was displaying raw network IDs like "Btc"
instead of human-readable names like "Bitcoin" because the 1Click API
uses `btc:mainnet` while Web3Icons expects `bitcoin` as the network
identifier
2. Many wrapped/variant tokens (WETH, wNEAR, xBTC, cbBTC) were showing
without icons
3. Token and network icons were square instead of rounded like in the
deposit modal

## Solution
1. Added a "btc" alias for the Bitcoin network when Web3Icons loads
2. Added token aliases to reuse existing token icons for wrapped
variants:
   - WETH uses ETH icon
   - wNEAR, GNEAR, NOEAR use NEAR icon
   - xBTC, cbBTC use BTC/WBTC icons
3. Applied `rounded-circle` class to all icons for visual consistency

## Test plan
- [x] Run the Bitcoin network display test: `npx playwright test
--project=treasury-testing
playwright-tests/tests/intents/oneclick-exchange-form.spec.js
--grep="Bitcoin"`
- [x] Test passes successfully verifying:
  - Bitcoin network shows as "Bitcoin" (not "Btc")
  - NEAR shows as "Near Protocol"  
  - Both networks display their correct icons
- [x] Manually tested in the OneClick Exchange form
- [x] Verified rounded icons match deposit modal styling
- [x] Verified wrapped tokens now show appropriate icons

Fixes #700

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
…and NEAR Intents integration (#702)

## Summary
This PR significantly improves the asset exchange feature in the
treasury dashboard by adding comprehensive USD value displays, network
information, proper NEAR Intents support, and fixing critical bugs in
proposal handling and slippage calculations.

See a demo video here: https://youtu.be/GMR8Lz6QvIA?si=19qwZE453FU3hjDR

## Key Changes

### 🎨 Enhanced UI/UX
- **USD Value Display**: All token amounts now show USD values alongside
token amounts throughout the asset exchange interface
- **Network Information**: Added network names and icons for better
cross-chain transaction visibility
- **Source Wallet Indicator**: Clearly distinguishes between NEAR
Intents and SputnikDAO transactions
- **Token Icons**: Integrated Web3Icons for automatic token icon
fetching and display
- **Clickable Explorer Links**: Deposit addresses now link directly to
NEAR Intents explorer for transaction tracking

### 🐛 Bug Fixes
- **Fixed Slippage Calculation (Issue #703)**: Corrected slippage
percentage handling - now properly stores as percentage internally
instead of basis points, fixing the issue where entering 0.1% displayed
as 10%
- **Fixed Proposal Loading**: Resolved blank page issue when viewing
executed NEAR Intents proposals by:
  - Adding proper null checks for policy object
  - Implementing early return when tokenDisplayLib is not loaded
  - Extracting actual token contract ID from mt_transfer args
- **Fixed Token Contract Identification**: NEAR Intents proposals now
correctly identify the token contract from mt_transfer arguments,
stripping "nep141:" prefixes as needed

### 🏗️ Architecture Improvements
- **Centralized Token Display Library**: 
  - Added `init()` method for cleaner state management
  - Consolidated token formatting, USD calculations, and icon management
  - Added support for network display names and icons
  - Integrated 1Click and NEAR Intents token data fetching
- **Improved State Management**: Token icons and network names are now
managed through a centralized handler with proper caching

### 🧪 Testing
- Added comprehensive Playwright test for NEAR Intents asset exchange
proposal details
- Test verifies exact values, USD amounts, network information, and all
proposal metadata
- Uses real on-chain data with mocked price APIs for consistency

## Technical Details

### Files Modified:
- `lib/tokenDisplay.jsx`: Extended with network/icon management and NEAR
Intents support
- `pages/asset-exchange/ProposalDetailsPage.jsx`: Fixed loading issues,
added USD values and network info
- `pages/asset-exchange/OneClickExchangeFormIframe.jsx`: Fixed slippage
percentage handling
- `pages/asset-exchange/Table.jsx`: Added source wallet and network
displays
- Added new test:
`playwright-tests/tests/intents/intents-asset-exchange-detail.spec.js`

## Breaking Changes
None - all changes are backward compatible

## Testing
- [x] Manual testing of asset exchange proposals (both regular and NEAR
Intents)
- [x] Verified slippage percentage calculations
- [x] Confirmed USD value displays are accurate
- [x] Tested proposal loading for executed NEAR Intents transactions
- [x] Playwright test suite passes

## Screenshots/Demo
The PR includes comprehensive test coverage that demonstrates all the
new features working correctly with webassemblymusic-treasury proposal
#30.

<img width="1234" height="653" alt="image"
src="https://github.com/user-attachments/assets/fb2b0107-d2b1-4c5c-8298-4863ce824ec6"
/>

<img width="824" height="660" alt="image"
src="https://github.com/user-attachments/assets/bba18d1e-603c-40f2-b195-73ea339f317a"
/>

<img width="826" height="547" alt="image"
src="https://github.com/user-attachments/assets/d64393b9-5464-452f-a223-92c70e75196a"
/>

## Issues Resolved
- Fixes #703 (Slippage percentage incorrectly multiplied by 100)
- Resolves #639

---------

Co-authored-by: Claude <noreply@anthropic.com>
…pdown balances (#673)

## Summary
This PR refactors the OneClick exchange form to use an iframe
implementation, improving isolation and maintainability. The form now
integrates Web3Icons directly for better performance and adds several UX
improvements.




https://github.com/user-attachments/assets/bfd149d3-9f7a-42ca-9579-83d4e512f508



https://github.com/user-attachments/assets/c4b8eda6-fe1a-42e2-8c7f-15d09e66f3b4


# Screenshots

<img width="576" height="800" alt="02-dark-theme"
src="https://github.com/user-attachments/assets/5fb6df15-6cc4-4f80-bdbb-7e78f52577e6"
/>

<img width="576" height="1116" alt="04-quote-details-expanded"
src="https://github.com/user-attachments/assets/ec387237-feba-47b4-899e-3a6665e91974"
/>

<img width="300" height="350" alt="05-token-icons-in-dropdown"
src="https://github.com/user-attachments/assets/0ce24da0-e53d-463c-9d1b-08006c0a902f"
/>

<img width="576" height="1116" alt="07-quote-with-details-expanded"
src="https://github.com/user-attachments/assets/db54d338-dfb3-4a91-a996-d27eeae62108"
/>


<img width="1280" height="720" alt="07-send-token-dropdown"
src="https://github.com/user-attachments/assets/f7287518-458e-46ee-9443-18cec51e76f5"
/>
<img width="1280" height="720" alt="08-quote-displayed"
src="https://github.com/user-attachments/assets/84b4be62-0327-4bb6-a838-172f6720cd16"
/>
<img width="1280" height="720" alt="09-quote-details-expanded"
src="https://github.com/user-attachments/assets/5438bd93-bef6-4bd9-9b1d-82100708e12a"
/>
<img width="1280" height="720" alt="09-transaction-modal"
src="https://github.com/user-attachments/assets/0c2f2587-7cfa-4c04-8b5e-5c6284d71416"
/>
<img width="1280" height="720" alt="10-pending-requests-page"
src="https://github.com/user-attachments/assets/e989b179-c131-49f1-98f5-3df458d6e436"
/>
<img width="1280" height="720" alt="11-after-approval"
src="https://github.com/user-attachments/assets/3cca7e94-29be-482d-96d2-637002f49146"
/>

<img width="1280" height="720" alt="12-history-tab"
src="https://github.com/user-attachments/assets/f4dcb0fa-7ac8-4605-aee0-8177c279def1"
/>




### Key Changes:
- **Iframe Implementation**: Moved OneClickExchangeForm to iframe-based
architecture for better isolation
- **New Quote Flow**: Added explicit "Get Quote" button that users must
click before seeing quote details and "Create Proposal" button
- **Web3Icons Integration**: Integrated Web3Icons library directly into
iframe for token/network icons and names
- **Token Balance Display**: Shows NEAR Intents balances in dropdown
selections
- **Improved Dropdowns**: Right-aligned dropdowns with search
functionality and visual improvements
- **Form Locking**: Fields are locked after obtaining a quote to prevent
changes
- **Quote Details**: Shows deposit address, minimum received amount, and
expiration time

### Technical Details:
- Removed unnecessary changes to DropDownWithSearchAndManualRequest
component
- Deleted old OneClickExchangeForm.jsx file (non-iframe version)
- Direct backend API calls from iframe without going through parent
component
- Preserves nep141: prefix in token IDs for proper mt_transfer
operations

### User Flow:
1. User selects send token, receive token, and network
2. User enters amount to exchange
3. Preview amount appears in receive field
4. User clicks "Get Quote" button to fetch actual quote from backend
5. Quote details are displayed with all relevant information
6. User clicks "Create Proposal" to submit the exchange request

### Testing:
- All Playwright tests updated for new iframe implementation and quote
flow
- Added deposit address verification in tests
- Tests cover both light and dark themes
- Comprehensive test coverage for search, icons, and form validation

resolves #640

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
…shboard (#694)

## Summary

This PR implements intelligent token decimal display formatting
throughout the treasury dashboard, showing only meaningful precision
based on USD value while removing unnecessary trailing zeros.

## Screenshots

### Dashboard

View of token balances in the NEAR Intents portfolio dashboard widget

<img width="526" height="460" alt="image"
src="https://github.com/user-attachments/assets/0c8ed460-8053-4b99-bbb3-e2a88fb364b0"
/>

### Payment request detail

<img width="297" height="334" alt="image"
src="https://github.com/user-attachments/assets/4b847d2f-af02-4037-a744-6a857d1302cc"
/>

### NEAR Intents asset exchange

<img width="363" height="688" alt="image"
src="https://github.com/user-attachments/assets/02b14306-3cde-4e0a-8f1b-083575a7ff95"
/>

### Asset exchange table

<img width="1073" height="621" alt="image"
src="https://github.com/user-attachments/assets/62192ec5-6d3b-4c05-a485-242eba3afd42"
/>

### Asset exchange details

<img width="467" height="349" alt="image"
src="https://github.com/user-attachments/assets/a6312cc6-041d-42f6-be7c-452dae3531c8"
/>

### Payment request table

<img width="574" height="246" alt="image"
src="https://github.com/user-attachments/assets/5c89cf5e-2d01-426a-94a6-30d57b120e71"
/>

## What's Changed

### Core Implementation
- **New tokenDisplay library** - Implements intelligent formatting with
0.01 USD precision threshold
- **TokenAmount component updates** - Integrated intelligent formatting
that dynamically adjusts decimal precision based on token price
- **TokenAmountAndIcon component** - Added intelligent formatting
support
- **OneClick Exchange form** - Display token balances with appropriate
precision in dropdowns

### Key Features
- Shows only meaningful decimals based on USD value (±0.01 precision
threshold)
- Removes unnecessary trailing zeros from whole numbers (e.g., 100.00 →
100)
- Maintains thousand separators for readability (e.g., 2500 → 2,500)
- Handles NEAR Intents token format by stripping 'nep141:' prefix for
proper price fetching
- Works across all token types: NEAR, wNEAR, BTC, ETH, USDC, etc.

### Areas Affected
- OneClick Exchange form token balance displays
- Payment requests table
- Asset exchange table  
- Dashboard portfolio views (IntentsPortfolio)
- Payment request detail pages
- Asset exchange detail pages
- Insufficient balance modals

### Test Updates
All tests have been updated to match the new formatting behavior:
-  - Updated balance display expectations
-  - Updated funding amount expectations
-  - Validates intelligent formatting behavior
-  - Updated token amount expectations
-  - Updated for new formatting

### Technical Details
- BOS VM compatibility maintained (no ES6 default parameters, no
destructuring with defaults)
- Price fetching optimized to support intelligent formatting
- Backward compatible - existing functionality preserved

## Testing
- ✅ All playwright tests passing
- ✅ Intelligent formatting verified across all components
- ✅ NEAR Intents tokens (BTC, ETH, USDC) display correctly
- ✅ Thousand separators and precision thresholds working as expected

## Screenshots
The formatting follows the rules demonstrated at
https://petersalomonsen.github.io/tokendecimalsdisplay/

Closes #661

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
)

## Summary
- Fixed Bitcoin network name display issue where "Btc" was shown instead
of "Bitcoin"
- Added proper network ID mapping for Web3Icons compatibility
- Made all token and network icons rounded to match deposit modal
styling
- Added icon support for wrapped and variant tokens (WETH, wNEAR, xBTC,
etc.)
- Enhanced test coverage for network name and icon display

<img width="401" height="485" alt="image"
src="https://github.com/user-attachments/assets/1916774b-90c0-402a-9ffb-fbe261c7b8c5"
/>


## Problem
1. The OneClick Exchange form was displaying raw network IDs like "Btc"
instead of human-readable names like "Bitcoin" because the 1Click API
uses `btc:mainnet` while Web3Icons expects `bitcoin` as the network
identifier
2. Many wrapped/variant tokens (WETH, wNEAR, xBTC, cbBTC) were showing
without icons
3. Token and network icons were square instead of rounded like in the
deposit modal

## Solution
1. Added a "btc" alias for the Bitcoin network when Web3Icons loads
2. Added token aliases to reuse existing token icons for wrapped
variants:
   - WETH uses ETH icon
   - wNEAR, GNEAR, NOEAR use NEAR icon
   - xBTC, cbBTC use BTC/WBTC icons
3. Applied `rounded-circle` class to all icons for visual consistency

## Test plan
- [x] Run the Bitcoin network display test: `npx playwright test
--project=treasury-testing
playwright-tests/tests/intents/oneclick-exchange-form.spec.js
--grep="Bitcoin"`
- [x] Test passes successfully verifying:
  - Bitcoin network shows as "Bitcoin" (not "Btc")
  - NEAR shows as "Near Protocol"  
  - Both networks display their correct icons
- [x] Manually tested in the OneClick Exchange form
- [x] Verified rounded icons match deposit modal styling
- [x] Verified wrapped tokens now show appropriate icons

Fixes #700

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
…and NEAR Intents integration (#702)

## Summary
This PR significantly improves the asset exchange feature in the
treasury dashboard by adding comprehensive USD value displays, network
information, proper NEAR Intents support, and fixing critical bugs in
proposal handling and slippage calculations.

See a demo video here: https://youtu.be/GMR8Lz6QvIA?si=19qwZE453FU3hjDR

## Key Changes

### 🎨 Enhanced UI/UX
- **USD Value Display**: All token amounts now show USD values alongside
token amounts throughout the asset exchange interface
- **Network Information**: Added network names and icons for better
cross-chain transaction visibility
- **Source Wallet Indicator**: Clearly distinguishes between NEAR
Intents and SputnikDAO transactions
- **Token Icons**: Integrated Web3Icons for automatic token icon
fetching and display
- **Clickable Explorer Links**: Deposit addresses now link directly to
NEAR Intents explorer for transaction tracking

### 🐛 Bug Fixes
- **Fixed Slippage Calculation (Issue #703)**: Corrected slippage
percentage handling - now properly stores as percentage internally
instead of basis points, fixing the issue where entering 0.1% displayed
as 10%
- **Fixed Proposal Loading**: Resolved blank page issue when viewing
executed NEAR Intents proposals by:
  - Adding proper null checks for policy object
  - Implementing early return when tokenDisplayLib is not loaded
  - Extracting actual token contract ID from mt_transfer args
- **Fixed Token Contract Identification**: NEAR Intents proposals now
correctly identify the token contract from mt_transfer arguments,
stripping "nep141:" prefixes as needed

### 🏗️ Architecture Improvements
- **Centralized Token Display Library**: 
  - Added `init()` method for cleaner state management
  - Consolidated token formatting, USD calculations, and icon management
  - Added support for network display names and icons
  - Integrated 1Click and NEAR Intents token data fetching
- **Improved State Management**: Token icons and network names are now
managed through a centralized handler with proper caching

### 🧪 Testing
- Added comprehensive Playwright test for NEAR Intents asset exchange
proposal details
- Test verifies exact values, USD amounts, network information, and all
proposal metadata
- Uses real on-chain data with mocked price APIs for consistency

## Technical Details

### Files Modified:
- `lib/tokenDisplay.jsx`: Extended with network/icon management and NEAR
Intents support
- `pages/asset-exchange/ProposalDetailsPage.jsx`: Fixed loading issues,
added USD values and network info
- `pages/asset-exchange/OneClickExchangeFormIframe.jsx`: Fixed slippage
percentage handling
- `pages/asset-exchange/Table.jsx`: Added source wallet and network
displays
- Added new test:
`playwright-tests/tests/intents/intents-asset-exchange-detail.spec.js`

## Breaking Changes
None - all changes are backward compatible

## Testing
- [x] Manual testing of asset exchange proposals (both regular and NEAR
Intents)
- [x] Verified slippage percentage calculations
- [x] Confirmed USD value displays are accurate
- [x] Tested proposal loading for executed NEAR Intents transactions
- [x] Playwright test suite passes

## Screenshots/Demo
The PR includes comprehensive test coverage that demonstrates all the
new features working correctly with webassemblymusic-treasury proposal
#30.

<img width="1234" height="653" alt="image"
src="https://github.com/user-attachments/assets/fb2b0107-d2b1-4c5c-8298-4863ce824ec6"
/>

<img width="824" height="660" alt="image"
src="https://github.com/user-attachments/assets/bba18d1e-603c-40f2-b195-73ea339f317a"
/>

<img width="826" height="547" alt="image"
src="https://github.com/user-attachments/assets/d64393b9-5464-452f-a223-92c70e75196a"
/>

## Issues Resolved
- Fixes #703 (Slippage percentage incorrectly multiplied by 100)
- Resolves #639

---------

Co-authored-by: Claude <noreply@anthropic.com>
#704)

- Used our own backend server to get intents tokens and network details
(icons, symbols, price, etc..)
- Some minor css changes
## Summary
Fixes #706 - Corrects the tooltip texts for "Quote expires" and
"Estimated time" fields in the 1Click exchange form, and updates the
time display to show seconds instead of minutes.

<img width="462" height="338" alt="image"
src="https://github.com/user-attachments/assets/bcd98324-d6a0-46c7-a0fa-6bec0825936a"
/>

<img width="449" height="311" alt="image"
src="https://github.com/user-attachments/assets/80a12d62-b5dc-4fe5-b28f-5df5589556d9"
/>

<img width="564" height="156" alt="image"
src="https://github.com/user-attachments/assets/4eefc400-232e-41e2-85dd-4f74ab732a36"
/>

<img width="615" height="254" alt="image"
src="https://github.com/user-attachments/assets/510a695d-f98e-405d-bc51-f2b9fa2e85aa"
/>


## Changes Made
- Added tooltip to **Quote expires** field: "Time when the deposit
address becomes inactive and funds may be lost"
- Added tooltip to **Estimated time** field: "Estimated time for the
swap to be executed after the deposit transaction is confirmed"
- Changed time display from "minutes" to "seconds" to match API response
- Removed misleading fallback value of 10, now shows "N/A" when no
estimate available
- Updated all relevant tests to expect "seconds" instead of "minutes"
- Kept historical proposal test unchanged for backwards compatibility

## Test Results
All affected tests have been updated and are passing:
- ✅ `create-1click-exchange-request.spec.js` 
- ✅ `intents-asset-exchange-detail.spec.js` (kept unchanged for
historical data)
- ✅ `oneclick-exchange-details.spec.js`
- ✅ `vote-on-expired-quote.spec.js`
- ✅ `vote-on-expired-quote-table.spec.js`

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Megha <100185149+Megha-Dev-19@users.noreply.github.com>
## Summary
Fixes #680 by removing voting buttons instead of disabling them when
NEAR Intents asset exchange quotes have expired, making the behavior
consistent with the rest of the system.

<img width="791" height="474" alt="image"
src="https://github.com/user-attachments/assets/81b2331f-b87d-4c9b-82c6-e21ba961e16d"
/>

## Changes
- Modified `VoteActions.jsx` to completely remove voting buttons when
quote is expired
- Added informative message: "Voting is not available due to expired
swap quote"
- Different display for table view (compact message) vs details page
(full message with "Learn more" link)
- Updated tooltip text to explain why voting is disabled

## Test Plan
- [x] Updated `vote-on-expired-quote.spec.js` test to verify buttons are
not visible instead of disabled
- [x] Updated `vote-on-expired-quote-table.spec.js` test for table view
to verify the new message is shown
- [x] All 4 tests passing successfully

## Screenshots
Before: Voting buttons were shown as disabled with reduced opacity
After: Voting buttons are completely removed with an informative message
explaining why

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
Megha-Dev-19 and others added 14 commits September 29, 2025 20:22
- Added intear, hot, near mobile wallet to wallet selector, updated
versions of all packages.
- Removed here wallet.
- For hot wallet, had issues with the exported packages so created our
own [bundle](https://github.com/Megha-Dev-19/hot-sdk-js) to export as
needed by hot-wallet
- I have manually tested signing transactions using meteor, hot, MNW,
near mobile wallet
Link to test: https://testing-near-treasury.near.page/

---------

Co-authored-by: Peter Salomonsen <pjsalomonsen@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Manually tested all wallets by login and signing transactions
[here](https://testing-near-treasury.near.page/?page=payments)

---------

Co-authored-by: Peter Salomonsen <pjsalomonsen@gmail.com>
## Summary

Adds NEAR global contract deployment support to reduce treasury instance
creation costs and enable centralized updates.

Fixes #692

## Key Benefits

🎯 **Cost Reduction**: 2 NEAR savings per instance (7 NEAR vs 9 NEAR)
- Global contract: 0.5 NEAR storage vs 2.5 NEAR for contract bytes
- Projected savings: ~$10-15 per treasury at current NEAR prices

🔄 **Centralized Updates**: All instances automatically use updated
contracts
- No user action required when web4 contract is updated
- Immediate propagation to all existing treasuries
- Demonstrated in test: Update factory → All instances updated

⚡ **Performance**: Same functionality, lower cost
- Backward compatible via separate `create_instance_global_contract`
function
- Original `create_instance` (9 NEAR) unchanged for compatibility

## Implementation

### Contract Changes
- Upgraded near-sdk to 5.17.2 with `global-contracts` feature
- Added `create_instance_global_contract(...)` - 7 NEAR deposit
- Added `deploy_web4_global_contract()` - Deploys to
`env::current_account_id()`
- Uses `deploy_global_contract_by_account_id` for registration

### Testing
- Comprehensive test suite with sandbox 2.8.0
- Verifies 500 mNEAR balance (proves global contract usage)
- Tests global contract update flow
- All 9 tests passing ✅

## Cost Comparison

| Method | Total | Storage | Global Contract |
|--------|-------|---------|----------------|
| `create_instance` | 9 NEAR | 2.5 NEAR | ❌ |
| `create_instance_global_contract` | **7 NEAR** | **0.5 NEAR** | ✅ |
| **Savings** | **2 NEAR** | **2 NEAR** | - |

## Next Steps
- [ ] Update frontend to use `create_instance_global_contract`
- [ ] Call `deploy_web4_global_contract()` on production factory

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude <noreply@anthropic.com>
We want to hide asset exchange from Navbar of BOS treasury, so that we
can launch it on react, as the experience and UX is better.
- Removed the mention of 3N for widget account
- Directly added use of sputnik-dao for creation of treasury
- Updated links to navigate to react version instead of web4
@Megha-Dev-19 Megha-Dev-19 marked this pull request as ready for review November 10, 2025 17:53
@Megha-Dev-19 Megha-Dev-19 merged commit 8fc2ef6 into main Nov 10, 2025
81 of 82 checks passed
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