Skip to content
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

Frequency Testnet Paseo support #15

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Author

Choose a reason for hiding this comment

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

This is the hack to make sure the fontend calls the correct backend

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