Commit Graph

5306 Commits

Author SHA1 Message Date
Anthony Laibe 0ddebc7a80 fix: using async with async npm 2019-01-30 09:53:45 +00:00
Jonathan Rainville 4023392ea9 feat(generattion): remove web3 generation to let EmbarkJS handle it 2019-01-28 16:21:45 -05:00
Jonathan Rainville 52aebebf9e feat(dapp-config): add dapp connection to dapp config (artifact) 2019-01-28 16:21:45 -05:00
Jonathan Rainville 1543f6ad41 feat(contract): contracts can point to an artifact file to bypass deploy and compile 2019-01-25 17:34:21 -05:00
Anthony Laibe daf6e6426b fix: allow to use embark in dev deps 2019-01-25 17:32:23 -05:00
Andre Medeiros 387d33a076 fix: warn when contract bytecode too large for EVM 2019-01-25 17:31:17 -05:00
Andre Medeiros afe2512eff fix: swarm command registers and warns when swarm is disabled 2019-01-25 17:27:56 -05:00
Andre Medeiros e36ea5d24d fix: command handlers named consistently
Now they're named following a `noun:[noun:]verb` convention.
2019-01-25 17:27:39 -05:00
Andre Medeiros 43fed4f3e5 fix(@embark/cockpit): fix gas estimation 2019-01-25 17:27:31 -05:00
Jonathan Rainville 1d459e45b1 feat(deployer): add event to return the contract send object 2019-01-25 17:27:14 -05:00
Iuri Matias d1ff3ed33a feature(@debugger) improve display of debugger variables 2019-01-25 17:24:15 -05:00
Anthony Laibe 0e01e3d846 PR feedback 2019-01-25 16:37:09 -05:00
Anthony Laibe e8da329d60 feat: avoid infinite loop 2019-01-25 16:37:09 -05:00
Anthony Laibe 29db66be23 feat: import resolver 2019-01-25 16:37:09 -05:00
Jonathan Rainville 0d8f23303a fix(generator): fix warnAboutMetamask being undefined 2019-01-25 14:32:05 -05:00
Thiago F. Alencar a3da5c0b5b docs(@embark/): Fixes 'Optionnal' typo in templates/ and contract.js examples 2019-01-25 11:31:03 -05:00
Anthony Laibe 7ac27a0f93 fix: first parallel deploy
Zero is falsy
2019-01-24 12:04:41 -05:00
Anthony Laibe 5968eef349 fix: simulator proxy with ws 2019-01-24 09:08:55 +00:00
emizzle 2613e6d683 feat(@embark/core): Recursively import contracts
Add support to recursively import contracts. If we have three contracts

1. A imports B
2. B imports C

Then prior to this PR, contract A would import contract B, and a remapping would be added to the contract so the compiler would know how to find contract B. However, contract B imports contracts C, and because the `parseFileForImport` method was not recursive, the remappings were not able to go one level deeper to remap the path to contract C, and thus the compiler would not know how to locate contract C, and would complain with the error `File outside of allowed directories.`

With the introduction of this PR, the `parseFileForImport` method is now recursive, and so any contract imported is also checked for it's own imports that can be remapped. Specifically, this use case is applicable when there is a dependency containing contracts that imports one of it's own dependency's contracts, ie:

```
pragma solididty ^0.5.0;

import "dependency-1/contract-1.sol";
```
where the dependencies look like:
```
|- node_modules
|--- dependency-1
|----- contract-1.sol <--- contains import "dependency-2/contract-2.sol"
|--- dependency-2
|----- contract-2.sol
```

Add unit tests that verify recursive imports work.
Add embark depdendency that installs a contract used in the recursive unit tests.
2019-01-22 14:46:38 +11:00
emizzle 02305fa4e5 fix(@embark/core): Fix contract testing with `remix_tests`
Remix_test-injected contract files were not correctly being tested due to an update in the `remix-tests` signature. I'm really not sure how tests were not completely bombing out during testing.

This PR introduces a few changes:

1. Ensure all contract files have been compiled before skipping compilation. This can occur if contract files have been added after a compilation round has already completed (ie in the tests).
2. Update solc tests to support latest `remix_tests.runTests` signature and include `userdoc` in compiled contracts.
3. Ensure `EmbarkJS` is reset before executing solc tests - like in the js tests, this is required for built EmbarkJS contract objects to behave correctly when it's functions are executed against the chain.
4. Refactor “all files already compiled” function.

