Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@parity/abi

Package Overview
Dependencies
Maintainers
6
Versions
76
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@parity/abi - npm Package Compare versions

Comparing version 2.1.4 to 3.0.1

changelogs/CHANGELOG-3.0.md

48

lib/abi.js

@@ -1,22 +0,28 @@

'use strict';function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self, call) {if (!self) {throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call && (typeof call === "object" || typeof call === "function") ? call : self;}function _inherits(subClass, superClass) {if (typeof superClass !== "function" && superClass !== null) {throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);}subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Interface = require('./spec/interface');var
Abi = function (_Interface) {_inherits(Abi, _Interface);function Abi() {_classCallCheck(this, Abi);return _possibleConstructorReturn(this, (Abi.__proto__ || Object.getPrototypeOf(Abi)).apply(this, arguments));}return Abi;}(Interface);
module.exports = Abi;
//
// SPDX-License-Identifier: MIT
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var interface_1 = require("./spec/interface");
var Abi = /** @class */ (function (_super) {
__extends(Abi, _super);
function Abi() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Abi;
}(interface_1.default));
exports.default = Abi;

@@ -1,32 +0,28 @@

"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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var
BytesTaken = function () {
function BytesTaken(bytes, newOffset) {_classCallCheck(this, BytesTaken);
this._bytes = bytes;
this._newOffset = newOffset;
}_createClass(BytesTaken, [{ key: "bytes", get: function get()
{
return this._bytes;
} }, { key: "newOffset", get: function get()
{
return this._newOffset;
} }]);return BytesTaken;}();
module.exports = BytesTaken;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var BytesTaken = /** @class */ (function () {
function BytesTaken(bytes, newOffset) {
this._bytes = bytes;
this._newOffset = newOffset;
}
Object.defineProperty(BytesTaken.prototype, "bytes", {
get: function () {
return this._bytes;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BytesTaken.prototype, "newOffset", {
get: function () {
return this._newOffset;
},
enumerable: true,
configurable: true
});
return BytesTaken;
}());
exports.default = BytesTaken;

@@ -1,159 +0,133 @@

'use strict';function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var utf8 = require('utf8');
var Token = require('../token/token');
var BytesTaken = require('./bytesTaken');
var DecodeResult = require('./decodeResult');
var ParamType = require('../spec/paramType/paramType');var _require =
require('../util/slice'),sliceData = _require.sliceData;var _require2 =
require('../util/sliceAs'),asAddress = _require2.asAddress,asBool = _require2.asBool,asI32 = _require2.asI32,asU32 = _require2.asU32;var _require3 =
require('../util/types'),isArray = _require3.isArray,isInstanceOf = _require3.isInstanceOf;
var NULL = '0000000000000000000000000000000000000000000000000000000000000000';var
Decoder = function Decoder() {_classCallCheck(this, Decoder);};
Decoder.decode = function (params, data) {
if (!isArray(params)) {
throw new Error('Parameters should be array of ParamType');
}
var slices = sliceData(data);
var offset = 0;
return params.map(function (param) {
var result = Decoder.decodeParam(param, slices, offset);
offset = result.newOffset;
return result.token;
});
};
Decoder.peek = function (slices, position) {
if (!slices || !slices[position]) {
return NULL;
}
return slices[position];
};
Decoder.takeBytes = function (slices, position, length) {
var slicesLength = Math.floor((length + 31) / 32);
var bytesStr = '';
for (var index = 0; index < slicesLength; index++) {
bytesStr = '' + bytesStr + Decoder.peek(slices, position + index);
}
var bytes = (bytesStr.substr(0, length * 2).match(/.{1,2}/g) || []).map(function (code) {return parseInt(code, 16);});
return new BytesTaken(bytes, position + slicesLength);
};
Decoder.decodeParam = function (param, slices, offset) {
if (!isInstanceOf(param, ParamType)) {
throw new Error('param should be instanceof ParamType');
}
var tokens = [];
var taken = void 0;
var lengthOffset = void 0;
var length = void 0;
var newOffset = void 0;
switch (param.type) {
case 'address':
return new DecodeResult(new Token(param.type, asAddress(Decoder.peek(slices, offset))), offset + 1);
case 'bool':
return new DecodeResult(new Token(param.type, asBool(Decoder.peek(slices, offset))), offset + 1);
case 'int':
return new DecodeResult(new Token(param.type, asI32(Decoder.peek(slices, offset))), offset + 1);
case 'uint':
return new DecodeResult(new Token(param.type, asU32(Decoder.peek(slices, offset))), offset + 1);
case 'fixedBytes':
taken = Decoder.takeBytes(slices, offset, param.length);
return new DecodeResult(new Token(param.type, taken.bytes), taken.newOffset);
case 'bytes':
lengthOffset = asU32(Decoder.peek(slices, offset)).div(32).toNumber();
length = asU32(Decoder.peek(slices, lengthOffset)).toNumber();
taken = Decoder.takeBytes(slices, lengthOffset + 1, length);
return new DecodeResult(new Token(param.type, taken.bytes), offset + 1);
case 'string':
if (param.indexed) {
taken = Decoder.takeBytes(slices, offset, 32);
return new DecodeResult(new Token('fixedBytes', taken.bytes), offset + 1);
}
lengthOffset = asU32(Decoder.peek(slices, offset)).div(32).toNumber();
length = asU32(Decoder.peek(slices, lengthOffset)).toNumber();
taken = Decoder.takeBytes(slices, lengthOffset + 1, length);
var str = taken.bytes.map(function (code) {return String.fromCharCode(code);}).join('');
var decoded = void 0;
try {
decoded = utf8.decode(str);
} catch (error) {
decoded = str;
}
return new DecodeResult(new Token(param.type, decoded), offset + 1);
case 'array':
lengthOffset = asU32(Decoder.peek(slices, offset)).div(32).toNumber();
length = asU32(Decoder.peek(slices, lengthOffset)).toNumber();
newOffset = lengthOffset + 1;
for (var index = 0; index < length; index++) {
var result = Decoder.decodeParam(param.subtype, slices, newOffset);
newOffset = result.newOffset;
tokens.push(result.token);
}
return new DecodeResult(new Token(param.type, tokens), offset + 1);
case 'fixedArray':
newOffset = offset;
for (var _index = 0; _index < param.length; _index++) {
var _result = Decoder.decodeParam(param.subtype, slices, newOffset);
newOffset = _result.newOffset;
tokens.push(_result.token);
}
return new DecodeResult(new Token(param.type, tokens), newOffset);
default:
throw new Error('Invalid param type ' + param.type + ' in decodeParam');}
};
module.exports = Decoder;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var utf8 = require("utf8");
var token_1 = require("../token/token");
var bytesTaken_1 = require("./bytesTaken");
var decodeResult_1 = require("./decodeResult");
var paramType_1 = require("../spec/paramType/paramType");
var slice_1 = require("../util/slice");
var sliceAs_1 = require("../util/sliceAs");
var types_1 = require("../util/types");
var NULL = '0000000000000000000000000000000000000000000000000000000000000000';
var Decoder = /** @class */ (function () {
function Decoder() {
}
Decoder.decode = function (params, data) {
if (!types_1.isArray(params)) {
throw new Error('Parameters should be array of ParamType');
}
var slices = slice_1.sliceData(data);
var offset = 0;
return params.map(function (param) {
var result = Decoder.decodeParam(param, slices, offset);
offset = result.newOffset;
return result.token;
});
};
Decoder.peek = function (slices, position) {
if (!slices || !slices[position]) {
return NULL;
}
return slices[position];
};
Decoder.takeBytes = function (slices, position, length) {
var slicesLength = Math.floor((length + 31) / 32);
var bytesStr = '';
for (var index = 0; index < slicesLength; index++) {
bytesStr = "" + bytesStr + Decoder.peek(slices, position + index);
}
var bytes = (bytesStr.substr(0, length * 2).match(/.{1,2}/g) || []).map(function (code) { return parseInt(code, 16); });
return new bytesTaken_1.default(bytes, position + slicesLength);
};
Decoder.decodeParam = function (param, slices, offset) {
if (offset === void 0) { offset = 0; }
if (!types_1.isInstanceOf(param, paramType_1.default)) {
throw new Error('param should be instanceof ParamType');
}
var tokens = [];
var taken;
var lengthOffset;
var length;
var newOffset;
switch (param.type) {
case 'address':
return new decodeResult_1.default(new token_1.default(param.type, sliceAs_1.asAddress(Decoder.peek(slices, offset))), offset + 1);
case 'bool':
return new decodeResult_1.default(new token_1.default(param.type, sliceAs_1.asBool(Decoder.peek(slices, offset))), offset + 1);
case 'int':
return new decodeResult_1.default(new token_1.default(param.type, sliceAs_1.asI32(Decoder.peek(slices, offset))), offset + 1);
case 'uint':
return new decodeResult_1.default(new token_1.default(param.type, sliceAs_1.asU32(Decoder.peek(slices, offset))), offset + 1);
case 'fixedBytes': {
taken = Decoder.takeBytes(slices, offset, param.length);
return new decodeResult_1.default(new token_1.default(param.type, taken.bytes), taken.newOffset);
}
case 'bytes': {
lengthOffset = sliceAs_1.asU32(Decoder.peek(slices, offset))
.div(32)
.toNumber();
length = sliceAs_1.asU32(Decoder.peek(slices, lengthOffset)).toNumber();
taken = Decoder.takeBytes(slices, lengthOffset + 1, length);
return new decodeResult_1.default(new token_1.default(param.type, taken.bytes), offset + 1);
}
case 'string': {
if (param.indexed) {
taken = Decoder.takeBytes(slices, offset, 32);
return new decodeResult_1.default(new token_1.default('fixedBytes', taken.bytes), offset + 1);
}
lengthOffset = sliceAs_1.asU32(Decoder.peek(slices, offset))
.div(32)
.toNumber();
length = sliceAs_1.asU32(Decoder.peek(slices, lengthOffset)).toNumber();
taken = Decoder.takeBytes(slices, lengthOffset + 1, length);
var str = taken.bytes
.map(function (code) { return String.fromCharCode(code); })
.join('');
var decoded = void 0;
try {
decoded = utf8.decode(str);
}
catch (error) {
decoded = str;
}
return new decodeResult_1.default(new token_1.default(param.type, decoded), offset + 1);
}
case 'array': {
if (!param.subtype) {
throw new Error("decodeParam: param of type '" + param.type + "' must have a subtype");
}
lengthOffset = sliceAs_1.asU32(Decoder.peek(slices, offset))
.div(32)
.toNumber();
length = sliceAs_1.asU32(Decoder.peek(slices, lengthOffset)).toNumber();
newOffset = lengthOffset + 1;
for (var index = 0; index < length; index++) {
var result = Decoder.decodeParam(param.subtype, slices, newOffset);
newOffset = result.newOffset;
tokens.push(result.token);
}
return new decodeResult_1.default(new token_1.default(param.type, tokens), offset + 1);
}
case 'fixedArray': {
if (!param.subtype) {
throw new Error("decodeParam: param of type '" + param.type + "' must have a subtype");
}
newOffset = offset;
for (var index = 0; index < param.length; index++) {
var result = Decoder.decodeParam(param.subtype, slices, newOffset);
newOffset = result.newOffset;
tokens.push(result.token);
}
return new decodeResult_1.default(new token_1.default(param.type, tokens), newOffset);
}
default:
throw new Error("Invalid param type " + param.type + " in decodeParam");
}
};
return Decoder;
}());
exports.default = Decoder;

@@ -1,32 +0,28 @@

"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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var
DecodeResult = function () {
function DecodeResult(token, newOffset) {_classCallCheck(this, DecodeResult);
this._token = token;
this._newOffset = newOffset;
}_createClass(DecodeResult, [{ key: "token", get: function get()
{
return this._token;
} }, { key: "newOffset", get: function get()
{
return this._newOffset;
} }]);return DecodeResult;}();
module.exports = DecodeResult;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var DecodeResult = /** @class */ (function () {
function DecodeResult(token, newOffset) {
this._token = token;
this._newOffset = newOffset;
}
Object.defineProperty(DecodeResult.prototype, "token", {
get: function () {
return this._token;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DecodeResult.prototype, "newOffset", {
get: function () {
return this._newOffset;
},
enumerable: true,
configurable: true
});
return DecodeResult;
}());
exports.default = DecodeResult;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Decoder = require('./decoder');
module.exports = Decoder;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var decoder_1 = require("./decoder");
exports.default = decoder_1.default;

@@ -1,78 +0,65 @@

'use strict';function _classCallCheck(instance, Constructor) {if (!(instance instanceof Constructor)) {throw new TypeError("Cannot call a class as a function");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('../util/pad'),padAddress = _require.padAddress,padBool = _require.padBool,padBytes = _require.padBytes,padFixedBytes = _require.padFixedBytes,padU32 = _require.padU32,padString = _require.padString;
var Mediate = require('./mediate');
var Token = require('../token/token');var _require2 =
require('../util/types'),isArray = _require2.isArray,isInstanceOf = _require2.isInstanceOf;var
Encoder = function Encoder() {_classCallCheck(this, Encoder);};
Encoder.encode = function (tokens) {
if (!isArray(tokens)) {
throw new Error('tokens should be array of Token');
}
var mediates = tokens.map(function (token, index) {return Encoder.encodeToken(token, index);});
var inits = mediates.
map(function (mediate, index) {return mediate.init(Mediate.offsetFor(mediates, index));}).
join('');
var closings = mediates.
map(function (mediate, index) {return mediate.closing(Mediate.offsetFor(mediates, index));}).
join('');
return '' + inits + closings;
};
Encoder.encodeToken = function (token) {var index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
if (!isInstanceOf(token, Token)) {
throw new Error('token should be instanceof Token');
}
try {
switch (token.type) {
case 'address':
return new Mediate('raw', padAddress(token.value));
case 'int':
case 'uint':
return new Mediate('raw', padU32(token.value));
case 'bool':
return new Mediate('raw', padBool(token.value));
case 'fixedBytes':
return new Mediate('raw', padFixedBytes(token.value));
case 'bytes':
return new Mediate('prefixed', padBytes(token.value));
case 'string':
return new Mediate('prefixed', padString(token.value));
case 'fixedArray':
case 'array':
return new Mediate(token.type, token.value.map(function (token) {return Encoder.encodeToken(token);}));}
} catch (e) {
throw new Error('Cannot encode token #' + index + ' [' + token.type + ': ' + token.value + ']. ' + e.message);
}
throw new Error('Invalid token type ' + token.type + ' in encodeToken');
};
module.exports = Encoder;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var pad_1 = require("../util/pad");
var mediate_1 = require("./mediate");
var token_1 = require("../token/token");
var types_1 = require("../util/types");
var Encoder = /** @class */ (function () {
function Encoder() {
}
Encoder.encode = function (tokens) {
if (!types_1.isArray(tokens)) {
throw new Error('tokens should be array of Token');
}
var mediates = tokens.map(function (token, index) {
return Encoder.encodeToken(token, index);
});
var inits = mediates
.map(function (mediate, index) { return mediate.init(mediate_1.default.offsetFor(mediates, index)); })
.join('');
var closings = mediates
.map(function (mediate, index) {
return mediate.closing(mediate_1.default.offsetFor(mediates, index));
})
.join('');
return "" + inits + closings;
};
Encoder.encodeToken = function (token, index) {
if (index === void 0) { index = 0; }
if (!token || !types_1.isInstanceOf(token, token_1.default)) {
throw new Error('token should be instanceof Token');
}
try {
switch (token.type) {
case 'address':
return new mediate_1.default('raw', pad_1.padAddress(token.value));
case 'int':
case 'uint':
return new mediate_1.default('raw', pad_1.padU32(token.value));
case 'bool':
return new mediate_1.default('raw', pad_1.padBool(token.value));
case 'fixedBytes':
return new mediate_1.default('raw', pad_1.padFixedBytes(token.value));
case 'bytes':
return new mediate_1.default('prefixed', pad_1.padBytes(token.value));
case 'string':
return new mediate_1.default('prefixed', pad_1.padString(token.value));
case 'fixedArray':
case 'array':
return new mediate_1.default(token.type,
// TODO token.value as Token[] seems weird.
token.value.map(function (token) { return Encoder.encodeToken(token); }));
}
}
catch (e) {
throw new Error("Cannot encode token #" + index + " [" + token.type + ": " + token.value + "]. " + e.message);
}
throw new Error("Invalid token type " + token.type + " in encodeToken");
};
return Encoder;
}());
exports.default = Encoder;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Encoder = require('./encoder');
module.exports = Encoder;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var encoder_1 = require("./encoder");
exports.default = encoder_1.default;

@@ -1,144 +0,133 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var TYPES = ['raw', 'prefixed', 'fixedArray', 'array'];var _require =
require('../util/pad'),padU32 = _require.padU32;var
Mediate = function () {
function Mediate(type, value) {_classCallCheck(this, Mediate);
Mediate.validateType(type);
this._type = type;
this._value = value;
}_createClass(Mediate, [{ key: 'initLength', value: function initLength()
{
switch (this._type) {
case 'raw':
return this._value.length / 2;
case 'array':
case 'prefixed':
return 32;
case 'fixedArray':
return this._value.
reduce(function (total, mediate) {
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var pad_1 = require("../util/pad");
var TYPES = ['raw', 'prefixed', 'fixedArray', 'array'];
var Mediate = /** @class */ (function () {
function Mediate(type, value) {
Mediate.validateType(type);
this._type = type;
this._value = value;
}
Mediate.offsetFor = function (mediates, position) {
if (position < 0 || position >= mediates.length) {
throw new Error("Invalid position " + position + " specified for Mediate.offsetFor");
}
var initLength = mediates.reduce(function (total, mediate) {
return total + mediate.initLength();
}, 0);}
} }, { key: 'closingLength', value: function closingLength()
{
switch (this._type) {
case 'raw':
return 0;
case 'prefixed':
return this._value.length / 2;
case 'array':
return this._value.
reduce(function (total, mediate) {
return total + mediate.initLength();
}, 32);
case 'fixedArray':
return this._value.
reduce(function (total, mediate) {
return total + mediate.initLength() + mediate.closingLength();
}, 0);}
} }, { key: 'init', value: function init(
suffixOffset) {var _this = this;
switch (this._type) {
case 'raw':
return this._value;
case 'fixedArray':
return this._value.
map(function (mediate, index) {return mediate.init(Mediate.offsetFor(_this._value, index)).toString(16);}).
join('');
case 'prefixed':
case 'array':
return padU32(suffixOffset);}
} }, { key: 'closing', value: function closing(
offset) {var _this2 = this;
switch (this._type) {
case 'raw':
return '';
case 'prefixed':
return this._value;
case 'fixedArray':
return this._value.
map(function (mediate, index) {return mediate.closing(Mediate.offsetFor(_this2._value, index)).toString(16);}).
join('');
case 'array':
var prefix = padU32(this._value.length);
var inits = this._value.
map(function (mediate, index) {return mediate.init(offset + Mediate.offsetFor(_this2._value, index) + 32).toString(16);}).
join('');
var closings = this._value.
map(function (mediate, index) {return mediate.closing(offset + Mediate.offsetFor(_this2._value, index)).toString(16);}).
join('');
return '' + prefix + inits + closings;}
} }, { key: 'type', get: function get()
{
return this._type;
} }, { key: 'value', get: function get()
{
return this._value;
} }]);return Mediate;}();
Mediate.offsetFor = function (mediates, position) {
if (position < 0 || position >= mediates.length) {
throw new Error('Invalid position ' + position + ' specified for Mediate.offsetFor');
}
var initLength = mediates.
reduce(function (total, mediate) {
return total + mediate.initLength();
}, 0);
return mediates.
slice(0, position).
reduce(function (total, mediate) {
return total + mediate.closingLength();
}, initLength);
};
Mediate.validateType = function (type) {
if (TYPES.filter(function (_type) {return type === _type;}).length) {
return true;
}
throw new Error('Invalid type ' + type + ' received for Mediate.validateType');
};
module.exports = Mediate;
}, 0);
return mediates.slice(0, position).reduce(function (total, mediate) {
return total + mediate.closingLength();
}, initLength);
};
Mediate.validateType = function (type) {
if (TYPES.filter(function (_type) { return type === _type; }).length) {
return true;
}
throw new Error("Invalid type " + type + " received for Mediate.validateType");
};
Mediate.prototype.initLength = function () {
switch (this._type) {
case 'raw':
return this._value.length / 2;
case 'array':
case 'prefixed':
return 32;
case 'fixedArray':
return this._value.reduce(function (total, mediate) {
return total + mediate.initLength();
}, 0);
}
};
Mediate.prototype.closingLength = function () {
switch (this._type) {
case 'raw':
return 0;
case 'prefixed':
return this._value.length / 2;
case 'array':
return this._value.reduce(function (total, mediate) {
return total + mediate.initLength();
}, 32);
case 'fixedArray':
return this._value.reduce(function (total, mediate) {
return total + mediate.initLength() + mediate.closingLength();
}, 0);
}
};
Mediate.prototype.init = function (suffixOffset) {
var _this = this;
switch (this._type) {
case 'raw':
return this._value;
case 'fixedArray':
return this._value
.map(function (mediate, index) {
// @ts-ignore toString doesn't take any args
return mediate
.init(Mediate.offsetFor(_this._value, index))
.toString(16);
})
.join('');
case 'prefixed':
case 'array':
return pad_1.padU32(suffixOffset);
}
};
Mediate.prototype.closing = function (offset) {
var _this = this;
switch (this._type) {
case 'raw':
return '';
case 'prefixed':
return this._value;
case 'fixedArray':
return this._value
.map(function (mediate, index) {
// @ts-ignore toString doesn't take any args
return mediate
.closing(Mediate.offsetFor(_this._value, index))
.toString(16);
})
.join('');
case 'array':
var prefix = pad_1.padU32(this._value.length);
var inits = this._value
.map(function (mediate, index) {
// @ts-ignore toString doesn't take any args
return mediate
.init(offset + Mediate.offsetFor(_this._value, index) + 32)
.toString(16);
})
.join('');
var closings = this._value
.map(function (mediate, index) {
// @ts-ignore toString doesn't take any args
return mediate
.closing(offset + Mediate.offsetFor(_this._value, index))
.toString(16);
})
.join('');
return "" + prefix + inits + closings;
}
};
Object.defineProperty(Mediate.prototype, "type", {
get: function () {
return this._type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Mediate.prototype, "value", {
get: function () {
return this._value;
},
enumerable: true,
configurable: true
});
return Mediate;
}());
exports.default = Mediate;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Abi = require('./abi');
module.exports = Abi;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var abi_1 = require("./abi");
exports.default = abi_1.default;

@@ -1,38 +0,28 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Encoder = require('../encoder/encoder');
var Param = require('./param');var
Constructor = function () {
function Constructor(abi) {_classCallCheck(this, Constructor);
this._inputs = Param.toParams(abi.inputs || []);
}_createClass(Constructor, [{ key: 'inputParamTypes', value: function inputParamTypes()
{
return this._inputs.map(function (input) {return input.kind;});
} }, { key: 'encodeCall', value: function encodeCall(
tokens) {
return Encoder.encode(tokens);
} }, { key: 'inputs', get: function get() {return this._inputs;} }]);return Constructor;}();
module.exports = Constructor;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var encoder_1 = require("../encoder/encoder");
var param_1 = require("./param");
var Constructor = /** @class */ (function () {
function Constructor(abi) {
this._inputs = param_1.default.toParams(abi.inputs || []);
}
Object.defineProperty(Constructor.prototype, "inputs", {
get: function () {
return this._inputs;
},
enumerable: true,
configurable: true
});
Constructor.prototype.inputParamTypes = function () {
return this._inputs.map(function (input) { return input.kind; });
};
Constructor.prototype.encodeCall = function (tokens) {
return encoder_1.default.encode(tokens);
};
return Constructor;
}());
exports.default = Constructor;

@@ -1,32 +0,28 @@

"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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var
DecodedLog = function () {
function DecodedLog(params, address) {_classCallCheck(this, DecodedLog);
this._params = params;
this._address = address;
}_createClass(DecodedLog, [{ key: "address", get: function get()
{
return this._address;
} }, { key: "params", get: function get()
{
return this._params;
} }]);return DecodedLog;}();
module.exports = DecodedLog;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var DecodedLog = /** @class */ (function () {
function DecodedLog(params, address) {
this._params = params;
this._address = address;
}
Object.defineProperty(DecodedLog.prototype, "address", {
get: function () {
return this._address;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DecodedLog.prototype, "params", {
get: function () {
return this._params;
},
enumerable: true,
configurable: true
});
return DecodedLog;
}());
exports.default = DecodedLog;

@@ -1,47 +0,45 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var ParamType = require('../paramType/paramType');
var Token = require('../../token/token');var _require =
require('../../util/types'),isInstanceOf = _require.isInstanceOf;var
DecodedLogParam = function () {
function DecodedLogParam(name, kind, token) {_classCallCheck(this, DecodedLogParam);
if (!isInstanceOf(kind, ParamType)) {
throw new Error('kind not instanceof ParamType');
} else if (!isInstanceOf(token, Token)) {
throw new Error('token not instanceof Token');
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var types_1 = require("../../util/types");
var paramType_1 = require("../paramType");
var token_1 = require("../../token");
var DecodedLogParam = /** @class */ (function () {
function DecodedLogParam(name, kind, token) {
if (!types_1.isInstanceOf(kind, paramType_1.default)) {
throw new Error('kind not instanceof ParamType');
}
else if (!types_1.isInstanceOf(token, token_1.default)) {
throw new Error('token not instanceof Token');
}
this._name = name;
this._kind = kind;
this._token = token;
}
this._name = name;
this._kind = kind;
this._token = token;
}_createClass(DecodedLogParam, [{ key: 'name', get: function get()
{
return this._name;
} }, { key: 'kind', get: function get()
{
return this._kind;
} }, { key: 'token', get: function get()
{
return this._token;
} }]);return DecodedLogParam;}();
module.exports = DecodedLogParam;
Object.defineProperty(DecodedLogParam.prototype, "name", {
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DecodedLogParam.prototype, "kind", {
get: function () {
return this._kind;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DecodedLogParam.prototype, "token", {
get: function () {
return this._token;
},
enumerable: true,
configurable: true
});
return DecodedLogParam;
}());
exports.default = DecodedLogParam;

@@ -1,116 +0,106 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Decoder = require('../../decoder/decoder');
var DecodedLog = require('./decodedLog');
var DecodedLogParam = require('./decodedLogParam');
var EventParam = require('./eventParam');var _require =
require('../../util/sliceAs'),asAddress = _require.asAddress;var _require2 =
require('../../util/signature'),eventSignature = _require2.eventSignature;var
Event = function () {
function Event(abi) {_classCallCheck(this, Event);
this._inputs = EventParam.toEventParams(abi.inputs || []);
this._anonymous = !!abi.anonymous;var _eventSignature =
eventSignature(abi.name, this.inputParamTypes()),id = _eventSignature.id,name = _eventSignature.name,signature = _eventSignature.signature;
this._id = id;
this._name = name;
this._signature = signature;
}_createClass(Event, [{ key: 'inputParamTypes', value: function inputParamTypes()
{
return this._inputs.map(function (input) {return input.kind;});
} }, { key: 'inputParamNames', value: function inputParamNames()
{
return this._inputs.map(function (input) {return input.name;});
} }, { key: 'indexedParams', value: function indexedParams(
indexed) {
return this._inputs.filter(function (input) {return input.indexed === indexed;});
} }, { key: 'decodeLog', value: function decodeLog(
topics, data) {
var topicParams = this.indexedParams(true);
var dataParams = this.indexedParams(false);
var address = void 0;
var toSkip = void 0;
if (!this.anonymous) {
address = asAddress(topics[0]);
toSkip = 1;
} else {
toSkip = 0;
}
var topicTypes = topicParams.map(function (param) {return param.kind;});
var flatTopics = topics.
filter(function (topic, index) {return index >= toSkip;}).
map(function (topic) {
return topic.substr(0, 2) === '0x' ?
topic.substr(2) :
topic;
}).join('');
var topicTokens = Decoder.decode(topicTypes, flatTopics);
if (topicTokens.length !== topics.length - toSkip) {
throw new Error('Invalid topic data');
}
var dataTypes = dataParams.map(function (param) {return param.kind;});
var dataTokens = Decoder.decode(dataTypes, data);
var namedTokens = {};
topicParams.forEach(function (param, index) {
namedTokens[param.name || index] = topicTokens[index];
});
dataParams.forEach(function (param, index) {
namedTokens[param.name || index] = dataTokens[index];
});
var inputParamTypes = this.inputParamTypes();
var decodedParams = this.inputParamNames().
map(function (name, index) {return new DecodedLogParam(name, inputParamTypes[index], namedTokens[name || index]);});
return new DecodedLog(decodedParams, address);
} }, { key: 'anonymous', get: function get() {return this._anonymous;} }, { key: 'id', get: function get() {return this._id;} }, { key: 'inputs', get: function get() {return this._inputs;} }, { key: 'name', get: function get() {return this._name;} }, { key: 'signature', get: function get() {return this._signature;} }]);return Event;}();
module.exports = Event;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var sliceAs_1 = require("../../util/sliceAs");
var decoder_1 = require("../../decoder/decoder");
var decodedLog_1 = require("./decodedLog");
var decodedLogParam_1 = require("./decodedLogParam");
var eventParam_1 = require("./eventParam");
var signature_1 = require("../../util/signature");
var Event = /** @class */ (function () {
function Event(abi) {
this._inputs = eventParam_1.default.toEventParams(abi.inputs || []);
this._anonymous = !!abi.anonymous;
var _a = signature_1.eventSignature(abi.name, this.inputParamTypes()), id = _a.id, name = _a.name, signature = _a.signature;
this._id = id;
this._name = name;
this._signature = signature;
}
Object.defineProperty(Event.prototype, "anonymous", {
get: function () {
return this._anonymous;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "id", {
get: function () {
return this._id;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "inputs", {
get: function () {
return this._inputs;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "name", {
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Event.prototype, "signature", {
get: function () {
return this._signature;
},
enumerable: true,
configurable: true
});
Event.prototype.inputParamTypes = function () {
return this._inputs.map(function (input) { return input.kind; });
};
Event.prototype.inputParamNames = function () {
return this._inputs.map(function (input) { return input.name; });
};
Event.prototype.indexedParams = function (indexed) {
return this._inputs.filter(function (input) { return input.indexed === indexed; });
};
Event.prototype.decodeLog = function (topics, data) {
var topicParams = this.indexedParams(true);
var dataParams = this.indexedParams(false);
var address = '';
var toSkip;
if (!this.anonymous) {
address = sliceAs_1.asAddress(topics[0]);
toSkip = 1;
}
else {
toSkip = 0;
}
var topicTypes = topicParams.map(function (param) { return param.kind; });
var flatTopics = topics
.filter(function (topic, index) { return index >= toSkip; })
.map(function (topic) {
return topic.substr(0, 2) === '0x' ? topic.substr(2) : topic;
})
.join('');
var topicTokens = decoder_1.default.decode(topicTypes, flatTopics);
if (topicTokens.length !== topics.length - toSkip) {
throw new Error('Invalid topic data');
}
var dataTypes = dataParams.map(function (param) { return param.kind; });
var dataTokens = decoder_1.default.decode(dataTypes, data);
var namedTokens = {};
topicParams.forEach(function (param, index) {
namedTokens[param.name || index] = topicTokens[index];
});
dataParams.forEach(function (param, index) {
namedTokens[param.name || index] = dataTokens[index];
});
var inputParamTypes = this.inputParamTypes();
var decodedParams = this.inputParamNames().map(function (name, index) {
return new decodedLogParam_1.default(name, inputParamTypes[index], namedTokens[name || index]);
});
return new decodedLog_1.default(decodedParams, address);
};
return Event;
}());
exports.default = Event;

@@ -1,43 +0,45 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('../paramType/format'),toParamType = _require.toParamType;var
EventParam = function () {
function EventParam(name, type) {var indexed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;_classCallCheck(this, EventParam);
this._name = name;
this._indexed = indexed;
this._kind = toParamType(type, indexed);
}_createClass(EventParam, [{ key: 'name', get: function get()
{
return this._name;
} }, { key: 'kind', get: function get()
{
return this._kind;
} }, { key: 'indexed', get: function get()
{
return this._indexed;
} }]);return EventParam;}();
EventParam.toEventParams = function (params) {
return params.map(function (param) {return new EventParam(param.name, param.type, param.indexed);});
};
module.exports = EventParam;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var format_1 = require("../paramType/format");
var EventParam = /** @class */ (function () {
function EventParam(name, type, indexed) {
if (indexed === void 0) { indexed = false; }
this._name = name;
this._indexed = indexed;
this._kind = format_1.toParamType(type, indexed);
}
EventParam.toEventParams = function (params) {
return params.map(function (param) {
return new EventParam(param.name, param.kind
? param.kind.type
: param.type, param.indexed);
});
};
Object.defineProperty(EventParam.prototype, "name", {
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(EventParam.prototype, "kind", {
get: function () {
return this._kind;
},
enumerable: true,
configurable: true
});
Object.defineProperty(EventParam.prototype, "indexed", {
get: function () {
return this._indexed;
},
enumerable: true,
configurable: true
});
return EventParam;
}());
exports.default = EventParam;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Event = require('./event');
module.exports = Event;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var event_1 = require("./event");
exports.default = event_1.default;

@@ -1,90 +0,96 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Decoder = require('../decoder/decoder');
var Encoder = require('../encoder/encoder');
var Param = require('./param');var _require =
require('../util/signature'),methodSignature = _require.methodSignature;var
Func = function () {
function Func(abi) {_classCallCheck(this, Func);
this._abi = abi;
this._constant = !!abi.constant;
this._payable = abi.payable;
this._inputs = Param.toParams(abi.inputs || []);
this._outputs = Param.toParams(abi.outputs || []);var _methodSignature =
methodSignature(abi.name, this.inputParamTypes()),id = _methodSignature.id,name = _methodSignature.name,signature = _methodSignature.signature;
this._id = id;
this._name = name;
this._signature = signature;
}_createClass(Func, [{ key: 'decodeInput', value: function decodeInput(
data) {
return Decoder.decode(this.inputParamTypes(), data);
} }, { key: 'decodeOutput', value: function decodeOutput(
data) {
return Decoder.decode(this.outputParamTypes(), data);
} }, { key: 'encodeCall', value: function encodeCall(
tokens) {
return '' + this._signature + Encoder.encode(tokens);
} }, { key: 'inputParamTypes', value: function inputParamTypes()
{
return this._inputs.map(function (input) {return input.kind;});
} }, { key: 'outputParamTypes', value: function outputParamTypes()
{
return this._outputs.map(function (output) {return output.kind;});
} }, { key: 'abi', get: function get() {return this._abi;} }, { key: 'constant', get: function get() {return this._constant;} }, { key: 'id', get: function get() {return this._id;} }, { key: 'inputs', get: function get() {return this._inputs;} }, { key: 'name', get: function get() {return this._name;} }, { key: 'outputs', get: function get() {return this._outputs;} }, { key: 'payable', get: function get() {return !!this._payable;} }, { key: 'signature', get: function get() {return this._signature;} }]);return Func;}();
module.exports = Func;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var decoder_1 = require("../decoder/decoder");
var encoder_1 = require("../encoder/encoder");
var signature_1 = require("../util/signature");
var param_1 = require("./param");
var Func = /** @class */ (function () {
function Func(abi) {
this._abi = abi;
this._constant = !!abi.constant;
this._payable = abi.payable || false;
this._inputs = param_1.default.toParams(abi.inputs || []);
this._outputs = param_1.default.toParams(abi.outputs || []);
var _a = signature_1.methodSignature(abi.name, this.inputParamTypes()), id = _a.id, name = _a.name, signature = _a.signature;
this._id = id;
this._name = name;
this._signature = signature;
}
Object.defineProperty(Func.prototype, "abi", {
get: function () {
return this._abi;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "constant", {
get: function () {
return this._constant;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "id", {
get: function () {
return this._id;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "inputs", {
get: function () {
return this._inputs;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "name", {
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "outputs", {
get: function () {
return this._outputs;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "payable", {
get: function () {
return !!this._payable;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Func.prototype, "signature", {
get: function () {
return this._signature;
},
enumerable: true,
configurable: true
});
Func.prototype.decodeInput = function (data) {
return decoder_1.default.decode(this.inputParamTypes(), data);
};
Func.prototype.decodeOutput = function (data) {
return decoder_1.default.decode(this.outputParamTypes(), data);
};
Func.prototype.encodeCall = function (tokens) {
return "" + this._signature + encoder_1.default.encode(tokens);
};
Func.prototype.inputParamTypes = function () {
return this._inputs.map(function (input) { return input.kind; });
};
Func.prototype.outputParamTypes = function () {
return this._outputs.map(function (output) { return output.kind; });
};
return Func;
}());
exports.default = Func;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Interface = require('./interface');
module.exports = Interface;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var interface_1 = require("./interface");
exports.default = interface_1.default;

@@ -1,79 +0,76 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Constructor = require('./constructor');
var Event = require('./event/event');
var Func = require('./function');
var Token = require('../token');var
Interface = function () {
function Interface(abi) {_classCallCheck(this, Interface);
this._interface = Interface.parseABI(abi);
}_createClass(Interface, [{ key: 'encodeTokens', value: function encodeTokens(
paramTypes, values) {
return Interface.encodeTokens(paramTypes, values);
} }, { key: 'interface', get: function get() {return this._interface;} }, { key: 'constructors', get: function get() {return this._interface.filter(function (item) {return item instanceof Constructor;});} }, { key: 'events', get: function get() {return this._interface.filter(function (item) {return item instanceof Event;});} }, { key: 'functions', get: function get() {return this._interface.filter(function (item) {return item instanceof Func;});} }]);return Interface;}();
Interface.encodeTokens = function (paramTypes, values) {
var createToken = function createToken(paramType, value) {
if (paramType.subtype) {
return new Token(paramType.type, value.map(function (entry) {return createToken(paramType.subtype, entry);}));
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var constructor_1 = require("./constructor");
var event_1 = require("./event/event");
var function_1 = require("./function");
var token_1 = require("../token");
var Interface = /** @class */ (function () {
function Interface(abi) {
this._interface = Interface.parseABI(abi);
}
return new Token(paramType.type, value);
};
return paramTypes.map(function (paramType, index) {return createToken(paramType, values[index]);});
};
Interface.parseABI = function (abi) {
return abi.map(function (item) {
switch (item.type) {
case 'constructor':
return new Constructor(item);
case 'event':
return new Event(item);
case 'function':
case 'fallback':
return new Func(item);
default:
throw new Error('Unknown ABI type ' + item.type);}
});
};
module.exports = Interface;
Interface.encodeTokens = function (paramTypes, values) {
var createToken = function (paramType, value) {
if (paramType.subtype) {
return new token_1.default(paramType.type, value.map(function (entry) {
return createToken(paramType.subtype, entry);
}));
}
return new token_1.default(paramType.type, value);
};
return paramTypes.map(function (paramType, index) {
return createToken(paramType, values[index]);
});
};
Interface.parseABI = function (abi) {
return abi.map(function (item) {
switch (item.type) {
case 'constructor':
return new constructor_1.default(item);
case 'event':
return new event_1.default(item);
case 'function':
case 'fallback':
return new function_1.default(item);
default:
throw new Error("Unknown ABI type " + item.type);
}
});
};
Object.defineProperty(Interface.prototype, "interface", {
get: function () {
return this._interface;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Interface.prototype, "constructors", {
get: function () {
return this._interface.filter(function (item) { return item instanceof constructor_1.default; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Interface.prototype, "events", {
get: function () {
return this._interface.filter(function (item) { return item instanceof event_1.default; });
},
enumerable: true,
configurable: true
});
Object.defineProperty(Interface.prototype, "functions", {
get: function () {
return this._interface.filter(function (item) { return item instanceof function_1.default; });
},
enumerable: true,
configurable: true
});
Interface.prototype.encodeTokens = function (paramTypes, values) {
return Interface.encodeTokens(paramTypes, values);
};
return Interface;
}());
exports.default = Interface;

@@ -1,44 +0,37 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('./paramType/format'),toParamType = _require.toParamType;var
Param = function () {
function Param(name, type) {_classCallCheck(this, Param);
this._name = name;
this._kind = toParamType(type);
}_createClass(Param, [{ key: 'name', get: function get()
{
return this._name;
} }, { key: 'kind', get: function get()
{
return this._kind;
} }]);return Param;}();
Param.toParams = function (params) {
return params.map(function (param) {
if (param instanceof Param) {
return param;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var format_1 = require("./paramType/format");
var Param = /** @class */ (function () {
function Param(name, type) {
this._name = name;
this._kind = format_1.toParamType(type);
}
return new Param(param.name, param.type);
});
};
module.exports = Param;
Param.toParams = function (params) {
return params.map(function (param) {
if (param instanceof Param) {
return param;
}
return new Param(param.name, param.type);
});
};
Object.defineProperty(Param.prototype, "name", {
get: function () {
return this._name;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Param.prototype, "kind", {
get: function () {
return this._kind;
},
enumerable: true,
configurable: true
});
return Param;
}());
exports.default = Param;

@@ -1,84 +0,82 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var ParamType = require('./paramType');
function toParamType(type, indexed) {
if (type[type.length - 1] === ']') {
var last = type.lastIndexOf('[');
var length = type.substr(last + 1, type.length - last - 2);
var subtype = toParamType(type.substr(0, last));
if (length.length === 0) {
return new ParamType('array', subtype, 0, indexed);
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var paramType_1 = require("./paramType");
/**
* Convert a string to a ParamType.
*
* @param type - Type to convert.
* @param indexed - Whether the ParamType is indexed or not.
*/
exports.toParamType = function (type, indexed) {
if (type[type.length - 1] === ']') {
var last = type.lastIndexOf('[');
var length_1 = type.substr(last + 1, type.length - last - 2);
var subtype = exports.toParamType(type.substr(0, last));
if (length_1.length === 0) {
return new paramType_1.default('array', subtype, 0, indexed);
}
return new paramType_1.default('fixedArray', subtype, parseInt(length_1, 10), indexed);
}
return new ParamType('fixedArray', subtype, parseInt(length, 10), indexed);
}
switch (type) {
case 'address':
case 'bool':
case 'bytes':
case 'string':
return new ParamType(type, null, 0, indexed);
case 'int':
case 'uint':
return new ParamType(type, null, 256, indexed);
default:
if (type.indexOf('uint') === 0) {
return new ParamType('uint', null, parseInt(type.substr(4), 10), indexed);
} else if (type.indexOf('int') === 0) {
return new ParamType('int', null, parseInt(type.substr(3), 10), indexed);
} else if (type.indexOf('bytes') === 0) {
return new ParamType('fixedBytes', null, parseInt(type.substr(5), 10), indexed);
}
throw new Error('Cannot convert ' + type + ' to valid ParamType');}
}
function fromParamType(paramType) {
switch (paramType.type) {
case 'address':
case 'bool':
case 'bytes':
case 'string':
return paramType.type;
case 'int':
case 'uint':
return '' + paramType.type + paramType.length;
case 'fixedBytes':
return 'bytes' + paramType.length;
case 'fixedArray':
return fromParamType(paramType.subtype) + '[' + paramType.length + ']';
case 'array':
return fromParamType(paramType.subtype) + '[]';
default:
throw new Error('Cannot convert from ParamType ' + paramType.type);}
}
switch (type) {
case 'address':
case 'bool':
case 'bytes':
case 'string':
return new paramType_1.default(type, undefined, 0, indexed);
case 'int':
case 'uint':
return new paramType_1.default(type, undefined, 256, indexed);
default:
if (type.indexOf('uint') === 0) {
return new paramType_1.default('uint', undefined, parseInt(type.substr(4), 10), indexed);
}
else if (type.indexOf('int') === 0) {
return new paramType_1.default('int', undefined, parseInt(type.substr(3), 10), indexed);
}
else if (type.indexOf('bytes') === 0) {
return new paramType_1.default('fixedBytes', undefined, parseInt(type.substr(5), 10), indexed);
}
throw new Error("Cannot convert " + type + " to valid ParamType");
}
};
/**
* Convert a ParamType to its string representation.
*
* @param paramType - ParamType instance to convert
*/
exports.fromParamType = function (paramType) {
switch (paramType.type) {
case 'address':
case 'bool':
case 'bytes':
case 'string':
return paramType.type;
case 'int':
case 'uint':
return "" + paramType.type + paramType.length;
case 'fixedBytes':
return "bytes" + paramType.length;
case 'fixedArray': {
if (!paramType.subtype) {
throw new Error("decodeParam: param of type '" + paramType.type + "' must have a subtype");
}
return exports.fromParamType(paramType.subtype) + "[" + paramType.length + "]";
}
case 'array': {
if (!paramType.subtype) {
throw new Error("decodeParam: param of type '" + paramType.type + "' must have a subtype");
}
return exports.fromParamType(paramType.subtype) + "[]";
}
default:
throw new Error("Cannot convert from ParamType " + paramType.type);
}
};
module.exports = {
fromParamType: fromParamType,
toParamType: toParamType };
fromParamType: exports.fromParamType,
toParamType: exports.toParamType
};

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var ParamType = require('./paramType');
module.exports = ParamType;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var paramType_1 = require("./paramType");
exports.default = paramType_1.default;

@@ -1,54 +0,55 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var TYPES = require('./types');var
ParamType = function () {
function ParamType(type) {var subtype = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;var length = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;var indexed = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;_classCallCheck(this, ParamType);
ParamType.validateType(type);
this._type = type;
this._subtype = subtype;
this._length = length;
this._indexed = indexed;
}_createClass(ParamType, [{ key: 'type', get: function get()
{
return this._type;
} }, { key: 'subtype', get: function get()
{
return this._subtype;
} }, { key: 'length', get: function get()
{
return this._length;
} }, { key: 'indexed', get: function get()
{
return this._indexed;
} }]);return ParamType;}();
ParamType.validateType = function (type) {
if (TYPES.filter(function (_type) {return type === _type;}).length) {
return true;
}
throw new Error('Invalid type ' + type + ' received for ParamType');
};
module.exports = ParamType;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var types_1 = require("./types");
var ParamType = /** @class */ (function () {
function ParamType(type, subtype, length, indexed) {
if (subtype === void 0) { subtype = undefined; }
if (length === void 0) { length = 0; }
if (indexed === void 0) { indexed = false; }
ParamType.validateType(type);
this._type = type;
this._subtype = subtype;
this._length = length;
this._indexed = indexed;
}
ParamType.validateType = function (type) {
if (types_1.default.some(function (_type) { return type === _type; })) {
return true;
}
throw new Error("Invalid type " + type + " received for ParamType");
};
Object.defineProperty(ParamType.prototype, "type", {
get: function () {
return this._type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParamType.prototype, "subtype", {
get: function () {
return this._subtype;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParamType.prototype, "length", {
get: function () {
return this._length;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ParamType.prototype, "indexed", {
get: function () {
return this._indexed;
},
enumerable: true,
configurable: true
});
return ParamType;
}());
exports.default = ParamType;

@@ -1,19 +0,18 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var TYPES = ['address', 'bytes', 'int', 'uint', 'bool', 'string', 'array', 'fixedBytes', 'fixedArray'];
module.exports = TYPES;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var TYPES = [
'address',
'bytes',
'int',
'uint',
'bool',
'string',
'array',
'fixedBytes',
'fixedArray'
];
exports.default = TYPES;

@@ -1,19 +0,8 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var Token = require('./token');
module.exports = Token;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var token_1 = require("./token");
exports.default = token_1.default;

@@ -1,44 +0,36 @@

'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");}} // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var TYPES = require('../spec/paramType/types');var
Token = function () {
function Token(type, value) {_classCallCheck(this, Token);
Token.validateType(type);
this._type = type;
this._value = value;
}_createClass(Token, [{ key: 'type', get: function get()
{
return this._type;
} }, { key: 'value', get: function get()
{
return this._value;
} }]);return Token;}();
Token.validateType = function (type) {
if (TYPES.filter(function (_type) {return type === _type;}).length) {
return true;
}
throw new Error('Invalid type ' + type + ' received for Token');
};
module.exports = Token;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var types_1 = require("../spec/paramType/types");
var Token = /** @class */ (function () {
function Token(type, value) {
Token.validateType(type);
this._type = type;
this._value = value;
}
Token.validateType = function (type) {
if (types_1.default.some(function (_type) { return type === _type; })) {
return true;
}
throw new Error("Invalid type " + type + " received for Token");
};
Object.defineProperty(Token.prototype, "type", {
get: function () {
return this._type;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Token.prototype, "value", {
get: function () {
return this._value;
},
enumerable: true,
configurable: true
});
return Token;
}());
exports.default = Token;

@@ -1,71 +0,64 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('js-sha3'),keccak_256 = _require.keccak_256; // eslint-disable-line camelcase
function isChecksumValid(_address) {
var address = _address.replace('0x', '');
var hash = keccak_256(address.toLowerCase());
for (var n = 0; n < 40; n++) {
var char = address[n];
var isLower = char !== char.toUpperCase();
var isUpper = char !== char.toLowerCase();
var hashval = parseInt(hash[n], 16);
if (hashval > 7 && isLower || hashval <= 7 && isUpper) {
return false;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var js_sha3_1 = require("js-sha3");
/**
* Verify that an address has a valid checksum.
*
* @param address - The Ethereum address to verify.
*/
exports.isChecksumValid = function (address) {
var _address = address.replace('0x', '');
var hash = js_sha3_1.keccak_256(_address.toLowerCase());
for (var n = 0; n < 40; n++) {
var char = _address[n];
var isLower = char !== char.toUpperCase();
var isUpper = char !== char.toLowerCase();
var hashval = parseInt(hash[n], 16);
if ((hashval > 7 && isLower) || (hashval <= 7 && isUpper)) {
return false;
}
}
}
return true;
}
function isAddress(address) {
if (address && address.length === 42) {
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
return false;
} else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
return true;
return true;
};
/**
* Verify that an address is a valid Ethereum address.
*
* @param address - The address to verify.
*/
exports.isAddress = function (address) {
if (address && address.length === 42) {
if (!/^(0x)?[0-9a-f]{40}$/i.test(address)) {
return false;
}
else if (/^(0x)?[0-9a-f]{40}$/.test(address) ||
/^(0x)?[0-9A-F]{40}$/.test(address)) {
return true;
}
return exports.isChecksumValid(address);
}
return isChecksumValid(address);
}
return false;
}
function toChecksumAddress(_address) {
var address = (_address || '').toLowerCase();
if (!isAddress(address)) {
return '';
}
var hash = keccak_256(address.slice(-40));
var result = '0x';
for (var n = 0; n < 40; n++) {
result = '' + result + (parseInt(hash[n], 16) > 7 ? address[n + 2].toUpperCase() : address[n + 2]);
}
return result;
}
module.exports = {
isAddress: isAddress,
isChecksumValid: isChecksumValid,
toChecksumAddress: toChecksumAddress };
return false;
};
/**
* Convert an Ethereum address to its checksum-valid version.
*
* @param address - The address to convert.
*/
exports.toChecksumAddress = function (address) {
if (address === void 0) { address = ''; }
var _address = address.toLowerCase();
if (!exports.isAddress(_address)) {
return '';
}
var hash = js_sha3_1.keccak_256(_address.slice(-40));
var result = '0x';
for (var n = 0; n < 40; n++) {
result = "" + result + (parseInt(hash[n], 16) > 7
? _address[n + 2].toUpperCase()
: _address[n + 2]);
}
return result;
};

@@ -1,87 +0,97 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var BigNumber = require('bignumber.js');
var utf8 = require('utf8');var _require =
require('./types'),isArray = _require.isArray;
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_js_1 = require("bignumber.js");
var utf8_1 = require("utf8");
var types_1 = require("./types");
var ZERO_64 = '0000000000000000000000000000000000000000000000000000000000000000';
function padAddress(_input) {
var input = _input.substr(0, 2) === '0x' ?
_input.substr(2) :
_input;
return ('' + ZERO_64 + input).slice(-64);
}
function padBool(input) {
return ('' + ZERO_64 + (input ? '1' : '0')).slice(-64);
}
function padU32(input) {
var bn = new BigNumber(input);
if (bn.lessThan(0)) {
bn = new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16).
plus(bn).plus(1);
}
return ('' + ZERO_64 + bn.toString(16)).slice(-64);
}
function stringToBytes(input) {
if (isArray(input)) {
return input;
} else if (input.substr(0, 2) === '0x') {
var matches = input.substr(2).toLowerCase().match(/.{1,2}/g) || [];
return matches.map(function (value) {return parseInt(value, 16);});
} else {
return input.split('').map(function (char) {return char.charCodeAt(0);});
}
}
function padBytes(_input) {
var input = stringToBytes(_input);
return '' + padU32(input.length) + padFixedBytes(input);
}
function padFixedBytes(_input) {
var input = stringToBytes(_input);
var sinput = input.map(function (code) {return ('0' + code.toString(16)).slice(-2);}).join('');
var max = Math.floor((sinput.length + 63) / 64) * 64;
return ('' + sinput + ZERO_64).substr(0, max);
}
function padString(input) {
var array = utf8.encode(input).
split('').
map(function (char) {return char.charCodeAt(0);});
return padBytes(array);
}
module.exports = {
padAddress: padAddress,
padBool: padBool,
padU32: padU32,
padBytes: padBytes,
padFixedBytes: padFixedBytes,
padString: padString };
/**
* Pad an address with zeros on the left.
*
* @param input - The input address to pad.
*/
exports.padAddress = function (input) {
var inputWithout0x = input.startsWith('0x') ? input.substr(2) : input;
return ("" + ZERO_64 + inputWithout0x).slice(-64);
};
/**
* Pad a boolean with zeros on the left.
*
* @param input - The input address to pad.
*/
exports.padBool = function (input) {
return ("" + ZERO_64 + (input ? '1' : '0')).slice(-64);
};
/**
* Pad a u32 with zeros on the left.
*
* @param input - The input address to pad.
*/
exports.padU32 = function (input) {
var bn = new bignumber_js_1.default(input);
if (bn.isNaN()) {
throw new Error('Input is not a valid number.');
}
if (bn.isLessThan(0)) {
bn = new bignumber_js_1.default('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)
.plus(bn)
.plus(1);
}
return ("" + ZERO_64 + bn.toString(16)).slice(-64);
};
/**
* Convert an input string to bytes.
*
* @param input - The input string to convert.
*/
exports.stringToBytes = function (input) {
if (types_1.isArray(input)) {
return input;
}
else if (input.startsWith('0x')) {
var matches = input
.substr(2)
.toLowerCase()
.match(/.{1,2}/g) || [];
return matches.map(function (value) { return parseInt(value, 16); });
}
else {
return input.split('').map(function (char) { return char.charCodeAt(0); });
}
};
/**
* Pad bytes with zeros on the left.
*
* @param input - The input bytes to pad.
*/
exports.padBytes = function (input) {
var inputBytes = exports.stringToBytes(input);
return "" + exports.padU32(inputBytes.length) + exports.padFixedBytes(inputBytes);
};
/**
* Pad fixed bytes.
*
* @param input - Input bytes to pad.
*/
exports.padFixedBytes = function (input) {
var inputBytes = exports.stringToBytes(input);
var sinput = inputBytes
.map(function (code) { return ("0" + code.toString(16)).slice(-2); })
.join('');
var max = Math.floor((sinput.length + 63) / 64) * 64;
return ("" + sinput + ZERO_64).substr(0, max);
};
/**
* Pad string.
*
* @param input - String to pad.
*/
exports.padString = function (input) {
var array = utf8_1.encode(input)
.split('')
.map(function (char) { return char.charCodeAt(0); });
return exports.padBytes(array);
};

@@ -1,53 +0,47 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('js-sha3'),keccak_256 = _require.keccak_256; // eslint-disable-line camelcase
var _require2 = require('../spec/paramType/format'),fromParamType = _require2.fromParamType;
function eventSignature(eventName, params) {var _parseName =
parseName(eventName),strName = _parseName.strName,name = _parseName.name;
var types = (params || []).map(fromParamType).join(',');
var id = strName + '(' + types + ')';
var signature = strName ? keccak_256(id) : '';
return { id: id, name: name, signature: signature };
}
function methodSignature(methodName, params) {var _eventSignature =
eventSignature(methodName, params),id = _eventSignature.id,name = _eventSignature.name,signature = _eventSignature.signature;
return { id: id, name: name, signature: signature.substr(0, 8) };
}
function parseName(name) {
var strName = '' + (name || '');
var index = strName.indexOf('(');
if (index === -1) {
return { strName: strName, name: name };
}
var trimmedName = strName.slice(0, index);
return {
strName: trimmedName,
name: trimmedName };
}
module.exports = {
eventSignature: eventSignature,
methodSignature: methodSignature };
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var js_sha3_1 = require("js-sha3");
var format_1 = require("../spec/paramType/format");
/**
* Get event signature.
*/
exports.eventSignature = function (eventName, params) {
if (params === void 0) { params = []; }
var _a = exports.parseName(eventName), strName = _a.strName, name = _a.name;
var types = (params || []).map(format_1.fromParamType).join(',');
var id = strName + "(" + types + ")";
var signature = strName ? js_sha3_1.keccak_256(id) : '';
return { id: id, name: name, signature: signature };
};
/**
* Get method signature.
*
* @param methodName - The method name.
* @param params - The list of params
*/
exports.methodSignature = function (methodName, params) {
if (params === void 0) { params = []; }
var _a = exports.eventSignature(methodName, params), id = _a.id, name = _a.name, signature = _a.signature;
return { id: id, name: name, signature: signature.substr(0, 8) };
};
/**
* Parse name.
*
* @param name - Name to parse.
*/
exports.parseName = function (name) {
var strName = "" + (name || '');
var index = strName.indexOf('(');
if (index === -1) {
return { strName: strName, name: name };
}
var trimmedName = strName.slice(0, index);
return {
strName: trimmedName,
name: trimmedName
};
};

@@ -1,34 +0,22 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var _require =
require('./pad'),padAddress = _require.padAddress;
function sliceData(_data) {
if (!_data || !_data.length) {
return [];
}
var data = _data.substr(0, 2) === '0x' ? _data.substr(2) : _data;
if (!data.length) {
data = padAddress('');
}
return data.match(/.{1,64}/g);
}
module.exports = {
sliceData: sliceData };
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var pad_1 = require("./pad");
/**
* Slice data.
*
* @param data - Data to slice.
*/
exports.sliceData = function (data) {
if (!data || !data.length) {
return [];
}
var dataWithout0x = data.substr(0, 2) === '0x' ? data.substr(2) : data;
if (!dataWithout0x.length) {
dataWithout0x = pad_1.padAddress('');
}
return dataWithout0x.match(/.{1,64}/g);
};

@@ -1,53 +0,48 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
var BigNumber = require('bignumber.js');var _require =
require('./address'),toChecksumAddress = _require.toChecksumAddress;
function asU32(slice) {
// TODO: validation
return new BigNumber(slice, 16);
}
function asI32(slice) {
if (new BigNumber(slice.substr(0, 1), 16).toString(2)[0] === '1') {
return new BigNumber(slice, 16).
minus(new BigNumber('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16)).
minus(1);
}
return new BigNumber(slice, 16);
}
function asAddress(slice) {
// TODO: address validation?
return toChecksumAddress('0x' + slice.slice(-40));
}
function asBool(slice) {
// TODO: everything else should be 0
return new BigNumber(slice[63]).eq(1);
}
module.exports = {
asAddress: asAddress,
asBool: asBool,
asI32: asI32,
asU32: asU32 };
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var bignumber_js_1 = require("bignumber.js");
var address_1 = require("./address");
/**
* Convert slice to u32.
*
* @param slice - Slice to convert.
*/
exports.asU32 = function (slice) {
// TODO: validation
return new bignumber_js_1.default(slice.toLowerCase(), 16);
};
/**
* Convert slice to i32.
*
* @param slice - Slice to convert.
*/
exports.asI32 = function (slice) {
if (new bignumber_js_1.default(slice.substr(0, 1), 16).toString(2)[0] === '1') {
return new bignumber_js_1.default(slice, 16)
.minus(new bignumber_js_1.default('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16))
.minus(1);
}
return new bignumber_js_1.default(slice, 16);
};
/**
* Convert slice to checksum address.
*
* @param slice - Slice to convert.
*/
exports.asAddress = function (slice) {
// TODO: address validation?
return address_1.toChecksumAddress("0x" + slice.slice(-40));
};
/**
* Convert slice to boolean.
*
* @param slice - Slice to convert.
*/
exports.asBool = function (slice) {
// TODO: everything else should be 0
return new bignumber_js_1.default(slice[63]).eq(1);
};

@@ -1,32 +0,63 @@

'use strict'; // Copyright 2015-2017 Parity Technologies (UK) Ltd.
"use strict";
// Copyright 2015-2018 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity 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 General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
function isArray(test) {
return Object.prototype.toString.call(test) === '[object Array]';
//
// SPDX-License-Identifier: MIT
Object.defineProperty(exports, "__esModule", { value: true });
var HEXDIGITS = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'
];
function isArray(input) {
return Array.isArray(input);
}
function isString(test) {
return Object.prototype.toString.call(test) === '[object String]';
exports.isArray = isArray;
function isError(input) {
return input instanceof Error;
}
function isInstanceOf(test, clazz) {
return test instanceof clazz;
exports.isError = isError;
function isFunction(input) {
return typeof input === 'function';
}
module.exports = {
isArray: isArray,
isString: isString,
isInstanceOf: isInstanceOf };
exports.isFunction = isFunction;
function isHex(input) {
if (!isString(input)) {
return false;
}
if (input.substr(0, 2) === '0x') {
return isHex(input.slice(2));
}
var lowerCaseInput = input.toLowerCase();
var hex = true;
for (var index = 0; hex && index < input.length; index++) {
hex = HEXDIGITS.includes(lowerCaseInput[index]);
}
return hex;
}
exports.isHex = isHex;
function isObject(input) {
return Object.prototype.toString.call(input) === '[object Object]';
}
exports.isObject = isObject;
function isString(input) {
return typeof input === 'string';
}
exports.isString = isString;
function isInstanceOf(input, clazz) {
return input instanceof clazz;
}
exports.isInstanceOf = isInstanceOf;
{
"name": "@parity/abi",
"description": "The Parity ABI library",
"version": "2.1.4",
"description": "Ethereum ABI encoder and decoder",
"version": "3.0.1",
"author": "Parity Team <admin@parity.io>",
"license": "MIT",
"repository": "https://github.com/paritytech/js-libs/tree/master/packages/abi",
"main": "lib/index.js",
"author": "Parity Team <admin@parity.io>",
"maintainers": [
"Jaco Greeff",
"Nicolas Gotchac"
],
"contributors": [],
"license": "GPL-3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/paritytech/js-abi.git"
},
"keywords": [

@@ -22,46 +14,20 @@ "Ethereum",

],
"engines": {
"node": ">=6.4"
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "rimraf lib && babel src --out-dir lib --ignore *.spec.js",
"ci:makeshift": "makeshift",
"lint": "npm run lint:css && npm run lint:js",
"lint:css": "echo \"WARN: npm run lint:css skipped\"",
"lint:js": "eslint src",
"test": "cross-env NODE_ENV=test mocha 'src/**/*.spec.js'",
"test:coverage": "cross-env NODE_ENV=test istanbul cover _mocha 'src/**/*.spec.js' && coveralls < coverage/lcov.info"
"docs": "typedoc",
"prebuild": "rimraf lib",
"build": "tsc",
"test": "jest"
},
"publishConfig": {
"access": "public"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"chai": "^4.1.0",
"coveralls": "^3.0.0",
"cross-env": "^5.1.1",
"eslint": "^4.4.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-react": "^5.0.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.1.1",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-standard": "^3.0.1",
"istanbul": "^0.4.5",
"makeshift": "^1.1.0",
"mocha": "^3.4.2",
"rimraf": "^2.6.2"
"@types/utf8": "^2.1.6"
},
"dependencies": {
"bignumber.js": "4.1.0",
"js-sha3": "0.5.5",
"utf8": "^2.1.2"
}
"bignumber.js": "7.2.1",
"js-sha3": "0.7.0",
"utf8": "^3.0.0"
},
"gitHead": "bc821a3d11caf6062f055628c1d1454263b53603"
}

@@ -5,18 +5,21 @@ # @parity/abi

[![Build Status](https://travis-ci.org/paritytech/js-abi.svg?branch=master)](https://travis-ci.org/paritytech/js-abi)
[![Coverage Status](https://coveralls.io/repos/github/paritytech/js-abi/badge.svg?branch=master)](https://coveralls.io/github/paritytech/js-abi?branch=master)
[![Dependency Status](https://david-dm.org/paritytech/js-abi.svg)](https://david-dm.org/paritytech/js-abi)
[![devDependency Status](https://david-dm.org/paritytech/js-abi/dev-status.svg)](https://david-dm.org/paritytech/js-abi#info=devDependencies)
[![Build Status](https://travis-ci.org/paritytech/js-libs.svg?branch=master)](https://travis-ci.org/paritytech/js-libs)
[![npm (scoped)](https://img.shields.io/npm/v/@parity/abi.svg)](https://www.npmjs.com/package/@parity/abi)
[![npm](https://img.shields.io/npm/dw/@parity/abi.svg)](https://www.npmjs.com/package/@parity/abi)
[![dependencies Status](https://david-dm.org/paritytech/js-libs/status.svg?path=packages/abi)](https://david-dm.org/paritytech/js-libs?path=packages/abi)
[![docs](https://img.shields.io/badge/docs-passing-green.svg)](https://parity-js.github.io/abi/)
## contributing
## [Full Documentation](https://parity-js.github.io/abi/)
## Contributing
Clone the repo and install dependencies via `npm install`. Tests can be executed via `npm run test`
## installation
## Installation
Install the package with `npm install --save @parity/abi` from [@parity/abi](https://www.npmjs.com/package/@parity/abi)
## Implementation
## implementation
### approach
### Approach

@@ -27,3 +30,3 @@ - this version tries to stay as close to the original Rust version in intent, function names & purpose

### differences to original Rust version
### Differences to original Rust version

@@ -30,0 +33,0 @@ - internally the library operates on string binary representations as opposed to Vector bytes, lengths are therefore 64 bytes as opposed to 32 bytes

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc