origin-js icon indicating copy to clipboard operation
origin-js copied to clipboard

Move sample listing creation out of truffle migration scripts

Open franckc opened this issue 7 years ago • 2 comments

Currently we create the sample listing via a script that runs as part of the truffle migration steps. The script calls directly the marketplace contract method createListing as opposed to using origin-js. This causes issue since some logic in origin-js runs as part of listing creation to properly set the deposit amount for example before calling the marketplace contract.

It would be better to move sample listing creation to a separate script that would get executed as part of the scripts/build.js build script.

franckc avatar Sep 18 '18 04:09 franckc

I have been trying to implement the following approach:

  • new method createSampleListing under scripts/helpers/create-sample-listing.js gets called by build.js
  • createSampleListing instantiates an Origin object then call Origin.marketplace.createListing

Code is on branch franck/create_sample_listings But I'm hitting a couple of problematic issues:

  1. In order to instantiate an Origin object, I need to point to either the origin-js npm or at a locally compiled version of it. But none of those exist yet when build.js runs. I also tried to point to dist/index.js but similarily that fails since webpack compiles that file as part of build.js running...
  2. The upload to IPFS of b64 encoded image data fails unless I make changes to the IpfsService. saveDataURIAsFile method (see #511). I have tested it on Node.js and Chrome browser installed on my envionment but this might be a risky change to put in without more validation on different type of browsers...

Overall I'm inclined to do the following:

  • For our Testnet release, disable sample listing creation on Rinkeby. We can create those manually if needed.
  • Continue looking at options for automatically creating sample listings when origin-js container gets started...

franckc avatar Sep 20 '18 05:09 franckc

Though we would loose all the logic in origin.js, we can always just make simple json POST calls to IPFS and Ganache....

It's probably a terrible idea, but it's always possible...

DanielVF avatar Sep 20 '18 12:09 DanielVF