Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Develop #36

Merged
merged 6 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion DApps/dicedapp_v2/dapp.manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name" : "Dice DApp Example",
"name" : "DiceDAppExample2",
"code" : "dicedapp_v2",

"index" : "./index.html",
Expand Down
2 changes: 1 addition & 1 deletion DApps/dicedapp_v2/lib/DC.js

Large diffs are not rendered by default.

Binary file modified DApps/example.zip
Binary file not shown.
5 changes: 2 additions & 3 deletions public/server.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const DApps = {
config : dapp_config,
path : full_path,
}

this.list[dir] = dapp_data
})
},
Expand Down Expand Up @@ -154,10 +153,10 @@ const DApps = {

fse.copySync(
cp_from,
dapps_path + dapp_config.name
dapps_path + dapp_config.code
)

this.init([dapp_config.name], callback )
this.init([dapp_config.code], callback )
},

remove: function(key, callback){
Expand Down
2 changes: 1 addition & 1 deletion src/model/DApps/DApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ export default class DApp {

if (receipt.transactionHash) {
// Set deposit in logic
this.users[params.user_id].logic.payChannel.setDeposit( player_deposit )
this.users[params.user_id].logic.payChannel.setDeposit( Utils.bet2dec(player_deposit) )
}

this.response(params, { receipt:receipt }, response_room)
Expand Down
8 changes: 4 additions & 4 deletions src/model/DApps/DApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const injectDAppScript = function(key, url, callback){
}

setTimeout(()=>{
console.log('injectDAppScript', url)
var script = document.createElement('script')
script.id = script_id
script.src = url
Expand Down Expand Up @@ -154,14 +153,17 @@ class _DCLib {
return this.web3.eth.accounts.recover(raw_msg, signed_msg).toLowerCase()
}

sigHashRecover(){
sigHashRecover(raw_msg, signed_msg){
return this.web3.eth.accounts.recover(raw_msg, signed_msg).toLowerCase()
}

checkSig(raw_msg, signed_msg, need_address){
raw_msg = Utils.remove0x(raw_msg)
return ( need_address.toLowerCase() == this.web3.eth.accounts.recover(raw_msg, signed_msg).toLowerCase() )
}
checkHashSig(raw_msg, signed_msg, need_address){
return ( need_address.toLowerCase() == this.web3.eth.accounts.recover(raw_msg, signed_msg).toLowerCase() )
}
}


Expand All @@ -176,7 +178,6 @@ export default new class DAppsAPIInit {

printDocs( G.DCLib )

console.log('get DApps info')
fetch(_config.server+'/DApps/info/')
.then( r => { return r.json() })
.then( info => {
Expand All @@ -202,7 +203,6 @@ export default new class DAppsAPIInit {

loadAll(){
fetch(_config.server+'/DApps/list/').then( r => { return r.json() }).then( list => {
console.log(list)
this.List = Object.assign({},list)
Object.keys(list).forEach( key => {
this.loadDApp(key)
Expand Down
89 changes: 0 additions & 89 deletions src/model/DApps/approve.js

This file was deleted.

5 changes: 0 additions & 5 deletions src/model/DApps/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ export default function(DCLib){

console.group('Account')

console.group('Eth Lightwallet')
console.log('lightwallet placed in DCLib.Account.lib ')
console.log('docs: https://github.com/ConsenSys/eth-lightwallet')
console.groupEnd()

console.group('Eth Account/Wallet')
console.log('Account info DCLib().Account.get():')
let accinfo = DCLib.Account.get()
Expand Down
53 changes: 0 additions & 53 deletions src/model/DApps/messaging.js

This file was deleted.

17 changes: 13 additions & 4 deletions src/model/Eth/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import RPC from './RPC'
const rpc = new RPC( _config.rpc_url )

let _web3acc
let _wallet = false
let _wallet = false
let _privkey = false

export default class Wallet {
constructor() {
Expand Down Expand Up @@ -78,7 +79,7 @@ export default class Wallet {
return new Promise((resolve, reject) => {
this.getPwDerivedKey( PwDerivedKey => {
let private_key = this.getKs().exportPrivateKey(_wallet.addr, PwDerivedKey)

_privkey = private_key
if(callback) callback(private_key)
resolve(private_key)
})
Expand Down Expand Up @@ -255,8 +256,16 @@ export default class Wallet {
return _web3acc.sign(raw)
}

async signHash(hash){
return signHash(hash, (await this.exportPrivateKey()) )
signHash(hash){
if (!_privkey) return false

hash = Utils.add0x(hash)
if (this.web3.utils.isHexStrict(hash)) {
console.log(hash+' is incorrect hex')
console.log('Use DCLib.Utils.makeSeed or Utils.soliditySHA3(your_args) to create valid hash')
}

return signHash(hash, Utils.add0x(_privkey))
}

}
Expand Down
4 changes: 2 additions & 2 deletions src/model/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ export const buf2bytes32 = buffer => {

export const remove0x = (str) => {
if (str.length > 2 && str.substr(0,2)=='0x') {
console.log('0x prefix removed from ', str)
console.log('0x prefix removed from ' + str.substr(0,8) + '...')
str = str.substr(2)
}
return str
}

export const add0x = (str) => {
if (str.substr(0,2)!='0x') {
console.log('0x prefix added to', str)
console.log('0x prefix added to ' + str.substr(0,8) + '...')
str = '0x'+str
}
return str
Expand Down
5 changes: 2 additions & 3 deletions src/server.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ const DApps = {
config : dapp_config,
path : full_path,
}

this.list[dir] = dapp_data
})
},
Expand Down Expand Up @@ -154,10 +153,10 @@ const DApps = {

fse.copySync(
cp_from,
dapps_path + dapp_config.name
dapps_path + dapp_config.code
)

this.init([dapp_config.name], callback )
this.init([dapp_config.code], callback )
},

remove: function(key, callback){
Expand Down
2 changes: 1 addition & 1 deletion src/view/components/screens/dev/dapps_list.tag
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ import './dapps_list.less'
</script>

<div class="links">
<a target="_blank" href="{dapps_path}/example.zip">Download DApp exmaple</a>
<a target="_blank" href="https://github.com/DaoCasino/BankRollerApp/raw/master/DApps/example.zip">Download DApp exmaple</a>
<a target="_blank" href="https://github.com/DaoCasino/DCLib">Read docs</a>
</div>

Expand Down