BLOCKER: base branch `feat/replace-node-vm` must be merged in https://github.com/embark-framework/embark/pull/1234 before this can be merged.
2019-01-22 14:46:06 +11:00
emizzle c1a5bfee3c feat(@embark/core): Improve VM
Improve support for external requires. Allows external requires to be called like so:
```
Embark.events.on('runcode:ready', () => {
    Embark.events.emit('runcode:register', 'generateClass', require('eth-contract-class'), false);

    Embark.registerCustomContractGenerator(contract => {
      return `
        ${contract.className} = generateClass(${JSON.stringify(contract.abiDefinition)}, '${contract.code}');
        ${contract.className}Instance = new ${contract.className}(web3, '${contract.deployedAddress}');
        `;
    });
  });
  Embark.events.once('contracts:deploy:afterAll', () => {
    Embark.events.request('runcode:eval', 'SimpleStorageInstance', (err, SimpleStorageInstance) => {
      if(err) return console.error(err);
      SimpleStorageInstance.get().then((result) => {
        console.log(`=====> SimpleStorageInstance.get(): ${result}`);
      });
    });
  });
```

* Add `runcode:ready` that is fired when the VM is ready to accept registration of variables.
* Add support for registration of ES6 modules
* Add callback to `registerVar` and `setupNodeVm` in the `VM` class.
* Add support for retaining modified sandbox values across new VM instances.
* Add VM unit tests for external reaquries and modified sandbox state.
2019-01-22 10:26:32 +11:00
Jonathan Rainville df872fdd5b feat(compiler): add a new compiler api that checks for compatibility 2019-01-18 09:03:39 -05:00
Pascal Precht e72d6483df feat(@cockpit/transaction-decoder): allow for decoding raw transaction hashes 2019-01-17 10:40:33 +01:00
Anthony Laibe eab9aa57d7 feat(embark-ui): add storybook 2019-01-16 09:03:57 +00:00
Anthony Laibe 85db678f89 chores: rename env var 2019-01-16 09:03:46 +00:00
emizzle 9a9eb45836 feat(@embark/core): Run all code in VM2
All code to be run in the console is run through a completely sandboxed VM2 instance, instead of the default Node VM.

VM2 will only allow whitelisted packages in a `require` statement. The whitelisted packages needed to run EmbarkJS scripts are:
```
[
  "@babel/runtime-corejs2/helpers/interopRequireDefault",
  "@babel/runtime-corejs2/core-js/json/stringify",
  "@babel/runtime-corejs2/core-js/promise",
  "@babel/runtime-corejs2/core-js/object/assign",
  "eth-ens-namehash"
]
```

This can be circumvented in an Embark context (ie Plugin) if needed, for example in a Plugin constructor:
```
Embark.events.emit('runcode:register', 'require', require('lodash'), false);

Embark.events.request("runcode:eval", "_.head(['a', 'b', 'c', 'd']);", (err, result) => {
  if(err) return console.log('========> error: ' + err);
  console.log('========> ' + result);
});
```
Will emit `========> a`.

NOTE: Attempts to use this method to override `require` and `eval` should be handled by Embark and not allowed.

NOTE: VM2 seems to allow `eval`, however it is in a completely sandboxed environment, so I'm unsure that we need to be too concerned with this. Thoughts?

Refactor tests to use standalone instance of the newly created VM class, so that code is not evaluated through the console. This was done based on the new unit test case where accounts are redefined in a subsequent unit test, which was not originally working with the initial VM2 PR.

Refactor `codeRunner`, put all code-affecting logic in the `VM` class.

Changed `runCode` to `VM` and converted to TypeScript

Add unit tests for `VM`.
2019-01-16 10:16:54 +11:00
Jonathan Rainville bdb6719baf Revert "feat(blockchain/config): adds a cors command to add it to the config"
This reverts commit ebafe45f22.
2019-01-14 08:29:21 -05:00
Jonathan Rainville 84a74ac4a2 feat(blockchain/config): adds a cors command to add it to the config 2019-01-14 08:29:21 -05:00
Jonathan Rainville 1bafc41d97 change to use an object instead and change templates 2019-01-14 08:29:21 -05:00
Jonathan Rainville 9e349ff267 feat(blockchainConfig): enable having auto cors plus other origins 2019-01-14 08:29:21 -05:00
Jonathan Rainville 540ff751a9 fix(code-generator): use isDev instead of checking env 2019-01-14 10:33:42 +01:00
Anthony Laibe 1e4eaa5fb6 fix: allow to debug instanceOf contracts 2019-01-14 10:33:08 +01:00
emizzle 518d319917 fix(@embark/ipfs): Update IPFS config CORS with default config
Check if IPFS config has `API.HTTPHeaders.Access-Control-Allow-Origin` before attempting to update it.

