Skip to content

Commit 8bc4c11

Browse files
committed
Merge branch 'develop'
2 parents 5e0b457 + c1113dd commit 8bc4c11

32 files changed

+444
-249
lines changed

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 iuri matias
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,39 @@ If you are using multiple contracts, you can pass a reference to another contrac
138138
...
139139
```
140140

141+
You can now deploy many instances of the same contract. e.g
142+
143+
144+
```Yaml
145+
# config/contracts.yml
146+
development:
147+
Currency:
148+
args:
149+
- 100
150+
Usd:
151+
instanceOf: Currency
152+
args:
153+
- "initial string"
154+
MyCoin:
155+
instanceOf: Currency
156+
args:
157+
- $SimpleStorage
158+
...
159+
```
160+
161+
Contracts addresses can be defined, If an address is defined the contract wouldn't be deployed but its defined address will be used instead.
162+
163+
164+
```Yaml
165+
development:
166+
UserStorage:
167+
address: 0x123456
168+
UserManagement:
169+
args:
170+
- $UserStorage
171+
...
172+
```
173+
141174
Tests
142175
======
143176

bin/embark

Lines changed: 80 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ var run = function(cmd) {
1414
}
1515
}
1616

17+
var deploy = fnction(embarkConfig) {
18+
contractFiles = grunt.file.expand(embarkConfig.contracts);
19+
destFile = embarkConfig.output
20+
Embark.init()
21+
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
22+
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
23+
abi = Embark.deployContracts(env, contractFiles, destFile)
24+
grunt.file.write(destFile, abi);
25+
}
26+
1727
program
18-
.version('0.5.0')
28+
.version('0.6.0')
1929

2030
program.command('new [name]').description('New application').action(function(name) {
2131
if (name === undefined) {
@@ -39,43 +49,87 @@ program.command('deploy [env]').description('deploy contracts').action(function(
3949
run("grunt deploy_contracts:" + env);
4050
}
4151
else {
42-
contractFiles = grunt.file.expand(embarkConfig.contracts);
43-
destFile = embarkConfig.output
44-
Embark.init()
45-
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
46-
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
47-
abi = Embark.deployContracts(env, contractFiles, destFile)
48-
grunt.file.write(destFile, abi);
52+
deploy();
4953
}
5054
});
5155

5256
program.command('build [env]').description('build dapp').action(function(env_) {
5357
var env = env_ || 'development';
54-
run("grunt clean");
55-
run("grunt deploy_contracts:" + env);
56-
run('grunt build:' + env);
58+
var embarkConfig = readYaml.sync("./embark.yml");
59+
60+
if (embarkConfig.type === "grunt") {
61+
run("grunt clean");
62+
run("grunt deploy_contracts:" + env);
63+
run('grunt build:' + env);
64+
}
65+
else if (embarkConfig.type === "meteor") {
66+
deploy();
67+
run("meteor-build-client ./build -p ''");
68+
}
5769
});
5870

5971
program.command('ipfs [env]').description('build dapp and make it available in ipfs').action(function(env_) {
6072
var env = env_ || 'development';
61-
run("grunt clean")
62-
run("grunt deploy_contracts:" + env)
63-
run('grunt build:' + env)
64-
run('grunt ipfs:' + env)
73+
var embarkConfig = readYaml.sync("./embark.yml");
74+
75+
if (embarkConfig.type === "grunt") {
76+
run("grunt clean")
77+
run("grunt deploy_contracts:" + env)
78+
run('grunt build:' + env)
79+
run('grunt ipfs:' + env)
80+
}
81+
else if (embarkConfig.type === "meteor") {
82+
deploy();
83+
run("meteor-build-client ./build -p ''");
84+
Embark.release.ipfs("build/")
85+
}
86+
else {
87+
console.log("command not available in manual mode yet");
88+
}
6589
});
6690

6791
program.command('run [env]').description('run dapp').action(function(env_) {
6892
var env = env_ || 'development';
69-
run('grunt deploy:' + env);
93+
var embarkConfig = readYaml.sync("./embark.yml");
94+
95+
if (embarkConfig.type === "grunt") {
96+
run('grunt deploy:' + env);
97+
}
98+
else {
99+
console.log("command not available in meteor or manual mode yet");
100+
console.log("try instead embark run");
101+
}
70102
});
71103

72104
program.command('spec').description('run specs').action(function() {
73-
run('jasmine');
105+
var embarkConfig = readYaml.sync("./embark.yml");
106+
107+
if (embarkConfig.type === "grunt") {
108+
run('jasmine');
109+
}
110+
else {
111+
console.log("command not available in meteor or manual mode yet");
112+
console.log("note: you can use embark tests with any framework");
113+
}
74114
});
75115

76116
program.command('blockchain [env]').description('run blockchain').action(function(env_) {
77117
var env = env_ || 'development';
78-
run('grunt blockchain:' + env);
118+
var embarkConfig = readYaml.sync("./embark.yml");
119+
120+
if (embarkConfig.type === "grunt") {
121+
run('grunt blockchain:' + env);
122+
}
123+
else {
124+
Embark.init()
125+
Embark.blockchainConfig.loadConfigFile(embarkConfig.blockchainConfig)
126+
Embark.contractsConfig.loadConfigFile(embarkConfig.contractsConfig)
127+
128+
//TODO: better with --exec, but need to fix console bug first
129+
wrench.copyDirSyncRecursive(__dirname + "/../js", "/tmp", {forceDelete: true});
130+
131+
Embark.startBlockchain(env, true);
132+
}
79133
});
80134

81135
program.command('demo').description('create a working dapp with a SimpleStorage contract').action(function() {
@@ -93,6 +147,14 @@ program.command('demo').description('create a working dapp with a SimpleStorage
93147
console.log('\n\ninit complete');
94148
});
95149

150+
program.command('meteor_demo').description('create a working meteor dapp with a SimpleStorage contract').action(function() {
151+
var boilerPath = path.join(__dirname + '/../demo_meteor');
152+
153+
var targetDir = "./embark_demo";
154+
wrench.copyDirSyncRecursive(boilerPath, targetDir);
155+
console.log('\n\ninit complete');
156+
});
157+
96158
program.parse(process.argv)
97159

98160
if (!process.argv.slice(2).length) {

boilerplate/Gruntfile.coffee

Lines changed: 95 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,102 @@
11
module.exports = (grunt) ->
22

3-
grunt.loadNpmTasks "embark-framework"
3+
grunt.loadNpmTasks "grunt-embark"
44

55
grunt.initConfig(
6-
@initEmbarkConfig(
7-
files:
8-
js:
9-
src: [
10-
"app/js/**/*.js"
11-
]
12-
13-
css:
14-
src: [
15-
"app/css/**/*.css"
16-
]
17-
18-
html:
19-
src: [
20-
"app/html/**/*.html"
21-
]
22-
23-
contracts:
24-
src: [
25-
"app/contracts/**/*.sol"
26-
]
27-
28-
concat:
29-
app:
30-
src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"]
31-
dest: "generated/dapp/js/app.min.js"
32-
css:
33-
src: "<%= files.css.src %>"
34-
dest: "generated/dapp/css/app.min.css"
35-
36-
copy:
37-
html:
38-
files:
39-
"generated/dapp/index.html" : "<%= files.html.src %>"
40-
"dist/dapp/index.html" : "<%= files.html.src %>"
41-
css:
42-
files:
43-
"dist/dapp/css/app.min.css" : "<%= files.css.src %>"
44-
contracts:
45-
files:
46-
"dist/contracts/": '<%= files.contracts.src %>'
47-
48-
deploy:
49-
contracts: '<%= files.contracts.src %>'
50-
dest: 'generated/tmp/abi.js'
51-
)
6+
files:
7+
web3:
8+
"node_modules/embark-framework/js/web3.js"
9+
10+
js:
11+
src: [
12+
"app/js/**/*.js"
13+
]
14+
15+
css:
16+
src: [
17+
"app/css/**/*.css"
18+
]
19+
20+
html:
21+
src: [
22+
"app/html/**/*.html"
23+
]
24+
25+
coffee:
26+
dest: "generated/dapp/compiled-coffee"
27+
compiled: [
28+
"generated/dapp/compiled-coffee/app.coffee"
29+
"generated/dapp/compiled-coffee/**/*.js"
30+
]
31+
32+
contracts:
33+
src: [
34+
"app/contracts/**/*.sol"
35+
]
36+
37+
coffee:
38+
compile:
39+
expand: true
40+
cwd: 'coffee'
41+
src: '**/*.coffee'
42+
dest: '<%= files.coffee.dest %>'
43+
ext: '.js'
44+
45+
concat:
46+
app:
47+
src: ["<%= files.web3 %>", 'generated/tmp/abi.js', "<%= files.js.src %>", "<%= files.coffee.compiled %>"]
48+
dest: "generated/dapp/js/app.min.js"
49+
css:
50+
src: "<%= files.css.src %>"
51+
dest: "generated/dapp/css/app.min.css"
52+
53+
watch:
54+
options:
55+
livereload: true
56+
57+
html:
58+
files: ["<%= files.html.src %>"]
59+
tasks: ["copy"]
60+
61+
js:
62+
files: ["<%= files.js.src %>"]
63+
tasks: ["concat"]
64+
65+
css:
66+
files: ["<%= concat.css.src %>"]
67+
tasks: ["concat"]
68+
69+
coffee:
70+
files: ["coffee/**/*.coffee"]
71+
tasks: ["coffee", "concat"]
72+
73+
contracts:
74+
files: ["<%= files.contracts.src %>"]
75+
tasks: ["deploy", "concat", "copy"]
76+
77+
copy:
78+
html:
79+
files:
80+
"generated/dapp/index.html" : "<%= files.html.src %>"
81+
"dist/dapp/index.html" : "<%= files.html.src %>"
82+
css:
83+
files:
84+
"dist/dapp/css/app.min.css" : "<%= files.css.src %>"
85+
contracts:
86+
files:
87+
"dist/contracts/": '<%= files.contracts.src %>'
88+
89+
uglify:
90+
dist:
91+
src: "<%= concat.app.dest %>" # input from the concat process
92+
dest: "dist/dapp/js/app.min.js"
93+
94+
clean:
95+
workspaces: ["dist", "generated"]
96+
97+
deploy:
98+
contracts: '<%= files.contracts.src %>'
99+
dest: 'generated/tmp/abi.js'
52100
)
53101

54102
# loading external tasks (aka: plugins)

boilerplate/embark.yml

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

boilerplate/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"license": "ISC",
1111
"homepage": "",
1212
"devDependencies": {
13-
"embark-framework": "^0.5.0",
13+
"embark-framework": "^0.6.0",
14+
"grunt-embark": "0.1.0",
1415
"grunt-contrib-clean": "^0.6.0",
1516
"grunt-contrib-coffee": "^0.13.0",
1617
"grunt-contrib-concat": "^0.5.1",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# This file contains information which helps Meteor properly upgrade your
2+
# app when you run 'meteor update'. You should check it into version control
3+
# with your project.
4+
5+
notices-for-0.9.0
6+
notices-for-0.9.1
7+
0.9.4-platform-file
8+
notices-for-facebook-graph-api-2

demo_meteor/.meteor/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local

demo_meteor/.meteor/.id

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file contains a token that is unique to your project.
2+
# Check it into your repository along with the rest of this directory.
3+
# It can be used for purposes such as:
4+
# - ensuring you don't accidentally deploy one app on top of another
5+
# - providing package authors with aggregated statistics
6+
7+
v2fbp61wvu7nd11xgkdz

0 commit comments

Comments
 (0)