Skip to content

Commit

Permalink
Accomodate
Browse files Browse the repository at this point in the history
  • Loading branch information
elffjs committed Oct 5, 2024
1 parent 76e7dcf commit faa6e8c
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions faucet.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!doctype html>

<h1>🚰 $OMID Faucet</h1>
<p>Transfer to: <input type="text" id="transfer_to" style="width: 20em">
<p id="info">
<p><button id="drip">Drip</button>

<script type="module">
Expand All @@ -13,7 +13,7 @@ <h1>🚰 $OMID Faucet</h1>
transport: http()
})

const faucetAddr = "0xD4dBee472ACB5854DfFe69F1DA404D1Bfc403175";
const faucetAddr = "0x1A8fb91b8204596605b312c23E62BD61Fc7c9Eb5";

export const walletClient = createWalletClient({
chain: polygonAmoy,
Expand All @@ -28,13 +28,7 @@ <h1>🚰 $OMID Faucet</h1>
const faucetAbi = [{
"type": "function",
"name": "drip",
"inputs": [
{
"name": "to",
"type": "address",
"internalType": "address"
}
],
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
Expand All @@ -59,21 +53,22 @@ <h1>🚰 $OMID Faucet</h1>
}
];

async function callback() {
const shareTo = document.getElementById("transfer_to").value;

const lastDrip = await publicClient.readContract({
const lastDrip = await publicClient.readContract({
address: faucetAddr,
abi: faucetAbi,
functionName: 'lastDrip',
args: [shareTo],
args: [account],
});

console.log("Last drip", lastDrip);

const now = BigInt(Math.floor(Date.now() / 1000));
const now = BigInt(Math.floor(Date.now() / 1000));

if (now - lastDrip < 86400) {
document.getElementById("info").innerText = `Wait ${lastDrip + 86400 - now} seconds`;
} else {
document.getElementById("info").innerText = `Drip away`;
}

async function callback() {
if (now - lastDrip < 86400) {
alert("Too soon");
return;
Expand All @@ -83,9 +78,7 @@ <h1>🚰 $OMID Faucet</h1>
address: faucetAddr,
abi: faucetAbi,
functionName: 'drip',
args: [
shareTo,
],
args: [],
account
})

Expand Down

0 comments on commit faa6e8c

Please sign in to comment.