-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathinformation.ts
44 lines (40 loc) · 2 KB
/
information.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { task, types } from "hardhat/config";
import { HardhatRuntimeEnvironment as HRE } from "hardhat/types";
import { getAddress } from "@ethersproject/address";
import { AddressOne } from "@gnosis.pm/safe-contracts";
import { Contract } from "@ethersproject/contracts";
import { compatHandler, contractFactory, safeSingleton } from "./contracts";
export const getSingletonAddress = async (hre: HRE, address: string): Promise<string> => {
const result = await hre.ethers.provider.getStorageAt(address, 0)
return getAddress("0x" + result.slice(26))
}
export const getFallbackHandlerAddress = async (hre: HRE, address: string): Promise<string> => {
const result = await hre.ethers.provider.getStorageAt(address, "0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5")
return getAddress("0x" + result.slice(26))
}
const getModules = async (hre: HRE, safe: Contract): Promise<string[]> => {
try {
return (await safe.getModulesPaginated(AddressOne, 10))[0]
} catch (e) {
}
try {
const compat = await compatHandler(hre, safe.address)
return await compat.getModules()
} catch (e) {
}
return ["Could not load modules"]
}
task("info", "Displays information about a Safe")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.setAction(async (taskArgs, hre) => {
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Checking Safe at ${safeAddress}`)
console.log(`Singleton: ${await getSingletonAddress(hre, safeAddress)}`)
console.log(`Version: ${await safe.VERSION()}`)
console.log(`Owners: ${await safe.getOwners()}`)
console.log(`Threshold: ${await safe.getThreshold()}`)
console.log(`Nonce: ${await safe.nonce()}`)
console.log(`Fallback Handler: ${await getFallbackHandlerAddress(hre, safeAddress)}`)
console.log(`Modules: ${await getModules(hre, safe)}`)
});