cic-client
Version:
Typescript libraries for building CIC client applications
156 lines (130 loc) • 105 kB
JavaScript
/*
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
* This devtool is not neither made for production nor for readable output files.
* It uses "eval()" calls to create a separate source file in the browser devtools.
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
* or disable the default devtool with "devtool: false".
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
*/
window.cic =
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./dist/bancor/convert.js":
/*!********************************!*\
!*** ./dist/bancor/convert.js ***!
\********************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 2:17-21 */
/*! CommonJS bailout: this is used directly at 11:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Conversion = void 0;\nvar tx_1 = __webpack_require__(/*! ../common/tx */ \"./dist/common/tx.js\");\nvar topic_convert = '0x7154b38b5dd31bb3122436a96d4e09aba5b323ae1fd580025fab55074334c095';\n/**\n * Instance represents a single conversion event on network.\n *\n * @class Conversion\n */\nvar Conversion = /** @class */ (function () {\n /**\n *\n * @param tx Ethereum transaction\n * @param sourceToken ERC20 token sent in conversion\n * @param destinationToken ERC20 token received from conversion\n * @param trader Ethereum address performing the conversion (sender and recipient)\n * @param fromValue Source token value of conversion\n * @param toValue Destination token value of conversion\n */\n function Conversion(tx, sourceToken, destinationToken, trader, fromValue, toValue) {\n this.sourceToken = sourceToken;\n this.destinationToken = destinationToken;\n this.trader = trader;\n this.fromValue = fromValue;\n this.toValue = toValue;\n this.tx = tx;\n }\n /**\n * Scans a transaction log for transfer event.\n *\n * @static\n * @param w3 A connected Web3 object\n * @param registry Registry context of conversion\n * @param success State of transaction\n * @param log A Web3 transaction receipt logs array\n * @return conversion Instance of Conversion if conversion is found, undefined if not.\n */\n Conversion.processLog = function (w3, registry, success, log) {\n return __awaiter(this, void 0, void 0, function () {\n var conversion, block, sourceToken_address, sourceToken, destinationToken_address, destinationToken, fromValue, toValue, trader, tx;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n conversion = undefined;\n if (!(log.topics[0] == topic_convert)) return [3 /*break*/, 4];\n return [4 /*yield*/, w3.eth.getBlock(log.blockNumber)];\n case 1:\n block = _a.sent();\n sourceToken_address = w3.utils.toChecksumAddress('0x' + log.topics[1].substring(26, 66));\n return [4 /*yield*/, registry.getToken(sourceToken_address)];\n case 2:\n sourceToken = _a.sent();\n destinationToken_address = w3.utils.toChecksumAddress('0x' + log.topics[2].substring(26, 66));\n return [4 /*yield*/, registry.getToken(destinationToken_address)];\n case 3:\n destinationToken = _a.sent();\n fromValue = BigInt(log.data.substring(0, 66));\n toValue = BigInt(log.data.substring(0, 66));\n trader = w3.utils.toChecksumAddress('0x' + log.data.substring(154));\n tx = new tx_1.Tx(log.blockNumber, log.transactionIndex, log.transactionHash, block.timestamp, success);\n conversion = new Conversion(tx, sourceToken, destinationToken, trader, fromValue, toValue);\n console.log('convert', conversion);\n _a.label = 4;\n case 4: return [2 /*return*/, conversion];\n }\n });\n });\n };\n return Conversion;\n}());\nexports.Conversion = Conversion;\n\n\n//# sourceURL=webpack://cic/./dist/bancor/convert.js?");
/***/ }),
/***/ "./dist/common/erc20.js":
/*!******************************!*\
!*** ./dist/common/erc20.js ***!
\******************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 7:17-21 */
/*! CommonJS bailout: this is used directly at 16:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\n/**\n * Provides a representation of a token transfer transaction, aswell as a processor to detect transfer events.\n *\n * @module erc20\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.topics = exports.Token = exports.Transfer = void 0;\nvar tx_1 = __webpack_require__(/*! ./tx */ \"./dist/common/tx.js\");\nvar topics = {\n 'transfer': '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',\n};\nexports.topics = topics;\n/**\n * A Transfer instance represents a single ERC20 token transfer.\n *\n * @class Transfer\n */\nvar Transfer = /** @class */ (function () {\n /**\n *\n * @param tx A transaction object\n * @param token Ethereum address of ERC20 token transferred\n * @param from Ethereum address of sender\n * @param to Ethereum address of receipient\n * @param value Value of transfer\n */\n function Transfer(tx, token, from, to, value) {\n this.from = from;\n this.to = to;\n this.token = token;\n this.value = value;\n this.tx = tx;\n }\n /**\n * Scans a transaction log for transfer event.\n *\n * @static\n * @param w3 A connected Web3 object\n * @param success State of transaction\n * @param token Token address to find transfer for\n * @param log A Web3 transaction receipt logs array\n * @return transfer Instance of Transfer if transfer is found, undefined if not.\n */\n Transfer.processLog = function (w3, success, token, log) {\n return __awaiter(this, void 0, void 0, function () {\n var transfer, block, from, to, value, tx;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n transfer = undefined;\n if (!(log.topics[0] == topics['transfer'])) return [3 /*break*/, 2];\n return [4 /*yield*/, w3.eth.getBlock(log.blockNumber)];\n case 1:\n block = _a.sent();\n from = w3.utils.toChecksumAddress(log.topics[1].substring(26, 66));\n to = w3.utils.toChecksumAddress(log.topics[2].substring(26, 66));\n value = BigInt(log.data);\n tx = new tx_1.Tx(log.blockNumber, log.transactionIndex, log.transactionHash, block.timestamp, success);\n transfer = new Transfer(tx, token, from, to, value);\n _a.label = 2;\n case 2: return [2 /*return*/, transfer];\n }\n });\n });\n };\n return Transfer;\n}());\nexports.Transfer = Transfer;\n/**\n * Metadata for a single ERC20 token.\n *\n * @class Token\n *\n */\nvar Token = /** @class */ (function () {\n /**\n *\n * @param address Ethereum address of token contract\n * @param name ERC20 token name\n * @param symbol ERC20 token symbol\n */\n function Token(address, name, symbol, decimals, totalSupply) {\n this.address = address;\n this.name = name;\n this.symbol = symbol;\n this.totalSupply = totalSupply;\n this.decimals = decimals;\n }\n /**\n * Informal string representation of token.\n *\n */\n Token.prototype.toString = function () {\n return 'Token: ' + this.name + ' (' + this.symbol + ')';\n };\n return Token;\n}());\nexports.Token = Token;\n\n\n//# sourceURL=webpack://cic/./dist/common/erc20.js?");
/***/ }),
/***/ "./dist/common/tx.js":
/*!***************************!*\
!*** ./dist/common/tx.js ***!
\***************************/
/*! flagged exports */
/*! export Log [provided] [no usage info] [missing usage info prevents renaming] */
/*! export Tx [provided] [no usage info] [missing usage info prevents renaming] */
/*! export __esModule [provided] [no usage info] [missing usage info prevents renaming] */
/*! other exports [not provided] [no usage info] */
/*! runtime requirements: __webpack_exports__ */
/***/ ((__unused_webpack_module, exports) => {
"use strict";
eval("\n/**\n * Abstractions of Web3 transactions and transaction receipt logs\n *\n * @module tx\n */\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Log = exports.Tx = void 0;\n/**\n * Instance encapsulates metadata of a single mined transaction.\n *\n * @class Tx\n */\nvar Tx = /** @class */ (function () {\n /**\n *\n * @param block Block number\n * @param txIndex Transaction index in block\n * @param txHash Transaction hash\n * @param timestamp Block timestamp\n * @param success Whether transaction was successful\n */\n function Tx(block, txIndex, txHash, timestamp, success) {\n this.block = block;\n this.txIndex = txIndex;\n this.txHash = txHash;\n this.timestamp = timestamp;\n this.success = success;\n }\n return Tx;\n}());\nexports.Tx = Tx;\n/**\n * Represents a single Web3 transaction receipt Log entry\n *\n * @class Log\n * @todo Should be changed to type def instead\n */\nvar Log = /** @class */ (function () {\n function Log() {\n }\n return Log;\n}());\nexports.Log = Log;\n\n\n//# sourceURL=webpack://cic/./dist/common/tx.js?");
/***/ }),
/***/ "./dist/const.js":
/*!***********************!*\
!*** ./dist/const.js ***!
\***********************/
/*! flagged exports */
/*! export __esModule [provided] [no usage info] [missing usage info prevents renaming] */
/*! export zeroAddress [provided] [no usage info] [missing usage info prevents renaming] */
/*! export zeroContent [provided] [no usage info] [missing usage info prevents renaming] */
/*! other exports [not provided] [no usage info] */
/*! runtime requirements: __webpack_exports__ */
/***/ ((__unused_webpack_module, exports) => {
"use strict";
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.zeroAddress = exports.zeroContent = void 0;\nvar zeroContent = '0x0000000000000000000000000000000000000000000000000000000000000000';\nexports.zeroContent = zeroContent;\nvar zeroAddress = '0x0000000000000000000000000000000000000000';\nexports.zeroAddress = zeroAddress;\n\n\n//# sourceURL=webpack://cic/./dist/const.js?");
/***/ }),
/***/ "./dist/crypto.js":
/*!************************!*\
!*** ./dist/crypto.js ***!
\************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 2:23-27 */
/*! CommonJS bailout: this is used directly at 9:26-30 */
/*! CommonJS bailout: this is used directly at 14:20-24 */
/*! CommonJS bailout: this is used directly at 21:17-21 */
/*! CommonJS bailout: this is used directly at 30:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.subtle = void 0;\nvar crypto = __importStar(__webpack_require__(/*! crypto */ \"?8465\"));\nvar _algs = {\n 'SHA-256': 'sha256',\n};\nfunction cryptoWrapper() {\n}\ncryptoWrapper.prototype.digest = function (s, d) {\n return __awaiter(this, void 0, void 0, function () {\n var h;\n return __generator(this, function (_a) {\n h = crypto.createHash(_algs[s]);\n h.update(d);\n return [2 /*return*/, h.digest()];\n });\n });\n};\nvar subtle = undefined;\nexports.subtle = subtle;\nif (typeof window !== 'undefined') {\n exports.subtle = subtle = window.crypto.subtle;\n}\nelse {\n exports.subtle = subtle = new cryptoWrapper();\n}\n\n\n//# sourceURL=webpack://cic/./dist/crypto.js?");
/***/ }),
/***/ "./dist/digest.js":
/*!************************!*\
!*** ./dist/digest.js ***!
\************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 2:23-27 */
/*! CommonJS bailout: this is used directly at 9:26-30 */
/*! CommonJS bailout: this is used directly at 14:20-24 */
/*! CommonJS bailout: this is used directly at 21:17-21 */
/*! CommonJS bailout: this is used directly at 30:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\n}) : function(o, v) {\n o[\"default\"] = v;\n});\nvar __importStar = (this && this.__importStar) || function (mod) {\n if (mod && mod.__esModule) return mod;\n var result = {};\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\n __setModuleDefault(result, mod);\n return result;\n};\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.addressToBytes = exports.bytesToHex = exports.toAddressKey = exports.toKey = void 0;\nvar crypto = __importStar(__webpack_require__(/*! ./crypto */ \"./dist/crypto.js\"));\nfunction stringToBytes(s) {\n var a = new Uint8Array(20);\n var j = 2;\n for (var i = 0; i < a.byteLength; i++) {\n var n = parseInt(s.substring(j, j + 2), 16);\n a[i] = n;\n j += 2;\n }\n return a;\n}\nfunction bytesToHex(a) {\n var s = '';\n for (var i = 0; i < a.byteLength; i++) {\n var h = '00' + a[i].toString(16);\n s += h.slice(-2);\n }\n return s;\n}\nexports.bytesToHex = bytesToHex;\nfunction mergeKey(a, s) {\n return __awaiter(this, void 0, void 0, function () {\n var y, i, i, z;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n y = new Uint8Array(a.byteLength + s.byteLength);\n for (i = 0; i < a.byteLength; i++) {\n y[i] = a[i];\n }\n for (i = 0; i < s.byteLength; i++) {\n y[a.byteLength + i] = s[i];\n }\n return [4 /*yield*/, crypto.subtle.digest('SHA-256', y)];\n case 1:\n z = _a.sent();\n return [2 /*return*/, bytesToHex(new Uint8Array(z))];\n }\n });\n });\n}\nfunction toKey(v, salt) {\n return __awaiter(this, void 0, void 0, function () {\n var a, s;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n a = stringToBytes(v);\n s = new TextEncoder().encode(salt);\n return [4 /*yield*/, mergeKey(a, s)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n}\nexports.toKey = toKey;\nfunction toAddressKey(zeroExHex, salt) {\n return __awaiter(this, void 0, void 0, function () {\n var a, s;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n a = addressToBytes(zeroExHex);\n s = new TextEncoder().encode(salt);\n return [4 /*yield*/, mergeKey(a, s)];\n case 1: return [2 /*return*/, _a.sent()];\n }\n });\n });\n}\nexports.toAddressKey = toAddressKey;\nvar re_addrHex = /^0[xX][a-fA-F0-9]{40}$/;\nfunction addressToBytes(s) {\n if (!s.match(re_addrHex)) {\n throw 'invalid address hex';\n }\n return stringToBytes(s);\n}\nexports.addressToBytes = addressToBytes;\n\n\n//# sourceURL=webpack://cic/./dist/digest.js?");
/***/ }),
/***/ "./dist/helper.js":
/*!************************!*\
!*** ./dist/helper.js ***!
\************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 7:17-21 */
/*! CommonJS bailout: this is used directly at 16:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\n/**\n * Provides processing of Ethereum transaction receipts relevant for the CIC network.\n *\n * @module helper\n */\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.TokenDeclarationHelper = exports.TransactionHelper = exports.DeclaratorHelper = void 0;\nvar erc20_1 = __webpack_require__(/*! ./common/erc20 */ \"./dist/common/erc20.js\");\nvar convert_1 = __webpack_require__(/*! ./bancor/convert */ \"./dist/bancor/convert.js\");\nvar solidity_1 = __webpack_require__(/*! ./solidity */ \"./dist/solidity.js\");\nvar const_1 = __webpack_require__(/*! ./const */ \"./dist/const.js\");\n/**\n * Reduced, concrete view of a transaction receipt.\n *\n * @todo Is there a way of importing the web3 type instead?\n */\nvar Receipt = /** @class */ (function () {\n function Receipt() {\n }\n return Receipt;\n}());\n/**\n * Receipt processor within context of a given registry.\n *\n */\nvar TransactionHelper = /** @class */ (function () {\n /**\n *\n * @param registry The registry context to use\n */\n function TransactionHelper(w3, registry) {\n this.w3 = w3;\n this.registry = registry;\n this.ontransfer = function (t) {\n console.debug('transfer ', t);\n };\n this.onconversion = function (c) {\n console.debug('convert ', c);\n };\n }\n /**\n * Processes a single receipt to find conversion and token transfer events.\n *\n * If a transfer is found, ontransfer callback will be called with a Transfer instance.\n * If a conversion is found, onconvsrsion callback will be called with a Conversion instance.\n *\n * @param r A Web3 transaction receipt.\n * @todo The from-amount of convert is currently wrong, but be retrieved from the initial transfer log entry instead.\n */\n TransactionHelper.prototype.processReceipt = function (r) {\n return __awaiter(this, void 0, void 0, function () {\n var self, logs, convert_log, token_txs, i, contractAddress, t, e_1, d, t, e_2, e_3, conversion, _i, token_txs_1, a, transfer;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0:\n self = this;\n logs = r.logs;\n convert_log = undefined;\n token_txs = [];\n i = 0;\n _a.label = 1;\n case 1:\n if (!(i < logs.length)) return [3 /*break*/, 15];\n contractAddress = logs[i].address;\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 14]);\n return [4 /*yield*/, this.registry.getToken(contractAddress)];\n case 3:\n t = _a.sent();\n token_txs.push([r.status, t, logs[i]]);\n return [3 /*break*/, 14];\n case 4:\n e_1 = _a.sent();\n _a.label = 5;\n case 5:\n _a.trys.push([5, 8, , 13]);\n return [4 /*yield*/, this.registry.declaratorHelper.getTrustedTokenDeclaration('AddressDeclarator', contractAddress)];\n case 6:\n d = _a.sent();\n console.debug('trust record for ' + contractAddress + ' found', d);\n return [4 /*yield*/, this.registry.addToken(contractAddress)];\n case 7:\n t = _a.sent();\n token_txs.push([r.status, t, logs[i]]);\n return [3 /*break*/, 13];\n case 8:\n e_2 = _a.sent();\n _a.label = 9;\n case 9:\n _a.trys.push([9, 11, , 12]);\n return [4 /*yield*/, this.registry.getContract(contractAddress)];\n case 10:\n _a.sent();\n convert_log = logs[i];\n return [3 /*break*/, 15];\n case 11:\n e_3 = _a.sent();\n return [3 /*break*/, 14];\n case 12: return [3 /*break*/, 13];\n case 13: return [3 /*break*/, 14];\n case 14:\n i++;\n return [3 /*break*/, 1];\n case 15:\n if (!(convert_log !== undefined)) return [3 /*break*/, 17];\n return [4 /*yield*/, convert_1.Conversion.processLog(this.w3, this.registry, r.status, convert_log)];\n case 16:\n conversion = _a.sent();\n if (conversion !== undefined) {\n this.onconversion(conversion);\n }\n return [3 /*break*/, 21];\n case 17:\n _i = 0, token_txs_1 = token_txs;\n _a.label = 18;\n case 18:\n if (!(_i < token_txs_1.length)) return [3 /*break*/, 21];\n a = token_txs_1[_i];\n return [4 /*yield*/, erc20_1.Transfer.processLog(this.w3, a[0], a[1], a[2])];\n case 19:\n transfer = _a.sent();\n if (transfer !== undefined) {\n this.ontransfer(transfer);\n }\n _a.label = 20;\n case 20:\n _i++;\n return [3 /*break*/, 18];\n case 21: return [2 /*return*/];\n }\n });\n });\n };\n return TransactionHelper;\n}());\nexports.TransactionHelper = TransactionHelper;\n/**\n * Token query within the context of a registry.\n */\nvar TokenDeclarationHelper = /** @class */ (function () {\n /**\n *\n * @param w3\n * @param registry The registry context to use.\n */\n function TokenDeclarationHelper(w3, registry) {\n this.registry = registry;\n this.w3 = w3;\n }\n /**\n * Check if a token fits the ERC20 standard.\n *\n * @param tokenAddress The address of the token to be checked.\n */\n TokenDeclarationHelper.prototype.assertERC20TokenType = function (tokenAddress) {\n return __awaiter(this, void 0, void 0, function () {\n var erc20Abi, tokenContract, tokenSymbol, e_4;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.registry.getAbi('ERC20')];\n case 1:\n erc20Abi = _a.sent();\n _a.label = 2;\n case 2:\n _a.trys.push([2, 4, , 5]);\n tokenContract = new this.w3.eth.Contract(erc20Abi, tokenAddress);\n return [4 /*yield*/, tokenContract.methods.symbol().call()];\n case 3:\n tokenSymbol = _a.sent();\n if (tokenSymbol !== undefined) {\n return [2 /*return*/, true];\n }\n return [3 /*break*/, 5];\n case 4:\n e_4 = _a.sent();\n console.log('contract ' + tokenAddress + ' is not an ERC20 token');\n return [3 /*break*/, 5];\n case 5: return [2 /*return*/, false];\n }\n });\n });\n };\n return TokenDeclarationHelper;\n}());\nexports.TokenDeclarationHelper = TokenDeclarationHelper;\n/**\n * Declarator query within the context of a registry.\n */\nvar DeclaratorHelper = /** @class */ (function () {\n /**\n *\n * @param w3\n * @param registry The registry context to use.\n */\n function DeclaratorHelper(w3, registry) {\n this.registry = registry;\n this.trusts = [];\n this.tokenHelper = new TokenDeclarationHelper(w3, registry);\n }\n /**\n * Add an address to list of declarators to trust.\n *\n * @param address The address to be added to the trust list\n */\n DeclaratorHelper.prototype.addTrust = function (address) {\n this.trusts.push(address);\n };\n /**\n * Check for trust records of a token\n *\n * if there are no trust records, an error will be thrown.\n *\n * @param tokenRegistryContractName The name of the token in the token registry.\n * @param tokenAddress The address of the contract used to deploy the token.\n * @param checkInterface A boolean on whether to to check the interface.\n */\n DeclaratorHelper.prototype.getTrustedTokenDeclaration = function (tokenRegistryContractName, tokenAddress, checkInterface) {\n if (checkInterface === void 0) { checkInterface = false; }\n return __awaiter(this, void 0, void 0, function () {\n var i, isERC20, _a;\n return __generator(this, function (_b) {\n switch (_b.label) {\n case 0:\n i = 0;\n _b.label = 1;\n case 1:\n if (!(i < this.trusts.length)) return [3 /*break*/, 7];\n console.debug('checking for trust record by ' + this.trusts[i] + ' for token ' + tokenAddress);\n _b.label = 2;\n case 2:\n _b.trys.push([2, 5, , 6]);\n return [4 /*yield*/, this.tokenHelper.assertERC20TokenType(tokenAddress)];\n case 3:\n isERC20 = _b.sent();\n if (isERC20) {\n console.log('contract ' + tokenAddress + ' is an ERC20 token');\n }\n return [4 /*yield*/, this.getTokenDeclaration(tokenRegistryContractName, this.trusts[i], tokenAddress, checkInterface)];\n case 4: return [2 /*return*/, _b.sent()];\n case 5:\n _a = _b.sent();\n return [3 /*break*/, 6];\n case 6:\n i++;\n return [3 /*break*/, 1];\n case 7: throw new Error('no trusted records for token ' + tokenAddress);\n }\n });\n });\n };\n /**\n * Check for trust records for a token by a declarator.\n *\n * @param tokenRegistryContractName The name of the token in the token registry.\n * @param declarator The address of the declarator used to check for trust.\n * @param tokenAddress The address of the contract used to deploy the token.\n * @param checkInterface A boolean on whether to to check the interface.\n */\n DeclaratorHelper.prototype.getTokenDeclaration = function (tokenRegistryContractName, declarator, tokenAddress, checkInterface) {\n if (checkInterface === void 0) { checkInterface = false; }\n return __awaiter(this, void 0, void 0, function () {\n var tokenRegistryContract, declarationParts;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, this.registry.getContractByName(tokenRegistryContractName, 'AddressDeclarator', [solidity_1.interfaceCodes.Declarator])];\n case 1:\n tokenRegistryContract = _a.sent();\n return [4 /*yield*/, tokenRegistryContract.methods.declaration(declarator, tokenAddress).call()];\n case 2:\n declarationParts = _a.sent();\n if (declarationParts.length == 1 && declarationParts[0] == const_1.zeroAddress) {\n throw new Error('no declarations found for declarator \"' + declarator + '\" address \"' + tokenAddress + '\"');\n }\n return [2 /*return*/, declarationParts];\n }\n });\n });\n };\n return DeclaratorHelper;\n}());\nexports.DeclaratorHelper = DeclaratorHelper;\n\n\n//# sourceURL=webpack://cic/./dist/helper.js?");
/***/ }),
/***/ "./dist/index.js":
/*!***********************!*\
!*** ./dist/index.js ***!
\***********************/
/*! flagged exports */
/*! export CICRegistry [provided] [maybe used in index (runtime-defined)] [usage prevents renaming] */
/*! export TransactionHelper [provided] [maybe used in index (runtime-defined)] [usage prevents renaming] */
/*! export __esModule [provided] [maybe used in index (runtime-defined)] [usage prevents renaming] */
/*! other exports [not provided] [maybe used in index (runtime-defined)] */
/*! runtime requirements: __webpack_exports__, __webpack_require__ */
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
"use strict";
eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.TransactionHelper = exports.CICRegistry = void 0;\nvar registry_1 = __webpack_require__(/*! ./registry */ \"./dist/registry.js\");\nObject.defineProperty(exports, \"CICRegistry\", ({ enumerable: true, get: function () { return registry_1.CICRegistry; } }));\nvar helper_1 = __webpack_require__(/*! ./helper */ \"./dist/helper.js\");\nObject.defineProperty(exports, \"TransactionHelper\", ({ enumerable: true, get: function () { return helper_1.TransactionHelper; } }));\n\n\n//# sourceURL=webpack://cic/./dist/index.js?");
/***/ }),
/***/ "./dist/registry.js":
/*!**************************!*\
!*** ./dist/registry.js ***!
\**************************/
/*! unknown exports (runtime-defined) */
/*! runtime requirements: top-level-this-exports, __webpack_exports__, __webpack_require__ */
/*! CommonJS bailout: this is used directly at 2:17-21 */
/*! CommonJS bailout: this is used directly at 11:19-23 */
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
eval("\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.toRegistryKey = exports.toContractKey = exports.CICRegistry = void 0;\nvar helper_1 = __webpack_require__(/*! ./helper */ \"./dist/helper.js\");\nvar LRU = __webpack_require__(/*! lru-cache */ \"./node_modules/lru-cache/index.js\");\nvar solidity_1 = __webpack_require__(/*! ./solidity */ \"./dist/solidity.js\");\nvar const_1 = __webpack_require__(/*! ./const */ \"./dist/const.js\");\nvar crypto_1 = __webpack_require__(/*! ./crypto */ \"./dist/crypto.js\");\nvar digest_1 = __webpack_require__(/*! ./digest */ \"./dist/digest.js\");\nvar KV = /** @class */ (function () {\n function KV() {\n this.store = {};\n }\n KV.prototype.put = function (k, v) {\n this.store[k] = v;\n };\n KV.prototype.get = function (k) {\n return this.store[k];\n };\n KV.prototype.peek = function (k) {\n return this.store[k];\n };\n return KV;\n}());\nvar CICRegistry = /** @class */ (function () {\n function CICRegistry(w3, address, abiName, fileGetter, paths) {\n this.w3 = w3;\n this.address = address;\n this.abiName = abiName;\n this.store = new KV();\n this.paths = paths;\n this.fileGetter = fileGetter;\n this.declaratorHelper = new helper_1.DeclaratorHelper(w3, this);\n }\n CICRegistry.prototype.load = function () {\n return __awaiter(this, void 0, void 0, function () {\n var registryAbi, contractIdHex, contractId, confirmedContractAddress;\n return __generator(this, function (_a) {\n switch (_a.label) {\n case 0: return [4 /*yield*/, solidity_1.abi(this.fileGetter, this.abiName, this.path