-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [#45] Add hardhat task to generate markdown file of deployed contract addresses * [#45] Use table in README--md for other commands, open links in new tab in * [#45] Add mermaid chart in README, add info about implemented components * [#45] Add execution flows * [#45] Add coverage number in README * [#45] Update diagram and add usage section
- Loading branch information
Showing
6 changed files
with
266 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Deployed Safe{Core} Protocol Contracts | ||
|
||
## Network: goerli | ||
|
||
| Contract Name | Address (click to view on Etherscan) | | ||
| -------------- | -------------------------------- | | ||
| SafeProtocolManager | <a href="https://goerli.etherscan.io/address/0x4026BA244d773F17FFA2d3173dAFe3fdF94216b9" target="_blank">0x4026BA244d773F17FFA2d3173dAFe3fdF94216b9</a> | | ||
| SafeProtocolRegistry | <a href="https://goerli.etherscan.io/address/0xc9361a1c6A8DeB0e4bB069820BB3f0Eaf94ae829" target="_blank">0xc9361a1c6A8DeB0e4bB069820BB3f0Eaf94ae829</a> | | ||
| TestSafeProtocolRegistryUnrestricted | <a href="https://goerli.etherscan.io/address/0x9EFbBcAD12034BC310581B9837D545A951761F5A" target="_blank">0x9EFbBcAD12034BC310581B9837D545A951761F5A</a> | | ||
| TestSafeProtocolManager | <a href="https://goerli.etherscan.io/address/0xAbd9769A78Ee63632A4fb603D85F63b8D3596DF9" target="_blank">0xAbd9769A78Ee63632A4fb603D85F63b8D3596DF9</a> | | ||
|
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,100 @@ | ||
# High-level overview of Execution Flows | ||
|
||
The below sections provide a high-level overview of the execution different flows for the Safe{Core} Protocol. | ||
|
||
## Enable Integration flow | ||
|
||
```mermaid | ||
--- | ||
title: Safe{Core} Protocol High-level execution flow for enabling Integration | ||
--- | ||
flowchart TD; | ||
subgraph Users | ||
User(User) | ||
end | ||
subgraph SafeAccounts | ||
User(User) -->|Call manager to enable Sample Plugin| SafeAccount | ||
end | ||
subgraph SafeProtocolManager | ||
SafeAccount -->|Enable Sample Plugin Tx| Enable_Integration(Enable Integration on a Safe) | ||
Enable_Plugin --> Validator{Is Sample Integration trusted?<br>Call SafeProtocolRegistry} | ||
Validator -- Yes --> C(Sample Integration enabled on Safe) | ||
Validator -- No ----> E(Revert transaction) | ||
end | ||
``` | ||
|
||
|
||
|
||
## Transaction execution through Plugin | ||
|
||
```mermaid | ||
--- | ||
title: Safe{Core} Protocol High-level Plugin execution flow | ||
--- | ||
flowchart TD; | ||
TxExecuteFromPlugin(Call to Plugin to execute tx ) --> ExamplePlugin1 | ||
Safe --> Execute_Transaction_From_Plugin(Execute transaction) | ||
Validate_ExecuteFromPluginFlow -- Yes --> Safe(Safe Account) | ||
subgraph Plugins | ||
ExamplePlugin1(Sample Plugin) | ||
end | ||
subgraph SafeProtocolManager | ||
ExamplePlugin1 -->|Execute tx for a Safe through Plugin| Execute_Transaction(Execute transaction from a Plugin) --> Validate_ExecuteFromPluginFlow{Is Plugin Enabled?<br>Call SafeProtocolRegistry<br>and validate if Plugin trusted} | ||
Validate_ExecuteFromPluginFlow -- No ----> E(Revert transaction) | ||
end | ||
``` | ||
|
||
## Safe transaction execution with Hooks | ||
|
||
```mermaid | ||
--- | ||
title: Safe{Core} Protocol High-level execution flow through Safe | ||
--- | ||
flowchart TD; | ||
subgraph Users | ||
User(User) | ||
end | ||
subgraph SafeAccounts | ||
User(User) -->|Execute Safe Tx| SafeAccount | ||
End | ||
end | ||
subgraph SafeAccount [Safe with SafeProtocolManager enabled as Hook] | ||
PreCheck_Hook | ||
PreCheck_Hook("Pre-check Hook") -->|On passing pre-checks| ExecuteTx(Execute Safe Transaction) | ||
ExecuteTx -->|On successful execution| PostCheckHook(Post-check hook) | ||
PostCheckHook -->|On passing post checks| End | ||
end | ||
``` | ||
|
||
## Signature Verifier | ||
|
||
```mermaid | ||
--- | ||
title: Safe{Core} Protocol High-level execution flow for signature verification | ||
--- | ||
flowchart TD; | ||
Sign_Transaction(Signature forward to a smart contract for validation as input) | ||
subgraph Users | ||
User(User) | ||
end | ||
subgraph SignatureVerifier [Signature verifier enabled for the given Safe] | ||
isValidSignature(isValidSignature) | ||
isValidSignature --> |No| E(Revert transaction) | ||
end | ||
Sign_Transaction --> RequestToValidate | ||
RequestToValidate(Call to validate a Signature for given Safe) --> SafeProtocolManager | ||
SafeProtocolManager --> isValidSignature{isValidSignature} | ||
isValidSignature --> |Yes| ExecuteTx(Continue transaction execution) | ||
User("`Users(s)`") --> |Generate a Safe signature| Sign_Transaction | ||
``` |
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,44 @@ | ||
// hardhat.config.js | ||
import "hardhat-deploy"; | ||
import fs from "fs"; | ||
import { task } from "hardhat/config"; | ||
import deployments from "../../deployments"; | ||
import {NETWORK_ID_URL_MAPPING} from "../utils/etherscan_urls"; | ||
|
||
task("generate:deployments", "Generate markdown file with deployed contract addresses") | ||
.setAction(async () => { | ||
const markdownFile = "./docs/deployments.md"; | ||
|
||
const networks = Object.keys(deployments); | ||
|
||
if (networks.length === 0) { | ||
console.error("No deployments found in the deployments file."); | ||
return; | ||
} | ||
|
||
|
||
let markdownContent = "# Deployed Safe{Core} Protocol Contracts\n\n"; | ||
|
||
networks.forEach((network) => { | ||
if (deployments[network]) { | ||
const contracts = deployments[network][0]; | ||
|
||
markdownContent += `## Network: ${contracts.name}\n\n`; | ||
markdownContent += "| Contract Name | Address (click to view on Etherscan) |\n"; | ||
markdownContent += "| -------------- | -------------------------------- |\n"; | ||
|
||
Object.keys(contracts.contracts).forEach((contractName) => { | ||
const contractAddress = contracts.contracts[contractName].address; | ||
const etherscanUrl = `${NETWORK_ID_URL_MAPPING[network]}/address/${contractAddress}`; | ||
markdownContent += `| ${contractName} | <a href="${etherscanUrl}" target="_blank">${contractAddress}</a> |\n`; | ||
|
||
}); | ||
|
||
markdownContent += "\n"; | ||
} | ||
}); | ||
|
||
fs.writeFileSync(markdownFile, markdownContent); | ||
|
||
console.log(`Markdown file with deployed contract addresses generated: ${markdownFile}`); | ||
}); |
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,4 @@ | ||
export const ETHERSCAN_GOERLI_BASE_URL = "https://goerli.etherscan.io"; | ||
export const NETWORK_ID_URL_MAPPING = { | ||
5: ETHERSCAN_GOERLI_BASE_URL | ||
} |