Skip to content

Commit

Permalink
Merge pull request #59 from maticnetwork/command-scripts
Browse files Browse the repository at this point in the history
new: add new script for update-implementation data
  • Loading branch information
jdkanani authored Nov 5, 2020
2 parents b3832d1 + b0fbb6f commit 7ed0dc2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,9 @@ npm run truffle -- migrate --network mainnetChild --f 5 --to 5
- Register RootChainManager and ChildChainManager on StateSender
- Set stateSenderAddress on RootChainManager
- Grant STATE_SYNCER_ROLE on ChildChainManager

### Command scripts (Management scripts)

```bash
npm run truffle exec scripts/update-implementation.js -- --network <network-name> <new-address>
```
32 changes: 32 additions & 0 deletions scripts/update-implementation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const contractAddresses = require('../contractAddresses.json')

const RootChainManagerProxy = artifacts.require('RootChainManagerProxy')

async function updateImplementation(address) {
const rootChainManager = await RootChainManagerProxy.at(
contractAddresses.root.RootChainManagerProxy
)

let currentImplementation = await rootChainManager.implementation()
console.log("Current ChildChainManagerProxy implementation address", currentImplementation)

const data = rootChainManager.contract.methods.updateImplementation(address).encodeABI()
console.log("ChildChainManagerProxy updateImplementation ABI encoded data:", data)
}

module.exports = async function(callback) {
// args starts with index 6, example: first arg == process.args[6]
console.log(process.argv)
try {
const accounts = await web3.eth.getAccounts()
console.log('Current configured address to make transactions:', accounts[0])

// set validator share address
// -- --network <network-name> <new-address>
await updateImplementation(process.argv[6])
} catch (e) {
// truffle exec <script> doesn't throw errors, so handling it in a verbose manner here
console.log(e)
}
callback()
}

0 comments on commit 7ed0dc2

Please sign in to comment.