Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
4ca57c1
get code from tip
bokarev Jan 1, 2018
bcce164
pfe
bokarev Oct 30, 2018
dfc7d69
fix console.log
bokarev Oct 30, 2018
4eec417
fix num.toFixed(8)
bokarev Oct 30, 2018
610d979
fix ifStatement
bokarev Oct 30, 2018
27150e6
env
bokarev Nov 5, 2018
c7fe12d
fix plug fee
bokarev Nov 5, 2018
a85d791
preset env js v5
bokarev Nov 13, 2018
83b3249
rm giant.mjs
bokarev Nov 13, 2018
6d9ff25
fix pfe
bokarev Nov 14, 2018
3d0905d
validator logic
bokarev Nov 14, 2018
7be4b28
upd validator
bokarev Nov 15, 2018
abfced2
fix desc validator
bokarev Nov 15, 2018
804b48c
fix validator
bokarev Nov 15, 2018
4ab1e98
fix super fee,validator
bokarev Nov 16, 2018
edc7ae2
fix fee,validator
bokarev Nov 16, 2018
0db97f4
optimisation fee
bokarev Nov 16, 2018
9d3c033
optimisation fee cb
bokarev Nov 16, 2018
33206b4
fix optimisation fee
bokarev Nov 16, 2018
2da2876
fix optimisation fee
bokarev Nov 16, 2018
42e6260
fix optimisation fee
bokarev Nov 16, 2018
547cbea
validate before compile
bokarev Nov 19, 2018
d111a8b
contract runTime version, test dir contract
bokarev Nov 19, 2018
8faa50e
fix comment
bokarev Nov 19, 2018
827f26b
lowerCamelCase
bokarev Nov 19, 2018
6fd2bb8
fix var
bokarev Nov 19, 2018
5d73d78
lowerCamelCase
bokarev Nov 19, 2018
443166b
validatorVars, pfeVars format
bokarev Nov 19, 2018
790573f
validatorVars, pfeVars short format
bokarev Nov 19, 2018
c56651a
ImportDeclaration validation name src GiantContract, GiantBlockChain
bokarev Nov 20, 2018
22d0002
SuperClassExtend
bokarev Nov 20, 2018
1fa5f59
test -All contract have RunTime version
bokarev Nov 21, 2018
5970234
test -Readable contracts is equals by his RunTime versions
bokarev Nov 22, 2018
60c1f64
test -Last readable contracts is equals by his RunTime versions
bokarev Nov 23, 2018
fdd69ae
fix test -Last readable contracts is equals by his RunTime versions
bokarev Nov 23, 2018
5af4927
fix test -Last readable contracts is equals by his RunTime versions
bokarev Nov 23, 2018
127ca4e
Declaration v5
bokarev Nov 27, 2018
19ccaaf
fix compile, fee plugin
bokarev Nov 28, 2018
5bb6b98
upd plugin fee
bokarev Nov 29, 2018
54f1c77
upd plugin fee
bokarev Nov 30, 2018
90cc2e2
upd plugin fee
bokarev Dec 3, 2018
f6dc084
injection pfeVar, uglify, minify
bokarev Dec 4, 2018
786a2f6
figlet, readme, loop declarations
bokarev Dec 5, 2018
e582cd2
fix contract
bokarev Dec 5, 2018
b41f31c
fix validator
bokarev Dec 5, 2018
88178e0
upd GiantContract
bokarev Dec 6, 2018
fe3e886
upd GiantContract
bokarev Dec 6, 2018
89cbd53
upd GiantContract
bokarev Dec 6, 2018
a42bca1
fix init and replace in build command
bokarev Dec 7, 2018
722ffa5
fix deploy
bokarev Dec 9, 2018
7ead226
fix mockClient
bokarev Dec 9, 2018
08f51a3
fix mockClient
bokarev Dec 9, 2018
eb3845f
stringify code object for hash
bokarev Dec 12, 2018
64157ae
fix hash
bokarev Dec 13, 2018
5ca6a29
fix transaction validate
bokarev Dec 13, 2018
04a2818
white paper fee
bokarev Dec 17, 2018
bcd9f99
loger info and wallet balance
bokarev Dec 18, 2018
010bd69
fix deploy
bokarev Dec 18, 2018
e199a08
Chain metadata
bokarev Dec 19, 2018
256a6e6
network info
bokarev Dec 20, 2018
684ee0d
network info
bokarev Dec 21, 2018
3dccc4a
fix network info
bokarev Dec 21, 2018
34391cd
fix deploy
bokarev Dec 21, 2018
23f7ca6
fix deploy
bokarev Dec 25, 2018
aef0ccf
fix deploy
bokarev Dec 27, 2018
de6b588
fix deploy
bokarev Dec 28, 2018
430ab84
fix deploy
bokarev Dec 28, 2018
3004736
deploy params
bokarev Jan 8, 2019
183d911
deploy metadata
bokarev Jan 8, 2019
0ee138f
deploy metadata
bokarev Jan 9, 2019
bc68a7b
config
bokarev Jan 10, 2019
96c40a5
chain metadata
bokarev Jan 14, 2019
58e7d0c
chain metadata
bokarev Jan 17, 2019
6c0b4bb
chain metadata
bokarev Jan 17, 2019
3a4a62b
network contracts list
bokarev Jan 17, 2019
0672b4f
exec contract module
bokarev Jan 28, 2019
7ec4f62
exec contract module
bokarev Jan 28, 2019
76dd30b
rm path from contract constructor
bokarev Jan 30, 2019
5a7e13a
global contracts
bokarev Jan 30, 2019
7c21e4c
method getPfe, receive obj pfeVars
bokarev Jan 31, 2019
77ef5fc
tmp get last contract code
bokarev Jan 31, 2019
0809886
fix fx code
bokarev Jan 1, 2018
88d7a37
debug info control in config
bokarev Feb 3, 2019
f4157be
upd debug
bokarev Feb 4, 2019
d467ff1
miner tx structure
bokarev Feb 5, 2019
93a1acc
metadata.deployFee fot tx out
bokarev Feb 6, 2019
4de5a45
metadata.deployFee real data
bokarev Feb 8, 2019
4e77407
miner method get deploy fee
bokarev Feb 8, 2019
7a1c398
miner wallets premine, wp count namespace
bokarev Feb 8, 2019
078b401
call wp methods from contract
bokarev Feb 10, 2019
4cd17aa
fix call wp methods from contract
bokarev Feb 10, 2019
fde5602
multiple payment preparation
bokarev Feb 12, 2019
ea299ea
update meta contract methods fee
bokarev Feb 12, 2019
83a9c06
fix update meta contract methods fee
bokarev Feb 12, 2019
ef85911
fix update meta contract methods fee
bokarev Feb 12, 2019
472f23e
fix update meta contract methods fee
bokarev Feb 12, 2019
002949a
init WP Method from console preparation
bokarev Feb 13, 2019
ee11544
initMethod exec <name> <method> <args>
bokarev Feb 13, 2019
4102235
fix initMethod
bokarev Feb 14, 2019
10e5a54
fix initMethod
bokarev Feb 14, 2019
e7bf70d
fix exec description
bokarev Feb 14, 2019
f5d95fb
resolve exec by -name -hash -last
bokarev Feb 15, 2019
fa3bfe1
fix resolve exec by -name -hash -last
bokarev Feb 15, 2019
8a9e847
fix tx options
bokarev Feb 15, 2019
841f4d4
fix chain when no one block found
bokarev Feb 18, 2019
eaab2f6
fix memPool
bokarev Feb 18, 2019
1c368bf
fix txid in deploy
bokarev Feb 19, 2019
338395f
fix txid in deploy
bokarev Feb 19, 2019
ed43990
fix txid in deploy
bokarev Feb 19, 2019
8afd833
fix deploy tx options
bokarev Feb 20, 2019
401df85
fix deploy meta
bokarev Feb 20, 2019
f42fa65
fix deploy metadata.txid, metadata.contractAddress
bokarev Feb 20, 2019
d88ecce
fix deploy metadata wp methods fee
bokarev Feb 21, 2019
3a06c65
fix deploy contractAddress
bokarev Feb 22, 2019
dda40d7
fix deploy tx type generation
bokarev Feb 22, 2019
aebb14e
fix deploy first tx
bokarev Feb 22, 2019
1b8b091
fix first block metadata
bokarev Feb 25, 2019
808cf65
fix first block metadata
bokarev Feb 25, 2019
212d647
upd tx count output
bokarev Feb 26, 2019
91a6d70
upd tx get output from metadata
bokarev Feb 26, 2019
96fa2ea
count utxo
bokarev Feb 27, 2019
d4e5675
upd deploy, save new wallets values in db
bokarev Feb 28, 2019
f4b7e26
get wallets from db
bokarev Feb 28, 2019
f3d1c11
upd tx type call
bokarev Mar 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,41 @@ With **Giantjs**, you get:
### Install

