GithubHelp home page GithubHelp logo

truffle-artifactor's Introduction

truffle-artifactor (formerly ether-pudding)

⚠️ This repo is deprecated ⚠️

Truffle has moved all modules to a monorepo at trufflesuite/truffle. See you over there!


This package saves contract artifacts into into Javascript files that can be require'd. i.e.,

var artifactor = require("truffle-artifactor");
artifactor.save({/*...*/}, "./MyContract.sol.js") // => a promise

// Later...
var MyContract = require("./MyContract.sol.js");
MyContract.setProvider(myWeb3Provider);
MyContract.deployed().then(function(instance) {
  return instance.doStuff(); // <-- matches the doStuff() function within MyContract.sol.
}).then(function(result) {
  // We just made a transaction, and it's been mined!
  // We're given transaction hash, logs (events) and receipt for further processing.
  console.log(result.tx, result.logs, result.receipt);
});

👏

Features

  • Manages contract ABIs, binaries and deployed addresses, so you don't have to.
  • Packages up build artifacts into .sol.js files, which can then be included in your project with a simple require.
  • Includes multiple versions of the same contract in a single package, automatically detecting which artifacts to use based on the network version (more on this below).
  • Manages library addresses for linked libraries.
  • Manages events, making them available on a per-transaction basis (no more event.watch()!)

The artifactor uses truffle-contract, which provides features above and beyond web3:

  • Synchronized transactions for better control flow: transactions won't be considered finished until you're guaranteed they've been mined.
  • Promises. No more callback hell. Works well with ES6 and async/await.
  • Default values for transactions, like from address or gas.
  • Returning logs, transaction receipt and transaction hash of every synchronized transaction.

Install

$ npm install truffle-artifactor

Example

Here, we'll generate a .sol.js files given a JSON object like truffle-schema. This will give us a file which we can later require into other projects and contexts.

var artifactor = require("truffle-artifactor");

// See truffle-schema for more info: https://github.com/trufflesuite/truffle-schema
var contract_data = {
  abi: ...,              // Array; required.
  unlinked_binary: "..." // String; optional.
  address: "..."         // String; optional.
};

artifactor.save(contract_data, "./MyContract.sol.js").then(function() {
  // The file ./MyContract.sol.js now exists, which you can
  // import into your project like any other Javascript file.
});

API

artifactor.save(options, filename[, extra_options])

Save contract data as a .sol.js file. Returns a Promise.

  • options: Object. Data that represents this contract:

    {
      contract_name: "MyContract",  // String; optional. Defaults to "Contract"
      abi: ...,                     // Array; required.  Application binary interface.
      unlinked_binary: "...",       // String; optional. Binary without resolve library links.
      address: "...",               // String; optional. Deployed address of contract.
      network_id: "...",            // String; optional. ID of network being saved within abstraction.
      default_network: "..."        // String; optional. ID of default network this abstraction should use.
    }

    Note: save() will also accept an already require'd contract object. i.e.,

    var MyContract = require("./path/to/MyContract.sol.js");
    
    artifactor.save(MyContract, ...).then(...);

    In this case, you can use the extra_options parameter to specify options that aren't managed by the contract abstraction itself.

  • filename: Path to save contract file.

  • extra_options: Object. Used if you need to specify other options within a separate object, for instance, when a contract abstraction is passed instead of an options object.

artifactor.saveAll(contracts, directory, options)

Save many contracts to the filesystem at once. Returns a Promise.

  • contracts: Object. Keys are the contract names and the values are contract_data objects, as in the save() function above:

    {
      "MyContract": {
        "abi": ...,
        "unlinked_binary": ...
      }
      "AnotherContract": {
        // ...
      }
    }
  • directory: String. Destination directory. Files will be saved via <contract_name>.sol.js within that directory.

  • options: Object. Same options listed in save() above.

artifactor.generate(options, networks)

Generate the source code that populates the .sol.js file. Returns a String.

  • options: Object. Subset of options listed in the save() function above. Expects:

    {
      abi: ...,
      unlinked_binary: ...
    }
  • networks: Object. Contains the information about this contract for each network, keyed by the network id.

    {
      "1": {        // live network
        "address": ...
      },
      "2": {        // morden network
        "address": ...
      },
      "1337": {     // private network
        "address": ...
      }
    }

Running Tests

$ npm test

License

MIT

truffle-artifactor's People

Contributors

area avatar benjamincburns avatar cgewecke avatar dylanseago avatar gnidan avatar jeffscottward avatar pidelport avatar raineorshine avatar redsquirrel avatar schaeff avatar tcoulter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

truffle-artifactor's Issues

Broken dependencies

Numerous packages have been broken due to web3/web3.js#904

Dependents affected by this issue include: web3, ethereumjs-testrpc, truffle-contract, and truffle-blockchain-utils

RangeError: Invalid array length

Versions

stack

Unhandled rejection RangeError: Invalid array length
  at Object.padRight (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/utils/utils.js:88:22)
  at [object Object].formatInputBytes [as _inputFormatter] (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/formatters.js:53:24)
  at [object Object].SolidityType.formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:83:17)
  at [object Object].SolidityCoder._formatInput (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:161:36)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:187:21
  at Array.map (native)
  at [object Object].SolidityCoder.encodeParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/solidity/coder.js:186:32)
  at /usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:45:22
  at Array.map (native)
  at encodeConstructorParams (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:44:8)
  at [object Object].ContractFactory.new (/usr/local/lib/node_modules/truffle/node_modules/web3/lib/web3/contract.js:196:17)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:114:28)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:294:26)
  at [object Object].contract_class.new (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:207:26)
  at [object Object].<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/build/ether-pudding.js:177:26)
  at [object Object].tryCatcher (/usr/local/lib/node_modules/truffle/node_modules/bluebird/js/main/util.js:24:31)
  at [object Object].ret (<anonymous>:14:23)
  at Context.<anonymous> (/Users/aeufemio/projects/digixglobal/digixgold/test/gold.coffee:15:9)
  at Test.Runnable.run (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runnable.js:233:15)
  at Runner.runTest (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:390:10)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:473:12
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:315:14)
  at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:325:7
  at next (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:260:23)
  at Immediate._onImmediate (/usr/local/lib/node_modules/truffle/node_modules/mocha/lib/runner.js:292:5)
  at processImmediate [as _immediateCallback] (timers.js:358:17)

Contract .call() with "defaultBlock" param specified not working

Just wondering: is there any way to invoke Pudding's promisify abstraction of .call() for contract function, in which the defaultBlock optional parameter is specified?
The web3 Javascript API equivalent for contract .call() is here:
https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-methods

It seems in Pudding's implementation of Utils.promisifyFunction():

args.push(tx_params, callback);

The contract function arguments list is manipulated in such a way that the last 2 arguments will always be the Transaction object (tx_params), then the callback.

However, in Web3:

myContractInstance.myMethod.call(param1 [, param2, ...] [, transactionObject] [, defaultBlock] [, callback]);

allows specifying the optional defaultBlock parameter after the Transaction object. Therefore, invoking Pudding's promisified .call() may not work as expected; because in such case, another tx_params will be appended to the argument list, then the callback.

undefined _iteratorError was thrown

Attempting to call the .at function, I get a throw with an undefined symbol

code that did this:

 dstore = myContractPd.at(myContract.address);
/home/barkthins/npm-global/lib/node_modules/ether-pudding/build/ether-pudding.js:69
            throw _iteratorError;
                  ^
ReferenceError: Symbol is not defined
    at Contract.Pudding (/home/barkthins/npm-global/lib/node_modules/ether-pudding/build/ether-pudding.js:40:51)
    at new Contract (/home/barkthins/npm-global/lib/node_modules/ether-pudding/build/ether-pudding.js:210:82)
    at Function.at (/home/barkthins/npm-global/lib/node_modules/ether-pudding/build/ether-pudding.js:131:16)

"Invalid JSON RPC response: undefined" with the new web3

Hi,

I get the error with the new web3. I think that code should return the response text:
https://github.com/ConsenSys/ether-pudding/blob/5a3f4023bb2b2816086193dce8015eb49193bd5e/classtemplate.js#L11

  Provider.prototype.send = function() {
    this.provider.send.apply(this.provider, arguments);
  };

because web3 expects it:
https://github.com/ethereum/web3.js/blob/develop/lib/web3/requestmanager.js#L58

    var result = this.provider.send(payload);

    if (!Jsonrpc.isValidResponse(result)) {
        throw errors.InvalidResponse(result);
    }

Feature: named enum values

Currently Solidity enums are exposed as uints:

