-
Notifications
You must be signed in to change notification settings - Fork 54
README outdated? #49
Comments
@jtakalai I noticed this too. It saves json files which contain deployment information but mostly they can be used with
Now you'd have promisified objects with the api found here |
It does not seem to output any I would really like to build the artifact to require later on in the project but it seems the readme does not reflect the correct usage. For now I'll stick to just truffle-contract I guess and do it "realtime". As far as I can tell, this should work:
const Artifactor = require("truffle-artifactor");
const artifactor = new Artifactor("./build/contracts");
const contractData = require('./build/contracts/SimpleStorage.json');
const path = require('path');
artifactor
.save(contractData, path.join(__dirname, 'SimpleStorage.sol.js'))
.then(function (file) {
// The file ./SimpleStorage.sol.js should now exist?
}); |
Yeah the readme is still wrong. The artifacts are .json files now. There
may be better documentation in https://truffle.readthedocs.io/en/develop/
On Mon, Aug 7, 2017 at 8:58 AM Kevin Smets ***@***.***> wrote:
It does not seem to output any .sol.js file at all? No matter what you
try.
I would really like to build the artifact to require later on in the
project but it seems the readme does not reflect the correct usage :/.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGofiSCFKdnt3huxqHb0EIIOt4MGT60wks5sVwnagaJpZM4MvaSt>
.
--
Thanks, Zac
|
@zmitton looks like that link isn't working anymore :/ @kevin-smets I had a crack at it after parsing through the tests and got a json file to output using a script like this: const Artifactor = require('truffle-artifactor');
const path = require('path');
const solc = require('solc');
const fs = require('fs');
const requireNoCache = require('require-nocache')(module);
// Compile first
const result = solc.compile(fs.readFileSync('./MyTest.sol', { encoding: 'utf8' }), 1);
// Clean up after solidity. Only remove solidity's listener,
// which happens to be the first.
process.removeListener('uncaughtException', process.listeners('uncaughtException')[0]);
const compiled = result.contracts[':MyTest']; // not sure why this is getting prepended with :
const abi = JSON.parse(compiled.interface);
const binary = compiled.bytecode;
// Setup
const dirPath = path.resolve('./');
const expected_filepath = path.join(dirPath, 'MyTest.json');
const artifactor = new Artifactor(dirPath);
artifactor.save({
contract_name: 'MyTest',
abi,
binary,
network_id: 3, // Ropsten
})
.then(function(result) {
const json = requireNoCache(expected_filepath);
console.log(contract(json));
})
.catch((error) => {
console.log('catch error:',error);
}); |
interesting, Yeah usually I would do a `truffle compile` to create the
`.json` file, but interesting to know how to do it from scratch
…On Wed, Sep 6, 2017 at 8:52 AM, captDaylight ***@***.***> wrote:
@zmitton <https://github.com/zmitton> looks like that link isn't working
anymore :/
@kevin-smets <https://github.com/kevin-smets> I had a crack at it after
parsing through the tests and got a json file to output using a script like
this:
const Artifactor = require('truffle-artifactor');
const contract = require('truffle-contract');
const path = require('path');
const solc = require('solc');
const fs = require('fs');
const requireNoCache = require('require-nocache')(module);
// Compile first
const result = solc.compile(fs.readFileSync('./MyTest.sol', { encoding: 'utf8' }), 1);
// Clean up after solidity. Only remove solidity's listener,
// which happens to be the first.
process.removeListener('uncaughtException', process.listeners('uncaughtException')[0]);
const compiled = result.contracts[':MyTest']; // not sure why this is getting prepended with :
const abi = JSON.parse(compiled.interface);
const binary = compiled.bytecode;
// Setup
const dirPath = path.resolve('./');
const expected_filepath = path.join(dirPath, 'MyTest.json');
const artifactor = new Artifactor(dirPath);
artifactor.save({
contract_name: 'MyTest',
abi,
binary,
network_id: 3, // Ropsten
})
.then(function(result) {
const json = requireNoCache(expected_filepath);
console.log(contract(json));
})
.catch((error) => {
console.log('catch error:',error);
});
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#49 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AGoficaFRLgHrgKsy_USlg7uiBzbq0Bqks5sfr_TgaJpZM4MvaSt>
.
|
@kevin-smets I did the same thing what you have suggested in generating ./SimpleStorage.sol.js but it is not generated |
Any chance of getting an official fix? I don't mean to belittle @captDaylight's effort, but srsl, the documentation should be the authors' explicit intent on how the library ought to be used, so it should be written by authors themselves. @tcoulter @gnidan? |
It seems truffle-artifactor doesn't work at all as described in the README.md:
Instead (digging the tests) it seems to work more like this:
I'm not sure how to write the
// Later...
part though, sincesave
only seems to generate a .json file, not sol.js. I don't thinkrequire("./wrappers/MyContract.json")
would be going to do much good...Any chance README.md could be updated, or at least please point to documentation on how to use truffle-artifactor the way it currently is?
The text was updated successfully, but these errors were encountered: