Skip to content

Commit b7b89cc

Browse files
author
Kristjan Kosic
committed
Initial commit
0 parents  commit b7b89cc

19 files changed

+5487
-0
lines changed

.editorconfig

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true

.gitattributes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Path-based git attributes
2+
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
3+
4+
# Ignore all test and documentation with "export-ignore".
5+
/.editorconfig export-ignore
6+
/.gitattributes export-ignore
7+
/.gitignore export-ignore
8+
/.travis.yml export-ignore
9+
/__tests__ export-ignore
10+
/docs export-ignore
11+
/README.md export-ignore

.gitignore

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
lerna-debug.log
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
.coverage
17+
18+
# nyc test coverage
19+
.nyc_output
20+
21+
# vscode
22+
.vscode
23+
24+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
25+
.grunt
26+
27+
# node-waf configuration
28+
.lock-wscript
29+
30+
# Build results
31+
app.js
32+
33+
# Compiled binary addons (http://nodejs.org/api/addons.html)
34+
build/Release
35+
36+
# Dependency directories
37+
node_modules
38+
jspm_packages
39+
40+
# Generated doc directory
41+
doc
42+
docs
43+
44+
# Optional npm cache directory
45+
.npm
46+
package-lock.json
47+
48+
# Mac OS X local settings
49+
.DS_Store
50+
.tags
51+
bundle.min.js
52+
53+
# Build
54+
dist
55+
packages/**/dist/
56+
57+
# Microsoft Visual Studio settings
58+
.vs
59+
60+
# Databases
61+
*.sqlite
62+
63+
# Random
64+
docker/development
65+
66+
#Webstorm/Intellij
67+
.idea
68+
69+
# Vagrant
70+
.vagrant
71+
72+
# oclif
73+
tmp
74+
oclif.manifest.json
75+
npm-shrinkwrap.json
76+
77+
# Transaction Pool
78+
transaction-pool.sqlite
79+
transaction-pool.sqlite-shm
80+
transaction-pool.sqlite-wal
81+
82+
# P2P
83+
/peers.json
84+
85+
# vim, copied from https://github.com/github/gitignore/blob/master/Global/Vim.gitignore
86+
# Swap
87+
[._]*.s[a-v][a-z]
88+
!*.svg
89+
[._]*.sw[a-p]
90+
[._]s[a-rt-v][a-z]
91+
[._]ss[a-gi-z]
92+
[._]sw[a-p]
93+
# Session
94+
Session.vim
95+
Sessionx.vim
96+
# Temporary
97+
.netrwhist
98+
*~
99+
# Auto-generated tag files
100+
tags
101+
# Persistent undo
102+
[._]*.un~
103+
# end of vim

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7+
8+
## Unreleased

LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Ark Ecosystem <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
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, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+137
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# ARK Core - dApp Template Project
2+
3+
This is a basic template project for ARK core dApp development. Create a new project based on this template and load your plugin into the corresponding network configuration by following the steps below.
4+
5+
> This Example is currently operational only on our `core/develop` branch!
6+
7+
This template project provides initial structure for your dApp development.
8+
9+
## dApp Creation Steps
10+
11+
### STEP 0: Create New Project Based On This Template
12+
13+
### STEP 1: Checkout Your New dApp Project As a GitSubmodule in `core/plugins`
14+
15+
You should already have a running core and a local testnet running. If not head over to https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-2-testnet-network-boot.
16+
17+
```bash
18+
cd plugins/ #location for loading of custom non-core dApps
19+
git submodule add -f https://github.com/your-gh-handle/your-dapp-name
20+
cd your-dapp-name
21+
```
22+
23+
### STEP 2: Load The dApp In The Corresponding Network Configurations.
24+
25+
We will enable our dApp `@vendorname/dappname` in the testnet network configuration. dApp name is taken from `node` package name as defined in package.json.
26+
You can change it to your needs.
27+
28+
Go to:
29+
`core/packages/core/bin/testnet`
30+
31+
```bash
32+
cd packages/core/bin/config/testnet
33+
```
34+
35+
Locate file `plugins.js`. We will add our dApp name to end of the list of the loaded plugins. This means that core will pickup the dapp and load it for a specific network configuration.
36+
37+
Add line `"@arkecosystem/dappname": {}`: to the end of the `plugins.js` file, so it looks something like this:
38+
39+
```javascript
40+
"@arkecosystem/core-exchange-json-rpc": {
41+
enabled: process.env.CORE_EXCHANGE_JSON_RPC_ENABLED,
42+
host: process.env.CORE_EXCHANGE_JSON_RPC_HOST || "0.0.0.0",
43+
port: process.env.CORE_EXCHANGE_JSON_RPC_PORT || 8080,
44+
allowRemote: false,
45+
whitelist: ["127.0.0.1", "::ffff:127.0.0.1"],
46+
},
47+
"@arkecosystem/core-snapshots": {},
48+
"@vendorname/dappname": {}, //our application hook (here we load the plugin/dapp, as defined in your dapp package.json)
49+
```
50+
51+
> Make sure to run `yarn setup` from the `core` root folder when you change or add code to `core/plugins`
52+
53+
After `yarn setup` completes, you should see the following log
54+
55+
```bash
56+
lerna success - @arkecosystem/core-vote-report
57+
lerna success - @arkecosystem/core-wallet-api
58+
lerna success - @arkecosystem/core-webhooks
59+
lerna success - @arkecosystem/core
60+
lerna success - @arkecosystem/crypto
61+
lerna success - @vendorname/dappname
62+
```
63+
64+
Last line showing that your dApp was detected and compiled.
65+
66+
### STEP 3: Start Local Testnet Blockchain
67+
68+
Start local blockchain with testnet running on your developer computer. Follow steps defined in here:
69+
https://learn.ark.dev/core-getting-started/spinning-up-your-first-testnet#step-2-testnet-network-boot
70+
71+
If you already have running and compiled core, you should go to `core/packages/core` and run command `yarn full:testnet`.
72+
73+
After local testnet starts, the log should show that dApp was loaded. It should look like this (if you haven't changed the source code):
74+
75+
```bash
76+
[2019-10-22 11:13:27.161] INFO : Starting dApp
77+
[2019-10-22 11:13:27.161] INFO : Initialization of dApp
78+
```
79+
80+
> Congratulations. Your first distributed blockchain application is loaded and working and compatible with any ARK Core based blockchain.
81+
82+
Feel free to look into `common/base-service.ts` class that exposes important Core Platform classes that you can work with. Your newly developed classes can extend this class and gain access to:
83+
84+
- wallets and state
85+
- transaction pool
86+
- blockchain protocol
87+
- events
88+
- database
89+
-... actually any module :)
90+
91+
> Also check other packages/modules as they follow the same dApp structure.
92+
93+
## Use Block Explorer To View Local Running Testnet
94+
95+
The following code instructions will run a local copy of ARK Explorer and connect to local node.
96+
97+
```bash
98+
git clone https://github.com/arkecosystem/explorer
99+
cd explorer
100+
101+
yarn install
102+
103+
yarn serve:testnet
104+
```
105+
106+
After running `yarn serve:testnet` you should see the following:
107+
108+
```bash
109+
DONE Compiled successfully in 11030ms 11:07:14 AM
110+
111+
No type errors found
112+
Version: typescript 3.6.3
113+
Time: 6973ms
114+
115+
App running at:
116+
- Local: http://localhost:8080/
117+
- Network: http://192.168.0.178:8080/
118+
119+
Note that the development build is not optimized.
120+
To create a production build, run yarn build.
121+
```
122+
123+
Head over to http://localhost:8080/ to view contents of local running blockchain with Testnet environment setup.
124+
125+
---
126+
127+
> Congrats, your dapp is loaded. Now look at the resources below to understand more about our dapp development.
128+
129+
- [Learn Development With ARK](https://learn.ark.dev)
130+
131+
## Security
132+
133+
If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.
134+
135+
## License
136+
137+
[MIT](LICENSE) © [ArkEcosystem](https://ark.io)

__tests__/.gitkeep

Whitespace-only changes.

banner.png

713 KB
Loading

package.json

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"private": true,
3+
"name": "@vendorname/your-dapp-name",
4+
"description": "Your dApp description",
5+
"version": "0.0.1",
6+
"contributors": [
7+
"FirstName, LastName <[email protected]>"
8+
],
9+
"license": "MIT",
10+
"main": "dist/index.js",
11+
"files": [
12+
"dist"
13+
],
14+
"scripts": {
15+
"prepublishOnly": "yarn test && yarn build",
16+
"pretest": "yarn lint && yarn build",
17+
"compile": "../../node_modules/typescript/bin/tsc",
18+
"build": "yarn clean && yarn compile",
19+
"build:watch": "yarn clean && yarn compile -w",
20+
"clean": "del dist",
21+
"docs": "node_modules/typedoc/bin/typedoc src --out docs",
22+
"lint": "./node_modules/tslint/bin/tslint -c ./tslint.json -p ./tslint-config.json './src/**/*.ts' --fix",
23+
"format": "yarn lint && yarn prettier",
24+
"prettier": "prettier --write \"./*.{ts,js,json,md}\" \"./src/**/*.{ts,js,json,md}\" \"./__tests__/**/*.{ts,js,json,md}\"",
25+
"lint:tests": "./node_modules/tslint/bin/tslint -c ./tslint.json '__tests__/**/*.ts' --fix",
26+
"format:tests": "yarn lint:tests && yarn prettier:tests",
27+
"prettier:tests": "prettier --write \"./__tests__/**/*.{ts,js,json,md}\"",
28+
"test": "cross-env CORE_ENV=test jest --runInBand --forceExit",
29+
"test:coverage": "cross-env CORE_ENV=test jest --coverage --coveragePathIgnorePatterns='/(defaults.ts|index.ts)$' --runInBand --forceExit"
30+
},
31+
"dependencies": {
32+
"@arkecosystem/core-container": "^2.6.0-next.2",
33+
"@arkecosystem/core-interfaces": "^2.6.0-next.2"
34+
},
35+
"devDependencies": {
36+
"@sindresorhus/tsconfig": "^0.5.0",
37+
"@types/jest": "^24.0.18",
38+
"@types/node": "^12.7.12",
39+
"tslint": "^5.20.0",
40+
"tslint-config-prettier": "^1.18.0",
41+
"typescript": "^3.6.4",
42+
"typedoc": "^0.15.0",
43+
"ts-jest": "^24.0.2",
44+
"jest": "^24.9.0",
45+
"jest-extended": "^0.11.2",
46+
"regenerator-runtime": "^0.13.0",
47+
"cross-env": "^6.0.3",
48+
"del-cli": "^3.0.0",
49+
"prettier": "^1.18.2"
50+
},
51+
"jest": {
52+
"testEnvironment": "node",
53+
"bail": true,
54+
"verbose": true,
55+
"transform": {
56+
"^.+\\.tsx?$": "ts-jest"
57+
},
58+
"testMatch": [
59+
"**/*.test.ts"
60+
],
61+
"moduleFileExtensions": [
62+
"ts",
63+
"tsx",
64+
"js",
65+
"jsx",
66+
"json",
67+
"node"
68+
],
69+
"collectCoverage": false,
70+
"coverageDirectory": "<rootDir>/.coverage",
71+
"collectCoverageFrom": [
72+
"packages/**/src/**/*.ts",
73+
"!**/node_modules/**"
74+
],
75+
"coverageReporters": [
76+
"json",
77+
"lcov",
78+
"text",
79+
"clover",
80+
"html"
81+
],
82+
"watchman": false,
83+
"setupFilesAfterEnv": [
84+
"jest-extended"
85+
]
86+
}
87+
}

0 commit comments

Comments
 (0)