Skip to content

Commit e1262f0

Browse files
committed
Changes to be committed: AE NPM Project Initialisation
1 parent a42201c commit e1262f0

20 files changed

+285
-104
lines changed

.gitignore

+4-104
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,4 @@
1-
# Logs
2-
logs
3-
*.log
4-
npm-debug.log*
5-
yarn-debug.log*
6-
yarn-error.log*
7-
lerna-debug.log*
8-
9-
# Diagnostic reports (https://nodejs.org/api/report.html)
10-
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11-
12-
# Runtime data
13-
pids
14-
*.pid
15-
*.seed
16-
*.pid.lock
17-
18-
# Directory for instrumented libs generated by jscoverage/JSCover
19-
lib-cov
20-
21-
# Coverage directory used by tools like istanbul
22-
coverage
23-
*.lcov
24-
25-
# nyc test coverage
26-
.nyc_output
27-
28-
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29-
.grunt
30-
31-
# Bower dependency directory (https://bower.io/)
32-
bower_components
33-
34-
# node-waf configuration
35-
.lock-wscript
36-
37-
# Compiled binary addons (https://nodejs.org/api/addons.html)
38-
build/Release
39-
40-
# Dependency directories
41-
node_modules/
42-
jspm_packages/
43-
44-
# TypeScript v1 declaration files
45-
typings/
46-
47-
# TypeScript cache
48-
*.tsbuildinfo
49-
50-
# Optional npm cache directory
51-
.npm
52-
53-
# Optional eslint cache
54-
.eslintcache
55-
56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
62-
# Optional REPL history
63-
.node_repl_history
64-
65-
# Output of 'npm pack'
66-
*.tgz
67-
68-
# Yarn Integrity file
69-
.yarn-integrity
70-
71-
# dotenv environment variables file
72-
.env
73-
.env.test
74-
75-
# parcel-bundler cache (https://parceljs.org/)
76-
.cache
77-
78-
# Next.js build output
79-
.next
80-
81-
# Nuxt.js build / generate output
82-
.nuxt
83-
dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
90-
91-
# vuepress build output
92-
.vuepress/dist
93-
94-
# Serverless directories
95-
.serverless/
96-
97-
# FuseBox cache
98-
.fusebox/
99-
100-
# DynamoDB Local files
101-
.dynamodb/
102-
103-
# TernJS port file
104-
.tern-port
1+
node_modules
2+
.aeproject-store
3+
.DS_Store
4+
package-lock.json

contracts/ExampleContract.aes

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
contract CryptoHamster =
2+
datatype event = NewHamster(indexed int, string, hash)
3+
4+
record state = { hamsters : map(string, hash), next_id : int }
5+
6+
stateful entrypoint init() = { hamsters = {}, next_id = 0 }
7+
8+
entrypoint nameExists(name: string) : bool =
9+
Map.member(name, state.hamsters)
10+
11+
stateful entrypoint createHamster(hamsterName: string) =
12+
require(!nameExists(hamsterName), "Name is already taken")
13+
createHamsterByNameDNA(hamsterName, generateDNA(hamsterName))
14+
15+
entrypoint getHamsterDNA(hamsterName: string) : hash =
16+
require(nameExists(hamsterName), "Hamster does not exist!")
17+
state.hamsters[hamsterName]
18+
19+
stateful function createHamsterByNameDNA(name: string, dna: hash) =
20+
put(state{hamsters[name] = dna, next_id = (state.next_id + 1)})
21+
Chain.event(NewHamster(state.next_id, name, dna))
22+
23+
function generateDNA(name : string) : hash =
24+
String.sha3(name)

deployment/deploy.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* ISC License (ISC)
3+
* Copyright (c) 2018 aeternity developers
4+
*
5+
* Permission to use, copy, modify, and/or distribute this software for any
6+
* purpose with or without fee is hereby granted, provided that the above
7+
* copyright notice and this permission notice appear in all copies.
8+
*
9+
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10+
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11+
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
12+
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13+
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
14+
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15+
* PERFORMANCE OF THIS SOFTWARE.
16+
*/
17+
const Deployer = require('aeproject-lib').Deployer;
18+
19+
const deploy = async (network, privateKey, compiler, networkId) => {
20+
let deployer = new Deployer(network, privateKey, compiler, networkId)
21+
22+
await deployer.deploy("./contracts/ExampleContract.aes")
23+
};
24+
25+
module.exports = {
26+
deploy
27+
};

docker-compose.compiler.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: '3'
2+
services:
3+
compiler:
4+
hostname: compiler
5+
image: 'aeternity/aesophia_http:${COMPILER_TAG}'
6+
ports:
7+
- '3080:3080'

docker-compose.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
version: '3'
2+
services:
3+
node1:
4+
image: 'aeternity/aeternity:${NODE_TAG}'
5+
hostname: node1
6+
environment:
7+
AETERNITY_CONFIG: /home/aeternity/aeternity.yaml
8+
command: |
9+
bin/aeternity console -noinput -aehttp enable_debug_endpoints true
10+
volumes:
11+
- './docker/aeternity_node1_mean15.yaml:/home/aeternity/aeternity.yaml'
12+
- './docker/keys/node1:/home/aeternity/node/keys'
13+
proxy:
14+
image: 'nginx:1.13.8'
15+
hostname: proxy
16+
ports:
17+
- '3001:3001'
18+
- '3002:3002'
19+
- '3003:3003'
20+
volumes:
21+
- './docker/nginx-default.conf:/etc/nginx/conf.d/default.conf'
22+
- './docker/nginx-cors.conf:/etc/nginx/cors.conf'
23+
- './docker/nginx-ws.conf:/etc/nginx/ws.conf'
24+
volumes:
25+
node1_db: null
26+
node1_keys: null

