Last active
November 27, 2019 22:10
-
-
Save eternauta1337/1b4435be448c80f1909c751fa3571f58 to your computer and use it in GitHub Desktop.
Aragon app installers using EVM scripts, bundling multiple arbitrary transactions into a single vote. Note: Requires that you use the #encode-commands branch of aragon-cli.
This file contains hidden or 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
#!/bin/bash | |
set -x | |
set -e | |
lastWordAtLine() { | |
tail -$1 | head -1 | grep -oE '[^ ]+$' | |
} | |
# Identify main account | |
printf "\n>>> IDENTIFYING ACCOUNTS...\n" | |
ACCOUNT1="0xb4124cEB3451635DAcedd11767f004d8a28c6eE7" | |
ACCOUNT2="0x8401Eb5ff34cc943f096A32EF3d5113FEbE8D4Eb" | |
# Create new DAO | |
printf "\n>>> CREATING NEW DAO...\n" | |
DAO=$(aragon dao new | lastWordAtLine 1) | |
# Create token | |
printf "\n>>> CREATING NEW TOKEN...\n" | |
TOKEN=$(aragon dao token new 'Member token' 'MBR' 0 | lastWordAtLine 4) | |
# Install token manager app | |
printf "\n>>> INSTALLING TOKEN MANAGER...\n" | |
TOKEN_MANAGER=$(aragon dao install $DAO token-manager --app-init none | lastWordAtLine 2) | |
# Change token controller | |
printf "\n>>> CHANGING TOKEN CONTROLLER...\n" | |
aragon dao token change-controller $TOKEN $TOKEN_MANAGER | |
# Give main account permission to mint | |
printf "\n>>> CREATING MINT_ROLE PERMISSION...\n" | |
aragon dao acl create $DAO $TOKEN_MANAGER MINT_ROLE $ACCOUNT1 $ACCOUNT1 | |
# Initialize token manager | |
printf "\n>>> INITIALIZING TOKEN MANAGER...\n" | |
aragon dao exec $DAO $TOKEN_MANAGER initialize $TOKEN false 1 | |
# Mint tokens for 2 accounts | |
printf "\n>>> MINTING TOKENS...\n" | |
aragon dao exec $DAO $TOKEN_MANAGER mint $ACCOUNT1 1 | |
aragon dao exec $DAO $TOKEN_MANAGER mint $ACCOUNT2 1 | |
# Install voting app | |
printf "\n>>> INSTALLING VOTING APP...\n" | |
VOTING=$(aragon dao install $DAO voting --app-init-args $TOKEN 600000000000000000 250000000000000000 604800 | lastWordAtLine 1) | |
# Set up voting app permissions | |
ACL=0x1fc294d2c23f9d79d07640af7e506714fd0b8ad4 | |
printf "\n>>> SETTING UP VOTING PERMISSIONS...\n" | |
aragon dao acl create $DAO $VOTING CREATE_VOTES_ROLE $TOKEN_MANAGER $VOTING | |
aragon dao acl create $DAO $VOTING MODIFY_SUPPORT_ROLE $VOTING $VOTING | |
aragon dao acl grant $DAO $DAO APP_MANAGER_ROLE $VOTING | |
aragon dao acl grant $DAO $ACL CREATE_PERMISSIONS_ROLE $VOTING | |
# Summary | |
echo " | |
DAO: $DAO | |
TOKEN: $TOKEN | |
TOKEN MANAGER: $TOKEN_MANAGER | |
VOTING: $VOTING | |
" |
This file contains hidden or 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
#!/bin/bash | |
set -x | |
set -e | |
# Identidy DAO | |
printf "\n>>> IDENTIFYING DAO...\n" | |
DAO=$1 | |
DAO_ARTIFACTS=~/aragon/repos/aragonOS/build/contracts/Kernel.json | |
# Identify voting app | |
printf "\n>>> IDENTIFYING VOTING APP...\n" | |
VOTING=$2 | |
VOTING_ARTIFACTS=~/aragon/repos/aragon-apps/apps/voting/build/contracts/Voting.json | |
# Retrieve DAO's base namespace | |
printf "\n>>> RETRIEVING BASE NAMESPACE...\n" | |
BASES_NAMESPACE=$(aragon read $DAO_ARTIFACTS $DAO APP_BASES_NAMESPACE) | |
# Retrieve app ids and base apps | |
printf "\n>>> RETRIEVING APP IDS AND BASE APPS...\n" | |
VAULT_APP_ID="0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1" | |
VAULT_BASE_APP=$(aragon apm info vault | tail -n +3 | jq '.contractAddress' --raw-output) | |
FINANCE_APP_ID="0xbf8491150dafc5dcaee5b861414dca922de09ccffa344964ae167212e8c673ae" | |
FINANCE_BASE_APP=$(aragon apm info finance | tail -n +3 | jq '.contractAddress' --raw-output) | |
# Encode installation calls | |
printf "\n>>> ENCODING INSTALLATION CALLS...\n" | |
FINANCE_INSTALL_CALL=$(aragon encode call $DAO_ARTIFACTS newAppInstance $FINANCE_APP_ID $FINANCE_BASE_APP) | |
VAULT_INSTALL_CALL=$(aragon encode call $DAO_ARTIFACTS newAppInstance $VAULT_APP_ID $VAULT_BASE_APP) | |
# Retrieve contract artifacts | |
printf "\n>>> RETRIEVING CONTRACT ARTIFACTS...\n" | |
VAULT_ARTIFACTS=~/aragon/repos/aragon-apps/apps/vault/build/contracts/Vault.json | |
FINANCE_ARTIFACTS=~/aragon/repos/aragon-apps/apps/finance/build/contracts/Finance.json | |
ACL_ARTIFACTS=~/aragon/repos/aragonOS/build/contracts/ACL.json | |
# Calculate deployed addresses | |
# TODO: Using deterministic aragen for now | |
printf "\n>>> CALCULATING DEPLOYMENT ADDRESSES...\n" | |
FINANCE=0x3bf37efD74354A29f9507D1A21329b773bB49F58 | |
VAULT=0xEB62b78213c6C2E5c0698dDa67E3260007b8C999 | |
# Encode permission calls | |
printf "\n>>> ENCODING PERMISSION CALLS...\n" | |
TRANSFER_ROLE=$(aragon read $VAULT_ARTIFACTS $VAULT_BASE_APP TRANSFER_ROLE) | |
CREATE_PAYMENTS_ROLE=$(aragon read $FINANCE_ARTIFACTS $FINANCE_BASE_APP CREATE_PAYMENTS_ROLE) | |
VAULT_PERMISSION_CALL=$(aragon encode call $ACL_ARTIFACTS createPermission $FINANCE $VAULT $TRANSFER_ROLE $VOTING) | |
FINANCE_PERMISSION_CALL=$(aragon encode call $ACL_ARTIFACTS createPermission $VOTING $FINANCE $CREATE_PAYMENTS_ROLE $VOTING) | |
# Wrap all calls in a script | |
printf "\n>>> ENCODING FINAL SCRIPT...\n" | |
ACL=$(aragon read $DAO_ARTIFACTS $DAO acl) | |
SCRIPT=$(aragon encode script --targets $DAO $DAO $ACL $ACL --calls $VAULT_INSTALL_CALL $FINANCE_INSTALL_CALL $VAULT_PERMISSION_CALL $FINANCE_PERMISSION_CALL) | |
# Create a new vote with the script | |
printf "\n>>> CREATING NEW VOTE WITH SCRIPT...\n" | |
aragon dao exec $DAO $VOTING newVote "$SCRIPT" "I'd like to install some shit" |
This file contains hidden or 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
#!/bin/bash | |
set -x | |
set -e | |
# Identidy DAO | |
printf "\n>>> IDENTIFYING DAO...\n" | |
DAO=$1 | |
# Identify voting app | |
printf "\n>>> IDENTIFYING VOTING APP...\n" | |
VOTING=$2 | |
VOTING_ARTIFACTS=~/aragon/repos/aragon-apps/apps/voting/build/contracts/Voting.json | |
# Encode call to voting's changeSupportRequiredPct function | |
printf "\n>>> ENCODING CALL TO changeSupportRequiredPct...\n" | |
CALL=$(aragon encode call $VOTING_ARTIFACTS changeSupportRequiredPct 490000000000000000) | |
# Wrap call in an EVM script | |
printf "\n>>> WRAPPING CALL IN A SCRIPT...\n" | |
SCRIPT=$(aragon encode script --targets $VOTING --calls $CALL) | |
# Create a new vote with the script | |
printf "\n>>> CREATING NEW VOTE WITH SCRIPT...\n" | |
aragon dao exec $DAO $VOTING newVote "$SCRIPT" "I'd like to change the required support" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run in this order:
Requires deep linking and latest voting packages, so this may require an apm publish for voting in aragen. Also, assumes that aragen is reset and freshly started.