Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment of ERC777 with Truffle Migrations doesn't work. #1743

Closed
crazyrabbitLTC opened this issue May 9, 2019 · 5 comments
Closed

Deployment of ERC777 with Truffle Migrations doesn't work. #1743

crazyrabbitLTC opened this issue May 9, 2019 · 5 comments

Comments

@crazyrabbitLTC
Copy link
Contributor

A requirement to deploy ERC777 requires a local instance of ERC1820 to be deployed, which does not exist on a local Test network.

There are several issues here:
1: ERC777 fails to deploy, but does not communicate to the user the reason why it failed. No revert/require statements fail with a description why. It is not communicated with the user that the lack of an ERC1820 contract is the problem.

2: Deployment of ERC1820 via the OpenZeppelin-test-helpers in migrations does not work as Truffle Migrations does not seem to be able to properly require in openzeppelin-test-helpers

Because of this, it is unclear of the best way to deploy ERC777 using truffle migrations. Perhaps an external 'setup script' needs to be created.

💻 Environment
Mac OSX Mojave, zsh terminal

OpenZeppelin: openzeppelin-solidity@next (Next at time of this issue filing)
Truffle v5.0.13

📝 Details

Solidity code:

pragma solidity >=0.4.21 <0.6.0;

import "openzeppelin-solidity/contracts/token/ERC777/ERC777.sol";

contract My777Token is ERC777 {
    constructor(string memory name, string memory symbol, address[] memory defaultOperators)
    ERC777(name, symbol, defaultOperators) public {
    }

}

Migrations code:


const My777Token = artifacts.require("My777Token");
const { singletons } = require('openzeppelin-test-helpers');


const name = "LuckyToken";
const symbol = "LT";
const defaultOperators = [];

module.exports = async function(deployer, accounts) {
    let accounts = await web3.eth.getAccounts();
    const erc1820 = await singletons.ERC1820Registry(accounts[0]);
    
  deployer.deploy(My777Token, name, symbol, defaultOperators);
};

🔢 Code to reproduce bug

The example above will not deploy an ERC777 token, it is unclear how to deploy a ERC777 in a standard method using Truffle Migrations.

@frangio
Copy link
Contributor

frangio commented May 9, 2019

Thank you for reporting this @crazyrabbitLTC! We definitely want to get this to work more like an out of the box experience, so we're looking into it.

I think that using the deployer in openzeppelin-test-helpers should be the recommended way, but it's not working due to OpenZeppelin/openzeppelin-test-helpers#35.

@frangio
Copy link
Contributor

frangio commented May 9, 2019

@crazyrabbitLTC There's a fix for this in OpenZeppelin/openzeppelin-test-helpers#38.

You can try it with

npm install github:OpenZeppelin/openzeppelin-test-helpers

You will then be able to

require('openzeppelin-test-helpers/configure')({ web3 })

@crazyrabbitLTC
Copy link
Contributor Author

crazyrabbitLTC commented May 11, 2019

Hi @frangio , for:

npm install frangio/openzeppelin-test-helpers#reduce-dependencies

is the "#reduce-dependencies" intentional? I'm getting this error:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git checkout reduce-dependencies
npm ERR! error: pathspec 'reduce-dependencies' did not match any file(s) known to git
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/dennisonzeppelin/.npm/_logs/2019-05-11T02_18_15_736Z-debug.log

I tried without, but I still have the:
Error: Cannot find module 'openzeppelin-test-helpers/configure'

So I assume I'm still missing something. My new deployment code looks like this: (but does not work)

const My777Token = artifacts.require("My777Token");
require('openzeppelin-test-helpers/configure')({ web3 })
const { singletons } = require('openzeppelin-test-helpers');

const name = "LuckyToken";
const symbol = "LT";
const defaultOperators = [];

module.exports = async function(deployer, accounts) {
    let accounts = await web3.eth.getAccounts();
    const erc1820 = await singletons.ERC1820Registry(accounts[0]);
    
  deployer.deploy(My777Token, name, symbol, defaultOperators);
};

@frangio
Copy link
Contributor

frangio commented May 11, 2019

Yes it was intentional but we just merged the PR so I deleted the branch and forgot to update this comment. Sorry! Updated the comment above now.

npm install github:OpenZeppelin/openzeppelin-test-helpers

Let me know if you have any other issues!

@frangio
Copy link
Contributor

frangio commented May 11, 2019

@crazyrabbitLTC I think you have a bug in your migrations code though.

The function you export in the migration receives three arguments and accounts is the third one. At least in truffle@5.0.13.

const ERC777 = artifacts.require('ERC777');

require('openzeppelin-test-helpers/configure')({ web3 });

const { singletons } = require('openzeppelin-test-helpers');

const name = "LuckyToken";
const symbol = "LT";
const defaultOperators = [];

module.exports = async function(deployer, network, accounts) {
  const erc1820 = await singletons.ERC1820Registry(accounts[0]);

  deployer.deploy(ERC777, name, symbol, defaultOperators);
};

@frangio frangio closed this as completed May 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants