{"version":3,"sources":["webpack:///./node_modules/web3-core-promievent/lib/index.js","webpack:///./node_modules/web3-core-requestmanager/lib/index.js","webpack:///./node_modules/web3-core-requestmanager/lib/givenProvider.js","webpack:///./node_modules/web3-core-helpers/lib/errors.js","webpack:///./node_modules/web3-core-helpers/lib/formatters.js","webpack:///./node_modules/web3-core-method/lib/index.js","webpack:///./node_modules/web3-core-requestmanager/lib/batch.js","webpack:///./node_modules/web3-core-requestmanager/lib/jsonrpc.js","webpack:///./node_modules/web3-bzz/lib/index.js","webpack:///./node_modules/web3-core-subscriptions/lib/subscription.js","webpack:///./node_modules/web3-core-helpers/lib/index.js","webpack:///./node_modules/web3-core/lib/index.js","webpack:///./node_modules/web3-core/lib/extend.js","webpack:///./node_modules/web3-core-subscriptions/lib/index.js"],"names":["EventEmitter","r","PromiEvent","justPromise","resolve","reject","eventEmitter","Promise","arguments","emitter","_events","emit","on","once","off","listeners","addListener","removeListener","removeAllListeners","value","promise","module","exports","callbackify","errors","Jsonrpc","BatchManager","givenProvider","RequestManager","provider","net","this","providers","setProvider","subscriptions","Map","WebsocketProvider","HttpProvider","IpcProvider","prototype","_this","test","connect","Error","connected","clearSubscriptions","request","payload","type","data","subscription","has","get","callback","result","deprecatedResult","method","params","forEach","resubscribe","error","disconnect","event","_isCleanCloseEvent","_isIpcCloseError","ConnectionCloseError","delete","id","send","InvalidProvider","jsonrpcPayload","toPayload","jsonrpcResultCallback","_jsonrpcResultCallback","bind","callbackRequest","sendAsync","sendBatch","toBatchPayload","err","results","Array","isArray","InvalidResponse","addSubscription","constructor","name","set","removeSubscription","options","keepIsSyncing","size","reset","e","includes","code","wasClean","JSON","stringify","ErrorResponse","isValidResponse","Manager","global","globalThis","Function","self","ethereum","web3","currentProvider","connection","toString","parse","indexOf","message","InvalidNumberOfParams","got","expected","InvalidConnection","host","ConnectionError","ConnectionTimeout","ms","ConnectionNotOpenError","reason","MaxAttemptsReachedOnReconnectingError","PendingRequestsOnReconnectingError","msg","RevertInstructionError","signature","TransactionRevertInstructionError","receipt","TransactionError","NoContractAddressFoundError","ContractCodeNotStoredError","TransactionRevertedWithoutReasonError","TransactionOutOfGasError","ResolverMethodMissingError","address","ContractMissingABIError","ContractOnceRequiresCallbackError","ContractEventDoesNotExistError","eventName","ContractReservedEventError","ContractMissingDeployDataError","ContractNoAddressDefinedError","ContractNoFromAddressDefinedError","utils","Iban","outputBigNumberFormatter","number","toBN","inputBlockNumberFormatter","blockNumber","isPredefinedBlockNumber","isHexStrict","toLowerCase","numberToHex","_txInputFormatter","to","inputAddressFormatter","input","startsWith","isHex","gas","gasLimit","maxPriorityFeePerGas","maxFeePerGas","gasPrice","filter","key","outputTransactionFormatter","tx","hexToNumber","transactionIndex","nonce","isAddress","toChecksumAddress","from","outputLogFormatter","log","blockHash","transactionHash","logIndex","shaId","sha3","replace","substr","iban","isValid","isDirect","toAddress","inputDefaultBlockNumberFormatter","defaultBlock","inputCallFormatter","defaultAccount","inputTransactionFormatter","inputPostFormatter","post","ttl","workToProve","priority","topics","map","topic","fromUtf8","inputLogFormatter","toTopic","String","fromBlock","toBlock","addr","inputSignFormatter","utf8ToHex","inputStorageKeysFormatter","keys","outputProofFormatter","proof","hexToNumberString","balance","outputTransactionReceiptFormatter","cumulativeGasUsed","gasUsed","logs","effectiveGasPrice","contractAddress","status","Boolean","parseInt","outputBlockFormatter","block","timestamp","difficulty","totalDifficulty","transactions","item","miner","baseFeePerGas","outputPostFormatter","expiry","sent","workProved","toUtf8","outputSyncingFormatter","startingBlock","currentBlock","highestBlock","knownStates","pulledStates","formatters","promiEvent","Subscriptions","EthersTransactionUtils","Method","call","inputFormatter","outputFormatter","transformPayload","extraFormatters","abiCoder","requestManager","accounts","transactionBlockTimeout","transactionConfirmationBlocks","transactionPollingTimeout","transactionPollingInterval","blockHeaderTimeout","defaultCommon","defaultChain","defaultHardfork","handleRevert","setRequestManager","createFunction","func","buildCall","attachToObject","obj","split","length","getCall","args","extractCallback","pop","validateArgs","formatInput","formatter","index","formatOutput","res","_confirmTransaction","defer","promiseResolved","canUnsubscribe","timeoutCount","confirmationCount","intervalId","blockHeaderTimeoutId","lastBlock","gasProvided","isContractDeployment","hasBytecode","_ethereumCalls","val","subscriptionName","_ethereumCall","mthd","checkConfirmation","existingReceipt","isPolling","blockHeader","sub","unsubscribe","clearInterval","clearTimeout","getTransactionReceipt","catch","_fireError","then","receiptFormatter","latestBlock","getBlockByNumber","latestBlockHash","hash","getCode","deploymentSuccess","contractDeployFormatter","outOfGas","revertMessage","txReplayOptions","rawTransactionHex","parsedTx","toHexString","getRevertReason","startWatching","blockHeaderArrived","startInterval","setInterval","subscribe","setTimeout","getWallet","wallet","privateKey","_handleTxPricing","toHex","getGasPrice","all","responses","mul","add","isSendTx","isCall","slice","sendTxCallback","reasonData","isRevertReasonString","substring","decodeParameter","sendSignedTx","sign","signedPayload","rawTransaction","sendRequest","chain","hardfork","common","signTransaction","txPricing","txOptions","format","Batch","requests","push","execute","sortResponses","_sortResponses","sort","a","b","messageId","jsonrpc","response","every","validateSingleMessage","messages","swarm","Bzz","_requestManager","document","pick","bzz","noProviderError","download","upload","isAvailable","at","identity","Subscription","Object","create","_extractCallback","_validateArgs","_formatInput","formattedArgs","_formatOutput","_toPayload","subscriptionMethod","shift","concat","err1","err2","hasOwnProperty","isFinite","blockParams","assign","output","resultItem","subscriptionHandler","extend","packageInit","pkg","defineProperty","_provider","enumerable","configurable","manager","BatchRequest","addProviders","pckg","ex","extension","extendedObject","property","methods","rm","console","warn","apply"],"mappings":"oHAsBA,IAAIA,EAAeC,EAAQ,QAMvBC,EAAa,SAAoBC,GACjC,IAAIC,EAASC,EAAQC,EAAe,IAAIC,SAAQA,WAC5CH,EAAUI,UAAU,GACpBH,EAASG,UAAU,MAEvB,GAAIL,EACA,MAAO,CACHC,QAASA,EACTC,OAAQA,EACRC,aAAcA,GAItB,IAAIG,EAAU,IAAIT,EAWlB,OATAM,EAAaI,QAAUD,EAAQC,QAC/BJ,EAAaK,KAAOF,EAAQ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SAAQA,SAAUF,GAC1BA,aAAkBoM,IACpBpM,EAAS,IAAIoM,EAAOpM,IAExBA,EAAO0N,eAAe2J,GACtBrX,EAAOsN,kBAAkB4J,EAAKzC,oBAG/ByC,GAKX,OAHAC,EAAGnL,WAAaA,EAChBmL,EAAGzR,MAAQA,EACXyR,EAAG/K,OAASA,EACL+K,I,kCC9BX,IAAIhC,EAAe1Y,EAAQ,QACvByP,EAAgB,SAAuBjK,GACvC1D,KAAKuD,KAAOG,EAAQH,KACpBvD,KAAKiB,KAAOyC,EAAQzC,KACpBjB,KAAKG,cAAgBuD,EAAQvD,eAAiB,GAC9CH,KAAKoO,eAAiB,MAE1BT,EAAcnN,UAAUuO,kBAAoB,SAAUkK,GAClDjZ,KAAKoO,eAAiB6K,GAE1BtL,EAAcnN,UAAU2O,eAAiB,SAAUC,GAC/C,IAAIH,EAAOjP,KAAKkP,YACZ3L,EAAOvD,KAAKuD,KAAK8L,MAAM,KACvB9L,EAAK+L,OAAS,GACdF,EAAI7L,EAAK,IAAM6L,EAAI7L,EAAK,KAAO,GAC/B6L,EAAI7L,EAAK,IAAIA,EAAK,IAAM0L,GAGxBG,EAAI7L,EAAK,IAAM0L,GAGvBtB,EAAcnN,UAAU0O,UAAY,WAChC,IAAIzO,EAAQT,KACZ,OAAO,WACES,EAAMN,cAAc1B,UAAU,KAC/Bya,QAAQC,KAAK,gBAAkBjV,KAAKC,UAAU1F,UAAU,IAAM,uCAElE,IAAI0C,EAAe,IAAIyV,EAAa,CAChCzV,aAAcV,EAAMN,cAAc1B,UAAU,KAAO,GACnD2P,eAAgB3N,EAAM2N,eACtBnN,KAAMR,EAAMQ,OAEhB,OAAOE,EAAa8R,UAAUmG,MAAMjY,EAAc1C,aAG1Da,EAAOC,QAAU,CACbY,cAAewN,EACfxM,aAAcyV","file":"js/chunk-vendors~8f89ddd9.685aba26.js","sourcesContent":["/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n */\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2016\n */\n\"use strict\";\nvar EventEmitter = require('eventemitter3');\n/**\n * This function generates a defer promise and adds eventEmitter functionality to it\n *\n * @method eventifiedPromise\n */\nvar PromiEvent = function PromiEvent(justPromise) {\n var resolve, reject, eventEmitter = new Promise(function () {\n resolve = arguments[0];\n reject = arguments[1];\n });\n if (justPromise) {\n return {\n resolve: resolve,\n reject: reject,\n eventEmitter: eventEmitter\n };\n }\n // get eventEmitter\n var emitter = new EventEmitter();\n // add eventEmitter to the promise\n eventEmitter._events = emitter._events;\n eventEmitter.emit = emitter.emit;\n eventEmitter.on = emitter.on;\n eventEmitter.once = emitter.once;\n eventEmitter.off = emitter.off;\n eventEmitter.listeners = emitter.listeners;\n eventEmitter.addListener = emitter.addListener;\n eventEmitter.removeListener = emitter.removeListener;\n eventEmitter.removeAllListeners = emitter.removeAllListeners;\n return {\n resolve: resolve,\n reject: reject,\n eventEmitter: eventEmitter\n };\n};\nPromiEvent.resolve = function (value) {\n var promise = PromiEvent(true);\n promise.resolve(value);\n return promise.eventEmitter;\n};\nmodule.exports = PromiEvent;\n","/*\n This file is part of web3.js.\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nconst { callbackify } = require('util');\nvar errors = require('web3-core-helpers').errors;\nvar Jsonrpc = require('./jsonrpc.js');\nvar BatchManager = require('./batch.js');\nvar givenProvider = require('./givenProvider.js');\n/**\n * It's responsible for passing messages to providers\n * It's also responsible for polling the ethereum node for incoming messages\n * Default poll timeout is 1 second\n * Singleton\n *\n * @param {string|Object}provider\n * @param {Net.Socket} net\n *\n * @constructor\n */\nvar RequestManager = function RequestManager(provider, net) {\n this.provider = null;\n this.providers = RequestManager.providers;\n this.setProvider(provider, net);\n this.subscriptions = new Map();\n};\nRequestManager.givenProvider = givenProvider;\nRequestManager.providers = {\n WebsocketProvider: require('web3-providers-ws'),\n HttpProvider: require('web3-providers-http'),\n IpcProvider: require('web3-providers-ipc')\n};\n/**\n * Should be used to set provider of request manager\n *\n * @method setProvider\n *\n * @param {Object} provider\n * @param {net.Socket} net\n *\n * @returns void\n */\nRequestManager.prototype.setProvider = function (provider, net) {\n var _this = this;\n // autodetect provider\n if (provider && typeof provider === 'string' && this.providers) {\n // HTTP\n if (/^http(s)?:\\/\\//i.test(provider)) {\n provider = new this.providers.HttpProvider(provider);\n // WS\n }\n else if (/^ws(s)?:\\/\\//i.test(provider)) {\n provider = new this.providers.WebsocketProvider(provider);\n // IPC\n }\n else if (provider && typeof net === 'object' && typeof net.connect === 'function') {\n provider = new this.providers.IpcProvider(provider, net);\n }\n else if (provider) {\n throw new Error('Can\\'t autodetect provider for \"' + provider + '\"');\n }\n }\n // reset the old one before changing, if still connected\n if (this.provider && this.provider.connected)\n this.clearSubscriptions();\n this.provider = provider || null;\n // listen to incoming notifications\n if (this.provider && this.provider.on) {\n if (typeof provider.request === 'function') { // EIP-1193 provider\n this.provider.on('message', function (payload) {\n if (payload && payload.type === 'eth_subscription' && payload.data) {\n const data = payload.data;\n if (data.subscription && _this.subscriptions.has(data.subscription)) {\n _this.subscriptions.get(data.subscription).callback(null, data.result);\n }\n }\n });\n }\n else { // legacy provider subscription event\n this.provider.on('data', function data(result, deprecatedResult) {\n result = result || deprecatedResult; // this is for possible old providers, which may had the error first handler\n // if result is a subscription, call callback for that subscription\n if (result.method && result.params && result.params.subscription && _this.subscriptions.has(result.params.subscription)) {\n _this.subscriptions.get(result.params.subscription).callback(null, result.params.result);\n }\n });\n }\n // resubscribe if the provider has reconnected\n this.provider.on('connect', function connect() {\n _this.subscriptions.forEach(function (subscription) {\n subscription.subscription.resubscribe();\n });\n });\n // notify all subscriptions about the error condition\n this.provider.on('error', function error(error) {\n _this.subscriptions.forEach(function (subscription) {\n subscription.callback(error);\n });\n });\n // notify all subscriptions about bad close conditions\n const disconnect = function disconnect(event) {\n if (!_this._isCleanCloseEvent(event) || _this._isIpcCloseError(event)) {\n _this.subscriptions.forEach(function (subscription) {\n subscription.callback(errors.ConnectionCloseError(event));\n _this.subscriptions.delete(subscription.subscription.id);\n });\n if (_this.provider && _this.provider.emit) {\n _this.provider.emit('error', errors.ConnectionCloseError(event));\n }\n }\n if (_this.provider && _this.provider.emit) {\n _this.provider.emit('end', event);\n }\n };\n this.provider.on('disconnect', disconnect);\n // TODO add end, timeout??\n }\n};\n/**\n * Asynchronously send request to provider.\n * Prefers to use the `request` method available on the provider as specified in [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193).\n * If `request` is not available, falls back to `sendAsync` and `send` respectively.\n * @method send\n * @param {Object} data\n * @param {Function} callback\n */\nRequestManager.prototype.send = function (data, callback) {\n callback = callback || function () { };\n if (!this.provider) {\n return callback(errors.InvalidProvider());\n }\n const { method, params } = data;\n const jsonrpcPayload = Jsonrpc.toPayload(method, params);\n const jsonrpcResultCallback = this._jsonrpcResultCallback(callback, jsonrpcPayload);\n if (this.provider.request) {\n const callbackRequest = callbackify(this.provider.request.bind(this.provider));\n const requestArgs = { method, params };\n callbackRequest(requestArgs, callback);\n }\n else if (this.provider.sendAsync) {\n this.provider.sendAsync(jsonrpcPayload, jsonrpcResultCallback);\n }\n else if (this.provider.send) {\n this.provider.send(jsonrpcPayload, jsonrpcResultCallback);\n }\n else {\n throw new Error('Provider does not have a request or send method to use.');\n }\n};\n/**\n * Asynchronously send batch request.\n * Only works if provider supports batch methods through `sendAsync` or `send`.\n * @method sendBatch\n * @param {Array} data - array of payload objects\n * @param {Function} callback\n */\nRequestManager.prototype.sendBatch = function (data, callback) {\n if (!this.provider) {\n return callback(errors.InvalidProvider());\n }\n var payload = Jsonrpc.toBatchPayload(data);\n this.provider[this.provider.sendAsync ? 'sendAsync' : 'send'](payload, function (err, results) {\n if (err) {\n return callback(err);\n }\n if (!Array.isArray(results)) {\n return callback(errors.InvalidResponse(results));\n }\n callback(null, results);\n });\n};\n/**\n * Waits for notifications\n *\n * @method addSubscription\n * @param {Subscription} subscription the subscription\n * @param {String} type the subscription namespace (eth, personal, etc)\n * @param {Function} callback the callback to call for incoming notifications\n */\nRequestManager.prototype.addSubscription = function (subscription, callback) {\n if (this.provider.on) {\n this.subscriptions.set(subscription.id, {\n callback: callback,\n subscription: subscription\n });\n }\n else {\n throw new Error('The provider doesn\\'t support subscriptions: ' + this.provider.constructor.name);\n }\n};\n/**\n * Waits for notifications\n *\n * @method removeSubscription\n * @param {String} id the subscription id\n * @param {Function} callback fired once the subscription is removed\n */\nRequestManager.prototype.removeSubscription = function (id, callback) {\n if (this.subscriptions.has(id)) {\n var type = this.subscriptions.get(id).subscription.options.type;\n // remove subscription first to avoid reentry\n this.subscriptions.delete(id);\n // then, try to actually unsubscribe\n this.send({\n method: type + '_unsubscribe',\n params: [id]\n }, callback);\n return;\n }\n if (typeof callback === 'function') {\n // call the callback if the subscription was already removed\n callback(null);\n }\n};\n/**\n * Should be called to reset the subscriptions\n *\n * @method reset\n *\n * @returns {boolean}\n */\nRequestManager.prototype.clearSubscriptions = function (keepIsSyncing) {\n try {\n var _this = this;\n // uninstall all subscriptions\n if (this.subscriptions.size > 0) {\n this.subscriptions.forEach(function (value, id) {\n if (!keepIsSyncing || value.name !== 'syncing')\n _this.removeSubscription(id);\n });\n }\n // reset notification callbacks etc.\n if (this.provider.reset)\n this.provider.reset();\n return true;\n }\n catch (e) {\n throw new Error(`Error while clearing subscriptions: ${e}`);\n }\n};\n/**\n * Evaluates WS close event\n *\n * @method _isCleanClose\n *\n * @param {CloseEvent | boolean} event WS close event or exception flag\n *\n * @returns {boolean}\n */\nRequestManager.prototype._isCleanCloseEvent = function (event) {\n return typeof event === 'object' && ([1000].includes(event.code) || event.wasClean === true);\n};\n/**\n * Detects Ipc close error. The node.net module emits ('close', isException)\n *\n * @method _isIpcCloseError\n *\n * @param {CloseEvent | boolean} event WS close event or exception flag\n *\n * @returns {boolean}\n */\nRequestManager.prototype._isIpcCloseError = function (event) {\n return typeof event === 'boolean' && event;\n};\n/**\n * The jsonrpc result callback for RequestManager.send\n *\n * @method _jsonrpcResultCallback\n *\n * @param {Function} callback the callback to use\n * @param {Object} payload the jsonrpc payload\n *\n * @returns {Function} return callback of form (err, result)\n *\n */\nRequestManager.prototype._jsonrpcResultCallback = function (callback, payload) {\n return function (err, result) {\n if (result && result.id && payload.id !== result.id) {\n return callback(new Error(`Wrong response id ${result.id} (expected: ${payload.id}) in ${JSON.stringify(payload)}`));\n }\n if (err) {\n return callback(err);\n }\n if (result && result.error) {\n return callback(errors.ErrorResponse(result));\n }\n if (!Jsonrpc.isValidResponse(result)) {\n return callback(errors.InvalidResponse(result));\n }\n callback(null, result.result);\n };\n};\nmodule.exports = {\n Manager: RequestManager,\n BatchManager: BatchManager\n};\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n */\n/**\n * @file givenProvider.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar givenProvider = null;\n// ADD GIVEN PROVIDER\n/* jshint ignore:start */\nvar global = typeof globalThis === 'object' ? globalThis : undefined;\nif (!global) {\n try {\n global = Function('return this')();\n }\n catch (e) {\n global = self;\n }\n}\n// EIP-1193: window.ethereum\nif (typeof global.ethereum !== 'undefined') {\n givenProvider = global.ethereum;\n // Legacy web3.currentProvider\n}\nelse if (typeof global.web3 !== 'undefined' && global.web3.currentProvider) {\n if (global.web3.currentProvider.sendAsync) {\n global.web3.currentProvider.send = global.web3.currentProvider.sendAsync;\n delete global.web3.currentProvider.sendAsync;\n }\n // if connection is 'ipcProviderWrapper', add subscription support\n if (!global.web3.currentProvider.on &&\n global.web3.currentProvider.connection &&\n global.web3.currentProvider.connection.constructor.name === 'ipcProviderWrapper') {\n global.web3.currentProvider.on = function (type, callback) {\n if (typeof callback !== 'function')\n throw new Error('The second parameter callback must be a function.');\n switch (type) {\n case 'data':\n this.connection.on('data', function (data) {\n var result = '';\n data = data.toString();\n try {\n result = JSON.parse(data);\n }\n catch (e) {\n return callback(new Error('Couldn\\'t parse response data' + data));\n }\n // notification\n if (!result.id && result.method.indexOf('_subscription') !== -1) {\n callback(null, result);\n }\n });\n break;\n default:\n this.connection.on(type, callback);\n break;\n }\n };\n }\n givenProvider = global.web3.currentProvider;\n}\n/* jshint ignore:end */\nmodule.exports = givenProvider;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file errors.js\n * @author Fabian Vogelsteller \n * @author Marek Kotewicz \n * @date 2017\n */\n\"use strict\";\nmodule.exports = {\n ErrorResponse: function (result) {\n var message = !!result && !!result.error && !!result.error.message ? result.error.message : JSON.stringify(result);\n var data = (!!result.error && !!result.error.data) ? result.error.data : null;\n var err = new Error('Returned error: ' + message);\n err.data = data;\n return err;\n },\n InvalidNumberOfParams: function (got, expected, method) {\n return new Error('Invalid number of parameters for \"' + method + '\". Got ' + got + ' expected ' + expected + '!');\n },\n InvalidConnection: function (host, event) {\n return this.ConnectionError('CONNECTION ERROR: Couldn\\'t connect to node ' + host + '.', event);\n },\n InvalidProvider: function () {\n return new Error('Provider not set or invalid');\n },\n InvalidResponse: function (result) {\n var message = !!result && !!result.error && !!result.error.message ? result.error.message : 'Invalid JSON RPC response: ' + JSON.stringify(result);\n return new Error(message);\n },\n ConnectionTimeout: function (ms) {\n return new Error('CONNECTION TIMEOUT: timeout of ' + ms + ' ms achived');\n },\n ConnectionNotOpenError: function (event) {\n return this.ConnectionError('connection not open on send()', event);\n },\n ConnectionCloseError: function (event) {\n if (typeof event === 'object' && event.code && event.reason) {\n return this.ConnectionError('CONNECTION ERROR: The connection got closed with ' +\n 'the close code `' + event.code + '` and the following ' +\n 'reason string `' + event.reason + '`', event);\n }\n return new Error('CONNECTION ERROR: The connection closed unexpectedly');\n },\n MaxAttemptsReachedOnReconnectingError: function () {\n return new Error('Maximum number of reconnect attempts reached!');\n },\n PendingRequestsOnReconnectingError: function () {\n return new Error('CONNECTION ERROR: Provider started to reconnect before the response got received!');\n },\n ConnectionError: function (msg, event) {\n const error = new Error(msg);\n if (event) {\n error.code = event.code;\n error.reason = event.reason;\n }\n return error;\n },\n RevertInstructionError: function (reason, signature) {\n var error = new Error('Your request got reverted with the following reason string: ' + reason);\n error.reason = reason;\n error.signature = signature;\n return error;\n },\n TransactionRevertInstructionError: function (reason, signature, receipt) {\n var error = new Error('Transaction has been reverted by the EVM:\\n' + JSON.stringify(receipt, null, 2));\n error.reason = reason;\n error.signature = signature;\n error.receipt = receipt;\n return error;\n },\n TransactionError: function (message, receipt) {\n var error = new Error(message);\n error.receipt = receipt;\n return error;\n },\n NoContractAddressFoundError: function (receipt) {\n return this.TransactionError('The transaction receipt didn\\'t contain a contract address.', receipt);\n },\n ContractCodeNotStoredError: function (receipt) {\n return this.TransactionError('The contract code couldn\\'t be stored, please check your gas limit.', receipt);\n },\n TransactionRevertedWithoutReasonError: function (receipt) {\n return this.TransactionError('Transaction has been reverted by the EVM:\\n' + JSON.stringify(receipt, null, 2), receipt);\n },\n TransactionOutOfGasError: function (receipt) {\n return this.TransactionError('Transaction ran out of gas. Please provide more gas:\\n' + JSON.stringify(receipt, null, 2), receipt);\n },\n ResolverMethodMissingError: function (address, name) {\n return new Error('The resolver at ' + address + 'does not implement requested method: \"' + name + '\".');\n },\n ContractMissingABIError: function () {\n return new Error('You must provide the json interface of the contract when instantiating a contract object.');\n },\n ContractOnceRequiresCallbackError: function () {\n return new Error('Once requires a callback as the second parameter.');\n },\n ContractEventDoesNotExistError: function (eventName) {\n return new Error('Event \"' + eventName + '\" doesn\\'t exist in this contract.');\n },\n ContractReservedEventError: function (type) {\n return new Error('The event \"' + type + '\" is a reserved event name, you can\\'t use it.');\n },\n ContractMissingDeployDataError: function () {\n return new Error('No \"data\" specified in neither the given options, nor the default options.');\n },\n ContractNoAddressDefinedError: function () {\n return new Error('This contract object doesn\\'t have address set yet, please set an address first.');\n },\n ContractNoFromAddressDefinedError: function () {\n return new Error('No \"from\" address specified in neither the given options, nor the default options.');\n }\n};\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file formatters.js\n * @author Fabian Vogelsteller \n * @author Marek Kotewicz \n * @date 2017\n */\n\"use strict\";\nvar utils = require('web3-utils');\nvar Iban = require('web3-eth-iban');\n/**\n * Will format the given storage key array values to hex strings.\n *\n * @method inputStorageKeysFormatter\n *\n * @param {Array} keys\n *\n * @returns {Array}\n */\nvar inputStorageKeysFormatter = function (keys) {\n return keys.map(utils.numberToHex);\n};\n/**\n * Will format the given proof response from the node.\n *\n * @method outputProofFormatter\n *\n * @param {object} proof\n *\n * @returns {object}\n */\nvar outputProofFormatter = function (proof) {\n proof.address = utils.toChecksumAddress(proof.address);\n proof.nonce = utils.hexToNumberString(proof.nonce);\n proof.balance = utils.hexToNumberString(proof.balance);\n return proof;\n};\n/**\n * Should the format output to a big number\n *\n * @method outputBigNumberFormatter\n *\n * @param {String|Number|BigNumber|BN} number\n *\n * @returns {BN} object\n */\nvar outputBigNumberFormatter = function (number) {\n return utils.toBN(number).toString(10);\n};\n/**\n * Returns true if the given blockNumber is 'latest', 'pending', or 'earliest.\n *\n * @method isPredefinedBlockNumber\n *\n * @param {String} blockNumber\n *\n * @returns {Boolean}\n */\nvar isPredefinedBlockNumber = function (blockNumber) {\n return blockNumber === 'latest' || blockNumber === 'pending' || blockNumber === 'earliest';\n};\n/**\n * Returns the given block number as hex string or does return the defaultBlock property of the current module\n *\n * @method inputDefaultBlockNumberFormatter\n *\n * @param {String|Number|BN|BigNumber} blockNumber\n *\n * @returns {String}\n */\nvar inputDefaultBlockNumberFormatter = function (blockNumber) {\n if (this && (blockNumber === undefined || blockNumber === null)) {\n return inputBlockNumberFormatter(this.defaultBlock);\n }\n return inputBlockNumberFormatter(blockNumber);\n};\n/**\n * Returns the given block number as hex string or the predefined block number 'latest', 'pending', 'earliest', 'genesis'\n *\n * @param {String|Number|BN|BigNumber} blockNumber\n *\n * @returns {String}\n */\nvar inputBlockNumberFormatter = function (blockNumber) {\n if (blockNumber === undefined) {\n return undefined;\n }\n if (isPredefinedBlockNumber(blockNumber)) {\n return blockNumber;\n }\n if (blockNumber === 'genesis') {\n return '0x0';\n }\n return (utils.isHexStrict(blockNumber)) ? ((typeof blockNumber === 'string') ? blockNumber.toLowerCase() : blockNumber) : utils.numberToHex(blockNumber);\n};\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method _txInputFormatter\n * @param {Object} transaction options\n * @returns object\n */\nvar _txInputFormatter = function (options) {\n if (options.to) { // it might be contract creation\n options.to = inputAddressFormatter(options.to);\n }\n if (options.data && options.input) {\n throw new Error('You can\\'t have \"data\" and \"input\" as properties of transactions at the same time, please use either \"data\" or \"input\" instead.');\n }\n if (!options.data && options.input) {\n options.data = options.input;\n delete options.input;\n }\n if (options.data && !options.data.startsWith('0x')) {\n options.data = '0x' + options.data;\n }\n if (options.data && !utils.isHex(options.data)) {\n throw new Error('The data field must be HEX encoded data.');\n }\n // allow both\n if (options.gas || options.gasLimit) {\n options.gas = options.gas || options.gasLimit;\n }\n if (options.maxPriorityFeePerGas || options.maxFeePerGas) {\n delete options.gasPrice;\n }\n ['gasPrice', 'gas', 'value', 'maxPriorityFeePerGas', 'maxFeePerGas', 'nonce'].filter(function (key) {\n return options[key] !== undefined;\n }).forEach(function (key) {\n options[key] = utils.numberToHex(options[key]);\n });\n return options;\n};\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method inputCallFormatter\n * @param {Object} transaction options\n * @returns object\n */\nvar inputCallFormatter = function (options) {\n options = _txInputFormatter(options);\n var from = options.from || (this ? this.defaultAccount : null);\n if (from) {\n options.from = inputAddressFormatter(from);\n }\n return options;\n};\n/**\n * Formats the input of a transaction and converts all values to HEX\n *\n * @method inputTransactionFormatter\n * @param {Object} options\n * @returns object\n */\nvar inputTransactionFormatter = function (options) {\n options = _txInputFormatter(options);\n // check from, only if not number, or object\n if (!(typeof options.from === 'number') && !(!!options.from && typeof options.from === 'object')) {\n options.from = options.from || (this ? this.defaultAccount : null);\n if (!options.from && !(typeof options.from === 'number')) {\n throw new Error('The send transactions \"from\" field must be defined!');\n }\n options.from = inputAddressFormatter(options.from);\n }\n return options;\n};\n/**\n * Hex encodes the data passed to eth_sign and personal_sign\n *\n * @method inputSignFormatter\n * @param {String} data\n * @returns {String}\n */\nvar inputSignFormatter = function (data) {\n return (utils.isHexStrict(data)) ? data : utils.utf8ToHex(data);\n};\n/**\n * Formats the output of a transaction to its proper values\n *\n * @method outputTransactionFormatter\n * @param {Object} tx\n * @returns {Object}\n */\nvar outputTransactionFormatter = function (tx) {\n if (tx.blockNumber !== null)\n tx.blockNumber = utils.hexToNumber(tx.blockNumber);\n if (tx.transactionIndex !== null)\n tx.transactionIndex = utils.hexToNumber(tx.transactionIndex);\n tx.nonce = utils.hexToNumber(tx.nonce);\n tx.gas = utils.hexToNumber(tx.gas);\n if (tx.gasPrice)\n tx.gasPrice = outputBigNumberFormatter(tx.gasPrice);\n if (tx.maxFeePerGas)\n tx.maxFeePerGas = outputBigNumberFormatter(tx.maxFeePerGas);\n if (tx.maxPriorityFeePerGas)\n tx.maxPriorityFeePerGas = outputBigNumberFormatter(tx.maxPriorityFeePerGas);\n if (tx.type)\n tx.type = utils.hexToNumber(tx.type);\n tx.value = outputBigNumberFormatter(tx.value);\n if (tx.to && utils.isAddress(tx.to)) { // tx.to could be `0x0` or `null` while contract creation\n tx.to = utils.toChecksumAddress(tx.to);\n }\n else {\n tx.to = null; // set to `null` if invalid address\n }\n if (tx.from) {\n tx.from = utils.toChecksumAddress(tx.from);\n }\n return tx;\n};\n/**\n * Formats the output of a transaction receipt to its proper values\n *\n * @method outputTransactionReceiptFormatter\n * @param {Object} receipt\n * @returns {Object}\n */\nvar outputTransactionReceiptFormatter = function (receipt) {\n if (typeof receipt !== 'object') {\n throw new Error('Received receipt is invalid: ' + receipt);\n }\n if (receipt.blockNumber !== null)\n receipt.blockNumber = utils.hexToNumber(receipt.blockNumber);\n if (receipt.transactionIndex !== null)\n receipt.transactionIndex = utils.hexToNumber(receipt.transactionIndex);\n receipt.cumulativeGasUsed = utils.hexToNumber(receipt.cumulativeGasUsed);\n receipt.gasUsed = utils.hexToNumber(receipt.gasUsed);\n if (Array.isArray(receipt.logs)) {\n receipt.logs = receipt.logs.map(outputLogFormatter);\n }\n if (receipt.effectiveGasPrice) {\n receipt.effectiveGasPrice = utils.hexToNumber(receipt.effectiveGasPrice);\n }\n if (receipt.contractAddress) {\n receipt.contractAddress = utils.toChecksumAddress(receipt.contractAddress);\n }\n if (typeof receipt.status !== 'undefined' && receipt.status !== null) {\n receipt.status = Boolean(parseInt(receipt.status));\n }\n return receipt;\n};\n/**\n * Formats the output of a block to its proper values\n *\n * @method outputBlockFormatter\n * @param {Object} block\n * @returns {Object}\n */\nvar outputBlockFormatter = function (block) {\n // transform to number\n block.gasLimit = utils.hexToNumber(block.gasLimit);\n block.gasUsed = utils.hexToNumber(block.gasUsed);\n block.size = utils.hexToNumber(block.size);\n block.timestamp = utils.hexToNumber(block.timestamp);\n if (block.number !== null)\n block.number = utils.hexToNumber(block.number);\n if (block.difficulty)\n block.difficulty = outputBigNumberFormatter(block.difficulty);\n if (block.totalDifficulty)\n block.totalDifficulty = outputBigNumberFormatter(block.totalDifficulty);\n if (Array.isArray(block.transactions)) {\n block.transactions.forEach(function (item) {\n if (!(typeof item === 'string'))\n return outputTransactionFormatter(item);\n });\n }\n if (block.miner)\n block.miner = utils.toChecksumAddress(block.miner);\n if (block.baseFeePerGas)\n block.baseFeePerGas = utils.hexToNumber(block.baseFeePerGas);\n return block;\n};\n/**\n * Formats the input of a log\n *\n * @method inputLogFormatter\n * @param {Object} log object\n * @returns {Object} log\n */\nvar inputLogFormatter = function (options) {\n var toTopic = function (value) {\n if (value === null || typeof value === 'undefined')\n return null;\n value = String(value);\n if (value.indexOf('0x') === 0)\n return value;\n else\n return utils.fromUtf8(value);\n };\n if (options === undefined)\n options = {};\n // If options !== undefined, don't blow out existing data\n if (options.fromBlock === undefined)\n options = { ...options, fromBlock: 'latest' };\n if (options.fromBlock || options.fromBlock === 0)\n options.fromBlock = inputBlockNumberFormatter(options.fromBlock);\n if (options.toBlock || options.toBlock === 0)\n options.toBlock = inputBlockNumberFormatter(options.toBlock);\n // make sure topics, get converted to hex\n options.topics = options.topics || [];\n options.topics = options.topics.map(function (topic) {\n return (Array.isArray(topic)) ? topic.map(toTopic) : toTopic(topic);\n });\n toTopic = null;\n if (options.address) {\n options.address = (Array.isArray(options.address)) ? options.address.map(function (addr) {\n return inputAddressFormatter(addr);\n }) : inputAddressFormatter(options.address);\n }\n return options;\n};\n/**\n * Formats the output of a log\n *\n * @method outputLogFormatter\n * @param {Object} log object\n * @returns {Object} log\n */\nvar outputLogFormatter = function (log) {\n // generate a custom log id\n if (typeof log.blockHash === 'string' &&\n typeof log.transactionHash === 'string' &&\n typeof log.logIndex === 'string') {\n var shaId = utils.sha3(log.blockHash.replace('0x', '') + log.transactionHash.replace('0x', '') + log.logIndex.replace('0x', ''));\n log.id = 'log_' + shaId.replace('0x', '').substr(0, 8);\n }\n else if (!log.id) {\n log.id = null;\n }\n if (log.blockNumber !== null)\n log.blockNumber = utils.hexToNumber(log.blockNumber);\n if (log.transactionIndex !== null)\n log.transactionIndex = utils.hexToNumber(log.transactionIndex);\n if (log.logIndex !== null)\n log.logIndex = utils.hexToNumber(log.logIndex);\n if (log.address) {\n log.address = utils.toChecksumAddress(log.address);\n }\n return log;\n};\n/**\n * Formats the input of a whisper post and converts all values to HEX\n *\n * @method inputPostFormatter\n * @param {Object} transaction object\n * @returns {Object}\n */\nvar inputPostFormatter = function (post) {\n // post.payload = utils.toHex(post.payload);\n if (post.ttl)\n post.ttl = utils.numberToHex(post.ttl);\n if (post.workToProve)\n post.workToProve = utils.numberToHex(post.workToProve);\n if (post.priority)\n post.priority = utils.numberToHex(post.priority);\n // fallback\n if (!Array.isArray(post.topics)) {\n post.topics = post.topics ? [post.topics] : [];\n }\n // format the following options\n post.topics = post.topics.map(function (topic) {\n // convert only if not hex\n return (topic.indexOf('0x') === 0) ? topic : utils.fromUtf8(topic);\n });\n return post;\n};\n/**\n * Formats the output of a received post message\n *\n * @method outputPostFormatter\n * @param {Object}\n * @returns {Object}\n */\nvar outputPostFormatter = function (post) {\n post.expiry = utils.hexToNumber(post.expiry);\n post.sent = utils.hexToNumber(post.sent);\n post.ttl = utils.hexToNumber(post.ttl);\n post.workProved = utils.hexToNumber(post.workProved);\n // post.payloadRaw = post.payload;\n // post.payload = utils.hexToAscii(post.payload);\n // if (utils.isJson(post.payload)) {\n // post.payload = JSON.parse(post.payload);\n // }\n // format the following options\n if (!post.topics) {\n post.topics = [];\n }\n post.topics = post.topics.map(function (topic) {\n return utils.toUtf8(topic);\n });\n return post;\n};\nvar inputAddressFormatter = function (address) {\n var iban = new Iban(address);\n if (iban.isValid() && iban.isDirect()) {\n return iban.toAddress().toLowerCase();\n }\n else if (utils.isAddress(address)) {\n return '0x' + address.toLowerCase().replace('0x', '');\n }\n throw new Error(`Provided address ${address} is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.`);\n};\nvar outputSyncingFormatter = function (result) {\n result.startingBlock = utils.hexToNumber(result.startingBlock);\n result.currentBlock = utils.hexToNumber(result.currentBlock);\n result.highestBlock = utils.hexToNumber(result.highestBlock);\n if (result.knownStates) {\n result.knownStates = utils.hexToNumber(result.knownStates);\n result.pulledStates = utils.hexToNumber(result.pulledStates);\n }\n return result;\n};\nmodule.exports = {\n inputDefaultBlockNumberFormatter: inputDefaultBlockNumberFormatter,\n inputBlockNumberFormatter: inputBlockNumberFormatter,\n inputCallFormatter: inputCallFormatter,\n inputTransactionFormatter: inputTransactionFormatter,\n inputAddressFormatter: inputAddressFormatter,\n inputPostFormatter: inputPostFormatter,\n inputLogFormatter: inputLogFormatter,\n inputSignFormatter: inputSignFormatter,\n inputStorageKeysFormatter: inputStorageKeysFormatter,\n outputProofFormatter: outputProofFormatter,\n outputBigNumberFormatter: outputBigNumberFormatter,\n outputTransactionFormatter: outputTransactionFormatter,\n outputTransactionReceiptFormatter: outputTransactionReceiptFormatter,\n outputBlockFormatter: outputBlockFormatter,\n outputLogFormatter: outputLogFormatter,\n outputPostFormatter: outputPostFormatter,\n outputSyncingFormatter: outputSyncingFormatter\n};\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @author Marek Kotewicz \n * @date 2017\n */\n'use strict';\nvar errors = require('web3-core-helpers').errors;\nvar formatters = require('web3-core-helpers').formatters;\nvar utils = require('web3-utils');\nvar promiEvent = require('web3-core-promievent');\nvar Subscriptions = require('web3-core-subscriptions').subscriptions;\nvar EthersTransactionUtils = require('@ethersproject/transactions');\nvar Method = function Method(options) {\n if (!options.call || !options.name) {\n throw new Error('When creating a method you need to provide at least the \"name\" and \"call\" property.');\n }\n this.name = options.name;\n this.call = options.call;\n this.params = options.params || 0;\n this.inputFormatter = options.inputFormatter;\n this.outputFormatter = options.outputFormatter;\n this.transformPayload = options.transformPayload;\n this.extraFormatters = options.extraFormatters;\n this.abiCoder = options.abiCoder; // Will be used to encode the revert reason string\n this.requestManager = options.requestManager;\n // reference to eth.accounts\n this.accounts = options.accounts;\n this.defaultBlock = options.defaultBlock || 'latest';\n this.defaultAccount = options.defaultAccount || null;\n this.transactionBlockTimeout = options.transactionBlockTimeout || 50;\n this.transactionConfirmationBlocks = options.transactionConfirmationBlocks || 24;\n this.transactionPollingTimeout = options.transactionPollingTimeout || 750;\n this.transactionPollingInterval = options.transactionPollingInterval || 1000;\n this.blockHeaderTimeout = options.blockHeaderTimeout || 10; // 10 seconds\n this.defaultCommon = options.defaultCommon;\n this.defaultChain = options.defaultChain;\n this.defaultHardfork = options.defaultHardfork;\n this.handleRevert = options.handleRevert;\n};\nMethod.prototype.setRequestManager = function (requestManager, accounts) {\n this.requestManager = requestManager;\n // reference to eth.accounts\n if (accounts) {\n this.accounts = accounts;\n }\n};\nMethod.prototype.createFunction = function (requestManager, accounts) {\n var func = this.buildCall();\n func.call = this.call;\n this.setRequestManager(requestManager || this.requestManager, accounts || this.accounts);\n return func;\n};\nMethod.prototype.attachToObject = function (obj) {\n var func = this.buildCall();\n func.call = this.call;\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n obj[name[0]][name[1]] = func;\n }\n else {\n obj[name[0]] = func;\n }\n};\n/**\n * Should be used to determine name of the jsonrpc method based on arguments\n *\n * @method getCall\n * @param {Array} arguments\n * @return {String} name of jsonrpc method\n */\nMethod.prototype.getCall = function (args) {\n return typeof this.call === 'function' ? this.call(args) : this.call;\n};\n/**\n * Should be used to extract callback from array of arguments. Modifies input param\n *\n * @method extractCallback\n * @param {Array} arguments\n * @return {Function|Null} callback, if exists\n */\nMethod.prototype.extractCallback = function (args) {\n if (typeof (args[args.length - 1]) === 'function') {\n return args.pop(); // modify the args array!\n }\n};\n/**\n * Should be called to check if the number of arguments is correct\n *\n * @method validateArgs\n * @param {Array} arguments\n * @throws {Error} if it is not\n */\nMethod.prototype.validateArgs = function (args) {\n if (args.length !== this.params) {\n throw errors.InvalidNumberOfParams(args.length, this.params, this.name);\n }\n};\n/**\n * Should be called to format input args of method\n *\n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nMethod.prototype.formatInput = function (args) {\n var _this = this;\n if (!this.inputFormatter) {\n return args;\n }\n return this.inputFormatter.map(function (formatter, index) {\n // bind this for defaultBlock, and defaultAccount\n return formatter ? formatter.call(_this, args[index]) : args[index];\n });\n};\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param {Object}\n * @return {Object}\n */\nMethod.prototype.formatOutput = function (result) {\n var _this = this;\n if (Array.isArray(result)) {\n return result.map(function (res) {\n return _this.outputFormatter && res ? _this.outputFormatter(res) : res;\n });\n }\n else {\n return this.outputFormatter && result ? this.outputFormatter(result) : result;\n }\n};\n/**\n * Should create payload from given input args\n *\n * @method toPayload\n * @param {Array} args\n * @return {Object}\n */\nMethod.prototype.toPayload = function (args) {\n var call = this.getCall(args);\n var callback = this.extractCallback(args);\n var params = this.formatInput(args);\n this.validateArgs(params);\n var payload = {\n method: call,\n params: params,\n callback: callback\n };\n if (this.transformPayload) {\n payload = this.transformPayload(payload);\n }\n return payload;\n};\nMethod.prototype._confirmTransaction = function (defer, result, payload) {\n var method = this, promiseResolved = false, canUnsubscribe = true, timeoutCount = 0, confirmationCount = 0, intervalId = null, blockHeaderTimeoutId = null, lastBlock = null, receiptJSON = '', gasProvided = ((!!payload.params[0] && typeof payload.params[0] === 'object') && payload.params[0].gas) ? payload.params[0].gas : null, isContractDeployment = (!!payload.params[0] && typeof payload.params[0] === 'object') &&\n payload.params[0].data &&\n payload.params[0].from &&\n !payload.params[0].to, hasBytecode = isContractDeployment && payload.params[0].data.length > 2;\n // add custom send Methods\n var _ethereumCalls = [\n new Method({\n name: 'getBlockByNumber',\n call: 'eth_getBlockByNumber',\n params: 2,\n inputFormatter: [formatters.inputBlockNumberFormatter, function (val) {\n return !!val;\n }],\n outputFormatter: formatters.outputBlockFormatter\n }),\n new Method({\n name: 'getTransactionReceipt',\n call: 'eth_getTransactionReceipt',\n params: 1,\n inputFormatter: [null],\n outputFormatter: formatters.outputTransactionReceiptFormatter\n }),\n new Method({\n name: 'getCode',\n call: 'eth_getCode',\n params: 2,\n inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]\n }),\n new Method({\n name: 'getTransactionByHash',\n call: 'eth_getTransactionByHash',\n params: 1,\n inputFormatter: [null],\n outputFormatter: formatters.outputTransactionFormatter\n }),\n new Subscriptions({\n name: 'subscribe',\n type: 'eth',\n subscriptions: {\n 'newBlockHeaders': {\n subscriptionName: 'newHeads',\n params: 0,\n outputFormatter: formatters.outputBlockFormatter\n }\n }\n })\n ];\n // attach methods to this._ethereumCall\n var _ethereumCall = {};\n _ethereumCalls.forEach(mthd => {\n mthd.attachToObject(_ethereumCall);\n mthd.requestManager = method.requestManager; // assign rather than call setRequestManager()\n });\n // fire \"receipt\" and confirmation events and resolve after\n var checkConfirmation = function (existingReceipt, isPolling, err, blockHeader, sub) {\n if (!err) {\n // create fake unsubscribe\n if (!sub) {\n sub = {\n unsubscribe: function () {\n clearInterval(intervalId);\n clearTimeout(blockHeaderTimeoutId);\n }\n };\n }\n // if we have a valid receipt we don't need to send a request\n return (existingReceipt ? promiEvent.resolve(existingReceipt) : _ethereumCall.getTransactionReceipt(result))\n // catch error from requesting receipt\n .catch(function (err) {\n sub.unsubscribe();\n promiseResolved = true;\n utils._fireError({\n message: 'Failed to check for transaction receipt:',\n data: err\n }, defer.eventEmitter, defer.reject);\n })\n // if CONFIRMATION listener exists check for confirmations, by setting canUnsubscribe = false\n .then(async function (receipt) {\n if (!receipt || !receipt.blockHash) {\n throw new Error('Receipt missing or blockHash null');\n }\n // apply extra formatters\n if (method.extraFormatters && method.extraFormatters.receiptFormatter) {\n receipt = method.extraFormatters.receiptFormatter(receipt);\n }\n // check if confirmation listener exists\n if (defer.eventEmitter.listeners('confirmation').length > 0) {\n var block;\n // If there was an immediately retrieved receipt, it's already\n // been confirmed by the direct call to checkConfirmation needed\n // for parity instant-seal\n if (existingReceipt === undefined || confirmationCount !== 0) {\n // Get latest block to emit with confirmation\n var latestBlock = await _ethereumCall.getBlockByNumber('latest');\n var latestBlockHash = latestBlock ? latestBlock.hash : null;\n if (isPolling) { // Check if actually a new block is existing on polling\n if (lastBlock) {\n block = await _ethereumCall.getBlockByNumber(lastBlock.number + 1);\n if (block) {\n lastBlock = block;\n defer.eventEmitter.emit('confirmation', confirmationCount, receipt, latestBlockHash);\n }\n }\n else {\n block = await _ethereumCall.getBlockByNumber(receipt.blockNumber);\n lastBlock = block;\n defer.eventEmitter.emit('confirmation', confirmationCount, receipt, latestBlockHash);\n }\n }\n else {\n defer.eventEmitter.emit('confirmation', confirmationCount, receipt, latestBlockHash);\n }\n }\n if ((isPolling && block) || !isPolling) {\n confirmationCount++;\n }\n canUnsubscribe = false;\n if (confirmationCount === method.transactionConfirmationBlocks + 1) { // add 1 so we account for conf 0\n sub.unsubscribe();\n defer.eventEmitter.removeAllListeners();\n }\n }\n return receipt;\n })\n // CHECK for CONTRACT DEPLOYMENT\n .then(async function (receipt) {\n if (isContractDeployment && !promiseResolved) {\n if (!receipt.contractAddress) {\n if (canUnsubscribe) {\n sub.unsubscribe();\n promiseResolved = true;\n }\n utils._fireError(errors.NoContractAddressFoundError(receipt), defer.eventEmitter, defer.reject, null, receipt);\n return;\n }\n var code;\n try {\n code = await _ethereumCall.getCode(receipt.contractAddress);\n }\n catch (err) {\n // ignore;\n }\n if (!code) {\n return;\n }\n // If deployment is status.true and there was a real\n // bytecode string, assume it was successful.\n var deploymentSuccess = receipt.status === true && hasBytecode;\n if (deploymentSuccess || code.length > 2) {\n defer.eventEmitter.emit('receipt', receipt);\n // if contract, return instance instead of receipt\n if (method.extraFormatters && method.extraFormatters.contractDeployFormatter) {\n defer.resolve(method.extraFormatters.contractDeployFormatter(receipt));\n }\n else {\n defer.resolve(receipt);\n }\n // need to remove listeners, as they aren't removed automatically when succesfull\n if (canUnsubscribe) {\n defer.eventEmitter.removeAllListeners();\n }\n }\n else {\n utils._fireError(errors.ContractCodeNotStoredError(receipt), defer.eventEmitter, defer.reject, null, receipt);\n }\n if (canUnsubscribe) {\n sub.unsubscribe();\n }\n promiseResolved = true;\n }\n return receipt;\n })\n // CHECK for normal tx check for receipt only\n .then(async function (receipt) {\n if (!isContractDeployment && !promiseResolved) {\n if (!receipt.outOfGas &&\n (!gasProvided || gasProvided !== receipt.gasUsed) &&\n (receipt.status === true || receipt.status === '0x1' || typeof receipt.status === 'undefined')) {\n defer.eventEmitter.emit('receipt', receipt);\n defer.resolve(receipt);\n // need to remove listeners, as they aren't removed automatically when succesfull\n if (canUnsubscribe) {\n defer.eventEmitter.removeAllListeners();\n }\n }\n else {\n receiptJSON = JSON.stringify(receipt, null, 2);\n if (receipt.status === false || receipt.status === '0x0') {\n try {\n var revertMessage = null;\n if (method.handleRevert &&\n (method.call === 'eth_sendTransaction' || method.call === 'eth_sendRawTransaction')) {\n var txReplayOptions = payload.params[0];\n // If send was raw, fetch the transaction and reconstitute the\n // original params so they can be replayed with `eth_call`\n if (method.call === 'eth_sendRawTransaction') {\n var rawTransactionHex = payload.params[0];\n var parsedTx = EthersTransactionUtils.parse(rawTransactionHex);\n txReplayOptions = formatters.inputTransactionFormatter({\n data: parsedTx.data,\n to: parsedTx.to,\n from: parsedTx.from,\n gas: parsedTx.gasLimit.toHexString(),\n gasPrice: parsedTx.gasPrice.toHexString(),\n value: parsedTx.value.toHexString()\n });\n }\n // Get revert reason string with eth_call\n revertMessage = await method.getRevertReason(txReplayOptions, receipt.blockNumber);\n if (revertMessage) { // Only throw a revert error if a revert reason is existing\n utils._fireError(errors.TransactionRevertInstructionError(revertMessage.reason, revertMessage.signature, receipt), defer.eventEmitter, defer.reject, null, receipt);\n }\n else {\n throw false; // Throw false and let the try/catch statement handle the error correctly after\n }\n }\n else {\n throw false; // Throw false and let the try/catch statement handle the error correctly after\n }\n }\n catch (error) {\n // Throw an normal revert error if no revert reason is given or the detection of it is disabled\n utils._fireError(errors.TransactionRevertedWithoutReasonError(receipt), defer.eventEmitter, defer.reject, null, receipt);\n }\n }\n else {\n // Throw OOG if status is not existing and provided gas and used gas are equal\n utils._fireError(errors.TransactionOutOfGasError(receipt), defer.eventEmitter, defer.reject, null, receipt);\n }\n }\n if (canUnsubscribe) {\n sub.unsubscribe();\n }\n promiseResolved = true;\n }\n })\n // time out the transaction if not mined after 50 blocks\n .catch(function () {\n timeoutCount++;\n // check to see if we are http polling\n if (!!isPolling) {\n // polling timeout is different than transactionBlockTimeout blocks since we are triggering every second\n if (timeoutCount - 1 >= method.transactionPollingTimeout) {\n sub.unsubscribe();\n promiseResolved = true;\n utils._fireError(errors.TransactionError('Transaction was not mined within ' + method.transactionPollingTimeout + ' seconds, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject);\n }\n }\n else {\n if (timeoutCount - 1 >= method.transactionBlockTimeout) {\n sub.unsubscribe();\n promiseResolved = true;\n utils._fireError(errors.TransactionError('Transaction was not mined within ' + method.transactionBlockTimeout + ' blocks, please make sure your transaction was properly sent. Be aware that it might still be mined!'), defer.eventEmitter, defer.reject);\n }\n }\n });\n }\n else {\n sub.unsubscribe();\n promiseResolved = true;\n utils._fireError({\n message: 'Failed to subscribe to new newBlockHeaders to confirm the transaction receipts.',\n data: err\n }, defer.eventEmitter, defer.reject);\n }\n };\n // start watching for confirmation depending on the support features of the provider\n var startWatching = function (existingReceipt) {\n let blockHeaderArrived = false;\n const startInterval = () => {\n intervalId = setInterval(checkConfirmation.bind(null, existingReceipt, true), method.transactionPollingInterval);\n };\n // If provider do not support event subscription use polling\n if (!this.requestManager.provider.on) {\n return startInterval();\n }\n // Subscribe to new block headers to look for tx receipt\n _ethereumCall.subscribe('newBlockHeaders', function (err, blockHeader, sub) {\n blockHeaderArrived = true;\n if (err || !blockHeader) {\n // fall back to polling\n return startInterval();\n }\n checkConfirmation(existingReceipt, false, err, blockHeader, sub);\n });\n // Fallback to polling if tx receipt didn't arrived in \"blockHeaderTimeout\" [10 seconds]\n blockHeaderTimeoutId = setTimeout(() => {\n if (!blockHeaderArrived) {\n startInterval();\n }\n }, this.blockHeaderTimeout * 1000);\n }.bind(this);\n // first check if we already have a confirmed transaction\n _ethereumCall.getTransactionReceipt(result)\n .then(function (receipt) {\n if (receipt && receipt.blockHash) {\n if (defer.eventEmitter.listeners('confirmation').length > 0) {\n // We must keep on watching for new Blocks, if a confirmation listener is present\n startWatching(receipt);\n }\n checkConfirmation(receipt, false);\n }\n else if (!promiseResolved) {\n startWatching();\n }\n })\n .catch(function () {\n if (!promiseResolved)\n startWatching();\n });\n};\nvar getWallet = function (from, accounts) {\n var wallet = null;\n // is index given\n if (typeof from === 'number') {\n wallet = accounts.wallet[from];\n // is account given\n }\n else if (!!from && typeof from === 'object' && from.address && from.privateKey) {\n wallet = from;\n // search in wallet for address\n }\n else {\n wallet = accounts.wallet[from.toLowerCase()];\n }\n return wallet;\n};\nMethod.prototype.buildCall = function () {\n var method = this, isSendTx = (method.call === 'eth_sendTransaction' || method.call === 'eth_sendRawTransaction'), // || method.call === 'personal_sendTransaction'\n isCall = (method.call === 'eth_call');\n // actual send function\n var send = function () {\n var defer = promiEvent(!isSendTx), payload = method.toPayload(Array.prototype.slice.call(arguments));\n // CALLBACK function\n var sendTxCallback = function (err, result) {\n if (method.handleRevert && isCall && method.abiCoder) {\n var reasonData;\n // Ganache / Geth <= 1.9.13 return the reason data as a successful eth_call response\n // Geth >= 1.9.15 attaches the reason data to an error object.\n // Geth 1.9.14 is missing revert reason (https://github.com/ethereum/web3.js/issues/3520)\n if (!err && method.isRevertReasonString(result)) {\n reasonData = result.substring(10);\n }\n else if (err && err.data) {\n reasonData = err.data.substring(10);\n }\n if (reasonData) {\n var reason = method.abiCoder.decodeParameter('string', '0x' + reasonData);\n var signature = 'Error(String)';\n utils._fireError(errors.RevertInstructionError(reason, signature), defer.eventEmitter, defer.reject, payload.callback, {\n reason: reason,\n signature: signature\n });\n return;\n }\n }\n try {\n result = method.formatOutput(result);\n }\n catch (e) {\n err = e;\n }\n if (result instanceof Error) {\n err = result;\n }\n if (!err) {\n if (payload.callback) {\n payload.callback(null, result);\n }\n }\n else {\n if (err.error) {\n err = err.error;\n }\n return utils._fireError(err, defer.eventEmitter, defer.reject, payload.callback);\n }\n // return PROMISE\n if (!isSendTx) {\n if (!err) {\n defer.resolve(result);\n }\n // return PROMIEVENT\n }\n else {\n defer.eventEmitter.emit('transactionHash', result);\n method._confirmTransaction(defer, result, payload);\n }\n };\n // SENDS the SIGNED SIGNATURE\n var sendSignedTx = function (sign) {\n var signedPayload = { ...payload,\n method: 'eth_sendRawTransaction',\n params: [sign.rawTransaction]\n };\n method.requestManager.send(signedPayload, sendTxCallback);\n };\n var sendRequest = function (payload, method) {\n if (method && method.accounts && method.accounts.wallet && method.accounts.wallet.length) {\n var wallet;\n // ETH_SENDTRANSACTION\n if (payload.method === 'eth_sendTransaction') {\n var tx = payload.params[0];\n wallet = getWallet((!!tx && typeof tx === 'object') ? tx.from : null, method.accounts);\n // If wallet was found, sign tx, and send using sendRawTransaction\n if (wallet && wallet.privateKey) {\n var tx = JSON.parse(JSON.stringify(tx));\n delete tx.from;\n if (method.defaultChain && !tx.chain) {\n tx.chain = method.defaultChain;\n }\n if (method.defaultHardfork && !tx.hardfork) {\n tx.hardfork = method.defaultHardfork;\n }\n if (method.defaultCommon && !tx.common) {\n tx.common = method.defaultCommon;\n }\n method.accounts.signTransaction(tx, wallet.privateKey)\n .then(sendSignedTx)\n .catch(function (err) {\n if (typeof defer.eventEmitter.listeners === 'function' && defer.eventEmitter.listeners('error').length) {\n try {\n defer.eventEmitter.emit('error', err);\n }\n catch (err) {\n // Ignore userland error prevent it to bubble up within web3.\n }\n defer.eventEmitter.removeAllListeners();\n defer.eventEmitter.catch(function () {\n });\n }\n defer.reject(err);\n });\n return;\n }\n // ETH_SIGN\n }\n else if (payload.method === 'eth_sign') {\n var data = payload.params[1];\n wallet = getWallet(payload.params[0], method.accounts);\n // If wallet was found, sign tx, and send using sendRawTransaction\n if (wallet && wallet.privateKey) {\n var sign = method.accounts.sign(data, wallet.privateKey);\n if (payload.callback) {\n payload.callback(null, sign.signature);\n }\n defer.resolve(sign.signature);\n return;\n }\n }\n }\n return method.requestManager.send(payload, sendTxCallback);\n };\n // Send the actual transaction\n if (isSendTx\n && !!payload.params[0]\n && typeof payload.params[0] === 'object'\n && (typeof payload.params[0].gasPrice === 'undefined'\n && (typeof payload.params[0].maxPriorityFeePerGas === 'undefined'\n || typeof payload.params[0].maxFeePerGas === 'undefined'))) {\n _handleTxPricing(method, payload.params[0]).then(txPricing => {\n if (txPricing.gasPrice !== undefined) {\n payload.params[0].gasPrice = txPricing.gasPrice;\n }\n else if (txPricing.maxPriorityFeePerGas !== undefined\n && txPricing.maxFeePerGas !== undefined) {\n payload.params[0].maxPriorityFeePerGas = txPricing.maxPriorityFeePerGas;\n payload.params[0].maxFeePerGas = txPricing.maxFeePerGas;\n }\n if (isSendTx) {\n setTimeout(() => {\n defer.eventEmitter.emit('sending', payload);\n }, 0);\n }\n sendRequest(payload, method);\n });\n }\n else {\n if (isSendTx) {\n setTimeout(() => {\n defer.eventEmitter.emit('sending', payload);\n }, 0);\n }\n sendRequest(payload, method);\n }\n if (isSendTx) {\n setTimeout(() => {\n defer.eventEmitter.emit('sent', payload);\n }, 0);\n }\n return defer.eventEmitter;\n };\n // necessary to attach things to the method\n send.method = method;\n // necessary for batch requests\n send.request = this.request.bind(this);\n return send;\n};\nfunction _handleTxPricing(method, tx) {\n return new Promise((resolve, reject) => {\n try {\n var getBlockByNumber = (new Method({\n name: 'getBlockByNumber',\n call: 'eth_getBlockByNumber',\n params: 2,\n inputFormatter: [function (blockNumber) {\n return blockNumber ? utils.toHex(blockNumber) : 'latest';\n }, function () {\n return false;\n }]\n })).createFunction(method.requestManager);\n var getGasPrice = (new Method({\n name: 'getGasPrice',\n call: 'eth_gasPrice',\n params: 0\n })).createFunction(method.requestManager);\n Promise.all([\n getBlockByNumber(),\n getGasPrice()\n ]).then(responses => {\n const [block, gasPrice] = responses;\n if ((tx.type === '0x2' || tx.type === undefined) &&\n (block && block.baseFeePerGas)) {\n // The network supports EIP-1559\n // Taken from https://github.com/ethers-io/ethers.js/blob/ba6854bdd5a912fe873d5da494cb5c62c190adde/packages/abstract-provider/src.ts/index.ts#L230\n let maxPriorityFeePerGas, maxFeePerGas;\n if (tx.gasPrice) {\n // Using legacy gasPrice property on an eip-1559 network,\n // so use gasPrice as both fee properties\n maxPriorityFeePerGas = tx.gasPrice;\n maxFeePerGas = tx.gasPrice;\n delete tx.gasPrice;\n }\n else {\n maxPriorityFeePerGas = tx.maxPriorityFeePerGas || '0x9502F900'; // 2.5 Gwei\n maxFeePerGas = tx.maxFeePerGas ||\n utils.toHex(utils.toBN(block.baseFeePerGas)\n .mul(utils.toBN(2))\n .add(utils.toBN(maxPriorityFeePerGas)));\n }\n resolve({ maxFeePerGas, maxPriorityFeePerGas });\n }\n else {\n if (tx.maxPriorityFeePerGas || tx.maxFeePerGas)\n throw Error(\"Network doesn't support eip-1559\");\n resolve({ gasPrice });\n }\n });\n }\n catch (error) {\n reject(error);\n }\n });\n}\n/**\n * Returns the revert reason string if existing or otherwise false.\n *\n * @method getRevertReason\n *\n * @param {Object} txOptions\n * @param {Number} blockNumber\n *\n * @returns {Promise}\n */\nMethod.prototype.getRevertReason = function (txOptions, blockNumber) {\n var self = this;\n return new Promise(function (resolve, reject) {\n (new Method({\n name: 'call',\n call: 'eth_call',\n params: 2,\n abiCoder: self.abiCoder,\n handleRevert: true\n }))\n .createFunction(self.requestManager)(txOptions, utils.numberToHex(blockNumber))\n .then(function () {\n resolve(false);\n })\n .catch(function (error) {\n if (error.reason) {\n resolve({\n reason: error.reason,\n signature: error.signature\n });\n }\n else {\n reject(error);\n }\n });\n });\n};\n/**\n * Checks if the given hex string is a revert message from the EVM\n *\n * @method isRevertReasonString\n *\n * @param {String} data - Hex string prefixed with 0x\n *\n * @returns {Boolean}\n */\nMethod.prototype.isRevertReasonString = function (data) {\n return typeof data === 'string' && ((data.length - 2) / 2) % 32 === 4 && data.substring(0, 10) === '0x08c379a0';\n};\n/**\n * Should be called to create the pure JSONRPC request which can be used in a batch request\n *\n * @method request\n * @return {Object} jsonrpc request\n */\nMethod.prototype.request = function () {\n var payload = this.toPayload(Array.prototype.slice.call(arguments));\n payload.format = this.formatOutput.bind(this);\n return payload;\n};\nmodule.exports = Method;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file batch.js\n * @author Marek Kotewicz \n * @date 2015\n */\n\"use strict\";\nvar Jsonrpc = require('./jsonrpc');\nvar errors = require('web3-core-helpers').errors;\nvar Batch = function (requestManager) {\n this.requestManager = requestManager;\n this.requests = [];\n};\n/**\n * Should be called to add create new request to batch request\n *\n * @method add\n * @param {Object} jsonrpc requet object\n */\nBatch.prototype.add = function (request) {\n this.requests.push(request);\n};\n/**\n * Should be called to execute batch request\n *\n * @method execute\n */\nBatch.prototype.execute = function () {\n var requests = this.requests;\n var sortResponses = this._sortResponses.bind(this);\n this.requestManager.sendBatch(requests, function (err, results) {\n results = sortResponses(results);\n requests.map(function (request, index) {\n return results[index] || {};\n }).forEach(function (result, index) {\n if (requests[index].callback) {\n if (result && result.error) {\n return requests[index].callback(errors.ErrorResponse(result));\n }\n if (!Jsonrpc.isValidResponse(result)) {\n return requests[index].callback(errors.InvalidResponse(result));\n }\n try {\n requests[index].callback(null, requests[index].format ? requests[index].format(result.result) : result.result);\n }\n catch (err) {\n requests[index].callback(err);\n }\n }\n });\n });\n};\n// Sort responses\nBatch.prototype._sortResponses = function (responses) {\n return (responses || []).sort((a, b) => a.id - b.id);\n};\nmodule.exports = Batch;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/** @file jsonrpc.js\n * @authors:\n * Fabian Vogelsteller \n * Marek Kotewicz \n * Aaron Kumavis \n * @date 2015\n */\n\"use strict\";\n// Initialize Jsonrpc as a simple object with utility functions.\nvar Jsonrpc = {\n messageId: 0\n};\n/**\n * Should be called to valid json create payload object\n *\n * @method toPayload\n * @param {Function} method of jsonrpc call, required\n * @param {Array} params, an array of method params, optional\n * @returns {Object} valid jsonrpc payload object\n */\nJsonrpc.toPayload = function (method, params) {\n if (!method) {\n throw new Error('JSONRPC method should be specified for params: \"' + JSON.stringify(params) + '\"!');\n }\n // advance message ID\n Jsonrpc.messageId++;\n return {\n jsonrpc: '2.0',\n id: Jsonrpc.messageId,\n method: method,\n params: params || []\n };\n};\n/**\n * Should be called to check if jsonrpc response is valid\n *\n * @method isValidResponse\n * @param {Object}\n * @returns {Boolean} true if response is valid, otherwise false\n */\nJsonrpc.isValidResponse = function (response) {\n return Array.isArray(response) ? response.every(validateSingleMessage) : validateSingleMessage(response);\n function validateSingleMessage(message) {\n return !!message &&\n !message.error &&\n message.jsonrpc === '2.0' &&\n (typeof message.id === 'number' || typeof message.id === 'string') &&\n message.result !== undefined; // only undefined is not valid json object\n }\n};\n/**\n * Should be called to create batch payload object\n *\n * @method toBatchPayload\n * @param {Array} messages, an array of objects with method (required) and params (optional) fields\n * @returns {Array} batch payload\n */\nJsonrpc.toBatchPayload = function (messages) {\n return messages.map(function (message) {\n return Jsonrpc.toPayload(message.method, message.params);\n });\n};\nmodule.exports = Jsonrpc;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar swarm = require(\"swarm-js\");\nvar Bzz = function Bzz(provider) {\n this.givenProvider = Bzz.givenProvider;\n if (provider && provider._requestManager) {\n provider = provider.currentProvider;\n }\n // only allow file picker when in browser\n if (typeof document !== 'undefined') {\n this.pick = swarm.pick;\n }\n this.setProvider(provider);\n};\n// set default ethereum provider\n/* jshint ignore:start */\nBzz.givenProvider = null;\nif (typeof ethereum !== 'undefined' && ethereum.bzz) {\n Bzz.givenProvider = ethereum.bzz;\n}\n/* jshint ignore:end */\nBzz.prototype.setProvider = function (provider) {\n // is ethereum provider\n if (!!provider && typeof provider === 'object' && typeof provider.bzz === 'string') {\n provider = provider.bzz;\n // is no string, set default\n }\n // else if(!_.isString(provider)) {\n // provider = 'http://swarm-gateways.net'; // default to gateway\n // }\n if (typeof provider === 'string') {\n this.currentProvider = provider;\n }\n else {\n this.currentProvider = null;\n var noProviderError = new Error('No provider set, please set one using bzz.setProvider().');\n this.download = this.upload = this.isAvailable = function () {\n throw noProviderError;\n };\n return false;\n }\n // add functions\n this.download = swarm.at(provider).download;\n this.upload = swarm.at(provider).upload;\n this.isAvailable = swarm.at(provider).isAvailable;\n return true;\n};\nmodule.exports = Bzz;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file subscription.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar errors = require('web3-core-helpers').errors;\nvar EventEmitter = require('eventemitter3');\nvar formatters = require('web3-core-helpers').formatters;\nfunction identity(value) {\n return value;\n}\nfunction Subscription(options) {\n EventEmitter.call(this);\n this.id = null;\n this.callback = identity;\n this.arguments = null;\n this.lastBlock = null; // \"from\" block tracker for backfilling events on reconnection\n this.options = {\n subscription: options.subscription,\n type: options.type,\n requestManager: options.requestManager\n };\n}\n// INHERIT\nSubscription.prototype = Object.create(EventEmitter.prototype);\nSubscription.prototype.constructor = Subscription;\n/**\n * Should be used to extract callback from array of arguments. Modifies input param\n *\n * @method extractCallback\n * @param {Array} arguments\n * @return {Function|Null} callback, if exists\n */\nSubscription.prototype._extractCallback = function (args) {\n if (typeof args[args.length - 1] === 'function') {\n return args.pop(); // modify the args array!\n }\n};\n/**\n * Should be called to check if the number of arguments is correct\n *\n * @method validateArgs\n * @param {Array} arguments\n * @throws {Error} if it is not\n */\nSubscription.prototype._validateArgs = function (args) {\n var subscription = this.options.subscription;\n if (!subscription)\n subscription = {};\n if (!subscription.params)\n subscription.params = 0;\n if (args.length !== subscription.params) {\n throw errors.InvalidNumberOfParams(args.length, subscription.params, subscription.subscriptionName);\n }\n};\n/**\n * Should be called to format input args of method\n *\n * @method formatInput\n * @param {Array}\n * @return {Array}\n */\nSubscription.prototype._formatInput = function (args) {\n var subscription = this.options.subscription;\n if (!subscription) {\n return args;\n }\n if (!subscription.inputFormatter) {\n return args;\n }\n var formattedArgs = subscription.inputFormatter.map(function (formatter, index) {\n return formatter ? formatter(args[index]) : args[index];\n });\n return formattedArgs;\n};\n/**\n * Should be called to format output(result) of method\n *\n * @method formatOutput\n * @param result {Object}\n * @return {Object}\n */\nSubscription.prototype._formatOutput = function (result) {\n var subscription = this.options.subscription;\n return (subscription && subscription.outputFormatter && result) ? subscription.outputFormatter(result) : result;\n};\n/**\n * Should create payload from given input args\n *\n * @method toPayload\n * @param {Array} args\n * @return {Object}\n */\nSubscription.prototype._toPayload = function (args) {\n var params = [];\n this.callback = this._extractCallback(args) || identity;\n if (!this.subscriptionMethod) {\n this.subscriptionMethod = args.shift();\n // replace subscription with given name\n if (this.options.subscription.subscriptionName) {\n this.subscriptionMethod = this.options.subscription.subscriptionName;\n }\n }\n if (!this.arguments) {\n this.arguments = this._formatInput(args);\n this._validateArgs(this.arguments);\n args = []; // make empty after validation\n }\n // re-add subscriptionName\n params.push(this.subscriptionMethod);\n params = params.concat(this.arguments);\n if (args.length) {\n throw new Error('Only a callback is allowed as parameter on an already instantiated subscription.');\n }\n return {\n method: this.options.type + '_subscribe',\n params: params\n };\n};\n/**\n * Unsubscribes and clears callbacks\n *\n * @method unsubscribe\n * @return {Object}\n */\nSubscription.prototype.unsubscribe = function (callback) {\n this.options.requestManager.removeSubscription(this.id, callback);\n this.id = null;\n this.lastBlock = null;\n this.removeAllListeners();\n};\n/**\n * Subscribes and watches for changes\n *\n * @method subscribe\n * @param {String} subscription the subscription\n * @param {Object} options the options object with address topics and fromBlock\n * @return {Object}\n */\nSubscription.prototype.subscribe = function () {\n var _this = this;\n var args = Array.prototype.slice.call(arguments);\n var payload = this._toPayload(args);\n if (!payload) {\n return this;\n }\n // throw error, if provider is not set\n if (!this.options.requestManager.provider) {\n setTimeout(function () {\n var err1 = new Error('No provider set.');\n _this.callback(err1, null, _this);\n _this.emit('error', err1);\n }, 0);\n return this;\n }\n // throw error, if provider doesnt support subscriptions\n if (!this.options.requestManager.provider.on) {\n setTimeout(function () {\n var err2 = new Error('The current provider doesn\\'t support subscriptions: ' +\n _this.options.requestManager.provider.constructor.name);\n _this.callback(err2, null, _this);\n _this.emit('error', err2);\n }, 0);\n return this;\n }\n // Re-subscription only: continue fetching from the last block we received.\n // a dropped connection may have resulted in gaps in the logs...\n if (this.lastBlock && !!this.options.params && typeof this.options.params === 'object') {\n payload.params[1] = this.options.params;\n payload.params[1].fromBlock = formatters.inputBlockNumberFormatter(this.lastBlock + 1);\n }\n // if id is there unsubscribe first\n if (this.id) {\n this.unsubscribe();\n }\n // store the params in the options object\n this.options.params = payload.params[1];\n // get past logs, if fromBlock is available\n if (payload.params[0] === 'logs' && !!payload.params[1] && typeof payload.params[1] === 'object' && payload.params[1].hasOwnProperty('fromBlock') && isFinite(payload.params[1].fromBlock)) {\n // send the subscription request\n // copy the params to avoid race-condition with deletion below this block\n var blockParams = Object.assign({}, payload.params[1]);\n this.options.requestManager.send({\n method: 'eth_getLogs',\n params: [blockParams]\n }, function (err, logs) {\n if (!err) {\n logs.forEach(function (log) {\n var output = _this._formatOutput(log);\n _this.callback(null, output, _this);\n _this.emit('data', output);\n });\n // TODO subscribe here? after the past logs?\n }\n else {\n setTimeout(function () {\n _this.callback(err, null, _this);\n _this.emit('error', err);\n }, 0);\n }\n });\n }\n // create subscription\n // TODO move to separate function? so that past logs can go first?\n if (typeof payload.params[1] === 'object')\n delete payload.params[1].fromBlock;\n this.options.requestManager.send(payload, function (err, result) {\n if (!err && result) {\n _this.id = result;\n _this.method = payload.params[0];\n // call callback on notifications\n _this.options.requestManager.addSubscription(_this, function (error, result) {\n if (!error) {\n if (!Array.isArray(result)) {\n result = [result];\n }\n result.forEach(function (resultItem) {\n var output = _this._formatOutput(resultItem);\n // Track current block (for gaps introduced by dropped connections)\n _this.lastBlock = !!output && typeof output === 'object' ? output.blockNumber : null;\n if (typeof _this.options.subscription.subscriptionHandler === 'function') {\n return _this.options.subscription.subscriptionHandler.call(_this, output);\n }\n else {\n _this.emit('data', output);\n }\n // call the callback, last so that unsubscribe there won't affect the emit above\n _this.callback(null, output, _this);\n });\n }\n else {\n _this.callback(error, false, _this);\n _this.emit('error', error);\n }\n });\n _this.emit('connected', result);\n }\n else {\n setTimeout(function () {\n _this.callback(err, false, _this);\n _this.emit('error', err);\n }, 0);\n }\n });\n // return an object to cancel the subscription\n return this;\n};\n/**\n * Resubscribe\n *\n * @method resubscribe\n *\n * @returns {void}\n */\nSubscription.prototype.resubscribe = function () {\n this.options.requestManager.removeSubscription(this.id); // unsubscribe\n this.id = null;\n this.subscribe(this.callback);\n};\nmodule.exports = Subscription;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar errors = require('./errors');\nvar formatters = require('./formatters');\nmodule.exports = {\n errors: errors,\n formatters: formatters\n};\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\nconst requestManager = require(\"web3-core-requestmanager\");\nconst extend = require(\"./extend\");\nconst packageInit = (pkg, args) => {\n args = Array.prototype.slice.call(args);\n if (!pkg) {\n throw new Error('You need to instantiate using the \"new\" keyword.');\n }\n // make property of pkg._provider, which can properly set providers\n Object.defineProperty(pkg, 'currentProvider', {\n get: () => {\n return pkg._provider;\n },\n set: (value) => {\n return pkg.setProvider(value);\n },\n enumerable: true,\n configurable: true\n });\n // inherit from parent package or create a new RequestManager\n if (args[0] && args[0]._requestManager) {\n pkg._requestManager = args[0]._requestManager;\n }\n else {\n pkg._requestManager = new requestManager.Manager(args[0], args[1]);\n }\n // add givenProvider\n pkg.givenProvider = requestManager.Manager.givenProvider;\n pkg.providers = requestManager.Manager.providers;\n pkg._provider = pkg._requestManager.provider;\n // add SETPROVIDER function (don't overwrite if already existing)\n if (!pkg.setProvider) {\n pkg.setProvider = (provider, net) => {\n pkg._requestManager.setProvider(provider, net);\n pkg._provider = pkg._requestManager.provider;\n return true;\n };\n }\n pkg.setRequestManager = (manager) => {\n pkg._requestManager = manager;\n pkg._provider = manager.provider;\n };\n // attach batch request creation\n pkg.BatchRequest = requestManager.BatchManager.bind(null, pkg._requestManager);\n // attach extend function\n pkg.extend = extend(pkg);\n};\nconst addProviders = (pkg) => {\n pkg.givenProvider = requestManager.Manager.givenProvider;\n pkg.providers = requestManager.Manager.providers;\n};\nmodule.exports = {\n packageInit,\n addProviders\n};\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n */\n/**\n * @file extend.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar formatters = require('web3-core-helpers').formatters;\nvar Method = require('web3-core-method');\nvar utils = require('web3-utils');\nvar extend = function (pckg) {\n /* jshint maxcomplexity:5 */\n var ex = function (extension) {\n var extendedObject;\n if (extension.property) {\n if (!pckg[extension.property]) {\n pckg[extension.property] = {};\n }\n extendedObject = pckg[extension.property];\n }\n else {\n extendedObject = pckg;\n }\n if (extension.methods) {\n extension.methods.forEach(function (method) {\n if (!(method instanceof Method)) {\n method = new Method(method);\n }\n method.attachToObject(extendedObject);\n method.setRequestManager(pckg._requestManager);\n });\n }\n return pckg;\n };\n ex.formatters = formatters;\n ex.utils = utils;\n ex.Method = Method;\n return ex;\n};\nmodule.exports = extend;\n","/*\n This file is part of web3.js.\n\n web3.js is free software: you can redistribute it and/or modify\n it under the terms of the GNU Lesser General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n web3.js is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU Lesser General Public License for more details.\n\n You should have received a copy of the GNU Lesser General Public License\n along with web3.js. If not, see .\n*/\n/**\n * @file index.js\n * @author Fabian Vogelsteller \n * @date 2017\n */\n\"use strict\";\nvar Subscription = require('./subscription.js');\nvar Subscriptions = function Subscriptions(options) {\n this.name = options.name;\n this.type = options.type;\n this.subscriptions = options.subscriptions || {};\n this.requestManager = null;\n};\nSubscriptions.prototype.setRequestManager = function (rm) {\n this.requestManager = rm;\n};\nSubscriptions.prototype.attachToObject = function (obj) {\n var func = this.buildCall();\n var name = this.name.split('.');\n if (name.length > 1) {\n obj[name[0]] = obj[name[0]] || {};\n obj[name[0]][name[1]] = func;\n }\n else {\n obj[name[0]] = func;\n }\n};\nSubscriptions.prototype.buildCall = function () {\n var _this = this;\n return function () {\n if (!_this.subscriptions[arguments[0]]) {\n console.warn('Subscription ' + JSON.stringify(arguments[0]) + ' doesn\\'t exist. Subscribing anyway.');\n }\n var subscription = new Subscription({\n subscription: _this.subscriptions[arguments[0]] || {},\n requestManager: _this.requestManager,\n type: _this.type\n });\n return subscription.subscribe.apply(subscription, arguments);\n };\n};\nmodule.exports = {\n subscriptions: Subscriptions,\n subscription: Subscription\n};\n"],"sourceRoot":""}