-
Notifications
You must be signed in to change notification settings - Fork 45
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
Add cluster API #65
base: master
Are you sure you want to change the base?
Add cluster API #65
Conversation
import type { IdentifierString } from '@wallet-standard/base'; | ||
|
||
/** Sonic Mainnet (beta) cluster, e.g. https://api.mainnet-beta.sonic.com */ | ||
export const SONIC_MAINNET_CHAIN = 'sonic:mainnet'; | ||
|
||
/** Sonic Devnet cluster, e.g. https://api.devnet.sonic.com */ | ||
export const SONIC_DEVNET_CHAIN = 'sonic:devnet'; | ||
|
||
/** Sonic Testnet cluster, e.g. https://api.testnet.sonic.com */ | ||
export const SONIC_TESTNET_CHAIN = 'sonic:testnet'; | ||
|
||
/** Sonic Localnet cluster, e.g. http://localhost:8899 */ | ||
export const SONIC_LOCALNET_CHAIN = 'sonic:localnet'; | ||
|
||
/** Array of all Sonic clusters */ | ||
export const SONIC_CHAINS = [ | ||
SONIC_MAINNET_CHAIN, | ||
SONIC_DEVNET_CHAIN, | ||
SONIC_TESTNET_CHAIN, | ||
SONIC_LOCALNET_CHAIN, | ||
] as const; | ||
|
||
/** Type of all Sonic clusters */ | ||
export type SonicChain = (typeof SONIC_CHAINS)[number]; | ||
|
||
/** | ||
* Check if a chain corresponds with one of the Sonic clusters. | ||
*/ | ||
export function isSonicChain(chain: IdentifierString): chain is SonicChain { | ||
return SONIC_CHAINS.includes(chain as SonicChain); | ||
} |
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.
The data should be stored in a json file IMO.
packages/core/data/chains.json
identifier: {network}:{environment}:{endpoint}
[
{
"name": "sonic",
"environments": [
{
"name": "devnet",
"proofOfHistorySha": "abac...cerr3",
"endpoints": [
{
"name": "sonic foundation",
"url": "https://api.devnet.sonic.com"
}
]
}
]
}
]
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.
I am fine with that solution.
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.
Should maybe be flatter where network is combined with environment but I can imagine wallets wanting to let users drill down to an rpc endpoint.
We try to avoid specifying behavior that wallets don't generally support. Are you aware of wallets with a public API for changing chains? |
We recently (Nightly) added out of standard api for SVM networks
you can use it |
This PR adds ability to synchronize wallet cluster via get/set API.
Why ?
New networks like Sonic and Eclipse leverage SVM, but current wallet standard API does not have a way for requesting cluster context change on the end of wallet. Synchronizing dapp cluster with wallet cluster improves both developer and user experience and makes usage of methods like
signAndSendTransaction
more robust.This PR also includes sonic chains names file.
Once I get the initial ACK, I will adjust rest of packages to support the new cluster API.