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.
Use safe-core-protocol package (5afe#12)
* Use safe-core-protocol package * Update protocol dependency * Update Sample Plugin
- Loading branch information
Showing
12 changed files
with
78 additions
and
221 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
node_modules | ||
build | ||
.env | ||
coverage | ||
coverage.json | ||
|
This file was deleted.
Oops, something went wrong.
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.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
6 changes: 5 additions & 1 deletion
6
contracts/deploy/deploy_plugin.ts → contracts/src/deploy/deploy_plugin.ts
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,41 @@ | ||
import { HardhatRuntimeEnvironment } from "hardhat/types"; | ||
import protocolDeployments from "@safe-global/safe-core-protocol" | ||
import { id } from "ethers"; | ||
|
||
const deployMock = async(hre: HardhatRuntimeEnvironment, name: string): Promise<string> => { | ||
const { deployments, getNamedAccounts } = hre; | ||
const { deployer } = await getNamedAccounts(); | ||
const { deploy } = deployments; | ||
|
||
const result = await deploy("MockContract", { | ||
from: deployer, | ||
args: [], | ||
log: true, | ||
deterministicDeployment: id(name), | ||
}); | ||
return result.address | ||
} | ||
|
||
export const getProtocolManagerAddress = async(hre: HardhatRuntimeEnvironment): Promise<string> => { | ||
const chainId = await hre.getChainId() | ||
|
||
// For the tests we deploy a mock for the manager | ||
if (chainId === "31337") return deployMock(hre, "ManagerMock") | ||
|
||
if (!(chainId in protocolDeployments)) throw Error("Unsupported Chain") | ||
const manager = (protocolDeployments as any)[chainId][0].contracts.SafeProtocolManager.address | ||
if (typeof manager !== "string") throw Error("Unexpected Manager") | ||
return manager | ||
} | ||
|
||
export const getProtocolRegistryAddress = async(hre: HardhatRuntimeEnvironment): Promise<string> => { | ||
const chainId = await hre.getChainId() | ||
|
||
// For the tests we deploy a mock for the registry | ||
if (chainId === "31337") return deployMock(hre, "RegistryMock") | ||
|
||
if (!(chainId in protocolDeployments)) throw Error("Unsupported Chain") | ||
const registry = (protocolDeployments as any)[chainId][0].contracts.SafeProtocolRegistry.address | ||
if (typeof registry !== "string") throw Error("Unexpected Registry") | ||
return registry | ||
} |
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