Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
4947489f
Commit
4947489f
authored
Jan 07, 2020
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix linting issues; missing requires and params
parent
408321f7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
9 deletions
+10
-9
blockchain.js
src/blockchain/blockchain.js
+1
-3
injected.js
src/blockchain/providers/injected.js
+2
-1
node.js
src/blockchain/providers/node.js
+3
-2
vm.js
src/blockchain/providers/vm.js
+4
-3
No files found.
src/blockchain/blockchain.js
View file @
4947489f
...
@@ -11,8 +11,6 @@ const Personal = require('web3-eth-personal')
...
@@ -11,8 +11,6 @@ const Personal = require('web3-eth-personal')
const
Web3
=
require
(
'web3'
)
const
Web3
=
require
(
'web3'
)
const
async
=
require
(
'async'
)
const
async
=
require
(
'async'
)
const
{
BN
,
privateToAddress
,
isValidPrivate
,
stripHexPrefix
}
=
require
(
'ethereumjs-util'
)
const
crypto
=
require
(
'crypto'
)
const
{
EventEmitter
}
=
require
(
'events'
)
const
{
EventEmitter
}
=
require
(
'events'
)
const
{
resultToRemixTx
}
=
require
(
'./txResultHelper'
)
const
{
resultToRemixTx
}
=
require
(
'./txResultHelper'
)
...
@@ -375,7 +373,7 @@ class Blockchain {
...
@@ -375,7 +373,7 @@ class Blockchain {
* Create a VM Account
* Create a VM Account
* @param {{privateKey: string, balance: string}} newAccount The new account to create
* @param {{privateKey: string, balance: string}} newAccount The new account to create
*/
*/
createVMAccount
(
newAccount
)
{
createVMAccount
(
newAccount
)
{
if
(
this
.
executionContext
.
getProvider
()
!==
'vm'
)
{
if
(
this
.
executionContext
.
getProvider
()
!==
'vm'
)
{
throw
new
Error
(
'plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed'
)
throw
new
Error
(
'plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed'
)
}
}
...
...
src/blockchain/providers/injected.js
View file @
4947489f
const
Web3
=
require
(
'web3'
)
const
Web3
=
require
(
'web3'
)
const
{
stripHexPrefix
}
=
require
(
'ethereumjs-util'
)
class
InjectedProvider
{
class
InjectedProvider
{
...
@@ -10,7 +11,7 @@ class InjectedProvider {
...
@@ -10,7 +11,7 @@ class InjectedProvider {
return
this
.
executionContext
.
web3
().
eth
.
getAccounts
(
cb
)
return
this
.
executionContext
.
web3
().
eth
.
getAccounts
(
cb
)
}
}
newAccount
(
passwordPromptCb
,
cb
)
{
newAccount
(
passwordPromptCb
,
cb
)
{
passwordPromptCb
((
passphrase
)
=>
{
passwordPromptCb
((
passphrase
)
=>
{
this
.
executionContext
.
web3
().
personal
.
newAccount
(
passphrase
,
cb
)
this
.
executionContext
.
web3
().
personal
.
newAccount
(
passphrase
,
cb
)
})
})
...
...
src/blockchain/providers/node.js
View file @
4947489f
const
Web3
=
require
(
'web3'
)
const
Web3
=
require
(
'web3'
)
const
{
stripHexPrefix
}
=
require
(
'ethereumjs-util'
)
class
NodeProvider
{
class
NodeProvider
{
...
@@ -14,7 +15,7 @@ class NodeProvider {
...
@@ -14,7 +15,7 @@ class NodeProvider {
return
this
.
executionContext
.
web3
().
eth
.
getAccounts
(
cb
)
return
this
.
executionContext
.
web3
().
eth
.
getAccounts
(
cb
)
}
}
newAccount
(
passwordPromptCb
,
cb
)
{
newAccount
(
passwordPromptCb
,
cb
)
{
if
(
!
this
.
config
.
get
(
'settings/personal-mode'
))
{
if
(
!
this
.
config
.
get
(
'settings/personal-mode'
))
{
return
cb
(
'Not running in personal mode'
)
return
cb
(
'Not running in personal mode'
)
}
}
...
@@ -26,7 +27,7 @@ class NodeProvider {
...
@@ -26,7 +27,7 @@ class NodeProvider {
resetEnvironment
()
{
resetEnvironment
()
{
}
}
getBalanceInEther
(
address
,
cb
)
{
getBalanceInEther
(
address
,
cb
)
{
address
=
stripHexPrefix
(
address
)
address
=
stripHexPrefix
(
address
)
this
.
executionContext
.
web3
().
eth
.
getBalance
(
address
,
(
err
,
res
)
=>
{
this
.
executionContext
.
web3
().
eth
.
getBalance
(
address
,
(
err
,
res
)
=>
{
if
(
err
)
{
if
(
err
)
{
...
...
src/blockchain/providers/vm.js
View file @
4947489f
const
Web3
=
require
(
'web3'
)
const
Web3
=
require
(
'web3'
)
const
{
privateToAddress
,
toChecksumAddress
}
=
require
(
'ethereumjs-util'
)
const
{
BN
,
privateToAddress
,
toChecksumAddress
,
isValidPrivate
,
stripHexPrefix
}
=
require
(
'ethereumjs-util'
)
const
crypto
=
require
(
'crypto'
)
class
VMProvider
{
class
VMProvider
{
...
@@ -43,14 +44,14 @@ class VMProvider {
...
@@ -43,14 +44,14 @@ class VMProvider {
this
.
accounts
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
this
.
accounts
[
toChecksumAddress
(
'0x'
+
address
.
toString
(
'hex'
))]
=
{
privateKey
,
nonce
:
0
}
}
}
createVMAccount
(
passwordPromptCb
,
cb
)
{
createVMAccount
(
newAccount
)
{
const
{
privateKey
,
balance
}
=
newAccount
const
{
privateKey
,
balance
}
=
newAccount
this
.
_addAccount
(
privateKey
,
balance
)
this
.
_addAccount
(
privateKey
,
balance
)
const
privKey
=
Buffer
.
from
(
privateKey
,
'hex'
)
const
privKey
=
Buffer
.
from
(
privateKey
,
'hex'
)
return
'0x'
+
privateToAddress
(
privKey
).
toString
(
'hex'
)
return
'0x'
+
privateToAddress
(
privKey
).
toString
(
'hex'
)
}
}
newAccount
(
_passwordPromptCb
,
cb
)
{
newAccount
(
_passwordPromptCb
,
cb
)
{
let
privateKey
let
privateKey
do
{
do
{
privateKey
=
crypto
.
randomBytes
(
32
)
privateKey
=
crypto
.
randomBytes
(
32
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment