done
This commit is contained in:
commit
33b0c7382f
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
node_modules
|
||||||
|
.env
|
||||||
|
coverage
|
||||||
|
coverage.json
|
||||||
|
typechain
|
||||||
|
typechain-types
|
||||||
|
|
||||||
|
# Hardhat files
|
||||||
|
cache
|
||||||
|
artifacts
|
||||||
|
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Rescue usdt example
|
||||||
|
|
||||||
|
This is hardhad project, install deps and run `npx hardhat test test.js`
|
16
hardhat.config.js
Normal file
16
hardhat.config.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
require("@nomicfoundation/hardhat-toolbox");
|
||||||
|
require("@nomicfoundation/hardhat-ethers")
|
||||||
|
|
||||||
|
/** @type import('hardhat/config').HardhatUserConfig */
|
||||||
|
module.exports = {
|
||||||
|
solidity: "0.8.20",
|
||||||
|
defaultNetwork: "hardhat",
|
||||||
|
networks: {
|
||||||
|
hardhat: {
|
||||||
|
forking: {
|
||||||
|
url: "https://eth.llamarpc.com",
|
||||||
|
blockNumber: 18284193
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
4885
package-lock.json
generated
Normal file
4885
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
Normal file
32
package.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "rescue-tokens-example",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"dependencies": {
|
||||||
|
"hardhat": "^2.17.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@nomicfoundation/hardhat-chai-matchers": "^2.0.2",
|
||||||
|
"@nomicfoundation/hardhat-ethers": "^3.0.4",
|
||||||
|
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
|
||||||
|
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
|
||||||
|
"@nomicfoundation/hardhat-verify": "^1.1.1",
|
||||||
|
"@typechain/ethers-v6": "^0.4.3",
|
||||||
|
"@typechain/hardhat": "^8.0.3",
|
||||||
|
"chai": "^4.3.10",
|
||||||
|
"ethers": "^6.7.1",
|
||||||
|
"hardhat-gas-reporter": "^1.0.9",
|
||||||
|
"solidity-coverage": "^0.8.5",
|
||||||
|
"typechain": "^8.3.1"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "mocha"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.tornado.ws/ButterflyEffect/rescue-tokens-example"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
40
test.js
Normal file
40
test.js
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
const { expect } = require("chai");
|
||||||
|
const TornABI = require("./tornABI.json");
|
||||||
|
const UsdtABI = require('./usdtABI.json')
|
||||||
|
|
||||||
|
describe("Rescue", function(){
|
||||||
|
const governanceAddr = "0x5efda50f22d34F262c29268506C5Fa42cB56A1Ce";
|
||||||
|
const me = "0xeb3E49Af2aB5D5D0f83A9289cF5a34d9e1f6C5b4";
|
||||||
|
const usdtAddr = "0xdAC17F958D2ee523a2206206994597C13D831ec7";
|
||||||
|
const tornAddr = "0x77777FeDdddFfC19Ff86DB637967013e6C6A116C";
|
||||||
|
|
||||||
|
async function getUsdtBalance(address){
|
||||||
|
const usdt = await ethers.getContractAt(UsdtABI, usdtAddr);
|
||||||
|
return usdt.balanceOf(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function rescueUsdt(){
|
||||||
|
const torn = await ethers.getContractAt(TornABI, tornAddr);
|
||||||
|
const governanceSigner = await ethers.getImpersonatedSigner(governanceAddr);
|
||||||
|
const availableBalance = await getUsdtBalance(tornAddr);
|
||||||
|
await torn.connect(governanceSigner).rescueTokens(usdtAddr, me, availableBalance);
|
||||||
|
}
|
||||||
|
|
||||||
|
it("USDT balance on torn address should be more than 1500", async function(){
|
||||||
|
const usdtDecimals = 6;
|
||||||
|
const usdtBalanceOnTornAddr = await getUsdtBalance(tornAddr);
|
||||||
|
expect(Number(usdtBalanceOnTornAddr) / 10 ** usdtDecimals).greaterThan(1500);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("USDT balance on torn address after rescue should be 0", async function(){
|
||||||
|
await rescueUsdt();
|
||||||
|
const usdtBalanceOnTornAddr = await getUsdtBalance(tornAddr);
|
||||||
|
expect(usdtBalanceOnTornAddr).to.eq(0);
|
||||||
|
})
|
||||||
|
|
||||||
|
it("USDT balance of my address after rescue should be more than 1500", async function(){
|
||||||
|
const usdtDecimals = 6;
|
||||||
|
const usdtBalanceOnMyAddr = await getUsdtBalance(me);
|
||||||
|
expect(Number(usdtBalanceOnMyAddr) / 10 ** usdtDecimals).greaterThan(1500);
|
||||||
|
})
|
||||||
|
})
|
1
tornABI.json
Normal file
1
tornABI.json
Normal file
File diff suppressed because one or more lines are too long
1
usdtABI.json
Normal file
1
usdtABI.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user