Skip to content

Instantly share code, notes, and snippets.

@mseijas
Last active May 23, 2018 20:14
Show Gist options
  • Save mseijas/9e93947af1428dc878592dd260eb7c2a to your computer and use it in GitHub Desktop.
Save mseijas/9e93947af1428dc878592dd260eb7c2a to your computer and use it in GitHub Desktop.
const SocialNetworkProxy = artifacts.require('SocialNetworkProxy')
const SocialNetworkV1 = artifacts.require('SocialNetworkV1')
const SocialNetworkV2 = artifacts.require('SocialNetworkV2')
module.exports = (deployer, network, accounts) => {
deployer.then(async () => {
/***********************************
* 1. INITIAL DEPLOYMENT
***********************************/
let proxy, socialNetworkV1, proxySocialNetwork
// 1. Deploy SocialNetworkProxy
proxy = await deployer.deploy(SocialNetworkProxy)
// 2. Deploy SocialNetworkV1 contract
socialNetworkV1 = await deployer.deploy(SocialNetworkV1)
// 3. Link SocialNetworkProxy with SocialNetworkV1 contract
await proxy.upgradeTo(socialNetworkV1.address)
// 4. Update ImageURL via Proxy
proxySocialNetwork = SocialNetworkV1.at(proxy.address)
await proxySocialNetwork.setName('TanookiChats')
await proxySocialNetwork.setImageUrl('http://tanookilabs.com/images/tanooki-small@2x-0500fc1e.png')
// /***********************************
// * 2. UPGRADE TO SOCIALNETWORKV2
// ***********************************/
let socialNetworkV2
// 1. Deploy SocialNetworkV2 contract
socialNetworkV2 = await deployer.deploy(SocialNetworkV2)
// 2. Upgrade proxy to SocialNetworkV2
await proxy.upgradeTo(socialNetworkV2.address)
// 3. Add an account as an admin
proxySocialNetwork = SocialNetworkV2.at(proxy.address)
await proxySocialNetwork.addAdminAccount(accounts[2])
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment