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
53b54e13
Unverified
Commit
53b54e13
authored
May 13, 2019
by
yann300
Committed by
GitHub
May 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1967 from ethereum/issue#1966-createvmaccount_api
Use an object for createVMAccount
parents
880a131d
4a9889a9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
9 deletions
+20
-9
universal-dapp.js
src/universal-dapp.js
+12
-7
plugin.js
test-browser/plugin/plugin.js
+4
-1
remix.js
test-browser/plugin/remix.js
+4
-1
No files found.
src/universal-dapp.js
View file @
53b54e13
...
...
@@ -82,13 +82,18 @@ module.exports = class UniversalDApp extends UdappApi {
this
.
transactionContextAPI
=
transactionContextAPI
}
createVMAccount
(
privateKey
,
balance
,
cb
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
executionContext
.
getProvider
()
!==
'vm'
)
return
reject
(
'plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed'
)
this
.
_addAccount
(
privateKey
,
balance
)
privateKey
=
Buffer
.
from
(
privateKey
,
'hex'
)
resolve
(
'0x'
+
ethJSUtil
.
privateToAddress
(
privateKey
).
toString
(
'hex'
))
})
/**
* Create a VM Account
* @param {{privateKey: string, balance: string}} newAccount The new account to create
*/
createVMAccount
(
newAccount
)
{
const
{
privateKey
,
balance
}
=
newAccount
if
(
executionContext
.
getProvider
()
!==
'vm'
)
{
throw
new
Error
(
'plugin API does not allow creating a new account through web3 connection. Only vm mode is allowed'
)
}
this
.
_addAccount
(
privateKey
,
balance
)
const
privKey
=
Buffer
.
from
(
privateKey
,
'hex'
)
return
'0x'
+
ethJSUtil
.
privateToAddress
(
privKey
).
toString
(
'hex'
)
}
newAccount
(
password
,
passwordPromptCb
,
cb
)
{
...
...
test-browser/plugin/plugin.js
View file @
53b54e13
...
...
@@ -44,7 +44,10 @@ window.onload = function () {
})
document
.
querySelector
(
'input#testaccountcreation'
).
addEventListener
(
'click'
,
function
()
{
extension
.
call
(
'udapp'
,
'createVMAccount'
,
[
'71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce'
,
'0x56BC75E2D63100000'
],
extension
.
call
(
'udapp'
,
'createVMAccount'
,
[{
privateKey
:
'71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce'
,
balance
:
'0x56BC75E2D63100000'
}],
function
(
error
,
result
)
{
console
.
log
(
error
,
result
)
})
})
...
...
test-browser/plugin/remix.js
View file @
53b54e13
...
...
@@ -64,7 +64,10 @@ window.onload = function () {
action
:
'request'
,
key
:
'udapp'
,
type
:
'createVMAccount'
,
value
:
[
'71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce'
,
'0x56BC75E2D63100000'
],
value
:
[{
privateKey
:
'71975fbf7fe448e004ac7ae54cad0a383c3906055a75468714156a07385e96ce'
,
balance
:
'0x56BC75E2D63100000'
}],
id
:
38
}),
'*'
)
})
...
...
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