[SOLVED] Discovery migrate - Unhandled Promise Rejection Warning - Error

Hey everyone!

While executing the " discovery migrate" command I get the following message:

So this error has already been addressed here: Problem running discovery test

And the solution was to:

  1. To reinitialize discovery to get the EnigmaSimulation.sol
  2. The location of the file ‘millionaires_problem.txt’ which contains the contact address needs to be changes in deployment and the test scripts.

For step 1: Checked whether the `EnigmaSimulation.json’ is in build/enigma_contracts and it is so this would probably confirm that the EnigmaSimulation.sol is compiled.

For step 2: Don’t know where to find the file ‘millionaires_problem.txt’ and what needs to be changed.

Can someone help out with step 2? Perhaps explain what is going on.
Much appreciated!!

PS: I thought it to be useful to create a separate thread for this error even thought it has already been mentioned. If there is a more effective way of documenting or a standard I can follow please do advice me on this.

Hi Franklin, that file should be in the same directory as your test file, because that’s where the secret contract’s address is read from.
The address is set/updated anytime you migrate, the file will be created if it doesn’t exist, the deploy script does this.
It does depend on where you ran the migrate from, though Laura recently fixed this to be relative in this commit

1 Like

Thanks for your response Taariq.

I cannot find this file in my directory where I have discovery initialized. Checked the commit from Laura and already have these fixes locally.

Sure you ran migrate successfully? Perhaps migration was successful but you had file permissions or something preventing the file from being created, please check the output for errors.

Here’s the sample deploy boilerplate where it writes the file

Still get this message with “discovery migrate”

And now I also get this message with “discovery compile”:

You’ll have to fix the compile error before migrating.
Can you try this with a fresh ‘discovery init -> compile -> migrate’ and confirm the file is there?

Sorry, just to be sure, do you mean the millionaires_problem.txt file? In that case I still have not found it.

I removed everything including the dependencies and started clean. Followed the steps on the medium post and the installation steps described op de git repo. Sadly still the same error when I execute the migrate command.

No there’ll be a simple_addition.txt file after migrating a new project.
So if that works your env is ok, it deploys and you can write files to your OS etc

There’s apparently an error in your contract preventing compilation, so you can’t migrate after making your changes.

Oke just to be 100% sure I have initialized discovery again in a new folder and follow the steps outlined in the medium post: https://blog.enigma.co/getting-started-with-enigma-an-intro-to-secret-contracts-cdba4fe501c2

Now I am at the part where I execute the “discovery migrate” command sadly I get the same error.

discovery compile works now before and after discovery migrate command.

Instead of an image please paste the output, can be helpful to see the versions etc.

btw what version of node are you on?
and what version of discovery-cli?

Oke wil do. Do you need me to paste any specific output atm?

Node: 10.15.2
npm: 6.10.3
discovery-cli 0.0.26

You can try bump node to at least 10.16 which is confirmed working by myself and others, eg https://forum.scrt.network/t/error-during-discovery-init/927/7

1 Like

It’s solved now!

The error message specified “only valid in async function at Object.run”, so I pasted the code snippet that was offered by the “an-intro-to-secret-contracts” tutorial inside the brackets of the only async function in the “2_deploy_contracts.js” file instead of at the end of the file as suggested by the tutorial.

Thank you for your help @taariq!