Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Migration only save the first deployed smart contract. #881

Closed
1 task done
Pedro-vk opened this issue Apr 2, 2018 · 1 comment
Closed
1 task done

Migration only save the first deployed smart contract. #881

Pedro-vk opened this issue Apr 2, 2018 · 1 comment

Comments

@Pedro-vk
Copy link

Pedro-vk commented Apr 2, 2018


Issue

My migration deploys a few contracts in a row. The JSON files get created with ABI and bytecode, but only the first contract deployed gets the deployed address saved under the network in the artefacts.

Steps to Reproduce

Run a migration of that:

var FirstContract = artifacts.require("./FirstContract.sol");
var SecondContract = artifacts.reqre("./SecondContract.sol");

module.exports = async function (deployer, helper, accounts)  {
  try {
    await deployer.deploy(FirstContract)
    let firstContract = await FirstContract.deployed()

    await deployer.deploy(SecondContract, firstContract.address)
    let secondContract = await SecondContract.deployed()
  } catch (error) {
    console.log(error)
  }
}

Expected Behavior

FirstContract and SecondContract must have the network parameter written, with the address where have been deployed.

Actual Results

Check the result of the FirstContract and SecondContract, only FirstContract have written the network parameter.

Environment

  • Operating System: Ubuntu 16.04
  • Ethereum client: Ganache v1.1.0-beta.1 and Ropsten network throught infura.
  • Truffle version (truffle version): 4.1.5 and 4.1.3
  • node version (node --version): 9.5.0
  • npm version (npm --version): 5.8.0
@cgewecke
Copy link
Contributor

cgewecke commented Apr 2, 2018

@Pedro-vk Thanks for opening - this is a duplicate of #501.

The way async/await integrates with the migrations feature is confusing for a lot of users. truffle-migrate was written before await became common and it stages deployments as 'thennables' rather than executing them as true promises. See this comment for advice about how to resolve.

@cgewecke cgewecke closed this as completed Apr 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants