Skip to content

Commit

Permalink
Paseo faucet support
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Apr 3, 2024
1 parent 9481bd2 commit fc090ae
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy-site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ jobs:
- run: yarn run build
env:
PUBLIC_CAPTCHA_KEY: 6LesXHomAAAAAGVVTCgc467t8hvBbmK7IlYZCc8O
PUBLIC_FAUCET_URL: https://faucet-api-rococo.liberti.social/drip/web
GITHUB_PAGES: "/${{ github.event.repository.name }}"
STATIC: true
- uses: actions/upload-artifact@v4
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ jobs:
- run: yarn run build
env:
PUBLIC_CAPTCHA_KEY: 6LesXHomAAAAAGVVTCgc467t8hvBbmK7IlYZCc8O
PUBLIC_FAUCET_URL: https://faucet-api-rococo.liberti.social/drip/web
GITHUB_PAGES: "/${{ github.event.repository.name }}"
STATIC: true
- uses: actions/upload-artifact@master
Expand Down
20 changes: 17 additions & 3 deletions client/src/lib/utils/faucetRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,25 @@ export async function faucetRequest(
network: NetworkData,
parachain_id?: string
): Promise<string> {
const body = { address, parachain_id, recaptcha };
const body: Record<string, string> = { address, recaptcha };

const url = network.endpoint;
const chain = network.chains.find((x) => x.id === parseInt(parachain_id || "-1", 10));

if (!chain) {
throw new Error(
`Parachain id:${parachain_id || "-1"} for ${network.networkName} is not defined`
);
}

// Force the parachain_id to be empty if we have a spcific chain endpoint

if (!chain.endpoint && parachain_id) {
body.parachain_id = parachain_id;
}

const url = chain.endpoint || network.endpoint;
if (!url) {
throw new Error(`Endpoint for ${network.networkName} is not defined`);
throw new Error(`Endpoint for ${network.networkName} with ${chain.name} is not defined`);
}
const fetchResult = await fetch(url, {
method: "POST",
Expand Down
12 changes: 10 additions & 2 deletions client/src/lib/utils/networkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { PUBLIC_FAUCET_URL } from "$env/static/public";
export interface ChainData {
name: string;
id: number;
endpoint?: string;
}

function faucetUrl(defaultUrl: string): string {
Expand All @@ -24,8 +25,15 @@ export interface NetworkData {
export const Frequency: NetworkData = {
networkName: "Frequency",
currency: "XRQCY",
chains: [{ name: "Frequency Rococo Testnet", id: -1 }],
endpoint: faucetUrl(PUBLIC_FAUCET_URL),
chains: [
{ name: "Frequency Paseo Testnet", id: -1 },
{
name: "Frequency Rococo Testnet",
id: 4044,
endpoint: "https://faucet-api-rococo.liberti.social/drip/web"
}
],
endpoint: faucetUrl("https://faucet-api-paseo.liberti.social/drip/web"),
explorer: null
};

Expand Down
23 changes: 22 additions & 1 deletion src/networkData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ const frequencyRococo: NetworkData = {
matrixWhitelistPatterns: [],
};

const frequencyPaseo: NetworkData = {
balanceCap: 1000,
chains: [{ name: "Frequency Paseo Testnet", id: -1 }],
currency: "XRQCY",
decimals: 8,
dripAmount: "5000",
explorer: null,
networkName: "Frequency Paseo Testnet",
rpcEndpoint: "wss://0.rpc.testnet.amplica.io",
matrixWhitelistPatterns: [],
};

const westend: NetworkData = {
balanceCap: 100,
chains: [
Expand Down Expand Up @@ -123,7 +135,16 @@ const e2e: NetworkData = {
matrixWhitelistPatterns: parityWhitelist,
};

export const networks: Record<string, NetworkData> = { rococo, versi, westend, e2e, trappist, paseo, frequencyRococo };
export const networks: Record<string, NetworkData> = {
rococo,
versi,
westend,
e2e,
trappist,
paseo,
frequencyRococo,
frequencyPaseo,
};

export function getNetworkData(networkName: string): NetworkData {
if (!Object.keys(networks).includes(networkName)) {
Expand Down

0 comments on commit fc090ae

Please sign in to comment.