forked from cerc-io/plugeth
jsre, rpc/api: pull in new web3 and use hex numbers
This commit is contained in:
parent
99b62f36b6
commit
d4d3fc6a70
@ -1002,7 +1002,7 @@ var formatInputDynamicBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputString = function (value) {
|
||||
var result = utils.fromAscii(value).substr(2);
|
||||
var result = utils.fromUtf8(value).substr(2);
|
||||
var length = result.length / 2;
|
||||
var l = Math.floor((result.length + 63) / 64);
|
||||
result = utils.padRight(result, l * 64);
|
||||
@ -1139,7 +1139,7 @@ var formatOutputDynamicBytes = function (param) {
|
||||
*/
|
||||
var formatOutputString = function (param) {
|
||||
var length = (new BigNumber(param.dynamicPart().slice(0, 64), 16)).toNumber() * 2;
|
||||
return utils.toAscii(param.dynamicPart().substr(64, length));
|
||||
return utils.toUtf8(param.dynamicPart().substr(64, length));
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1697,7 +1697,7 @@ var SolidityType = require('./type');
|
||||
*/
|
||||
var SolidityTypeUInt = function () {
|
||||
this._inputFormatter = f.formatInputInt;
|
||||
this._outputFormatter = f.formatOutputInt;
|
||||
this._outputFormatter = f.formatOutputUInt;
|
||||
};
|
||||
|
||||
SolidityTypeUInt.prototype = new SolidityType({});
|
||||
@ -1876,7 +1876,7 @@ module.exports = function (str, isNew) {
|
||||
console.warn('new usage: \'web3.sha3("hello")\'');
|
||||
console.warn('see https://github.com/ethereum/web3.js/pull/205');
|
||||
console.warn('if you need to hash hex value, you can do \'sha3("0xfff", true)\'');
|
||||
str = utils.toAscii(str);
|
||||
str = utils.toUtf8(str);
|
||||
}
|
||||
|
||||
return sha3(str, {
|
||||
@ -1885,7 +1885,7 @@ module.exports = function (str, isNew) {
|
||||
};
|
||||
|
||||
|
||||
},{"./utils":20,"crypto-js/sha3":47}],20:[function(require,module,exports){
|
||||
},{"./utils":20,"crypto-js/sha3":48}],20:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -1923,6 +1923,7 @@ module.exports = function (str, isNew) {
|
||||
|
||||
|
||||
var BigNumber = require('bignumber.js');
|
||||
var utf8 = require('utf8');
|
||||
|
||||
var unitMap = {
|
||||
'wei': '1',
|
||||
@ -1978,8 +1979,29 @@ var padRight = function (string, chars, sign) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get sting from it's hex representation
|
||||
* TODO: it should be called toUTF8
|
||||
* Should be called to get utf8 from it's hex representation
|
||||
*
|
||||
* @method toUtf8
|
||||
* @param {String} string in hex
|
||||
* @returns {String} ascii string representation of hex value
|
||||
*/
|
||||
var toUtf8 = function(hex) {
|
||||
// Find termination
|
||||
var str = "";
|
||||
var i = 0, l = hex.length;
|
||||
if (hex.substring(0, 2) === '0x') {
|
||||
i = 2;
|
||||
}
|
||||
for (; i < l; i+=2) {
|
||||
var code = parseInt(hex.substr(i, 2), 16);
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
|
||||
return utf8.decode(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Should be called to get ascii from it's hex representation
|
||||
*
|
||||
* @method toAscii
|
||||
* @param {String} string in hex
|
||||
@ -1997,25 +2019,26 @@ var toAscii = function(hex) {
|
||||
str += String.fromCharCode(code);
|
||||
}
|
||||
|
||||
return decodeURIComponent(escape(str)); // jshint ignore:line
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Shold be called to get hex representation (prefixed by 0x) of ascii string
|
||||
* Shold be called to get hex representation (prefixed by 0x) of utf8 string
|
||||
*
|
||||
* @method toHexNative
|
||||
* @method fromUtf8
|
||||
* @param {String} string
|
||||
* @param {Number} optional padding
|
||||
* @returns {String} hex representation of input string
|
||||
*/
|
||||
var toHexNative = function(str) {
|
||||
str = unescape(encodeURIComponent(str)); // jshint ignore:line
|
||||
var fromUtf8 = function(str) {
|
||||
str = utf8.encode(str);
|
||||
var hex = "";
|
||||
for(var i = 0; i < str.length; i++) {
|
||||
var n = str.charCodeAt(i).toString(16);
|
||||
hex += n.length < 2 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return hex;
|
||||
return "0x" + hex;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2026,11 +2049,14 @@ var toHexNative = function(str) {
|
||||
* @param {Number} optional padding
|
||||
* @returns {String} hex representation of input string
|
||||
*/
|
||||
var fromAscii = function(str, pad) {
|
||||
pad = pad === undefined ? 0 : pad;
|
||||
var hex = toHexNative(str);
|
||||
while (hex.length < pad*2)
|
||||
hex += "00";
|
||||
var fromAscii = function(str) {
|
||||
var hex = "";
|
||||
for(var i = 0; i < str.length; i++) {
|
||||
var code = str.charCodeAt(i);
|
||||
var n = code.toString(16);
|
||||
hex += n.length < 2 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return "0x" + hex;
|
||||
};
|
||||
|
||||
@ -2113,7 +2139,7 @@ var toHex = function (val) {
|
||||
return fromDecimal(val);
|
||||
|
||||
if (isObject(val))
|
||||
return fromAscii(JSON.stringify(val));
|
||||
return fromUtf8(JSON.stringify(val));
|
||||
|
||||
// if its a negative number, pass it through fromDecimal
|
||||
if (isString(val)) {
|
||||
@ -2242,7 +2268,7 @@ var toTwosComplement = function (number) {
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isStrictAddress = function (address) {
|
||||
return /^0x[0-9a-f]{40}$/.test(address);
|
||||
return /^0x[0-9a-f]{40}$/i.test(address);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2253,7 +2279,7 @@ var isStrictAddress = function (address) {
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var isAddress = function (address) {
|
||||
return /^(0x)?[0-9a-f]{40}$/.test(address);
|
||||
return /^(0x)?[0-9a-f]{40}$/i.test(address);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -2365,7 +2391,9 @@ module.exports = {
|
||||
toHex: toHex,
|
||||
toDecimal: toDecimal,
|
||||
fromDecimal: fromDecimal,
|
||||
toUtf8: toUtf8,
|
||||
toAscii: toAscii,
|
||||
fromUtf8: fromUtf8,
|
||||
fromAscii: fromAscii,
|
||||
transformToFullName: transformToFullName,
|
||||
extractDisplayName: extractDisplayName,
|
||||
@ -2386,10 +2414,9 @@ module.exports = {
|
||||
isJson: isJson
|
||||
};
|
||||
|
||||
|
||||
},{"bignumber.js":"bignumber.js"}],21:[function(require,module,exports){
|
||||
},{"bignumber.js":"bignumber.js","utf8":50}],21:[function(require,module,exports){
|
||||
module.exports={
|
||||
"version": "0.12.1"
|
||||
"version": "0.13.0"
|
||||
}
|
||||
|
||||
},{}],22:[function(require,module,exports){
|
||||
@ -2426,6 +2453,7 @@ var db = require('./web3/methods/db');
|
||||
var shh = require('./web3/methods/shh');
|
||||
var watches = require('./web3/methods/watches');
|
||||
var Filter = require('./web3/filter');
|
||||
var IsSyncing = require('./web3/syncing');
|
||||
var utils = require('./utils/utils');
|
||||
var formatters = require('./web3/formatters');
|
||||
var RequestManager = require('./web3/requestmanager');
|
||||
@ -2480,6 +2508,10 @@ web3.version = {};
|
||||
web3.version.api = version.version;
|
||||
web3.eth = {};
|
||||
|
||||
web3.eth.isSyncing = function (callback) {
|
||||
return new IsSyncing(callback);
|
||||
};
|
||||
|
||||
/*jshint maxparams:4 */
|
||||
web3.eth.filter = function (fil, callback) {
|
||||
return new Filter(fil, watches.eth(), formatters.outputLogFormatter, callback);
|
||||
@ -2499,14 +2531,16 @@ web3.setProvider = function (provider) {
|
||||
web3.isConnected = function(){
|
||||
return (this.currentProvider && this.currentProvider.isConnected());
|
||||
};
|
||||
web3.reset = function () {
|
||||
RequestManager.getInstance().reset();
|
||||
web3.reset = function (keepIsSyncing) {
|
||||
RequestManager.getInstance().reset(keepIsSyncing);
|
||||
c.defaultBlock = 'latest';
|
||||
c.defaultAccount = undefined;
|
||||
};
|
||||
web3.toHex = utils.toHex;
|
||||
web3.toAscii = utils.toAscii;
|
||||
web3.toUtf8 = utils.toUtf8;
|
||||
web3.fromAscii = utils.fromAscii;
|
||||
web3.fromUtf8 = utils.fromUtf8;
|
||||
web3.toDecimal = utils.toDecimal;
|
||||
web3.fromDecimal = utils.fromDecimal;
|
||||
web3.toBigNumber = utils.toBigNumber;
|
||||
@ -2569,7 +2603,7 @@ setupMethods(web3.shh, shh.methods);
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43}],23:[function(require,module,exports){
|
||||
},{"./utils/config":18,"./utils/sha3":19,"./utils/utils":20,"./version.json":21,"./web3/batch":24,"./web3/filter":28,"./web3/formatters":29,"./web3/method":35,"./web3/methods/db":36,"./web3/methods/eth":37,"./web3/methods/net":38,"./web3/methods/shh":39,"./web3/methods/watches":40,"./web3/property":42,"./web3/requestmanager":43,"./web3/syncing":44}],23:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
@ -3301,7 +3335,7 @@ var toTopic = function(value){
|
||||
if(value.indexOf('0x') === 0)
|
||||
return value;
|
||||
else
|
||||
return utils.fromAscii(value);
|
||||
return utils.fromUtf8(value);
|
||||
};
|
||||
|
||||
/// This method should be called on options object, to verify deprecated properties && lazy load dynamic ones
|
||||
@ -3371,12 +3405,14 @@ var pollFilter = function(self) {
|
||||
});
|
||||
}
|
||||
|
||||
messages.forEach(function (message) {
|
||||
message = self.formatter ? self.formatter(message) : message;
|
||||
self.callbacks.forEach(function (callback) {
|
||||
callback(null, message);
|
||||
if(utils.isArray(messages)) {
|
||||
messages.forEach(function (message) {
|
||||
message = self.formatter ? self.formatter(message) : message;
|
||||
self.callbacks.forEach(function (callback) {
|
||||
callback(null, message);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
RequestManager.getInstance().startPolling({
|
||||
@ -3396,6 +3432,7 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
this.implementation = implementation;
|
||||
this.filterId = null;
|
||||
this.callbacks = [];
|
||||
this.getLogsCallbacks = [];
|
||||
this.pollFilters = [];
|
||||
this.formatter = formatter;
|
||||
this.implementation.newFilter(this.options, function(error, id){
|
||||
@ -3406,6 +3443,13 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
} else {
|
||||
self.filterId = id;
|
||||
|
||||
// check if there are get pending callbacks as a consequence
|
||||
// of calling get() with filterId unassigned.
|
||||
self.getLogsCallbacks.forEach(function (cb){
|
||||
self.get(cb);
|
||||
});
|
||||
self.getLogsCallbacks = [];
|
||||
|
||||
// get filter logs for the already existing watch calls
|
||||
self.callbacks.forEach(function(cb){
|
||||
getLogsAtStart(self, cb);
|
||||
@ -3444,16 +3488,25 @@ Filter.prototype.stopWatching = function () {
|
||||
Filter.prototype.get = function (callback) {
|
||||
var self = this;
|
||||
if (utils.isFunction(callback)) {
|
||||
this.implementation.getLogs(this.filterId, function(err, res){
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, res.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
}));
|
||||
}
|
||||
});
|
||||
if (this.filterId === null) {
|
||||
// If filterId is not set yet, call it back
|
||||
// when newFilter() assigns it.
|
||||
this.getLogsCallbacks.push(callback);
|
||||
} else {
|
||||
this.implementation.getLogs(this.filterId, function(err, res){
|
||||
if (err) {
|
||||
callback(err);
|
||||
} else {
|
||||
callback(null, res.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (this.filterId === null) {
|
||||
throw new Error('Filter ID Error: filter().get() can\'t be chained synchronous, please provide a callback for the get() method.');
|
||||
}
|
||||
var logs = this.implementation.getLogs(this.filterId);
|
||||
return logs.map(function (log) {
|
||||
return self.formatter ? self.formatter(log) : log;
|
||||
@ -3690,7 +3743,7 @@ var inputPostFormatter = function(post) {
|
||||
|
||||
// format the following options
|
||||
post.topics = post.topics.map(function(topic){
|
||||
return utils.fromAscii(topic);
|
||||
return utils.fromUtf8(topic);
|
||||
});
|
||||
|
||||
return post;
|
||||
@ -3710,7 +3763,7 @@ var outputPostFormatter = function(post){
|
||||
post.ttl = utils.toDecimal(post.ttl);
|
||||
post.workProved = utils.toDecimal(post.workProved);
|
||||
post.payloadRaw = post.payload;
|
||||
post.payload = utils.toAscii(post.payload);
|
||||
post.payload = utils.toUtf8(post.payload);
|
||||
|
||||
if (utils.isJson(post.payload)) {
|
||||
post.payload = JSON.parse(post.payload);
|
||||
@ -3721,7 +3774,7 @@ var outputPostFormatter = function(post){
|
||||
post.topics = [];
|
||||
}
|
||||
post.topics = post.topics.map(function(topic){
|
||||
return utils.toAscii(topic);
|
||||
return utils.toUtf8(topic);
|
||||
});
|
||||
|
||||
return post;
|
||||
@ -3739,6 +3792,16 @@ var inputAddressFormatter = function (address) {
|
||||
throw 'invalid address';
|
||||
};
|
||||
|
||||
|
||||
var outputSyncingFormatter = function(result) {
|
||||
|
||||
result.startingBlock = utils.toDecimal(result.startingBlock);
|
||||
result.currentBlock = utils.toDecimal(result.currentBlock);
|
||||
result.highestBlock = utils.toDecimal(result.highestBlock);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,
|
||||
inputBlockNumberFormatter: inputBlockNumberFormatter,
|
||||
@ -3751,7 +3814,8 @@ module.exports = {
|
||||
outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,
|
||||
outputBlockFormatter: outputBlockFormatter,
|
||||
outputLogFormatter: outputLogFormatter,
|
||||
outputPostFormatter: outputPostFormatter
|
||||
outputPostFormatter: outputPostFormatter,
|
||||
outputSyncingFormatter: outputSyncingFormatter
|
||||
};
|
||||
|
||||
|
||||
@ -4289,7 +4353,7 @@ Iban.isValid = function (iban) {
|
||||
* @returns {Boolean} true if it is, otherwise false
|
||||
*/
|
||||
Iban.prototype.isValid = function () {
|
||||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30})$/.test(this._iban) &&
|
||||
return /^XE[0-9]{2}(ETH[0-9A-Z]{13}|[0-9A-Z]{30,31})$/.test(this._iban) &&
|
||||
mod9710(iso13616Prepare(this._iban)) === 1;
|
||||
};
|
||||
|
||||
@ -5185,6 +5249,11 @@ var properties = [
|
||||
getter: 'eth_hashrate',
|
||||
outputFormatter: utils.toDecimal
|
||||
}),
|
||||
new Property({
|
||||
name: 'syncing',
|
||||
getter: 'eth_syncing',
|
||||
outputFormatter: formatters.outputSyncingFormatter
|
||||
}),
|
||||
new Property({
|
||||
name: 'gasPrice',
|
||||
getter: 'eth_gasPrice',
|
||||
@ -5811,11 +5880,15 @@ RequestManager.prototype.stopPolling = function (pollId) {
|
||||
*
|
||||
* @method reset
|
||||
*/
|
||||
RequestManager.prototype.reset = function () {
|
||||
RequestManager.prototype.reset = function (keepIsSyncing) {
|
||||
for (var key in this.polls) {
|
||||
this.polls[key].uninstall();
|
||||
// remove all polls, except sync polls,
|
||||
// they need to be removed manually by calling syncing.stopWatching()
|
||||
if(!keepIsSyncing || key.indexOf('syncPoll_') === -1) {
|
||||
this.polls[key].uninstall();
|
||||
delete this.polls[key];
|
||||
}
|
||||
}
|
||||
this.polls = {};
|
||||
|
||||
if (this.timeout) {
|
||||
clearTimeout(this.timeout);
|
||||
@ -5843,10 +5916,10 @@ RequestManager.prototype.poll = function () {
|
||||
}
|
||||
|
||||
var pollsData = [];
|
||||
var pollsKeys = [];
|
||||
var pollsIds = [];
|
||||
for (var key in this.polls) {
|
||||
pollsData.push(this.polls[key].data);
|
||||
pollsKeys.push(key);
|
||||
pollsIds.push(key);
|
||||
}
|
||||
|
||||
if (pollsData.length === 0) {
|
||||
@ -5855,8 +5928,17 @@ RequestManager.prototype.poll = function () {
|
||||
|
||||
var payload = Jsonrpc.getInstance().toBatchPayload(pollsData);
|
||||
|
||||
// map the request id to they poll id
|
||||
var pollsIdMap = {};
|
||||
payload.forEach(function(load, index){
|
||||
pollsIdMap[load.id] = pollsIds[index];
|
||||
});
|
||||
|
||||
|
||||
var self = this;
|
||||
this.provider.sendAsync(payload, function (error, results) {
|
||||
|
||||
|
||||
// TODO: console log?
|
||||
if (error) {
|
||||
return;
|
||||
@ -5865,12 +5947,12 @@ RequestManager.prototype.poll = function () {
|
||||
if (!utils.isArray(results)) {
|
||||
throw errors.InvalidResponse(results);
|
||||
}
|
||||
results.map(function (result) {
|
||||
var id = pollsIdMap[result.id];
|
||||
|
||||
results.map(function (result, index) {
|
||||
var key = pollsKeys[index];
|
||||
// make sure the filter is still installed after arrival of the request
|
||||
if (self.polls[key]) {
|
||||
result.callback = self.polls[key].callback;
|
||||
if (self.polls[id]) {
|
||||
result.callback = self.polls[id].callback;
|
||||
return result;
|
||||
} else
|
||||
return false;
|
||||
@ -5882,8 +5964,6 @@ RequestManager.prototype.poll = function () {
|
||||
result.callback(errors.InvalidResponse(result));
|
||||
}
|
||||
return valid;
|
||||
}).filter(function (result) {
|
||||
return utils.isArray(result.result) && result.result.length > 0;
|
||||
}).forEach(function (result) {
|
||||
result.callback(null, result.result);
|
||||
});
|
||||
@ -5910,6 +5990,109 @@ module.exports = RequestManager;
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/** @file syncing.js
|
||||
* @authors:
|
||||
* Fabian Vogelsteller <fabian@ethdev.com>
|
||||
* @date 2015
|
||||
*/
|
||||
|
||||
var RequestManager = require('./requestmanager');
|
||||
var Method = require('./method');
|
||||
var formatters = require('./formatters');
|
||||
var utils = require('../utils/utils');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Adds the callback and sets up the methods, to iterate over the results.
|
||||
|
||||
@method pollSyncing
|
||||
@param {Object} self
|
||||
*/
|
||||
var pollSyncing = function(self) {
|
||||
var lastSyncState = false;
|
||||
|
||||
var onMessage = function (error, sync) {
|
||||
if (error) {
|
||||
return self.callbacks.forEach(function (callback) {
|
||||
callback(error);
|
||||
});
|
||||
}
|
||||
|
||||
if(utils.isObject(sync))
|
||||
sync = self.implementation.outputFormatter(sync);
|
||||
|
||||
self.callbacks.forEach(function (callback) {
|
||||
if(lastSyncState !== sync) {
|
||||
|
||||
// call the callback with true first so the app can stop anything, before receiving the sync data
|
||||
if(!lastSyncState && utils.isObject(sync))
|
||||
callback(null, true);
|
||||
|
||||
// call on the next CPU cycle, so the actions of the sync stop can be processes first
|
||||
setTimeout(function() {
|
||||
callback(null, sync);
|
||||
}, 1);
|
||||
|
||||
lastSyncState = sync;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
RequestManager.getInstance().startPolling({
|
||||
method: self.implementation.call,
|
||||
params: [],
|
||||
}, self.pollId, onMessage, self.stopWatching.bind(self));
|
||||
|
||||
};
|
||||
|
||||
var IsSyncing = function (callback) {
|
||||
this.pollId = 'syncPoll_'+ Math.floor(Math.random() * 1000);
|
||||
this.callbacks = [];
|
||||
this.implementation = new Method({
|
||||
name: 'isSyncing',
|
||||
call: 'eth_syncing',
|
||||
params: 0,
|
||||
outputFormatter: formatters.outputSyncingFormatter
|
||||
});
|
||||
|
||||
this.addCallback(callback);
|
||||
pollSyncing(this);
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
IsSyncing.prototype.addCallback = function (callback) {
|
||||
if(callback)
|
||||
this.callbacks.push(callback);
|
||||
return this;
|
||||
};
|
||||
|
||||
IsSyncing.prototype.stopWatching = function () {
|
||||
RequestManager.getInstance().stopPolling(this.pollId);
|
||||
this.callbacks = [];
|
||||
};
|
||||
|
||||
module.exports = IsSyncing;
|
||||
|
||||
|
||||
},{"../utils/utils":20,"./formatters":29,"./method":35,"./requestmanager":43}],45:[function(require,module,exports){
|
||||
/*
|
||||
This file is part of ethereum.js.
|
||||
|
||||
ethereum.js is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ethereum.js is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with ethereum.js. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/**
|
||||
* @file transfer.js
|
||||
* @author Marek Kotewicz <marek@ethdev.com>
|
||||
@ -5990,9 +6173,9 @@ var deposit = function (from, to, value, client, callback) {
|
||||
module.exports = transfer;
|
||||
|
||||
|
||||
},{"../contracts/SmartExchange.json":3,"../web3":22,"./contract":25,"./iban":32,"./namereg":41}],45:[function(require,module,exports){
|
||||
},{"../contracts/SmartExchange.json":3,"../web3":22,"./contract":25,"./iban":32,"./namereg":41}],46:[function(require,module,exports){
|
||||
|
||||
},{}],46:[function(require,module,exports){
|
||||
},{}],47:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -6735,7 +6918,7 @@ module.exports = transfer;
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{}],47:[function(require,module,exports){
|
||||
},{}],48:[function(require,module,exports){
|
||||
;(function (root, factory, undef) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -7059,7 +7242,7 @@ module.exports = transfer;
|
||||
return CryptoJS.SHA3;
|
||||
|
||||
}));
|
||||
},{"./core":46,"./x64-core":48}],48:[function(require,module,exports){
|
||||
},{"./core":47,"./x64-core":49}],49:[function(require,module,exports){
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === "object") {
|
||||
// CommonJS
|
||||
@ -7364,7 +7547,253 @@ module.exports = transfer;
|
||||
return CryptoJS;
|
||||
|
||||
}));
|
||||
},{"./core":46}],"bignumber.js":[function(require,module,exports){
|
||||
},{"./core":47}],50:[function(require,module,exports){
|
||||
/*! https://mths.be/utf8js v2.0.0 by @mathias */
|
||||
;(function(root) {
|
||||
|
||||
// Detect free variables 'exports'
|
||||
var freeExports = typeof exports == 'object' && exports;
|
||||
|
||||
// Detect free variable 'module'
|
||||
var freeModule = typeof module == 'object' && module &&
|
||||
module.exports == freeExports && module;
|
||||
|
||||
// Detect free variable 'global', from Node.js or Browserified code,
|
||||
// and use it as 'root'
|
||||
var freeGlobal = typeof global == 'object' && global;
|
||||
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {
|
||||
root = freeGlobal;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var stringFromCharCode = String.fromCharCode;
|
||||
|
||||
// Taken from https://mths.be/punycode
|
||||
function ucs2decode(string) {
|
||||
var output = [];
|
||||
var counter = 0;
|
||||
var length = string.length;
|
||||
var value;
|
||||
var extra;
|
||||
while (counter < length) {
|
||||
value = string.charCodeAt(counter++);
|
||||
if (value >= 0xD800 && value <= 0xDBFF && counter < length) {
|
||||
// high surrogate, and there is a next character
|
||||
extra = string.charCodeAt(counter++);
|
||||
if ((extra & 0xFC00) == 0xDC00) { // low surrogate
|
||||
output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000);
|
||||
} else {
|
||||
// unmatched surrogate; only append this code unit, in case the next
|
||||
// code unit is the high surrogate of a surrogate pair
|
||||
output.push(value);
|
||||
counter--;
|
||||
}
|
||||
} else {
|
||||
output.push(value);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
// Taken from https://mths.be/punycode
|
||||
function ucs2encode(array) {
|
||||
var length = array.length;
|
||||
var index = -1;
|
||||
var value;
|
||||
var output = '';
|
||||
while (++index < length) {
|
||||
value = array[index];
|
||||
if (value > 0xFFFF) {
|
||||
value -= 0x10000;
|
||||
output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800);
|
||||
value = 0xDC00 | value & 0x3FF;
|
||||
}
|
||||
output += stringFromCharCode(value);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
function checkScalarValue(codePoint) {
|
||||
if (codePoint >= 0xD800 && codePoint <= 0xDFFF) {
|
||||
throw Error(
|
||||
'Lone surrogate U+' + codePoint.toString(16).toUpperCase() +
|
||||
' is not a scalar value'
|
||||
);
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
function createByte(codePoint, shift) {
|
||||
return stringFromCharCode(((codePoint >> shift) & 0x3F) | 0x80);
|
||||
}
|
||||
|
||||
function encodeCodePoint(codePoint) {
|
||||
if ((codePoint & 0xFFFFFF80) == 0) { // 1-byte sequence
|
||||
return stringFromCharCode(codePoint);
|
||||
}
|
||||
var symbol = '';
|
||||
if ((codePoint & 0xFFFFF800) == 0) { // 2-byte sequence
|
||||
symbol = stringFromCharCode(((codePoint >> 6) & 0x1F) | 0xC0);
|
||||
}
|
||||
else if ((codePoint & 0xFFFF0000) == 0) { // 3-byte sequence
|
||||
checkScalarValue(codePoint);
|
||||
symbol = stringFromCharCode(((codePoint >> 12) & 0x0F) | 0xE0);
|
||||
symbol += createByte(codePoint, 6);
|
||||
}
|
||||
else if ((codePoint & 0xFFE00000) == 0) { // 4-byte sequence
|
||||
symbol = stringFromCharCode(((codePoint >> 18) & 0x07) | 0xF0);
|
||||
symbol += createByte(codePoint, 12);
|
||||
symbol += createByte(codePoint, 6);
|
||||
}
|
||||
symbol += stringFromCharCode((codePoint & 0x3F) | 0x80);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
function utf8encode(string) {
|
||||
var codePoints = ucs2decode(string);
|
||||
var length = codePoints.length;
|
||||
var index = -1;
|
||||
var codePoint;
|
||||
var byteString = '';
|
||||
while (++index < length) {
|
||||
codePoint = codePoints[index];
|
||||
byteString += encodeCodePoint(codePoint);
|
||||
}
|
||||
return byteString;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
function readContinuationByte() {
|
||||
if (byteIndex >= byteCount) {
|
||||
throw Error('Invalid byte index');
|
||||
}
|
||||
|
||||
var continuationByte = byteArray[byteIndex] & 0xFF;
|
||||
byteIndex++;
|
||||
|
||||
if ((continuationByte & 0xC0) == 0x80) {
|
||||
return continuationByte & 0x3F;
|
||||
}
|
||||
|
||||
// If we end up here, it’s not a continuation byte
|
||||
throw Error('Invalid continuation byte');
|
||||
}
|
||||
|
||||
function decodeSymbol() {
|
||||
var byte1;
|
||||
var byte2;
|
||||
var byte3;
|
||||
var byte4;
|
||||
var codePoint;
|
||||
|
||||
if (byteIndex > byteCount) {
|
||||
throw Error('Invalid byte index');
|
||||
}
|
||||
|
||||
if (byteIndex == byteCount) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read first byte
|
||||
byte1 = byteArray[byteIndex] & 0xFF;
|
||||
byteIndex++;
|
||||
|
||||
// 1-byte sequence (no continuation bytes)
|
||||
if ((byte1 & 0x80) == 0) {
|
||||
return byte1;
|
||||
}
|
||||
|
||||
// 2-byte sequence
|
||||
if ((byte1 & 0xE0) == 0xC0) {
|
||||
var byte2 = readContinuationByte();
|
||||
codePoint = ((byte1 & 0x1F) << 6) | byte2;
|
||||
if (codePoint >= 0x80) {
|
||||
return codePoint;
|
||||
} else {
|
||||
throw Error('Invalid continuation byte');
|
||||
}
|
||||
}
|
||||
|
||||
// 3-byte sequence (may include unpaired surrogates)
|
||||
if ((byte1 & 0xF0) == 0xE0) {
|
||||
byte2 = readContinuationByte();
|
||||
byte3 = readContinuationByte();
|
||||
codePoint = ((byte1 & 0x0F) << 12) | (byte2 << 6) | byte3;
|
||||
if (codePoint >= 0x0800) {
|
||||
checkScalarValue(codePoint);
|
||||
return codePoint;
|
||||
} else {
|
||||
throw Error('Invalid continuation byte');
|
||||
}
|
||||
}
|
||||
|
||||
// 4-byte sequence
|
||||
if ((byte1 & 0xF8) == 0xF0) {
|
||||
byte2 = readContinuationByte();
|
||||
byte3 = readContinuationByte();
|
||||
byte4 = readContinuationByte();
|
||||
codePoint = ((byte1 & 0x0F) << 0x12) | (byte2 << 0x0C) |
|
||||
(byte3 << 0x06) | byte4;
|
||||
if (codePoint >= 0x010000 && codePoint <= 0x10FFFF) {
|
||||
return codePoint;
|
||||
}
|
||||
}
|
||||
|
||||
throw Error('Invalid UTF-8 detected');
|
||||
}
|
||||
|
||||
var byteArray;
|
||||
var byteCount;
|
||||
var byteIndex;
|
||||
function utf8decode(byteString) {
|
||||
byteArray = ucs2decode(byteString);
|
||||
byteCount = byteArray.length;
|
||||
byteIndex = 0;
|
||||
var codePoints = [];
|
||||
var tmp;
|
||||
while ((tmp = decodeSymbol()) !== false) {
|
||||
codePoints.push(tmp);
|
||||
}
|
||||
return ucs2encode(codePoints);
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
var utf8 = {
|
||||
'version': '2.0.0',
|
||||
'encode': utf8encode,
|
||||
'decode': utf8decode
|
||||
};
|
||||
|
||||
// Some AMD build optimizers, like r.js, check for specific condition patterns
|
||||
// like the following:
|
||||
if (
|
||||
typeof define == 'function' &&
|
||||
typeof define.amd == 'object' &&
|
||||
define.amd
|
||||
) {
|
||||
define(function() {
|
||||
return utf8;
|
||||
});
|
||||
} else if (freeExports && !freeExports.nodeType) {
|
||||
if (freeModule) { // in Node.js or RingoJS v0.8.0+
|
||||
freeModule.exports = utf8;
|
||||
} else { // in Narwhal or RingoJS v0.7.0-
|
||||
var object = {};
|
||||
var hasOwnProperty = object.hasOwnProperty;
|
||||
for (var key in utf8) {
|
||||
hasOwnProperty.call(utf8, key) && (freeExports[key] = utf8[key]);
|
||||
}
|
||||
}
|
||||
} else { // in Rhino or a web browser
|
||||
root.utf8 = utf8;
|
||||
}
|
||||
|
||||
}(this));
|
||||
|
||||
},{}],"bignumber.js":[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
module.exports = BigNumber; // jshint ignore:line
|
||||
@ -7391,6 +7820,6 @@ if (typeof window !== 'undefined' && typeof window.web3 === 'undefined') {
|
||||
module.exports = web3;
|
||||
|
||||
|
||||
},{"./lib/web3":22,"./lib/web3/contract":25,"./lib/web3/httpprovider":31,"./lib/web3/iban":32,"./lib/web3/ipcprovider":33,"./lib/web3/namereg":41,"./lib/web3/transfer":44}]},{},["web3"])
|
||||
},{"./lib/web3":22,"./lib/web3/contract":25,"./lib/web3/httpprovider":31,"./lib/web3/iban":32,"./lib/web3/ipcprovider":33,"./lib/web3/namereg":41,"./lib/web3/transfer":45}]},{},["web3"])
|
||||
//# sourceMappingURL=web3-light.js.map
|
||||
`
|
||||
|
@ -173,9 +173,9 @@ func (self *ethApi) IsSyncing(req *shared.Request) (interface{}, error) {
|
||||
|
||||
if current < height {
|
||||
return map[string]interface{}{
|
||||
"startingBlock": origin,
|
||||
"currentBlock": current,
|
||||
"highestBlock": height,
|
||||
"startingBlock": newHexNum(big.NewInt(int64(origin)).Bytes()),
|
||||
"currentBlock": newHexNum(big.NewInt(int64(current)).Bytes()),
|
||||
"highestBlock": newHexNum(big.NewInt(int64(height)).Bytes()),
|
||||
}, nil
|
||||
}
|
||||
return false, nil
|
||||
|
@ -42,10 +42,6 @@ web3._extend({
|
||||
new web3._extend.Property({
|
||||
name: 'pendingTransactions',
|
||||
getter: 'eth_pendingTransactions'
|
||||
}),
|
||||
new web3._extend.Property({
|
||||
name: 'syncing',
|
||||
getter: 'eth_syncing'
|
||||
})
|
||||
]
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user