Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7fe7e8e
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Thu Aug 25 03:37:55 2022 +0530

    Fixed link bug

commit 63e7261
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Thu Aug 25 02:09:43 2022 +0530

    Test1

commit a09f3a5
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Thu Aug 25 01:32:59 2022 +0530

    Increased gas price and set nonce for token transfers too

commit 42024fc
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 23:53:27 2022 +0530

    Made few changes to embed transaction

commit 659bcb7
Author: Yash <ysolanki069@gmail.com>
Date:   Wed Aug 24 23:16:05 2022 +0530

    embed edit

commit d8e9a31
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 03:45:15 2022 +0530

    Fixed a bug related to nonce limit

commit 38a9fb5
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 03:31:15 2022 +0530

    Made keyv set after confirmation. Added nonce limiter

commit 6c4b60c
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 01:47:58 2022 +0530

    Rate limiting added

commit 6ddc4dd
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 01:37:10 2022 +0530

    Setup Memory DB rate limiting

commit 7daa4e6
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 01:10:29 2022 +0530

    Setup basic keyv for ratelimiting

commit 8761d37
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Wed Aug 24 00:09:34 2022 +0530

    Changed config json and get maxFeeGas from config

commit 14a2d62
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Tue Aug 23 22:44:22 2022 +0530

    Fixed Matic mumbai issue with gas control

commit 57f9ed5
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Tue Aug 23 15:12:17 2022 +0530

    Added error channels

commit 50931ce
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Tue Aug 23 02:57:47 2022 +0530

    Removed defer and added log to show txobj

commit c917fcf
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Tue Aug 23 02:03:11 2022 +0530

    Stripped off unwanted try catches

commit a2b9636
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Mon Aug 22 23:33:04 2022 +0530

    Refactored Code

commit 3c6da78
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Mon Aug 22 20:12:06 2022 +0530

    Working state with transfers

commit 47a42a4
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Mon Aug 22 18:48:17 2022 +0530

    Setup basic erc20 transfers

commit 2f59e68
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Mon Aug 22 17:30:11 2022 +0530

    Implemented try catch for all

commit 6062fa2
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Mon Aug 22 00:44:01 2022 +0530

    Setup basic faucet transfer

commit e7a1109
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 23:41:50 2022 +0530

    Setup Faucet inputs

commit 01bfd0d
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 22:58:06 2022 +0530

    Finished getting balance for setup tokens

commit 6114bf1
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 20:41:36 2022 +0530

    Fix up balance

commit 5dea12d
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 19:51:12 2022 +0530

    Setup getting balance for rinkeby,mumbai and goerli

commit 00d6b47
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 19:44:32 2022 +0530

    Moved to json

commit d082de6
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 16:42:34 2022 +0530

    Worked on getting the balance of goerli

commit 4d83345
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 15:34:47 2022 +0530

    Worked on Feedback

commit 84e42c8
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 02:05:14 2022 +0530

    Removed website command

commit 1421fa9
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 00:22:56 2022 +0530

    Removed unwanted packages and moved to discord.js

commit 4d897b0
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sun Aug 21 00:10:15 2022 +0530

    Checking Webhook discord github

commit bd0ddcb
Author: yanukadeneth99 <yanukadeneth99@gmail.com>
Date:   Sat Aug 20 23:30:42 2022 +0530

    Updated code
  • Loading branch information
yanukadeneth99 committed Aug 24, 2022
1 parent d5fb1c9 commit f96c0c6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
27 changes: 24 additions & 3 deletions responses/faucet_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ module.exports = async (keyv, interaction) => {
);
if (nonceLimit) {
const timeLeft = Math.floor(
(stats.coolDownTime - (Date.now() - nonceLimit)) / 1000
(stats.globalCoolDown - (Date.now() - nonceLimit)) / 1000
);
await interaction.editReply(
`🥶 Please wait for ${timeLeft} seconds before requesting`
);
return;
}
await keyv.set(`${networkName}`, Date.now());

// Rate Limiting for non Admins
const limit = await handleRateLimiting(
Expand All @@ -78,6 +77,8 @@ module.exports = async (keyv, interaction) => {
`😎 Cool people waits for ${timeLeft} seconds`
);
return;
} else {
await keyv.set(`${networkName}`, Date.now());
}

// Transaction
Expand Down Expand Up @@ -114,7 +115,7 @@ module.exports = async (keyv, interaction) => {

// If the balance is too low (curBalance is in a float)
const curBalance = await getBalance(provider, tokenName, networkName);
if (curBalance < stats.dailyEth) {
if (parseFloat(curBalance) < tokens[tokenName].amount) {
await interaction.editReply(
`😥 Insufficient funds, please donate ${tokenName.toUpperCase()} to : ${
stats.walletAddress
Expand All @@ -123,6 +124,24 @@ module.exports = async (keyv, interaction) => {
return;
}

// Rate Limiting for nonce
const nonceLimit = await handleRateLimiting(
keyv,
interaction,
networkName,
stats.globalCoolDown,
true
);
if (nonceLimit) {
const timeLeft = Math.floor(
(stats.globalCoolDown - (Date.now() - nonceLimit)) / 1000
);
await interaction.editReply(
`🥶 Please wait for ${timeLeft} seconds before requesting`
);
return;
}

// Rate Limiting for non Admins
const limit = await handleRateLimiting(
keyv,
Expand All @@ -138,6 +157,8 @@ module.exports = async (keyv, interaction) => {
`😎 Cool people waits for ${timeLeft} seconds`
);
return;
} else {
await keyv.set(`${networkName}`, Date.now());
}

// Transaction
Expand Down
4 changes: 3 additions & 1 deletion utils/getBalance.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ module.exports = async (provider, tokenName, networkName) => {
if (!address) throw Error("Token Address not found!");

const contract = new ethers.Contract(address, erc20ABI, provider);
return (await contract.balanceOf(stats.walletAddress)).toString();
return await ethers.utils.formatEther(
(await contract.balanceOf(stats.walletAddress)).toString()
);
}

//* Native Balance
Expand Down
2 changes: 1 addition & 1 deletion utils/getTxName.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Used in Faucet_response.js to display the transaction hash link

module.exports = (networkName) => {
module.exports = async (networkName) => {
if (networkName == "mumbai") {
return `https://${networkName}.polygonscan.com/tx/`;
}
Expand Down
9 changes: 1 addition & 8 deletions utils/transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ module.exports = async (provider, usrAddress, networkName, tokenName) => {
nonce,
value: ethers.utils.parseEther(stats.dailyEth.toString()),
type: 2,
maxFeePerGas: stats.maxFee,
maxPriorityFeePerGas: stats.maxFee,
gasLimit: "21000",
};
}

Expand All @@ -54,11 +51,7 @@ module.exports = async (provider, usrAddress, networkName, tokenName) => {
// Create Transaction object
return await contract.transfer(
usrAddress,
ethers.utils.parseEther(tokens[tokenName].amount.toString(), decimals),
{
maxFeePerGas: stats.maxFee,
maxPriorityFeePerGas: stats.maxFee,
}
ethers.utils.parseEther(tokens[tokenName].amount.toString(), decimals)
);
}
};

0 comments on commit f96c0c6

Please sign in to comment.