```
$ npm install -g gcdk
$ git clone https://github.com/GiantPay/giantjs.git gcdk; cd gcdk
$ npm install
```

### Build project

```
$ npm run build
```

### Quick Usage

For a default set of contracts and tests, run the following within an empty project directory:
Compile your contracts, deploy those contracts to the network.

```
node dist/giant create contract {ContractName}
node dist/giant deploy {ContractName}
```

### Tests

Run their associated unit tests.

```
$ npm test
```

### Autocompile mode

For autocompile mode open new terminal window.

```
$ giantjs init
$ npm run watch
```

From there, you can run `giantjs compile`, `giantjs migrate` and `giantjs test` to compile your contracts, deploy those contracts to the network, and run their associated unit tests.

**Giantjs** comes bundled with a local development blockchain server that launches automatically when you invoke the commands above.

Expand Down
18 changes: 18 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"network": "development",
"mining": true,
"blockTime": 500,
"maxBlockSize": 5,
"feePrice": 10,
"debug": false,
"caller": {
"privateKey": "YULqUkbYnFT6Fw6YS9Es1H94THRe4BrujuXNgtqT52UMgivrqq7K",
"publicKey": "GUuf1RCuFmLAbyNFT5WifEpZTnLYk2rtVd",
"premine": 20000
},
"owner": {
"privateKey": "YUsc83YuzURjo5eqezyCKUQXAMXets1Ko6edm9paexd7wD8DYhrU",
"publicKey": "GPLkrYE3GdXDoZMz4zhxyBmTiF1N3AQvpH",
"premine": 2010
}
}
30 changes: 0 additions & 30 deletions gulpfile.js

This file was deleted.

9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"author": "GiantCodeDev <admin@giantpay.network>",
"license": "MIT",
"scripts": {
"build": "NODE_ENV=production babel src --out-dir dist",
"build": "NODE_ENV=production babel src --out-dir dist; node dist/giant init",
"watch": "babel src -d dist -w",
"prepublishOnly": "npm run build",
"test": "NODE_ENV=test mocha --require babel-core/register ./test/**/*.test.js",
"coverage": "istanbul cover _mocha -- --recursive"
Expand All @@ -18,6 +19,7 @@
"preferGlobal": true,
"bin": "./src/giantjs.js",
"dependencies": {
"async": "^2.6.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-remove-comments": "^2.0.0",
Expand Down Expand Up @@ -45,7 +47,9 @@
"require-from-string": "^2.0.2"
},
"devDependencies": {
"async_hooks": "^1.0.0",
"babel-core": "^6.26.3",
"babel-preset-es2016": "^6.24.1",
"chai": "^4.1.2",
"coveralls": "^3.0.2",
"gulp": "^3.9.1",
Expand All @@ -55,6 +59,7 @@
"istanbul": "^0.4.5",
"mocha": "^5.2.0",
"proxyquire": "^2.0.1",
"sinon": "^6.1.5"
"sinon": "^6.1.5",
"uglify-js": "^3.4.9"
}
}
4 changes: 3 additions & 1 deletion src/babel/babel-plugin-contract-code-reflection/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import giantConfig from '../../config'
import logger from '../../logger'

const getMetadata = (path) => {
Expand All @@ -21,9 +22,10 @@ export default (babel) => {

metadata.className = declaration.get('id').node.name
metadata.methods = []
metadata.deployFee = 0

declaration.traverse({
ClassMethod (path) {
ClassMethod(path) {
metadata.methods.push({
name: path.get('key').node.name,
params: path.get('params').map((param) => param.node.name),
Expand Down
233 changes: 233 additions & 0 deletions src/babel/babel-plugin-contract-fee/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
import logger from '../../logger'
import giantConfig from "../../config";

let pfeVars = {
Program: {count: 0, max: 1, fee: 10, required: true},
StringLiteral: {count: 0, max: 1000, fee: 4, required: true},
ExpressionStatement: {count: 0, max: 1000, fee: 4, required: true},
Identifier: {count: 0, max: 1000, fee: 4, required: true},
MemberExpression: {count: 0, max: 100, fee: 4, required: true},
ObjectProperty: {count: 0, max: 1000, fee: 4, required: true},
ObjectExpression: {count: 0, max: 100, fee: 4, required: true},
CallExpression: {count: 0, max: 100, fee: 4, required: true},
VariableDeclarator: {count: 0, max: 100, fee: 4, required: true},
VariableDeclaration: {count: 0, max: 100, fee: 4, required: true},
BinaryExpression: {count: 0, max: 100, fee: 4, required: true},
UpdateExpression: {count: 0, max: 100, fee: 4, required: true},
LogicalExpression: {count: 0, max: 100, fee: 4, required: true},
AssignmentExpression: {count: 0, max: 100, fee: 4, required: true},
IfStatement: {count: 0, max: 100, fee: 4, required: true},
BlockStatement: {count: 0, max: 100, fee: 4, required: true},
ForStatement: {count: 0, max: 100, fee: 4, required: true},
FunctionDeclaration: {count: 0, max: 100, fee: 4, required: true},
ReturnStatement: {count: 0, max: 100, fee: 4, required: true},
FunctionExpression: {count: 0, max: 100, fee: 4, required: true},
ConditionalExpression: {count: 0, max: 100, fee: 4, required: true},
UnaryExpression: {count: 0, max: 100, fee: 4, required: true},
NewExpression: {count: 0, max: 100, fee: 4, required: true},
ThrowStatement: {count: 0, max: 100, fee: 4, required: true},
ThisExpression: {count: 0, max: 100, fee: 4, required: true},
SequenceExpression: {count: 0, max: 100, fee: 4, required: false},
ArrayExpression: {count: 0, max: 100, fee: 4, required: true},
ForStatement: {count: 0, max: 10, fee: 20, required: false},
ForInStatement: {count: 0, max: 10, fee: 20, required: false},
WhileStatement: {count: 0, max: 10, fee: 20, required: false},
DoWhileStatement: {count: 0, max: 10, fee: 20, required: false},
WhitePaper: {
getNodeOwner: {count: 0, max: 10, fee: 20, required: false},
getNodeOwnerBalance: {count: 0, max: 10, fee: 30, required: false},
getCaller: {count: 0, max: 10, fee: 40, required: false},
getCallerBalance: {count: 0, max: 10, fee: 50, required: false},
},
}, pfeVarsCount = (type, whitePaper) => {
if (type) {
pfeVars.hasOwnProperty(type) ? pfeVars[type].count++ : pfeVars[type] = {count: 1}
} else if (whitePaper) {
pfeVars.WhitePaper[whitePaper].count++
}
}


/**
* @returns ast and pfe functions of the giant contract code
*
*/
export default ({template: template}) => {
let pfeCall = (pfeVars) => {
let str = '{'
for (let i in pfeVars) {
str += i + `: {count: ${pfeVars[i]['count']}, fee: ${pfeVars[i]['fee']}},\n`
}
str += `WhitePaper: {`
for (let i in pfeVars.WhitePaper) {
str += i + `: {count: ${pfeVars.WhitePaper[i]['count']}, fee: ${pfeVars.WhitePaper[i]['fee']}},\n`
}
str += '}}'
return template(`var pfeVars = ${str}`, {
sourceType: 'module'
})()
}, injectionPath

return {
visitor: {
Program: (path) => {
pfeVarsCount(path.type, false)
path.traverse({
StringLiteral: (path) => {
/**
* its possible use like White Paper marker
*
* logger.info("Visiting StringLiteral : " + path.node.value)
*
{giantjs} info : Visiting StringLiteral : buyCoin
{giantjs} info : Visiting StringLiteral : sendCoin
{giantjs} info : Visiting StringLiteral : getBalance
*
*/
pfeVarsCount(path.type, false)
if (pfeVars.WhitePaper.hasOwnProperty(path.node.value)) {
pfeVarsCount(false, path.node.value)
}
},
ExpressionStatement: (path) => {
pfeVarsCount(path.type, false)
},
FunctionDeclaration: (path) => {
pfeVarsCount(path.type, false)
if (path.node.id.name == '_inherits') {
/**
* Some place for injection pfeVars
*/
injectionPath = path
}
},
Identifier: (path) => {
pfeVarsCount(path.type, false)
/**
* its possible use like White Paper marker
*
* logger.info("Visiting Identifier : " + path.node.name)
*
{giantjs} info : Visiting Identifier : getBalance
{giantjs} info : Visiting Identifier : address
{giantjs} info : Visiting Identifier : balances
{giantjs} info : Visiting Identifier : get
{giantjs} info : Visiting Identifier : address
{giantjs} info : Visiting Identifier : MetaCoin
*
*/
},
MemberExpression: (path) => {
pfeVarsCount(path.type, false)
},
ObjectProperty: (path) => {
pfeVarsCount(path.type, false)
},
ObjectExpression: (path) => {
pfeVarsCount(path.type, false)
},
CallExpression: (path) => {
pfeVarsCount(path.type, false)
},
VariableDeclarator: (path) => {
pfeVarsCount(path.type, false)
},
VariableDeclaration: (path) => {
pfeVarsCount(path.type, false)
},
BinaryExpression: (path) => {
pfeVarsCount(path.type, false)
},
UpdateExpression: (path) => {
pfeVarsCount(path.type, false)
},
LogicalExpression: (path) => {
pfeVarsCount(path.type, false)
},
AssignmentExpression: (path) => {
pfeVarsCount(path.type, false)
},
IfStatement: (path) => {
pfeVarsCount(path.type, false)
},
BlockStatement: (path) => {
pfeVarsCount(path.type, false)
},
ForStatement: (path) => {
pfeVarsCount(path.type, false)
},
ReturnStatement: (path) => {
pfeVarsCount(path.type, false)
},
FunctionExpression: (path) => {
pfeVarsCount(path.type, false)
},
ConditionalExpression: (path) => {
pfeVarsCount(path.type, false)
},
UnaryExpression: (path) => {
pfeVarsCount(path.type, false)
},
NewExpression: (path) => {
pfeVarsCount(path.type, false)
},
ThrowStatement: (path) => {
pfeVarsCount(path.type, false)
},
ThisExpression: (path) => {
pfeVarsCount(path.type, false)
},
SequenceExpression: (path) => {
pfeVarsCount(path.type, false)
},
ArrayExpression: (path) => {
pfeVarsCount(path.type, false)
},
ForStatement: (path) => {
pfeVarsCount(path.type, false)
},
ForInStatement: (path) => {
pfeVarsCount(path.type, false)
},
WhileStatement: (path) => {
pfeVarsCount(path.type, false)
},
DoWhileStatement: (path) => {
pfeVarsCount(path.type, false)
},
})
injectionPath.insertAfter(pfeCall(pfeVars))
}
}, post(state) {

/**
* validator logic
*
* */
let foundErrors = []
logger.warn(`Count fee debug ${giantConfig.debug}`)
for (let k in pfeVars) {
if (pfeVars[k].required && !pfeVars[k].count) {
foundErrors.push('not found ' + k)
}
if (pfeVars[k].count > pfeVars[k].max) {
foundErrors.push(k + ' ' +
pfeVars[k].count +
' times payment, expect max ' +
pfeVars[k].max)
} else {
if (giantConfig.debug) {
logger.info(k + ' ' + pfeVars[k].count + ' times payment')
}
}
}

if (!foundErrors.length) {
logger.warn('Succeseful! Contract code transpiled.')
} else {
logger.error('Some errors found', foundErrors)
}

}
}
}
Loading