This repository has been archived by the owner on Oct 27, 2023. It is now read-only.
forked from 5afe/safe-core-protocol-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tasks to interact with test registry (5afe#14)
- Loading branch information
Showing
11 changed files
with
62 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import "hardhat-deploy"; | ||
import "@nomicfoundation/hardhat-ethers"; | ||
import { task } from "hardhat/config"; | ||
import { getPlugin, getRegistry, getSamplePlugin } from "../utils/contracts"; | ||
import { IntegrationType } from "../utils/constants"; | ||
import { loadPluginMetaData } from "../utils/metadata"; | ||
|
||
task("register-plugin", "Registers the sample Plugin in the Safe{Core} test register") | ||
.setAction(async (_, hre) => { | ||
const registry = await getRegistry(hre) | ||
const plugin = await getSamplePlugin(hre) | ||
await registry.addIntegration(await plugin.getAddress(), IntegrationType.Plugin) | ||
console.log("Registered Plugin registry") | ||
}); | ||
|
||
task("list-plugins", "List available Plugins in the Safe{Core} test register") | ||
.setAction(async (_, hre) => { | ||
const registry = await getRegistry(hre) | ||
const events = await registry.queryFilter(registry.filters.IntegrationAdded) | ||
for (const event of events) { | ||
const plugin = await getPlugin(hre, event.args.integration) | ||
const metaData = await loadPluginMetaData(hre, plugin) | ||
console.log(event.args.integration, metaData) | ||
} | ||
}); | ||
|
||
export { } |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { BaseContract } from "ethers"; | ||
import { BasePlugin, SamplePlugin, TestSafeProtocolRegistryUnrestricted } from "../../typechain-types"; | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import { getProtocolRegistryAddress } from "./protocol"; | ||
|
||
export const getInstance = async <T extends BaseContract>(hre: HardhatRuntimeEnvironment, name: string, address: string): Promise<T> => { | ||
// TODO: this typecasting should be refactored | ||
return (await hre.ethers.getContractAt(name, address)) as unknown as T; | ||
}; | ||
|
||
export const getSingleton = async <T extends BaseContract>(hre: HardhatRuntimeEnvironment, name: string): Promise<T> => { | ||
const deployment = await hre.deployments.get(name); | ||
return getInstance<T>(hre, name, deployment.address); | ||
}; | ||
|
||
export const getPlugin = (hre: HardhatRuntimeEnvironment, address: string) => getInstance<BasePlugin>(hre, "BasePlugin", address); | ||
export const getSamplePlugin = (hre: HardhatRuntimeEnvironment) => getSingleton<SamplePlugin>(hre, "SamplePlugin"); | ||
export const getRegistry = async (hre: HardhatRuntimeEnvironment) => getInstance<TestSafeProtocolRegistryUnrestricted>(hre, "TestSafeProtocolRegistryUnrestricted", await getProtocolRegistryAddress(hre)); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.