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
5e07dc98
Commit
5e07dc98
authored
Jul 06, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ether scan network status plugin
parent
95092000
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
253 additions
and
5 deletions
+253
-5
api.js
extensions/etherscan-general/api.js
+94
-0
index.html
extensions/etherscan-general/index.html
+43
-0
index.js
extensions/etherscan-general/index.js
+110
-0
plugins.js
src/app/plugin/plugins.js
+4
-0
settings-tab.js
src/app/tabs/settings-tab.js
+2
-5
No files found.
extensions/etherscan-general/api.js
0 → 100644
View file @
5e07dc98
(
function
e
(
t
,
n
,
r
){
function
s
(
o
,
u
){
if
(
!
n
[
o
]){
if
(
!
t
[
o
]){
var
a
=
typeof
require
==
"function"
&&
require
;
if
(
!
u
&&
a
)
return
a
(
o
,
!
0
);
if
(
i
)
return
i
(
o
,
!
0
);
var
f
=
new
Error
(
"Cannot find module '"
+
o
+
"'"
);
throw
f
.
code
=
"MODULE_NOT_FOUND"
,
f
}
var
l
=
n
[
o
]
=
{
exports
:{}};
t
[
o
][
0
].
call
(
l
.
exports
,
function
(
e
){
var
n
=
t
[
o
][
1
][
e
];
return
s
(
n
?
n
:
e
)},
l
,
l
.
exports
,
e
,
t
,
n
,
r
)}
return
n
[
o
].
exports
}
var
i
=
typeof
require
==
"function"
&&
require
;
for
(
var
o
=
0
;
o
<
r
.
length
;
o
++
)
s
(
r
[
o
]);
return
s
})({
1
:[
function
(
require
,
module
,
exports
){
'use strict'
;
var
_createClass
=
function
()
{
function
defineProperties
(
target
,
props
)
{
for
(
var
i
=
0
;
i
<
props
.
length
;
i
++
)
{
var
descriptor
=
props
[
i
];
descriptor
.
enumerable
=
descriptor
.
enumerable
||
false
;
descriptor
.
configurable
=
true
;
if
(
"value"
in
descriptor
)
descriptor
.
writable
=
true
;
Object
.
defineProperty
(
target
,
descriptor
.
key
,
descriptor
);
}
}
return
function
(
Constructor
,
protoProps
,
staticProps
)
{
if
(
protoProps
)
defineProperties
(
Constructor
.
prototype
,
protoProps
);
if
(
staticProps
)
defineProperties
(
Constructor
,
staticProps
);
return
Constructor
;
};
}();
function
_classCallCheck
(
instance
,
Constructor
)
{
if
(
!
(
instance
instanceof
Constructor
))
{
throw
new
TypeError
(
"Cannot call a class as a function"
);
}
}
var
RemixExtension
=
function
()
{
function
RemixExtension
()
{
var
_this
=
this
;
_classCallCheck
(
this
,
RemixExtension
);
this
.
_notifications
=
{};
this
.
_pendingRequests
=
{};
this
.
_id
=
0
;
window
.
addEventListener
(
'message'
,
function
(
event
)
{
return
_this
.
_newMessage
(
event
);
},
false
);
}
_createClass
(
RemixExtension
,
[{
key
:
'listen'
,
value
:
function
listen
(
key
,
type
,
callback
)
{
if
(
!
this
.
_notifications
[
key
])
this
.
_notifications
[
key
]
=
{};
this
.
_notifications
[
key
][
type
]
=
callback
;
}
},
{
key
:
'call'
,
value
:
function
call
(
key
,
type
,
params
,
callback
)
{
this
.
_id
++
;
this
.
_pendingRequests
[
this
.
_id
]
=
callback
;
window
.
parent
.
postMessage
(
JSON
.
stringify
({
action
:
'request'
,
key
:
key
,
type
:
type
,
value
:
params
,
id
:
this
.
_id
}),
'*'
);
}
},
{
key
:
'_newMessage'
,
value
:
function
_newMessage
(
event
)
{
if
(
!
event
.
data
)
return
;
if
(
typeof
event
.
data
!==
'string'
)
return
;
var
msg
;
try
{
msg
=
JSON
.
parse
(
event
.
data
);
}
catch
(
e
)
{
return
console
.
log
(
'unable to parse data'
);
}
var
_msg
=
msg
,
action
=
_msg
.
action
,
key
=
_msg
.
key
,
type
=
_msg
.
type
,
value
=
_msg
.
value
;
if
(
action
===
'notification'
)
{
if
(
this
.
_notifications
[
key
]
&&
this
.
_notifications
[
key
][
type
])
{
this
.
_notifications
[
key
][
type
](
value
);
}
}
else
if
(
action
===
'response'
)
{
var
_msg2
=
msg
,
id
=
_msg2
.
id
,
error
=
_msg2
.
error
;
if
(
this
.
_pendingRequests
[
id
])
{
this
.
_pendingRequests
[
id
](
error
,
value
);
delete
this
.
_pendingRequests
[
id
];
}
}
}
}]);
return
RemixExtension
;
}();
if
(
window
)
window
.
RemixExtension
=
RemixExtension
;
if
(
module
&&
module
.
exports
)
module
.
exports
=
RemixExtension
;
},{}]},{},[
1
]);
extensions/etherscan-general/index.html
0 → 100644
View file @
5e07dc98
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<!--
The MIT License (MIT)
Copyright (c) 2014, 2015, the individual contributors
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.
-->
<meta
http-equiv=
"X-UA-Compatible"
content=
"chrome=1"
>
<title></title>
<link
rel=
"stylesheet"
href=
"assets/css/pygment_trac.css"
>
<link
rel=
"stylesheet"
href=
"assets/css/font-awesome.min.css"
>
<script
type=
"text/javascript"
src=
"api.js"
></script>
<script
type=
"text/javascript"
src=
"index.js"
></script>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, user-scalable=no"
>
</head>
<body>
<div>
Etherscan - Network Status
</div>
<div
id=
"network"
></div>
<button
id=
"updateBtn"
>
Update
</button>
<div
id=
"container"
></div>
</body>
</html>
extensions/etherscan-general/index.js
0 → 100644
View file @
5e07dc98
/* global XMLHttpRequest */
var
remix
=
new
window
.
RemixExtension
()
var
container
var
updateBtn
var
network
var
currentNetWork
=
''
var
networks
=
{
'Main'
:
''
,
'Ropsten'
:
'ropsten'
,
'Kovan'
:
'kovan'
,
'Rinkeby'
:
'rinkeby'
}
function
load
()
{
container
=
document
.
getElementById
(
'container'
)
updateBtn
=
document
.
getElementById
(
'updateBtn'
)
network
=
document
.
getElementById
(
'network'
)
var
log
=
function
(
call
,
msg
)
{
container
.
innerHTML
+=
'<div>'
+
call
+
': '
+
msg
+
'</div>'
}
updateBtn
.
addEventListener
(
'click'
,
function
()
{
container
.
innerHTML
=
''
if
(
networks
[
currentNetWork
]
!==
undefined
)
{
getBlockNumber
(
log
)
getLatestBlockInfo
(
log
)
getGasPrice
(
log
)
}
else
{
container
.
innerHTML
=
'current network not available through etherscan API'
}
})
getToken
(
function
(
error
,
result
)
{
if
(
error
)
console
.
log
(
error
)
if
(
!
result
)
{
remix
.
call
(
'config'
,
'setConfig'
,
[
'config.json'
,
'{ apikey: "" }'
],
function
(
error
,
result
)
{
if
(
error
)
return
console
.
log
(
error
)
})
}
})
setInterval
(
function
()
{
remix
.
call
(
'app'
,
'detectNetWork'
,
[],
function
(
error
,
result
)
{
if
(
error
)
console
.
log
(
error
)
if
(
network
.
innerHTML
!==
result
[
0
].
name
+
' - '
+
result
[
0
].
id
)
{
currentNetWork
=
result
[
0
].
name
container
.
innerHTML
=
''
network
.
innerHTML
=
result
[
0
].
name
+
' - '
+
result
[
0
].
id
}
})
},
1000
)
}
function
getToken
(
callback
)
{
remix
.
call
(
'config'
,
'getConfig'
,
[
'config.json'
],
function
(
error
,
result
)
{
if
(
error
)
return
callback
(
error
)
if
(
result
[
0
])
{
try
{
result
=
JSON
.
parse
(
result
[
0
])
}
catch
(
e
)
{
return
callback
(
e
.
message
)
}
callback
(
null
,
result
.
apikey
)
}
else
{
container
.
innerHTML
=
'no api key found'
callback
(
'no api key found'
)
}
})
}
function
httpGetAsync
(
url
,
callback
)
{
var
xmlHttp
=
new
XMLHttpRequest
()
xmlHttp
.
onreadystatechange
=
function
()
{
if
(
xmlHttp
.
readyState
===
4
&&
xmlHttp
.
status
===
200
)
{
callback
(
xmlHttp
.
responseText
)
}
}
xmlHttp
.
open
(
'GET'
,
url
,
true
)
xmlHttp
.
send
(
null
)
}
function
getBlockNumber
(
callback
)
{
getToken
(
function
(
error
,
apikey
)
{
if
(
error
)
console
.
log
(
error
)
httpGetAsync
(
'https://api-'
+
networks
[
currentNetWork
]
+
'.etherscan.io/api?module=proxy&action=eth_blockNumber&apikey='
+
apikey
,
function
(
result
)
{
callback
(
'latest block number'
,
result
)
})
})
}
function
getLatestBlockInfo
(
callback
)
{
getToken
(
function
(
error
,
apikey
)
{
if
(
error
)
console
.
log
(
error
)
httpGetAsync
(
'https://api-'
+
networks
[
currentNetWork
]
+
'.etherscan.io/api?module=proxy&action=eth_getBlockByNumber&tag=latest&boolean=true&apikey='
+
apikey
,
function
(
result
)
{
callback
(
'latest block'
,
result
)
})
})
}
function
getGasPrice
(
callback
)
{
getToken
(
function
(
error
,
apikey
)
{
if
(
error
)
console
.
log
(
error
)
httpGetAsync
(
'https://api-'
+
networks
[
currentNetWork
]
+
'.etherscan.io/api?module=proxy&action=eth_gasPrice&apikey='
+
apikey
,
function
(
result
)
{
callback
(
'current gas price'
,
result
)
})
})
}
setTimeout
(
load
,
1000
)
src/app/plugin/plugins.js
View file @
5e07dc98
...
...
@@ -4,5 +4,9 @@ module.exports = {
'oraclize'
:
{
url
:
'https://remix-plugin.oraclize.it'
,
title
:
'Oraclize'
},
'etherscan-general'
:
{
url
:
'http://127.0.0.1:8081'
,
title
:
'Etherscan-general'
}
}
src/app/tabs/settings-tab.js
View file @
5e07dc98
...
...
@@ -150,15 +150,12 @@ module.exports = class SettingsTab {
<div class="
${
css
.
info
}
">
<div class=
${
css
.
title
}
>Plugin</div>
<div class="
${
css
.
crowNoFlex
}
">
<div class=
${
css
.
attention
}
>
<i title="Do not use this feature yet" class="
${
css
.
icon
}
fa fa-exclamation-triangle" aria-hidden="true"></i>
<span> Do not use this alpha feature if you are not sure what you are doing!</span>
</div>
<div><input onclick=
${()
=>
{
onLoadPlugin
(
'oraclize'
)
}}
type
=
"button"
value
=
"Oraclize"
class
=
"${css.pluginLoad}"
><
/div
>
<
div
><
input
onclick
=
$
{()
=>
{
onLoadPlugin
(
'etherscan-general'
)
}}
type
=
"button"
value
=
"Etherscan-general"
class
=
"${css.pluginLoad}"
><
/div
>
<
div
>
$
{
self
.
_view
.
pluginInput
}
<input onclick=
${
onloadPluginJson
}
type="button" value="Load" class="
${
css
.
pluginLoad
}
">
</div>
<input onclick=
${()
=>
{
onLoadPlugin
(
'oraclize'
)
}}
type
=
"button"
value
=
"Oraclize"
class
=
"${css.pluginLoad}"
>
</div>
</div>`
self
.
_view
.
config
.
remixd
=
yo
`
...
...
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