Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Miguel Montes
nucleo
Commits
2bfbe2c7
Commit
2bfbe2c7
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Arreglando MasterDistiller
parent
0d8f5afa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/MasterDistiller.js
+13
-1
13 additions, 1 deletion
bin/MasterDistiller.js
bin/libbfa.js
+41
-32
41 additions, 32 deletions
bin/libbfa.js
with
54 additions
and
33 deletions
bin/MasterDistiller.js
+
13
−
1
View file @
2bfbe2c7
#!/usr/bin/node
"
use strict
"
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
const
rl
=
require
(
'
readline
'
).
createInterface
(
{
input
:
process
.
stdin
,
output
:
process
.
stdout
}
...
...
@@ -25,6 +27,8 @@ function init()
bfa
=
new
Libbfa
();
web3
=
bfa
.
newweb3
();
Distillery
=
bfa
.
contract
(
web3
,
'
Distillery
'
);
if
(
undefined
==
Distillery
)
fatal
(
'
Can not initialise Distillery contact.
'
);
web3
.
eth
.
getBalance
(
Distillery
.
contractaddress
).
then
(
function
receivedOwnBalance
(
val
)
{
Distillery
.
contractbalance
=
val
;
...
...
@@ -128,7 +132,7 @@ function editAccount( entry, pallet )
if
(
entry
==
"
x
"
)
{
// trigger distribution
Distillery
.
methods
.
distribute
().
send
(
{
"
from
"
:
bfa
.
account
,
"
gas
"
:
1
000000
}
)
Distillery
.
methods
.
distribute
().
send
(
{
"
from
"
:
bfa
.
account
,
"
gas
"
:
4
000000
}
)
.
then
(
function
distOK
(
x
)
{
console
.
log
(
...
...
@@ -155,7 +159,15 @@ function editAccount( entry, pallet )
return
;
}
else
if
(
entry
==
""
)
{
// Do nothing, basically just update the display
return
;
}
else
{
bfa
.
fatal
(
"
I don't know what to do with
\"
"
+
entry
+
"
\"
.
"
);
}
rl
.
question
(
"
Adjust the
"
+
notation
[
2
]
...
...
This diff is collapsed.
Click to expand it.
bin/libbfa.js
+
41
−
32
View file @
2bfbe2c7
// 20180724 Robert Martin-Legene <robert@nic.ar>
"
use strict
"
module
.
exports
=
class
Libbfa
{
constructor
()
{
this
.
fs
=
require
(
'
fs
'
);
this
.
Web3
=
require
(
'
web3
'
);
this
.
fs
=
require
(
'
fs
'
);
this
.
Web3
=
require
(
'
web3
'
);
//
// BFAHOME
if
(
undefined
==
process
.
env
.
BFAHOME
)
fatal
(
"
$BFAHOME not set. Did you source bfa/bin/env ?
"
);
// BFANETWORKID
this
.
home
=
process
.
env
.
BFAHOME
;
if
(
undefined
==
process
.
env
.
BFANETWORKID
)
process
.
env
.
BFANETWORKID
=
47525974938
;
process
.
env
.
BFANETWORKID
=
47525974938
;
this
.
networkid
=
process
.
env
.
BFANETWORKID
;
// BFANETWORKDIR
if
(
undefined
==
process
.
env
.
BFANETWORKDIR
)
process
.
env
.
BFANETWORKDIR
=
process
.
env
.
BFAHOME
+
'
/network
'
;
process
.
env
.
BFANETWORKDIR
=
process
.
env
.
BFAHOME
+
'
/network
'
;
this
.
networkdir
=
process
.
env
.
BFANETWORKDIR
;
// BFANODEDIR
if
(
undefined
==
process
.
env
.
BFANODEDIR
)
process
.
env
.
BFANODEDIR
=
this
.
networkdir
+
"
/node
"
;
process
.
env
.
BFANODEDIR
=
this
.
networkdir
+
"
/node
"
;
this
.
nodedir
=
process
.
env
.
BFANODEDIR
;
// ACCOUNT
if
(
undefined
==
process
.
env
.
BFAACCOUNT
)
{
var
files
=
new
Array
();
this
.
fs
.
readdirSync
(
process
.
env
.
BFANODEDIR
+
'
/keystore
'
).
forEach
(
function
(
filename
)
{
if
(
filename
.
includes
(
'
--
'
)
)
files
.
push
(
filename
);
});
if
(
this
.
fs
.
existsSync
(
process
.
env
.
BFANODEDIR
+
'
/keystore
'
)
)
{
this
.
fs
.
readdirSync
(
process
.
env
.
BFANODEDIR
+
'
/keystore
'
).
forEach
(
function
(
filename
)
{
if
(
filename
.
includes
(
'
--
'
)
)
files
.
push
(
filename
);
});
}
// found none?
if
(
files
.
length
==
0
)
fatal
(
"
Found no accounts in your keystore.
"
);
files
.
sort
();
process
.
env
.
BFAACCOUNT
=
'
0x
'
+
files
[
0
].
replace
(
/^.*--/
,
''
);
if
(
files
.
length
>
0
)
{
files
.
sort
();
process
.
env
.
BFAACCOUNT
=
'
0x
'
+
files
[
0
].
replace
(
/^.*--/
,
''
);
}
}
//
this
.
home
=
process
.
env
.
BFAHOME
;
this
.
networkid
=
process
.
env
.
BFANETWORKID
;
this
.
networkdir
=
process
.
env
.
BFANETWORKDIR
;
this
.
nodedir
=
process
.
env
.
BFANODEDIR
;
this
.
netport
=
Number
.
parseInt
(
this
.
setfromfile
(
this
.
nodedir
+
'
/netport
'
,
30303
);
this
.
rpcport
=
Number
.
parseInt
(
this
.
setfromfile
(
this
.
nodedir
+
'
/rpcport
'
,
8545
);
this
.
account
=
process
.
env
.
BFAACCOUNT
;
this
.
netport
=
Number
.
parseInt
(
this
.
setfromfile
(
this
.
nodedir
+
'
/netport
'
,
30303
));
this
.
rpcport
=
Number
.
parseInt
(
this
.
setfromfile
(
this
.
nodedir
+
'
/rpcport
'
,
8545
));
this
.
account
=
process
.
env
.
BFAACCOUNT
;
}
contract
(
w3
,
name
)
{
this
.
_networkdir
();
var
contractdir
=
[
this
.
networkdir
,
'
contracts
'
,
name
].
join
(
'
/
'
);
var
contractaddress
=
this
.
fs
.
realpathSync
(
contractdir
).
replace
(
/^.*
\/
/
,
''
);
var
contractdir
=
[
this
.
networkdir
,
'
contracts
'
,
name
].
join
(
'
/
'
);
if
(
!
this
.
fs
.
existsSync
(
contractdir
)
)
return
;
var
contractaddress
=
this
.
fs
.
realpathSync
(
contractdir
).
replace
(
/^.*
\/
/
,
''
);
if
(
undefined
==
contractaddress
)
return
;
var
abistr
=
this
.
fs
.
readFileSync
(
contractdir
+
'
/abi
'
).
toString
();
var
abistr
=
this
.
fs
.
readFileSync
(
contractdir
+
'
/abi
'
).
toString
();
if
(
undefined
==
abistr
)
return
;
var
abi
=
JSON
.
parse
(
abistr
);
var
abi
=
JSON
.
parse
(
abistr
);
if
(
undefined
==
abi
)
return
;
var
c
=
new
w3
.
eth
.
Contract
(
abi
,
contractaddress
);
c
.
abi
=
abi
;
c
.
contractaddress
=
contractaddress
;
var
c
=
new
w3
.
eth
.
Contract
(
abi
,
contractaddress
);
c
.
abi
=
abi
;
c
.
contractaddress
=
contractaddress
;
return
c
;
}
...
...
@@ -69,9 +76,8 @@ module.exports = class Libbfa
newweb3
()
{
this
.
_nodedir
();
var
provider
=
'
http://127.0.0.1:
'
+
this
.
rpcport
;
var
w3
=
new
this
.
Web3
(
provider
);
var
provider
=
'
http://127.0.0.1:
'
+
this
.
rpcport
;
var
w3
=
new
this
.
Web3
(
provider
);
w3
.
eth
.
extend
({
//property: 'bfaclique',
methods
:
[{
...
...
@@ -80,6 +86,9 @@ module.exports = class Libbfa
params
:
0
}]
});
if
(
undefined
!=
process
.
env
.
BFAACCOUNT
)
{
w3
.
eth
.
defaultAccount
=
this
.
account
;
}
return
w3
;
}
isNumeric
(
n
)
{
...
...
@@ -92,7 +101,7 @@ module.exports = class Libbfa
setfromfile
(
filename
,
defval
)
{
if
(
this
.
fs
.
stat
Sync
(
filename
)
.
isFile
()
)
if
(
this
.
fs
.
exists
Sync
(
filename
)
)
return
this
.
fs
.
readFileSync
(
filename
);
return
defval
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment