Skip to content

Commit

Permalink
Merge pull request #28 from JoinColony/extension-upgrade-notification
Browse files Browse the repository at this point in the history
Notification for ExtensionUpgrade to v6 of VotingReputation contract
  • Loading branch information
area authored Aug 26, 2022
2 parents 81c41d9 + ee8cf08 commit 0ad6b33
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 18 deletions.
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ HUBOT_ETHEREUM_PRIVATE_KEY= # optional, uses dummy account if unspecified
# Server
SERVER_ENDPOINT=
RPC_URL=

# Contracts
NETWORK_ADDRESS=

# Users
UPGRADE_ALERT_DISCORD_USER_ID=
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ To add a feature to Chewie, create a new file in the `scripts` directory. To lea

```
yarn dev
yarn start-discord
```

For Discord, run
```
yarn start-discord
```


This will start a shell where you can talk to Chewie without having to hook it up to Slack! If you want any of the other scripts which require configuration to work, you'll need to set up your environment variables.

```
Expand Down
61 changes: 43 additions & 18 deletions scripts/abis/IColonyNetwork.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,47 @@
[
{
"inputs": [
{
"inputs": [
{
"internalType": "bool",
"name": "_active",
"type": "bool"
}
],
"name": "getReputationMiningCycle",
"outputs": [
{
"internalType": "address",
"name": "repMiningCycleAddress",
"type": "address"
}
],
"stateMutability": "view",
"type": "function",
"constant": true
},
{
"anonymous": false,
"inputs": [
{
"internalType": "bool",
"name": "_active",
"type": "bool"
}
],
"name": "getReputationMiningCycle",
"outputs": [
"indexed": true,
"internalType": "bytes32",
"name": "extensionId",
"type": "bytes32"
},
{
"indexed": true,
"internalType": "address",
"name": "colony",
"type": "address"
},
{
"internalType": "address",
"name": "repMiningCycleAddress",
"type": "address"
"indexed": false,
"internalType": "uint256",
"name": "version",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function",
"constant": true
}
]
],
"name": "ExtensionUpgraded",
"type": "event"
}
]
25 changes: 25 additions & 0 deletions scripts/contractUpgrades.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const { ethers } = require('ethers')
const colonyABI = require('./abis/IColonyNetwork.json')

// #Skunkworks Channel
const SKUNKWORKS_CHANNEL = process.env.SKUNKWORKS_DISCORD_CHANNEL
// Colony Contract Address
const NETWORK_ADDRESS = process.env.NETWORK_ADDRESS
// Gnosis Chain RPC URL
const RPC_URL = process.env.RPC_URL
// Ping Admin User
const DISCORD_USER_ID = process.env.UPGRADE_ALERT_DISCORD_USER_ID

module.exports = robot => {
const channel = robot.client.channels.cache.get(SKUNKWORKS_CHANNEL)
const provider = new ethers.providers.JsonRpcProvider(RPC_URL)
const contract = new ethers.Contract(NETWORK_ADDRESS, colonyABI, provider)

contract.on("ExtensionUpgraded", (extensionId, colonyAddress, version) => {
if (version.toString() === '6' && extensionId === '0xdc951b3d4193c331186bc2de3b4e659e51d8b00ef92751ae69abaa48a6ab38dd') {
message = 'Extension Upgraded in Colony: ' + colonyAddress
channel.send(`<@${DISCORD_USER_ID}> ` + message)
}
})

}

0 comments on commit 0ad6b33

Please sign in to comment.