Skip to content

Update faucet alerts #2041

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
108 changes: 67 additions & 41 deletions src/components/Faucet/Alerts.tsx
Original file line number Diff line number Diff line change
@@ -1,140 +1,166 @@
import React from "react";
import { AlertTitle, AlertText } from "@site/src/components/Alert";
import { trackClickForSegment } from "@site/src/lib/segmentAnalytics";
import React from 'react'
import { AlertTitle, AlertText } from '@site/src/components/Alert'
import { trackClickForSegment } from '@site/src/lib/segmentAnalytics'

const handleClickCommonIssue = () => {
trackClickForSegment({
eventName: "Contact us",
eventName: 'Contact us',
clickType: `Common Issue Alert`,
userExperience: "B",
userExperience: 'B',
responseStatus: null,
responseMsg: null,
timestamp: Date.now(),
});
};
})
}

const handleClickBalanceLow = () => {
trackClickForSegment({
eventName: "Add funds using MetaMask",
eventName: 'Add funds using MetaMask',
clickType: `Low Balance Alert`,
userExperience: "B",
userExperience: 'B',
responseStatus: null,
responseMsg: null,
timestamp: Date.now(),
});
};
})
}

const handleClickCooldown = () => {
trackClickForSegment({
eventName: "Contact us",
eventName: 'Contact us',
clickType: `Cooldown Alert`,
userExperience: "B",
userExperience: 'B',
responseStatus: null,
responseMsg: null,
timestamp: Date.now(),
});
};
})
}

const handleClickPoh = () => {
trackClickForSegment({
eventName: 'PoH',
clickType: `PoH Alert`,
userExperience: 'B',
responseStatus: null,
responseMsg: null,
timestamp: Date.now(),
})
}

const handleClickViewTransaction = () => {
trackClickForSegment({
eventName: "View on Etherscan",
eventName: 'View on Etherscan',
clickType: `Success Alert`,
userExperience: "B",
userExperience: 'B',
responseStatus: null,
responseMsg: null,
timestamp: Date.now(),
});
};
})
}

export const AlertCommonIssue = () => (
<div>
<AlertTitle>Issue starting transaction</AlertTitle>
<AlertText>
<span>
There was an issue starting your transaction. Try again in a few
minutes. If the problem persists please{" "}
There was an issue starting your transaction. Try again in a few minutes. If the problem
persists please{' '}
<a
data-testid="alert-common-contact-us"
onClick={handleClickCommonIssue}
target="_blank"
href="https://support.metamask.io/"
>
href="https://support.metamask.io/">
contact support
</a>
.
</span>
</AlertText>
</div>
);
)

export const AlertFailedPoh = () => (
<div>
<AlertTitle>You haven't completed Linea Proof of Humanity</AlertTitle>
<AlertText>
<span>
The address provided has not completed Linea Proof of Humanity. Please visit{' '}
<a
data-testid="alert-poh"
onClick={handleClickPoh}
target="_blank"
href="https://poh.linea.build/">
poh.linea.build
</a>
.
</span>
</AlertText>
</div>
)

export const AlertPastActivity = () => (
<div>
<AlertTitle>No past activity</AlertTitle>
<AlertText>
The address provided does not have sufficient historical activity or balance on the Ethereum Mainnet. Please use a
different address to proceed. Read the FAQ below for more information.
The address provided does not have sufficient historical activity or balance on the Ethereum
Mainnet. Please use a different address to proceed. Read the FAQ below for more information.
</AlertText>
</div>
);
)

export const AlertBalanceTooLow = () => (
<div>
<AlertTitle>Balance too low</AlertTitle>
<AlertText>
<span>
Your current Ethereum address does not contain enough ETH on
Ethereum Mainnet. You can add funds to your address using{" "}
Your current Ethereum address does not contain enough ETH on Ethereum Mainnet. You can add
funds to your address using{' '}
<a
data-testid="alert-balance-add-funds"
onClick={handleClickBalanceLow}
className="underline"
href="https://metamask.io/buy-crypto/"
>
href="https://metamask.io/buy-crypto/">
MetaMask
</a>
.
</span>
</AlertText>
</div>
);
)

export const AlertCooldown = () => (
<div>
<AlertTitle>Cooldown period</AlertTitle>
<AlertText>
<span>
You already got ETH from the faucet today. Try again in 24 hours.{" "}
You already got ETH from the faucet today. Try again in 24 hours.{' '}
<a
data-testid="alert-cooldown-contact-us"
onClick={handleClickCooldown}
target="_blank"
href="https://support.metamask.io/"
>
href="https://support.metamask.io/">
Contact us
</a>
.
</span>
</AlertText>
</div>
);
)

export const AlertSuccess = ({ url }: { url: string }) => (
<div>
<AlertTitle>Transaction successful!</AlertTitle>
<AlertText>
<span>
Your transaction has been sent to the Ethereum/Sepolia network. You
will receive your ETH shortly.{" "}
Your transaction has been sent to the Ethereum/Sepolia network. You will receive your ETH
shortly.{' '}
<a
data-testid="alert-success-etherscan"
onClick={handleClickViewTransaction}
target="_blank"
href={url}
>
href={url}>
View on Etherscan
</a>
.
</span>
</AlertText>
</div>
);
)
8 changes: 7 additions & 1 deletion src/components/Faucet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export { default as Faq } from './Faq'
export { default as TransactionTable } from './TransactionTable'
export { default as Hero } from './Hero'
export { AlertCommonIssue, AlertPastActivity, AlertCooldown, AlertSuccess } from './Alerts'
export {
AlertCommonIssue,
AlertPastActivity,
AlertCooldown,
AlertSuccess,
AlertFailedPoh,
} from './Alerts'
5 changes: 4 additions & 1 deletion src/pages/developer-tools/faucet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
TransactionTable,
Hero,
AlertPastActivity,
AlertFailedPoh,
} from '@site/src/components/Faucet'
import { useAlert } from 'react-alert'
import { MetamaskProviderContext } from '@site/src/theme/Root'
Expand Down Expand Up @@ -85,7 +86,9 @@ export default function Faucet() {
const error = faucetResponse.error

if (error) {
if (error.code === 'balance_too_low') {
if (error.code === 'failed_poh') {
alert.error(<AlertFailedPoh />)
} else if (error.code === 'balance_too_low') {
alert.error(<AlertBalanceTooLow />)
} else if (error.code === 'transaction_count_too_low') {
alert.error(<AlertPastActivity />)
Expand Down
Loading