Skip to content

Commit

Permalink
feat: movement testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPrimata committed Oct 11, 2024
1 parent 99455b2 commit 1ee8761
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
6 changes: 3 additions & 3 deletions api/rate-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function createAssessment(

export default async function handler(request: any, response: any) {
// You could alternatively limit based on user ID or similar
const {token, address} = request.body;
const {token, address, network} = request.body;
const secretKey = process.env.RECAPTCHA_SECRET_KEY;
const verificationUrl = `https://www.google.com/recaptcha/api/siteverify?secret=${secretKey}&response=${token}`;

Expand Down Expand Up @@ -134,8 +134,8 @@ export default async function handler(request: any, response: any) {
const aptos = new Aptos(
new AptosConfig({
network: Network.TESTNET,
fullnode: "https://aptos.testnet.suzuka.movementlabs.xyz/v1",
faucet: "https://faucet.testnet.suzuka.movementlabs.xyz",
fullnode: network == "movement" ? "https://testnet.movementnetwork.xyz/v1" : "https://aptos.testnet.suzuka.movementlabs.xyz/v1",
faucet: network == "movement" ? "https://faucet.testnet.movementnetwork.xyz" : "https://faucet.testnet.suzuka.movementlabs.xyz",
faucetConfig: {HEADERS: HEADERS},
}),
);
Expand Down
4 changes: 2 additions & 2 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ export async function requestFaucet(
}
}

export async function aptosRequestFaucet(address : string, captchaValue: string) {
export async function aptosRequestFaucet(address : string, captchaValue: string, network: string) {
try {
const response = await fetch('/api/rate-limit', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ token: captchaValue, address: address }),
body: JSON.stringify({ token: captchaValue, address: address, network: network }),
});
// Check if the response is an HTML page
const contentType = response.headers.get('content-type');
Expand Down
2 changes: 1 addition & 1 deletion src/components/Chain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function Chains({
setErrorMessage("Please complete the captcha.");
} else {
let status = false;
const res = await faucetRequest(address, token);
const res = await faucetRequest(address, token, name);
console.log(res);
if (res.error) {
try {
Expand Down
17 changes: 12 additions & 5 deletions src/pages/LandingPage/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const aptosFaucetAddress = '0x275f508689de8756169d1ee02d889c777de1cebda3a7bbcce6
const PACKAGE_ID = "0x8ac626e474c33520a815175649fefcbb272678c8c37a7b024e7171fa45d47711";

const CHAIN = {
movement: {network: 'testnet', url: 'https://testnet.movementnetwork.xyz', faucetUrl: 'https://faucet.testnet.movementnetwork.xyz', language: 'aptos'},
aptos: { network: 'testnet', url: 'https://aptos.testnet.suzuka.movementlabs.xyz/v1', faucetUrl: 'https://faucet.testnet.suzuka.movementlabs.xyz', language: 'aptos' },
m1: { network: 'devnet', url: 'https://aptos.devnet.m1.movementlabs.xyz', language: 'aptos' },
mevmM1: { network: 'devnet', url: 'https://mevm.devnet.m1.movementlabs.xyz', language: 'evm' },
Expand Down Expand Up @@ -184,23 +185,24 @@ export default function LandingPage() {
setToken(e.target.value);
};

const aptosFaucetRequest = async (address: string, token: string) => {
const aptosFaucetRequest = async (address: string, token: string, network: string) => {
return aptosRequestFaucet(
address,
token
token,
network
);
};


const suiFaucetRequest = async (address: string, token: string) => {
const suiFaucetRequest = async (address: string, token: string, network: string) => {
return suiRequestFaucet(
CHAIN.sui.url,
address,
token
token,
)
};

const handleM1evmFaucetRequest = async (address: string, token: string) => {
const handleM1evmFaucetRequest = async (address: string, token: string, network: string) => {
return mevmRequestFaucet(
CHAIN.mevm.url,
address,
Expand Down Expand Up @@ -248,6 +250,7 @@ export default function LandingPage() {
<div style={{ width: "300px" }}>
<h1 style={{ textAlign: "left" }}>Faucets</h1>
</div>
<Chain name="movement" eventName="movement_apt_request" language={CHAIN.movement.language} amount={10} isEvm={false} network={network} faucetRequest={aptosFaucetRequest} />
<Chain name="aptos" eventName="movement_apt_request" language={CHAIN.aptos.language} amount={10} isEvm={false} network={network} faucetRequest={aptosFaucetRequest} />
<Chain name="MEVM" eventName="m1_evm_request" language={CHAIN.mevm.language} amount={1} isEvm={true} network={network} faucetRequest={handleM1evmFaucetRequest} />
<Chain name="Sui" eventName="sui_sui_request" language={CHAIN.sui.language} amount={1} isEvm={false} network={network} faucetRequest={suiFaucetRequest} />
Expand All @@ -259,6 +262,10 @@ export default function LandingPage() {
value={network}
exclusive
onChange={handleNetwork}>
<ToggleButton
value="movement">
<h3 style={style}>{"{Movement}"}</h3>
</ToggleButton>
<ToggleButton
value="aptos">
<h3 style={style}>{"{Aptos Move}"}</h3>
Expand Down

0 comments on commit 1ee8761

Please sign in to comment.