`ipfs init` produces a default configuration without a `API.HTTPHeaders.Access-Control-Allow-Origin` element in the JSON. This caused an error to be thrown when attempting to update the IPFS config to provide CORS values.
2019-01-13 15:51:34 +01:00
Eric Mastro 05803fcf42
Merge pull request #1220 from embark-framework/feat/enable-regular-txs
feat(@embark/core): Disable regular txs until needed
2019-01-11 23:38:50 +11:00
Anthony Laibe 52d830a34b feat: allow to stop debugger 2019-01-11 11:46:50 +00:00
Iuri Matias 2d716e1101 chore(release): 4.0.0-beta.0 2019-01-10 13:07:10 -05:00
Anthony Laibe 34f5f97b28 feat: add option --no-single-use-cockpit-token
This option is added to run and console.
This can be usefull while developing on cockpit,
the auto reload don't always ask to authenticate
2019-01-10 12:05:01 +00:00
emizzle 135fde0a85 feat(@embark/core): Disable regular txs until needed
Regular transactions (aka “dev funds”) exist in embark as a workaround to a known bug in geth when using metamask. The workaround is to send a transaction at a regular interval (1.5s), which pushes through any transactions that were stuck. The problem is that the transaction logs and trace logs become cluttered and difficult to parse visually.

This PR disables regular transactions until the following conditions are met:
1. Embark is running geth
2. The user is running metamask in their browser
3. The user authenticates to the cockpit with `enableRegularTxs=1|true` in the query string.

A console warning is show in large letters in the browser with a link to the cockpit URL that includes the special query string to enable regular txs.

This could be extended later to have a button in the cockpit that start/stops regular txs. Or at least extended to allow disabling of regular txs once started.

Support standalone blockchain process.
2019-01-10 12:43:18 +11:00
Anthony Laibe 8efa8895aa feat: allow cockpit with docker 2019-01-09 17:35:28 -05:00
Anthony Laibe 2505fa5284 feat: add development mode to cockpit 2019-01-09 17:34:13 -05:00
emizzle 2613c56da7 feat(@embark-ui): Change page title and description
Update page title and description tags in the page head when the view changes.
2019-01-09 17:27:55 -05:00
Jonathan Rainville d0711305fc fix(contracts): fix linking libraries with long paths using output 2019-01-09 17:13:08 -05:00
Michael Bradley, Jr 2dea50ab13 fix(@embark/coderunner): use custom require function in vm context
Supply a custom require function to the vm context for `doEval` so that module
resolution succeeds for both DApp dependencies and Embark dependencies.
2019-01-09 17:12:16 -05:00
emizzle c6c6af01c9 Expose embark version to plugin constructor
Expose Embark’s version to the plugin constructor, allowing plugins to make logical decisions based on the version of Embark.
2019-01-09 16:56:47 -05:00
emizzle f54982254d fix(@embark/core): fix to allow large ether values
Specifying large ether values in the configs was causing embark to crash as javascript could not handle the large integer after the value was converted to wei.

The fix involves converting all values to BigNumbers and then comparing and adding/subtracting BigNumbers from that point forward.

There are two specific components that this affected: `config/contracts > accounts > balance` and `config/blockchain > account > balance`. The contracts config is used to fund accounts for contract deployment while the blockchain config is used for dev_funds accounts.

JSON.stringify unknown log messages

Add a unit test in the test app that sets a large ether value in the config before contract deployment and ensures the account balance is the value specified in the config.

Prior to this commit, if subsequent unit tests contained different account configurations, the blockchain VM was essentially reset, however EmbarkJS was hanging on to the old providers it used from the previous configuation.

In addition, there is a limitation with `embark.registerActionForEvent` in that the action will be persisted across configuration changes. In our case, once the configuration was updated in a subsequent unit test, the directive subdomains would be attempted to be registered in ENS using the old configuration.

This commit does two things:
1) It resets the EmbarkJS.Blockchain and EmbarkJS.Names providers to the new chain configuration
2) Update to the ENS directives that prevents attempts at registered configured subdomains for previous configurations.
2019-01-09 16:56:23 -05:00
Anthony Laibe d67863cff6 feat: add API server 2019-01-09 14:11:03 +00:00
Anthony Laibe df3435f02b feat: coverage without emit
For solc version below 0.4.21

fixes #1230
2019-01-09 13:44:48 +00:00
Jonathan Rainville 749c32cf07 fix(blockchain): fix metamask using the old web3 2019-01-08 09:24:13 -05:00
Michael Bradley, Jr 919d271996 feat(@embark/cli): unify command history without needing a restart
Send a message over IPC when a command is executed from the REPL so that
command history is immediately unified across `embark run` and one/more `embark
console`. Previously, for `embark console` to pick up a command entered in the
REPL of an `embark run` of which it was an IPC client it would have to be
restarted, and vice versa.
2019-01-07 17:02:28 -06:00
Iuri Matias 39d5e9f205 chore(release): 4.0.0-alpha.3 2018-12-31 15:10:59 -05:00