Skip to content

Commit 87a8fc7

Browse files
committed
Merge branch 'develop'
2 parents e5a18eb + fc66ea9 commit 87a8fc7

29 files changed

+539
-63
lines changed

Gruntfile.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = (grunt) ->
2323
src: ['test/**/*.js']
2424

2525
grunt.loadTasks "tasks"
26-
require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks)
26+
require('matchdep').filterAll(['grunt-*','!grunt-cli']).forEach(grunt.loadNpmTasks)
2727

2828
grunt.registerTask 'default', ['clean']
2929
grunt.registerTask 'build', ['clean', 'coffee']

README.md

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ Embark is a framework that allows you to easily develop and deploy DApps.
77

88
With Embark you can:
99
* Automatically deploy contracts and make them available in your JS code. Embark watches for changes, and if you update a contract, Embark will automatically redeploy the contracts (if needed) and the dapp.
10+
* Use any build pipeline or tool you wish, including grunt and meteor.
1011
* Do Test Driven Development with Contracts using Javascript.
1112
* Easily deploy to & use decentralized systems such as IPFS.
13+
* Keep track of deployed contracts, deploy only when truly needed.
1214
* Quickly create advanced DApps using multiple contracts.
1315

1416
See the [Wiki](https://github.com/iurimatias/embark-framework/wiki) for more details.
1517

1618
Installation
1719
======
18-
Requirements: geth (1.0.0), solc (0.9.23), node (0.12.2) and npm
20+
Requirements: geth (1.0.0), solc (0.1.0) or serpent (develop), node (0.12.2) and npm
1921

2022
For specs: pyethereum, ethertdd.py
2123

@@ -49,6 +51,8 @@ This will automatically deploy the contracts, update their JS bindings and deplo
4951

5052
Note that if you update your code it will automatically be re-deployed, contracts included. There is no need to restart embark, refreshing the page on the browser will do.
5153

54+
note: for a demo using meteor do ```embark meteor_demo``` followed by ```embark deploy``` then ```meteor```
55+
5256
Creating a new DApp
5357
======
5458

@@ -62,7 +66,7 @@ DApp Structure
6266

6367
```Bash
6468
app/
65-
|___ contracts/ #solidity contracts
69+
|___ contracts/ #solidity or serpent contracts
6670
|___ html/
6771
|___ css/
6872
|___ js/
@@ -74,7 +78,7 @@ DApp Structure
7478
|___ contracts/ #contracts tests
7579
```
7680

77-
Solidity files in the contracts directory will automatically be deployed with embark run. Changes in any files will automatically be reflected in app, changes to contracts will result in a redeployment and update of their JS Bindings
81+
Solidity/Serpent files in the contracts directory will automatically be deployed with embark run. Changes in any files will automatically be reflected in app, changes to contracts will result in a redeployment and update of their JS Bindings
7882

7983
Using Contracts
8084
======
@@ -145,6 +149,7 @@ You can now deploy many instances of the same contract. e.g
145149
# config/contracts.yml
146150
development:
147151
Currency:
152+
deploy: false
148153
args:
149154
- 100
150155
Usd:
@@ -171,16 +176,44 @@ Contracts addresses can be defined, If an address is defined the contract wouldn
171176
...
172177
```
173178

179+
You can also define contract interfaces (Stubs) and actions to do on deployment
180+
181+
```Yaml
182+
development:
183+
DataSource:
184+
args:
185+
MyDataSource:
186+
args:
187+
instanceOf: DataSource
188+
Manager:
189+
stubs:
190+
- DataSource
191+
args:
192+
- $MyDataSource
193+
onDeploy:
194+
- Manager.updateStorage($MyDataSource)
195+
- MyDataSource.set(5)
196+
...
197+
```
198+
174199
Tests
175200
======
176201

177202
You can run specs with ```embark spec```, it will run any files ending *_spec.js under ```spec/```.
178203

179-
Embark includes a testing lib to fastly run & test your contracts in a EVM.
204+
Embark includes a testing lib to fastly run & test your contracts in a EVM.
180205

181206
```Javascript
182207
# spec/contracts/simple_storage_spec.js
183-
EmbarkSpec = require('embark-framework').Tests;
208+
Embark = require('embark-framework');
209+
Embark.init();
210+
Embark.blockchainConfig.loadConfigFile('config/blockchain.yml');
211+
Embark.contractsConfig.loadConfigFile('config/contracts.yml');
212+
213+
var files = ['app/contracts/simpleStorage.sol'];
214+
Embark.contractsConfig.init(files, 'development');
215+
216+
var EmbarkSpec = Embark.tests(files);
184217

185218
describe("SimpleStorage", function() {
186219
beforeAll(function() {
@@ -222,6 +255,7 @@ The environment is a specific blockchain configuration that can be managed at co
222255
rpc_port: 8101
223256
rpc_whitelist: "*"
224257
datadir: default
258+
chains: chains_staging.json
225259
network_id: 0
226260
console: true
227261
account:
@@ -231,7 +265,6 @@ The environment is a specific blockchain configuration that can be managed at co
231265
232266
See [Configuration](https://github.com/iurimatias/embark-framework/wiki/Configuration).
233267
234-
235268
Deploying only contracts
236269
======
237270
Although embark run will automatically deploy contracts, you can choose to only deploy the contracts to a specific environment
@@ -242,6 +275,26 @@ $ embark deploy privatenet
242275

243276
embark deploy will deploy all contracts at app/contracts and return the resulting addresses
244277

278+
Structuring Application
279+
======
280+
281+
Embark is quite flexible and you can configure you're own directory structure using ```embark.yml```
282+
283+
```Yaml
284+
# embark.yml
285+
type: "manual" #other options: meteor, grunt
286+
contracts: ["app/contracts/**/*.sol", "app/contracts/**/*.se"] # contracts files
287+
output: "src/embark.js" # resulting javascript interface
288+
blockchainConfig: "config/blockchain.yml" # blockchain config
289+
contractsConfig: "config/contracts.yml" # contracts config
290+
```
291+
292+
Deploying to IPFS
293+
======
294+
295+
To deploy a dapp to IPFS, all you need to do is run a local IPFS node and then run ```embark ipfs```.
296+
If you want to deploy to the live net then after configuring you account on ```config/blockchain.yml``` on the ```production``` environment then you can deploy to that chain by specifying the environment ```embark ipfs production```.
297+
245298
LiveReload Plugin
246299
======
247300

@@ -255,5 +308,19 @@ Because embark is internally using grunt tasks, debugging is not straightforward
255308
- normally you would write something like `node-debug -p 7000 embark -- deploy`
256309
- This gives you nothing with embark. If you look at `deploy` command in [`./bin/embark`](https://github.com/iurimatias/embark-framework/blob/develop/bin/embark#L32-L35) you will notice that it internally runs grunt task `grunt deploy_contracts:[env]`
257310
- with this knowledge we can prepare proper command to start debugging
258-
- `node-debug -p 7000 grunt -- deploy_contracts:development`
259-
- [here](https://github.com/iurimatias/embark-framework/blob/develop/tasks/tasks.coffee) is list of all debuggable grunt tasks
311+
- ```node-debug -p 7000 grunt -- deploy_contracts:development```
312+
313+
314+
[here](https://github.com/iurimatias/embark-framework/blob/develop/tasks/tasks.coffee) is list of all debuggable grunt tasks
315+
316+
EACCESS Error
317+
======
318+
If you get EACCES (access denied) errors, don't use sudo, try this:
319+
320+
```Bash
321+
$ mkdir ~/npm-global
322+
$ npm config set prefix ~/npm-global
323+
$ echo 'export PATH="$PATH:$HOME/npm-global/bin"' >>~/.bashrc
324+
$ source ~/.bashrc
325+
$ npm install -g embark-framework grunt-cli
326+
```

bin/embark

100644100755
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var wrench = require('wrench');
66
var grunt = require('grunt');
77
require('shelljs/global');
88
var readYaml = require('read-yaml');
9-
var Embark = require('embark-framework');
9+
var Embark = require('..');
1010

1111
var run = function(cmd) {
1212
if (exec(cmd).code != 0) {
@@ -17,22 +17,19 @@ var run = function(cmd) {
1717
var deploy = function(env, embarkConfig) {
1818
var contractFiles = grunt.file.expand(embarkConfig.contracts);
1919
var destFile = embarkConfig.output;
20-
var chainFile = embarkConfig.chains;
2120

2221
Embark.init();
2322
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig);
2423
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig);
2524

26-
if (chainFile === undefined) {
27-
chainFile = './chains.json';
28-
}
25+
var chainFile = Embark.blockchainConfig.blockchainConfig[env].chains || embarkConfig.chains || './chains.json';
2926

3027
abi = Embark.deployContracts(env, contractFiles, destFile, chainFile);
3128
grunt.file.write(destFile, abi);
3229
}
3330

3431
program
35-
.version('0.8.4')
32+
.version('0.9.1')
3633

3734
program.command('new [name]').description('New application').action(function(name) {
3835
if (name === undefined) {
@@ -132,13 +129,24 @@ program.command('blockchain [env]').description('run blockchain').action(functio
132129
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
133130
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
134131

135-
//TODO: better with --exec, but need to fix console bug first
136-
wrench.copyDirSyncRecursive(__dirname + "/../js", "/tmp/js", {forceDelete: true});
132+
Embark.copyMinerJavascriptToTemp();
137133

138134
Embark.startBlockchain(env, true);
139135
}
140136
});
141137

138+
program.command('geth <env> [args...]').description('run geth with specified arguments').action(function(env_, args_) {
139+
var env = env_ || 'development';
140+
var embarkConfig = readYaml.sync("./embark.yml");
141+
var args = args_.join(' ');
142+
143+
Embark.init()
144+
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
145+
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
146+
147+
Embark.geth(env, args);
148+
});
149+
142150
program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() {
143151
var boilerPath = path.join(__dirname + '/../boilerplate');
144152
var demoPath = path.join(__dirname + '/../demo');
@@ -169,4 +177,3 @@ if (!process.argv.slice(2).length) {
169177
}
170178

171179
exit();
172-

boilerplate/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
chains/development.json

boilerplate/Gruntfile.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = (grunt) ->
3333
contracts:
3434
src: [
3535
"app/contracts/**/*.sol"
36+
"app/contracts/**/*.se"
3637
]
3738

3839
coffee:

boilerplate/config/blockchain.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ development:
55
minerthreads: 1
66
genesis_block: config/genesis/dev_genesis.json
77
datadir: /tmp/embark
8+
chains: config/chains/development.json
89
mine_when_needed: true
910
max_peers: 0
1011
gas_limit: 500000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

boilerplate/config/genesis/dev_genesis.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"nonce": "0x0000000000000042",
3-
"difficulty": "0x40000",
3+
"difficulty": "0x0",
44
"alloc": {
5+
"0x3333333333333333333333333333333333333333": {"balance": "15000000000000000000"}
56
},
67
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
7-
"coinbase": "0x0000000000000000000000000000000000000000",
8+
"coinbase": "0x3333333333333333333333333333333333333333",
89
"timestamp": "0x00",
910
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
1011
"extraData": "0x",

boilerplate/embark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type: "grunt" #other options: meteor, manual
2-
#contracts: ["app/contracts/**/*.sol"]
2+
#contracts: ["app/contracts/**/*.sol", "app/contracts/**/*.se"]
33
#output: "src/embark.js"
44
#blockchainConfig: "config/blockchain.yml"
55
#contractsConfig: "config/contracts.yml"

boilerplate/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
"license": "ISC",
1111
"homepage": "",
1212
"devDependencies": {
13-
"embark-framework": "^0.8.4",
14-
"grunt-embark": "^0.3.0",
13+
"embark-framework": "^0.9.1",
14+
"grunt-embark": "^0.4.1",
1515
"grunt-contrib-clean": "^0.6.0",
1616
"grunt-contrib-coffee": "^0.13.0",
1717
"grunt-contrib-concat": "^0.5.1",

0 commit comments

Comments
 (0)