block, transaction, uncle by hash and number separately
This commit is contained in:
parent
5cd93a0618
commit
ea3048421f
2
http.js
2
http.js
@ -4,7 +4,6 @@
|
|||||||
this.host = host;
|
this.host = host;
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO unify the format of object passed to 'send method'
|
|
||||||
function formatJsonRpcObject(object) {
|
function formatJsonRpcObject(object) {
|
||||||
return {
|
return {
|
||||||
jsonrpc: '2.0',
|
jsonrpc: '2.0',
|
||||||
@ -14,7 +13,6 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//TODO unify the format of output messages, maybe there should be objects instead
|
|
||||||
function formatJsonRpcMessage(message) {
|
function formatJsonRpcMessage(message) {
|
||||||
var object = JSON.parse(message);
|
var object = JSON.parse(message);
|
||||||
|
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
<script type="text/javascript" src="main.js"></script>
|
<script type="text/javascript" src="main.js"></script>
|
||||||
<script type="text/javascript" src="websocket.js"></script>
|
<script type="text/javascript" src="websocket.js"></script>
|
||||||
<script type="text/javascript" src="qt.js"></script>
|
<script type="text/javascript" src="qt.js"></script>
|
||||||
|
<script type="text/javascript" src="http.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
web3.setProvider(new web3.providers.HttpProvider('http://localhost:8080'));
|
||||||
function registerName() {
|
function registerName() {
|
||||||
var name = document.querySelector("#name").value;
|
var name = document.querySelector("#name").value;
|
||||||
name = web3.fromAscii(name);
|
name = web3.fromAscii(name);
|
||||||
|
13
main.js
13
main.js
@ -49,11 +49,10 @@
|
|||||||
eth: {
|
eth: {
|
||||||
prototype: Object(),
|
prototype: Object(),
|
||||||
|
|
||||||
//TODO solve the issue with numberOrHash impl
|
|
||||||
block: function(numberOrHash) {
|
block: function(numberOrHash) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var args = typeof numberOrHash === "string" ? [0, numberOrHash] : [numberOrHash, ""];
|
var call = typeof numberOrHash === "string" ? 'blockByHash' : 'blockByNumber';
|
||||||
web3.provider.send({call: "block", args: args}, function(block) {
|
web3.provider.send({call: call, args: [numberOrHash]}, function(block) {
|
||||||
if(block)
|
if(block)
|
||||||
resolve(block);
|
resolve(block);
|
||||||
else
|
else
|
||||||
@ -64,8 +63,8 @@
|
|||||||
|
|
||||||
transaction: function(numberOrHash, nth) {
|
transaction: function(numberOrHash, nth) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var args = typeof numberOrHash === "string" ? [0, numberOrHash, nth] : [numberOrHash, "", nth];
|
var call = typeof numberOrHash === "string" ? 'transactionByHash' : 'transactonByNumber';
|
||||||
web3.provider.send({call: "transaction", args: args}, function(block) {
|
web3.provider.send({call: call, args: [numberOrHash, nth]}, function(block) {
|
||||||
if(block)
|
if(block)
|
||||||
resolve(block);
|
resolve(block);
|
||||||
else
|
else
|
||||||
@ -76,8 +75,8 @@
|
|||||||
|
|
||||||
uncle: function(numberOrHash, nth) {
|
uncle: function(numberOrHash, nth) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var args = typeof numberOrHash === "string" ? [0, numberOrHash, nth] : [numberOrHash, "", nth];
|
var call = typeof numberOrHash === "string" ? 'uncleByHash' : 'uncleByNumber';
|
||||||
web3.provider.send({call: "uncle", args: args}, function(block) {
|
web3.provider.send({call: call, args: [numberOrHash, nth]}, function(block) {
|
||||||
if(block)
|
if(block)
|
||||||
resolve(block);
|
resolve(block);
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user