Skip to content

Commit

Permalink
Feat/client solana support (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericHgorski authored Sep 26, 2024
1 parent 6758310 commit b114667
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/twenty-bees-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/client': patch
---

update client to include solana support via public RPC and show warning when public infrastructure is not overriden
65 changes: 55 additions & 10 deletions packages/client/src/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,21 +303,66 @@ const CELESTIA_CHAIN = {
],
};

/** @deprecated */
const SOLANA_CHAIN = {
chain_name: 'solana',
chain_id: 'solana',
pretty_name: 'Solana',
network_type: 'mainnet',
website: 'https://solana.com',
bech32_prefix: '',
daemon_name: '', // Not applicable for Solana
node_home: '', // Not applicable for Solana
codebase: {
git_repo: 'https://github.com/solana-labs/solana',
},
logo_URIs: {
png: 'https://raw.githubusercontent.com/cosmostation/chainlist/main/chain/solana/asset/sol.png',
},
apis: {
rpc: [
{
address: 'https://api.mainnet-beta.solana.com',
provider: 'Solana Foundation',
},
{
address: 'https://mainnet.helius-rpc.com/?api-key=6cadbc95-3333-488f-a187-21ffd0c5fef3',
provider: 'Helius',
},
],
},
explorers: [
{
kind: 'blockchain',
url: 'https://explorer.solana.com',
tx_page: 'https://explorer.solana.com/tx/${txHash}',
account_page: 'https://explorer.solana.com/address/${accountAddress}',
},
{
kind: 'Solscan',
url: 'https://solscan.io',
tx_page: 'https://solscan.io/tx/${txHash}',
account_page: 'https://solscan.io/account/${accountAddress}',
},
],
images: [
{
png: 'https://raw.githubusercontent.com/cosmostation/chainlist/main/chain/solana/asset/sol.png',
},
],
};

export function chains(): Chain[] {
const chains = chainRegistry.chains;
const registryChains = chainRegistry.chains;
const additionalChains = [DYDX_CHAIN, CELESTIA_CHAIN, SOLANA_CHAIN] as Chain[];

if (chains.findIndex((chain) => chain.chain_id === 'dydx-mainnet-1') === -1) {
chains.push(DYDX_CHAIN);
}
const existingChainIds = new Set(registryChains.map((chain) => chain.chain_id));

if (chains.findIndex((chain) => chain.chain_id === 'celestia') === -1) {
chains.push(CELESTIA_CHAIN);
}
const newChains = additionalChains.filter(
(chain) => !existingChainIds.has(chain.chain_id)
);

return chains;
return [...registryChains, ...newChains];
}

export function initiaChains(): Chain[] {
const chains = initiaRegistry.chains as Chain[];

Expand Down
2 changes: 2 additions & 0 deletions packages/client/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,8 @@ export class SkipClient {
}
}

console.warn('Warning: You are using unreliable public endpoints. We strongly reccomend overriding them via endpointOptions for use beyond development settings.');

let chain;
chain = chains().find((chain) => chain.chain_id === chainID);
if (!chain) {
Expand Down

0 comments on commit b114667

Please sign in to comment.