Skip to content

Commit

Permalink
Merge pull request #48 from lndgalante/feat/faucets
Browse files Browse the repository at this point in the history
Add getFaucetUrl helper
  • Loading branch information
lndgalante authored Jan 5, 2023
2 parents a51086b + e820684 commit 55e3fc9
Show file tree
Hide file tree
Showing 46 changed files with 9,708 additions and 7,240 deletions.
45 changes: 39 additions & 6 deletions core/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function getAllExplorersUrl(signature: string, cluster: Cluster = 'mainne
return { urls };
}

export type Provider =
export type RpcProvider =
| 'solana'
| 'serum'
| 'genesysgo'
Expand All @@ -106,11 +106,11 @@ export type Provider =
export type Network = 'mainnet' | 'devnet';

export function getRpcEndpointUrl(
provider: Provider,
provider: RpcProvider,
network: Network,
apiKeyOrAccessToken?: string,
): { rpcEndpointUrl: string } {
const endpoints = {
): { rpcUrl: string } {
const rpcUrls = {
localhost: {
mainnet: 'http://localhost:8899',
devnet: 'http://localhost:8899',
Expand Down Expand Up @@ -156,7 +156,40 @@ export function getRpcEndpointUrl(
devnet: `https://solana-api.syndica.io/access-token/${apiKeyOrAccessToken}/rpc`,
},
};
const rpcEndpointUrl = endpoints[provider][network];
const rpcUrl = rpcUrls[provider][network];

return { rpcEndpointUrl };
return { rpcUrl };
}

export type FaucetProvider = 'credix' | 'solfaucet' | 'stakely' | 'togatech' | 'thirdweb' | 'quicknode';

type Faucet = { url: string; maxSolAmount: number; tweetRequired: boolean; captchaRequired: boolean };

export function getFaucetUrl(faucetProvider: FaucetProvider): { faucet: Faucet } {
const faucetsUrls = {
credix: { url: 'https://spl-token-faucet.com', maxSolAmount: 1, tweetRequired: false, captchaRequired: false },
solfaucet: { url: 'https://solfaucet.com', maxSolAmount: 1, tweetRequired: false, captchaRequired: false },
stakely: {
url: 'https://stakely.io/en/faucet/solana-sol',
maxSolAmount: 0.001,
tweetRequired: true,
captchaRequired: true,
},
togatech: { url: 'https://solfaucet.togatech.org', maxSolAmount: 1, tweetRequired: false, captchaRequired: true },
thirdweb: {
url: 'https://thirdweb.com/faucet/solana',
maxSolAmount: 1,
tweetRequired: false,
captchaRequired: false,
},
quicknode: {
url: 'https://faucet.quicknode.com/solana/devnet',
maxSolAmount: 2,
tweetRequired: false,
captchaRequired: false,
},
};
const faucet = faucetsUrls[faucetProvider];

return { faucet };
}
24 changes: 12 additions & 12 deletions docs/examples/hooks/use-is-valid-transaction/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
"lint": "next lint"
},
"dependencies": {
"@lndgalante/solutils": "^0.3.7",
"@lndgalante/solutils": "^0.5.4",
"@solana/spl-token": "^0.3.6",
"@solana/wallet-adapter-react": "^0.15.24",
"@solana/wallet-adapter-react-ui": "^0.9.22",
"@solana/wallet-adapter-wallets": "^0.19.5",
"@solana/web3.js": "^1.66.2",
"next": "13.0.2",
"@solana/wallet-adapter-react": "^0.15.28",
"@solana/wallet-adapter-react-ui": "^0.9.27",
"@solana/wallet-adapter-wallets": "^0.19.10",
"@solana/web3.js": "^1.73.0",
"next": "13.1.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.8",
"eslint": "8.27.0",
"eslint-config-next": "13.0.2",
"typescript": "4.8.4"
"@types/node": "18.11.18",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"eslint": "8.31.0",
"eslint-config-next": "13.1.1",
"typescript": "4.9.4"
}
}
4 changes: 2 additions & 2 deletions docs/examples/hooks/use-is-valid-transaction/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ require('@solana/wallet-adapter-react-ui/styles.css');

// rpc endpoint and wallet
const wallets = [new PhantomWalletAdapter()];
const { rpcEndpointUrl } = getRpcEndpointUrl('serum', 'devnet');
const { rpcUrl } = getRpcEndpointUrl('genesysgo', 'mainnet');

export default function App({ Component, pageProps }: AppProps) {
return (
<ConnectionProvider endpoint={rpcEndpointUrl}>
<ConnectionProvider endpoint={rpcUrl}>
<WalletProvider wallets={wallets} autoConnect>
<WalletModalProvider>
<Component {...pageProps} />
Expand Down
Loading

2 comments on commit 55e3fc9

@vercel
Copy link

@vercel vercel bot commented on 55e3fc9 Jan 5, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

solutils – ./docs/web

solutils-lndgalante.vercel.app
solutils.vercel.app
solutils-git-main-lndgalante.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 55e3fc9 Jan 5, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

solutils-s8bx – ./docs/web

solutils-s8bx-lndgalante.vercel.app
solutils-s8bx-git-main-lndgalante.vercel.app
solutils-s8bx.vercel.app

Please sign in to comment.