docker/aeternity_node1_mean15.yaml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
peers:
3+
- aenode://pp_28uQUgsPcsy7TQwnRxhF8GMKU4ykFLKsgf4TwDwPMNaSCXwWV8@node2:3015
4+
- aenode://pp_Dxq41rJN33j26MLqryvh7AnhuZywefWKEPBiiYu2Da2vDWLBq@node3:3015
5+
6+
http:
7+
external:
8+
port: 3013
9+
internal:
10+
debug_endpoints: true
11+
port: 3113
12+
listen_address: 0.0.0.0
13+
14+
15+
websocket:
16+
channel:
17+
listen_address: 0.0.0.0
18+
port: 3014
19+
20+
keys:
21+
peer_password: "top secret"
22+
dir: ./keys
23+
24+
chain:
25+
persist: true
26+
hard_forks:
27+
"1": 0
28+
"2": 1
29+
"3": 2
30+
"4": 3
31+
32+
33+
mining:
34+
autostart: true
35+
beneficiary: "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU"
36+
beneficiary_reward_delay: 2
37+
expected_mine_rate: 4000
38+
micro_block_cycle: 1000
39+
cuckoo:
40+
miner:
41+
executable: mean15-generic
42+
extra_args: ""
43+
edge_bits: 15
44+
45+
fork_management:
46+
network_id: "ae_devnet"
47+
48+

docker/entrypoint.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Using console with extra arguments because "foreground" does not handle SIGTERM/SIGQUIT
5+
exec ./bin/aeternity console -noshell -noinput $@

docker/healthcheck.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
# As this script might be used as docker health check it should exit with either 0/1
4+
5+
EXTERNAL_ADDRESS=${EXTERNAL_ADDRESS:-localhost:3013}
6+
MIN_PEERS=${MIN_PEERS:-2}
7+
8+
curl -s -f -S -o /dev/null --retry 6 http://${EXTERNAL_ADDRESS}/v2/blocks/top || exit 1
9+
10+
if [ -z $INTERNAL_ADDRESS ]; then
11+
exit 0
12+
fi
13+
14+
PEERS_COUNT=$(curl -s -S ${INTERNAL_ADDRESS}/v2/debug/peers | grep -o aenode | wc -l)
15+
16+
# Explicit exit because otherwise test would exit with status 127
17+
test $PEERS_COUNT -ge $MIN_PEERS || exit 1

docker/keys/beneficiary/key

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2�|�[2�1��F�_�衧'm�]�$t'�Za�Ԏ>�1,Bc#��>^aj����tLǕSJ�8�zM�

docker/keys/beneficiary/key.pub

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�>�1,Bc#��>^aj����tLǕSJ�8�zM�

docker/keys/node1/peer_key

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�(.�G �QR��;l,m�h5� <\��W�5�

docker/keys/node1/peer_key.pub

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
���G~@>��n�&^F�r�������V�J��

docker/keys/node1/sign_key

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
�{�7�6�A���޵�O0�5e�o�a}�t��P%�M�)g�`��7�)?Y��M�v���<������

docker/keys/node1/sign_key.pub

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
%�M�)g�`��7�)?Y��M�v���<������

docker/nginx-cors.conf

Whitespace-only changes.

docker/nginx-default.conf

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
server {
2+
listen 3001;
3+
4+
location / {
5+
include cors.conf;
6+
proxy_pass http://node1:3013/;
7+
}
8+
9+
location /internal/ {
10+
include cors.conf;
11+
proxy_pass http://node1:3113/;
12+
}
13+
14+
location /channel {
15+
include cors.conf;
16+
include ws.conf;
17+
proxy_pass http://node1:3014;
18+
}
19+
}

docker/nginx-ws.conf

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
proxy_http_version 1.1;
2+
proxy_set_header Upgrade "websocket";
3+
proxy_set_header Connection "upgrade";
4+
proxy_connect_timeout 15s;
5+
proxy_send_timeout 2h;
6+
proxy_read_timeout 2h;
7+
proxy_pass_request_headers on;

integrations/contractsAeppSettings.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// export default {"account":{"pub":"ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU","priv":"bb9f0b01c8c9553cfbaf7ef81a50f977b1326801ebf7294d1c2cbccdedf27476e9bbf604e611b5460a3b3999e9771b6f60417d73ce7c5519e12f7e127a1225ca"},"url":"http://localhost:3001/","internalUrl":"http://localhost:3001//internal/","host":"http://localhost:3001/","internalHost":"http://localhost:3001/internal/"}
2+
module.exports = {
3+
"account": {
4+
"pub": "ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU",
5+
"priv": "bb9f0b01c8c9553cfbaf7ef81a50f977b1326801ebf7294d1c2cbccdedf27476e9bbf604e611b5460a3b3999e9771b6f60417d73ce7c5519e12f7e127a1225ca"
6+
},
7+
"url": "http://localhost:3001/",
8+
"internalUrl": "http://localhost:3001/internal/",
9+
"host": "http://localhost:3001/",
10+
"internalHost": "http://localhost:3001/internal/"
11+
}

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "aeproject-project",
3+
"version": "1.0.0",
4+
"description": "This is the default package.json generated for your project",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "mocha ./test/**/*.js --timeout 0 --exit",
8+
"aetest": "aeproject test"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"@aeternity/aepp-sdk": "7.0.0",
14+
"aeproject-lib": "^2.2.0"
15+
}
16+
}

0 commit comments

Comments
 (0)