it('should have a myEnum property', () => {
  var contract = MyContract.deployed()
  return contract.myEnum.call(accounts[0]).then(myEnumResult => {
    assert.equal(myEnumResult.valueOf(), 1)
  })
})

It would be great for ether-pudding to expose named enum values so that the tests are not tightly coupled to the enum's underlying integer values:

assert.equal(myEnumResult.valueOf(), contract.deployed().MyEnum.SomeValue)

Enums are not exposed in the ABI, so we would need to parse the source code to map enum types to integer values.


Moved from trufflesuite/truffle#157 (comment)

ERROR in ./node_modules/graceful-fs/graceful-fs.js

Hi I am getting this error when I try to use truffle-artifactor.
ERROR in ./node_modules/graceful-fs/graceful-fs.js
Module not found: Error: Can't resolve 'fs' in '/Applications/MAMP/htdocs/tokensale/node_modules/graceful-fs'

Anyone know of a fix?

Basic example throws 'TypeError: contract.abi.filter is not a function'

Hi there,

I have been using a previous version of ether-pudding (thanks for the work!) and am trying to upgrade to the latest release, but am having some difficulties.

npm install web3 ether-pudding

This gives me web3 in version 0.14.1 and ether-pudding in version 1.0.2 .

I'm trying to get a very simple example running, based on what's in the README. I think the README example is currently missing Pudding.setWeb3(web3), right? I get Cannot read property 'eth' of undefined if I don't include that.

var Web3 = require('web3')
var web3 = new Web3()
var Pudding = require('ether-pudding')

web3.setProvider(new web3.providers.HttpProvider())
Pudding.setWeb3(web3)

var abi = '[{"constant":true,"inputs":[],"name":"hello","outputs":[{"name":"","type":"bool"}],"type":"function"}]'
var binary = '606060405260658060106000396000f360606040526000357c01000000000000000000000000000000000000000000000000000000009004806319ff1d21146037576035565b005b604260048050506058565b6040518082815260200191505060405180910390f35b6000600190506062565b9056'

var MyContract = Pudding.whisk(abi, binary)
var myContract = MyContract.at('0xabcd')

Running this, I now get this error:

TypeError: contract.abi.filter is not a function
    at addFunctionsToContract (/tmp/p/node_modules/web3/lib/web3/contract.js:56:18)
    at ContractFactory.at (/tmp/p/node_modules/web3/lib/web3/contract.js:251:5)
    at Function.at (/tmp/p/node_modules/ether-pudding/build/ether-pudding.js:124:39)
    at Object.<anonymous> (/tmp/p/letswhisk.js:12:29)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3

Any ideas what I'm doing wrong or where things go wrong?

Exception while deploying on testnet

Running truffle beta 3.0.0

