Skip to content

Commit

Permalink
Merge pull request #30 from ava-labs/development
Browse files Browse the repository at this point in the history
1.1.3
  • Loading branch information
rajranjan0608 authored Jun 24, 2022
2 parents ee24652 + a0a028c commit 7175576
Show file tree
Hide file tree
Showing 21 changed files with 32 additions and 18 deletions.
Binary file removed client/public/avaxblack.png
Binary file not shown.
Binary file added client/public/avaxblack.webp
Binary file not shown.
Binary file removed client/public/avaxred.png
Binary file not shown.
Binary file added client/public/avaxred.webp
Binary file not shown.
Binary file removed client/public/banner.png
Binary file not shown.
Binary file added client/public/banner.webp
Binary file not shown.
Binary file removed client/public/github.png
Binary file not shown.
Binary file added client/public/github.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en" style="width: 100%; height: 100%;">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/avaxblack.png" />
<link rel="icon" href="%PUBLIC_URL%/avaxblack.webp" />
<meta name="viewport" content="width=device-width, initial-scale=1" />


Expand Down
Binary file removed client/public/memtamask.png
Binary file not shown.
Binary file added client/public/memtamask.webp
Binary file not shown.
Binary file removed client/public/wagmi.png
Binary file not shown.
Binary file added client/public/wagmi.webp
Binary file not shown.
4 changes: 2 additions & 2 deletions client/src/components/AddNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export default function AddNetwork(props: any) {
return (
<div className='footer-buttons'>
<button className="add-network" onClick={() => {addNetwork(props.config)}}>
<img alt='metamask' style={{width: "25px", height: "25px", marginRight: "5px"}} src="/memtamask.png"/>
<img alt='metamask' style={{width: "25px", height: "25px", marginRight: "5px"}} src="/memtamask.webp"/>
Add Subnet to Metamask
</button>

<button className="add-network" onClick={() => {window.open(`${props.config.EXPLORER}`, '_blank')}}>
<img alt="block-explorer" style={{width: "25px", height: "25px"}} src="/avaxblack.png"/>
<img alt="block-explorer" style={{width: "25px", height: "25px"}} src="/avaxblack.webp"/>
View Block Explorer
</button>

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Contribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const Contribute = () => {
window.open('https://github.com/ava-labs/avalanche-faucet', '_blank')
}
}>
<img alt='github' src="/github.png"/>
<img alt='github' src="/github.webp"/>
Contribute on Github
</div>
)
Expand Down
20 changes: 10 additions & 10 deletions client/src/components/FaucetForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const FaucetForm = (props: any) => {
const [chain, setChain] = useState<number | null>(null)
const [token, setToken] = useState<number | null>(null)
const [widgetID, setwidgetID] = useState<string | undefined>(undefined)
const [recaptcha, setRecaptcha] = useState<ReCaptcha | undefined>(undefined)
const [isV2, setIsV2] = useState<boolean>(false)
const [chainConfigs, setChainConfigs] = useState<any>([])
const [inputAddress, setInputAddress] = useState<string>("")
Expand All @@ -30,16 +31,15 @@ const FaucetForm = (props: any) => {
message: null
})

const recaptcha: ReCaptcha = new ReCaptcha(
props.config.SITE_KEY,
props.config.ACTION,
props.config.V2_SITE_KEY,
setwidgetID,
widgetID
)

// Update chain configs
useEffect(() => {
setRecaptcha(new ReCaptcha(
props.config.SITE_KEY,
props.config.ACTION,
props.config.V2_SITE_KEY,
setwidgetID,
widgetID
))
updateChainConfigs()
}, [])

Expand Down Expand Up @@ -259,7 +259,7 @@ const FaucetForm = (props: any) => {
}

async function getCaptchaToken(): Promise<{token?:string, v2Token?: string}> {
const { token, v2Token } = await recaptcha.getToken(isV2)
const { token, v2Token } = await recaptcha!.getToken(isV2)
return { token, v2Token }
}

Expand Down Expand Up @@ -423,7 +423,7 @@ const FaucetForm = (props: any) => {

const resetRecaptcha = (): void => {
setIsV2(false)
recaptcha.resetV2Captcha()
recaptcha!.resetV2Captcha()
}

const back = (): void => {
Expand Down
2 changes: 1 addition & 1 deletion client/src/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"banner": "/banner.png",
"banner": "/banner.webp",
"apiBaseEndpointProduction": "/api/",
"apiBaseEndpointDevelopment": "http://localhost:8000/api/",
"apiTimeout": 10000,
Expand Down
3 changes: 2 additions & 1 deletion middlewares/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './rateLimiter'
export * from './verifyCaptcha'
export * from './verifyTOTP'
export * from './verifyTOTP'
export * from './parseURI'
12 changes: 12 additions & 0 deletions middlewares/parseURI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const parseURI = (req: any, res: any, next: any) => {
var err = null;
try {
decodeURIComponent(req.path)
} catch(e) {
err = e
}
if(err) {
return res.redirect('/')
}
next();
}
2 changes: 1 addition & 1 deletion middlewares/rateLimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class RateLimiter {
keyGenerator: (req, res) => {
const ip = this.getIP(req)
if(ip != null) {
return ip + req.body?.chain
return ip
}
}
})
Expand Down
3 changes: 2 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path'
import dotenv from 'dotenv'
import { BN } from 'avalanche'

import { RateLimiter, VerifyCaptcha } from './middlewares'
import { RateLimiter, VerifyCaptcha, parseURI } from './middlewares'
import EVM from './vms/evm'

import {
Expand All @@ -28,6 +28,7 @@ const router: any = express.Router()

app.use(express.static(path.join(__dirname, "client")))
app.use(cors())
app.use(parseURI)
app.use(bodyParser.json())

new RateLimiter(app, [GLOBAL_RL])
Expand Down

0 comments on commit 7175576

Please sign in to comment.