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.
Browse files
Browse the repository at this point in the history
…5afe#18) * Closes 5afe#3: Trigger Safe transaction to enable protocol and module * Add docs for the plugin commands
- Loading branch information
Showing
8 changed files
with
189 additions
and
15 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
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,32 @@ | ||
import { ethers } from "ethers" | ||
import { getProvider } from "./web3"; | ||
import { BaseTransaction } from '@safe-global/safe-apps-sdk'; | ||
|
||
const SAFE_ABI = [ | ||
"function isModuleEnabled(address module) public view returns (bool)", | ||
"function enableModule(address module) public" | ||
] | ||
|
||
// TODO: use safe-core-sdk here | ||
const getSafe = async(address: string) => { | ||
const provider = await getProvider() | ||
return new ethers.Contract( | ||
address, | ||
SAFE_ABI, | ||
provider | ||
) | ||
} | ||
|
||
export const isModuleEnabled = async(safeAddress: string, module: string): Promise<boolean> => { | ||
const safe = await getSafe(safeAddress) | ||
return await safe.isModuleEnabled(module) | ||
} | ||
|
||
export const buildEnableModule = async(safeAddress: string, module: string): Promise<BaseTransaction> => { | ||
const safe = await getSafe(safeAddress) | ||
return { | ||
to: safeAddress, | ||
value: "0", | ||
data: (await safe.enableModule.populateTransaction(module)).data | ||
} | ||
} |
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