@oceanprotocol/lib 1.0.0-next.7 → 1.0.0-next.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("web3"),t=require("bignumber.js"),r=require("cross-fetch"),n=require("fs"),o=require("save-file"),i=require("@oceanprotocol/contracts/addresses/address.json"),s=require("crypto-js/sha256"),a=require("@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json"),c=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),u=require("decimal.js"),l=require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),f=require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),h=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),m=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),v=require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P,g=/*#__PURE__*/d(e),p=/*#__PURE__*/d(t),w=/*#__PURE__*/d(r),b=/*#__PURE__*/d(n),A=/*#__PURE__*/d(o),y=/*#__PURE__*/d(i),T=/*#__PURE__*/d(s),E=/*#__PURE__*/d(a),C=/*#__PURE__*/d(c),F=/*#__PURE__*/d(u),R=/*#__PURE__*/d(l),k=/*#__PURE__*/d(f),I=/*#__PURE__*/d(h),j=/*#__PURE__*/d(m),S=/*#__PURE__*/d(v);exports.LogLevel=void 0,(P=exports.LogLevel||(exports.LogLevel={}))[P.None=-1]="None",P[P.Error=0]="Error",P[P.Warn=1]="Warn",P[P.Log=2]="Log",P[P.Verbose=3]="Verbose";var x=/*#__PURE__*/function(){function e(e){void 0===e&&(e=exports.LogLevel.Error),this.logLevel=void 0,this.logLevel=e}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",exports.LogLevel.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",exports.LogLevel.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",exports.LogLevel.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",exports.LogLevel.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),G=new x,L={nouns:["Crab","Fish","Seal","Octopus","Shark","Seahorse","Walrus","Starfish","Whale","Orca","Penguin","Jellyfish","Squid","Lobster","Pelican","Shrimp","Oyster","Clam","Seagull","Dolphin","Shell","Cormorant","Otter","Anemone","Turtle","Coral","Ray","Barracuda","Krill","Anchovy","Angelfish","Barnacle","Clownfish","Cod","Cuttlefish","Eel","Fugu","Herring","Haddock","Ling","Mackerel","Manatee","Narwhal","Nautilus","Plankton","Porpoise","Prawn","Pufferfish","Swordfish","Tuna"],adjectives:["adamant","adroit","amatory","ambitious","amused","animistic","antic","arcadian","artistic","astonishing","astounding","baleful","bellicose","bilious","blissful","boorish","brave","breathtaking","brilliant","calamitous","caustic","cerulean","clever","charming","comely","competent","concomitant","confident","contumacious","corpulent","crapulous","creative","dazzling","dedicated","defamatory","delighted","delightful","determined","didactic","dilatory","dowdy","efficacious","effulgent","egregious","empowered","endemic","enthusiastic","equanimous","exceptional","execrable","fabulous","fantastic","fastidious","feckless","fecund","friable","fulsome","garrulous","generous","gentle","guileless","gustatory","heuristic","histrionic","hubristic","incendiary","incredible","insidious","insolent","inspired","intransigent","inveterate","invidious","invigorated","irksome","jejune","juicy","jocular","joyful","judicious","kind","lachrymose","limpid","loquacious","lovely","luminous","mannered","marvelous","mendacious","meretricious","minatory","mordant","motivated","munificent","nefarious","noxious","obtuse","optimistic","parsimonious","pendulous","pernicious","pervasive","petulant","passionate","phenomenal","platitudinous","pleasant","powerful","precipitate","propitious","puckish","querulous","quiescent","rebarbative","recalcitant","redolent","rhadamanthine","risible","ruminative","sagacious","salubrious","sartorial","sclerotic","serpentine","smart","spasmodic","strident","stunning","stupendous","taciturn","tactful","tasty","tenacious","tremendous","tremulous","trenchant","turbulent","turgid","ubiquitous","uxorious","verdant","vibrant","voluble","voracious","wheedling","withering","wonderful","zealous"]};function U(e){var t=e||L,r=Math.floor(Math.random()*t.adjectives.length),n=Math.floor(Math.random()*t.nouns.length),o=Math.floor(100*Math.random()),i=t.adjectives[r].replace(/^\w/,function(e){return e.toUpperCase()}),s=t.nouns[n].replace(/^\w/,function(e){return e.toUpperCase()});return{name:i+" "+s+" Token",symbol:(i.substring(0,3)+s.substring(0,3)).toUpperCase()+"-"+o}}var M=function(e,t){try{return Promise.resolve(e.eth.getGasPrice()).then(function(e){var r=new p.default(e);return t&&t.gasFeeMultiplier?r.multipliedBy(t.gasFeeMultiplier).integerValue(p.default.ROUND_DOWN).toString(10):r.toString(10)})}catch(e){return Promise.reject(e)}};function O(e,t){return t&&(t.transactionBlockTimeout&&(e.transactionBlockTimeout=t.transactionBlockTimeout),t.transactionConfirmationBlocks&&(e.transactionConfirmationBlocks=t.transactionConfirmationBlocks),t.transactionPollingTimeout&&(e.transactionPollingTimeout=t.transactionPollingTimeout)),e}function D(e){var t,r;if(!e.name||!e.symbol){var n=U();t=n.name,r=n.symbol}return{templateIndex:e.templateIndex,strings:[e.name||t,e.symbol||r],addresses:[e.minter,e.feeManager,e.mpFeeAddress,e.feeToken],uints:[g.default.utils.toWei(e.cap),g.default.utils.toWei(e.feeAmount)],bytess:[]}}function N(e){return e.allowedConsumer||(e.allowedConsumer="0x0000000000000000000000000000000000000000"),{fixedPriceAddress:e.fixedRateAddress,addresses:[e.baseTokenAddress,e.owner,e.marketFeeCollector,e.allowedConsumer],uints:[e.baseTokenDecimals,e.datatokenDecimals,e.fixedRate,e.marketFee,e.withMint?1:0]}}function W(e){return{addresses:[e.ssContract,e.baseTokenAddress,e.baseTokenSender,e.publisherAddress,e.marketFeeCollector,e.poolTemplateAddress],ssParams:[g.default.utils.toWei(e.rate),e.baseTokenDecimals,g.default.utils.toWei(e.vestingAmount),e.vestedBlocks,g.default.utils.toWei(e.initialBaseTokenLiquidity)],swapFees:[e.swapFeeLiquidityProvider,e.swapFeeMarketRunner]}}var _=function(e,t,r,n){try{return Promise.resolve(w.default(t,{method:e,body:r,headers:n}))}catch(e){return Promise.reject(e)}},B=function(e){try{return Promise.resolve(w.default(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}};function q(){return q=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},q.apply(this,arguments)}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function J(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return z(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?z(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var H={chainId:null,network:"unknown",metadataCacheUri:"https://aquarius.oceanprotocol.com",nodeUri:"http://localhost:8545",providerUri:"http://127.0.0.1:8030",subgraphUri:null,explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",poolTemplateAddress:null,fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},Z=[q({},H),q({},H,{chainId:8996,network:"development",metadataCacheUri:"http://127.0.0.1:5000"}),q({},H,{chainId:3,network:"ropsten",nodeUri:"https://ropsten.infura.io/v3",providerUri:"https://provider.ropsten.oceanprotocol.com",subgraphUri:"https://subgraph.ropsten.oceanprotocol.com",explorerUri:"https://ropsten.etherscan.io",startBlock:9227563}),q({},H,{chainId:4,network:"rinkeby",nodeUri:"https://rinkeby.infura.io/v3",providerUri:"https://providerv4.rinkeby.oceanprotocol.com",subgraphUri:"https://subgraphv4.rinkeby.oceanprotocol.com",explorerUri:"https://rinkeby.etherscan.io",startBlock:7294090}),q({},H,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",providerUri:"https://provider.mainnet.oceanprotocol.com",subgraphUri:"https://subgraph.mainnet.oceanprotocol.com",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05}),q({},H,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",providerUri:"https://provider.polygon.oceanprotocol.com",subgraphUri:"https://subgraph.polygon.oceanprotocol.com",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",startBlock:11005222}),q({},H,{chainId:1287,network:"moonbeamalpha",nodeUri:"https://rpc.testnet.moonbeam.network",providerUri:"https://provider.moonbeamalpha.oceanprotocol.com",subgraphUri:"https://subgraph.moonbeamalpha.oceanprotocol.com",explorerUri:"https://moonbase-blockscout.testnet.moonbeam.network/",startBlock:90707}),q({},H,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",providerUri:"https://provider.gaiaxtestnet.oceanprotocol.com",subgraphUri:"https://subgraph.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com"}),q({},H,{chainId:2021001,network:"catenaxtestnet",nodeUri:"https://rpc.catenaxtestnet.oceanprotocol.com",providerUri:"https://provider.catenaxtestnet.oceanprotocol.com",subgraphUri:"https://subgraph.catenaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.catenaxtestnet.oceanprotocol.com",metadataCacheUri:"https://aquarius.catenaxtestnet.oceanprotocol.com"}),q({},H,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",providerUri:"https://provider.mumbai.oceanprotocol.com",subgraphUri:"https://subgraph.mumbai.oceanprotocol.com",explorerUri:"https://mumbai.polygonscan.com"}),q({},H,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",providerUri:"https://provider.bsc.oceanprotocol.com",subgraphUri:"https://subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05}),q({},H,{chainId:44787,network:"celoalfajores",nodeUri:"https://alfajores-forno.celo-testnet.org",providerUri:"https://provider.celoalfajores.oceanprotocol.com",subgraphUri:"https://subgraph.celoalfajores.oceanprotocol.com",explorerUri:"https://alfajores-blockscout.celo-testnet.org"}),q({},H,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",providerUri:"https://provider.energyweb.oceanprotocol.com",subgraphUri:"https://subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05}),q({},H,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",providerUri:"https://provider.moonriver.oceanprotocol.com",subgraphUri:"https://subgraph.moonriver.oceanprotocol.com",explorerUri:"https://blockscout.moonriver.moonbeam.network",gasFeeMultiplier:1.05})],V=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e){var t;if(y.default[e]){var r=y.default[e];t=q({erc721FactoryAddress:r.ERC721Factory,sideStakingAddress:r.Staking,opfCommunityFeeCollector:r.OPFCommunityFeeCollector,poolTemplateAddress:r.poolTemplate,fixedRateExchangeAddress:r.FixedPrice,dispenserAddress:r.Dispenser,oceanTokenAddress:r.Ocean,chainId:r.chainId,startBlock:r.startBlock},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}if(b.default&&process.env.ADDRESS_FILE)try{var n=JSON.parse(b.default.readFileSync(process.env.ADDRESS_FILE,"utf8"))[e];t=q({erc721FactoryAddress:n.ERC721Factory,sideStakingAddress:n.Staking,opfCommunityFeeCollector:n.OPFCommunityFeeCollector,poolTemplateAddress:n.poolTemplate,fixedRateExchangeAddress:n.FixedPrice,dispenserAddress:n.Dispenser,oceanTokenAddress:n.Ocean,chainId:n.chainId,startBlock:n.startBlock},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}catch(e){}return t},t.getConfig=function(e,t){var r="string"==typeof e?"network":"chainId",n=Z.find(function(t){return t[r]===e});return n?(n=q({},n,this.getAddressesFromEnv(n.network)),q({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(G.error("No config found for given network '"+e+"'"),null)},e}();function Q(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var X=function(e,t,r,n){try{var o=e.utils.utf8ToHex(t),i=e&&e.currentProvider&&e.currentProvider.isMetaMask;return Promise.resolve(Q(function(){return Promise.resolve(e.eth.personal.sign(o,r,n))},function(t){if(i)throw t;return G.warn("Error on personal sign."),G.warn(t),Q(function(){return Promise.resolve(e.eth.sign(o,r))},function(e){throw G.error("Error on sign."),G.error(e),new Error("Error executing personal sign")})}))}catch(e){return Promise.reject(e)}},$=function(e,t,r,n){try{var o=e&&e.currentProvider&&e.currentProvider.isMetaMask;return Promise.resolve(Q(function(){return Promise.resolve(e.eth.personal.sign(t,r,n))},function(n){if(o)throw n;return G.warn("Error on personal sign."),G.warn(n),Q(function(){return Promise.resolve(e.eth.sign(t,r))},function(e){throw G.error("Error on sign."),G.error(e),new Error("Error executing personal sign")})}))}catch(e){return Promise.reject(e)}};function K(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Y="115792089237316195423570985008687907853269984665640564039457584007913129639934";function ee(e,t,r){if(!e.s){if(r instanceof te){if(!r.s)return void(r.o=ee.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(ee.bind(null,e,t),ee.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var te=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{ee(n,1,i(this.v))}catch(e){ee(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?ee(n,1,t?t(o):o):r?ee(n,1,r(o)):ee(n,2,o)}catch(e){ee(n,2,e)}},n},e}();function re(e){return e instanceof te&&1&e.s}function ne(e,t,r){for(var n;;){var o=e();if(re(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!re(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!re(s)){n=2;break}}}var a=new te,c=ee.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(f)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!re(s))return void s.then(f).then(void 0,c);if(!(o=e())||re(o)&&!o.v)return void ee(a,1,i);if(o.then)return void o.then(l).then(void 0,c);re(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,c)}function l(e){e?(i=r())&&i.then?i.then(u).then(void 0,c):u(i):ee(a,1,i)}function f(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):ee(a,1,i)}}var oe=/*#__PURE__*/function(){function e(e,t,r,n){void 0===r&&(r=null),this.poolAbi=void 0,this.web3=void 0,this.GASLIMIT_DEFAULT=1e6,this.logger=void 0,this.config=void 0,this.poolAbi=r||E.default.abi,this.web3=e,this.logger=t,this.config=n||Z[0]}var t=e.prototype;return t.estApprove=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(C.default.abi,t),s.config),c=s.GASLIMIT_DEFAULT,u=K(function(){return Promise.resolve(a.methods.approve(r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(e){i=c,G.error("estimate gas failed for approve!",e)});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.allowance=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(C.default.abi,e),n.config);return Promise.resolve(o.methods.allowance(t,r).call()).then(function(t){return Promise.resolve(n.unitsToAmount(e,t))})}catch(e){return Promise.reject(e)}},t.approve=function(e,t,r,n,o){void 0===o&&(o=!1);try{var i,s=function(o){if(i)return o;var s=null;return Promise.resolve(a.amountToUnits(t,n)).then(function(n){return Promise.resolve(a.estApprove(e,t,r,n)).then(function(t){var o=K(function(){var o=c.methods.approve(r,n),i=o.send;return Promise.resolve(M(a.web3,a.config)).then(function(r){return Promise.resolve(i.call(o,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){a.logger.error("ERRPR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return s}):s})})},a=this,c=O(new a.web3.eth.Contract([{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}],t),a.config),u=function(){if(!o)return Promise.resolve(a.allowance(t,e,r)).then(function(e){if(new F.default(e).greaterThanOrEqualTo(new F.default(n)))return i=1,e})}();return Promise.resolve(u&&u.then?u.then(s):s(u))}catch(e){return Promise.reject(e)}},t.sharesBalance=function(e,t){try{var r=this,n=null,o=K(function(){var o=O(new r.web3.eth.Contract(r.poolAbi,t),r.config);return Promise.resolve(o.methods.balanceOf(e).call()).then(function(e){n=r.web3.utils.fromWei(e)})},function(e){r.logger.error("ERROR: Failed to get shares of pool : "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.estSetSwapFee=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(C.default.abi,t),i.config),a=i.GASLIMIT_DEFAULT,c=K(function(){return Promise.resolve(s.methods.setSwapFee(r).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setSwapFee=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.poolAbi,t,{from:e}),n.config),i=null;return Promise.resolve(n.estSetSwapFee(e,t,r)).then(function(t){var s=K(function(){var s=o.methods.setSwapFee(n.web3.utils.toWei(r)),a=s.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(s,{from:e,gas:t,gasPrice:r})).then(function(e){i=e})})},function(e){n.logger.error("ERROR: Failed to set pool swap fee: "+e.message)});return s&&s.then?s.then(function(){return i}):i})}catch(e){return Promise.reject(e)}},t.getNumTokens=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getNumTokens().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get number of tokens: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getPoolSharesTotalSupply=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.totalSupply().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){t.logger.error("ERROR: Failed to get total supply of pool shares: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getCurrentTokens=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getCurrentTokens().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get tokens composing this pool: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getFinalTokens=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getFinalTokens().call()).then(function(e){n=e})},function(){t.logger.error("ERROR: Failed to get the final tokens composing this pool")});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getController=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getController().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get pool controller address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getBaseToken=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getBaseTokenAddress().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get baseToken address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getDatatoken=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getDatatokenAddress().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get datatoken address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getMarketFeeCollector=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods._publishMarketCollector().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get marketFeeCollector address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getOPFCollector=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods._opfCollector().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.isBound=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=K(function(){return Promise.resolve(n.methods.isBound(t).call()).then(function(e){o=e})},function(e){r.logger.error("ERROR: Failed to check whether a token bounded to a pool. "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getReserve=function(e,t){try{var r=function(){return o.toString()},n=this,o=null,i=K(function(){var r=O(new n.web3.eth.Contract(n.poolAbi,e),n.config);return Promise.resolve(r.methods.getBalance(t).call()).then(function(e){return Promise.resolve(n.unitsToAmount(t,e)).then(function(e){o=e})})},function(e){n.logger.error("ERROR: Failed to get how many tokens are in the pool: "+e.message)});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.isFinalized=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.isFinalized().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to check whether pool is finalized: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getSwapFee=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getSwapFee().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){t.logger.error("ERROR: Failed to get pool fee: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getNormalizedWeight=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=K(function(){return Promise.resolve(n.methods.getNormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(e){r.logger.error("ERROR: Failed to get normalized weight of a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getDenormalizedWeight=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=K(function(){return Promise.resolve(n.methods.getDenormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(){r.logger.error("ERROR: Failed to get denormalized weight of a token in pool")});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getTotalDenormalizedWeight=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=K(function(){return Promise.resolve(r.methods.getTotalDenormalizedWeight().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(){t.logger.error("ERROR: Failed to get total denormalized weight in pool")});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getMarketFees=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=K(function(){return Promise.resolve(n.methods.publishMarketFees(t).call()).then(function(e){return Promise.resolve(r.unitsToAmount(t,e)).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to get market fees for a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getCurrentMarketFees=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(K(function(){return Promise.resolve(r.methods.getCurrentOPFFees().call())},function(e){t.logger.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},t.getCurrentOPFFees=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(K(function(){return Promise.resolve(r.methods.getCurrentOPFFees().call())},function(e){t.logger.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},t.getCommunityFees=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=K(function(){return Promise.resolve(n.methods.communityFees(t).call()).then(function(e){return Promise.resolve(r.unitsToAmount(t,e)).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to get community fees for a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.estCollectOPF=function(e,t,r){try{var n,o=this,i=r||O(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,a=K(function(){return Promise.resolve(i.methods.collectOPF().estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectOPF=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.poolAbi,t),r.config),o=null;return Promise.resolve(r.estCollectOPF(e,t)).then(function(t){var i=K(function(){var i=n.methods.collectOPF(),s=i.send;return Promise.resolve(M(r.web3,r.config)).then(function(r){return Promise.resolve(s.call(i,{from:e,gas:t+1,gasPrice:r})).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return i&&i.then?i.then(function(){return o}):o})}catch(e){return Promise.reject(e)}},t.estCollectMarketFee=function(e,t,r){try{var n,o=this,i=r||O(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,a=K(function(){return Promise.resolve(i.methods.collectMarketFee().estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getMarketFeeCollector(t)).then(function(n){if(n!==e)throw new Error("Caller is not MarketFeeCollector");var o=O(new r.web3.eth.Contract(r.poolAbi,t),r.config),i=null;return Promise.resolve(r.estCollectMarketFee(e,t)).then(function(t){var n=K(function(){var n=o.methods.collectMarketFee(),s=n.send;return Promise.resolve(M(r.web3,r.config)).then(function(r){return Promise.resolve(s.call(n,{from:e,gas:t+1,gasPrice:r})).then(function(e){i=e})})},function(e){r.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return n&&n.then?n.then(function(){return i}):i})})}catch(e){return Promise.reject(e)}},t.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=i.GASLIMIT_DEFAULT,c=K(function(){return Promise.resolve(s.methods.updateMarketFeeCollector(r).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.getMarketFeeCollector(t)).then(function(o){if(o!==e)throw new Error("Caller is not MarketFeeCollector");var i=O(new n.web3.eth.Contract(n.poolAbi,t),n.config),s=null;return Promise.resolve(n.estUpdateMarketFeeCollector(e,t,r)).then(function(t){var o=K(function(){var o=i.methods.updateMarketFeeCollector(r),a=o.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(o,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){n.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return o&&o.then?o.then(function(){return s}):s})})}catch(e){return Promise.reject(e)}},t.amountToUnits=function(e,t){try{var r=this;return Promise.resolve(K(function(){var n=O(new r.web3.eth.Contract(C.default.abi,e),r.config);return Promise.resolve(n.methods.decimals().call()).then(function(e){"0"===e&&(e=18);var r=new p.default(parseInt(t)*Math.pow(10,e));return p.default.config({EXPONENTIAL_AT:50}),r.toString()})},function(){r.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t){try{var r=this;return Promise.resolve(K(function(){var n=O(new r.web3.eth.Contract(C.default.abi,e),r.config);return Promise.resolve(n.methods.decimals().call()).then(function(e){return"0"===e&&(e=18),new p.default(parseInt(t)/Math.pow(10,e)).toString()})},function(){r.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},t.estSwapExactAmountIn=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=n.maxPrice?s.web3.utils.toWei(n.maxPrice):Y,u=s.GASLIMIT_DEFAULT,l=K(function(){return Promise.resolve(a.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,c,s.web3.utils.toWei(n.swapMarketFee)]).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){i=e})},function(){i=u});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.swapExactAmountIn=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.poolAbi,t),o.config);return Promise.resolve(o.amountToUnits(r.tokenIn,n.tokenAmountIn)).then(function(s){return n.tokenAmountIn=s,Promise.resolve(o.amountToUnits(r.tokenOut,n.minAmountOut)).then(function(s){n.minAmountOut=s;var a=null;return Promise.resolve(o.estSwapExactAmountIn(e,t,r,n)).then(function(t){var s=n.maxPrice?o.web3.utils.toWei(n.maxPrice):Y,c=K(function(){var c=i.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,s,o.web3.utils.toWei(n.swapMarketFee)]),u=c.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){o.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return c&&c.then?c.then(function(){return a}):a})})})}catch(e){return Promise.reject(e)}},t.estSwapExactAmountOut=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=n.maxPrice?s.web3.utils.toWei(n.maxPrice):Y,l=K(function(){return Promise.resolve(a.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.maxAmountIn,n.tokenAmountOut,u,s.web3.utils.toWei(n.swapMarketFee)]).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.swapExactAmountOut=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=null;return Promise.resolve(o.amountToUnits(r.tokenIn,n.maxAmountIn)).then(function(a){return n.maxAmountIn=a,Promise.resolve(o.amountToUnits(r.tokenOut,n.tokenAmountOut)).then(function(a){return n.tokenAmountOut=a,Promise.resolve(o.estSwapExactAmountOut(e,t,r,n)).then(function(t){var a=n.maxPrice?o.web3.utils.toWei(n.maxPrice):Y,c=K(function(){var c=i.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.maxAmountIn,n.tokenAmountOut,a,o.web3.utils.toWei(n.swapMarketFee)]),u=c.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){o.logger.error("ERROR: Failed to swap exact amount out: "+e.message)});return c&&c.then?c.then(function(){return s}):s})})})}catch(e){return Promise.reject(e)}},t.estJoinPool=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=K(function(){return Promise.resolve(a.methods.joinPool(r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.joinPool=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(a){function c(){var n=null;return Promise.resolve(o.estJoinPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var a=K(function(){var a=i.methods.joinPool(o.web3.utils.toWei(r),s),c=a.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(c.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){n=e})})},function(e){o.logger.error("ERROR: Failed to join pool: "+e.message)});return a&&a.then?a.then(function(){return n}):n})}var u=0,l=ne(function(){return u<2},function(){return u++},function(){return Promise.resolve(o.amountToUnits(a[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(c):c()})}catch(e){return Promise.reject(e)}},t.estExitPool=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=K(function(){return Promise.resolve(a.methods.exitPool(r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.exitPool=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(a){function c(){var n=null;return Promise.resolve(o.estExitPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var a=K(function(){var a=i.methods.exitPool(o.web3.utils.toWei(r),s),c=a.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(c.call(a,{from:e,gas:t,gasPrice:r})).then(function(e){n=e})})},function(e){o.logger.error("ERROR: Failed to exit pool: "+e.message)});return a&&a.then?a.then(function(){return n}):n})}var u=0,l=ne(function(){return u<2},function(){return u++},function(){return Promise.resolve(o.amountToUnits(a[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(c):c()})}catch(e){return Promise.reject(e)}},t.estJoinswapExternAmountIn=function(e,t,r,n,o,i){try{var s,a=this,c=i||O(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=K(function(){return Promise.resolve(c.methods.joinswapExternAmountIn(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.joinswapExternAmountIn=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(i.amountToUnits(r,n)).then(function(n){return Promise.resolve(i.estJoinswapExternAmountIn(e,t,r,n,i.web3.utils.toWei(o))).then(function(t){var c=K(function(){var c=s.methods.joinswapExternAmountIn(r,n,i.web3.utils.toWei(o)),u=c.send;return Promise.resolve(M(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){i.logger.error("ERROR: Failed to pay tokens in order to join the pool: "+e.message)});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estJoinswapPoolAmountOut=function(e,t,r,n,o,i){try{var s,a=this,c=i||O(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=K(function(){return Promise.resolve(c.methods.joinswapPoolAmountOut(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.joinswapPoolAmountOut=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(i.amountToUnits(r,o)).then(function(o){return Promise.resolve(i.estJoinswapPoolAmountOut(e,t,r,i.web3.utils.toWei(n),o)).then(function(t){var c=K(function(){var c=s.methods.joinswapPoolAmountOut(r,i.web3.utils.toWei(n),o),u=c.send;return Promise.resolve(M(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(){i.logger.error("ERROR: Failed to join swap pool amount out")});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estExitswapPoolAmountIn=function(e,t,r,n,o,i){try{var s,a=this,c=i||O(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=K(function(){return Promise.resolve(c.methods.exitswapPoolAmountIn(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.exitswapPoolAmountIn=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(i.amountToUnits(r,o)).then(function(o){return Promise.resolve(i.estExitswapPoolAmountIn(e,t,r,i.web3.utils.toWei(n),o)).then(function(t){var c=K(function(){var c=s.methods.exitswapPoolAmountIn(r,i.web3.utils.toWei(n),o),u=c.send;return Promise.resolve(M(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){i.logger.error("ERROR: Failed to pay pool shares into the pool: "+e.message)});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estExitswapExternAmountOut=function(e,t,r,n,o,i){try{var s,a=this,c=i||O(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=K(function(){return Promise.resolve(c.methods.exitswapExternAmountOut(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.exitswapExternAmountOut=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(i.estExitswapExternAmountOut(e,t,r,i.web3.utils.toWei(n),i.web3.utils.toWei(o))).then(function(t){var c=K(function(){var c=s.methods.exitswapExternAmountOut(r,i.web3.utils.toWei(n),i.web3.utils.toWei(o)),u=c.send;return Promise.resolve(M(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(){i.logger.error("ERROR: Failed to exitswapExternAmountOut")});return c&&c.then?c.then(function(){return a}):a})}catch(e){return Promise.reject(e)}},t.getSpotPrice=function(e,t,r,n){try{var o=function(){function e(){function e(){var e;return a>c?(e=a-c,o=new p.default(o/Math.pow(10,e)),o/=Math.pow(10,c)):(e=c-a,o=new p.default(o*Math.pow(10,2*e)),o/=Math.pow(10,c)),o.toString()}var o=null,u=K(function(){return Promise.resolve(s.methods.getSpotPrice(t,r,i.web3.utils.toWei(n)).call()).then(function(e){o=new p.default((o=e).toString())})},function(){i.logger.error("ERROR: Failed to get spot price of swapping tokenIn to tokenOut")});return u&&u.then?u.then(e):e()}var o=K(function(){return Promise.resolve(l.methods.decimals().call()).then(function(e){c=e})},function(){i.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return o&&o.then?o.then(e):e()},i=this,s=O(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=18,c=18,u=O(new i.web3.eth.Contract(C.default.abi,t),i.config),l=O(new i.web3.eth.Contract(C.default.abi,r),i.config),f=K(function(){return Promise.resolve(u.methods.decimals().call()).then(function(e){a=e})},function(){i.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(f&&f.then?f.then(o):o())}catch(e){return Promise.reject(e)}},t.getAmountInExactOut=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(i.amountToUnits(r,n)).then(function(e){var n=null,a=K(function(){return Promise.resolve(s.methods.getAmountInExactOut(t,r,e,i.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(i.unitsToAmount(t,e)).then(function(e){n=e})})},function(){i.logger.error("ERROR: Failed to calcInGivenOut")});return a&&a.then?a.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},t.getAmountOutExactIn=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(i.amountToUnits(t,n)).then(function(e){var n=null,a=K(function(){return Promise.resolve(s.methods.getAmountOutExactIn(t,r,e,i.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(i.unitsToAmount(r,e)).then(function(e){n=e})})},function(){i.logger.error("ERROR: Failed to calcOutGivenIn")});return a&&a.then?a.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},t.calcPoolOutGivenSingleIn=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=K(function(){var s=o.methods,a=s.calcPoolOutSingleIn;return Promise.resolve(n.amountToUnits(t,r)).then(function(r){return Promise.resolve(a.call(s,t,r).call()).then(function(t){return Promise.resolve(n.unitsToAmount(e,t)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate PoolOutGivenSingleIn : "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.calcSingleInGivenPoolOut=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null;return Promise.resolve(n.amountToUnits(e,r)).then(function(e){var r=K(function(){return Promise.resolve(o.methods.calcSingleInPoolOut(t,e).call()).then(function(e){return Promise.resolve(n.unitsToAmount(t,e)).then(function(e){i=e})})},function(e){n.logger.error("ERROR: Failed to calculate SingleInGivenPoolOut : "+e.message)});return r&&r.then?r.then(function(){return i}):i})}catch(e){return Promise.reject(e)}},t.calcSingleOutGivenPoolIn=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=K(function(){var s=o.methods,a=s.calcSingleOutPoolIn;return Promise.resolve(n.amountToUnits(e,r)).then(function(e){return Promise.resolve(a.call(s,t,e).call()).then(function(e){return Promise.resolve(n.unitsToAmount(t,e)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate SingleOutGivenPoolIn : "+e)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.calcPoolInGivenSingleOut=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=K(function(){var s=o.methods,a=s.calcPoolInSingleOut;return Promise.resolve(n.amountToUnits(t,r)).then(function(r){return Promise.resolve(a.call(s,t,r).call()).then(function(t){return Promise.resolve(n.unitsToAmount(e,t)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate PoolInGivenSingleOut : "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.getSwapEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_SWAP"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},t.getJoinEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_JOIN"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},t.getExitEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_EXIT"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},e}();function ie(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var se,ae=/*#__PURE__*/function(){function e(e,t,r,n){void 0===t&&(t=null),void 0===r&&(r=null),this.GASLIMIT_DEFAULT=1e6,this.web3=null,this.dispenserAddress=void 0,this.config=void 0,this.dispenserAbi=void 0,this.dispenserContract=void 0,this.web3=e,this.dispenserAddress=t,this.dispenserAbi=r||R.default.abi,this.config=n||Z[0],e&&(this.dispenserContract=O(new this.web3.eth.Contract(this.dispenserAbi,this.dispenserAddress),this.config))}var t=e.prototype;return t.status=function(e){try{var t,r=this,n=ie(function(){return Promise.resolve(r.dispenserContract.methods.status(e).call()).then(function(e){return e.maxTokens=r.web3.utils.fromWei(e.maxTokens),e.maxBalance=r.web3.utils.fromWei(e.maxBalance),e.balance=r.web3.utils.fromWei(e.balance),t=1,e})},function(){G.warn("No dispenser available for datatoken: "+e)});return Promise.resolve(n&&n.then?n.then(function(e){return t?e:null}):t?n:null)}catch(e){return Promise.reject(e)}},t.estGasCreate=function(e,t,r,n,o){try{var i,s=this,a=s.GASLIMIT_DEFAULT,c=ie(function(){return Promise.resolve(s.dispenserContract.methods.create(e,s.web3.utils.toWei(r),s.web3.utils.toWei(n),t,o).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.create=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.estGasCreate(e,t,r,n,o)).then(function(s){var a=i.dispenserContract.methods.create(e,i.web3.utils.toWei(r),i.web3.utils.toWei(n),t,o),c=a.send;return Promise.resolve(M(i.web3,i.config)).then(function(e){return Promise.resolve(c.call(a,{from:t,gas:s+1,gasPrice:e}))})})}catch(e){return Promise.reject(e)}},t.estGasActivate=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=ie(function(){return Promise.resolve(i.dispenserContract.methods.activate(e,i.web3.utils.toWei(t),i.web3.utils.toWei(r)).estimateGas({from:n},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.activate=function(e,t,r,n){try{var o,i=this,s=ie(function(){return Promise.resolve(i.estGasActivate(e,t,r,n)).then(function(s){var a=i.dispenserContract.methods.activate(e,i.web3.utils.toWei(t),i.web3.utils.toWei(r)),c=a.send;return Promise.resolve(M(i.web3,i.config)).then(function(e){return Promise.resolve(c.call(a,{from:n,gas:s+1,gasPrice:e})).then(function(e){return o=1,e})})})},function(e){G.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(s&&s.then?s.then(function(e){return o?e:null}):o?s:null)}catch(e){return Promise.reject(e)}},t.estGasDeactivate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ie(function(){return Promise.resolve(n.dispenserContract.methods.deactivate(e).estimateGas({from:t},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.deactivate=function(e,t){try{var r,n=this,o=ie(function(){return Promise.resolve(n.estGasDeactivate(e,t)).then(function(o){var i=n.dispenserContract.methods.deactivate(e),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(e){return Promise.resolve(s.call(i,{from:t,gas:o+1,gasPrice:e})).then(function(e){return r=1,e})})})},function(e){G.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},t.estGasSetAllowedSwapper=function(e,t,r){try{var n,o=this,i=o.GASLIMIT_DEFAULT,s=ie(function(){return Promise.resolve(o.dispenserContract.methods.setAllowedSwapper(e,r).estimateGas({from:t},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n,o=this,i=ie(function(){return Promise.resolve(o.estGasSetAllowedSwapper(e,t,r)).then(function(i){var s=o.dispenserContract.methods.setAllowedSwapper(e,r),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(e){return Promise.resolve(a.call(s,{from:t,gas:i+1,gasPrice:e})).then(function(e){return n=1,e})})})},function(e){G.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}},t.estGasDispense=function(e,t,r,n){void 0===r&&(r="1");try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=ie(function(){return Promise.resolve(i.dispenserContract.methods.dispense(e,i.web3.utils.toWei(r),n).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.dispense=function(e,t,r,n){void 0===r&&(r="1");try{var o=this;return Promise.resolve(o.estGasDispense(e,t,r,n)).then(function(i){var s,a=ie(function(){var a=o.dispenserContract.methods.dispense(e,o.web3.utils.toWei(r),n),c=a.send;return Promise.resolve(M(o.web3,o.config)).then(function(e){return Promise.resolve(c.call(a,{from:t,gas:i+1,gasPrice:e})).then(function(e){return s=1,e})})},function(e){G.error("ERROR: Failed to dispense tokens: "+e.message)});return a&&a.then?a.then(function(e){return s?e:null}):s?a:null})}catch(e){return Promise.reject(e)}},t.estGasOwnerWithdraw=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ie(function(){return Promise.resolve(n.dispenserContract.methods.ownerWithdraw(e).estimateGas({from:t},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.ownerWithdraw=function(e,t){try{var r=this;return Promise.resolve(r.estGasOwnerWithdraw(e,t)).then(function(n){var o,i=ie(function(){var i=r.dispenserContract.methods.ownerWithdraw(e),s=i.send;return Promise.resolve(M(r.web3,r.config)).then(function(e){return Promise.resolve(s.call(i,{from:t,gas:n+1,gasPrice:e})).then(function(e){return o=1,e})})},function(e){G.error("ERROR: Failed to withdraw tokens: "+e.message)});return i&&i.then?i.then(function(e){return o?e:null}):o?i:null})}catch(e){return Promise.reject(e)}},t.isDispensable=function(e,t,r,n){void 0===n&&(n="1");try{return Promise.resolve(this.status(e)).then(function(o){return!!o&&!1!==o.active&&Promise.resolve(t.balance(e,r)).then(function(e){return!(new F.default(e).greaterThanOrEqualTo(o.maxBalance)||new F.default(String(n)).greaterThan(o.maxTokens)||!new F.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},e}();function ce(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}exports.FixedRateCreateProgressStep=void 0,(se=exports.FixedRateCreateProgressStep||(exports.FixedRateCreateProgressStep={}))[se.CreatingExchange=0]="CreatingExchange",se[se.ApprovingDatatoken=1]="ApprovingDatatoken";var ue=/*#__PURE__*/function(){function e(e,t,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),this.GASLIMIT_DEFAULT=1e6,this.oceanAddress=null,this.fixedRateAddress=void 0,this.fixedRateExchangeAbi=void 0,this.fixedRateContract=void 0,this.web3=void 0,this.contract=null,this.config=void 0,this.ssAbi=void 0,this.web3=e,this.config=o||Z[0],this.fixedRateExchangeAbi=r||k.default.abi,this.oceanAddress=n,this.fixedRateAddress=t,this.contract=O(new this.web3.eth.Contract(this.fixedRateExchangeAbi,this.fixedRateAddress),this.config)}var t=e.prototype;return t.amountToUnits=function(e,t){try{var r=function(){return new p.default(parseInt(t)*Math.pow(10,n)).toString()},n=18,o=O(new this.web3.eth.Contract(C.default.abi,e),this.config),i=ce(function(){return Promise.resolve(o.methods.decimals().call()).then(function(e){n=e})},function(){G.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t){try{var r=function(){return new p.default(parseInt(t)/Math.pow(10,n)).toString()},n=18,o=O(new this.web3.eth.Contract(C.default.abi,e),this.config),i=ce(function(){return Promise.resolve(o.methods.decimals().call()).then(function(e){n=e})},function(){G.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.generateExchangeId=function(e,t,r){try{return Promise.resolve(this.contract.methods.generateExchangeId(e,t,r).call())}catch(e){return Promise.reject(e)}},t.estBuyDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,a=this.GASLIMIT_DEFAULT,c=ce(function(){return Promise.resolve(s.methods.buyDT(t,r.toString(),n.toString()).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyDT=function(e,t,r,n){try{var o=this,i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.datatoken,r)).then(function(r){var i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.baseToken,n)).then(function(n){return Promise.resolve(o.estBuyDT(e,t,r,n)).then(function(i){return ce(function(){var s=o.contract.methods.buyDT(t,r,n),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:i+1,gasPrice:t}))})},function(e){return G.error("ERROR: Failed to buy datatokens: "+e.message),null})})})})})})}catch(e){return Promise.reject(e)}},t.estSellDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,a=this.GASLIMIT_DEFAULT,c=ce(function(){return Promise.resolve(s.methods.sellDT(t,r,n).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.sellDT=function(e,t,r,n){try{var o=this,i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.datatoken,r)).then(function(r){var i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.baseToken,n)).then(function(n){return Promise.resolve(o.estBuyDT(e,t,r,n)).then(function(i){return ce(function(){var s=o.contract.methods.sellDT(t,r,n),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:i+1,gasPrice:t}))})},function(e){return G.error("ERROR: Failed to sell datatokens: "+e.message),null})})})})})})}catch(e){return Promise.reject(e)}},t.getNumberOfExchanges=function(){try{return Promise.resolve(this.contract.methods.getNumberOfExchanges().call())}catch(e){return Promise.reject(e)}},t.estSetRate=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=ce(function(){return Promise.resolve(i.methods.setRate(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setRate=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetRate(e,t,n.web3.utils.toWei(String(r)))).then(function(o){var i=n.contract.methods.setRate(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estSetAllowedSwapper=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=ce(function(){return Promise.resolve(i.methods.setRate(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetAllowedSwapper(e,t,r)).then(function(o){var i=n.contract.methods.setAllowedSwapper(t,r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estActivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.toggleExchangeState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.activate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!0===n.active?null:Promise.resolve(r.estActivate(e,t)).then(function(n){var o=r.contract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estDeactivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.toggleExchangeState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!1===n.active?null:Promise.resolve(r.estDeactivate(e,t)).then(function(n){var o=r.contract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.getRate=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getRate(e).call()).then(function(e){return t.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},t.getDTSupply=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getDTSupply(e).call()).then(function(r){var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(n.call(t,e.datatoken,r))})})}catch(e){return Promise.reject(e)}},t.getBTSupply=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getBTSupply(e).call()).then(function(r){var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(n.call(t,e.baseToken,r))})})}catch(e){return Promise.reject(e)}},t.getAllowedSwapper=function(e){try{return Promise.resolve(this.contract.methods.getAllowedSwapper(e).call())}catch(e){return Promise.reject(e)}},t.getAmountBTIn=function(e,t){try{var r=this,n=r.contract.methods,o=n.calcBaseInGivenOutDT,i=r.amountToUnits;return Promise.resolve(r.getExchange(e)).then(function(s){return Promise.resolve(i.call(r,s.datatoken,t)).then(function(t){return Promise.resolve(o.call(n,e,t).call()).then(function(t){var n=r.unitsToAmount;return Promise.resolve(r.getExchange(e)).then(function(e){return Promise.resolve(n.call(r,e.baseToken,t.baseTokenAmount))})})})})}catch(e){return Promise.reject(e)}},t.getAmountBTOut=function(e,t){try{var r=this,n=r.contract.methods,o=n.calcBaseOutGivenInDT,i=r.amountToUnits;return Promise.resolve(r.getExchange(e)).then(function(s){return Promise.resolve(i.call(r,s.datatoken,t)).then(function(t){return Promise.resolve(o.call(n,e,t).call()).then(function(t){var n=r.unitsToAmount;return Promise.resolve(r.getExchange(e)).then(function(e){return Promise.resolve(n.call(r,e.baseToken,t.baseTokenAmount))})})})})}catch(e){return Promise.reject(e)}},t.getExchange=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getExchange(e).call()).then(function(r){return r.dtDecimals=r.dtDecimals.toString(),r.btDecimals=r.btDecimals.toString(),Promise.resolve(t.unitsToAmount(r.datatoken,r.dtBalance)).then(function(n){return r.dtBalance=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btBalance)).then(function(n){return r.btBalance=n,Promise.resolve(t.unitsToAmount(r.datatoken,r.dtSupply)).then(function(n){return r.dtSupply=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply)).then(function(n){return r.btSupply=n,r.fixedRate=t.web3.utils.fromWei(r.fixedRate),r.exchangeId=e,r})})})})})}catch(e){return Promise.reject(e)}},t.getFeesInfo=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getFeesInfo(e).call()).then(function(r){r.opfFee=t.web3.utils.fromWei(r.opfFee.toString()),r.marketFee=t.web3.utils.fromWei(r.marketFee.toString());var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(o){return Promise.resolve(n.call(t,o.baseToken,r.marketFeeAvailable)).then(function(n){r.marketFeeAvailable=n;var o=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(n){return Promise.resolve(o.call(t,n.baseToken,r.oceanFeeAvailable)).then(function(t){return r.oceanFeeAvailable=t,r.exchangeId=e,r})})})})})}catch(e){return Promise.reject(e)}},t.getExchanges=function(){try{return Promise.resolve(this.contract.methods.getExchanges().call())}catch(e){return Promise.reject(e)}},t.isActive=function(e){try{return Promise.resolve(this.contract.methods.isActive(e).call())}catch(e){return Promise.reject(e)}},t.estActivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.toggleMintState(t,!0).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.activateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!0===n.withMint?null:Promise.resolve(r.estActivateMint(e,t)).then(function(n){var o=r.contract.methods.toggleMintState(t,!0),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estDeactivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.toggleMintState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.deactivateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!1===n.withMint?null:Promise.resolve(r.estDeactivate(e,t)).then(function(n){var o=r.contract.methods.toggleMintState(t,!1),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectBT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.collectBT(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectBT=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectBT(e,t)).then(function(n){var o=r.contract.methods.collectBT(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectDT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.collectDT(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectDT=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectDT(e,t)).then(function(n){var o=r.contract.methods.collectDT(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectMarketFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.collectMarketFee(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectMarketFee(e,t)).then(function(n){var o=r.contract.methods.collectMarketFee(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectOceanFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ce(function(){return Promise.resolve(o.methods.collectMarketFee(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectOceanFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectOceanFee(e,t)).then(function(n){var o=r.contract.methods.collectOceanFee(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.getOPFCollector=function(){try{var e=this,t=null,r=ce(function(){return Promise.resolve(e.contract.methods.opfCollector().call()).then(function(e){t=e})},function(e){G.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(r&&r.then?r.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},t.getRouter=function(){try{var e=this,t=null,r=ce(function(){return Promise.resolve(e.contract.methods.router().call()).then(function(e){t=e})},function(e){G.error("ERROR: Failed to get Router address: "+e.message)});return Promise.resolve(r&&r.then?r.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},t.getExchangeOwner=function(e){try{var t=this,r=null,n=ce(function(){return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(e.exchangeOwner).then(function(e){r=e})})},function(e){G.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(n&&n.then?n.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.estUpdateMarketFee=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=ce(function(){return Promise.resolve(i.methods.updateMarketFee(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFee=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetRate(e,t,n.web3.utils.toWei(r))).then(function(o){var i=n.contract.methods.updateMarketFee(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=ce(function(){return Promise.resolve(i.methods.updateMarketFeeCollector(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.estUpdateMarketFeeCollector(e,t,r)).then(function(o){var i=n.contract.methods.updateMarketFeeCollector(t,r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},e}();function le(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var fe=/*#__PURE__*/function(){function e(e,t,r){this.GASLIMIT_DEFAULT=1e6,this.factory721Address=void 0,this.factory721Abi=void 0,this.nftAbi=void 0,this.web3=void 0,this.startBlock=void 0,this.config=void 0,this.nftAbi=t||j.default.abi,this.web3=e,this.config=r||Z[0]}var t=e.prototype;return t.estGasCreateErc20=function(e,t,r,n,o,i,s,a,c,u,l,f){try{var h,m=this,v=f||O(new m.web3.eth.Contract(m.nftAbi,e),m.config),d=m.GASLIMIT_DEFAULT,P=le(function(){return Promise.resolve(v.methods.createERC20(l,[c,u],[r,n,o,i],[m.web3.utils.toWei(a),m.web3.utils.toWei(s)],[]).estimateGas({from:t},function(e,t){return e?d:t})).then(function(e){h=e})},function(){h=d});return Promise.resolve(P&&P.then?P.then(function(){return h}):h)}catch(e){return Promise.reject(e)}},t.createErc20=function(e,t,r,n,o,i,s,a,c,u,l){try{var f=this;return Promise.resolve(f.getNftPermissions(e,t)).then(function(h){if(!0!==h.deployERC20)throw new Error("Caller is not ERC20Deployer");if(l||(l=1),!c||!u){var m=U();c=m.name,u=m.symbol}var v=O(new f.web3.eth.Contract(f.nftAbi,e),f.config);return Promise.resolve(f.estGasCreateErc20(e,t,r,n,o,i,s,a,c,u,l,v)).then(function(e){var h=v.methods.createERC20(l,[c,u],[r,n,o,i],[f.web3.utils.toWei(a),f.web3.utils.toWei(s)],[]),m=h.send;return Promise.resolve(M(f.web3,f.config)).then(function(r){return Promise.resolve(m.call(h,{from:t,gas:e+1,gasPrice:r})).then(function(e){var t=null;try{t=e.events.TokenCreated.returnValues[0]}catch(e){G.error("ERROR: Failed to create datatoken : "+e.message)}return t})})})})}catch(e){return Promise.reject(e)}},t.estGasAddManager=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.addManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addManager=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(i){if(i!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(n.estGasAddManager(e,t,r,o)).then(function(e){var i=o.methods.addManager(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveManager=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.removeManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeManager=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(i){if(i!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(n.estGasRemoveManager(e,t,r,o)).then(function(e){var i=o.methods.removeManager(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasAddErc20Deployer=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.addToCreateERC20List(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addErc20Deployer=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddErc20Deployer(e,t,r,o)).then(function(e){var i=o.methods.addToCreateERC20List(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveErc20Deployer=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.removeFromCreateErc20List(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeErc20Deployer=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t===r&&!0!==i.deployERC20)throw new Error("Caller is not Manager nor ERC20Deployer");return Promise.resolve(n.estGasRemoveErc20Deployer(e,t,r,o)).then(function(e){var i=o.methods.removeFromCreateERC20List(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t!==r?s(a||t===r&&n.getNftPermissions(e,t)):Promise.resolve(a||t===r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasAddMetadataUpdater=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.addToMetadataList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMetadataUpdater=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddMetadataUpdater(e,t,r,o)).then(function(e){var i=o.methods.addToMetadataList(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.esGasRemoveMetadataUpdater=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.removeFromMetadataList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMetadataUpdater=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t!==r&&!0!==i.updateMetadata)throw new Error("Caller is not Manager nor Metadata Updater");return Promise.resolve(n.esGasRemoveMetadataUpdater(e,t,r,o)).then(function(e){var i=o.methods.removeFromMetadataList(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t===r?s(a||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(a||t!==r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasAddStoreUpdater=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.addTo725StoreList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addStoreUpdater=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddStoreUpdater(e,t,r,o)).then(function(e){var i=o.methods.addTo725StoreList(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveStoreUpdater=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.removeFrom725StoreList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeStoreUpdater=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t!==r&&!0!==i.store)throw new Error("Caller is not Manager nor storeUpdater");return Promise.resolve(n.estGasRemoveStoreUpdater(e,t,r,o)).then(function(e){var i=o.methods.removeFrom725StoreList(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t===r?s(a||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(a||t!==r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasCleanPermissions=function(e,t,r){try{var n,o=this,i=r||O(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=le(function(){return Promise.resolve(i.methods.cleanPermissions().estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(r.getNftOwner(e)).then(function(o){if(o!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(r.estGasCleanPermissions(e,t,n)).then(function(e){var o=n.methods.cleanPermissions(),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(r){return Promise.resolve(i.call(o,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasTransferNft=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.nftAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=le(function(){return Promise.resolve(a.methods.transferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.transferNft=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(s){if(s!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(o.estGasTransferNft(e,t,r,a,i)).then(function(e){var n=i.methods.transferFrom(t,r,a),s=n.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(s.call(n,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSafeTransferNft=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.nftAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=le(function(){return Promise.resolve(a.methods.safeTransferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.safeTransferNft=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(s){if(s!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(o.estGasSafeTransferNft(e,t,r,a,i)).then(function(e){var n=i.methods.safeTransferFrom(t,r,a),s=n.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(s.call(n,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l,f=this,h=u||O(new f.web3.eth.Contract(f.nftAbi,e),f.config),m=f.GASLIMIT_DEFAULT,v=le(function(){return Promise.resolve(h.methods.setMetaData(r,n,o,i,s,a,c).estimateGas({from:t},function(e,t){return e?m:t})).then(function(e){l=e})},function(){l=m});return Promise.resolve(v&&v.then?v.then(function(){return l}):l)}catch(e){return Promise.reject(e)}},t.setMetadata=function(e,t,r,n,o,i,s,a,c){try{var u=this,l=O(new u.web3.eth.Contract(u.nftAbi,e),u.config);return c||(c=[]),Promise.resolve(u.getNftPermissions(e,t)).then(function(f){if(!f.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(u.estGasSetMetadata(e,t,r,n,o,i,s,a,c,l)).then(function(e){var f=l.methods.setMetaData(r,n,o,i,s,a,c),h=f.send;return Promise.resolve(M(u.web3,u.config)).then(function(r){return Promise.resolve(h.call(f,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadataState=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=le(function(){return Promise.resolve(s.methods.setMetaDataState(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setMetadataState=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!i.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(n.estGasSetMetadataState(e,t,r)).then(function(e){var i=o.methods.setMetaDataState(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estSetTokenURI=function(e,t,r){try{var n,o=this,i=O(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=le(function(){return Promise.resolve(i.methods.setTokenURI("1",r).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.setTokenURI=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.estSetTokenURI(e,t,r)).then(function(e){var i=o.methods.setTokenURI("1",r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}catch(e){return Promise.reject(e)}},t.getNftOwner=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.nftAbi,e),t.config);return Promise.resolve(r.methods.ownerOf(1).call())}catch(e){return Promise.reject(e)}},t.getNftPermissions=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.getPermissions(t).call())}catch(e){return Promise.reject(e)}},t.getMetadata=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.nftAbi,e),t.config);return Promise.resolve(r.methods.getMetaData().call())}catch(e){return Promise.reject(e)}},t.isErc20Deployer=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.isERC20Deployer(t).call())}catch(e){return Promise.reject(e)}},t.getData=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.getData(t).call())}catch(e){return Promise.reject(e)}},t.getTokenURI=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.tokenURI(t).call())}catch(e){return Promise.reject(e)}},e}();function he(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var me=/*#__PURE__*/function(){function e(e,t,r,n){this.GASLIMIT_DEFAULT=1e6,this.factoryAddress=void 0,this.factoryABI=void 0,this.datatokensAbi=void 0,this.datatokensEnterpriseAbi=void 0,this.web3=void 0,this.config=void 0,this.nft=void 0,this.web3=e,this.datatokensAbi=t||C.default.abi,this.datatokensEnterpriseAbi=r||I.default.abi,this.config=n||Z[0],this.nft=new fe(this.web3)}var t=e.prototype;return t.estGasApprove=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(a.methods.approve(t,s.web3.utils.toWei(r)).estimateGas({from:n},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.approve=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(o.estGasApprove(e,t,r,n,i)).then(function(e){var s=i.methods.approve(t,o.web3.utils.toWei(r)),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:n,gas:e+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasMint=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(a.methods.mint(n||t,s.web3.utils.toWei(r)).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.estGasCreateFixedRate=function(e,t,r,n){try{var o=this,i=n||O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT;r.allowedConsumer||(r.allowedConsumer="0x0000000000000000000000000000000000000000");var a,c=r.withMint?1:0,u=he(function(){return Promise.resolve(i.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,t,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,c]).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){a=e})},function(){a=s});return Promise.resolve(u&&u.then?u.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},t.createFixedRate=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!i)throw new Error("User is not ERC20 Deployer");r.allowedConsumer||(r.allowedConsumer="0x0000000000000000000000000000000000000000");var s=r.withMint?1:0;return Promise.resolve(n.estGasCreateFixedRate(e,t,r,o)).then(function(e){var i=o.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,s]),a=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasCreateDispenser=function(e,t,r,n,o){try{var i=this,s=o||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);n.allowedSwapper||(n.allowedSwapper="0x0000000000000000000000000000000000000000"),n.withMint||(n.withMint=!1);var a,c=i.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){a=e})},function(){a=c});return Promise.resolve(u&&u.then?u.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},t.createDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isERC20Deployer(e,t)).then(function(i){if(!i)throw new Error("User is not ERC20 Deployer");var s=O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return n.allowedSwapper||(n.allowedSwapper="0x0000000000000000000000000000000000000000"),n.withMint||(n.withMint=!1),Promise.resolve(o.estGasCreateDispenser(e,t,r,n,s)).then(function(e){var i=s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper),a=i.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.mint=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(o.getDTPermissions(e,t)).then(function(s){if(!0!==s.minter)throw new Error("Caller is not Minter");return Promise.resolve(o.getCap(e)).then(function(s){if(new F.default(s).gte(r))return Promise.resolve(o.estGasMint(e,t,r,n,i)).then(function(e){var s=i.methods.mint(n||t,o.web3.utils.toWei(r)),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},t.estGasAddMinter=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.addMinter(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMinter=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasAddMinter(e,t,r,o)).then(function(e){var i=o.methods.addMinter(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveMinter=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.removeMinter(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMinter=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasRemoveMinter(e,t,r,o)).then(function(e){var i=o.methods.removeMinter(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasAddPaymentManager=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.addPaymentManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addPaymentManager=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasAddPaymentManager(e,t,r,o)).then(function(e){var i=o.methods.addPaymentManager(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemovePaymentManager=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.removePaymentManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removePaymentManager=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasRemovePaymentManager(e,t,r,o)).then(function(e){var i=o.methods.removePaymentManager(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetPaymentCollector=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.setPaymentCollector(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setPaymentCollector=function(e,t,r){try{var n=this,o=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.getDTPermissions(e,t)).then(function(i){if(!0!==i.paymentManager)throw new Error("Caller is not Fee Manager");return Promise.resolve(n.estGasSetPaymentCollector(e,t,r,o)).then(function(e){var i=o.methods.setPaymentCollector(r),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.getPaymentCollector=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.getPaymentCollector().call())}catch(e){return Promise.reject(e)}},t.transfer=function(e,t,r,n){try{var o=this.web3.utils.toWei(r);return Promise.resolve(this.transferWei(e,t,o,n))}catch(e){return Promise.reject(e)}},t.estGasTransfer=function(e,t,r,n,o){try{var i,s=this,a=o||O(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(a.methods.transfer(t,r).estimateGas({from:n},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.transferWei=function(e,t,r,n){try{var o=this,i=O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(he(function(){return Promise.resolve(o.estGasTransfer(e,t,r,n,i)).then(function(e){var s=i.methods.transfer(t,r),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:n,gas:e+1,gasPrice:t}))})})},function(e){throw G.error("ERROR: Failed to transfer tokens: "+e.message),new Error("Failed Failed to transfer tokens: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasStartOrder=function(e,t,r,n,o,i){try{var s,a=this,c=i||O(new a.web3.eth.Contract(a.datatokensAbi,e),a.config),u=a.GASLIMIT_DEFAULT,l=he(function(){return Promise.resolve(c.methods.startOrder(r,n,o).estimateGas({from:t},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.startOrder=function(e,t,r,n,o){try{var i=this,s=O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(he(function(){return Promise.resolve(i.estGasStartOrder(e,t,r,n,o,s)).then(function(e){var a=s.methods.startOrder(r,n,o),c=a.send;return Promise.resolve(M(i.web3,i.config)).then(function(r){return Promise.resolve(c.call(a,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw G.error("ERROR: Failed to start order : "+e.message),new Error("Failed to start order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasBuyFromFreAndOrder=function(e,t,r,n,o){try{var i,s=this,a=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),c=s.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(a.methods.buyFromFreAndOrder(r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=new o.web3.eth.Contract(o.datatokensEnterpriseAbi,e);return Promise.resolve(he(function(){return Promise.resolve(o.estGasBuyFromFreAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromFreAndOrder(r,n),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw G.error("ERROR: Failed to buy DT From Fre And Order : "+e.message),new Error("Failed to buy DT From Fre And Order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasBuyFromDispenserAndOrder=function(e,t,r,n,o){try{var i,s=this,a=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),c=s.GASLIMIT_DEFAULT,u=he(function(){return Promise.resolve(a.methods.buyFromDispenserAndOrder(r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=new o.web3.eth.Contract(o.datatokensEnterpriseAbi,e);return Promise.resolve(he(function(){return Promise.resolve(o.estGasBuyFromDispenserAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromDispenserAndOrder(r,n),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw G.error("ERROR: Failed to buy DT From Fre And Order : "+e.message),new Error("Failed to buy DT From Fre And Order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasSetData=function(e,t,r,n){try{var o,i=this,s=n||O(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.setData(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setData=function(e,t,r){try{var n=this;return Promise.resolve(n.isERC20Deployer(e,t)).then(function(o){if(!o)throw new Error("User is not ERC20 Deployer");var i=O(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.estGasSetData(e,t,r,i)).then(function(e){var o=i.methods.setData(r),s=o.send;return Promise.resolve(M(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(o,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasCleanPermissions=function(e,t,r){try{var n,o=this,i=r||O(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=he(function(){return Promise.resolve(i.methods.cleanPermissions().estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=r.nft,o=n.getNftOwner;return Promise.resolve(r.getNFTAddress(e)).then(function(i){return Promise.resolve(o.call(n,i)).then(function(n){if(n!==t)throw new Error("Caller is NOT Nft Owner");var o=O(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(r.estGasCleanPermissions(e,t,o)).then(function(e){var n=o.methods.cleanPermissions(),i=n.send;return Promise.resolve(M(r.web3,r.config)).then(function(r){return Promise.resolve(i.call(n,{from:t,gas:e+1,gasPrice:r}))})})})})}catch(e){return Promise.reject(e)}},t.getDTPermissions=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(n.methods.permissions(t).call())}catch(e){return Promise.reject(e)}},t.getCap=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.cap().call()).then(function(e){return t.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},t.getDecimals=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.decimals().call())}catch(e){return Promise.reject(e)}},t.getNFTAddress=function(e){try{var t=this,r=O(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.getERC721Address().call())}catch(e){return Promise.reject(e)}},t.isERC20Deployer=function(e,t){try{var r=this,n=O(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(n.methods.isERC20Deployer(t).call())}catch(e){return Promise.reject(e)}},t.balance=function(e,t){try{var r=this,n=new r.web3.eth.Contract(r.datatokensAbi,e,{from:t});return Promise.resolve(n.methods.balanceOf(t).call()).then(function(e){return r.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},e}();function ve(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var de="0x0000000000000000000000000000000000000000",Pe=/*#__PURE__*/function(){function e(e,t,r,n){this.GASLIMIT_DEFAULT=1e6,this.factory721Address=void 0,this.factory721Abi=void 0,this.web3=void 0,this.config=void 0,this.factory721=void 0,this.factory721Address=e,this.factory721Abi=r||S.default.abi,this.web3=t,this.config=n||Z[0],this.factory721=O(new this.web3.eth.Contract(this.factory721Abi,this.factory721Address),this.config)}var t=e.prototype;return t.estGasCreateNFT=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,de,t.tokenURI).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.createNFT=function(e,t){try{var r=this;if(t.templateIndex||(t.templateIndex=1),!t.name||!t.symbol){var n=U(),o=n.symbol;t.name=n.name,t.symbol=o}var i=t.templateIndex;return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(i>n)throw new Error("Template index doesnt exist");if(0===t.templateIndex)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(t.templateIndex)).then(function(n){if(!1===n.isActive)throw new Error("Template is not active");return Promise.resolve(r.estGasCreateNFT(e,t)).then(function(n){var o=r.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,de,t.tokenURI),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t})).then(function(e){var t=null;try{t=e.events.NFTCreated.returnValues[0]}catch(e){G.error("ERROR: Failed to create datatoken : "+e.message)}return t})})})})})}catch(e){return Promise.reject(e)}},t.getCurrentNFTCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTCount().call())}catch(e){return Promise.reject(e)}},t.getCurrentTokenCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTokenCount().call())}catch(e){return Promise.reject(e)}},t.getOwner=function(){try{return Promise.resolve(this.factory721.methods.owner().call())}catch(e){return Promise.reject(e)}},t.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTTemplateCount().call())}catch(e){return Promise.reject(e)}},t.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTemplateCount().call())}catch(e){return Promise.reject(e)}},t.getNFTTemplate=function(e){try{var t=this;return Promise.resolve(t.getCurrentNFTTemplateCount()).then(function(r){if(e>r)throw new Error("Template index doesnt exist");if(0===e)throw new Error("Template index cannot be ZERO");return Promise.resolve(t.factory721.methods.getNFTTemplate(e).call())})}catch(e){return Promise.reject(e)}},t.getTokenTemplate=function(e){try{return Promise.resolve(this.factory721.methods.getTokenTemplate(e).call())}catch(e){return Promise.reject(e)}},t.checkDatatoken=function(e){try{return Promise.resolve(this.factory721.methods.erc20List(e).call())}catch(e){return Promise.reject(e)}},t.checkNFT=function(e){try{return Promise.resolve(this.factory721.methods.erc721List(e).call())}catch(e){return Promise.reject(e)}},t.estGasAddNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.add721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.addNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");if(t===de)throw new Error("Template cannot be ZERO address");return Promise.resolve(r.estGasAddNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.add721TokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},t.estGasDisableNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.disable721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.disableNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.estGasDisableNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.disable721TokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})}catch(e){return Promise.reject(e)}},t.estGasReactivateNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.reactivate721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.reactivateNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.estGasReactivateNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.reactivate721TokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})}catch(e){return Promise.reject(e)}},t.estGasAddTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.addTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.addTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");if(t===de)throw new Error("Template cannot be address ZERO");return Promise.resolve(r.estGasAddTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.addTokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},t.estGasDisableTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.disableTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.disableTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(t)).then(function(n){if(!1===n.isActive)throw new Error("Template is already disabled");return Promise.resolve(r.estGasDisableTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.disableTokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})})}catch(e){return Promise.reject(e)}},t.estGasReactivateTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.reactivateTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.reactivateTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getTokenTemplate(t)).then(function(n){if(!0===n.isActive)throw new Error("Template is already active");return Promise.resolve(r.estGasReactivateTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.reactivateTokenTemplate(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})})}catch(e){return Promise.reject(e)}},t.estGasStartMultipleTokenOrder=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ve(function(){return Promise.resolve(n.factory721.methods.startMultipleTokenOrder(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.startMultipleTokenOrder=function(e,t){try{var r=this;if(t.length>50)throw new Error("Too many orders");return Promise.resolve(r.estGasStartMultipleTokenOrder(e,t)).then(function(n){var o=r.factory721.methods.startMultipleTokenOrder(t),i=o.send;return Promise.resolve(M(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftWithErc=function(e,t,r){try{var n,o=this,i=o.GASLIMIT_DEFAULT,s=ve(function(){var s=D(r);return Promise.resolve(o.factory721.methods.createNftWithErc(t,s).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.createNftWithErc=function(e,t,r){try{var n=this,o=D(r);return Promise.resolve(n.estGasCreateNftWithErc(e,t,r)).then(function(r){var i=n.factory721.methods.createNftWithErc(t,o),s=i.send;return Promise.resolve(M(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithPool=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=ve(function(){var a=D(r),c=W(n);return Promise.resolve(i.factory721.methods.createNftErcWithPool(t,a,c).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithPool=function(e,t,r,n){try{var o=this;return Promise.resolve(o.estGasCreateNftErcWithPool(e,t,r,n)).then(function(i){var s=D(r),a=W(n),c=o.factory721.methods.createNftErcWithPool(t,s,a),u=c.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(u.call(c,{from:e,gas:i+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithFixedRate=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=D(r),c=N(n),u=ve(function(){return Promise.resolve(i.factory721.methods.createNftErcWithFixedRate(t,a,c).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(u&&u.then?u.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithFixedRate=function(e,t,r,n){try{var o=this,i=D(r),s=N(n);return Promise.resolve(o.estGasCreateNftErcWithFixedRate(e,t,r,n)).then(function(r){var n=o.factory721.methods.createNftErcWithFixedRate(t,i,s),a=n.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(n,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithDispenser=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=D(r),c=ve(function(){return Promise.resolve(i.factory721.methods.createNftErcWithDispenser(t,a,n).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(e){o=s,G.error("Failed to estimate gas for createNftErcWithDispenser",e)});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithDispenser=function(e,t,r,n){try{var o=this,i=D(r);return Promise.resolve(o.estGasCreateNftErcWithDispenser(e,t,r,n)).then(function(r){var s=o.factory721.methods.createNftErcWithDispenser(t,i,n),a=s.send;return Promise.resolve(M(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},e}(),ge=function(e){return function(e,t){void 0===e&&(e="");var r=function(e,t,r){if("string"!=typeof e)throw G.debug("Not input string:"),G.debug(e),new Error("[zeroXTransformer] Expected string, input type: "+typeof e);var n=e.match(/^(?:0x)*([a-f0-9]+)$/i);return n?{valid:!0,output:n[1]}:(G.warn("[zeroXTransformer] Input transformation failed."),{valid:!1,output:e})}(e);return""+r.output}(e)};function pe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var we=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getEndpoints=function(e){try{return Promise.resolve(pe(function(){return Promise.resolve(B(e)).then(function(e){return Promise.resolve(e.json())})},function(e){return G.error("Finding the service endpoints failed:",e),null}))}catch(e){return Promise.reject(e)}},t.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName===t}):null},t.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints)r.push({serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e+t.serviceEndpoints[n][1]});return Promise.resolve(r)}catch(e){return Promise.reject(e)}},t.getNonce=function(e,t,r,n,o){try{var i=function(){function r(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?pe(function(){return Promise.resolve(a("GET",e+"?userAddress="+t,null,{"Content-Type":"application/json"})).then(function(e){var t=String;return Promise.resolve(e.json()).then(function(e){return t(e.nonce)})})},function(e){throw G.error(e),new Error("HTTP request failed")}):null}var i=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return i&&i.then?i.then(r):r()},s=this,a=r||_,c=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(c&&c.then?c.then(i):i())}catch(e){return Promise.reject(e)}},t.createSignature=function(e,t,r){try{return Promise.resolve($(e,ge(r),t))}catch(e){return Promise.reject(e)}},t.createHashSignature=function(e,t,r){try{return Promise.resolve(X(e,r,t))}catch(e){return Promise.reject(e)}},t.encrypt=function(e,t,r){try{var n=this,o=r||_;return Promise.resolve(n.getEndpoints(t)).then(function(r){return Promise.resolve(n.getServiceEndpoints(t,r)).then(function(t){var r=n.getEndpointURL(t,"encrypt")?n.getEndpointURL(t,"encrypt").urlPath:null;return r?pe(function(){return Promise.resolve(o("POST",r,decodeURI(JSON.stringify(e)),{"Content-Type":"application/octet-stream"}))},function(e){throw G.error(e),new Error("HTTP request failed")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n){try{var o=this,i=n||_;return Promise.resolve(o.getEndpoints(r)).then(function(n){return Promise.resolve(o.getServiceEndpoints(r,n)).then(function(r){var n={did:e,serviceId:t},s=[],a=o.getEndpointURL(r,"fileinfo")?o.getEndpointURL(r,"fileinfo").urlPath:null;return a?pe(function(){return Promise.resolve(i("POST",a,JSON.stringify(n),{"Content-Type":"application/json"})).then(function(e){function t(e){for(var t,r=J(e);!(t=r()).done;)s.push(t.value);return s}return e.data?t(e.data):Promise.resolve(e.json()).then(t)})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.checkFileUrl=function(e,t,r){try{var n=this,o=r||_;return Promise.resolve(n.getEndpoints(t)).then(function(r){return Promise.resolve(n.getServiceEndpoints(t,r)).then(function(t){var r={url:e,type:"url"},i=[],s=n.getEndpointURL(t,"fileinfo")?n.getEndpointURL(t,"fileinfo").urlPath:null;return s?pe(function(){return Promise.resolve(o("POST",s,JSON.stringify(r),{"Content-Type":"application/json"})).then(function(e){function t(e){for(var t,r=J(e);!(t=r()).done;)i.push(t.value);return i}return e.data?t(e.data):Promise.resolve(e.json()).then(t)})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,o,i,s,a,c){try{var u=this,l=i||_;return Promise.resolve(u.getEndpoints(o)).then(function(i){return Promise.resolve(u.getServiceEndpoints(o,i)).then(function(o){var i=u.getEndpointURL(o,"initialize")?u.getEndpointURL(o,"initialize").urlPath:null;return i?(i+="?documentId="+e,i+="&serviceId="+t,i+="&fileIndex="+r,i+="&consumerAddress="+n,s&&(i+="&userdata="+encodeURI(JSON.stringify(s))),a&&(i+="&computeEnv="+encodeURI(a)),c&&(i+="&validUntil="+c),pe(function(){return Promise.resolve(l("GET",i,null,{"Content-Type":"application/json"})).then(function(e){return e.data?e.data:Promise.resolve(e.json())})},function(e){throw G.error(e),new Error("Asset URL not found or not available.")})):null})})}catch(e){return Promise.reject(e)}},t.getDownloadUrl=function(e,t,r,n,o,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(i)).then(function(u){return Promise.resolve(c.getServiceEndpoints(i,u)).then(function(i){var u=c.getEndpointURL(i,"download")?c.getEndpointURL(i,"download").urlPath:null;if(!u)return null;var l=Date.now();return Promise.resolve(c.createSignature(s,t,e+l)).then(function(i){var s=u;return s+="?fileIndex="+n,s+="&documentId="+e,s+="&transferTxId="+o,s+="&serviceId="+r,s+="&consumerAddress="+t,s+="&nonce="+l,s+="&signature="+i,a&&(s+="&userdata="+encodeURI(JSON.stringify(a))),s})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,o,i,s,a,c){try{var u=this,l=s||_;return Promise.resolve(u.getEndpoints(e)).then(function(s){return Promise.resolve(u.getServiceEndpoints(e,s)).then(function(e){var s=u.getEndpointURL(e,"computeStart")?u.getEndpointURL(e,"computeStart").urlPath:null,f=Date.now(),h=r;return h+=o.documentId,h+=f,Promise.resolve(u.createHashSignature(t,r,h)).then(function(e){var t=Object();return t.consumerAddress=r,t.signature=e,t.nonce=f,t.computeEnv=n,t.dataset=o,t.algorithm=i,t.additionalDatasets&&(t.additionalDatasets=a),c&&(t.output=c),s?pe(function(){return Promise.resolve(l("POST",s,JSON.stringify(t),{"Content-Type":"application/json"})).then(function(e){var r;function n(n){return r?n:(console.error("Compute start failed:",e.status,e.statusText),G.error("Payload was:",t),null)}var o=function(){if(null!=e&&e.ok){var t=function(e){return r=1,e};return e.data?t(e.data):Promise.resolve(e.json()).then(t)}}();return o&&o.then?o.then(n):n(o)})},function(e){return G.error("Compute start failed:"),G.error(e),G.error("Payload was:",t),null}):null})})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,o,i){try{var s=this,a=i||_;return Promise.resolve(s.getEndpoints(n)).then(function(c){return Promise.resolve(s.getServiceEndpoints(n,c)).then(function(u){var l=s.getEndpointURL(u,"computeStop")?s.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,c,u)).then(function(n){var i=t;return i+=r||"",i+=e&&""+ge(e)||"",i+=n,Promise.resolve(s.createHashSignature(o,t,i)).then(function(n){var o=Object();return o.signature=n,o.documentId=ge(e),o.consumerAddress=t,r&&(o.jobId=r),l?pe(function(){return Promise.resolve(a("PUT",l,JSON.stringify(o),{"Content-Type":"application/json"})).then(function(e){var t;function r(r){return t?r:(G.error("Compute stop failed:",e.status,e.statusText),G.error("Payload was:",o),null)}var n=function(){if(null!=e&&e.ok){var r=function(e){return t=1,e};return e.data?r(e.data):Promise.resolve(e.json()).then(r)}}();return n&&n.then?n.then(r):r(n)})},function(e){return G.error("Compute stop failed:"),G.error(e),G.error("Payload was:",o),null}):null})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,n,o){try{var i=this;if(!r&&!n&&!o)throw new Error("You need at least one of jobId, did, consumerAddress");var s=t||_;return Promise.resolve(i.getEndpoints(e)).then(function(t){return Promise.resolve(i.getServiceEndpoints(e,t)).then(function(e){var t=i.getEndpointURL(e,"computeStatus")?i.getEndpointURL(e,"computeStatus").urlPath:null,a="?documentId="+ge(n);return a+="&consumerAddress="+o,a+=r&&"&jobId="+r||"",t?pe(function(){return Promise.resolve(s("GET",t+a,null,{"Content-Type":"application/json"})).then(function(e){var t;function r(r){return t?r:(G.error("Get compute status failed:",e.status,e.statusText),null)}var n=function(){if(null!=e&&e.ok){var r=function(e){return t=1,e};return e.data?r(e.data):Promise.resolve(e.json()).then(r)}}();return n&&n.then?n.then(r):r(n)})},function(e){return G.error("Get compute status failed"),G.error(e),null}):null})})}catch(e){return Promise.reject(e)}},t.computeResult=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(c){return Promise.resolve(a.getServiceEndpoints(o,c)).then(function(u){var l=a.getEndpointURL(u,"computeResult")?a.getEndpointURL(u,"computeResult").urlPath:null;return Promise.resolve(a.getNonce(o,n,s,c,u)).then(function(o){var c=n;return c+=e,c+=String(t),c+=o,Promise.resolve(a.createHashSignature(i,n,c)).then(function(o){var i=l;if(i+="?consumerAddress="+n,i+="&jobId="+e,i+="&index="+String(t),i+=o&&"&signature="+o||"",!l)return null;var a=pe(function(){return Promise.resolve(r?s.downloadFile(i,r,t):s.downloadFileBrowser(i)).then(function(e){})},function(e){throw G.error("Error getting job result"),G.error(e),e});return a&&a.then?a.then(function(e){return r}):r})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,o,i){try{var s=this,a=i||_;return Promise.resolve(s.getEndpoints(n)).then(function(c){return Promise.resolve(s.getServiceEndpoints(n,c)).then(function(u){var l=s.getEndpointURL(u,"computeDelete")?s.getEndpointURL(u,"computeDelete").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,c,u)).then(function(n){var i=t;return i+=r||"",i+=e&&""+ge(e)||"",i+=n,Promise.resolve(s.createHashSignature(o,t,i)).then(function(n){var o=Object();return o.documentId=ge(e),o.consumerAddress=t,o.jobId=r,n&&(o.signature=n),l?pe(function(){return Promise.resolve(a("DELETE",l,JSON.stringify(o),{"Content-Type":"application/json"})).then(function(e){var t;function r(r){return t?r:(G.error("Delete compute job failed:",e.status,e.statusText),G.error("Payload was:",o),null)}var n=function(){if(null!=e&&e.ok){var r=function(e){return t=1,e};return e.data?r(e.data):Promise.resolve(e.json()).then(r)}}();return n&&n.then?n.then(r):r(n)})},function(e){return G.error("Delete compute job failed:"),G.error(e),G.error("Payload was:",o),null}):null})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(pe(function(){return Promise.resolve((t||_)("GET",e,null,{"Content-Type":"application/json"})).then(function(e){var t,r=function(){if(null!=e&&e.ok){var r=function(e){if(e&&e.providerAddress)return t=!0};return e.data?r(e.data):Promise.resolve(e.json()).then(r)}}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return G.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},e}(),be=new we;exports.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.erc721FactoryAddress=void 0,this.erc721FFactoryABI=void 0,this.datatokensABI=void 0,this.poolTemplateAddress=void 0,this.poolFactoryABI=void 0,this.poolABI=void 0,this.fixedRateExchangeAddress=void 0,this.fixedRateExchangeAddressABI=void 0,this.dispenserAddress=void 0,this.dispenserABI=void 0,this.opfCommunityFeeCollector=void 0,this.sideStakingAddress=void 0,this.startBlock=void 0,this.verbose=void 0,this.authMessage=void 0,this.authTokenExpiration=void 0,this.parityUri=void 0,this.threshold=void 0,this.chainId=void 0,this.network=void 0,this.subgraphUri=void 0,this.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0},exports.ConfigHelper=V,exports.Datatoken=me,exports.Dispenser=ae,exports.FixedRateExchange=ue,exports.Logger=x,exports.LoggerInstance=G,exports.Nft=fe,exports.NftFactory=Pe,exports.Pool=oe,exports.Provider=we,exports.ProviderInstance=be,exports.ZERO_ADDRESS="0x0000000000000000000000000000000000000000",exports.configHelperNetworks=Z,exports.crossFetchGeneric=_,exports.downloadFile=function(e,t,r){try{return Promise.resolve(w.default(e)).then(function(n){if(!n.ok)throw new Error("Response error.");var o;try{o=n.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]}catch(t){try{o=e.split("/").pop()}catch(e){o="file"+r}}return function(){if(t){b.default.mkdirSync(t,{recursive:!0});var e=b.default.writeFileSync,r=t+"/"+o;return Promise.resolve(n.text()).then(function(n){return e.call(b.default,r,n),t})}return Promise.resolve(n.arrayBuffer()).then(function(e){A.default(e,o)})}()})}catch(e){return Promise.reject(e)}},exports.fetchData=function(e,t){try{return Promise.resolve(w.default(e,t)).then(function(r){var n=function(){if(!r.ok){G.error("Error requesting ["+t.method+"] "+e);var n=G.error;return Promise.resolve(r.text()).then(function(e){throw n.call(G,"Response message: \n"+e),r})}}();return n&&n.then?n.then(function(e){return r}):r})}catch(e){return Promise.reject(e)}},exports.generateDid=function(e,t){return e=g.default.utils.toChecksumAddress(e),"did:op:"+T.default(e+t.toString(10)).toString()},exports.generateDtName=U,exports.getData=B,exports.getErcCreationParams=D,exports.getFairGasPrice=M,exports.getFreCreationParams=N,exports.getHash=function(e){return T.default(e).toString()},exports.getPoolCreationParams=W,exports.postData=function(e,t){return function(e,t,r){try{return Promise.resolve(w.default(e,null!=t?{method:"POST",body:t,headers:{"Content-type":"application/json"}}:{method:"POST"}))}catch(e){return Promise.reject(e)}}(e,t)},exports.setContractDefaults=O,exports.signHash=function(e,t,r){try{return Promise.resolve(e.eth.sign(t,r)).then(function(e){var t="0x"+(e=e.substr(2)).slice(0,64),r="0x"+e.slice(64,128),n="0x"+e.slice(128,130);return"0x00"===n&&(n="0x1b"),"0x01"===n&&(n="0x1c"),{v:n,r:t,s:r}})}catch(e){return Promise.reject(e)}},exports.signText=$,exports.signWithHash=X;
1
+ var e=require("web3"),t=require("bignumber.js"),r=require("cross-fetch"),n=require("@oceanprotocol/contracts/addresses/address.json"),o=require("crypto-js/sha256"),i=require("decimal.js"),s=require("@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json"),a=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),c=require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),u=require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),l=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),f=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),h=require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d,v=/*#__PURE__*/m(e),P=/*#__PURE__*/m(t),g=/*#__PURE__*/m(r),p=/*#__PURE__*/m(n),w=/*#__PURE__*/m(o),b=/*#__PURE__*/m(i),y=/*#__PURE__*/m(s),A=/*#__PURE__*/m(a),T=/*#__PURE__*/m(c),E=/*#__PURE__*/m(u),C=/*#__PURE__*/m(l),F=/*#__PURE__*/m(f),R=/*#__PURE__*/m(h);exports.LogLevel=void 0,(d=exports.LogLevel||(exports.LogLevel={}))[d.None=-1]="None",d[d.Error=0]="Error",d[d.Warn=1]="Warn",d[d.Log=2]="Log",d[d.Verbose=3]="Verbose";var k=/*#__PURE__*/function(){function e(e){void 0===e&&(e=exports.LogLevel.Error),this.logLevel=void 0,this.logLevel=e}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",exports.LogLevel.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",exports.LogLevel.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",exports.LogLevel.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",exports.LogLevel.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),I=new k,j={nouns:["Crab","Fish","Seal","Octopus","Shark","Seahorse","Walrus","Starfish","Whale","Orca","Penguin","Jellyfish","Squid","Lobster","Pelican","Shrimp","Oyster","Clam","Seagull","Dolphin","Shell","Cormorant","Otter","Anemone","Turtle","Coral","Ray","Barracuda","Krill","Anchovy","Angelfish","Barnacle","Clownfish","Cod","Cuttlefish","Eel","Fugu","Herring","Haddock","Ling","Mackerel","Manatee","Narwhal","Nautilus","Plankton","Porpoise","Prawn","Pufferfish","Swordfish","Tuna"],adjectives:["adamant","adroit","amatory","ambitious","amused","animistic","antic","arcadian","artistic","astonishing","astounding","baleful","bellicose","bilious","blissful","boorish","brave","breathtaking","brilliant","calamitous","caustic","cerulean","clever","charming","comely","competent","concomitant","confident","contumacious","corpulent","crapulous","creative","dazzling","dedicated","defamatory","delighted","delightful","determined","didactic","dilatory","dowdy","efficacious","effulgent","egregious","empowered","endemic","enthusiastic","equanimous","exceptional","execrable","fabulous","fantastic","fastidious","feckless","fecund","friable","fulsome","garrulous","generous","gentle","guileless","gustatory","heuristic","histrionic","hubristic","incendiary","incredible","insidious","insolent","inspired","intransigent","inveterate","invidious","invigorated","irksome","jejune","juicy","jocular","joyful","judicious","kind","lachrymose","limpid","loquacious","lovely","luminous","mannered","marvelous","mendacious","meretricious","minatory","mordant","motivated","munificent","nefarious","noxious","obtuse","optimistic","parsimonious","pendulous","pernicious","pervasive","petulant","passionate","phenomenal","platitudinous","pleasant","powerful","precipitate","propitious","puckish","querulous","quiescent","rebarbative","recalcitant","redolent","rhadamanthine","risible","ruminative","sagacious","salubrious","sartorial","sclerotic","serpentine","smart","spasmodic","strident","stunning","stupendous","taciturn","tactful","tasty","tenacious","tremendous","tremulous","trenchant","turbulent","turgid","ubiquitous","uxorious","verdant","vibrant","voluble","voracious","wheedling","withering","wonderful","zealous"]};function x(e){var t=e||j,r=Math.floor(Math.random()*t.adjectives.length),n=Math.floor(Math.random()*t.nouns.length),o=Math.floor(100*Math.random()),i=t.adjectives[r].replace(/^\w/,function(e){return e.toUpperCase()}),s=t.nouns[n].replace(/^\w/,function(e){return e.toUpperCase()});return{name:i+" "+s+" Token",symbol:(i.substring(0,3)+s.substring(0,3)).toUpperCase()+"-"+o}}var S=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}];function G(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var M=function(e,t,r){try{var n=this;return Promise.resolve(G(function(){var n=new e.eth.Contract(S,t);return Promise.resolve(n.methods.decimals().call()).then(function(e){"0"===e&&(e=18);var t=new P.default(parseInt(r)*Math.pow(10,e));return P.default.config({EXPONENTIAL_AT:50}),t.toString()})},function(){n.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},L=function(e,t,r){try{var n=this;return Promise.resolve(G(function(){var n=new e.eth.Contract(S,t);return Promise.resolve(n.methods.decimals().call()).then(function(e){"0"===e&&(e=18);var t=new P.default(parseInt(r)/Math.pow(10,e));return P.default.config({EXPONENTIAL_AT:50}),t.toString()})},function(){n.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},O=function(e,t){try{return Promise.resolve(e.eth.getGasPrice()).then(function(e){var r=new P.default(e);return t&&t.gasFeeMultiplier?r.multipliedBy(t.gasFeeMultiplier).integerValue(P.default.ROUND_DOWN).toString(10):r.toString(10)})}catch(e){return Promise.reject(e)}};function U(e,t){return t&&(t.transactionBlockTimeout&&(e.transactionBlockTimeout=t.transactionBlockTimeout),t.transactionConfirmationBlocks&&(e.transactionConfirmationBlocks=t.transactionConfirmationBlocks),t.transactionPollingTimeout&&(e.transactionPollingTimeout=t.transactionPollingTimeout)),e}function D(e){var t,r;if(!e.name||!e.symbol){var n=x();t=n.name,r=n.symbol}return{templateIndex:e.templateIndex,strings:[e.name||t,e.symbol||r],addresses:[e.minter,e.feeManager,e.mpFeeAddress,e.feeToken],uints:[v.default.utils.toWei(e.cap),v.default.utils.toWei(e.feeAmount)],bytess:[]}}function N(e){return e.allowedConsumer||(e.allowedConsumer="0x0000000000000000000000000000000000000000"),{fixedPriceAddress:e.fixedRateAddress,addresses:[e.baseTokenAddress,e.owner,e.marketFeeCollector,e.allowedConsumer],uints:[e.baseTokenDecimals,e.datatokenDecimals,e.fixedRate,e.marketFee,e.withMint?1:0]}}function W(e){return{addresses:[e.ssContract,e.baseTokenAddress,e.baseTokenSender,e.publisherAddress,e.marketFeeCollector,e.poolTemplateAddress],ssParams:[v.default.utils.toWei(e.rate),e.baseTokenDecimals,v.default.utils.toWei(e.vestingAmount),e.vestedBlocks,v.default.utils.toWei(e.initialBaseTokenLiquidity)],swapFees:[e.swapFeeLiquidityProvider,e.swapFeeMarketRunner]}}var _=function(e){try{return Promise.resolve(g.default(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},B=function(e,t){try{return Promise.resolve(g.default(e)).then(function(r){if(!r.ok)throw new Error("Response error.");var n;try{n=r.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]}catch(r){try{n=e.split("/").pop()}catch(e){n="file"+t}}return Promise.resolve(r.arrayBuffer()).then(function(e){return{data:e,filename:n}})})}catch(e){return Promise.reject(e)}},q=function(e){try{var t=document.createElement("a");return t.download="",t.href=e,t.click(),Promise.resolve()}catch(e){return Promise.reject(e)}};function z(){return z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},z.apply(this,arguments)}function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function H(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return J(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?J(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var Z={chainId:null,network:"unknown",metadataCacheUri:"https://aquarius.oceanprotocol.com",nodeUri:"http://localhost:8545",providerUri:"http://127.0.0.1:8030",subgraphUri:null,explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",poolTemplateAddress:null,fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},V=[z({},Z),z({},Z,{chainId:8996,network:"development",metadataCacheUri:"http://127.0.0.1:5000"}),z({},Z,{chainId:3,network:"ropsten",nodeUri:"https://ropsten.infura.io/v3",providerUri:"https://provider.ropsten.oceanprotocol.com",subgraphUri:"https://subgraph.ropsten.oceanprotocol.com",explorerUri:"https://ropsten.etherscan.io",startBlock:9227563}),z({},Z,{chainId:4,network:"rinkeby",nodeUri:"https://rinkeby.infura.io/v3",providerUri:"https://providerv4.rinkeby.oceanprotocol.com",subgraphUri:"https://subgraphv4.rinkeby.oceanprotocol.com",explorerUri:"https://rinkeby.etherscan.io",startBlock:7294090}),z({},Z,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",providerUri:"https://provider.mainnet.oceanprotocol.com",subgraphUri:"https://subgraph.mainnet.oceanprotocol.com",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05}),z({},Z,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",providerUri:"https://provider.polygon.oceanprotocol.com",subgraphUri:"https://subgraph.polygon.oceanprotocol.com",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",startBlock:11005222}),z({},Z,{chainId:1287,network:"moonbeamalpha",nodeUri:"https://rpc.testnet.moonbeam.network",providerUri:"https://provider.moonbeamalpha.oceanprotocol.com",subgraphUri:"https://subgraph.moonbeamalpha.oceanprotocol.com",explorerUri:"https://moonbase-blockscout.testnet.moonbeam.network/",startBlock:90707}),z({},Z,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",providerUri:"https://provider.gaiaxtestnet.oceanprotocol.com",subgraphUri:"https://subgraph.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com"}),z({},Z,{chainId:2021001,network:"catenaxtestnet",nodeUri:"https://rpc.catenaxtestnet.oceanprotocol.com",providerUri:"https://provider.catenaxtestnet.oceanprotocol.com",subgraphUri:"https://subgraph.catenaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.catenaxtestnet.oceanprotocol.com",metadataCacheUri:"https://aquarius.catenaxtestnet.oceanprotocol.com"}),z({},Z,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",providerUri:"https://provider.mumbai.oceanprotocol.com",subgraphUri:"https://subgraph.mumbai.oceanprotocol.com",explorerUri:"https://mumbai.polygonscan.com"}),z({},Z,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",providerUri:"https://provider.bsc.oceanprotocol.com",subgraphUri:"https://subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05}),z({},Z,{chainId:44787,network:"celoalfajores",nodeUri:"https://alfajores-forno.celo-testnet.org",providerUri:"https://provider.celoalfajores.oceanprotocol.com",subgraphUri:"https://subgraph.celoalfajores.oceanprotocol.com",explorerUri:"https://alfajores-blockscout.celo-testnet.org"}),z({},Z,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",providerUri:"https://provider.energyweb.oceanprotocol.com",subgraphUri:"https://subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05}),z({},Z,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",providerUri:"https://provider.moonriver.oceanprotocol.com",subgraphUri:"https://subgraph.moonriver.oceanprotocol.com",explorerUri:"https://blockscout.moonriver.moonbeam.network",gasFeeMultiplier:1.05})],X=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r;if(t)try{var n=t[e];r=z({erc721FactoryAddress:n.ERC721Factory,sideStakingAddress:n.Staking,opfCommunityFeeCollector:n.OPFCommunityFeeCollector,poolTemplateAddress:n.poolTemplate,fixedRateExchangeAddress:n.FixedPrice,dispenserAddress:n.Dispenser,oceanTokenAddress:n.Ocean,chainId:n.chainId,startBlock:n.startBlock},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}catch(e){}else if(p.default[e]){var o=p.default[e];r=z({erc721FactoryAddress:o.ERC721Factory,sideStakingAddress:o.Staking,opfCommunityFeeCollector:o.OPFCommunityFeeCollector,poolTemplateAddress:o.poolTemplate,fixedRateExchangeAddress:o.FixedPrice,dispenserAddress:o.Dispenser,oceanTokenAddress:o.Ocean,chainId:o.chainId,startBlock:o.startBlock},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}return r},t.getConfig=function(e,t){var r="string"==typeof e?"network":"chainId",n=V.find(function(t){return t[r]===e});return n?(n=z({},n,this.getAddressesFromEnv(n.network)),z({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(I.error("No config found for given network '"+e+"'"),null)},e}();function Q(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var $=function(e,t,r,n){try{var o=e.utils.utf8ToHex(t),i=e&&e.currentProvider&&e.currentProvider.isMetaMask;return Promise.resolve(Q(function(){return Promise.resolve(e.eth.personal.sign(o,r,n))},function(t){if(i)throw t;return I.warn("Error on personal sign."),I.warn(t),Q(function(){return Promise.resolve(e.eth.sign(o,r))},function(e){throw I.error("Error on sign."),I.error(e),new Error("Error executing personal sign")})}))}catch(e){return Promise.reject(e)}},K=function(e,t,r,n){try{var o=e&&e.currentProvider&&e.currentProvider.isMetaMask;return Promise.resolve(Q(function(){return Promise.resolve(e.eth.personal.sign(t,r,n))},function(n){if(o)throw n;return I.warn("Error on personal sign."),I.warn(n),Q(function(){return Promise.resolve(e.eth.sign(t,r))},function(e){throw I.error("Error on sign."),I.error(e),new Error("Error executing personal sign")})}))}catch(e){return Promise.reject(e)}};function Y(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ee=function(e,t,r,n){try{var o=new e.eth.Contract(S,t);return Promise.resolve(o.methods.allowance(r,n).call()).then(function(r){return Promise.resolve(L(e,t,r))})}catch(e){return Promise.reject(e)}},te=function(e,t,r,n,o,i){try{var s,a=i||new e.eth.Contract(S,r),c=1e6,u=Y(function(){return Promise.resolve(a.methods.approve(n,o).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){s=e})},function(e){s=c,I.error("estimate gas failed for approve!",e)});return Promise.resolve(u&&u.then?u.then(function(){return s}):s)}catch(e){return Promise.reject(e)}};function re(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ne="115792089237316195423570985008687907853269984665640564039457584007913129639934";function oe(e,t,r){if(!e.s){if(r instanceof ie){if(!r.s)return void(r.o=oe.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(oe.bind(null,e,t),oe.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var ie=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{oe(n,1,i(this.v))}catch(e){oe(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?oe(n,1,t?t(o):o):r?oe(n,1,r(o)):oe(n,2,o)}catch(e){oe(n,2,e)}},n},e}();function se(e){return e instanceof ie&&1&e.s}function ae(e,t,r){for(var n;;){var o=e();if(se(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!se(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!se(s)){n=2;break}}}var a=new ie,c=oe.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(f)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!se(s))return void s.then(f).then(void 0,c);if(!(o=e())||se(o)&&!o.v)return void oe(a,1,i);if(o.then)return void o.then(l).then(void 0,c);se(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,c)}function l(e){e?(i=r())&&i.then?i.then(u).then(void 0,c):u(i):oe(a,1,i)}function f(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):oe(a,1,i)}}var ce=/*#__PURE__*/function(){function e(e,t,r,n){void 0===r&&(r=null),this.poolAbi=void 0,this.web3=void 0,this.GASLIMIT_DEFAULT=1e6,this.logger=void 0,this.config=void 0,this.poolAbi=r||y.default.abi,this.web3=e,this.logger=t,this.config=n||V[0]}var t=e.prototype;return t.sharesBalance=function(e,t){try{var r=this,n=null,o=re(function(){var o=U(new r.web3.eth.Contract(r.poolAbi,t),r.config);return Promise.resolve(o.methods.balanceOf(e).call()).then(function(e){n=r.web3.utils.fromWei(e)})},function(e){r.logger.error("ERROR: Failed to get shares of pool : "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.estSetSwapFee=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(A.default.abi,t),i.config),a=i.GASLIMIT_DEFAULT,c=re(function(){return Promise.resolve(s.methods.setSwapFee(r).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setSwapFee=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.poolAbi,t,{from:e}),n.config),i=null;return Promise.resolve(n.estSetSwapFee(e,t,r)).then(function(t){var s=re(function(){var s=o.methods.setSwapFee(n.web3.utils.toWei(r)),a=s.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(s,{from:e,gas:t,gasPrice:r})).then(function(e){i=e})})},function(e){n.logger.error("ERROR: Failed to set pool swap fee: "+e.message)});return s&&s.then?s.then(function(){return i}):i})}catch(e){return Promise.reject(e)}},t.getNumTokens=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getNumTokens().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get number of tokens: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getPoolSharesTotalSupply=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.totalSupply().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){t.logger.error("ERROR: Failed to get total supply of pool shares: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getCurrentTokens=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getCurrentTokens().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get tokens composing this pool: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getFinalTokens=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getFinalTokens().call()).then(function(e){n=e})},function(){t.logger.error("ERROR: Failed to get the final tokens composing this pool")});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getController=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getController().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get pool controller address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getBaseToken=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getBaseTokenAddress().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get baseToken address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getDatatoken=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getDatatokenAddress().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get datatoken address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getMarketFeeCollector=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods._publishMarketCollector().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get marketFeeCollector address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getOPFCollector=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods._opfCollector().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.isBound=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=re(function(){return Promise.resolve(n.methods.isBound(t).call()).then(function(e){o=e})},function(e){r.logger.error("ERROR: Failed to check whether a token bounded to a pool. "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getReserve=function(e,t){try{var r=function(){return o.toString()},n=this,o=null,i=re(function(){var r=U(new n.web3.eth.Contract(n.poolAbi,e),n.config);return Promise.resolve(r.methods.getBalance(t).call()).then(function(e){return Promise.resolve(L(n.web3,t,e)).then(function(e){o=e})})},function(e){n.logger.error("ERROR: Failed to get how many tokens are in the pool: "+e.message)});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.isFinalized=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.isFinalized().call()).then(function(e){n=e})},function(e){t.logger.error("ERROR: Failed to check whether pool is finalized: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getSwapFee=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getSwapFee().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){t.logger.error("ERROR: Failed to get pool fee: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getNormalizedWeight=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=re(function(){return Promise.resolve(n.methods.getNormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(e){r.logger.error("ERROR: Failed to get normalized weight of a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getDenormalizedWeight=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=re(function(){return Promise.resolve(n.methods.getDenormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(){r.logger.error("ERROR: Failed to get denormalized weight of a token in pool")});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getTotalDenormalizedWeight=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=re(function(){return Promise.resolve(r.methods.getTotalDenormalizedWeight().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(){t.logger.error("ERROR: Failed to get total denormalized weight in pool")});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getMarketFees=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=re(function(){return Promise.resolve(n.methods.publishMarketFees(t).call()).then(function(e){return Promise.resolve(L(r.web3,t,e)).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to get market fees for a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getCurrentMarketFees=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(re(function(){return Promise.resolve(r.methods.getCurrentOPFFees().call())},function(e){t.logger.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},t.getCurrentOPFFees=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(re(function(){return Promise.resolve(r.methods.getCurrentOPFFees().call())},function(e){t.logger.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},t.getCommunityFees=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=re(function(){return Promise.resolve(n.methods.communityFees(t).call()).then(function(e){return Promise.resolve(L(r.web3,t,e)).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to get community fees for a token: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.estCollectOPF=function(e,t,r){try{var n,o=this,i=r||U(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(i.methods.collectOPF().estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectOPF=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.poolAbi,t),r.config),o=null;return Promise.resolve(r.estCollectOPF(e,t)).then(function(t){var i=re(function(){var i=n.methods.collectOPF(),s=i.send;return Promise.resolve(O(r.web3,r.config)).then(function(r){return Promise.resolve(s.call(i,{from:e,gas:t+1,gasPrice:r})).then(function(e){o=e})})},function(e){r.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return i&&i.then?i.then(function(){return o}):o})}catch(e){return Promise.reject(e)}},t.estCollectMarketFee=function(e,t,r){try{var n,o=this,i=r||U(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(i.methods.collectMarketFee().estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getMarketFeeCollector(t)).then(function(n){if(n!==e)throw new Error("Caller is not MarketFeeCollector");var o=U(new r.web3.eth.Contract(r.poolAbi,t),r.config),i=null;return Promise.resolve(r.estCollectMarketFee(e,t)).then(function(t){var n=re(function(){var n=o.methods.collectMarketFee(),s=n.send;return Promise.resolve(O(r.web3,r.config)).then(function(r){return Promise.resolve(s.call(n,{from:e,gas:t+1,gasPrice:r})).then(function(e){i=e})})},function(e){r.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return n&&n.then?n.then(function(){return i}):i})})}catch(e){return Promise.reject(e)}},t.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=i.GASLIMIT_DEFAULT,c=re(function(){return Promise.resolve(s.methods.updateMarketFeeCollector(r).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.getMarketFeeCollector(t)).then(function(o){if(o!==e)throw new Error("Caller is not MarketFeeCollector");var i=U(new n.web3.eth.Contract(n.poolAbi,t),n.config),s=null;return Promise.resolve(n.estUpdateMarketFeeCollector(e,t,r)).then(function(t){var o=re(function(){var o=i.methods.updateMarketFeeCollector(r),a=o.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(o,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){n.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return o&&o.then?o.then(function(){return s}):s})})}catch(e){return Promise.reject(e)}},t.estSwapExactAmountIn=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=n.maxPrice?s.web3.utils.toWei(n.maxPrice):ne,u=s.GASLIMIT_DEFAULT,l=re(function(){return Promise.resolve(a.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,c,s.web3.utils.toWei(n.swapMarketFee)]).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){i=e})},function(){i=u});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.swapExactAmountIn=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.poolAbi,t),o.config);return Promise.resolve(M(o.web3,r.tokenIn,n.tokenAmountIn)).then(function(s){return n.tokenAmountIn=s,Promise.resolve(M(o.web3,r.tokenOut,n.minAmountOut)).then(function(s){n.minAmountOut=s;var a=null;return Promise.resolve(o.estSwapExactAmountIn(e,t,r,n)).then(function(t){var s=n.maxPrice?o.web3.utils.toWei(n.maxPrice):ne,c=re(function(){var c=i.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,s,o.web3.utils.toWei(n.swapMarketFee)]),u=c.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){o.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return c&&c.then?c.then(function(){return a}):a})})})}catch(e){return Promise.reject(e)}},t.estSwapExactAmountOut=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=n.maxPrice?s.web3.utils.toWei(n.maxPrice):ne,l=re(function(){return Promise.resolve(a.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.maxAmountIn,n.tokenAmountOut,u,s.web3.utils.toWei(n.swapMarketFee)]).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.swapExactAmountOut=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=null;return Promise.resolve(M(o.web3,r.tokenIn,n.maxAmountIn)).then(function(a){return n.maxAmountIn=a,Promise.resolve(M(o.web3,r.tokenOut,n.tokenAmountOut)).then(function(a){return n.tokenAmountOut=a,Promise.resolve(o.estSwapExactAmountOut(e,t,r,n)).then(function(t){var a=n.maxPrice?o.web3.utils.toWei(n.maxPrice):ne,c=re(function(){var c=i.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.maxAmountIn,n.tokenAmountOut,a,o.web3.utils.toWei(n.swapMarketFee)]),u=c.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){o.logger.error("ERROR: Failed to swap exact amount out: "+e.message)});return c&&c.then?c.then(function(){return s}):s})})})}catch(e){return Promise.reject(e)}},t.estJoinPool=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=re(function(){return Promise.resolve(a.methods.joinPool(r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.joinPool=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(a){function c(){var n=null;return Promise.resolve(o.estJoinPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var a=re(function(){var a=i.methods.joinPool(o.web3.utils.toWei(r),s),c=a.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(c.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){n=e})})},function(e){o.logger.error("ERROR: Failed to join pool: "+e.message)});return a&&a.then?a.then(function(){return n}):n})}var u=0,l=ae(function(){return u<2},function(){return u++},function(){return Promise.resolve(M(o.web3,a[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(c):c()})}catch(e){return Promise.reject(e)}},t.estExitPool=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=s.GASLIMIT_DEFAULT,u=re(function(){return Promise.resolve(a.methods.exitPool(r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.exitPool=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(a){function c(){var n=null;return Promise.resolve(o.estExitPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var a=re(function(){var a=i.methods.exitPool(o.web3.utils.toWei(r),s),c=a.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(c.call(a,{from:e,gas:t,gasPrice:r})).then(function(e){n=e})})},function(e){o.logger.error("ERROR: Failed to exit pool: "+e.message)});return a&&a.then?a.then(function(){return n}):n})}var u=0,l=ae(function(){return u<2},function(){return u++},function(){return Promise.resolve(M(o.web3,a[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(c):c()})}catch(e){return Promise.reject(e)}},t.estJoinswapExternAmountIn=function(e,t,r,n,o,i){try{var s,a=this,c=i||U(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=re(function(){return Promise.resolve(c.methods.joinswapExternAmountIn(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.joinswapExternAmountIn=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(M(i.web3,r,n)).then(function(n){return Promise.resolve(i.estJoinswapExternAmountIn(e,t,r,n,i.web3.utils.toWei(o))).then(function(t){var c=re(function(){var c=s.methods.joinswapExternAmountIn(r,n,i.web3.utils.toWei(o)),u=c.send;return Promise.resolve(O(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){i.logger.error("ERROR: Failed to pay tokens in order to join the pool: "+e.message)});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estJoinswapPoolAmountOut=function(e,t,r,n,o,i){try{var s,a=this,c=i||U(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=re(function(){return Promise.resolve(c.methods.joinswapPoolAmountOut(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.joinswapPoolAmountOut=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(M(i.web3,r,o)).then(function(o){return Promise.resolve(i.estJoinswapPoolAmountOut(e,t,r,i.web3.utils.toWei(n),o)).then(function(t){var c=re(function(){var c=s.methods.joinswapPoolAmountOut(r,i.web3.utils.toWei(n),o),u=c.send;return Promise.resolve(O(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(){i.logger.error("ERROR: Failed to join swap pool amount out")});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estExitswapPoolAmountIn=function(e,t,r,n,o,i){try{var s,a=this,c=i||U(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=re(function(){return Promise.resolve(c.methods.exitswapPoolAmountIn(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.exitswapPoolAmountIn=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(M(i.web3,r,o)).then(function(o){return Promise.resolve(i.estExitswapPoolAmountIn(e,t,r,i.web3.utils.toWei(n),o)).then(function(t){var c=re(function(){var c=s.methods.exitswapPoolAmountIn(r,i.web3.utils.toWei(n),o),u=c.send;return Promise.resolve(O(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){i.logger.error("ERROR: Failed to pay pool shares into the pool: "+e.message)});return c&&c.then?c.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},t.estExitswapExternAmountOut=function(e,t,r,n,o,i){try{var s,a=this,c=i||U(new a.web3.eth.Contract(a.poolAbi,t),a.config),u=a.GASLIMIT_DEFAULT,l=re(function(){return Promise.resolve(c.methods.exitswapExternAmountOut(r,n,o).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.exitswapExternAmountOut=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,t),i.config),a=null;return Promise.resolve(i.estExitswapExternAmountOut(e,t,r,i.web3.utils.toWei(n),i.web3.utils.toWei(o))).then(function(t){var c=re(function(){var c=s.methods.exitswapExternAmountOut(r,i.web3.utils.toWei(n),i.web3.utils.toWei(o)),u=c.send;return Promise.resolve(O(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(c,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(){i.logger.error("ERROR: Failed to exitswapExternAmountOut")});return c&&c.then?c.then(function(){return a}):a})}catch(e){return Promise.reject(e)}},t.getSpotPrice=function(e,t,r,n){try{var o=function(){function e(){function e(){var e;return a>c?(e=a-c,o=new P.default(o/Math.pow(10,e)),o/=Math.pow(10,c)):(e=c-a,o=new P.default(o*Math.pow(10,2*e)),o/=Math.pow(10,c)),o.toString()}var o=null,u=re(function(){return Promise.resolve(s.methods.getSpotPrice(t,r,i.web3.utils.toWei(n)).call()).then(function(e){o=new P.default((o=e).toString())})},function(){i.logger.error("ERROR: Failed to get spot price of swapping tokenIn to tokenOut")});return u&&u.then?u.then(e):e()}var o=re(function(){return Promise.resolve(l.methods.decimals().call()).then(function(e){c=e})},function(){i.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return o&&o.then?o.then(e):e()},i=this,s=U(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=18,c=18,u=U(new i.web3.eth.Contract(A.default.abi,t),i.config),l=U(new i.web3.eth.Contract(A.default.abi,r),i.config),f=re(function(){return Promise.resolve(u.methods.decimals().call()).then(function(e){a=e})},function(){i.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(f&&f.then?f.then(o):o())}catch(e){return Promise.reject(e)}},t.getAmountInExactOut=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(M(i.web3,r,n)).then(function(e){var n=null,a=re(function(){return Promise.resolve(s.methods.getAmountInExactOut(t,r,e,i.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(L(i.web3,t,e)).then(function(e){n=e})})},function(){i.logger.error("ERROR: Failed to calcInGivenOut")});return a&&a.then?a.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},t.getAmountOutExactIn=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(M(i.web3,t,n)).then(function(e){var n=null,a=re(function(){return Promise.resolve(s.methods.getAmountOutExactIn(t,r,e,i.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(L(i.web3,r,e)).then(function(e){n=e})})},function(){i.logger.error("ERROR: Failed to calcOutGivenIn")});return a&&a.then?a.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},t.calcPoolOutGivenSingleIn=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=re(function(){var s=o.methods,a=s.calcPoolOutSingleIn;return Promise.resolve(M(n.web3,t,r)).then(function(r){return Promise.resolve(a.call(s,t,r).call()).then(function(t){return Promise.resolve(L(n.web3,e,t)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate PoolOutGivenSingleIn : "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.calcSingleInGivenPoolOut=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null;return Promise.resolve(M(n.web3,e,r)).then(function(e){var r=re(function(){return Promise.resolve(o.methods.calcSingleInPoolOut(t,e).call()).then(function(e){return Promise.resolve(L(n.web3,t,e)).then(function(e){i=e})})},function(e){n.logger.error("ERROR: Failed to calculate SingleInGivenPoolOut : "+e.message)});return r&&r.then?r.then(function(){return i}):i})}catch(e){return Promise.reject(e)}},t.calcSingleOutGivenPoolIn=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=re(function(){var s=o.methods,a=s.calcSingleOutPoolIn;return Promise.resolve(M(n.web3,e,r)).then(function(e){return Promise.resolve(a.call(s,t,e).call()).then(function(e){return Promise.resolve(L(n.web3,t,e)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate SingleOutGivenPoolIn : "+e)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.calcPoolInGivenSingleOut=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=re(function(){var s=o.methods,a=s.calcPoolInSingleOut;return Promise.resolve(M(n.web3,t,r)).then(function(r){return Promise.resolve(a.call(s,t,r).call()).then(function(t){return Promise.resolve(L(n.web3,e,t)).then(function(e){i=e})})})},function(e){n.logger.error("ERROR: Failed to calculate PoolInGivenSingleOut : "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.getSwapEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_SWAP"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},t.getJoinEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_JOIN"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},t.getExitEventSignature=function(){var e=this.poolAbi.find(function(e){if("LOG_EXIT"===e.name&&"event"===e.type)return e});return this.web3.eth.abi.encodeEventSignature(e)},e}();function ue(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var le,fe=/*#__PURE__*/function(){function e(e,t,r,n){void 0===t&&(t=null),void 0===r&&(r=null),this.GASLIMIT_DEFAULT=1e6,this.web3=null,this.dispenserAddress=void 0,this.config=void 0,this.dispenserAbi=void 0,this.dispenserContract=void 0,this.web3=e,this.dispenserAddress=t,this.dispenserAbi=r||T.default.abi,this.config=n||V[0],e&&(this.dispenserContract=U(new this.web3.eth.Contract(this.dispenserAbi,this.dispenserAddress),this.config))}var t=e.prototype;return t.status=function(e){try{var t,r=this,n=ue(function(){return Promise.resolve(r.dispenserContract.methods.status(e).call()).then(function(e){return e.maxTokens=r.web3.utils.fromWei(e.maxTokens),e.maxBalance=r.web3.utils.fromWei(e.maxBalance),e.balance=r.web3.utils.fromWei(e.balance),t=1,e})},function(){I.warn("No dispenser available for datatoken: "+e)});return Promise.resolve(n&&n.then?n.then(function(e){return t?e:null}):t?n:null)}catch(e){return Promise.reject(e)}},t.estGasCreate=function(e,t,r,n,o){try{var i,s=this,a=s.GASLIMIT_DEFAULT,c=ue(function(){return Promise.resolve(s.dispenserContract.methods.create(e,s.web3.utils.toWei(r),s.web3.utils.toWei(n),t,o).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.create=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.estGasCreate(e,t,r,n,o)).then(function(s){var a=i.dispenserContract.methods.create(e,i.web3.utils.toWei(r),i.web3.utils.toWei(n),t,o),c=a.send;return Promise.resolve(O(i.web3,i.config)).then(function(e){return Promise.resolve(c.call(a,{from:t,gas:s+1,gasPrice:e}))})})}catch(e){return Promise.reject(e)}},t.estGasActivate=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=ue(function(){return Promise.resolve(i.dispenserContract.methods.activate(e,i.web3.utils.toWei(t),i.web3.utils.toWei(r)).estimateGas({from:n},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.activate=function(e,t,r,n){try{var o,i=this,s=ue(function(){return Promise.resolve(i.estGasActivate(e,t,r,n)).then(function(s){var a=i.dispenserContract.methods.activate(e,i.web3.utils.toWei(t),i.web3.utils.toWei(r)),c=a.send;return Promise.resolve(O(i.web3,i.config)).then(function(e){return Promise.resolve(c.call(a,{from:n,gas:s+1,gasPrice:e})).then(function(e){return o=1,e})})})},function(e){I.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(s&&s.then?s.then(function(e){return o?e:null}):o?s:null)}catch(e){return Promise.reject(e)}},t.estGasDeactivate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ue(function(){return Promise.resolve(n.dispenserContract.methods.deactivate(e).estimateGas({from:t},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.deactivate=function(e,t){try{var r,n=this,o=ue(function(){return Promise.resolve(n.estGasDeactivate(e,t)).then(function(o){var i=n.dispenserContract.methods.deactivate(e),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(e){return Promise.resolve(s.call(i,{from:t,gas:o+1,gasPrice:e})).then(function(e){return r=1,e})})})},function(e){I.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(e){return r?e:null}):r?o:null)}catch(e){return Promise.reject(e)}},t.estGasSetAllowedSwapper=function(e,t,r){try{var n,o=this,i=o.GASLIMIT_DEFAULT,s=ue(function(){return Promise.resolve(o.dispenserContract.methods.setAllowedSwapper(e,r).estimateGas({from:t},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n,o=this,i=ue(function(){return Promise.resolve(o.estGasSetAllowedSwapper(e,t,r)).then(function(i){var s=o.dispenserContract.methods.setAllowedSwapper(e,r),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(e){return Promise.resolve(a.call(s,{from:t,gas:i+1,gasPrice:e})).then(function(e){return n=1,e})})})},function(e){I.error("ERROR: Failed to activate dispenser: "+e.message)});return Promise.resolve(i&&i.then?i.then(function(e){return n?e:null}):n?i:null)}catch(e){return Promise.reject(e)}},t.estGasDispense=function(e,t,r,n){void 0===r&&(r="1");try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=ue(function(){return Promise.resolve(i.dispenserContract.methods.dispense(e,i.web3.utils.toWei(r),n).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.dispense=function(e,t,r,n){void 0===r&&(r="1");try{var o=this;return Promise.resolve(o.estGasDispense(e,t,r,n)).then(function(i){var s,a=ue(function(){var a=o.dispenserContract.methods.dispense(e,o.web3.utils.toWei(r),n),c=a.send;return Promise.resolve(O(o.web3,o.config)).then(function(e){return Promise.resolve(c.call(a,{from:t,gas:i+1,gasPrice:e})).then(function(e){return s=1,e})})},function(e){I.error("ERROR: Failed to dispense tokens: "+e.message)});return a&&a.then?a.then(function(e){return s?e:null}):s?a:null})}catch(e){return Promise.reject(e)}},t.estGasOwnerWithdraw=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=ue(function(){return Promise.resolve(n.dispenserContract.methods.ownerWithdraw(e).estimateGas({from:t},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.ownerWithdraw=function(e,t){try{var r=this;return Promise.resolve(r.estGasOwnerWithdraw(e,t)).then(function(n){var o,i=ue(function(){var i=r.dispenserContract.methods.ownerWithdraw(e),s=i.send;return Promise.resolve(O(r.web3,r.config)).then(function(e){return Promise.resolve(s.call(i,{from:t,gas:n+1,gasPrice:e})).then(function(e){return o=1,e})})},function(e){I.error("ERROR: Failed to withdraw tokens: "+e.message)});return i&&i.then?i.then(function(e){return o?e:null}):o?i:null})}catch(e){return Promise.reject(e)}},t.isDispensable=function(e,t,r,n){void 0===n&&(n="1");try{return Promise.resolve(this.status(e)).then(function(o){return!!o&&!1!==o.active&&Promise.resolve(t.balance(e,r)).then(function(e){return!(new b.default(e).greaterThanOrEqualTo(o.maxBalance)||new b.default(String(n)).greaterThan(o.maxTokens)||!new b.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},e}();function he(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}exports.FixedRateCreateProgressStep=void 0,(le=exports.FixedRateCreateProgressStep||(exports.FixedRateCreateProgressStep={}))[le.CreatingExchange=0]="CreatingExchange",le[le.ApprovingDatatoken=1]="ApprovingDatatoken";var me=/*#__PURE__*/function(){function e(e,t,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),this.GASLIMIT_DEFAULT=1e6,this.oceanAddress=null,this.fixedRateAddress=void 0,this.fixedRateExchangeAbi=void 0,this.fixedRateContract=void 0,this.web3=void 0,this.contract=null,this.config=void 0,this.ssAbi=void 0,this.web3=e,this.config=o||V[0],this.fixedRateExchangeAbi=r||E.default.abi,this.oceanAddress=n,this.fixedRateAddress=t,this.contract=U(new this.web3.eth.Contract(this.fixedRateExchangeAbi,this.fixedRateAddress),this.config)}var t=e.prototype;return t.amountToUnits=function(e,t){try{var r=function(){return new P.default(parseInt(t)*Math.pow(10,n)).toString()},n=18,o=U(new this.web3.eth.Contract(A.default.abi,e),this.config),i=he(function(){return Promise.resolve(o.methods.decimals().call()).then(function(e){n=e})},function(){I.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t){try{var r=function(){return new P.default(parseInt(t)/Math.pow(10,n)).toString()},n=18,o=U(new this.web3.eth.Contract(A.default.abi,e),this.config),i=he(function(){return Promise.resolve(o.methods.decimals().call()).then(function(e){n=e})},function(){I.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.generateExchangeId=function(e,t,r){try{return Promise.resolve(this.contract.methods.generateExchangeId(e,t,r).call())}catch(e){return Promise.reject(e)}},t.estBuyDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,a=this.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.buyDT(t,r.toString(),n.toString()).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyDT=function(e,t,r,n){try{var o=this,i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.datatoken,r)).then(function(r){var i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.baseToken,n)).then(function(n){return Promise.resolve(o.estBuyDT(e,t,r,n)).then(function(i){return he(function(){var s=o.contract.methods.buyDT(t,r,n),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:i+1,gasPrice:t}))})},function(e){return I.error("ERROR: Failed to buy datatokens: "+e.message),null})})})})})})}catch(e){return Promise.reject(e)}},t.estSellDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,a=this.GASLIMIT_DEFAULT,c=he(function(){return Promise.resolve(s.methods.sellDT(t,r,n).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(c&&c.then?c.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.sellDT=function(e,t,r,n){try{var o=this,i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.datatoken,r)).then(function(r){var i=o.amountToUnits;return Promise.resolve(o.getExchange(t)).then(function(s){return Promise.resolve(i.call(o,s.baseToken,n)).then(function(n){return Promise.resolve(o.estBuyDT(e,t,r,n)).then(function(i){return he(function(){var s=o.contract.methods.sellDT(t,r,n),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:i+1,gasPrice:t}))})},function(e){return I.error("ERROR: Failed to sell datatokens: "+e.message),null})})})})})})}catch(e){return Promise.reject(e)}},t.getNumberOfExchanges=function(){try{return Promise.resolve(this.contract.methods.getNumberOfExchanges().call())}catch(e){return Promise.reject(e)}},t.estSetRate=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=he(function(){return Promise.resolve(i.methods.setRate(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setRate=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetRate(e,t,n.web3.utils.toWei(String(r)))).then(function(o){var i=n.contract.methods.setRate(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estSetAllowedSwapper=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=he(function(){return Promise.resolve(i.methods.setRate(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetAllowedSwapper(e,t,r)).then(function(o){var i=n.contract.methods.setAllowedSwapper(t,r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estActivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.toggleExchangeState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.activate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!0===n.active?null:Promise.resolve(r.estActivate(e,t)).then(function(n){var o=r.contract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estDeactivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.toggleExchangeState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!1===n.active?null:Promise.resolve(r.estDeactivate(e,t)).then(function(n){var o=r.contract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.getRate=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getRate(e).call()).then(function(e){return t.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},t.getDTSupply=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getDTSupply(e).call()).then(function(r){var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(n.call(t,e.datatoken,r))})})}catch(e){return Promise.reject(e)}},t.getBTSupply=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getBTSupply(e).call()).then(function(r){var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(n.call(t,e.baseToken,r))})})}catch(e){return Promise.reject(e)}},t.getAllowedSwapper=function(e){try{return Promise.resolve(this.contract.methods.getAllowedSwapper(e).call())}catch(e){return Promise.reject(e)}},t.getAmountBTIn=function(e,t){try{var r=this,n=r.contract.methods,o=n.calcBaseInGivenOutDT,i=r.amountToUnits;return Promise.resolve(r.getExchange(e)).then(function(s){return Promise.resolve(i.call(r,s.datatoken,t)).then(function(t){return Promise.resolve(o.call(n,e,t).call()).then(function(t){var n=r.unitsToAmount;return Promise.resolve(r.getExchange(e)).then(function(e){return Promise.resolve(n.call(r,e.baseToken,t.baseTokenAmount))})})})})}catch(e){return Promise.reject(e)}},t.getAmountBTOut=function(e,t){try{var r=this,n=r.contract.methods,o=n.calcBaseOutGivenInDT,i=r.amountToUnits;return Promise.resolve(r.getExchange(e)).then(function(s){return Promise.resolve(i.call(r,s.datatoken,t)).then(function(t){return Promise.resolve(o.call(n,e,t).call()).then(function(t){var n=r.unitsToAmount;return Promise.resolve(r.getExchange(e)).then(function(e){return Promise.resolve(n.call(r,e.baseToken,t.baseTokenAmount))})})})})}catch(e){return Promise.reject(e)}},t.getExchange=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getExchange(e).call()).then(function(r){return r.dtDecimals=r.dtDecimals.toString(),r.btDecimals=r.btDecimals.toString(),Promise.resolve(t.unitsToAmount(r.datatoken,r.dtBalance)).then(function(n){return r.dtBalance=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btBalance)).then(function(n){return r.btBalance=n,Promise.resolve(t.unitsToAmount(r.datatoken,r.dtSupply)).then(function(n){return r.dtSupply=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply)).then(function(n){return r.btSupply=n,r.fixedRate=t.web3.utils.fromWei(r.fixedRate),r.exchangeId=e,r})})})})})}catch(e){return Promise.reject(e)}},t.getFeesInfo=function(e){try{var t=this;return Promise.resolve(t.contract.methods.getFeesInfo(e).call()).then(function(r){r.opfFee=t.web3.utils.fromWei(r.opfFee.toString()),r.marketFee=t.web3.utils.fromWei(r.marketFee.toString());var n=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(o){return Promise.resolve(n.call(t,o.baseToken,r.marketFeeAvailable)).then(function(n){r.marketFeeAvailable=n;var o=t.unitsToAmount;return Promise.resolve(t.getExchange(e)).then(function(n){return Promise.resolve(o.call(t,n.baseToken,r.oceanFeeAvailable)).then(function(t){return r.oceanFeeAvailable=t,r.exchangeId=e,r})})})})})}catch(e){return Promise.reject(e)}},t.getExchanges=function(){try{return Promise.resolve(this.contract.methods.getExchanges().call())}catch(e){return Promise.reject(e)}},t.isActive=function(e){try{return Promise.resolve(this.contract.methods.isActive(e).call())}catch(e){return Promise.reject(e)}},t.estActivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.toggleMintState(t,!0).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.activateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!0===n.withMint?null:Promise.resolve(r.estActivateMint(e,t)).then(function(n){var o=r.contract.methods.toggleMintState(t,!0),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estDeactivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.toggleMintState(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.deactivateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?!1===n.withMint?null:Promise.resolve(r.estDeactivate(e,t)).then(function(n){var o=r.contract.methods.toggleMintState(t,!1),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectBT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.collectBT(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectBT=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectBT(e,t)).then(function(n){var o=r.contract.methods.collectBT(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectDT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.collectDT(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectDT=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectDT(e,t)).then(function(n){var o=r.contract.methods.collectDT(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectMarketFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.collectMarketFee(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectMarketFee(e,t)).then(function(n){var o=r.contract.methods.collectMarketFee(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.estCollectOceanFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=he(function(){return Promise.resolve(o.methods.collectMarketFee(t).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.collectOceanFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(t)).then(function(n){return n?Promise.resolve(r.estCollectOceanFee(e,t)).then(function(n){var o=r.contract.methods.collectOceanFee(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})}):null})}catch(e){return Promise.reject(e)}},t.getOPFCollector=function(){try{var e=this,t=null,r=he(function(){return Promise.resolve(e.contract.methods.opfCollector().call()).then(function(e){t=e})},function(e){I.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(r&&r.then?r.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},t.getRouter=function(){try{var e=this,t=null,r=he(function(){return Promise.resolve(e.contract.methods.router().call()).then(function(e){t=e})},function(e){I.error("ERROR: Failed to get Router address: "+e.message)});return Promise.resolve(r&&r.then?r.then(function(){return t}):t)}catch(e){return Promise.reject(e)}},t.getExchangeOwner=function(e){try{var t=this,r=null,n=he(function(){return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(e.exchangeOwner).then(function(e){r=e})})},function(e){I.error("ERROR: Failed to get OPF Collector address: "+e.message)});return Promise.resolve(n&&n.then?n.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.estUpdateMarketFee=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=he(function(){return Promise.resolve(i.methods.updateMarketFee(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFee=function(e,t,r){try{var n=this;return Promise.resolve(n.estSetRate(e,t,n.web3.utils.toWei(r))).then(function(o){var i=n.contract.methods.updateMarketFee(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,a=he(function(){return Promise.resolve(i.methods.updateMarketFeeCollector(t,r).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.estUpdateMarketFeeCollector(e,t,r)).then(function(o){var i=n.contract.methods.updateMarketFeeCollector(t,r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},e}();function de(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ve=/*#__PURE__*/function(){function e(e,t,r){this.GASLIMIT_DEFAULT=1e6,this.factory721Address=void 0,this.factory721Abi=void 0,this.nftAbi=void 0,this.web3=void 0,this.startBlock=void 0,this.config=void 0,this.nftAbi=t||F.default.abi,this.web3=e,this.config=r||V[0]}var t=e.prototype;return t.estGasCreateErc20=function(e,t,r,n,o,i,s,a,c,u,l,f){try{var h,m=this,d=f||U(new m.web3.eth.Contract(m.nftAbi,e),m.config),v=m.GASLIMIT_DEFAULT,P=de(function(){return Promise.resolve(d.methods.createERC20(l,[c,u],[r,n,o,i],[m.web3.utils.toWei(a),m.web3.utils.toWei(s)],[]).estimateGas({from:t},function(e,t){return e?v:t})).then(function(e){h=e})},function(){h=v});return Promise.resolve(P&&P.then?P.then(function(){return h}):h)}catch(e){return Promise.reject(e)}},t.createErc20=function(e,t,r,n,o,i,s,a,c,u,l){try{var f=this;return Promise.resolve(f.getNftPermissions(e,t)).then(function(h){if(!0!==h.deployERC20)throw new Error("Caller is not ERC20Deployer");if(l||(l=1),!c||!u){var m=x();c=m.name,u=m.symbol}var d=U(new f.web3.eth.Contract(f.nftAbi,e),f.config);return Promise.resolve(f.estGasCreateErc20(e,t,r,n,o,i,s,a,c,u,l,d)).then(function(e){var h=d.methods.createERC20(l,[c,u],[r,n,o,i],[f.web3.utils.toWei(a),f.web3.utils.toWei(s)],[]),m=h.send;return Promise.resolve(O(f.web3,f.config)).then(function(r){return Promise.resolve(m.call(h,{from:t,gas:e+1,gasPrice:r})).then(function(e){var t=null;try{t=e.events.TokenCreated.returnValues[0]}catch(e){I.error("ERROR: Failed to create datatoken : "+e.message)}return t})})})})}catch(e){return Promise.reject(e)}},t.estGasAddManager=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.addManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addManager=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(i){if(i!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(n.estGasAddManager(e,t,r,o)).then(function(e){var i=o.methods.addManager(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveManager=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.removeManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeManager=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(i){if(i!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(n.estGasRemoveManager(e,t,r,o)).then(function(e){var i=o.methods.removeManager(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasAddErc20Deployer=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.addToCreateERC20List(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addErc20Deployer=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddErc20Deployer(e,t,r,o)).then(function(e){var i=o.methods.addToCreateERC20List(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveErc20Deployer=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.removeFromCreateErc20List(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeErc20Deployer=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t===r&&!0!==i.deployERC20)throw new Error("Caller is not Manager nor ERC20Deployer");return Promise.resolve(n.estGasRemoveErc20Deployer(e,t,r,o)).then(function(e){var i=o.methods.removeFromCreateERC20List(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t!==r?s(a||t===r&&n.getNftPermissions(e,t)):Promise.resolve(a||t===r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasAddMetadataUpdater=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.addToMetadataList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMetadataUpdater=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddMetadataUpdater(e,t,r,o)).then(function(e){var i=o.methods.addToMetadataList(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.esGasRemoveMetadataUpdater=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.removeFromMetadataList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMetadataUpdater=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t!==r&&!0!==i.updateMetadata)throw new Error("Caller is not Manager nor Metadata Updater");return Promise.resolve(n.esGasRemoveMetadataUpdater(e,t,r,o)).then(function(e){var i=o.methods.removeFromMetadataList(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t===r?s(a||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(a||t!==r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasAddStoreUpdater=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.addTo725StoreList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addStoreUpdater=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!0!==i.manager)throw new Error("Caller is not Manager");return Promise.resolve(n.estGasAddStoreUpdater(e,t,r,o)).then(function(e){var i=o.methods.addTo725StoreList(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveStoreUpdater=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.removeFrom725StoreList(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeStoreUpdater=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(a||t!==r&&!0!==i.store)throw new Error("Caller is not Manager nor storeUpdater");return Promise.resolve(n.estGasRemoveStoreUpdater(e,t,r,o)).then(function(e){var i=o.methods.removeFrom725StoreList(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var a=!0!==i.manager;return a||t===r?s(a||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(a||t!==r&&n.getNftPermissions(e,t)).then(s)})}catch(e){return Promise.reject(e)}},t.estGasCleanPermissions=function(e,t,r){try{var n,o=this,i=r||U(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=de(function(){return Promise.resolve(i.methods.cleanPermissions().estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(r.getNftOwner(e)).then(function(o){if(o!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(r.estGasCleanPermissions(e,t,n)).then(function(e){var o=n.methods.cleanPermissions(),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(r){return Promise.resolve(i.call(o,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasTransferNft=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.nftAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=de(function(){return Promise.resolve(a.methods.transferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.transferNft=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(s){if(s!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(o.estGasTransferNft(e,t,r,a,i)).then(function(e){var n=i.methods.transferFrom(t,r,a),s=n.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(s.call(n,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSafeTransferNft=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.nftAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=de(function(){return Promise.resolve(a.methods.safeTransferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.safeTransferNft=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(s){if(s!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(o.estGasSafeTransferNft(e,t,r,a,i)).then(function(e){var n=i.methods.safeTransferFrom(t,r,a),s=n.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(s.call(n,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l,f=this,h=u||U(new f.web3.eth.Contract(f.nftAbi,e),f.config),m=f.GASLIMIT_DEFAULT,d=de(function(){return Promise.resolve(h.methods.setMetaData(r,n,o,i,s,a,c).estimateGas({from:t},function(e,t){return e?m:t})).then(function(e){l=e})},function(){l=m});return Promise.resolve(d&&d.then?d.then(function(){return l}):l)}catch(e){return Promise.reject(e)}},t.setMetadata=function(e,t,r,n,o,i,s,a,c){try{var u=this,l=U(new u.web3.eth.Contract(u.nftAbi,e),u.config);return c||(c=[]),Promise.resolve(u.getNftPermissions(e,t)).then(function(f){if(!f.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(u.estGasSetMetadata(e,t,r,n,o,i,s,a,c,l)).then(function(e){var f=l.methods.setMetaData(r,n,o,i,s,a,c),h=f.send;return Promise.resolve(O(u.web3,u.config)).then(function(r){return Promise.resolve(h.call(f,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadataAndTokenURI=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.setMetaDataAndTokenURI(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setMetadataAndTokenURI=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!i.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(n.estGasSetMetadataAndTokenURI(e,t,r,o)).then(function(e){var i=o.methods.setMetaDataAndTokenURI(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadataState=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.nftAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=de(function(){return Promise.resolve(s.methods.setMetaDataState(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setMetadataState=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){if(!i.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(n.estGasSetMetadataState(e,t,r)).then(function(e){var i=o.methods.setMetaDataState(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estSetTokenURI=function(e,t,r){try{var n,o=this,i=U(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=de(function(){return Promise.resolve(i.methods.setTokenURI("1",r).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.setTokenURI=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.estSetTokenURI(e,t,r)).then(function(e){var i=o.methods.setTokenURI("1",r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}catch(e){return Promise.reject(e)}},t.getNftOwner=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.nftAbi,e),t.config);return Promise.resolve(r.methods.ownerOf(1).call())}catch(e){return Promise.reject(e)}},t.getNftPermissions=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.getPermissions(t).call())}catch(e){return Promise.reject(e)}},t.getMetadata=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.nftAbi,e),t.config);return Promise.resolve(r.methods.getMetaData().call())}catch(e){return Promise.reject(e)}},t.isErc20Deployer=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.isERC20Deployer(t).call())}catch(e){return Promise.reject(e)}},t.getData=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.getData(t).call())}catch(e){return Promise.reject(e)}},t.getTokenURI=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(n.methods.tokenURI(t).call())}catch(e){return Promise.reject(e)}},e}();function Pe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ge=/*#__PURE__*/function(){function e(e,t,r,n){this.GASLIMIT_DEFAULT=1e6,this.factoryAddress=void 0,this.factoryABI=void 0,this.datatokensAbi=void 0,this.datatokensEnterpriseAbi=void 0,this.web3=void 0,this.config=void 0,this.nft=void 0,this.web3=e,this.datatokensAbi=t||A.default.abi,this.datatokensEnterpriseAbi=r||C.default.abi,this.config=n||V[0],this.nft=new ve(this.web3)}var t=e.prototype;return t.estGasApprove=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(a.methods.approve(t,s.web3.utils.toWei(r)).estimateGas({from:n},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.approve=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(o.estGasApprove(e,t,r,n,i)).then(function(e){var s=i.methods.approve(t,o.web3.utils.toWei(r)),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:n,gas:e+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasMint=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(a.methods.mint(n||t,s.web3.utils.toWei(r)).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.estGasCreateFixedRate=function(e,t,r,n){try{var o=this,i=n||U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT;r.allowedConsumer||(r.allowedConsumer="0x0000000000000000000000000000000000000000");var a,c=r.withMint?1:0,u=Pe(function(){return Promise.resolve(i.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,t,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,c]).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){a=e})},function(){a=s});return Promise.resolve(u&&u.then?u.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},t.createFixedRate=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!i)throw new Error("User is not ERC20 Deployer");r.allowedConsumer||(r.allowedConsumer="0x0000000000000000000000000000000000000000");var s=r.withMint?1:0;return Promise.resolve(n.estGasCreateFixedRate(e,t,r,o)).then(function(e){var i=o.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,s]),a=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasCreateDispenser=function(e,t,r,n,o){try{var i=this,s=o||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);n.allowedSwapper||(n.allowedSwapper="0x0000000000000000000000000000000000000000"),n.withMint||(n.withMint=!1);var a,c=i.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){a=e})},function(){a=c});return Promise.resolve(u&&u.then?u.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},t.createDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isERC20Deployer(e,t)).then(function(i){if(!i)throw new Error("User is not ERC20 Deployer");var s=U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return n.allowedSwapper||(n.allowedSwapper="0x0000000000000000000000000000000000000000"),n.withMint||(n.withMint=!1),Promise.resolve(o.estGasCreateDispenser(e,t,r,n,s)).then(function(e){var i=s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper),a=i.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.mint=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(o.getDTPermissions(e,t)).then(function(s){if(!0!==s.minter)throw new Error("Caller is not Minter");return Promise.resolve(o.getCap(e)).then(function(s){if(new b.default(s).gte(r))return Promise.resolve(o.estGasMint(e,t,r,n,i)).then(function(e){var s=i.methods.mint(n||t,o.web3.utils.toWei(r)),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},t.estGasAddMinter=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.addMinter(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMinter=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasAddMinter(e,t,r,o)).then(function(e){var i=o.methods.addMinter(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemoveMinter=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.removeMinter(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMinter=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasRemoveMinter(e,t,r,o)).then(function(e){var i=o.methods.removeMinter(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasAddPaymentManager=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.addPaymentManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addPaymentManager=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasAddPaymentManager(e,t,r,o)).then(function(e){var i=o.methods.addPaymentManager(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasRemovePaymentManager=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.removePaymentManager(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removePaymentManager=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(i){if(!0!==i)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(n.estGasRemovePaymentManager(e,t,r,o)).then(function(e){var i=o.methods.removePaymentManager(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetPaymentCollector=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.setPaymentCollector(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setPaymentCollector=function(e,t,r){try{var n=this,o=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.getDTPermissions(e,t)).then(function(i){if(!0!==i.paymentManager)throw new Error("Caller is not Fee Manager");return Promise.resolve(n.estGasSetPaymentCollector(e,t,r,o)).then(function(e){var i=o.methods.setPaymentCollector(r),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.getPaymentCollector=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.getPaymentCollector().call())}catch(e){return Promise.reject(e)}},t.transfer=function(e,t,r,n){try{var o=this.web3.utils.toWei(r);return Promise.resolve(this.transferWei(e,t,o,n))}catch(e){return Promise.reject(e)}},t.estGasTransfer=function(e,t,r,n,o){try{var i,s=this,a=o||U(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),c=s.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(a.methods.transfer(t,r).estimateGas({from:n},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.transferWei=function(e,t,r,n){try{var o=this,i=U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(Pe(function(){return Promise.resolve(o.estGasTransfer(e,t,r,n,i)).then(function(e){var s=i.methods.transfer(t,r),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:n,gas:e+1,gasPrice:t}))})})},function(e){throw I.error("ERROR: Failed to transfer tokens: "+e.message),new Error("Failed Failed to transfer tokens: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasStartOrder=function(e,t,r,n,o,i){try{var s,a=this,c=i||U(new a.web3.eth.Contract(a.datatokensAbi,e),a.config),u=a.GASLIMIT_DEFAULT,l=Pe(function(){return Promise.resolve(c.methods.startOrder(r,n,o).estimateGas({from:t},function(e,t){return e?u:t})).then(function(e){s=e})},function(){s=u});return Promise.resolve(l&&l.then?l.then(function(){return s}):s)}catch(e){return Promise.reject(e)}},t.startOrder=function(e,t,r,n,o){try{var i=this,s=U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(Pe(function(){return Promise.resolve(i.estGasStartOrder(e,t,r,n,o,s)).then(function(e){var a=s.methods.startOrder(r,n,o),c=a.send;return Promise.resolve(O(i.web3,i.config)).then(function(r){return Promise.resolve(c.call(a,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw I.error("ERROR: Failed to start order : "+e.message),new Error("Failed to start order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasBuyFromFreAndOrder=function(e,t,r,n,o){try{var i,s=this,a=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),c=s.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(a.methods.buyFromFreAndOrder(r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=new o.web3.eth.Contract(o.datatokensEnterpriseAbi,e);return Promise.resolve(Pe(function(){return Promise.resolve(o.estGasBuyFromFreAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromFreAndOrder(r,n),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw I.error("ERROR: Failed to buy DT From Fre And Order : "+e.message),new Error("Failed to buy DT From Fre And Order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasBuyFromDispenserAndOrder=function(e,t,r,n,o){try{var i,s=this,a=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),c=s.GASLIMIT_DEFAULT,u=Pe(function(){return Promise.resolve(a.methods.buyFromDispenserAndOrder(r,n).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=new o.web3.eth.Contract(o.datatokensEnterpriseAbi,e);return Promise.resolve(Pe(function(){return Promise.resolve(o.estGasBuyFromDispenserAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromDispenserAndOrder(r,n),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(s,{from:t,gas:e+1,gasPrice:r}))})})},function(e){throw I.error("ERROR: Failed to buy DT From Fre And Order : "+e.message),new Error("Failed to buy DT From Fre And Order: "+e.message)}))}catch(e){return Promise.reject(e)}},t.estGasSetData=function(e,t,r,n){try{var o,i=this,s=n||U(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),a=i.GASLIMIT_DEFAULT,c=Pe(function(){return Promise.resolve(s.methods.setData(r).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){o=e})},function(){o=a});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setData=function(e,t,r){try{var n=this;return Promise.resolve(n.isERC20Deployer(e,t)).then(function(o){if(!o)throw new Error("User is not ERC20 Deployer");var i=U(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.estGasSetData(e,t,r,i)).then(function(e){var o=i.methods.setData(r),s=o.send;return Promise.resolve(O(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(o,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasCleanPermissions=function(e,t,r){try{var n,o=this,i=r||U(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT,a=Pe(function(){return Promise.resolve(i.methods.cleanPermissions().estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){n=e})},function(){n=s});return Promise.resolve(a&&a.then?a.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=r.nft,o=n.getNftOwner;return Promise.resolve(r.getNFTAddress(e)).then(function(i){return Promise.resolve(o.call(n,i)).then(function(n){if(n!==t)throw new Error("Caller is NOT Nft Owner");var o=U(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(r.estGasCleanPermissions(e,t,o)).then(function(e){var n=o.methods.cleanPermissions(),i=n.send;return Promise.resolve(O(r.web3,r.config)).then(function(r){return Promise.resolve(i.call(n,{from:t,gas:e+1,gasPrice:r}))})})})})}catch(e){return Promise.reject(e)}},t.getDTPermissions=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(n.methods.permissions(t).call())}catch(e){return Promise.reject(e)}},t.getCap=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.cap().call()).then(function(e){return t.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},t.getDecimals=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.decimals().call())}catch(e){return Promise.reject(e)}},t.getNFTAddress=function(e){try{var t=this,r=U(new t.web3.eth.Contract(t.datatokensAbi,e),t.config);return Promise.resolve(r.methods.getERC721Address().call())}catch(e){return Promise.reject(e)}},t.isERC20Deployer=function(e,t){try{var r=this,n=U(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(n.methods.isERC20Deployer(t).call())}catch(e){return Promise.reject(e)}},t.balance=function(e,t){try{var r=this,n=new r.web3.eth.Contract(r.datatokensAbi,e,{from:t});return Promise.resolve(n.methods.balanceOf(t).call()).then(function(e){return r.web3.utils.fromWei(e)})}catch(e){return Promise.reject(e)}},e}();function pe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var we="0x0000000000000000000000000000000000000000",be=/*#__PURE__*/function(){function e(e,t,r,n){this.GASLIMIT_DEFAULT=1e6,this.factory721Address=void 0,this.factory721Abi=void 0,this.web3=void 0,this.config=void 0,this.factory721=void 0,this.factory721Address=e,this.factory721Abi=r||R.default.abi,this.web3=t,this.config=n||V[0],this.factory721=U(new this.web3.eth.Contract(this.factory721Abi,this.factory721Address),this.config)}var t=e.prototype;return t.estGasCreateNFT=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,we,t.tokenURI).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.createNFT=function(e,t){try{var r=this;if(t.templateIndex||(t.templateIndex=1),!t.name||!t.symbol){var n=x(),o=n.symbol;t.name=n.name,t.symbol=o}var i=t.templateIndex;return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(i>n)throw new Error("Template index doesnt exist");if(0===t.templateIndex)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(t.templateIndex)).then(function(n){if(!1===n.isActive)throw new Error("Template is not active");return Promise.resolve(r.estGasCreateNFT(e,t)).then(function(n){var o=r.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,we,t.tokenURI),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t})).then(function(e){var t=null;try{t=e.events.NFTCreated.returnValues[0]}catch(e){I.error("ERROR: Failed to create datatoken : "+e.message)}return t})})})})})}catch(e){return Promise.reject(e)}},t.getCurrentNFTCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTCount().call())}catch(e){return Promise.reject(e)}},t.getCurrentTokenCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTokenCount().call())}catch(e){return Promise.reject(e)}},t.getOwner=function(){try{return Promise.resolve(this.factory721.methods.owner().call())}catch(e){return Promise.reject(e)}},t.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTTemplateCount().call())}catch(e){return Promise.reject(e)}},t.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTemplateCount().call())}catch(e){return Promise.reject(e)}},t.getNFTTemplate=function(e){try{var t=this;return Promise.resolve(t.getCurrentNFTTemplateCount()).then(function(r){if(e>r)throw new Error("Template index doesnt exist");if(0===e)throw new Error("Template index cannot be ZERO");return Promise.resolve(t.factory721.methods.getNFTTemplate(e).call())})}catch(e){return Promise.reject(e)}},t.getTokenTemplate=function(e){try{return Promise.resolve(this.factory721.methods.getTokenTemplate(e).call())}catch(e){return Promise.reject(e)}},t.checkDatatoken=function(e){try{return Promise.resolve(this.factory721.methods.erc20List(e).call())}catch(e){return Promise.reject(e)}},t.checkNFT=function(e){try{return Promise.resolve(this.factory721.methods.erc721List(e).call())}catch(e){return Promise.reject(e)}},t.estGasAddNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.add721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.addNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");if(t===we)throw new Error("Template cannot be ZERO address");return Promise.resolve(r.estGasAddNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.add721TokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},t.estGasDisableNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.disable721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.disableNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.estGasDisableNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.disable721TokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})}catch(e){return Promise.reject(e)}},t.estGasReactivateNFTTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.reactivate721TokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.reactivateNFTTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.estGasReactivateNFTTemplate(e,t)).then(function(n){var o=r.factory721.methods.reactivate721TokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})}catch(e){return Promise.reject(e)}},t.estGasAddTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.addTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.addTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");if(t===we)throw new Error("Template cannot be address ZERO");return Promise.resolve(r.estGasAddTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.addTokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},t.estGasDisableTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.disableTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.disableTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(t)).then(function(n){if(!1===n.isActive)throw new Error("Template is already disabled");return Promise.resolve(r.estGasDisableTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.disableTokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})})}catch(e){return Promise.reject(e)}},t.estGasReactivateTokenTemplate=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.reactivateTokenTemplate(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.reactivateTokenTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(t>n)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getTokenTemplate(t)).then(function(n){if(!0===n.isActive)throw new Error("Template is already active");return Promise.resolve(r.estGasReactivateTokenTemplate(e,t)).then(function(n){var o=r.factory721.methods.reactivateTokenTemplate(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})})})})}catch(e){return Promise.reject(e)}},t.estGasStartMultipleTokenOrder=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=pe(function(){return Promise.resolve(n.factory721.methods.startMultipleTokenOrder(t).estimateGas({from:e},function(e,t){return e?o:t})).then(function(e){r=e})},function(){r=o});return Promise.resolve(i&&i.then?i.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},t.startMultipleTokenOrder=function(e,t){try{var r=this;if(t.length>50)throw new Error("Too many orders");return Promise.resolve(r.estGasStartMultipleTokenOrder(e,t)).then(function(n){var o=r.factory721.methods.startMultipleTokenOrder(t),i=o.send;return Promise.resolve(O(r.web3,r.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftWithErc=function(e,t,r){try{var n,o=this,i=o.GASLIMIT_DEFAULT,s=pe(function(){var s=D(r);return Promise.resolve(o.factory721.methods.createNftWithErc(t,s).estimateGas({from:e},function(e,t){return e?i:t})).then(function(e){n=e})},function(){n=i});return Promise.resolve(s&&s.then?s.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.createNftWithErc=function(e,t,r){try{var n=this,o=D(r);return Promise.resolve(n.estGasCreateNftWithErc(e,t,r)).then(function(r){var i=n.factory721.methods.createNftWithErc(t,o),s=i.send;return Promise.resolve(O(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithPool=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=pe(function(){var a=D(r),c=W(n);return Promise.resolve(i.factory721.methods.createNftErcWithPool(t,a,c).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithPool=function(e,t,r,n){try{var o=this;return Promise.resolve(o.estGasCreateNftErcWithPool(e,t,r,n)).then(function(i){var s=D(r),a=W(n),c=o.factory721.methods.createNftErcWithPool(t,s,a),u=c.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(u.call(c,{from:e,gas:i+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithFixedRate=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=D(r),c=N(n),u=pe(function(){return Promise.resolve(i.factory721.methods.createNftErcWithFixedRate(t,a,c).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(u&&u.then?u.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithFixedRate=function(e,t,r,n){try{var o=this,i=D(r),s=N(n);return Promise.resolve(o.estGasCreateNftErcWithFixedRate(e,t,r,n)).then(function(r){var n=o.factory721.methods.createNftErcWithFixedRate(t,i,s),a=n.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(n,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},t.estGasCreateNftErcWithDispenser=function(e,t,r,n){try{var o,i=this,s=i.GASLIMIT_DEFAULT,a=D(r),c=pe(function(){return Promise.resolve(i.factory721.methods.createNftErcWithDispenser(t,a,n).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(e){o=s,I.error("Failed to estimate gas for createNftErcWithDispenser",e)});return Promise.resolve(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithDispenser=function(e,t,r,n){try{var o=this,i=D(r);return Promise.resolve(o.estGasCreateNftErcWithDispenser(e,t,r,n)).then(function(r){var s=o.factory721.methods.createNftErcWithDispenser(t,i,n),a=s.send;return Promise.resolve(O(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},e}(),ye=function(e){return function(e,t){void 0===e&&(e="");var r=function(e,t,r){if("string"!=typeof e)throw I.debug("Not input string:"),I.debug(e),new Error("[zeroXTransformer] Expected string, input type: "+typeof e);var n=e.match(/^(?:0x)*([a-f0-9]+)$/i);return n?{valid:!0,output:n[1]}:(I.warn("[zeroXTransformer] Input transformation failed."),{valid:!1,output:e})}(e);return""+r.output}(e)};function Ae(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Te=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getEndpoints=function(e){try{return Promise.resolve(Ae(function(){return Promise.resolve(_(e)).then(function(e){return Promise.resolve(e.json())})},function(e){return I.error("Finding the service endpoints failed:",e),null}))}catch(e){return Promise.reject(e)}},t.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName===t}):null},t.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints)r.push({serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e+t.serviceEndpoints[n][1]});return Promise.resolve(r)}catch(e){return Promise.reject(e)}},t.getNonce=function(e,t,r,n,o){try{var i=function(){function i(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?Ae(function(){return Promise.resolve(g.default(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){var t=String;return Promise.resolve(e.json()).then(function(e){return t(e.nonce)})})},function(e){throw I.error(e),new Error("HTTP request failed")}):null}var a=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return a&&a.then?a.then(i):i()},s=this,a=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},t.createSignature=function(e,t,r){try{return Promise.resolve(K(e,ye(r),t))}catch(e){return Promise.reject(e)}},t.createHashSignature=function(e,t,r){try{return Promise.resolve($(e,r,t))}catch(e){return Promise.reject(e)}},t.encrypt=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(t)).then(function(o){return Promise.resolve(n.getServiceEndpoints(t,o)).then(function(t){var o=n.getEndpointURL(t,"encrypt")?n.getEndpointURL(t,"encrypt").urlPath:null;return o?Ae(function(){return Promise.resolve(g.default(o,{method:"POST",body:decodeURI(JSON.stringify(e)),headers:{"Content-Type":"application/octet-stream"},signal:r})).then(function(e){return Promise.resolve(e.text())})},function(e){throw I.error(e),new Error("HTTP request failed")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(r)).then(function(i){return Promise.resolve(o.getServiceEndpoints(r,i)).then(function(r){var i={did:e,serviceId:t},s=[],a=o.getEndpointURL(r,"fileinfo")?o.getEndpointURL(r,"fileinfo").urlPath:null;return a?Ae(function(){return Promise.resolve(g.default(a,{method:"POST",body:JSON.stringify(i),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){return Promise.resolve(e.json()).then(function(e){for(var t,r=H(e);!(t=r()).done;)s.push(t.value);return s})})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.checkFileUrl=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(t)).then(function(o){return Promise.resolve(n.getServiceEndpoints(t,o)).then(function(t){var o={url:e,type:"url"},i=[],s=n.getEndpointURL(t,"fileinfo")?n.getEndpointURL(t,"fileinfo").urlPath:null;return s?Ae(function(){return Promise.resolve(g.default(s,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return Promise.resolve(e.json()).then(function(e){for(var t,r=H(e);!(t=r()).done;)i.push(t.value);return i})})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(o)).then(function(l){return Promise.resolve(u.getServiceEndpoints(o,l)).then(function(o){var l=u.getEndpointURL(o,"initialize")?u.getEndpointURL(o,"initialize").urlPath:null;return l?(l+="?documentId="+e,l+="&serviceId="+t,l+="&fileIndex="+r,l+="&consumerAddress="+n,s&&(l+="&userdata="+encodeURI(JSON.stringify(s))),a&&(l+="&computeEnv="+encodeURI(a)),c&&(l+="&validUntil="+c),Ae(function(){return Promise.resolve(g.default(l,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){return Promise.resolve(e.json())})},function(e){throw I.error(e),new Error("Asset URL not found or not available.")})):null})})}catch(e){return Promise.reject(e)}},t.getDownloadUrl=function(e,t,r,n,o,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(i)).then(function(u){return Promise.resolve(c.getServiceEndpoints(i,u)).then(function(i){var u=c.getEndpointURL(i,"download")?c.getEndpointURL(i,"download").urlPath:null;if(!u)return null;var l=Date.now();return Promise.resolve(c.createSignature(s,t,e+l)).then(function(i){var s=u;return s+="?fileIndex="+n,s+="&documentId="+e,s+="&transferTxId="+o,s+="&serviceId="+r,s+="&consumerAddress="+t,s+="&nonce="+l,s+="&signature="+i,a&&(s+="&userdata="+encodeURI(JSON.stringify(a))),s})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(e)).then(function(l){return Promise.resolve(u.getServiceEndpoints(e,l)).then(function(e){var l=u.getEndpointURL(e,"computeStart")?u.getEndpointURL(e,"computeStart").urlPath:null,f=Date.now(),h=r;return h+=o.documentId,h+=f,Promise.resolve(u.createHashSignature(t,r,h)).then(function(e){var t=Object();return t.consumerAddress=r,t.signature=e,t.nonce=f,t.computeEnv=n,t.dataset=o,t.algorithm=i,t.additionalDatasets&&(t.additionalDatasets=a),c&&(t.output=c),l?Ae(function(){return Promise.resolve(g.default(l,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){var r;function n(n){return r?n:(console.error("Compute start failed:",e.status,e.statusText),I.error("Payload was:",t),null)}var o=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)})},function(e){return I.error("Compute start failed:"),I.error(e),I.error("Payload was:",t),null}):null})})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(c){var u=s.getEndpointURL(c,"computeStop")?s.getEndpointURL(c,"computeStop").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,c)).then(function(n){var a=t;return a+=r||"",a+=e&&""+ye(e)||"",a+=n,Promise.resolve(s.createHashSignature(o,t,a)).then(function(n){var o=Object();return o.signature=n,o.documentId=ye(e),o.consumerAddress=t,r&&(o.jobId=r),u?Ae(function(){return Promise.resolve(g.default(u,{method:"PUT",body:JSON.stringify(o),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){var t;function r(r){return t?r:(I.error("Compute stop failed:",e.status,e.statusText),I.error("Payload was:",o),null)}var n=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)})},function(e){return I.error("Compute stop failed:"),I.error(e),I.error("Payload was:",o),null}):null})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,n,o){try{var i=this;if(!r&&!n&&!o)throw new Error("You need at least one of jobId, did, consumerAddress");return Promise.resolve(i.getEndpoints(e)).then(function(s){return Promise.resolve(i.getServiceEndpoints(e,s)).then(function(e){var s=i.getEndpointURL(e,"computeStatus")?i.getEndpointURL(e,"computeStatus").urlPath:null,a="?documentId="+ye(n);return a+="&consumerAddress="+o,a+=r&&"&jobId="+r||"",s?Ae(function(){return Promise.resolve(g.default(s+a,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t;function r(r){return t?r:(I.error("Get compute status failed:",e.status,e.statusText),null)}var n=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)})},function(e){return I.error("Get compute status failed"),I.error(e),null}):null})})}catch(e){return Promise.reject(e)}},t.computeResult=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(c){var u=s.getEndpointURL(c,"computeResult")?s.getEndpointURL(c,"computeResult").urlPath:null;return Promise.resolve(s.getNonce(n,r,i,a,c)).then(function(n){var i=r;return i+=e,i+=String(t),i+=n,Promise.resolve(s.createHashSignature(o,r,i)).then(function(n){var o=u;return o+="?consumerAddress="+r,o+="&jobId="+e,o+="&index="+String(t),o+=n&&"&signature="+n||"",u?Ae(function(){return document?Promise.resolve(q(o)).then(function(){}):Promise.resolve(B(o,t))},function(e){throw I.error("Error getting job result"),I.error(e),e}):null})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(c){var u=s.getEndpointURL(c,"computeDelete")?s.getEndpointURL(c,"computeDelete").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,c)).then(function(n){var a=t;return a+=r||"",a+=e&&""+ye(e)||"",a+=n,Promise.resolve(s.createHashSignature(o,t,a)).then(function(n){var o=Object();return o.documentId=ye(e),o.consumerAddress=t,o.jobId=r,n&&(o.signature=n),u?Ae(function(){return Promise.resolve(g.default(u,{method:"DELETE",body:JSON.stringify(o),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){var t;function r(r){return t?r:(I.error("Delete compute job failed:",e.status,e.statusText),I.error("Payload was:",o),null)}var n=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)})},function(e){return I.error("Delete compute job failed:"),I.error(e),I.error("Payload was:",o),null}):null})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(Ae(function(){return Promise.resolve(g.default(e,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t,r=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){if(e&&e.providerAddress)return t=!0})}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return I.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},e}(),Ee=new Te;exports.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.erc721FactoryAddress=void 0,this.erc721FFactoryABI=void 0,this.datatokensABI=void 0,this.poolTemplateAddress=void 0,this.poolFactoryABI=void 0,this.poolABI=void 0,this.fixedRateExchangeAddress=void 0,this.fixedRateExchangeAddressABI=void 0,this.dispenserAddress=void 0,this.dispenserABI=void 0,this.opfCommunityFeeCollector=void 0,this.sideStakingAddress=void 0,this.startBlock=void 0,this.verbose=void 0,this.authMessage=void 0,this.authTokenExpiration=void 0,this.parityUri=void 0,this.threshold=void 0,this.chainId=void 0,this.network=void 0,this.subgraphUri=void 0,this.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0},exports.ConfigHelper=X,exports.Datatoken=ge,exports.Dispenser=fe,exports.FixedRateExchange=me,exports.GASLIMIT_DEFAULT=1e6,exports.Logger=k,exports.LoggerInstance=I,exports.Nft=ve,exports.NftFactory=be,exports.Pool=ce,exports.Provider=Te,exports.ProviderInstance=Ee,exports.ZERO_ADDRESS="0x0000000000000000000000000000000000000000",exports.allowance=ee,exports.amountToUnits=M,exports.approve=function(e,t,r,n,o,i){void 0===i&&(i=!1);try{var s,a=function(i){if(s)return i;var a=null;return Promise.resolve(M(e,r,o)).then(function(o){return Promise.resolve(te(e,t,r,n,o,c)).then(function(r){var i=Y(function(){var i=c.methods.approve(n,o),s=i.send;return Promise.resolve(O(e,null)).then(function(e){return Promise.resolve(s.call(i,{from:t,gas:r+1,gasPrice:e})).then(function(e){a=e})})},function(e){I.error("ERRPR: Failed to approve spender to spend tokens : "+e.message)});return i&&i.then?i.then(function(){return a}):a})})},c=new e.eth.Contract(S,r),u=function(){if(!i)return Promise.resolve(ee(e,r,t,n)).then(function(e){if(new b.default(e).greaterThanOrEqualTo(new b.default(o)))return s=1,e})}();return Promise.resolve(u&&u.then?u.then(a):a(u))}catch(e){return Promise.reject(e)}},exports.balance=function(e,t,r){try{var n=new e.eth.Contract(S,t);return Promise.resolve(n.methods.balanceOf(r).call()).then(function(r){return Promise.resolve(L(e,t,r))})}catch(e){return Promise.reject(e)}},exports.configHelperNetworks=V,exports.downloadFile=B,exports.downloadFileBrowser=q,exports.estApprove=te,exports.fetchData=function(e,t){try{return Promise.resolve(g.default(e,t)).then(function(r){var n=function(){if(!r.ok){I.error("Error requesting ["+t.method+"] "+e);var n=I.error;return Promise.resolve(r.text()).then(function(e){throw n.call(I,"Response message: \n"+e),r})}}();return n&&n.then?n.then(function(e){return r}):r})}catch(e){return Promise.reject(e)}},exports.generateDid=function(e,t){return e=v.default.utils.toChecksumAddress(e),"did:op:"+w.default(e+t.toString(10)).toString()},exports.generateDtName=x,exports.getData=_,exports.getErcCreationParams=D,exports.getFairGasPrice=O,exports.getFreCreationParams=N,exports.getHash=function(e){return w.default(e).toString()},exports.getPoolCreationParams=W,exports.postData=function(e,t){return function(e,t,r){try{return Promise.resolve(g.default(e,null!=t?{method:"POST",body:t,headers:{"Content-type":"application/json"}}:{method:"POST"}))}catch(e){return Promise.reject(e)}}(e,t)},exports.setContractDefaults=U,exports.signHash=function(e,t,r){try{return Promise.resolve(e.eth.sign(t,r)).then(function(e){var t="0x"+(e=e.substr(2)).slice(0,64),r="0x"+e.slice(64,128),n="0x"+e.slice(128,130);return"0x00"===n&&(n="0x1b"),"0x01"===n&&(n="0x1c"),{v:n,r:t,s:r}})}catch(e){return Promise.reject(e)}},exports.signText=K,exports.signWithHash=$,exports.unitsToAmount=L;
2
2
  //# sourceMappingURL=lib.js.map