/usr/local/lib/node_modules/truffle/node_modules/ether-pudding/index.js:58
        network.abi.forEach(function(item) {
                   ^

TypeError: Cannot read property 'forEach' of undefined
    at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/index.js:58:20
    at tryToString (fs.js:455:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

README outdated?

It seems truffle-artifactor doesn't work at all as described in the README.md:

var artifactor = require("truffle-artifactor");
artifactor.save({/*...*/}, "./wrappers/MyContract.sol.js") // => a promise

// Later...
var MyContract = require("./wrappers/MyContract.sol.js");

Instead (digging the tests) it seems to work more like this:

var Artifactor = require("truffle-artifactor")
var artifactor = new Artifactor("./wrappers")

artifactor.save({contract_name: "MyContract", /*...*/}) // => a promise

I'm not sure how to write the // Later... part though, since save only seems to generate a .json file, not sol.js. I don't think require("./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?

Not working with node v6.0

I get the following error when using node v6.0
I had to revert to v5.5 using nvm to fix the error.

Apparently it is missing a string parameter for the filename

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1324:5)
    at Module._compile (module.js:536:22)
    at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/loader.js:49:11
    at /usr/local/lib/node_modules/truffle/node_modules/ether-pudding/loader.js:30:7
    at done (/usr/local/lib/node_modules/truffle/node_modules/node-dir/lib/paths.js:27:13)
    at /usr/local/lib/node_modules/truffle/node_modules/node-dir/lib/paths.js:55:33
    at FSReqWrap.oncomplete (fs.js:117:15)
    at Function.module.exports.loopWhile (/usr/local/lib/node_modules/truffle/node_modules/deasync/index.js:72:22)
    at /usr/local/lib/node_modules/truffle/node_modules/deasync/index.js:44:19
    at Object.Config.gather (/usr/local/lib/node_modules/truffle/lib/config.js:304:5)
    at /usr/local/lib/node_modules/truffle/cli.js:251:31
    at /usr/local/lib/node_modules/truffle/node_modules/deasync/index.js:43:7
    at runTask (/usr/local/lib/node_mod

Problem with promisses

I have difficulties to work with Promises:

Every snipped is run in the browser truffle(v0.0.13) env with a fresh chain(testrpc) and contract deployment.
I use the Coin Contract from the Solidity Tutorial.

The following web3 code works well:

a = web3.eth.accounts[0];
C = web3.eth.contract(Coin.abi);
c = C.at( Coin.deployed_address );
c.mint(a,42);
c.queryBalance( a ); // BigNumber(42)  

but the following pudding code never return its promise:

a = web3.eth.accounts[0]
c = Coin.at( Coin.deployed_address );
c.mint( a, 42 ).then( function() {
  c.queryBalance(a)
  .then( function( v ){ 
    console.log( v ); // never gets called
  });
})

The code works well until the correct balance(42) is received via rpc.
Then suddenly every second the following rpc request is send:

{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["42"],"id":5}

with following response

{"error": {"message": "Invalid parameters.", "code": -32602}, "jsonrpc": "2.0", "id": 5}

where to go from here?

Let built pudding contracts inherit from, not redefine, basic methods

I was just looking through the contract objects that pudding generates, and found a fair amount of duplicate code between them. Each contract has about 14kb of boilerplate that seems like it could be imported from a single module, or defined as a single class to inherit from.

Curious your thoughts!

ReferenceError: attempts is not defined

Receiving an error from generated .sol.js file. Appears the synchronization function does not instantiate attempts variable.

var make_attempt = function() {
  C.web3.eth.getTransactionReceipt(tx, function(err, receipt) {
    if (err) return reject(err);

    if (receipt != null) {
      return accept(tx, receipt);
    }

    if (timeout > 0 && new Date().getTime() - start > timeout) {
      return reject(new Error("Transaction " + tx + " wasn't processed in " + (timeout / 1000) + " seconds!"));
    }

    attempts += 1;

    setTimeout(make_attempt, 1000);
  });
};

Interface with storage layers

Pudding truffle-artifactor does a great job interacting with contracts.
Are any ways to interact with storage layers (IPFS, centralized, Swarm) planned as it has been seen in other frameworks?

Something like for example:

MyContract.setStorage('ipfs')
MyContract.new({foo: 'bar'}, {from: '0x42'})

Truffle could know from the abi that MyContract expects bytes, so it would

  • push {foo: 'bar'} to ipfs
  • call new with the corresponding hash

Even a simpler version that just enables to write to and read from storage could be useful.

Make .address a property such that if it's null it'll error.

This will throw errors up front, like in this migration, for instance:

module.exports = function(deployer) {
  deployer.deploy([
    Mutex,
    Owned,
    Mortal,
    ExternalStorage,    
    [ForexDB, ExternalStorage.address],
    OrderDB,    
    [DepositDB, ExternalStorage.address],
    [Exchanger, ForexDB.address, OrderDB.address, DepositDB.address],
  ]);
};

This eventually leads to an error deep within the .sol.js file because .address is null in all cased above.

Network Synchronization Transactions Not Synchronized

Hi!
I am using ethere-pudding from truffle, and in my private testnet (i use Geth/v1.4.0-unstable/linux/go1.5.1) the transactions never appear as synchronized, the callback is fired immediately (even with no active miner).
I performed some tests and I realized that the issue is at line 288 of index.js:

if (tx_info.blockHash != null) {
    clearInterval(interval);
    accept(tx);
}

As a matter of fact when a transaction is created on my network, the blockHash is immediately initialized to '0x0':

eth.getTransaction('0x630fcb406e23e87f15fbc8aca48e8f09411a0cbae50480c7efd7c370d33d3de0').blockHash
"0x0000000000000000000000000000000000000000000000000000000000000000"

Changing the code in:

if (tx_info.blockHash != null && tx_info.blockHash != 0x0 ) {
    clearInterval(interval);
    accept(tx);
}

ether-pudding starts to behave correctly.

Am I missing something or there was a change in the last version of ethereum regarding the transaction.blockHash management?

Thank you!

Kind regards

Matteo

Truffle hangs and then throws exception when running truffle test

truffle test

Compiling ./contracts/ExampleToken.sol...
Compiling ./contracts/HMLottery.sol...
Compiling ./test/TestHMLottery.sol...
Compiling truffle/Assert.sol...
Compiling truffle/DeployedAddresses.sol...
Compiling zeppelin/SafeMath.sol...
Compiling zeppelin/lifecycle/Killable.sol...
Compiling zeppelin/ownership/Contactable.sol...
Compiling zeppelin/ownership/Ownable.sol...
Compiling zeppelin/token/ERC20.sol...
Compiling zeppelin/token/StandardToken.sol...
/usr/lib/node_modules/truffle/node_modules/truffle-solidity-utils/index.js:31
      contract_definition.body.forEach(function(statement) {
                              ^

TypeError: Cannot read property 'forEach' of null
    at /usr/lib/node_modules/truffle/node_modules/truffle-solidity-utils/index.js:31:31
    at tryToString (fs.js:456:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:443:12)

Event filters broken

Creating event filters doesn't work in the current NPM release. AFAICT, wrapping contract.allEvents() in a promise doesn't quite work as intended (and also isn't needed). My solution was to simply skip that method as seen here:

chetan@07418ad

I was about to submit a PR when I saw a bunch of refactoring underway. I see some special handling of events but I haven't yet had a chance to test the current version. Any idea if this is fixed in the new implementation?

Cannot artifacts.require npm module name with '/'

Hello.

We used to name our package as dnssec-oracle and was able to load as an artifact at migration.
However, it starts failing when we renamed to @ensdomains/dnssec-oracle to name space our package with organisation name. When I manually copy the files from node_modeules/@ensdomains/dnssec-oracle to node_modeules/dnssec-oracle I was able to load it again. Is this something can be fixed or we should not have / as package name?

makoto@Makotos-MacBook-Air: [~/work/ens/dnsprove-js -  (dnsprove)] $ ls node_modules/@ensdomains/dnssec-oracle/contracts/RSASHA1Algorithm.sol
node_modules/@ensdomains/dnssec-oracle/contracts/RSASHA1Algorithm.sol
makoto@Makotos-MacBook-Air: [~/work/ens/dnsprove-js -  (dnsprove)] $ ls node_modules/dnssec-oracle/contracts/RSASHA1Algorithm.sol
node_modules/dnssec-oracle/contracts/RSASHA1Algorithm.sol
makoto@Makotos-MacBook-Air: [~/work/ens/dnsprove-js -  (dnsprove)] $ node inspect node_modules/.bin/truffle migrate
< Debugger listening on ws://127.0.0.1:9229/12a647df-fb0d-45da-a906-0db3172da72b
< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
debug> c
Break on start in node_modules/truffle/build/cli.bundled.js:1
> 1 (function (exports, require, module, __filename, __dirname) { 
  2 
  3 /******/ (function(modules) { // webpackBootstrap
< Using network 'development'.
< Running migration: 2_deploy_contracts.js
break in migrations/2_deploy_contracts.js:1
> 1 debugger
  2 var rsasha1   = artifacts.require("@ensdomains/dnssec-oracle/contracts/RSASHA1Algorithm");
  3 var rsasha256 = artifacts.require("@ensdomains/dnssec-oracle/contracts/RSASHA256Algorithm.sol");
debug> repl
Press Ctrl + C to leave debug repl
> artifacts.require("@ensdomains/dnssec-oracle/contracts/RSASHA1Algorithm")
Error: Could not find artifacts for @ensdomains/dnssec-oracle/contracts/RSASHA1Algorithm from any sources
    at Resolver.require (/Users/makoto/work/ens/dnsprove-js/node_modules/truffle/build/cli.bundled.js:63317:9)
    at Object.require (/Users/makoto/work/ens/dnsprove-js/node_modules/truffle/build/cli.bundled.js:75276:36)
    at ResolverIntercept.require (/Users/makoto/work/ens/dnsprove-js/node_modules/truffle/build/cli.bundled.js:218313:32)
    at eval (eval at <anonymous> (/Users/makoto/work/ens/dnsprove-js/migrations/2_deploy_contracts.js:1:1), <anonymous>:1:11)
    at /Users/makoto/work/ens/dnsprove-js/migrations/2_deploy_contracts.js:1:1
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at ContextifyScript.Script.runInNewContext (vm.js:65:15)
    at /Users/makoto/work/ens/dnsprove-js/node_modules/truffle/build/cli.bundled.js:121314:14
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
> artifacts.require("dnssec-oracle/contracts/RSASHA1Algorithm")
[Function: TruffleContract]

better interface for sending money to a contract

Current best practice for sending money to a contract via fallback function is: (AFAIK)

web3.eth.sendTransaction({to: contract.address, value: 100, from: accounts[0]});

I propose the following alternatives:

contract.sendTransaction({value: 100})
contract.fallback({value: 100})

Error: The node API for `babel` has been moved to `babel-core`.

git clone https://github.com/ConsenSys/truffle
git clone https://github.com/ConsenSys/ether-pudding
cd ether-pudding
npm install
npm link
cd ../truffle
npm install
npm link ether-pudding
TRUFFLE_NPM_LOCATION=pwd TRUFFLE_WORKING_DIRECTORY="/usr/local/lib/node_modules/ether-pudding" ./truffle.bash test

TRUFFLE_NPM_LOCATION=pwd TRUFFLE_WORKING_DIRECTORY="/usr/local/lib/node_modules/ether-pudding" ./truffle.bash test

/home/vagrant/truffle/node_modules/solc/bin/soljson-latest.js:1
aughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));Mod
^
Error: The node API for babel has been moved to babel-core.
at Object. (/home/vagrant/ether-pudding/node_modules/babel/index.js:1:69)
at Module._compile (module.js:456:26)
at Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (/home/vagrant/truffle/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/vagrant/ether-pudding/generator.js:6:13)
at Module._compile (module.js:456:26)
at normalLoader (/home/vagrant/truffle/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (/home/vagrant/truffle/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/vagrant/truffle/lib/contracts.es6:11:24)
at Module._compile (module.js:456:26)
at normalLoader (/home/vagrant/truffle/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) as .es6
at Module.load (/home/vagrant/truffle/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/vagrant/truffle/truffle.es6:15:17)
at Module._compile (module.js:456:26)
at normalLoader (/home/vagrant/truffle/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) as .es6
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at Object. (/home/vagrant/truffle/node_modules/babel/lib/_babel-node.js:144:25)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3

How do you send ether?

How do you do a sendTransaction to simply send ether from one account to another in ether-pudding?

In web3 you would do this:

web3.eth.sendTransaction({ from: a, to: b, value: 100 })

I would like the promisey goodness of ether-pudding though.

Endless RPC Call loop on return

Setup:
web3: 0.12.0
pudding: 0.10.0
testrpc: 0.1.14

I've got a problem with the following contract:

contract Store {
  uint value;

  function Store(){
    value = 9;
  }

  function query() constant returns (uint val) {
    return value;
  }
}

and the following JS Code:

Store
  .new({ from: web3.eth.coinbase, data: Store.binary })
  .then( function( instance ){
    return instance.query();
  }).then(function( v ){
    console.log( v );
  });

The strange thing is: as log as the value in Store is set to 0-9, Pudding shows the behavior described here: #4
If the value is set to 10 and above. Pudding works fine.
This is probably caused here: https://github.com/ConsenSys/ether-pudding/blob/master/build/ether-pudding.js#L244 as the response( tx ) is an BigNumber Object and not a transaction hash. But I have still to figure out why this works with value=10

Strict operator comparison and CamelCase output inside of any `.sol.js`

Issue

Strict operator comparison output inside of any .sol.js

Steps to Reproduce

Run StandardJS standard --fix against any compiled .sol.js file

Expected Behavior

No warnings

Actual Results

environments/test/contracts/SOMECONTRACT.sol.js:56:21: Expected '!==' and instead saw '!='
environments/test/contracts/Status.sol.js:6:7: Identifier 'contract_data' is not in camel case.

This may be a solidity compiler issue and not Ether-Pudding.
Community has standardized on strict equality due to "truthiness complexity"
http://dorey.github.io/JavaScript-Equality-Table/

CamelCase in JS is stylistic and will not effect computation - optional but should be fixed

Environment

  • Operating System: MAC OSX 10.11.6
  • StandardJS version: 8.0.0-beta.5
  • node version: v6.2.2
  • npm version: 3.9.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.