Skip to content

Commit 7ed0dc2

Browse files
authored
Merge pull request #59 from maticnetwork/command-scripts
new: add new script for update-implementation data
2 parents b3832d1 + b0fbb6f commit 7ed0dc2

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,9 @@ npm run truffle -- migrate --network mainnetChild --f 5 --to 5
118118
- Register RootChainManager and ChildChainManager on StateSender
119119
- Set stateSenderAddress on RootChainManager
120120
- Grant STATE_SYNCER_ROLE on ChildChainManager
121+
122+
### Command scripts (Management scripts)
123+
124+
```bash
125+
npm run truffle exec scripts/update-implementation.js -- --network <network-name> <new-address>
126+
```

scripts/update-implementation.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const contractAddresses = require('../contractAddresses.json')
2+
3+
const RootChainManagerProxy = artifacts.require('RootChainManagerProxy')
4+
5+
async function updateImplementation(address) {
6+
const rootChainManager = await RootChainManagerProxy.at(
7+
contractAddresses.root.RootChainManagerProxy
8+
)
9+
10+
let currentImplementation = await rootChainManager.implementation()
11+
console.log("Current ChildChainManagerProxy implementation address", currentImplementation)
12+
13+
const data = rootChainManager.contract.methods.updateImplementation(address).encodeABI()
14+
console.log("ChildChainManagerProxy updateImplementation ABI encoded data:", data)
15+
}
16+
17+
module.exports = async function(callback) {
18+
// args starts with index 6, example: first arg == process.args[6]
19+
console.log(process.argv)
20+
try {
21+
const accounts = await web3.eth.getAccounts()
22+
console.log('Current configured address to make transactions:', accounts[0])
23+
24+
// set validator share address
25+
// -- --network <network-name> <new-address>
26+
await updateImplementation(process.argv[6])
27+
} catch (e) {
28+
// truffle exec <script> doesn't throw errors, so handling it in a verbose manner here
29+
console.log(e)
30+
}
31+
callback()
32+
}

0 commit comments

Comments
 (0)