mirror of
https://github.com/status-im/web3.js.git
synced 2025-02-23 03:28:07 +00:00
merged develop
This commit is contained in:
commit
2ee7c997bc
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "web3",
|
||||
"namespace": "ethereum",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1",
|
||||
"description": "Ethereum Compatible JavaScript API",
|
||||
"main": [
|
||||
"./dist/web3.js",
|
||||
|
44
dist/web3-light.js
vendored
44
dist/web3-light.js
vendored
@ -354,9 +354,10 @@ var formatInputBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputDynamicBytes = function (value) {
|
||||
value = utils.toHex(value);
|
||||
var result = utils.padRight((value).substr(2), 64);
|
||||
var length = Math.floor(value.length / 2 - 1);
|
||||
value = utils.toHex(value).substr(2);
|
||||
var l = Math.floor((value.length + 63) / 64);
|
||||
var result = utils.padRight(value, l * 64);
|
||||
var length = Math.floor(value.length / 2);
|
||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||
};
|
||||
|
||||
@ -368,7 +369,9 @@ var formatInputDynamicBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputString = function (value) {
|
||||
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
||||
var result = utils.fromAscii(value).substr(2);
|
||||
var l = Math.floor((result.length + 63) / 64);
|
||||
result = utils.padRight(result, l * 64);
|
||||
return new SolidityParam(formatInputInt(value.length).value + result, 32);
|
||||
};
|
||||
|
||||
@ -721,13 +724,14 @@ var getOffset = function (bytes, index) {
|
||||
*/
|
||||
SolidityParam.decodeBytes = function (bytes, index) {
|
||||
index = index || 0;
|
||||
//TODO add support for strings longer than 32 bytes
|
||||
//var length = parseInt('0x' + bytes.substr(offset * 64, 64));
|
||||
|
||||
var offset = getOffset(bytes, index);
|
||||
|
||||
// 2 * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
|
||||
var l = parseInt('0x' + bytes.substr(offset * 2, 64));
|
||||
l = Math.floor((l + 31) / 32);
|
||||
|
||||
// (1 + l) * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, (1 + l) * 64), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1394,7 +1398,7 @@ module.exports = {
|
||||
|
||||
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
|
||||
module.exports={
|
||||
"version": "0.7.0"
|
||||
"version": "0.7.1"
|
||||
}
|
||||
|
||||
},{}],9:[function(require,module,exports){
|
||||
@ -2638,6 +2642,7 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
this.options = getOptions(options);
|
||||
this.implementation = implementation;
|
||||
this.filterId = null;
|
||||
this.callbacks = [];
|
||||
this.pollFilters = [];
|
||||
this.formatter = formatter;
|
||||
@ -2648,12 +2653,13 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
} else {
|
||||
self.filterId = id;
|
||||
// get filter logs at start
|
||||
|
||||
// get filter logs for the already existing watch calls
|
||||
self.callbacks.forEach(function(cb){
|
||||
getLogsAtStart(self, cb);
|
||||
});
|
||||
pollFilter(self);
|
||||
|
||||
if(self.callbacks.length > 0)
|
||||
pollFilter(self);
|
||||
|
||||
// start to watch immediately
|
||||
if(callback) {
|
||||
@ -3120,8 +3126,9 @@ SolidityFunction.prototype.request = function () {
|
||||
var format = this.unpackOutput.bind(this);
|
||||
|
||||
return {
|
||||
method: this._constant ? 'eth_call' : 'eth_sendTransaction',
|
||||
callback: callback,
|
||||
payload: payload,
|
||||
params: [payload],
|
||||
format: format
|
||||
};
|
||||
};
|
||||
@ -3434,13 +3441,14 @@ var IpcProvider = function (path, net) {
|
||||
_this._timeout();
|
||||
});
|
||||
|
||||
this.connection.on('end', function(e){
|
||||
this.connection.on('end', function(){
|
||||
_this._timeout();
|
||||
});
|
||||
|
||||
|
||||
// LISTEN FOR CONNECTION RESPONSES
|
||||
this.connection.on('data', function(data) {
|
||||
/*jshint maxcomplexity: 6 */
|
||||
data = data.toString();
|
||||
|
||||
// DE-CHUNKER
|
||||
@ -3451,8 +3459,8 @@ var IpcProvider = function (path, net) {
|
||||
.replace(/\}\]\{/g,'}]|--|{') // }]{
|
||||
.split('|--|');
|
||||
|
||||
for (var i = 0; i < dechunkedData.length; i++) {
|
||||
data = dechunkedData[i];
|
||||
|
||||
dechunkedData.forEach(function(data){
|
||||
|
||||
// prepend the last chunk
|
||||
if(_this.lastChunk)
|
||||
@ -3471,8 +3479,8 @@ var IpcProvider = function (path, net) {
|
||||
// start timeout to cancel all requests
|
||||
clearTimeout(_this.lastChunkTimeout);
|
||||
_this.lastChunkTimeout = setTimeout(function(){
|
||||
throw errors.InvalidResponse(result);
|
||||
_this.timeout();
|
||||
throw errors.InvalidResponse(result);
|
||||
}, 1000 * 15);
|
||||
|
||||
return;
|
||||
@ -3497,7 +3505,7 @@ var IpcProvider = function (path, net) {
|
||||
_this.responseCallbacks[id](null, result);
|
||||
delete _this.responseCallbacks[id];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
5
dist/web3-light.min.js
vendored
5
dist/web3-light.min.js
vendored
File diff suppressed because one or more lines are too long
44
dist/web3.js
vendored
44
dist/web3.js
vendored
@ -354,9 +354,10 @@ var formatInputBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputDynamicBytes = function (value) {
|
||||
value = utils.toHex(value);
|
||||
var result = utils.padRight((value).substr(2), 64);
|
||||
var length = Math.floor(value.length / 2 - 1);
|
||||
value = utils.toHex(value).substr(2);
|
||||
var l = Math.floor((value.length + 63) / 64);
|
||||
var result = utils.padRight(value, l * 64);
|
||||
var length = Math.floor(value.length / 2);
|
||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||
};
|
||||
|
||||
@ -368,7 +369,9 @@ var formatInputDynamicBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputString = function (value) {
|
||||
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
||||
var result = utils.fromAscii(value).substr(2);
|
||||
var l = Math.floor((result.length + 63) / 64);
|
||||
result = utils.padRight(result, l * 64);
|
||||
return new SolidityParam(formatInputInt(value.length).value + result, 32);
|
||||
};
|
||||
|
||||
@ -721,13 +724,14 @@ var getOffset = function (bytes, index) {
|
||||
*/
|
||||
SolidityParam.decodeBytes = function (bytes, index) {
|
||||
index = index || 0;
|
||||
//TODO add support for strings longer than 32 bytes
|
||||
//var length = parseInt('0x' + bytes.substr(offset * 64, 64));
|
||||
|
||||
var offset = getOffset(bytes, index);
|
||||
|
||||
// 2 * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
|
||||
var l = parseInt('0x' + bytes.substr(offset * 2, 64));
|
||||
l = Math.floor((l + 31) / 32);
|
||||
|
||||
// (1 + l) * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, (1 + l) * 64), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1394,7 +1398,7 @@ module.exports = {
|
||||
|
||||
},{"bignumber.js":"bignumber.js"}],8:[function(require,module,exports){
|
||||
module.exports={
|
||||
"version": "0.7.0"
|
||||
"version": "0.7.1"
|
||||
}
|
||||
|
||||
},{}],9:[function(require,module,exports){
|
||||
@ -2638,6 +2642,7 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
this.options = getOptions(options);
|
||||
this.implementation = implementation;
|
||||
this.filterId = null;
|
||||
this.callbacks = [];
|
||||
this.pollFilters = [];
|
||||
this.formatter = formatter;
|
||||
@ -2648,12 +2653,13 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
} else {
|
||||
self.filterId = id;
|
||||
// get filter logs at start
|
||||
|
||||
// get filter logs for the already existing watch calls
|
||||
self.callbacks.forEach(function(cb){
|
||||
getLogsAtStart(self, cb);
|
||||
});
|
||||
pollFilter(self);
|
||||
|
||||
if(self.callbacks.length > 0)
|
||||
pollFilter(self);
|
||||
|
||||
// start to watch immediately
|
||||
if(callback) {
|
||||
@ -3120,8 +3126,9 @@ SolidityFunction.prototype.request = function () {
|
||||
var format = this.unpackOutput.bind(this);
|
||||
|
||||
return {
|
||||
method: this._constant ? 'eth_call' : 'eth_sendTransaction',
|
||||
callback: callback,
|
||||
payload: payload,
|
||||
params: [payload],
|
||||
format: format
|
||||
};
|
||||
};
|
||||
@ -3434,13 +3441,14 @@ var IpcProvider = function (path, net) {
|
||||
_this._timeout();
|
||||
});
|
||||
|
||||
this.connection.on('end', function(e){
|
||||
this.connection.on('end', function(){
|
||||
_this._timeout();
|
||||
});
|
||||
|
||||
|
||||
// LISTEN FOR CONNECTION RESPONSES
|
||||
this.connection.on('data', function(data) {
|
||||
/*jshint maxcomplexity: 6 */
|
||||
data = data.toString();
|
||||
|
||||
// DE-CHUNKER
|
||||
@ -3451,8 +3459,8 @@ var IpcProvider = function (path, net) {
|
||||
.replace(/\}\]\{/g,'}]|--|{') // }]{
|
||||
.split('|--|');
|
||||
|
||||
for (var i = 0; i < dechunkedData.length; i++) {
|
||||
data = dechunkedData[i];
|
||||
|
||||
dechunkedData.forEach(function(data){
|
||||
|
||||
// prepend the last chunk
|
||||
if(_this.lastChunk)
|
||||
@ -3471,8 +3479,8 @@ var IpcProvider = function (path, net) {
|
||||
// start timeout to cancel all requests
|
||||
clearTimeout(_this.lastChunkTimeout);
|
||||
_this.lastChunkTimeout = setTimeout(function(){
|
||||
throw errors.InvalidResponse(result);
|
||||
_this.timeout();
|
||||
throw errors.InvalidResponse(result);
|
||||
}, 1000 * 15);
|
||||
|
||||
return;
|
||||
@ -3497,7 +3505,7 @@ var IpcProvider = function (path, net) {
|
||||
_this.responseCallbacks[id](null, result);
|
||||
delete _this.responseCallbacks[id];
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
7
dist/web3.min.js
vendored
7
dist/web3.min.js
vendored
File diff suppressed because one or more lines are too long
@ -62,9 +62,10 @@ var formatInputBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputDynamicBytes = function (value) {
|
||||
value = utils.toHex(value);
|
||||
var result = utils.padRight((value).substr(2), 64);
|
||||
var length = Math.floor(value.length / 2 - 1);
|
||||
value = utils.toHex(value).substr(2);
|
||||
var l = Math.floor((value.length + 63) / 64);
|
||||
var result = utils.padRight(value, l * 64);
|
||||
var length = Math.floor(value.length / 2);
|
||||
return new SolidityParam(formatInputInt(length).value + result, 32);
|
||||
};
|
||||
|
||||
@ -76,7 +77,9 @@ var formatInputDynamicBytes = function (value) {
|
||||
* @returns {SolidityParam}
|
||||
*/
|
||||
var formatInputString = function (value) {
|
||||
var result = utils.fromAscii(value, c.ETH_PADDING).substr(2);
|
||||
var result = utils.fromAscii(value).substr(2);
|
||||
var l = Math.floor((result.length + 63) / 64);
|
||||
result = utils.padRight(result, l * 64);
|
||||
return new SolidityParam(formatInputInt(value.length).value + result, 32);
|
||||
};
|
||||
|
||||
|
@ -182,13 +182,14 @@ var getOffset = function (bytes, index) {
|
||||
*/
|
||||
SolidityParam.decodeBytes = function (bytes, index) {
|
||||
index = index || 0;
|
||||
//TODO add support for strings longer than 32 bytes
|
||||
//var length = parseInt('0x' + bytes.substr(offset * 64, 64));
|
||||
|
||||
var offset = getOffset(bytes, index);
|
||||
|
||||
// 2 * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, 2 * 64), 0);
|
||||
var l = parseInt('0x' + bytes.substr(offset * 2, 64));
|
||||
l = Math.floor((l + 31) / 32);
|
||||
|
||||
// (1 + l) * , cause we also parse length
|
||||
return new SolidityParam(bytes.substr(offset * 2, (1 + l) * 64), 0);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,3 @@
|
||||
{
|
||||
"version": "0.7.0"
|
||||
"version": "0.7.1"
|
||||
}
|
||||
|
@ -135,6 +135,7 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
this.options = getOptions(options);
|
||||
this.implementation = implementation;
|
||||
this.filterId = null;
|
||||
this.callbacks = [];
|
||||
this.pollFilters = [];
|
||||
this.formatter = formatter;
|
||||
@ -145,12 +146,13 @@ var Filter = function (options, methods, formatter, callback) {
|
||||
});
|
||||
} else {
|
||||
self.filterId = id;
|
||||
// get filter logs at start
|
||||
|
||||
// get filter logs for the already existing watch calls
|
||||
self.callbacks.forEach(function(cb){
|
||||
getLogsAtStart(self, cb);
|
||||
});
|
||||
pollFilter(self);
|
||||
|
||||
if(self.callbacks.length > 0)
|
||||
pollFilter(self);
|
||||
|
||||
// start to watch immediately
|
||||
if(callback) {
|
||||
|
@ -188,8 +188,9 @@ SolidityFunction.prototype.request = function () {
|
||||
var format = this.unpackOutput.bind(this);
|
||||
|
||||
return {
|
||||
method: this._constant ? 'eth_call' : 'eth_sendTransaction',
|
||||
callback: callback,
|
||||
payload: payload,
|
||||
params: [payload],
|
||||
format: format
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* jshint ignore:start */
|
||||
Package.describe({
|
||||
name: 'ethereum:web3',
|
||||
version: '0.7.0',
|
||||
version: '0.7.1',
|
||||
summary: 'Ethereum JavaScript API, middleware to talk to a ethreum node over RPC',
|
||||
git: 'https://github.com/ethereum/ethereum.js',
|
||||
// By default, Meteor will default to using README.md for documentation.
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "web3",
|
||||
"namespace": "ethereum",
|
||||
"version": "0.7.0",
|
||||
"version": "0.7.1",
|
||||
"description": "Ethereum JavaScript API, middleware to talk to a ethereum node over RPC",
|
||||
"main": "./index.js",
|
||||
"directories": {
|
||||
|
@ -28,6 +28,16 @@ describe('lib/web3/batch', function () {
|
||||
done();
|
||||
};
|
||||
|
||||
provider.injectValidation(function (payload) {
|
||||
var first = payload[0];
|
||||
var second = payload[1];
|
||||
|
||||
assert.equal(first.method, 'eth_getBalance');
|
||||
assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']);
|
||||
assert.equal(second.method, 'eth_getBalance');
|
||||
assert.deepEqual(second.params, ['0x0000000000000000000000000000000000000005', 'latest']);
|
||||
});
|
||||
|
||||
var batch = web3.createBatch();
|
||||
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
|
||||
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000005', 'latest', callback2));
|
||||
@ -55,7 +65,7 @@ describe('lib/web3/batch', function () {
|
||||
}];
|
||||
|
||||
|
||||
var address = '0x0000000000000000000000000000000000000000';
|
||||
var address = '0x1000000000000000000000000000000000000001';
|
||||
var result = '0x126';
|
||||
var result2 = '0x0000000000000000000000000000000000000000000000000000000000000123';
|
||||
|
||||
@ -71,6 +81,19 @@ describe('lib/web3/batch', function () {
|
||||
done();
|
||||
};
|
||||
|
||||
provider.injectValidation(function (payload) {
|
||||
var first = payload[0];
|
||||
var second = payload[1];
|
||||
|
||||
assert.equal(first.method, 'eth_getBalance');
|
||||
assert.deepEqual(first.params, ['0x0000000000000000000000000000000000000000', 'latest']);
|
||||
assert.equal(second.method, 'eth_call');
|
||||
assert.deepEqual(second.params, [{
|
||||
'to': '0x1000000000000000000000000000000000000001',
|
||||
'data': '0xe3d670d70000000000000000000000001000000000000000000000000000000000000001'
|
||||
}]);
|
||||
});
|
||||
|
||||
var batch = web3.createBatch();
|
||||
batch.add(web3.eth.getBalance.request('0x0000000000000000000000000000000000000000', 'latest', callback));
|
||||
batch.add(web3.eth.contract(abi).at(address).balance.request(address, callback2));
|
||||
|
@ -20,9 +20,9 @@ describe('lib/solidity/coder', function () {
|
||||
test({ type: 'int256', expected: new bn(1), value: '0000000000000000000000000000000000000000000000000000000000000001'});
|
||||
test({ type: 'int256', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int256', expected: new bn(-1), value: 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'});
|
||||
test({ type: 'int8', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int32', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int64', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int8', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int32', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int64', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'int128', expected: new bn(16), value: '0000000000000000000000000000000000000000000000000000000000000010'});
|
||||
test({ type: 'bytes32', expected: '0x6761766f66796f726b0000000000000000000000000000000000000000000000',
|
||||
value: '6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
@ -36,6 +36,20 @@ describe('lib/solidity/coder', function () {
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'bytes', expected: '0x731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'731a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'bytes', expected: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000060' +
|
||||
'131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'string', expected: 'gavofyork', value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000'});
|
||||
@ -78,6 +92,11 @@ describe('lib/solidity/coder', function () {
|
||||
test({ type: 'ureal', expected: new bn(8.5), value: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
test({ type: 'address', expected: '0x407d73d8a49eeb85d32cf465507dd71d507100c1',
|
||||
value: '000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1'});
|
||||
test({ type: 'string', expected: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.',
|
||||
value: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'000000000000000000000000000000000000000000000000000000000000003e' +
|
||||
'77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' +
|
||||
'657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000'});
|
||||
});
|
||||
});
|
||||
|
||||
@ -100,17 +119,35 @@ describe('lib/solidity/coder', function () {
|
||||
test({ types: ['int', 'string', 'int', 'int', 'int', 'int[]'], expected: [new bn(1), 'gavofyork', new bn(2), new bn(3), new bn(4),
|
||||
[new bn(5), new bn(6), new bn(7)]],
|
||||
values: '0000000000000000000000000000000000000000000000000000000000000001' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000c0' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000004' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000100' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000007'});
|
||||
'00000000000000000000000000000000000000000000000000000000000000c0' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000002' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000004' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000100' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000009' +
|
||||
'6761766f66796f726b0000000000000000000000000000000000000000000000' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000007'});
|
||||
test({ types: ['int', 'bytes', 'int', 'bytes'], expected: [
|
||||
new bn(5),
|
||||
'0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
new bn(3),
|
||||
'0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
],
|
||||
values: '0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000080' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000e0' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -75,6 +75,25 @@ describe('lib/solidity/coder', function () {
|
||||
test({ type: 'ureal', value: 1, expected: '0000000000000000000000000000000100000000000000000000000000000000'});
|
||||
test({ type: 'ureal', value: 2.125, expected: '0000000000000000000000000000000220000000000000000000000000000000'});
|
||||
test({ type: 'ureal', value: 8.5, expected: '0000000000000000000000000000000880000000000000000000000000000000'});
|
||||
test({ type: 'bytes', value: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'bytes', value: '0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000060' +
|
||||
'131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
test({ type: 'string', value: 'welcome to ethereum. welcome to ethereum. welcome to ethereum.',
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000020' +
|
||||
'000000000000000000000000000000000000000000000000000000000000003e' +
|
||||
'77656c636f6d6520746f20657468657265756d2e2077656c636f6d6520746f20' +
|
||||
'657468657265756d2e2077656c636f6d6520746f20657468657265756d2e0000'});
|
||||
});
|
||||
});
|
||||
|
||||
@ -167,6 +186,24 @@ describe('lib/solidity/coder', function () {
|
||||
'0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000006' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000007'});
|
||||
test({ types: ['int', 'bytes', 'int', 'bytes'], values: [
|
||||
5,
|
||||
'0x131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
3,
|
||||
'0x331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b',
|
||||
],
|
||||
expected: '0000000000000000000000000000000000000000000000000000000000000005' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000080' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000003' +
|
||||
'00000000000000000000000000000000000000000000000000000000000000e0' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'131a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'231a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'0000000000000000000000000000000000000000000000000000000000000040' +
|
||||
'331a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b' +
|
||||
'431a3afc00d1b1e3461b955e53fc866dcf303b3eb9f4c16f89e388930f48134b'});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user