Skip to content

(WIP)feat: json-rpc 2.0 faucet api #52

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

(WIP)feat: json-rpc 2.0 faucet api #52

wants to merge 4 commits into from

Conversation

alexiscolin
Copy link
Member

@alexiscolin alexiscolin commented Jun 14, 2025

Update Faucet API to JSON-RPC 2.0 Standard

Changes

  • Created new useFaucetApi composable to handle JSON-RPC 2.0 communication and separate API from store
  • Added amount.ts utility for ugnot conversions.
  • Updated faucet requests to follow JSON-RPC 2.0 format
  • Improved error handling for API responses

JSON-RPC 2.0 Format

Folowwing gnolang/gno#4303 requirements, requests now follow the standard format:

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "drip",
  "params": [
    "g1e6gxg5tvc55mwsn7t7dymmlasratv7mkv0rap2",
    "1000ugnot"
  ]
}

Response Handling

  • Text responses are treated as HTTP errors
  • JSON responses are parsed as JSON-RPC 2.0 objects
  • Proper error handling for both HTTP and JSON-RPC errors

Code Organization

  • Separated API communication logic into useFaucetApi composable
  • Created pure utility functions for amount conversions in amount.ts
  • Maintained UI state management in the store

@alexiscolin alexiscolin self-assigned this Jun 14, 2025
Copy link

netlify bot commented Jun 14, 2025

Deploy Preview for gno-faucet-hub ready!

Name Link
🔨 Latest commit 4e0e9ac
🔍 Latest deploy log https://app.netlify.com/projects/gno-faucet-hub/deploys/684e514cd48f700008f3f116
😎 Deploy Preview https://deploy-preview-52--gno-faucet-hub.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@alexiscolin alexiscolin marked this pull request as draft June 14, 2025 06:59
@alexiscolin alexiscolin changed the title (WIP)feat: json-rpc 2.0 faucet API (WIP)feat: json-rpc 2.0 faucet api Jun 14, 2025
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it out locally, works great 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants