Code Monkey home page Code Monkey logo

lisk-dapps-sdk's Introduction

Lisk Apps SDK

The official SDK for building blockchain apps on the Lisk platform.

Directory Structure

  • modules - Contains the backend code of your app.
  • public - Contains the frontend user interface of your app.
  • blockchain.json - JSON file describing the SQL database schema. You will need this if you want to store any data within your app.
  • config.json - JSON file containing your app's configuration data. By default this file defines a list of peers.
  • genesis.json - JSON file containing important information about your app's genesis block.
  • index.js - JavaScript file used to start your app.
  • modules.full.json - JSON file containing a list of defined modules, required by index.js.
  • routes.json - JSON file defining the HTTP routes of every endpoint in your app's API.

Full documentation is available here.

Authors

License

The MIT License (MIT)

Copyright (c) 2016-2017 Lisk
Copyright (c) 2015 Crypti

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

lisk-dapps-sdk's People

Contributors

borispovod avatar dezelin avatar freeart avatar karmacoma avatar m-schmoock avatar veralimita avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lisk-dapps-sdk's Issues

ERROR: column "dapp_7122403458829374178_blocks.id" must appear in the GROUP BY clause or be used in an aggregate function

When you have a dapp running on couple of different nodes and you connect them as peers in config.json this is the error output from console on all of the nodes:

error - query: select "height" as "height", ARRAY_AGG(s."id") as "ids" from (select "id" as "id", MAX("height") as "height" from "dapp_7122403458829374178_blocks" group by (CAST("height" / 101 AS INTEGER) + (CASE WHEN "height" % 101 > 0 THEN 1 ELSE 0 END)) having "height" <= 520 union select "id" as "id", 1 as "height" from "dapp_7122403458829374178_blocks" where "height" = 1 order by "height" asc limit 1000) as "s";

Unable to create a new dapp

I'm trying to do a Hello World dapp usiing this sdk.

Sorry if a very noob question, but I was unable to locate tutorials and samples, so I'm digging alone until now.

`~/src/lisk-dapps-sdk$ node_modules/.bin/lisk-cli dapps --add
? Existing blockchain will be replaced, are you sure? Yes
? Enter secret of your testnet account *******************************************? Overwrite the existing genesis block? Yes
? Enter DApp name LiskHelloWorld
? Enter DApp description My first dapp using lisk with sdk code
? Enter Github repository (SSH|HTTPS) https://github.com/glaudiston/LiskHelloWorld? Enter DApp link https://github.com/glaudiston/LiskHelloWorld/archive/master.zip
Generating unique genesis block...
? Enter public keys of dapp forgers - hex array, use ',' for separator ce11283a750f7b41d4c4484a40ff4b09ddefec3b71e0b3ba0da880be7a1733df
Creating DApp genesis block
Fetching Lisk Dapps SDK
Error: Command failed: git clone "[email protected]:LiskHQ/lisk-dapps-sdk.git" "dapps/2958385414531461679"
Cloning into 'dapps/2958385414531461679'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.`

bug: token.js is mapping the non-existent SQL columns asset_token.name

File: modules/blockchain/token.js :72

    {"tkn.\"name\"": "name"},

If I see it correctly there is no such column (any more?). What was the original intention behind this? I cannot simply remove it since the name field is used to calculate the dynamic field balance.

Log output is:

[log] 2016-06-21 19:34:45 | error - "error: ERROR:  column tkn.name does not exist\nLINE 1: select \"tkn\".\"transactionId\" as \"transactionId\", \"tkn\".\"name...\n                                                         ^"      
[log] 2016-06-21 19:34:45 | error - "query: select \"tkn\".\"transactionId\" as \"transactionId\", \"tkn\".\"name\" as \"name\", \"t\".\"senderId\" as \"owner\", \"tkn\".\"fund\" as \"fund\", \"tkn\".\"description\" as \"description\", tkn.\"fund\" - IFNULL((SELECT SUM(\"amount\")::bigint AS \"amount\" FROM dapp_8655694938687431615_transactions WHERE \"senderId\" = t.\"senderId\" AND \"token\" = tkn.\"name\"), 0) from \"dapp_8655694938687431615_asset_token\" as \"tkn\" inner join \"dapp_8655694938687431615_transactions\" as \"t\" on \"tkn\".\"transactionId\" = \"t\".\"id\";"
[ERR] 2016-06-21 19:34:45 | Error: ERROR:  column tkn.name does not exist

dapp cannot be loaded

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope

The error can be reproduced with a newly created dapp (lisk-cli dapps -a)
Lisk version 0.3.1, private testnet

info 2016-06-06 21:57:28 Forging enabled on account: 15434105908147528073L 
info 2016-06-06 21:57:28 Forged new block id: 1501722308861472731 height: 2 round: 1 slot: 114104 reward: 0 
error 2016-06-06 21:57:29 Application not found 
Failed to launch application 10113539455696385153: Dapp not found
Launched application 12119915503893025515 successfully
Debug /home/jens/src/coins/lisk/lisk/dapps/12119915503893025515/index.js: 

Dapp loading process pid 13637

Debug /home/jens/src/coins/lisk/lisk/dapps/12119915503893025515/index.js: 

Dapp loaded process pid 13637

Debug /home/jens/src/coins/lisk/lisk/dapps/12119915503893025515/index.js: 

FATAL ERROR: v8::HandleScope::CreateHandle() Cannot create a handle without a HandleScope

error 2016-06-06 21:57:30 DApps#onNewBlock error: Application not ready

modules.api.sql.select and the order of fields

I'm concerned about the need for the fields to be ordered just like they exists in the blockchain.db and if you join with system table like often used in the examples like "transactions" if Lisk team decide to add a new field in "transactions" every dapps which updates the SDK breaks.

async.js callback wrong parameter order

Recent npm version of the async library has switched the parameter ordering.
When doing a multi module call, the first parameter will be the scope variable and the second parameter is the cb callback function variable.

When using recent sources this leads to errors like this:

Domain master {
    message: 'object is not a function', 
    stack: 'TypeError: object is not a function
        at async.auto.scheme (/home/lisk/lisk/dapps/8242793458529886002/index.js:77:4)
        ...'

It can be easily fixed by switching the parameters at dapps SDK index.js at line 35, 145, 174 just like here: https://github.com/m-schmoock/blockDataDapp/commit/666e97985091305c087acdcaed5c69f42580f219

Dapp deposit fails

This issue was copied from issue 51 (LiskHQ/lisk repo):

  • Using Lisk v0.1.4, development branch
  • I created a basic dapp using "lisk-cli dapps -a" without changes
  • starting the node
  • if I try to deposit the dapp using "lisk-cli dapps -d" (here with an amount of 100 LISK), the transaction seems successfull:
$ lisk-cli dapps -d
? Enter secret ****
? Enter amount 10000000000
? DApp Id 16924003274252134805
? Enter secondary secret (if defined) 
? Host and port localhost:7000
null { success: true, transactionId: '13688217344496871545' }
13688217344496871545

The transaction is credited, but seconds later reverted. Only the fee was applied. See screenshot.
image

postgres branch: message: 'Invalid payload hash'

I updated my dapp with the sources from the postgres branch. Now the dapp ist running again, but the following error occurred (starting with a fresh and empty database):

$ node app.js 
info 2016-05-03 20:50:37 Lisk started: 0.0.0.0:7000 
HINWEIS:  Relation „blocks“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs“ existiert bereits, wird übersprungen
HINWEIS:  Relation „signatures“ existiert bereits, wird übersprungen
HINWEIS:  Relation „delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „votes“ existiert bereits, wird übersprungen
HINWEIS:  Relation „forks_stat“ existiert bereits, wird übersprungen
HINWEIS:  Relation „multisignatures“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapps“ existiert bereits, wird übersprungen
HINWEIS:  Relation „intransfer“ existiert bereits, wird übersprungen
HINWEIS:  Relation „outtransfer“ existiert bereits, wird übersprungen
HINWEIS:  Relation „peers“ existiert bereits, wird übersprungen
HINWEIS:  Relation „peers_dapp“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_height“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_previousBlock“ existiert bereits, wird übersprungen
HINWEIS:  Relation „out_transaction_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „peers_unique“ existiert bereits, wird übersprungen
HINWEIS:  Relation „peers_dapp_unique“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_rowId“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_generator_public_key“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_reward“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_totalFee“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_totalAmount“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_numberOfTransactions“ existiert bereits, wird übersprungen
HINWEIS:  Relation „blocks_timestamp“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_rowId“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_block_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_sender_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_recipient_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_senderPublicKey“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_type“ existiert bereits, wird übersprungen
HINWEIS:  Relation „trs_timestamp“ existiert bereits, wird übersprungen
HINWEIS:  Relation „signatures_trs_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „votes_trs_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „delegates_trs_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „multisignatures_trs_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapps_trs_id“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapps_name“ existiert bereits, wird übersprungen
info 2016-05-03 20:50:37 Modules ready and launched 
HINWEIS:  Relation „mem_accounts“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_round“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2u_delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2multisignatures“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2u_multisignatures“ existiert bereits, wird übersprungen
info 2016-05-03 20:50:37 Blocks 1 
HINWEIS:  Relation „mem_accounts“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_round“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2u_delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2multisignatures“ existiert bereits, wird übersprungen
HINWEIS:  Relation „mem_accounts2u_multisignatures“ existiert bereits, wird übersprungen
info 2016-05-03 20:50:37 Current 0 
info 2016-05-03 20:50:38 Blockchain ready 
warn 2016-05-03 20:50:38 Peers list is empty 
log 2016-05-03 20:50:39 GET /api/loader/status/sync from 127.0.0.1 
log 2016-05-03 20:50:39 GET /api/loader/status/sync from 127.0.0.1 
HINWEIS:  Relation „dapp_10113539455696385153_blocks“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_transactions“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_asset_dapptransfer“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_asset_myasset“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_asset_delegates“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_asset_token“ existiert bereits, wird übersprungen
HINWEIS:  Relation „dapp_10113539455696385153_asset_messages“ existiert bereits, wird übersprungen
Launched dapp 10113539455696385153 successfully
Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

dapp loading process pid 12947

log 2016-05-03 20:50:40 GET /api/loader/status/sync from 127.0.0.1 
log 2016-05-03 20:50:40 GET /api/loader/status/sync from 127.0.0.1 
Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

log 2016-05-03 22:50:40 DApp GoldenMessage started 

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

dapp loaded process pid 12947

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

Blocks 1

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

Current 0

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

loadBlocksOffset { block: 
   { id: undefined,
     height: undefined,
     timestamp: undefined,
     payloadLength: undefined,
     payloadHash: undefined,
     prevBlockId: undefined,
     pointId: undefined,
     pointHeight: undefined,
     delegate: undefined,
     signature: undefined,
     count: undefined,
     transactions: [] },
  message: 'Invalid payload hash' }

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

Blockchain failed at  undefined

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

Blockchain clipped

Debug /home/jens/src/coins/lisk_my/lisk/dapps/10113539455696385153/index.js: 

Sync#transactionsSync timer No peers in db

log 2016-05-03 20:50:41 GET /api/loader/status/sync from 127.0.0.1 
log 2016-05-03 20:50:41 GET /api/loader/status/sync from 127.0.0.1 
^Cinfo 2016-05-03 20:50:44 Cleaning up... 
info 2016-05-03 20:50:44 Cleaned up successfully 

undefined fields returned to callback from modules.api.sql.select

Values of all fields in returned transactions are undefined in callback.

modules.api.sql.select({
            table: "transactions",
            alias: "t",
            condition: {
                recipientId: query.recipientId,
                type: self.type
            },
            join: [{
                type: "left outer",
                table: "asset_message",
                alias: "tm",
                on: { "t.id": "tm.\"transactionId\"" }
            }]
        }, ['id', 'type', 'senderId', 'senderPublicKey', 'recipientId', 'amount', 'fee', 'timestamp', 'signature', 'blockId', 'token', 'message', 'transactionId'], function(err, transactions) {
            if (err) {
                return cb(err.toString());
            }

            // Map results to asset object
            var messages = transactions.map(function(tx) {
                // BUG:
                // tx.message and all other fields are undefined in tx argument
                //
                return new Buffer(tx.message, 'hex').toString('utf8')
            });

            return cb(null, {
                messages: messages
            })
        });

Link in readme broken

Hi, the link in your readme with the text:
"Full documentation is available here."
points to a 404. I don’t know where it should be pointing…

module initialization issue async.parallel(cb)

When a dapp loads and initializes all its js modules it uses a parallel async loading method: index.js:154+. When using the recent library version it may happen that the async completion callback index.js:170 is called before the very last module is finished, leading to undefined application states.

Can be fixed by using async.setImmediate inside the async completion handler instead of calling cb directly.

system/sync.js: sendWithdrawal() fails because of missing parameter

the modules.api.dapps.sendWithdrawal() call fails because of the missing dappId parameter

[log] 2016-09-04 13:19:15 | GET /api/loader/status/sync from 127.0.0.1
[log] 2016-09-04 13:19:15 | GET /api/loader/status/sync from 127.0.0.1
Debug /home/jens/src/coins/lisk/lisk/dapps/10113539455696385153/index.js: 

Sync#withdrawalSync timer Missing required property: dappId

Before a withdrawal from Dapp account back to the Lisk account was done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.