Skip to content
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

feat: StablePay Implementation #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Tanya-ruby
Copy link
Contributor

@Tanya-ruby Tanya-ruby commented Nov 9, 2024

πŸš€ StablePay SDK Implementation

🎯 Overview

This PR introduces a comprehensive StablePay SDK implementation with React components, network support, and wallet integration capabilities.

✨ Key Features

  • 🎨 Custom styling system - modular CSS
  • πŸ”„ React Context providers - network and wallet management
  • πŸ“¦ Rollup configuration - optimal bundling
  • πŸ’» Widget-based implementation - React
  • πŸ”— Integration - viem and web3.js

πŸ“ File Structure

stablepay-sdk/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   └── NetworkSelector.jsx
β”‚   β”œβ”€β”€ contexts/
β”‚   β”‚   β”œβ”€β”€ NetworkContext.jsx
β”‚   β”‚   └── WalletContext.jsx
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   β”œβ”€β”€ MerchantConfig.js
β”‚   β”‚   β”œβ”€β”€ NetworkSelector.js
β”‚   β”‚   β”œβ”€β”€ TokenSelector.js
β”‚   β”‚   └── Transaction.js
β”‚   β”œβ”€β”€ styles/
β”‚   β”œβ”€β”€ utils/
β”‚   └── widget/
β”‚       β”œβ”€β”€ Dialog.jsx
β”‚       β”œβ”€β”€ NetworkDropdown.jsx
β”‚       β”œβ”€β”€ PayButton.jsx
β”‚       β”œβ”€β”€ TokenDropdown.jsx
β”‚       β”œβ”€β”€ TransactionReview.jsx
β”‚       └── Widget.jsx

πŸ’» Widget Components

  • Widget.jsx - Main container component
  • Dialog.jsx - Modal component for interactions
  • NetworkDropdown.jsx - Network selector component
  • PayButton.jsx - Primary payment trigger
  • TokenDropdown.jsx - Token selection interface
  • TransactionReview.jsx - Transaction confirmation flow

βš™οΈ Core Logic

  • MerchantConfig.js - Merchant configuration handling
  • NetworkSelector.js - Network selection logic
  • TokenSelector.js - Token selection management
  • Transaction.js - Transaction processing

πŸ“¦ Dependencies

  • viem - Ethereum interaction library
  • web3.js - Web3 functionality
  • react - widget creation dependency

✏️ Next Steps

  • Modify buy function from djed-sdk:
  • Implement transaction confirmation flow
  • Add transaction hash return functionality
  • Add additional network support

πŸŽ₯ Demo

final-vid.mov

Features demonstrated:

  • *Network switching *
  • Token selection and validation
  • Transaction flow with confirmation
  • Error handling scenarios
  • Responsive design adaptability

πŸ§ͺ Testing

  • Core components tested locally
  • Transaction flow verified on test networks
  • Mobile responsiveness verified

πŸ“‹ Checklist

  • Code follows the style guidelines
  • Changes have been tested locally
  • No breaking changes introduced

πŸ” Additional Notes

The implementation focuses on maintainability and extensibility. Future network additions can be easily integrated through the network context system.


Note

Please ensure you have the latest dependencies installed before testing(example directory will have the vite/react test file) :

npm install

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.

1 participant