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

Update docs to be more clear about deployer function arguments #2830

Open
JackBekket opened this issue Feb 13, 2020 · 5 comments
Open

Update docs to be more clear about deployer function arguments #2830

JackBekket opened this issue Feb 13, 2020 · 5 comments

Comments

@JackBekket
Copy link

I'm trying to deploy contracts to ganache, using truffle migrate. One of my contracts requiring to get accounts addresses as constructor parameter

When I try to use

module.exports = function(deployer, network, accounts) {
 // Use the accounts within your migrations.
} 

and trying deploy like this:

module.exports = function(deployer, accounts) {
 // deployer.deploy(SimpleStorage);
 deployer.deploy(KNS).then(function() {
  console.log(accounts);
  console.log(accounts[0]);
  return deployer.deploy(SuperFactory, KNS.address,accounts[0],accounts[0]);
});
};

it falis with invalid address.

console.log(accounts)
just print me string
ganache

Expected Behavior

migration successful, or at least console.log should return me Promise of accounts array
(the same way as I would invoke web3.eth.getAccounts() )

I also should note, that when I'm invoking web3.eth.getAccounts() manually - it works fine, but when I'm trying to get accounts from module.exports it returns me that ganache string and nothing else

Current Behavior

accounts contain simple string ganache and nothing else

Possible Solution

Check out accounts from module.exports or check out ganache accounts accesability.

Your Environment

Truffle v.5.1.12

@JackBekket
Copy link
Author

Oh, I just found where bug is

module.exports = function(deployer, network, accounts) {
 // Use the accounts within your migrations.
} 

module exports always think, that second parameter is a network, and third parameter is accounts.

If I don't need network parameter for deploy and only need accounts -- I should cast it as third parameter to module.exports

@nicholasjpaterno
Copy link
Contributor

@JackBekket thanks for opening this issue! I'm going to transfer this over to the truffle repository where it can be triaged!

@nicholasjpaterno nicholasjpaterno transferred this issue from trufflesuite/ganache-ui Feb 13, 2020
@gnidan
Copy link
Contributor

gnidan commented Feb 19, 2020

Is there something we could do here to make this experience better? It seems like the confusion was just the argument order.

If anyone has any thoughts, please suggest! Otherwise we'll close this in ~1 month. Thanks all!

@JackBekket
Copy link
Author

@gnidan

Could you kindly add this note to truffle docs?

Something like this?

// @params - deployer, network, accounts
// order is matter
module.exports = ...

Right now it is confusing for people who may work without IDE or without static typing.

@gnidan
Copy link
Contributor

gnidan commented Mar 4, 2020

Yep! I'll update this issue accordingly! Thanks @JackBekket

@gnidan gnidan changed the title Invalid address in deployment procees (bug with ganache accounts) Update docs to be more clear about deployer function arguments Mar 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants