@oceanprotocol/lib 1.0.0-next.7 → 1.0.0

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +405 -1
  2. package/CodeExamples.md +918 -0
  3. package/README.md +12 -80
  4. package/dist/lib.js +1 -1
  5. package/dist/lib.js.map +1 -1
  6. package/dist/lib.modern.js +1 -1
  7. package/dist/lib.modern.js.map +1 -1
  8. package/dist/lib.module.js +1 -1
  9. package/dist/lib.module.js.map +1 -1
  10. package/dist/lib.umd.js +1 -1
  11. package/dist/lib.umd.js.map +1 -1
  12. package/dist/src/@types/Asset.d.ts +83 -0
  13. package/dist/src/@types/Compute.d.ts +18 -1
  14. package/dist/src/@types/DDO/DDO.d.ts +43 -0
  15. package/dist/src/@types/DDO/Event.d.ts +20 -0
  16. package/dist/src/@types/DDO/Metadata.d.ts +92 -0
  17. package/dist/src/@types/DDO/Service.d.ts +72 -6
  18. package/dist/src/{interfaces/DispenserInterface.d.ts → @types/Dispenser.d.ts} +0 -0
  19. package/dist/src/@types/DownloadResponse.d.ts +4 -0
  20. package/dist/src/@types/Erc20.d.ts +21 -0
  21. package/dist/src/@types/Erc721.d.ts +12 -0
  22. package/dist/src/@types/FileMetadata.d.ts +29 -0
  23. package/dist/src/{interfaces/FixedRateInterface.d.ts → @types/FixedPrice.d.ts} +7 -1
  24. package/dist/src/{interfaces/PoolInterface.d.ts → @types/Pool.d.ts} +11 -2
  25. package/dist/src/@types/Provider.d.ts +9 -0
  26. package/dist/src/@types/Router.d.ts +59 -0
  27. package/dist/src/@types/index.d.ts +6 -0
  28. package/dist/src/aquarius/Aquarius.d.ts +26 -4
  29. package/dist/src/factories/NFTFactory.d.ts +222 -13
  30. package/dist/src/index.d.ts +1 -1
  31. package/dist/src/models/Config.d.ts +128 -0
  32. package/dist/src/pools/Router.d.ts +193 -12
  33. package/dist/src/pools/balancer/Pool.d.ts +357 -37
  34. package/dist/src/pools/dispenser/Dispenser.d.ts +109 -2
  35. package/dist/src/pools/fixedRate/FixedRateExchange.d.ts +311 -19
  36. package/dist/src/pools/index.d.ts +2 -0
  37. package/dist/src/pools/ssContracts/SideStaking.d.ts +110 -7
  38. package/dist/src/provider/Provider.d.ts +137 -14
  39. package/dist/src/tokens/Datatoken.d.ts +347 -7
  40. package/dist/src/tokens/NFT.d.ts +301 -6
  41. package/dist/src/utils/ConfigHelper.d.ts +1 -1
  42. package/dist/src/utils/Constants.d.ts +1 -0
  43. package/dist/src/utils/ContractUtils.d.ts +13 -2
  44. package/dist/src/utils/DatatokenName.d.ts +4 -0
  45. package/dist/src/utils/FetchHelper.d.ts +3 -2
  46. package/dist/src/utils/General.d.ts +4 -0
  47. package/dist/src/utils/PoolHelpers.d.ts +8 -0
  48. package/dist/src/utils/SignatureUtils.d.ts +0 -2
  49. package/dist/src/utils/TokenUtils.d.ts +69 -0
  50. package/dist/src/utils/index.d.ts +3 -0
  51. package/dist/src/utils/minAbi.d.ts +2 -0
  52. package/dist/test/TestContractHandler.d.ts +8 -36
  53. package/dist/test/config.d.ts +5 -0
  54. package/dist/test/{unit/NftFactory.test.d.ts → integration/CodeExamples.test.d.ts} +0 -0
  55. package/dist/test/unit/factories/NftFactory.test.d.ts +1 -0
  56. package/package.json +38 -34
  57. package/dist/src/interfaces/Erc20Interface.d.ts +0 -11
  58. package/dist/src/interfaces/RouterInterface.d.ts +0 -12
  59. package/dist/src/interfaces/index.d.ts +0 -5
  60. package/dist/test/integration/config.d.ts +0 -3
  61. package/dist/test/unit/config.d.ts +0 -3
  62. package/docs/beginners_guide.md +0 -338
  63. package/docs/get-test-OCEAN.md +0 -24
  64. package/docs/overview.md +0 -394
  65. package/docs/quickstart_marketplace.md +0 -423
  66. package/docs/quickstart_simple.md +0 -272
  67. package/docs/services.md +0 -94
  68. package/docs/wallets.md +0 -98
@@ -1,2 +1,2 @@
1
- import e from"web3";import t from"bignumber.js";import r from"cross-fetch";import n from"fs";import o from"save-file";import i from"@oceanprotocol/contracts/addresses/address.json";import s from"crypto-js/sha256";import c from"@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json";import a from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json";import u from"decimal.js";import l from"@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json";import h from"@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json";import f from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json";import m from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json";import v from"@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json";var d;!function(e){e[e.None=-1]="None",e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Log=2]="Log",e[e.Verbose=3]="Verbose"}(d||(d={}));var P=/*#__PURE__*/function(){function e(e){void 0===e&&(e=d.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",d.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",d.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",d.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",d.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 P,p={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 w(e){var t=e||p,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 b=function(e,r){try{return Promise.resolve(e.eth.getGasPrice()).then(function(e){var n=new t(e);return r&&r.gasFeeMultiplier?n.multipliedBy(r.gasFeeMultiplier).integerValue(t.ROUND_DOWN).toString(10):n.toString(10)})}catch(e){return Promise.reject(e)}};function A(e,t){return t&&(t.transactionBlockTimeout&&(e.transactionBlockTimeout=t.transactionBlockTimeout),t.transactionConfirmationBlocks&&(e.transactionConfirmationBlocks=t.transactionConfirmationBlocks),t.transactionPollingTimeout&&(e.transactionPollingTimeout=t.transactionPollingTimeout)),e}function y(t){var r,n;if(!t.name||!t.symbol){var o=w();r=o.name,n=o.symbol}return{templateIndex:t.templateIndex,strings:[t.name||r,t.symbol||n],addresses:[t.minter,t.feeManager,t.mpFeeAddress,t.feeToken],uints:[e.utils.toWei(t.cap),e.utils.toWei(t.feeAmount)],bytess:[]}}function T(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 E(t){return{addresses:[t.ssContract,t.baseTokenAddress,t.baseTokenSender,t.publisherAddress,t.marketFeeCollector,t.poolTemplateAddress],ssParams:[e.utils.toWei(t.rate),t.baseTokenDecimals,e.utils.toWei(t.vestingAmount),t.vestedBlocks,e.utils.toWei(t.initialBaseTokenLiquidity)],swapFees:[t.swapFeeLiquidityProvider,t.swapFeeMarketRunner]}}var C=function(e,t,n,o){try{return Promise.resolve(r(t,{method:e,body:n,headers:o}))}catch(e){return Promise.reject(e)}},F=function(e,t){return R(e,t,{"Content-type":"application/json"})},R=function(e,t,n){try{return Promise.resolve(r(e,null!=t?{method:"POST",body:t,headers:n}:{method:"POST"}))}catch(e){return Promise.reject(e)}},k=function(e){try{return Promise.resolve(r(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},I=function(e,t,i){try{return Promise.resolve(r(e)).then(function(r){if(!r.ok)throw new Error("Response error.");var s;try{s=r.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]}catch(t){try{s=e.split("/").pop()}catch(e){s="file"+i}}return function(){if(t){n.mkdirSync(t,{recursive:!0});var e=n.writeFileSync,i=t+"/"+s;return Promise.resolve(r.text()).then(function(r){return e.call(n,i,r),t})}return Promise.resolve(r.arrayBuffer()).then(function(e){o(e,s)})}()})}catch(e){return Promise.reject(e)}},j=function(e,t){try{return Promise.resolve(r(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)}};function S(){return S=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},S.apply(this,arguments)}function G(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 x(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 G(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)?G(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 U={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},M=[S({},U),S({},U,{chainId:8996,network:"development",metadataCacheUri:"http://127.0.0.1:5000"}),S({},U,{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}),S({},U,{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}),S({},U,{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}),S({},U,{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}),S({},U,{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}),S({},U,{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"}),S({},U,{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"}),S({},U,{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"}),S({},U,{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}),S({},U,{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"}),S({},U,{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}),S({},U,{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})],O=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e){var t;if(i[e]){var r=i[e];t=S({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(n&&process.env.ADDRESS_FILE)try{var o=JSON.parse(n.readFileSync(process.env.ADDRESS_FILE,"utf8"))[e];t=S({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})}catch(e){}return t},t.getConfig=function(e,t){var r="string"==typeof e?"network":"chainId",n=M.find(function(t){return t[r]===e});return n?(n=S({},n,this.getAddressesFromEnv(n.network)),S({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(g.error("No config found for given network '"+e+"'"),null)},e}();function L(t,r){return t=e.utils.toChecksumAddress(t),"did:op:"+s(t+r.toString(10)).toString()}function D(e){return s(e).toString()}var N="0x0000000000000000000000000000000000000000";function W(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(W(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),W(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)}},B=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)}},z=function(e,t,r,n){try{var o=e&&e.currentProvider&&e.currentProvider.isMetaMask;return Promise.resolve(W(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),W(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 J(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var q="115792089237316195423570985008687907853269984665640564039457584007913129639934";function H(e,t,r){if(!e.s){if(r instanceof Z){if(!r.s)return void(r.o=H.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(H.bind(null,e,t),H.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var Z=/*#__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{H(n,1,i(this.v))}catch(e){H(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?H(n,1,t?t(o):o):r?H(n,1,r(o)):H(n,2,o)}catch(e){H(n,2,e)}},n},e}();function V(e){return e instanceof Z&&1&e.s}function Q(e,t,r){for(var n;;){var o=e();if(V(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!V(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!V(s)){n=2;break}}}var c=new Z,a=H.bind(null,c,2);return(0===n?o.then(l):1===n?i.then(u):s.then(h)).then(void 0,a),c;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!V(s))return void s.then(h).then(void 0,a);if(!(o=e())||V(o)&&!o.v)return void H(c,1,i);if(o.then)return void o.then(l).then(void 0,a);V(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,a)}function l(e){e?(i=r())&&i.then?i.then(u).then(void 0,a):u(i):H(c,1,i)}function h(){(o=e())?o.then?o.then(l).then(void 0,a):l(o):H(c,1,i)}}var X=/*#__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||c.abi,this.web3=e,this.logger=t,this.config=n||M[0]}var r=e.prototype;return r.estApprove=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(a.abi,t),s.config),u=s.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(c.methods.approve(r,n).estimateGas({from:e},function(e,t){return e?u:t})).then(function(e){i=e})},function(e){i=u,g.error("estimate gas failed for approve!",e)});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.allowance=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(a.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)}},r.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(c.amountToUnits(t,n)).then(function(n){return Promise.resolve(c.estApprove(e,t,r,n)).then(function(t){var o=J(function(){var o=a.methods.approve(r,n),i=o.send;return Promise.resolve(b(c.web3,c.config)).then(function(r){return Promise.resolve(i.call(o,{from:e,gas:t+1,gasPrice:r})).then(function(e){s=e})})},function(e){c.logger.error("ERRPR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return s}):s})})},c=this,a=A(new c.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),c.config),l=function(){if(!o)return Promise.resolve(c.allowance(t,e,r)).then(function(e){if(new u(e).greaterThanOrEqualTo(new u(n)))return i=1,e})}();return Promise.resolve(l&&l.then?l.then(s):s(l))}catch(e){return Promise.reject(e)}},r.sharesBalance=function(e,t){try{var r=this,n=null,o=J(function(){var o=A(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)}},r.estSetSwapFee=function(e,t,r,n){try{var o,i=this,s=n||A(new i.web3.eth.Contract(a.abi,t),i.config),c=i.GASLIMIT_DEFAULT,u=J(function(){return Promise.resolve(s.methods.setSwapFee(r).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(u&&u.then?u.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.setSwapFee=function(e,t,r){try{var n=this,o=A(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=J(function(){var s=o.methods.setSwapFee(n.web3.utils.toWei(r)),c=s.send;return Promise.resolve(b(n.web3,n.config)).then(function(r){return Promise.resolve(c.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)}},r.getNumTokens=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getPoolSharesTotalSupply=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getCurrentTokens=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getFinalTokens=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getController=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getBaseToken=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getDatatoken=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getMarketFeeCollector=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getOPFCollector=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.isBound=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=J(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)}},r.getReserve=function(e,t){try{var r=function(){return o.toString()},n=this,o=null,i=J(function(){var r=A(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)}},r.isFinalized=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getSwapFee=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getNormalizedWeight=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=J(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)}},r.getDenormalizedWeight=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=J(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)}},r.getTotalDenormalizedWeight=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=J(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)}},r.getMarketFees=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=J(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)}},r.getCurrentMarketFees=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(J(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)}},r.getCurrentOPFFees=function(e){try{var t=this,r=A(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(J(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)}},r.getCommunityFees=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=J(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)}},r.estCollectOPF=function(e,t,r){try{var n,o=this,i=r||A(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,c=J(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(c&&c.then?c.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},r.collectOPF=function(e,t){try{var r=this,n=A(new r.web3.eth.Contract(r.poolAbi,t),r.config),o=null;return Promise.resolve(r.estCollectOPF(e,t)).then(function(t){var i=J(function(){var i=n.methods.collectOPF(),s=i.send;return Promise.resolve(b(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)}},r.estCollectMarketFee=function(e,t,r){try{var n,o=this,i=r||A(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=o.GASLIMIT_DEFAULT,c=J(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(c&&c.then?c.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},r.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=A(new r.web3.eth.Contract(r.poolAbi,t),r.config),i=null;return Promise.resolve(r.estCollectMarketFee(e,t)).then(function(t){var n=J(function(){var n=o.methods.collectMarketFee(),s=n.send;return Promise.resolve(b(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)}},r.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=this,s=n||A(new i.web3.eth.Contract(i.poolAbi,t),i.config),c=i.GASLIMIT_DEFAULT,a=J(function(){return Promise.resolve(s.methods.updateMarketFeeCollector(r).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.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=A(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=J(function(){var o=i.methods.updateMarketFeeCollector(r),c=o.send;return Promise.resolve(b(n.web3,n.config)).then(function(r){return Promise.resolve(c.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)}},r.amountToUnits=function(e,r){try{var n=this;return Promise.resolve(J(function(){var o=A(new n.web3.eth.Contract(a.abi,e),n.config);return Promise.resolve(o.methods.decimals().call()).then(function(e){"0"===e&&(e=18);var n=new t(parseInt(r)*Math.pow(10,e));return t.config({EXPONENTIAL_AT:50}),n.toString()})},function(){n.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},r.unitsToAmount=function(e,r){try{var n=this;return Promise.resolve(J(function(){var o=A(new n.web3.eth.Contract(a.abi,e),n.config);return Promise.resolve(o.methods.decimals().call()).then(function(e){return"0"===e&&(e=18),new t(parseInt(r)/Math.pow(10,e)).toString()})},function(){n.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")}))}catch(e){return Promise.reject(e)}},r.estSwapExactAmountIn=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(s.poolAbi,t),s.config),a=n.maxPrice?s.web3.utils.toWei(n.maxPrice):q,u=s.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(c.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,a,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)}},r.swapExactAmountIn=function(e,t,r,n){try{var o=this,i=A(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 c=null;return Promise.resolve(o.estSwapExactAmountIn(e,t,r,n)).then(function(t){var s=n.maxPrice?o.web3.utils.toWei(n.maxPrice):q,a=J(function(){var a=i.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.tokenAmountIn,n.minAmountOut,s,o.web3.utils.toWei(n.swapMarketFee)]),u=a.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){c=e})})},function(e){o.logger.error("ERROR: Failed to swap exact amount in : "+e.message)});return a&&a.then?a.then(function(){return c}):c})})})}catch(e){return Promise.reject(e)}},r.estSwapExactAmountOut=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(s.poolAbi,t),s.config),a=s.GASLIMIT_DEFAULT,u=n.maxPrice?s.web3.utils.toWei(n.maxPrice):q,l=J(function(){return Promise.resolve(c.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?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(l&&l.then?l.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.swapExactAmountOut=function(e,t,r,n){try{var o=this,i=A(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=null;return Promise.resolve(o.amountToUnits(r.tokenIn,n.maxAmountIn)).then(function(c){return n.maxAmountIn=c,Promise.resolve(o.amountToUnits(r.tokenOut,n.tokenAmountOut)).then(function(c){return n.tokenAmountOut=c,Promise.resolve(o.estSwapExactAmountOut(e,t,r,n)).then(function(t){var c=n.maxPrice?o.web3.utils.toWei(n.maxPrice):q,a=J(function(){var a=i.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[n.maxAmountIn,n.tokenAmountOut,c,o.web3.utils.toWei(n.swapMarketFee)]),u=a.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(u.call(a,{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 a&&a.then?a.then(function(){return s}):s})})})}catch(e){return Promise.reject(e)}},r.estJoinPool=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(s.poolAbi,t),s.config),a=s.GASLIMIT_DEFAULT,u=J(function(){return Promise.resolve(c.methods.joinPool(r,n).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.joinPool=function(e,t,r,n){try{var o=this,i=A(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(c){function a(){var n=null;return Promise.resolve(o.estJoinPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var c=J(function(){var c=i.methods.joinPool(o.web3.utils.toWei(r),s),a=c.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(c,{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 c&&c.then?c.then(function(){return n}):n})}var u=0,l=Q(function(){return u<2},function(){return u++},function(){return Promise.resolve(o.amountToUnits(c[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(a):a()})}catch(e){return Promise.reject(e)}},r.estExitPool=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(s.poolAbi,t),s.config),a=s.GASLIMIT_DEFAULT,u=J(function(){return Promise.resolve(c.methods.exitPool(r,n).estimateGas({from:e},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});return Promise.resolve(u&&u.then?u.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.exitPool=function(e,t,r,n){try{var o=this,i=A(new o.web3.eth.Contract(o.poolAbi,t),o.config),s=[];return Promise.resolve(o.getFinalTokens(t)).then(function(c){function a(){var n=null;return Promise.resolve(o.estExitPool(e,t,o.web3.utils.toWei(r),s)).then(function(t){var c=J(function(){var c=i.methods.exitPool(o.web3.utils.toWei(r),s),a=c.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(c,{from:e,gas:t,gasPrice:r})).then(function(e){n=e})})},function(e){o.logger.error("ERROR: Failed to exit pool: "+e.message)});return c&&c.then?c.then(function(){return n}):n})}var u=0,l=Q(function(){return u<2},function(){return u++},function(){return Promise.resolve(o.amountToUnits(c[u],n[u])).then(function(e){s.push(e)})});return l&&l.then?l.then(a):a()})}catch(e){return Promise.reject(e)}},r.estJoinswapExternAmountIn=function(e,t,r,n,o,i){try{var s,c=this,a=i||A(new c.web3.eth.Contract(c.poolAbi,t),c.config),u=c.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(a.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)}},r.joinswapExternAmountIn=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,t),i.config),c=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 a=J(function(){var a=s.methods.joinswapExternAmountIn(r,n,i.web3.utils.toWei(o)),u=a.send;return Promise.resolve(b(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){c=e})})},function(e){i.logger.error("ERROR: Failed to pay tokens in order to join the pool: "+e.message)});return a&&a.then?a.then(function(){return c}):c})})}catch(e){return Promise.reject(e)}},r.estJoinswapPoolAmountOut=function(e,t,r,n,o,i){try{var s,c=this,a=i||A(new c.web3.eth.Contract(c.poolAbi,t),c.config),u=c.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(a.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)}},r.joinswapPoolAmountOut=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,t),i.config),c=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 a=J(function(){var a=s.methods.joinswapPoolAmountOut(r,i.web3.utils.toWei(n),o),u=a.send;return Promise.resolve(b(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){c=e})})},function(){i.logger.error("ERROR: Failed to join swap pool amount out")});return a&&a.then?a.then(function(){return c}):c})})}catch(e){return Promise.reject(e)}},r.estExitswapPoolAmountIn=function(e,t,r,n,o,i){try{var s,c=this,a=i||A(new c.web3.eth.Contract(c.poolAbi,t),c.config),u=c.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(a.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)}},r.exitswapPoolAmountIn=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,t),i.config),c=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 a=J(function(){var a=s.methods.exitswapPoolAmountIn(r,i.web3.utils.toWei(n),o),u=a.send;return Promise.resolve(b(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){c=e})})},function(e){i.logger.error("ERROR: Failed to pay pool shares into the pool: "+e.message)});return a&&a.then?a.then(function(){return c}):c})})}catch(e){return Promise.reject(e)}},r.estExitswapExternAmountOut=function(e,t,r,n,o,i){try{var s,c=this,a=i||A(new c.web3.eth.Contract(c.poolAbi,t),c.config),u=c.GASLIMIT_DEFAULT,l=J(function(){return Promise.resolve(a.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)}},r.exitswapExternAmountOut=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,t),i.config),c=null;return Promise.resolve(i.estExitswapExternAmountOut(e,t,r,i.web3.utils.toWei(n),i.web3.utils.toWei(o))).then(function(t){var a=J(function(){var a=s.methods.exitswapExternAmountOut(r,i.web3.utils.toWei(n),i.web3.utils.toWei(o)),u=a.send;return Promise.resolve(b(i.web3,i.config)).then(function(r){return Promise.resolve(u.call(a,{from:e,gas:t+1,gasPrice:r})).then(function(e){c=e})})},function(){i.logger.error("ERROR: Failed to exitswapExternAmountOut")});return a&&a.then?a.then(function(){return c}):c})}catch(e){return Promise.reject(e)}},r.getSpotPrice=function(e,r,n,o){try{var i=function(){function e(){function e(){var e;return u>l?(e=u-l,i=new t(i/Math.pow(10,e)),i/=Math.pow(10,l)):(e=l-u,i=new t(i*Math.pow(10,2*e)),i/=Math.pow(10,l)),i.toString()}var i=null,a=J(function(){return Promise.resolve(c.methods.getSpotPrice(r,n,s.web3.utils.toWei(o)).call()).then(function(e){i=new t((i=e).toString())})},function(){s.logger.error("ERROR: Failed to get spot price of swapping tokenIn to tokenOut")});return a&&a.then?a.then(e):e()}var i=J(function(){return Promise.resolve(f.methods.decimals().call()).then(function(e){l=e})},function(){s.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return i&&i.then?i.then(e):e()},s=this,c=A(new s.web3.eth.Contract(s.poolAbi,e),s.config),u=18,l=18,h=A(new s.web3.eth.Contract(a.abi,r),s.config),f=A(new s.web3.eth.Contract(a.abi,n),s.config),m=J(function(){return Promise.resolve(h.methods.decimals().call()).then(function(e){u=e})},function(){s.logger.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(m&&m.then?m.then(i):i())}catch(e){return Promise.reject(e)}},r.getAmountInExactOut=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(i.amountToUnits(r,n)).then(function(e){var n=null,c=J(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 c&&c.then?c.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},r.getAmountOutExactIn=function(e,t,r,n,o){try{var i=this,s=A(new i.web3.eth.Contract(i.poolAbi,e),i.config);return Promise.resolve(i.amountToUnits(t,n)).then(function(e){var n=null,c=J(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 c&&c.then?c.then(function(){return n}):n})}catch(e){return Promise.reject(e)}},r.calcPoolOutGivenSingleIn=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=J(function(){var s=o.methods,c=s.calcPoolOutSingleIn;return Promise.resolve(n.amountToUnits(t,r)).then(function(r){return Promise.resolve(c.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)}},r.calcSingleInGivenPoolOut=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null;return Promise.resolve(n.amountToUnits(e,r)).then(function(e){var r=J(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)}},r.calcSingleOutGivenPoolIn=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=J(function(){var s=o.methods,c=s.calcSingleOutPoolIn;return Promise.resolve(n.amountToUnits(e,r)).then(function(e){return Promise.resolve(c.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)}},r.calcPoolInGivenSingleOut=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=J(function(){var s=o.methods,c=s.calcPoolInSingleOut;return Promise.resolve(n.amountToUnits(t,r)).then(function(r){return Promise.resolve(c.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)}},r.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)},r.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)},r.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 $(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var K,Y=/*#__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||l.abi,this.config=n||M[0],e&&(this.dispenserContract=A(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=$(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,c=s.GASLIMIT_DEFAULT,a=$(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?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(a&&a.then?a.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 c=i.dispenserContract.methods.create(e,i.web3.utils.toWei(r),i.web3.utils.toWei(n),t,o),a=c.send;return Promise.resolve(b(i.web3,i.config)).then(function(e){return Promise.resolve(a.call(c,{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,c=$(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(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.activate=function(e,t,r,n){try{var o,i=this,s=$(function(){return Promise.resolve(i.estGasActivate(e,t,r,n)).then(function(s){var c=i.dispenserContract.methods.activate(e,i.web3.utils.toWei(t),i.web3.utils.toWei(r)),a=c.send;return Promise.resolve(b(i.web3,i.config)).then(function(e){return Promise.resolve(a.call(c,{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=$(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=$(function(){return Promise.resolve(n.estGasDeactivate(e,t)).then(function(o){var i=n.dispenserContract.methods.deactivate(e),s=i.send;return Promise.resolve(b(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=$(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=$(function(){return Promise.resolve(o.estGasSetAllowedSwapper(e,t,r)).then(function(i){var s=o.dispenserContract.methods.setAllowedSwapper(e,r),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(e){return Promise.resolve(c.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,c=$(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(c&&c.then?c.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,c=$(function(){var c=o.dispenserContract.methods.dispense(e,o.web3.utils.toWei(r),n),a=c.send;return Promise.resolve(b(o.web3,o.config)).then(function(e){return Promise.resolve(a.call(c,{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 c&&c.then?c.then(function(e){return s?e:null}):s?c:null})}catch(e){return Promise.reject(e)}},t.estGasOwnerWithdraw=function(e,t){try{var r,n=this,o=n.GASLIMIT_DEFAULT,i=$(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=$(function(){var i=r.dispenserContract.methods.ownerWithdraw(e),s=i.send;return Promise.resolve(b(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 u(e).greaterThanOrEqualTo(o.maxBalance)||new u(String(n)).greaterThan(o.maxTokens)||!new u(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},e}();function ee(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e[e.CreatingExchange=0]="CreatingExchange",e[e.ApprovingDatatoken=1]="ApprovingDatatoken"}(K||(K={}));var te=/*#__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||M[0],this.fixedRateExchangeAbi=r||h.abi,this.oceanAddress=n,this.fixedRateAddress=t,this.contract=A(new this.web3.eth.Contract(this.fixedRateExchangeAbi,this.fixedRateAddress),this.config)}var r=e.prototype;return r.amountToUnits=function(e,r){try{var n=function(){return new t(parseInt(r)*Math.pow(10,o)).toString()},o=18,i=A(new this.web3.eth.Contract(a.abi,e),this.config),s=ee(function(){return Promise.resolve(i.methods.decimals().call()).then(function(e){o=e})},function(){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(s&&s.then?s.then(n):n())}catch(e){return Promise.reject(e)}},r.unitsToAmount=function(e,r){try{var n=function(){return new t(parseInt(r)/Math.pow(10,o)).toString()},o=18,i=A(new this.web3.eth.Contract(a.abi,e),this.config),s=ee(function(){return Promise.resolve(i.methods.decimals().call()).then(function(e){o=e})},function(){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18")});return Promise.resolve(s&&s.then?s.then(n):n())}catch(e){return Promise.reject(e)}},r.generateExchangeId=function(e,t,r){try{return Promise.resolve(this.contract.methods.generateExchangeId(e,t,r).call())}catch(e){return Promise.reject(e)}},r.estBuyDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,c=this.GASLIMIT_DEFAULT,a=ee(function(){return Promise.resolve(s.methods.buyDT(t,r.toString(),n.toString()).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(a&&a.then?a.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.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 ee(function(){var s=o.contract.methods.buyDT(t,r,n),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.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)}},r.estSellDT=function(e,t,r,n,o){try{var i,s=o||this.fixedRateContract,c=this.GASLIMIT_DEFAULT,a=ee(function(){return Promise.resolve(s.methods.sellDT(t,r,n).estimateGas({from:e},function(e,t){return e?c:t})).then(function(e){i=e})},function(){i=c});return Promise.resolve(a&&a.then?a.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.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 ee(function(){var s=o.contract.methods.sellDT(t,r,n),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.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)}},r.getNumberOfExchanges=function(){try{return Promise.resolve(this.contract.methods.getNumberOfExchanges().call())}catch(e){return Promise.reject(e)}},r.estSetRate=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,c=ee(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(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.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(b(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)}},r.estSetAllowedSwapper=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,c=ee(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(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.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(b(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)}},r.estActivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estDeactivate=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.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)}},r.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)}},r.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)}},r.getAllowedSwapper=function(e){try{return Promise.resolve(this.contract.methods.getAllowedSwapper(e).call())}catch(e){return Promise.reject(e)}},r.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)}},r.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)}},r.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)}},r.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)}},r.getExchanges=function(){try{return Promise.resolve(this.contract.methods.getExchanges().call())}catch(e){return Promise.reject(e)}},r.isActive=function(e){try{return Promise.resolve(this.contract.methods.isActive(e).call())}catch(e){return Promise.reject(e)}},r.estActivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estDeactivateMint=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estCollectBT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estCollectDT=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estCollectMarketFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.estCollectOceanFee=function(e,t,r){try{var n,o=r||this.fixedRateContract,i=this.GASLIMIT_DEFAULT,s=ee(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)}},r.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(b(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)}},r.getOPFCollector=function(){try{var e=this,t=null,r=ee(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)}},r.getRouter=function(){try{var e=this,t=null,r=ee(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)}},r.getExchangeOwner=function(e){try{var t=this,r=null,n=ee(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)}},r.estUpdateMarketFee=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,c=ee(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(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.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(b(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)}},r.estUpdateMarketFeeCollector=function(e,t,r,n){try{var o,i=n||this.fixedRateContract,s=this.GASLIMIT_DEFAULT,c=ee(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(c&&c.then?c.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.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(b(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 re(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ne=/*#__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||m.abi,this.web3=e,this.config=r||M[0]}var t=e.prototype;return t.estGasCreateErc20=function(e,t,r,n,o,i,s,c,a,u,l,h){try{var f,m=this,v=h||A(new m.web3.eth.Contract(m.nftAbi,e),m.config),d=m.GASLIMIT_DEFAULT,P=re(function(){return Promise.resolve(v.methods.createERC20(l,[a,u],[r,n,o,i],[m.web3.utils.toWei(c),m.web3.utils.toWei(s)],[]).estimateGas({from:t},function(e,t){return e?d:t})).then(function(e){f=e})},function(){f=d});return Promise.resolve(P&&P.then?P.then(function(){return f}):f)}catch(e){return Promise.reject(e)}},t.createErc20=function(e,t,r,n,o,i,s,c,a,u,l){try{var h=this;return Promise.resolve(h.getNftPermissions(e,t)).then(function(f){if(!0!==f.deployERC20)throw new Error("Caller is not ERC20Deployer");if(l||(l=1),!a||!u){var m=w();a=m.name,u=m.symbol}var v=A(new h.web3.eth.Contract(h.nftAbi,e),h.config);return Promise.resolve(h.estGasCreateErc20(e,t,r,n,o,i,s,c,a,u,l,v)).then(function(e){var f=v.methods.createERC20(l,[a,u],[r,n,o,i],[h.web3.utils.toWei(c),h.web3.utils.toWei(s)],[]),m=f.send;return Promise.resolve(b(h.web3,h.config)).then(function(r){return Promise.resolve(m.call(f,{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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.addManager(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addManager=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.removeManager(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeManager=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.addToCreateERC20List(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addErc20Deployer=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.removeFromCreateErc20List(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeErc20Deployer=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(c||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(b(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var c=!0!==i.manager;return c||t!==r?s(c||t===r&&n.getNftPermissions(e,t)):Promise.resolve(c||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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.addToMetadataList(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMetadataUpdater=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.removeFromMetadataList(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMetadataUpdater=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(c||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(b(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var c=!0!==i.manager;return c||t===r?s(c||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(c||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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.addTo725StoreList(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addStoreUpdater=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.removeFrom725StoreList(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeStoreUpdater=function(e,t,r){try{var n=this,o=A(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(i){if(c||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(b(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var c=!0!==i.manager;return c||t===r?s(c||t!==r&&n.getNftPermissions(e,t)):Promise.resolve(c||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||A(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,c=re(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(c&&c.then?c.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=A(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(b(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,c=o||A(new s.web3.eth.Contract(s.nftAbi,e),s.config),a=s.GASLIMIT_DEFAULT,u=re(function(){return Promise.resolve(c.methods.transferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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=A(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 c=n||1;return Promise.resolve(o.estGasTransferNft(e,t,r,c,i)).then(function(e){var n=i.methods.transferFrom(t,r,c),s=n.send;return Promise.resolve(b(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,c=o||A(new s.web3.eth.Contract(s.nftAbi,e),s.config),a=s.GASLIMIT_DEFAULT,u=re(function(){return Promise.resolve(c.methods.safeTransferFrom(t,r,n).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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=A(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 c=n||1;return Promise.resolve(o.estGasSafeTransferNft(e,t,r,c,i)).then(function(e){var n=i.methods.safeTransferFrom(t,r,c),s=n.send;return Promise.resolve(b(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,c,a,u){try{var l,h=this,f=u||A(new h.web3.eth.Contract(h.nftAbi,e),h.config),m=h.GASLIMIT_DEFAULT,v=re(function(){return Promise.resolve(f.methods.setMetaData(r,n,o,i,s,c,a).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,c,a){try{var u=this,l=A(new u.web3.eth.Contract(u.nftAbi,e),u.config);return a||(a=[]),Promise.resolve(u.getNftPermissions(e,t)).then(function(h){if(!h.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(u.estGasSetMetadata(e,t,r,n,o,i,s,c,a,l)).then(function(e){var h=l.methods.setMetaData(r,n,o,i,s,c,a),f=h.send;return Promise.resolve(b(u.web3,u.config)).then(function(r){return Promise.resolve(f.call(h,{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||A(new i.web3.eth.Contract(i.nftAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=re(function(){return Promise.resolve(s.methods.setMetaDataState(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setMetadataState=function(e,t,r){try{var n=this,o=A(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(b(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=A(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=o.GASLIMIT_DEFAULT,c=re(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(c&&c.then?c.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.setTokenURI=function(e,t,r){try{var n=this,o=A(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(b(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=A(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=A(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=A(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=A(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=A(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=A(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 oe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ie=/*#__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.abi,this.datatokensEnterpriseAbi=r||f.abi,this.config=n||M[0],this.nft=new ne(this.web3)}var t=e.prototype;return t.estGasApprove=function(e,t,r,n,o){try{var i,s=this,c=o||A(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),a=s.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(c.methods.approve(t,s.web3.utils.toWei(r)).estimateGas({from:n},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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=A(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)),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.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,c=o||A(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),a=s.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(c.methods.mint(n||t,s.web3.utils.toWei(r)).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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||A(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT;r.allowedConsumer||(r.allowedConsumer="0x0000000000000000000000000000000000000000");var c,a=r.withMint?1:0,u=oe(function(){return Promise.resolve(i.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,t,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,a]).estimateGas({from:t},function(e,t){return e?s:t})).then(function(e){c=e})},function(){c=s});return Promise.resolve(u&&u.then?u.then(function(){return c}):c)}catch(e){return Promise.reject(e)}},t.createFixedRate=function(e,t,r){try{var n=this,o=A(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]),c=i.send;return Promise.resolve(b(n.web3,n.config)).then(function(r){return Promise.resolve(c.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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);n.allowedSwapper||(n.allowedSwapper="0x0000000000000000000000000000000000000000"),n.withMint||(n.withMint=!1);var c,a=i.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){c=e})},function(){c=a});return Promise.resolve(u&&u.then?u.then(function(){return c}):c)}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=A(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),c=i.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(c.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=A(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 u(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)),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(c.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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.addMinter(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addMinter=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.removeMinter(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removeMinter=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.addPaymentManager(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.addPaymentManager=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.removePaymentManager(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.removePaymentManager=function(e,t,r){try{var n=this,o=A(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(b(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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.setPaymentCollector(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.setPaymentCollector=function(e,t,r){try{var n=this,o=A(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(b(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=A(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,c=o||A(new s.web3.eth.Contract(s.datatokensAbi,e),s.config),a=s.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(c.methods.transfer(t,r).estimateGas({from:n},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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=A(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(oe(function(){return Promise.resolve(o.estGasTransfer(e,t,r,n,i)).then(function(e){var s=i.methods.transfer(t,r),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.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,c=this,a=i||A(new c.web3.eth.Contract(c.datatokensAbi,e),c.config),u=c.GASLIMIT_DEFAULT,l=oe(function(){return Promise.resolve(a.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=A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(oe(function(){return Promise.resolve(i.estGasStartOrder(e,t,r,n,o,s)).then(function(e){var c=s.methods.startOrder(r,n,o),a=c.send;return Promise.resolve(b(i.web3,i.config)).then(function(r){return Promise.resolve(a.call(c,{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,c=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),a=s.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(c.methods.buyFromFreAndOrder(r,n).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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(oe(function(){return Promise.resolve(o.estGasBuyFromFreAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromFreAndOrder(r,n),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(c.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,c=o||new s.web3.eth.Contract(s.datatokensEnterpriseAbi,e),a=s.GASLIMIT_DEFAULT,u=oe(function(){return Promise.resolve(c.methods.buyFromDispenserAndOrder(r,n).estimateGas({from:t},function(e,t){return e?a:t})).then(function(e){i=e})},function(){i=a});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(oe(function(){return Promise.resolve(o.estGasBuyFromDispenserAndOrder(e,t,r,n,i)).then(function(e){var s=i.methods.buyFromDispenserAndOrder(r,n),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(r){return Promise.resolve(c.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||A(new i.web3.eth.Contract(i.datatokensAbi,e),i.config),c=i.GASLIMIT_DEFAULT,a=oe(function(){return Promise.resolve(s.methods.setData(r).estimateGas({from:t},function(e,t){return e?c:t})).then(function(e){o=e})},function(){o=c});return Promise.resolve(a&&a.then?a.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=A(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(b(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||A(new o.web3.eth.Contract(o.datatokensAbi,e),o.config),s=o.GASLIMIT_DEFAULT,c=oe(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(c&&c.then?c.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=A(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(b(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=A(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=A(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=A(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=A(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=A(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 se(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var ce="0x0000000000000000000000000000000000000000",ae=/*#__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||v.abi,this.web3=t,this.config=n||M[0],this.factory721=A(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=se(function(){return Promise.resolve(n.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,ce,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=w(),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,ce,t.tokenURI),i=o.send;return Promise.resolve(b(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=se(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===ce)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(b(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=se(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(b(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=se(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(b(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=se(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===ce)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(b(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=se(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(b(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=se(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(b(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=se(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(b(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=se(function(){var s=y(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=y(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(b(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,c=se(function(){var c=y(r),a=E(n);return Promise.resolve(i.factory721.methods.createNftErcWithPool(t,c,a).estimateGas({from:e},function(e,t){return e?s:t})).then(function(e){o=e})},function(){o=s});return Promise.resolve(c&&c.then?c.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=y(r),c=E(n),a=o.factory721.methods.createNftErcWithPool(t,s,c),u=a.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(u.call(a,{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,c=y(r),a=T(n),u=se(function(){return Promise.resolve(i.factory721.methods.createNftErcWithFixedRate(t,c,a).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=y(r),s=T(n);return Promise.resolve(o.estGasCreateNftErcWithFixedRate(e,t,r,n)).then(function(r){var n=o.factory721.methods.createNftErcWithFixedRate(t,i,s),c=n.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.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,c=y(r),a=se(function(){return Promise.resolve(i.factory721.methods.createNftErcWithDispenser(t,c,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(a&&a.then?a.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.createNftErcWithDispenser=function(e,t,r,n){try{var o=this,i=y(r);return Promise.resolve(o.estGasCreateNftErcWithDispenser(e,t,r,n)).then(function(r){var s=o.factory721.methods.createNftErcWithDispenser(t,i,n),c=s.send;return Promise.resolve(b(o.web3,o.config)).then(function(t){return Promise.resolve(c.call(s,{from:e,gas:r+1,gasPrice:t}))})})}catch(e){return Promise.reject(e)}},e}(),ue=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},le=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 he(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(){}var t=e.prototype;return t.getEndpoints=function(e){try{return Promise.resolve(he(function(){return Promise.resolve(k(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?he(function(){return Promise.resolve(c("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,c=r||C,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(z(e,le(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,o=r||C;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?he(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||C;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=[],c=o.getEndpointURL(r,"fileinfo")?o.getEndpointURL(r,"fileinfo").urlPath:null;return c?he(function(){return Promise.resolve(i("POST",c,JSON.stringify(n),{"Content-Type":"application/json"})).then(function(e){function t(e){for(var t,r=x(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||C;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?he(function(){return Promise.resolve(o("POST",s,JSON.stringify(r),{"Content-Type":"application/json"})).then(function(e){function t(e){for(var t,r=x(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,c,a){try{var u=this,l=i||C;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))),c&&(i+="&computeEnv="+encodeURI(c)),a&&(i+="&validUntil="+a),he(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,c){try{var a=this;return Promise.resolve(a.getEndpoints(i)).then(function(u){return Promise.resolve(a.getServiceEndpoints(i,u)).then(function(i){var u=a.getEndpointURL(i,"download")?a.getEndpointURL(i,"download").urlPath:null;if(!u)return null;var l=Date.now();return Promise.resolve(a.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,c&&(s+="&userdata="+encodeURI(JSON.stringify(c))),s})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,o,i,s,c,a){try{var u=this,l=s||C;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,h=Date.now(),f=r;return f+=o.documentId,f+=h,Promise.resolve(u.createHashSignature(t,r,f)).then(function(e){var t=Object();return t.consumerAddress=r,t.signature=e,t.nonce=h,t.computeEnv=n,t.dataset=o,t.algorithm=i,t.additionalDatasets&&(t.additionalDatasets=c),a&&(t.output=a),s?he(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,c=i||C;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(u){var l=s.getEndpointURL(u,"computeStop")?s.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,u)).then(function(n){var i=t;return i+=r||"",i+=e&&""+le(e)||"",i+=n,Promise.resolve(s.createHashSignature(o,t,i)).then(function(n){var o=Object();return o.signature=n,o.documentId=le(e),o.consumerAddress=t,r&&(o.jobId=r),l?he(function(){return Promise.resolve(c("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||C;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,c="?documentId="+le(n);return c+="&consumerAddress="+o,c+=r&&"&jobId="+r||"",t?he(function(){return Promise.resolve(s("GET",t+c,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 c=this;return Promise.resolve(c.getEndpoints(o)).then(function(a){return Promise.resolve(c.getServiceEndpoints(o,a)).then(function(u){var l=c.getEndpointURL(u,"computeResult")?c.getEndpointURL(u,"computeResult").urlPath:null;return Promise.resolve(c.getNonce(o,n,s,a,u)).then(function(o){var a=n;return a+=e,a+=String(t),a+=o,Promise.resolve(c.createHashSignature(i,n,a)).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 c=he(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 c&&c.then?c.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,c=i||C;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(u){var l=s.getEndpointURL(u,"computeDelete")?s.getEndpointURL(u,"computeDelete").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,u)).then(function(n){var i=t;return i+=r||"",i+=e&&""+le(e)||"",i+=n,Promise.resolve(s.createHashSignature(o,t,i)).then(function(n){var o=Object();return o.documentId=le(e),o.consumerAddress=t,o.jobId=r,n&&(o.signature=n),l?he(function(){return Promise.resolve(c("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(he(function(){return Promise.resolve((t||C)("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}(),me=new fe;export{ue as Config,O as ConfigHelper,ie as Datatoken,Y as Dispenser,K as FixedRateCreateProgressStep,te as FixedRateExchange,d as LogLevel,P as Logger,g as LoggerInstance,ne as Nft,ae as NftFactory,X as Pool,fe as Provider,me as ProviderInstance,N as ZERO_ADDRESS,M as configHelperNetworks,C as crossFetchGeneric,I as downloadFile,j as fetchData,L as generateDid,w as generateDtName,k as getData,y as getErcCreationParams,b as getFairGasPrice,T as getFreCreationParams,D as getHash,E as getPoolCreationParams,F as postData,A as setContractDefaults,B as signHash,z as signText,_ as signWithHash};
1
+ import e from"web3";import t from"bignumber.js";import r from"cross-fetch";import n from"@oceanprotocol/contracts/addresses/address.json";import o from"crypto-js/sha256";import i from"decimal.js";import s from"@oceanprotocol/contracts/artifacts/contracts/pools/balancer/BPool.sol/BPool.json";import a from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json";import c from"@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json";import u from"@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json";import l from"@oceanprotocol/contracts/artifacts/contracts/pools/ssContracts/SideStaking.sol/SideStaking.json";import m from"@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json";import h from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json";import f from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json";import d from"@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json";var v;!function(e){e[e.None=-1]="None",e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Log=2]="Log",e[e.Verbose=3]="Verbose"}(v||(v={}));var P=/*#__PURE__*/function(){function e(e){void 0===e&&(e=v.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",v.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",v.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",v.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",v.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 P,p={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 w(e){var t=e||p,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 b=[{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"}],y="0x0000000000000000000000000000000000000000",C=1e6;function R(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var A=function(e,t){try{var r=arguments,n=1e6,o=R(function(){return Promise.resolve(t.apply(null,[].slice.call(r,2)).estimateGas({from:e},function(e,t){return e?1e6:t})).then(function(e){n=e})},function(e){g.error("ERROR: Estimate gas failed!",e)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},k=function(e,r,n,o){try{return Promise.resolve(R(function(){function i(e){return"0"===e&&(e=18),t.config({EXPONENTIAL_AT:50}),new t(n).times(new t(10).exponentiatedBy(e)).toString()}var s=new e.eth.Contract(b,r);return o?i(o):Promise.resolve(s.methods.decimals().call()).then(i)},function(e){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18', "+e.message)}))}catch(e){return Promise.reject(e)}},T=function(e,r,n,o){try{return Promise.resolve(R(function(){function i(e){"0"===e&&(e=18);var r=new t(n).div(new t(10).exponentiatedBy(e));return t.config({EXPONENTIAL_AT:50}),r.toString()}var s=new e.eth.Contract(b,r);return o?i(o):Promise.resolve(s.methods.decimals().call()).then(i)},function(e){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18' : "+e.message)}))}catch(e){return Promise.reject(e)}},E=function(t,r){try{var n=[r.ssContract,r.baseTokenAddress,r.baseTokenSender,r.publisherAddress,r.marketFeeCollector,r.poolTemplateAddress],o=r.vestedBlocks,i=e.utils.toWei(r.vestingAmount),s=r.baseTokenDecimals,a=e.utils.toWei(r.rate);return Promise.resolve(k(t,r.baseTokenAddress,r.initialBaseTokenLiquidity)).then(function(t){return{addresses:n,ssParams:[a,s,i,o,t],swapFees:[e.utils.toWei(r.swapFeeLiquidityProvider),e.utils.toWei(r.swapFeeMarketRunner)]}})}catch(e){return Promise.reject(e)}},j=function(e,r){try{return Promise.resolve(e.eth.getGasPrice()).then(function(e){var n=new t(e);return r&&r.gasFeeMultiplier?n.multipliedBy(r.gasFeeMultiplier).integerValue(t.ROUND_DOWN).toString(10):n.toString(10)})}catch(e){return Promise.reject(e)}};function F(e,t){return t&&(t.transactionBlockTimeout&&(e.transactionBlockTimeout=t.transactionBlockTimeout),t.transactionConfirmationBlocks&&(e.transactionConfirmationBlocks=t.transactionConfirmationBlocks),t.transactionPollingTimeout&&(e.transactionPollingTimeout=t.transactionPollingTimeout)),e}function x(t){var r,n;if(!t.name||!t.symbol){var o=w();r=o.name,n=o.symbol}return{templateIndex:t.templateIndex,strings:[t.name||r,t.symbol||n],addresses:[t.minter,t.paymentCollector,t.mpFeeAddress,t.feeToken],uints:[e.utils.toWei(t.cap),e.utils.toWei(t.feeAmount)],bytess:[]}}function O(t){return{exchangeContract:t.exchangeContract,exchangeId:t.exchangeId,maxBaseTokenAmount:e.utils.toWei(t.maxBaseTokenAmount),swapMarketFee:e.utils.toWei(t.swapMarketFee),marketFeeAddress:t.marketFeeAddress}}function S(t){t.allowedConsumer||(t.allowedConsumer=y);var r=t.withMint?1:0;return{fixedPriceAddress:t.fixedRateAddress,addresses:[t.baseTokenAddress,t.owner,t.marketFeeCollector,t.allowedConsumer],uints:[t.baseTokenDecimals,t.datatokenDecimals,e.utils.toWei(t.fixedRate),e.utils.toWei(t.marketFee),r]}}var M=function(e,t){return D(e,t,{"Content-type":"application/json"})},D=function(e,t,n){try{return Promise.resolve(r(e,null!=t?{method:"POST",body:t,headers:n}:{method:"POST"}))}catch(e){return Promise.reject(e)}},U=function(e){try{return Promise.resolve(r(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},I=function(e,t){try{return Promise.resolve(r(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)}},W=function(e){try{var t=document.createElement("a");return t.download="",t.href=e,t.click(),Promise.resolve()}catch(e){return Promise.reject(e)}},N=function(e,t){try{return Promise.resolve(r(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)}};function G(){return G=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},G.apply(this,arguments)}function B(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 L(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 B(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)?B(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 q={chainId:null,network:"unknown",metadataCacheUri:"https://v4.aquarius.oceanprotocol.com",nodeUri:"http://127.0.0.1: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=[G({},q),G({},q,{chainId:8996,network:"development",metadataCacheUri:"http://127.0.0.1:5000",providerUri:"http://172.15.0.4:8030"}),G({},q,{chainId:3,network:"ropsten",nodeUri:"https://ropsten.infura.io/v3",providerUri:"https://v4.provider.ropsten.oceanprotocol.com",subgraphUri:"https://v4.subgraph.ropsten.oceanprotocol.com",explorerUri:"https://ropsten.etherscan.io",gasFeeMultiplier:1.1}),G({},q,{chainId:4,network:"rinkeby",nodeUri:"https://rinkeby.infura.io/v3",providerUri:"https://v4.provider.rinkeby.oceanprotocol.com",subgraphUri:"https://v4.subgraph.rinkeby.oceanprotocol.com",explorerUri:"https://rinkeby.etherscan.io",gasFeeMultiplier:1.1}),G({},q,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",providerUri:"https://v4.provider.mainnet.oceanprotocol.com",subgraphUri:"https://v4.subgraph.mainnet.oceanprotocol.com",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05}),G({},q,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",providerUri:"https://v4.provider.polygon.oceanprotocol.com",subgraphUri:"https://v4.subgraph.polygon.oceanprotocol.com",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN"}),G({},q,{chainId:1287,network:"moonbase",nodeUri:"https://rpc.api.moonbase.moonbeam.network",providerUri:"https://v4.provider.moonbase.oceanprotocol.com",subgraphUri:"https://v4.subgraph.moonbase.oceanprotocol.com",explorerUri:"https://moonbase.moonscan.io/",gasFeeMultiplier:1.1}),G({},q,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",providerUri:"https://v4.provider.gaiaxtestnet.oceanprotocol.com",subgraphUri:"https://v4.subgraph.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com"}),G({},q,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",providerUri:"https://v4.provider.mumbai.oceanprotocol.com",subgraphUri:"https://v4.subgraph.mumbai.oceanprotocol.com",explorerUri:"https://mumbai.polygonscan.com",gasFeeMultiplier:1.1}),G({},q,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",providerUri:"https://v4.provider.bsc.oceanprotocol.com",subgraphUri:"https://v4.subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05}),G({},q,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",providerUri:"https://v4.provider.energyweb.oceanprotocol.com",subgraphUri:"https://v4.subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05}),G({},q,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",providerUri:"https://v4.provider.moonriver.oceanprotocol.com",subgraphUri:"https://v4.subgraph.moonriver.oceanprotocol.com",explorerUri:"https://moonriver.moonscan.io/",gasFeeMultiplier:1.05})],_=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r;if(t)try{var o=t[e];r=G({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})}catch(e){}else if(n[e]){var i=n[e];r=G({erc721FactoryAddress:i.ERC721Factory,sideStakingAddress:i.Staking,opfCommunityFeeCollector:i.OPFCommunityFeeCollector,poolTemplateAddress:i.poolTemplate,fixedRateExchangeAddress:i.FixedPrice,dispenserAddress:i.Dispenser,oceanTokenAddress:i.Ocean,chainId:i.chainId,startBlock:i.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=z.find(function(t){return t[r]===e});return n?(n=G({},n,this.getAddressesFromEnv(n.network)),G({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(g.error("No config found for given network '"+e+"'"),null)},e}();function J(t,r){return t=e.utils.toChecksumAddress(t),"did:op:"+o(t+r.toString(10)).toString()}function V(e){try{return o(e).toString()}catch(e){g.error("getHash error: ",e.message)}}var H=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)}};function Z(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){try{var r=new e.eth.Contract(b,t);return Promise.resolve(r.methods.decimals().call())}catch(e){return Promise.reject(e)}},Q=function(e,t,r,n){try{var o=new e.eth.Contract(b,t);return Promise.resolve(o.methods.balanceOf(r).call()).then(function(r){return Promise.resolve(T(e,t,r,n))})}catch(e){return Promise.reject(e)}},K=function(e,t,r,n,o){try{var i=new e.eth.Contract(b,t);return Promise.resolve(i.methods.allowance(r,n).call()).then(function(r){return Promise.resolve(T(e,t,r,o))})}catch(e){return Promise.reject(e)}},$=function(e,t,r,n,o){try{var i=new e.eth.Contract(b,r),s=null;return Promise.resolve(k(e,r,o)).then(function(r){return Promise.resolve(A(t,i.methods.transfer,n,r)).then(function(o){var a=Z(function(){var a=i.methods.transfer(n,r),c=a.send;return Promise.resolve(j(e,null)).then(function(e){return Promise.resolve(c.call(a,{from:t,gas:o+1,gasPrice:e})).then(function(e){s=e})})},function(e){g.error("ERROR: Failed to transfer tokens : "+e.message)});return a&&a.then?a.then(function(){return s}):s})})}catch(e){return Promise.reject(e)}},Y=function(e,t,r,n,o,i){try{var s=i||new e.eth.Contract(b,r);return Promise.resolve(A(t,s.methods.transfer,n,o))}catch(e){return Promise.reject(e)}},ee=function(e,t,r,n,o,s,a){void 0===s&&(s=!1);try{var c,u=function(i){if(c)return i;var s=null;return Promise.resolve(k(e,r,o,a)).then(function(r){return Promise.resolve(A(t,l.methods.approve,n,r)).then(function(o){var i=Z(function(){var i=l.methods.approve(n,r),a=i.send;return Promise.resolve(j(e,null)).then(function(e){return Promise.resolve(a.call(i,{from:t,gas:o+1,gasPrice:e})).then(function(e){s=e})})},function(e){g.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return i&&i.then?i.then(function(){return s}):s})})},l=new e.eth.Contract(b,r),m=function(){if(!s)return Promise.resolve(K(e,r,t,n)).then(function(e){if(new i(e).greaterThanOrEqualTo(new i(o)))return c=1,e})}();return Promise.resolve(m&&m.then?m.then(u):u(m))}catch(e){return Promise.reject(e)}},te=function(e,t,r,n,o,i){try{var s=i||new e.eth.Contract(b,r);return Promise.resolve(A(t,s.methods.approve,n,o))}catch(e){return Promise.reject(e)}},re=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}},ne=function(e,t,r){try{return Promise.resolve(e.getReserve(t,r)).then(ce)}catch(e){return Promise.reject(e)}},oe=function(e,t,r){try{return Promise.resolve(e.getReserve(t,r)).then(ce)}catch(e){return Promise.reject(e)}},ie=function(e,t,r){try{return Promise.resolve(e.getReserve(t,r)).then(ce)}catch(e){return Promise.reject(e)}},se=function(e,t,r){try{return Promise.resolve(e.getReserve(t,r)).then(ae)}catch(e){return Promise.reject(e)}};function ae(e){return new i(e).div(2)}function ce(e){return new i(e).div(2)}function ue(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function le(e,t,r){if(!e.s){if(r instanceof me){if(!r.s)return void(r.o=le.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(le.bind(null,e,t),le.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var me=/*#__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{le(n,1,i(this.v))}catch(e){le(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?le(n,1,t?t(o):o):r?le(n,1,r(o)):le(n,2,o)}catch(e){le(n,2,e)}},n},e}();function he(e){return e instanceof me&&1&e.s}var fe=/*#__PURE__*/function(){function e(e){this.aquariusURL=void 0,this.aquariusURL=e}var t=e.prototype;return t.resolve=function(e,t){try{var n=this.aquariusURL+"/api/aquarius/assets/ddo/"+e;return Promise.resolve(ue(function(){return Promise.resolve(r(n,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return Promise.resolve(e.json());throw new Error("HTTP request failed with status "+e.status)})},function(e){throw g.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForAqua=function(e,t,n){try{var o,i=this,s=0,a=function(e,t){var r;do{var n=e();if(n&&n.then){if(!he(n)){r=!0;break}n=n.v}var o=t();if(he(o)&&(o=o.v),!o)return n}while(!o.then);var i=new me,s=le.bind(null,i,2);return(r?n.then(a):o.then(c)).then(void 0,s),i;function a(r){for(n=r;he(o=t())&&(o=o.v),o;){if(o.then)return void o.then(c).then(void 0,s);if((n=e())&&n.then){if(!he(n))return void n.then(a).then(void 0,s);n=n.v}}le(i,1,n)}function c(r){if(r){do{if((n=e())&&n.then){if(!he(n))return void n.then(a).then(void 0,s);n=n.v}if(he(r=t())&&(r=r.v),!r)return void le(i,1,n)}while(!r.then);r.then(c).then(void 0,s)}else le(i,1,n)}}(function(){function a(e){return o?e:Promise.resolve(re(1500)).then(function(){s++})}var c=ue(function(){return Promise.resolve(r(i.aquariusURL+"/api/aquarius/assets/ddo/"+e,{method:"GET",headers:{"Content-Type":"application/json"},signal:n})).then(function(e){return function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){return t?e.event&&e.event.txid===t?(o=1,e):void 0:(o=1,e)})}()})},function(){});return c&&c.then?c.then(a):a(c)},function(){return!o&&s<100});return Promise.resolve(a&&a.then?a.then(function(e){return o?e:null}):o?a:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t){try{var n,o=this,i={valid:!1},s=ue(function(){return Promise.resolve(r(o.aquariusURL+"/api/aquarius/assets/ddo/validate",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:t})).then(function(e){return Promise.resolve(e.json()).then(function(t){n=t,200===e.status?(i.valid=!0,i.hash=n.hash,i.proof={validatorAddress:n.publicKey,r:n.r[0],s:n.s[0],v:n.v}):(i.errors=n,g.error("validate Metadata failed:",e.status,i.errors))})})},function(e){g.error("Error validating metadata: ",e)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}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="115792089237316195423570985008687907853269984665640564039457584007913129639934",Pe=/*#__PURE__*/function(){function e(e,t,r,n){void 0===r&&(r=null),this.poolAbi=void 0,this.web3=void 0,this.config=void 0,this.poolAbi=r||s.abi,this.web3=e,this.config=n||(new _).getConfig(t||"unknown")}var r=e.prototype;return r.amountToUnits=function(e,t,r){try{return Promise.resolve(k(this.web3,e,t,r))}catch(e){return Promise.reject(e)}},r.unitsToAmount=function(e,t,r){try{return Promise.resolve(T(this.web3,e,t,r))}catch(e){return Promise.reject(e)}},r.sharesBalance=function(e,t){try{var r=this,n=null,o=de(function(){var o=F(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){g.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)}},r.estSetSwapFee=function(e,t,r,n){try{var o=n||F(new this.web3.eth.Contract(a.abi,t),this.config);return Promise.resolve(A(e,o.methods.setSwapFee,r))}catch(e){return Promise.reject(e)}},r.setSwapFee=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.poolAbi,t,{from:e}),n.config),i=null;return Promise.resolve(A(e,o.methods.setSwapFee,r)).then(function(t){var s=de(function(){var s=o.methods.setSwapFee(n.web3.utils.toWei(r)),a=s.send;return Promise.resolve(j(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){g.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)}},r.getNumTokens=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getNumTokens().call()).then(function(e){n=e})},function(e){g.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)}},r.getPoolSharesTotalSupply=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.totalSupply().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){g.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)}},r.getCurrentTokens=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getCurrentTokens().call()).then(function(e){n=e})},function(e){g.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)}},r.getFinalTokens=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getFinalTokens().call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get the final tokens composing this pool "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},r.getController=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getController().call()).then(function(e){n=e})},function(e){g.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)}},r.getBaseToken=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getBaseTokenAddress().call()).then(function(e){n=e})},function(e){g.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)}},r.getDatatoken=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getDatatokenAddress().call()).then(function(e){n=e})},function(e){g.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)}},r.getMarketFee=function(e){try{var t=function(){return r.web3.utils.fromWei(o).toString()},r=this,n=F(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=de(function(){return Promise.resolve(n.methods.getMarketFee().call()).then(function(e){o=e})},function(e){g.error("ERROR: Failed to get getMarketFee: "+e.message)});return Promise.resolve(i&&i.then?i.then(t):t())}catch(e){return Promise.reject(e)}},r.getMarketFeeCollector=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods._publishMarketCollector().call()).then(function(e){n=e})},function(e){g.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)}},r.isBound=function(e,t){try{var r=this,n=F(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=de(function(){return Promise.resolve(n.methods.isBound(t).call()).then(function(e){o=e})},function(e){g.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)}},r.getReserve=function(e,t,r){try{var n=function(){return i.toString()},o=this,i=null,s=de(function(){var n=F(new o.web3.eth.Contract(o.poolAbi,e),o.config);return Promise.resolve(n.methods.getBalance(t).call()).then(function(e){return Promise.resolve(o.unitsToAmount(t,e,r)).then(function(e){i=e})})},function(e){g.error("ERROR: Failed to get how many tokens are in the pool: "+e.message)});return Promise.resolve(s&&s.then?s.then(n):n())}catch(e){return Promise.reject(e)}},r.isFinalized=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.isFinalized().call()).then(function(e){n=e})},function(e){g.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)}},r.getSwapFee=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getSwapFee().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){g.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)}},r.getNormalizedWeight=function(e,t){try{var r=this,n=F(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=de(function(){return Promise.resolve(n.methods.getNormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(e){g.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)}},r.getDenormalizedWeight=function(e,t){try{var r=this,n=F(new r.web3.eth.Contract(r.poolAbi,e),r.config),o=null,i=de(function(){return Promise.resolve(n.methods.getDenormalizedWeight(t).call()).then(function(e){o=r.web3.utils.fromWei(e)})},function(e){g.error("ERROR: Failed to get denormalized weight of a token in pool "+e.message)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},r.getTotalDenormalizedWeight=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config),n=null,o=de(function(){return Promise.resolve(r.methods.getTotalDenormalizedWeight().call()).then(function(e){n=t.web3.utils.fromWei(e)})},function(e){g.error("ERROR: Failed to get total denormalized weight in pool "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},r.getMarketFees=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=de(function(){return Promise.resolve(o.methods.publishMarketFees(t).call()).then(function(e){return Promise.resolve(n.unitsToAmount(t,e,r)).then(function(e){i=e})})},function(e){g.error("ERROR: Failed to get market fees for a token: "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.getCurrentMarketFees=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(de(function(){return Promise.resolve(r.methods.getCurrentOPCFees().call())},function(e){g.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},r.getCurrentOPCFees=function(e){try{var t=this,r=F(new t.web3.eth.Contract(t.poolAbi,e),t.config);return Promise.resolve(de(function(){return Promise.resolve(r.methods.getCurrentOPCFees().call())},function(e){g.error("ERROR: Failed to get community fees for a token: "+e.message)}))}catch(e){return Promise.reject(e)}},r.getCommunityFees=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.poolAbi,e),n.config),i=null,s=de(function(){return Promise.resolve(o.methods.communityFees(t).call()).then(function(e){return Promise.resolve(n.unitsToAmount(t,e,r)).then(function(e){i=e})})},function(e){g.error("ERROR: Failed to get community fees for a token: "+e.message)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},r.estCollectOPC=function(e,t,r){try{var n=this,o=r||F(new n.web3.eth.Contract(n.poolAbi,t),n.config);return Promise.resolve(A(e,o.methods.collectOPC))}catch(e){return Promise.reject(e)}},r.collectOPC=function(e,t){try{var r=this,n=F(new r.web3.eth.Contract(r.poolAbi,t),r.config),o=null;return Promise.resolve(A(e,n.methods.collectOPC)).then(function(t){var i=de(function(){var i=n.methods.collectOPC(),s=i.send;return Promise.resolve(j(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){g.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)}},r.estCollectMarketFee=function(e,t,r){try{var n=this,o=r||F(new n.web3.eth.Contract(n.poolAbi,t),n.config);return Promise.resolve(A(e,o.methods.collectMarketFee))}catch(e){return Promise.reject(e)}},r.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=F(new r.web3.eth.Contract(r.poolAbi,t),r.config),i=null;return Promise.resolve(A(e,o.methods.collectMarketFee)).then(function(t){var n=de(function(){var n=o.methods.collectMarketFee(),s=n.send;return Promise.resolve(j(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){g.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)}},r.estUpdatePublishMarketFee=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.poolAbi,t),i.config);return Promise.resolve(A(e,s.methods.updatePublishMarketFee,r,i.web3.utils.toWei(n)))}catch(e){return Promise.reject(e)}},r.updatePublishMarketFee=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getMarketFeeCollector(t)).then(function(i){if(i!==e)throw new Error("Caller is not MarketFeeCollector");var s=F(new o.web3.eth.Contract(o.poolAbi,t),o.config),a=null;return Promise.resolve(A(e,s.methods.updatePublishMarketFee,r,o.web3.utils.toWei(n))).then(function(t){var i=de(function(){var i=s.methods.updatePublishMarketFee(r,o.web3.utils.toWei(n)),c=i.send;return Promise.resolve(j(o.web3,o.config)).then(function(r){return Promise.resolve(c.call(i,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){g.error("ERROR: Failed to updatePublishMarketFee : "+e.message)});return i&&i.then?i.then(function(){return a}):a})})}catch(e){return Promise.reject(e)}},r.estSwapExactAmountIn=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.poolAbi,t),i.config);return Promise.resolve(i.amountToUnits(r.tokenIn,n.tokenAmountIn,r.tokenInDecimals)).then(function(o){return Promise.resolve(i.amountToUnits(r.tokenOut,n.minAmountOut,r.tokenOutDecimals)).then(function(a){function c(t){var c=u?l.call(i,t,n.maxPrice):t;return A(e,s.methods.swapExactAmountIn,[r.tokenIn,r.tokenOut,r.marketFeeAddress],[o,a,c,i.web3.utils.toWei(n.swapMarketFee)])}var u=n.maxPrice,l=u&&i.amountToUnits;return u?Promise.resolve(i.getBaseToken(t)).then(c):c(ve)})})}catch(e){return Promise.reject(e)}},r.swapExactAmountIn=function(e,t,r,n){try{var o=this,s=F(new o.web3.eth.Contract(o.poolAbi,t),o.config);return Promise.resolve(ie(o,t,r.tokenIn)).then(function(a){if(new i(n.tokenAmountIn).greaterThan(a))throw new Error("tokenAmountIn is greater than "+a.toString());return Promise.resolve(o.amountToUnits(r.tokenIn,n.tokenAmountIn,r.tokenInDecimals)).then(function(i){return Promise.resolve(o.amountToUnits(r.tokenOut,n.minAmountOut,r.tokenOutDecimals)).then(function(a){function c(e){return l?Promise.resolve(m.call(o,e,n.maxPrice)).then(u):e}function u(t){return Promise.resolve(A(e,s.methods.swapExactAmountIn,[r.tokenIn,r.tokenOut,r.marketFeeAddress],[i,a,t,o.web3.utils.toWei(n.swapMarketFee)])).then(function(c){var u=null,l=de(function(){var l=s.methods.swapExactAmountIn([r.tokenIn,r.tokenOut,r.marketFeeAddress],[i,a,t,o.web3.utils.toWei(n.swapMarketFee)]),m=l.send;return Promise.resolve(j(o.web3,o.config)).then(function(t){return Promise.resolve(m.call(l,{from:e,gas:c+1,gasPrice:t})).then(function(e){u=e})})},function(e){g.error("ERROR: Failed to swap exact amount in : "+e.message)});return l&&l.then?l.then(function(){return u}):u})}var l=n.maxPrice,m=l&&o.amountToUnits;return l?Promise.resolve(o.getBaseToken(t)).then(c):c(u(ve))})})})}catch(e){return Promise.reject(e)}},r.estSwapExactAmountOut=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.poolAbi,t),i.config);return Promise.resolve(i.amountToUnits(r.tokenIn,n.maxAmountIn,r.tokenInDecimals)).then(function(o){return Promise.resolve(i.amountToUnits(r.tokenOut,n.tokenAmountOut,r.tokenOutDecimals)).then(function(a){function c(e){return l?Promise.resolve(m.call(i,e,n.maxPrice)).then(u):e}function u(t){return A(e,s.methods.swapExactAmountOut,[r.tokenIn,r.tokenOut,r.marketFeeAddress],[o,a,t,i.web3.utils.toWei(n.swapMarketFee)])}var l=n.maxPrice,m=l&&i.amountToUnits;return l?Promise.resolve(i.getBaseToken(t)).then(c):c(u(ve))})})}catch(e){return Promise.reject(e)}},r.swapExactAmountOut=function(e,t,r,n){try{var o=this,s=F(new o.web3.eth.Contract(o.poolAbi,t),o.config),a=null;return Promise.resolve(se(o,t,r.tokenOut)).then(function(c){if(new i(n.tokenAmountOut).greaterThan(c))throw new Error("tokenAmountOut is greater than "+c.toString());return Promise.resolve(o.amountToUnits(r.tokenIn,n.maxAmountIn,r.tokenInDecimals)).then(function(i){return Promise.resolve(o.amountToUnits(r.tokenOut,n.tokenAmountOut,r.tokenOutDecimals)).then(function(c){function u(t){var u=l?m.call(o,t,n.maxPrice):t;return Promise.resolve(A(e,s.methods.swapExactAmountOut,[r.tokenIn,r.tokenOut,r.marketFeeAddress],[i,c,u,o.web3.utils.toWei(n.swapMarketFee)])).then(function(t){var l=de(function(){var l=s.methods.swapExactAmountOut([r.tokenIn,r.tokenOut,r.marketFeeAddress],[i,c,u,o.web3.utils.toWei(n.swapMarketFee)]),m=l.send;return Promise.resolve(j(o.web3,o.config)).then(function(r){return Promise.resolve(m.call(l,{from:e,gas:t+1,gasPrice:r})).then(function(e){a=e})})},function(e){g.error("ERROR: Failed to swap exact amount out: "+e.message)});return l&&l.then?l.then(function(){return a}):a})}var l=n.maxPrice,m=l&&o.amountToUnits;return l?Promise.resolve(o.getBaseToken(t)).then(u):u(ve)})})})}catch(e){return Promise.reject(e)}},r.estJoinswapExternAmountIn=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.poolAbi,t),i.config);return Promise.resolve(A(e,s.methods.joinswapExternAmountIn,r,n))}catch(e){return Promise.reject(e)}},r.joinswapExternAmountIn=function(e,t,r,n,o){try{var s=this,a=F(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=null;return Promise.resolve(s.getBaseToken(t)).then(function(u){return Promise.resolve(oe(s,t,u)).then(function(t){if(new i(r).greaterThan(t))throw new Error("tokenAmountOut is greater than "+t.toString());return Promise.resolve(s.amountToUnits(u,r,o)).then(function(t){return Promise.resolve(A(e,a.methods.joinswapExternAmountIn,t,s.web3.utils.toWei(n))).then(function(r){var o=de(function(){var o=a.methods.joinswapExternAmountIn(t,s.web3.utils.toWei(n)),i=o.send;return Promise.resolve(j(s.web3,s.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:r+1,gasPrice:t})).then(function(e){c=e})})},function(e){g.error("ERROR: Failed to pay tokens in order to join the pool: "+e.message)});return o&&o.then?o.then(function(){return c}):c})})})})}catch(e){return Promise.reject(e)}},r.estExitswapPoolAmountIn=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.poolAbi,t),i.config);return Promise.resolve(A(e,s.methods.exitswapPoolAmountIn,r,n))}catch(e){return Promise.reject(e)}},r.exitswapPoolAmountIn=function(e,t,r,n,o){try{var s=this,a=F(new s.web3.eth.Contract(s.poolAbi,t),s.config),c=null;return Promise.resolve(s.getBaseToken(t)).then(function(u){return Promise.resolve(s.calcSingleOutGivenPoolIn(t,u,r)).then(function(l){return Promise.resolve(ne(s,t,u)).then(function(u){if(new i(l).greaterThan(u))throw new Error("tokenAmountOut is greater than "+u.toString());var m=s.amountToUnits;return Promise.resolve(s.getBaseToken(t)).then(function(t){return Promise.resolve(m.call(s,t,n,o)).then(function(t){return Promise.resolve(A(e,a.methods.exitswapPoolAmountIn,s.web3.utils.toWei(r),t)).then(function(n){var o=de(function(){var o=a.methods.exitswapPoolAmountIn(s.web3.utils.toWei(r),t),i=o.send;return Promise.resolve(j(s.web3,s.config)).then(function(t){return Promise.resolve(i.call(o,{from:e,gas:n+1,gasPrice:t})).then(function(e){c=e})})},function(e){g.error("ERROR: Failed to pay pool shares into the pool: "+e.message)});return o&&o.then?o.then(function(){return c}):c})})})})})})}catch(e){return Promise.reject(e)}},r.getSpotPrice=function(e,r,n,o){try{var i=function(){function e(){function e(){var e;return u>l?(e=u-l,i=new t(i/Math.pow(10,e)),i/=Math.pow(10,l)):(e=l-u,i=new t(i*Math.pow(10,2*e)),i/=Math.pow(10,l)),i.toString()}var i=null,a=de(function(){return Promise.resolve(c.methods.getSpotPrice(r,n,s.web3.utils.toWei(o)).call()).then(function(e){i=new t((i=e).toString())})},function(){g.error("ERROR: Failed to get spot price of swapping tokenIn to tokenOut")});return a&&a.then?a.then(e):e()}var i=de(function(){return Promise.resolve(h.methods.decimals().call()).then(function(e){l=e})},function(e){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18 "+e.message)});return i&&i.then?i.then(e):e()},s=this,c=F(new s.web3.eth.Contract(s.poolAbi,e),s.config),u=18,l=18,m=F(new s.web3.eth.Contract(a.abi,r),s.config),h=F(new s.web3.eth.Contract(a.abi,n),s.config),f=de(function(){return Promise.resolve(m.methods.decimals().call()).then(function(e){u=e})},function(e){g.error("ERROR: FAILED TO CALL DECIMALS(), USING 18 "+e.message)});return Promise.resolve(f&&f.then?f.then(i):i())}catch(e){return Promise.reject(e)}},r.getAmountInExactOut=function(e,t,r,n,o,s,a){try{var c=this,u=F(new c.web3.eth.Contract(c.poolAbi,e),c.config);return Promise.resolve(se(c,e,r)).then(function(e){if(new i(n).greaterThan(e))throw new Error("tokenAmountOut is greater than "+e.toString());return Promise.resolve(c.amountToUnits(r,n,a)).then(function(e){var n=null,i=de(function(){return Promise.resolve(u.methods.getAmountInExactOut(t,r,e,c.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(c.unitsToAmount(r,e.tokenAmountIn,a)).then(function(r){return Promise.resolve(c.unitsToAmount(t,e.lpFeeAmount,s)).then(function(o){return Promise.resolve(c.unitsToAmount(t,e.oceanFeeAmount,s)).then(function(i){return Promise.resolve(c.unitsToAmount(t,e.publishMarketSwapFeeAmount,s)).then(function(a){return Promise.resolve(c.unitsToAmount(t,e.consumeMarketSwapFeeAmount,s)).then(function(e){n={tokenAmount:r,liquidityProviderSwapFeeAmount:o,oceanFeeAmount:i,publishMarketSwapFeeAmount:a,consumeMarketSwapFeeAmount:e}})})})})})})},function(e){g.error("ERROR: Failed to calcInGivenOut "+e.message)});return i&&i.then?i.then(function(){return n}):n})})}catch(e){return Promise.reject(e)}},r.getAmountOutExactIn=function(e,t,r,n,o,s,a){try{var c=this,u=F(new c.web3.eth.Contract(c.poolAbi,e),c.config);return Promise.resolve(ie(c,e,t)).then(function(e){if(new i(n).greaterThan(e))throw new Error("tokenAmountIn is greater than "+e.toString());return Promise.resolve(c.amountToUnits(t,n,s)).then(function(e){var n=null,i=de(function(){return Promise.resolve(u.methods.getAmountOutExactIn(t,r,e,c.web3.utils.toWei(o)).call()).then(function(e){return Promise.resolve(c.unitsToAmount(r,e.tokenAmountOut,a)).then(function(r){return Promise.resolve(c.unitsToAmount(t,e.lpFeeAmount,s)).then(function(o){return Promise.resolve(c.unitsToAmount(t,e.oceanFeeAmount,s)).then(function(i){return Promise.resolve(c.unitsToAmount(t,e.publishMarketSwapFeeAmount,s)).then(function(a){return Promise.resolve(c.unitsToAmount(t,e.consumeMarketSwapFeeAmount,s)).then(function(e){n={tokenAmount:r,liquidityProviderSwapFeeAmount:o,oceanFeeAmount:i,publishMarketSwapFeeAmount:a,consumeMarketSwapFeeAmount:e}})})})})})})},function(e){g.error("ERROR: Failed to calcOutGivenIn "+e.message)});return i&&i.then?i.then(function(){return n}):n})})}catch(e){return Promise.reject(e)}},r.calcPoolOutGivenSingleIn=function(e,t,r,n,o){try{var i=this,s=F(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=null,c=de(function(){var c=s.methods,u=c.calcPoolOutSingleIn;return Promise.resolve(i.amountToUnits(t,r,o)).then(function(r){return Promise.resolve(u.call(c,t,r).call()).then(function(t){return Promise.resolve(i.unitsToAmount(e,t,n)).then(function(e){a=e})})})},function(e){g.error("ERROR: Failed to calculate PoolOutGivenSingleIn : "+e.message)});return Promise.resolve(c&&c.then?c.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},r.calcSingleInGivenPoolOut=function(e,t,r,n,o){try{var i=this,s=F(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=null;return Promise.resolve(i.amountToUnits(e,r,n)).then(function(e){var r=de(function(){return Promise.resolve(s.methods.calcSingleInPoolOut(t,e).call()).then(function(e){return Promise.resolve(i.unitsToAmount(t,e,o)).then(function(e){a=e})})},function(e){g.error("ERROR: Failed to calculate SingleInGivenPoolOut : "+e.message)});return r&&r.then?r.then(function(){return a}):a})}catch(e){return Promise.reject(e)}},r.calcSingleOutGivenPoolIn=function(e,t,r,n,o){try{var i=this,s=F(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=null,c=de(function(){var c=s.methods,u=c.calcSingleOutPoolIn;return Promise.resolve(i.amountToUnits(e,r,n)).then(function(e){return Promise.resolve(u.call(c,t,e).call()).then(function(e){return Promise.resolve(i.unitsToAmount(t,e,o)).then(function(e){a=e})})})},function(e){g.error("ERROR: Failed to calculate SingleOutGivenPoolIn : "+e)});return Promise.resolve(c&&c.then?c.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},r.calcPoolInGivenSingleOut=function(e,t,r,n,o){try{var i=this,s=F(new i.web3.eth.Contract(i.poolAbi,e),i.config),a=null,c=de(function(){var c=s.methods,u=c.calcPoolInSingleOut;return Promise.resolve(i.amountToUnits(t,r,o)).then(function(r){return Promise.resolve(u.call(c,t,r).call()).then(function(t){return Promise.resolve(i.unitsToAmount(e,t,n)).then(function(e){a=e})})})},function(e){g.error("ERROR: Failed to calculate PoolInGivenSingleOut : "+e.message)});return Promise.resolve(c&&c.then?c.then(function(){return a}):a)}catch(e){return Promise.reject(e)}},r.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)},r.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)},r.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 ge(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var pe,we=/*#__PURE__*/function(){function e(e,t,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),this.web3=null,this.dispenserAddress=void 0,this.config=void 0,this.dispenserAbi=void 0,this.dispenserContract=void 0,this.web3=e,this.dispenserAddress=r,this.dispenserAbi=n||c.abi,this.config=o||(new _).getConfig(t||"unknown"),e&&(this.dispenserContract=F(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=ge(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=this;return Promise.resolve(A(t,i.dispenserContract.methods.create,e,i.web3.utils.toWei(r),i.web3.utils.toWei(n),t,o))}catch(e){return Promise.reject(e)}},t.create=function(e,t,r,n,o){try{var i=this;return Promise.resolve(A(t,i.dispenserContract.methods.create,e,i.web3.utils.toWei(r),i.web3.utils.toWei(n),t,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(j(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=this;return Promise.resolve(A(n,o.dispenserContract.methods.activate,e,o.web3.utils.toWei(t),o.web3.utils.toWei(r)))}catch(e){return Promise.reject(e)}},t.activate=function(e,t,r,n){try{var o,i=this,s=ge(function(){return Promise.resolve(A(n,i.dispenserContract.methods.activate,e,i.web3.utils.toWei(t),i.web3.utils.toWei(r))).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(j(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{return Promise.resolve(A(t,this.dispenserContract.methods.deactivate,e))}catch(e){return Promise.reject(e)}},t.deactivate=function(e,t){try{var r,n=this,o=ge(function(){return Promise.resolve(A(t,n.dispenserContract.methods.deactivate,e)).then(function(o){var i=n.dispenserContract.methods.deactivate(e),s=i.send;return Promise.resolve(j(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{return Promise.resolve(A(t,this.dispenserContract.methods.setAllowedSwapper,e,r))}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n,o=this,i=ge(function(){return Promise.resolve(A(t,o.dispenserContract.methods.setAllowedSwapper,e,r)).then(function(i){var s=o.dispenserContract.methods.setAllowedSwapper(e,r),a=s.send;return Promise.resolve(j(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{return Promise.resolve(A(t,this.dispenserContract.methods.dispense,e,this.web3.utils.toWei(r),n))}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(A(t,o.dispenserContract.methods.dispense,e,o.web3.utils.toWei(r),n)).then(function(i){var s,a=ge(function(){var a=o.dispenserContract.methods.dispense(e,o.web3.utils.toWei(r),n),c=a.send;return Promise.resolve(j(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{return Promise.resolve(A(t,this.dispenserContract.methods.ownerWithdraw,e))}catch(e){return Promise.reject(e)}},t.ownerWithdraw=function(e,t){try{var r=this;return Promise.resolve(A(t,r.dispenserContract.methods.ownerWithdraw,e)).then(function(n){var o,i=ge(function(){var i=r.dispenserContract.methods.ownerWithdraw(e),s=i.send;return Promise.resolve(j(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 i(e).greaterThanOrEqualTo(o.maxBalance)||new i(String(n)).greaterThan(o.maxTokens)||!new i(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},e}();function be(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}!function(e){e[e.CreatingExchange=0]="CreatingExchange",e[e.ApprovingDatatoken=1]="ApprovingDatatoken"}(pe||(pe={}));var ye=/*#__PURE__*/function(){function e(e,t,r,n,o,i){void 0===n&&(n=null),void 0===o&&(o=null),this.oceanAddress=null,this.fixedRateAddress=void 0,this.fixedRateExchangeAbi=void 0,this.web3=void 0,this.fixedRateContract=null,this.config=void 0,this.ssAbi=void 0,this.web3=e,this.config=i||(new _).getConfig(r||"unknown"),this.fixedRateExchangeAbi=n||u.abi,this.oceanAddress=o,this.fixedRateAddress=t,this.fixedRateContract=F(new this.web3.eth.Contract(this.fixedRateExchangeAbi,this.fixedRateAddress),this.config)}var t=e.prototype;return t.amountToUnits=function(e,t,r){try{return Promise.resolve(k(this.web3,e,t,r))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t,r){try{return Promise.resolve(T(this.web3,e,t,r))}catch(e){return Promise.reject(e)}},t.generateExchangeId=function(e,t){try{return Promise.resolve(this.fixedRateContract.methods.generateExchangeId(e,t).call())}catch(e){return Promise.reject(e)}},t.estBuyDT=function(e,t,r,n,o,i,s){try{return Promise.resolve(A(e,(s||this.fixedRateContract).methods.buyDT,t,r,n,o,i))}catch(e){return Promise.reject(e)}},t.buyDT=function(e,t,r,n,o,i){void 0===o&&(o=y),void 0===i&&(i="0");try{var s=this;return Promise.resolve(s.getExchange(t)).then(function(a){var c=s.web3.utils.toWei(i);return Promise.resolve(s.amountToUnits(a.datatoken,r,+a.dtDecimals)).then(function(r){return Promise.resolve(s.amountToUnits(a.baseToken,n,+a.btDecimals)).then(function(n){return Promise.resolve(A(e,s.fixedRateContract.methods.buyDT,t,r,n,o,c)).then(function(i){return be(function(){var a=s.fixedRateContract.methods.buyDT(t,r,n,o,c),u=a.send;return Promise.resolve(j(s.web3,s.config)).then(function(t){return Promise.resolve(u.call(a,{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,i,s){try{return Promise.resolve(A(e,(s||this.fixedRateContract).methods.sellDT,t,r,n,o,i))}catch(e){return Promise.reject(e)}},t.sellDT=function(e,t,r,n,o,i){void 0===o&&(o=y),void 0===i&&(i="0");try{var s=this;return Promise.resolve(s.getExchange(t)).then(function(a){var c=s.web3.utils.toWei(i);return Promise.resolve(s.amountToUnits(a.datatoken,r,+a.dtDecimals)).then(function(r){return Promise.resolve(s.amountToUnits(a.baseToken,n,+a.btDecimals)).then(function(n){return Promise.resolve(A(e,s.fixedRateContract.methods.sellDT,t,r,n,o,c)).then(function(i){return be(function(){var a=s.fixedRateContract.methods.sellDT(t,r,n,o,c),u=a.send;return Promise.resolve(j(s.web3,s.config)).then(function(t){return Promise.resolve(u.call(a,{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.fixedRateContract.methods.getNumberOfExchanges().call())}catch(e){return Promise.reject(e)}},t.estSetRate=function(e,t,r,n){try{var o=(n||this.fixedRateContract).methods.setRate;return Promise.resolve(this.web3.utils.toWei(r)).then(function(r){return A(e,o,t,r)})}catch(e){return Promise.reject(e)}},t.setRate=function(e,t,r){try{var n=this;return Promise.resolve(A(e,n.fixedRateContract.methods.setRate,t,n.web3.utils.toWei(r))).then(function(o){var i=n.fixedRateContract.methods.setRate(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(n||this.fixedRateContract).methods.setAllowedSwapper,t,r))}catch(e){return Promise.reject(e)}},t.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(A(e,n.fixedRateContract.methods.setAllowedSwapper,t,r)).then(function(o){var i=n.fixedRateContract.methods.setAllowedSwapper(t,r),s=i.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.toggleExchangeState,t))}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(A(e,r.fixedRateContract.methods.toggleExchangeState,t)).then(function(n){var o=r.fixedRateContract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.toggleExchangeState,t))}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(A(e,r.fixedRateContract.methods.toggleExchangeState,t)).then(function(n){var o=r.fixedRateContract.methods.toggleExchangeState(t),i=o.send;return Promise.resolve(j(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.fixedRateContract.methods.getRate(e).call()).then(function(e){return Promise.resolve(t.web3.utils.fromWei(e))})}catch(e){return Promise.reject(e)}},t.getDTSupply=function(e){try{var t=this;return Promise.resolve(t.fixedRateContract.methods.getDTSupply(e).call()).then(function(r){return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(t.unitsToAmount(e.datatoken,r,+e.dtDecimals))})})}catch(e){return Promise.reject(e)}},t.getBTSupply=function(e){try{var t=this;return Promise.resolve(t.fixedRateContract.methods.getBTSupply(e).call()).then(function(r){return Promise.resolve(t.getExchange(e)).then(function(e){return Promise.resolve(t.unitsToAmount(e.baseToken,r,+e.btDecimals))})})}catch(e){return Promise.reject(e)}},t.getAllowedSwapper=function(e){try{return Promise.resolve(this.fixedRateContract.methods.getAllowedSwapper(e).call())}catch(e){return Promise.reject(e)}},t.calcBaseInGivenOutDT=function(e,t,r){void 0===r&&(r="0");try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){var i=n.fixedRateContract.methods,s=i.calcBaseInGivenOutDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(s.call(i,e,t,n.web3.utils.toWei(r)).call()).then(function(e){return Promise.resolve(n.unitsToAmount(o.baseToken,e.baseTokenAmount,+o.btDecimals)).then(function(t){return Promise.resolve(n.unitsToAmount(o.baseToken,e.marketFeeAmount,+o.btDecimals)).then(function(r){return Promise.resolve(n.unitsToAmount(o.baseToken,e.oceanFeeAmount,+o.btDecimals)).then(function(i){return Promise.resolve(n.unitsToAmount(o.baseToken,e.consumeMarketFeeAmount,+o.btDecimals)).then(function(e){return{baseTokenAmount:t,marketFeeAmount:r,oceanFeeAmount:i,consumeMarketFeeAmount:e}})})})})})})})}catch(e){return Promise.reject(e)}},t.getAmountBTOut=function(e,t,r){void 0===r&&(r="0");try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){var i=n.fixedRateContract.methods,s=i.calcBaseOutGivenInDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(s.call(i,e,t,n.web3.utils.toWei(r)).call()).then(function(e){return Promise.resolve(n.unitsToAmount(o.baseToken,e[0],+o.btDecimals))})})})}catch(e){return Promise.reject(e)}},t.getExchange=function(e){try{var t=this;return Promise.resolve(t.fixedRateContract.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,+r.dtDecimals)).then(function(n){return r.dtBalance=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btBalance,+r.btDecimals)).then(function(n){return r.btBalance=n,Promise.resolve(t.unitsToAmount(r.datatoken,r.dtSupply,+r.dtDecimals)).then(function(n){return r.dtSupply=n,Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).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.fixedRateContract.methods.getFeesInfo(e).call()).then(function(r){return r.opcFee=t.web3.utils.fromWei(r.opcFee.toString()),r.marketFee=t.web3.utils.fromWei(r.marketFee.toString()),Promise.resolve(t.getExchange(e)).then(function(n){return Promise.resolve(t.unitsToAmount(n.baseToken,r.marketFeeAvailable,+n.btDecimals)).then(function(o){return r.marketFeeAvailable=o,Promise.resolve(t.unitsToAmount(n.baseToken,r.oceanFeeAvailable,+n.btDecimals)).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.fixedRateContract.methods.getExchanges().call())}catch(e){return Promise.reject(e)}},t.isActive=function(e){try{return Promise.resolve(this.fixedRateContract.methods.isActive(e).call())}catch(e){return Promise.reject(e)}},t.estActivateMint=function(e,t,r){try{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.toggleMintState,t,!0))}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(A(e,r.fixedRateContract.methods.toggleMintState,t,!0)).then(function(n){var o=r.fixedRateContract.methods.toggleMintState(t,!0),i=o.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.toggleMintState(t,!1),t,!1))}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(A(e,r.fixedRateContract.methods.toggleMintState,t,!1)).then(function(n){var o=r.fixedRateContract.methods.toggleMintState(t,!1),i=o.send;return Promise.resolve(j(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,n){try{var o=this,i=n||o.fixedRateContract;return Promise.resolve(o.fixedRateContract.methods.getExchange(t).call()).then(function(n){return Promise.resolve(o.amountToUnits(n.baseToken,r,+n.btDecimals)).then(function(r){return A(e,i.methods.collectBT,t,r)})})}catch(e){return Promise.reject(e)}},t.collectBT=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(t)).then(function(o){return o?Promise.resolve(n.fixedRateContract.methods.getExchange(t).call()).then(function(o){return Promise.resolve(n.amountToUnits(o.baseToken,r,+o.btDecimals)).then(function(r){return Promise.resolve(A(e,n.fixedRateContract.methods.collectBT,t,r)).then(function(o){var i=n.fixedRateContract.methods.collectBT(t,r),s=i.send;return Promise.resolve(j(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})})}):null})}catch(e){return Promise.reject(e)}},t.estCollectDT=function(e,t,r,n){try{var o=this,i=n||o.fixedRateContract;return Promise.resolve(o.fixedRateContract.methods.getExchange(t).call()).then(function(n){return Promise.resolve(o.amountToUnits(n.datatoken,r,+n.dtDecimals)).then(function(r){return A(e,i.methods.collectDT,t,r)})})}catch(e){return Promise.reject(e)}},t.collectDT=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(t)).then(function(o){return o?Promise.resolve(n.fixedRateContract.methods.getExchange(t).call()).then(function(o){return Promise.resolve(n.amountToUnits(o.datatoken,r,+o.dtDecimals)).then(function(r){return Promise.resolve(A(e,n.fixedRateContract.methods.collectDT,t,r)).then(function(o){var i=n.fixedRateContract.methods.collectDT(t,r),s=i.send;return Promise.resolve(j(n.web3,n.config)).then(function(t){return Promise.resolve(s.call(i,{from:e,gas:o+1,gasPrice:t}))})})})}):null})}catch(e){return Promise.reject(e)}},t.estCollectMarketFee=function(e,t,r){try{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.collectMarketFee,t))}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(A(e,r.fixedRateContract.methods.collectMarketFee,t)).then(function(n){var o=r.fixedRateContract.methods.collectMarketFee(t),i=o.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(r||this.fixedRateContract).methods.collectMarketFee,t))}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(A(e,r.fixedRateContract.methods.collectOceanFee,t)).then(function(n){var o=r.fixedRateContract.methods.collectOceanFee(t),i=o.send;return Promise.resolve(j(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.getOPCCollector=function(){try{var e=this,t=null,r=be(function(){return Promise.resolve(e.fixedRateContract.methods.opcCollector().call()).then(function(e){t=e})},function(e){g.error("ERROR: Failed to get OPC 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=be(function(){return Promise.resolve(e.fixedRateContract.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=be(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{return Promise.resolve(A(e,(n||this.fixedRateContract).methods.updateMarketFee,t,r))}catch(e){return Promise.reject(e)}},t.updateMarketFee=function(e,t,r){try{var n=this;return Promise.resolve(A(e,n.fixedRateContract.methods.updateMarketFee,t,n.web3.utils.toWei(r))).then(function(o){var i=n.fixedRateContract.methods.updateMarketFee(t,n.web3.utils.toWei(r)),s=i.send;return Promise.resolve(j(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{return Promise.resolve(A(e,(n||this.fixedRateContract).methods.updateMarketFeeCollector,t,r))}catch(e){return Promise.reject(e)}},t.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(A(e,n.fixedRateContract.methods.updateMarketFeeCollector,t,r)).then(function(o){var i=n.fixedRateContract.methods.updateMarketFeeCollector(t,r),s=i.send;return Promise.resolve(j(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 Ce(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Re=/*#__PURE__*/function(){function e(e,t,r,n){void 0===r&&(r=null),this.ssAbi=void 0,this.web3=void 0,this.config=void 0,this.ssAbi=r||l.abi,this.web3=e,this.config=n||(new _).getConfig(t||"unknown")}var t=e.prototype;return t.unitsToAmount=function(e,t,r){try{return Promise.resolve(T(this.web3,e,t,r))}catch(e){return Promise.reject(e)}},t.getDatatokenCirculatingSupply=function(e,t){try{var r=function(){return o.toString()},n=new this.web3.eth.Contract(this.ssAbi,e),o=null,i=Ce(function(){return Promise.resolve(n.methods.getDatatokenCirculatingSupply(t).call()).then(function(e){o=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(i&&i.then?i.then(r):r())}catch(e){return Promise.reject(e)}},t.getDatatokenCurrentCirculatingSupply=function(e,t){try{var r=this;return Promise.resolve(Ce(function(){var n=new r.web3.eth.Contract(r.ssAbi,e);return Promise.resolve(n.methods.getDatatokenCurrentCirculatingSupply(t).call()).then(function(e){return e.toString()})},function(e){g.error("ERROR: Failed to get: "+e.message)}))}catch(e){return Promise.reject(e)}},t.getPublisherAddress=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getPublisherAddress(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getBaseToken=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getBaseTokenAddress(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getPoolAddress=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getPoolAddress(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getBaseTokenBalance=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getBaseTokenBalance(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getDatatokenBalance=function(e,t,r){try{var n=function(){return Promise.resolve(o.unitsToAmount(t,s,r)).then(function(e){return s=e})},o=this,i=new o.web3.eth.Contract(o.ssAbi,e),s=null,a=Ce(function(){return Promise.resolve(i.methods.getDatatokenBalance(t).call()).then(function(e){s=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.getvestingEndBlock=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getvestingEndBlock(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getvestingAmount=function(e,t,r){try{var n=function(){return Promise.resolve(o.unitsToAmount(t,s,r)).then(function(e){return s=e})},o=this,i=new o.web3.eth.Contract(o.ssAbi,e),s=null,a=Ce(function(){return Promise.resolve(i.methods.getvestingAmount(t).call()).then(function(e){s=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.getvestingLastBlock=function(e,t){try{var r=new this.web3.eth.Contract(this.ssAbi,e),n=null,o=Ce(function(){return Promise.resolve(r.methods.getvestingLastBlock(t).call()).then(function(e){n=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){return n}):n)}catch(e){return Promise.reject(e)}},t.getvestingAmountSoFar=function(e,t,r){try{var n=function(){return Promise.resolve(o.unitsToAmount(t,s,r)).then(function(e){return s=e})},o=this,i=new o.web3.eth.Contract(o.ssAbi,e),s=null,a=Ce(function(){return Promise.resolve(i.methods.getvestingAmountSoFar(t).call()).then(function(e){s=e})},function(e){g.error("ERROR: Failed to get: "+e.message)});return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},t.estGetVesting=function(e,t,r,n){try{var o=n||new this.web3.eth.Contract(this.ssAbi,t);return Promise.resolve(A(e,o.methods.getVesting,r))}catch(e){return Promise.reject(e)}},t.getVesting=function(e,t,r){try{var n=this,o=new n.web3.eth.Contract(n.ssAbi,t),i=null;return Promise.resolve(A(e,o.methods.getVesting,r)).then(function(t){var s=Ce(function(){var s=o.methods.getVesting(r),a=s.send;return Promise.resolve(j(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(s,{from:e,gas:t+1,gasPrice:r})).then(function(e){i=e})})},function(){g.error("ERROR: Failed to join swap pool amount out")});return s&&s.then?s.then(function(){return i}):i})}catch(e){return Promise.reject(e)}},t.estSetPoolSwapFee=function(e,t,r,n,o,i){try{var s=i||new this.web3.eth.Contract(this.ssAbi,t);return Promise.resolve(A(e,s.methods.setPoolSwapFee,r,n,o))}catch(e){return Promise.reject(e)}},t.setPoolSwapFee=function(e,t,r,n,o){try{var i=this,s=new i.web3.eth.Contract(i.ssAbi,t),a=null;return Promise.resolve(A(e,s.methods.setPoolSwapFee,r,n,o)).then(function(t){var c=Ce(function(){var c=s.methods.setPoolSwapFee(r,n,o),u=c.send;return Promise.resolve(j(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(){g.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.getRouter=function(e){try{var t=new this.web3.eth.Contract(this.ssAbi,e),r=null,n=Ce(function(){return Promise.resolve(t.methods.router().call()).then(function(e){r=e})},function(e){g.error("ERROR: Failed to get Router address: "+e.message)});return Promise.resolve(n&&n.then?n.then(function(){return r}):r)}catch(e){return Promise.reject(e)}},e}(),Ae=/*#__PURE__*/function(){function e(e,t,r,n,o){this.routerAddress=void 0,this.RouterAbi=void 0,this.web3=void 0,this.config=void 0,this.router=void 0,this.routerAddress=e,this.RouterAbi=n||m.abi,this.web3=t,this.config=o||(new _).getConfig(r||"unknown"),this.router=F(new this.web3.eth.Contract(this.RouterAbi,this.routerAddress),this.config)}var t=e.prototype;return t.estGasBuyDTBatch=function(e,t){try{return Promise.resolve(A(e,this.router.methods.buyDTBatch,t))}catch(e){return Promise.reject(e)}},t.buyDTBatch=function(e,t){try{var r=this;return Promise.resolve(A(e,r.router.methods.buyDTBatch,t)).then(function(n){var o=r.router.methods.buyDTBatch(t),i=o.send;return Promise.resolve(j(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.isApprovedToken=function(e){try{return Promise.resolve(this.router.methods.isApprovedToken(e).call())}catch(e){return Promise.reject(e)}},t.isSideStaking=function(e){try{return Promise.resolve(this.router.methods.isSSContract(e).call())}catch(e){return Promise.reject(e)}},t.isFixedPrice=function(e){try{return Promise.resolve(this.router.methods.isFixedRateContract(e).call())}catch(e){return Promise.reject(e)}},t.getOwner=function(){try{return Promise.resolve(this.router.methods.routerOwner().call())}catch(e){return Promise.reject(e)}},t.getNFTFactory=function(){try{return Promise.resolve(this.router.methods.factory().call())}catch(e){return Promise.reject(e)}},t.isPoolTemplate=function(e){try{return Promise.resolve(this.router.methods.isPoolTemplate(e).call())}catch(e){return Promise.reject(e)}},t.estGasAddApprovedToken=function(e,t,r){try{return Promise.resolve(A(e,this.router.methods.addApprovedToken,t))}catch(e){return Promise.reject(e)}},t.addApprovedToken=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.addApprovedToken,t)).then(function(n){var o=r.router.methods.addApprovedToken(t),i=o.send;return Promise.resolve(j(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.estGasRemoveApprovedToken=function(e,t,r){try{return Promise.resolve(A(e,this.router.methods.removeApprovedToken,t))}catch(e){return Promise.reject(e)}},t.removeApprovedToken=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.removeApprovedToken,t)).then(function(n){var o=r.router.methods.removeApprovedToken(t),i=o.send;return Promise.resolve(j(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.estGasAddSSContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.addSSContract,t))}catch(e){return Promise.reject(e)}},t.addSSContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.addSSContract,t)).then(function(n){var o=r.router.methods.addSSContract(t),i=o.send;return Promise.resolve(j(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.estGasRemoveSSContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.removeSSContract,t))}catch(e){return Promise.reject(e)}},t.removeSSContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.removeSSContract,t)).then(function(n){var o=r.router.methods.removeSSContract(t),i=o.send;return Promise.resolve(j(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.estGasAddFixedRateContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.addFixedRateContract,t))}catch(e){return Promise.reject(e)}},t.addFixedRateContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.addFixedRateContract,t)).then(function(n){var o=r.router.methods.addFixedRateContract(t),i=o.send;return Promise.resolve(j(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.estGasRemoveFixedRateContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.removeFixedRateContract,t))}catch(e){return Promise.reject(e)}},t.removeFixedRateContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.removeFixedRateContract,t)).then(function(n){var o=r.router.methods.removeFixedRateContract(t),i=o.send;return Promise.resolve(j(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.estGasAddDispenserContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.addDispenserContract,t))}catch(e){return Promise.reject(e)}},t.addDispenserContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.addDispenserContract,t)).then(function(n){var o=r.router.methods.addDispenserContract(t),i=o.send;return Promise.resolve(j(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.estGasRemoveDispenserContract=function(e,t){try{return Promise.resolve(A(e,this.router.methods.removeDispenserContract,t))}catch(e){return Promise.reject(e)}},t.removeDispenserContract=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.removeDispenserContract,t)).then(function(n){var o=r.router.methods.removeDispenserContract(t),i=o.send;return Promise.resolve(j(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.getOPCFee=function(e){try{return Promise.resolve(this.router.methods.getOPCFee(e).call())}catch(e){return Promise.reject(e)}},t.getCurrentOPCFee=function(){try{return Promise.resolve(this.router.methods.swapOceanFee().call())}catch(e){return Promise.reject(e)}},t.estGasUpdateOPCFee=function(e,t,r,n,o){try{return Promise.resolve(A(e,this.router.methods.updateOPCFee,t,r,n,o))}catch(e){return Promise.reject(e)}},t.updateOPCFee=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getOwner()).then(function(s){if(s!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,i.router.methods.updateOPCFee,t,r,n,o)).then(function(s){var a=i.router.methods.updateOPCFee(t,r,n,o),c=a.send;return Promise.resolve(j(i.web3,i.config)).then(function(t){return Promise.resolve(c.call(a,{from:e,gas:s+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},t.estGasAddPoolTemplate=function(e,t){try{return Promise.resolve(A(e,this.router.methods.addPoolTemplate,t))}catch(e){return Promise.reject(e)}},t.addPoolTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.addPoolTemplate,t)).then(function(n){var o=r.router.methods.addPoolTemplate(t),i=o.send;return Promise.resolve(j(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.estGasRemovePoolTemplate=function(e,t){try{return Promise.resolve(A(e,this.router.methods.removePoolTemplate,t))}catch(e){return Promise.reject(e)}},t.removePoolTemplate=function(e,t){try{var r=this;return Promise.resolve(r.getOwner()).then(function(n){if(n!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(A(e,r.router.methods.removePoolTemplate,t)).then(function(n){var o=r.router.methods.removePoolTemplate(t),i=o.send;return Promise.resolve(j(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)}},e}(),ke=/*#__PURE__*/function(){function e(e,t,r,n){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=r||f.abi,this.web3=e,this.config=n||(new _).getConfig(t||"unknown")}var t=e.prototype;return t.estGasCreateErc20=function(e,t,r,n,o,i,s,a,c,u,l,m){try{var h=this,f=m||F(new h.web3.eth.Contract(h.nftAbi,e),h.config);return Promise.resolve(A(t,f.methods.createERC20,l,[c,u],[r,n,o,i],[h.web3.utils.toWei(a),h.web3.utils.toWei(s)],[]))}catch(e){return Promise.reject(e)}},t.createErc20=function(e,t,r,n,o,i,s,a,c,u,l){try{var m=this;return Promise.resolve(m.getNftPermissions(e,t)).then(function(h){if(!0!==h.deployERC20)throw new Error("Caller is not ERC20Deployer");if(l||(l=1),!c||!u){var f=w();c=f.name,u=f.symbol}var d=F(new m.web3.eth.Contract(m.nftAbi,e),m.config);return Promise.resolve(A(t,d.methods.createERC20,l,[c,u],[r,n,o,i],[m.web3.utils.toWei(a),m.web3.utils.toWei(s)],[])).then(function(e){var h=d.methods.createERC20(l,[c,u],[r,n,o,i],[m.web3.utils.toWei(a),m.web3.utils.toWei(s)],[]),f=h.send;return Promise.resolve(j(m.web3,m.config)).then(function(r){return Promise.resolve(f.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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.addManager,r))}catch(e){return Promise.reject(e)}},t.addManager=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(A(t,o.methods.addManager,r)).then(function(e){var i=o.methods.addManager(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.removeManager,r))}catch(e){return Promise.reject(e)}},t.removeManager=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(A(t,o.methods.removeManager,r)).then(function(e){var i=o.methods.removeManager(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.addToCreateERC20List,r))}catch(e){return Promise.reject(e)}},t.addErc20Deployer=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(A(t,o.methods.addToCreateERC20List,r)).then(function(e){var i=o.methods.addToCreateERC20List(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.removeFromCreateERC20List,r))}catch(e){return Promise.reject(e)}},t.removeErc20Deployer=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(e){if(a||t===r&&!0!==e.deployERC20)throw new Error("Caller is not Manager nor ERC20Deployer");return Promise.resolve(A(t,o.methods.removeFromCreateERC20List,r)).then(function(e){var i=o.methods.removeFromCreateERC20List(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.addToMetadataList,r))}catch(e){return Promise.reject(e)}},t.addMetadataUpdater=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(A(t,o.methods.addToMetadataList,r)).then(function(e){var i=o.methods.addToMetadataList(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.removeFromMetadataList,r))}catch(e){return Promise.reject(e)}},t.removeMetadataUpdater=function(e,t,r){try{var n=this,o=F(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(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.addTo725StoreList,r))}catch(e){return Promise.reject(e)}},t.addStoreUpdater=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(A(t,o.methods.addTo725StoreList,r)).then(function(e){var i=o.methods.addTo725StoreList(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.removeFrom725StoreList,r))}catch(e){return Promise.reject(e)}},t.removeStoreUpdater=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(i){function s(e){if(a||t!==r&&!0!==e.store)throw new Error("Caller is not Manager nor storeUpdater");return Promise.resolve(A(t,o.methods.removeFrom725StoreList,r)).then(function(e){var i=o.methods.removeFrom725StoreList(r),s=i.send;return Promise.resolve(j(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=this,o=r||F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(A(t,o.methods.cleanPermissions))}catch(e){return Promise.reject(e)}},t.cleanPermissions=function(e,t){try{var r=this,n=F(new r.web3.eth.Contract(r.nftAbi,e),r.config);return Promise.resolve(r.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(A(t,n.methods.cleanPermissions)).then(function(e){var o=n.methods.cleanPermissions(),i=o.send;return Promise.resolve(j(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=this,s=o||F(new i.web3.eth.Contract(i.nftAbi,e),i.config);return Promise.resolve(A(t,s.methods.transferFrom,t,r,n))}catch(e){return Promise.reject(e)}},t.transferNft=function(e,t,r,n){try{var o=this,i=F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var s=n||1;return Promise.resolve(A(t,i.methods.transferFrom,t,r,s)).then(function(e){var n=i.methods.transferFrom(t,r,s),a=n.send;return Promise.resolve(j(o.web3,o.config)).then(function(r){return Promise.resolve(a.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=this,s=o||F(new i.web3.eth.Contract(i.nftAbi,e),i.config);return Promise.resolve(A(t,s.methods.safeTransferFrom,t,r,n))}catch(e){return Promise.reject(e)}},t.safeTransferNft=function(e,t,r,n){try{var o=this,i=F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var s=n||1;return Promise.resolve(A(t,i.methods.safeTransferFrom,t,r,s)).then(function(e){var n=i.methods.safeTransferFrom(t,r,s),a=n.send;return Promise.resolve(j(o.web3,o.config)).then(function(r){return Promise.resolve(a.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=this,m=u||F(new l.web3.eth.Contract(l.nftAbi,e),l.config);return c||(c=[]),Promise.resolve(A(t,m.methods.setMetaData,r,n,o,i,s,a,c))}catch(e){return Promise.reject(e)}},t.setMetadata=function(e,t,r,n,o,i,s,a,c){try{var u=this,l=F(new u.web3.eth.Contract(u.nftAbi,e),u.config);return c||(c=[]),Promise.resolve(u.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(A(t,l.methods.setMetaData,r,n,o,i,s,a,c)).then(function(e){var m=l.methods.setMetaData(r,n,o,i,s,a,c),h=m.send;return Promise.resolve(j(u.web3,u.config)).then(function(r){return Promise.resolve(h.call(m,{from:t,gas:e+1,gasPrice:r}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadataAndTokenURI=function(e,t,r,n){try{var o=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config),s=G({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(A(t,i.methods.setMetaDataAndTokenURI,s))}catch(e){return Promise.reject(e)}},t.setMetadataAndTokenURI=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");var i=G({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(A(t,o.methods.setMetaDataAndTokenURI,i)).then(function(e){var r=o.methods.setMetaDataAndTokenURI(i),s=r.send;return Promise.resolve(j(n.web3,n.config)).then(function(n){return Promise.resolve(s.call(r,{from:t,gas:e+1,gasPrice:n}))})})})}catch(e){return Promise.reject(e)}},t.estGasSetMetadataState=function(e,t,r,n){try{var o=this,i=n||F(new o.web3.eth.Contract(o.nftAbi,e),o.config);return Promise.resolve(A(t,i.methods.setMetaDataState,r))}catch(e){return Promise.reject(e)}},t.setMetadataState=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(n.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(A(t,o.methods.setMetaDataState,r)).then(function(e){var i=o.methods.setMetaDataState(r),s=i.send;return Promise.resolve(j(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=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(A(t,o.methods.setTokenURI,"1",r))}catch(e){return Promise.reject(e)}},t.setTokenURI=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.nftAbi,e),n.config);return Promise.resolve(A(t,o.methods.setTokenURI,"1",r)).then(function(e){var i=o.methods.setTokenURI("1",r),s=i.send;return Promise.resolve(j(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=F(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=F(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=F(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=F(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=F(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=F(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 Te(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Ee=/*#__PURE__*/function(){function e(e,t,r,n,o){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=r||a.abi,this.datatokensEnterpriseAbi=n||h.abi,this.config=o||(new _).getConfig(t||"unknown"),this.nft=new ke(this.web3)}var t=e.prototype;return t.estGasApprove=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(A(n,s.methods.approve,t,i.web3.utils.toWei(r)))}catch(e){return Promise.reject(e)}},t.approve=function(e,t,r,n){try{var o=this,i=F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(n,i.methods.approve,t,o.web3.utils.toWei(r))).then(function(e){var s=i.methods.approve(t,o.web3.utils.toWei(r)),a=s.send;return Promise.resolve(j(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=this,s=o||F(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(A(t,s.methods.mint,n||t,i.web3.utils.toWei(r)))}catch(e){return Promise.reject(e)}},t.estGasCreateFixedRate=function(e,t,r,n){try{var o=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return r.allowedConsumer||(r.allowedConsumer=y),Promise.resolve(A(t,i.methods.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,t,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,r.withMint?1:0]))}catch(e){return Promise.reject(e)}},t.createFixedRate=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(e){if(!e)throw new Error("User is not ERC20 Deployer");r.allowedConsumer||(r.allowedConsumer=y);var i=r.withMint?1:0;return Promise.resolve(A(t,o.methods.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,i])).then(function(e){var s=o.methods.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,i]),a=s.send;return Promise.resolve(j(n.web3,n.config)).then(function(r){return Promise.resolve(a.call(s,{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||F(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return n.allowedSwapper||(n.allowedSwapper=y),n.withMint||(n.withMint=!1),Promise.resolve(A(t,s.methods.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper))}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=F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return n.allowedSwapper||(n.allowedSwapper=y),n.withMint||(n.withMint=!1),Promise.resolve(A(t,s.methods.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper)).then(function(e){var i=s.methods.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper),a=i.send;return Promise.resolve(j(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,s=F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(o.getDTPermissions(e,t)).then(function(a){if(!0!==a.minter)throw new Error("Caller is not Minter");return Promise.resolve(o.getCap(e)).then(function(e){if(new i(e).gte(r))return Promise.resolve(A(t,s.methods.mint,n||t,o.web3.utils.toWei(r))).then(function(e){var i=s.methods.mint(n||t,o.web3.utils.toWei(r)),a=i.send;return Promise.resolve(j(o.web3,o.config)).then(function(r){return Promise.resolve(a.call(i,{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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.addMinter,r))}catch(e){return Promise.reject(e)}},t.addMinter=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(A(t,o.methods.addMinter,r)).then(function(e){var i=o.methods.addMinter(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.removeMinter,r))}catch(e){return Promise.reject(e)}},t.removeMinter=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(A(t,o.methods.removeMinter,r)).then(function(e){var i=o.methods.removeMinter(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.addPaymentManager,r))}catch(e){return Promise.reject(e)}},t.addPaymentManager=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(A(t,o.methods.addPaymentManager,r)).then(function(e){var i=o.methods.addPaymentManager(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.removePaymentManager,r))}catch(e){return Promise.reject(e)}},t.removePaymentManager=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.isERC20Deployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not ERC20Deployer");return Promise.resolve(A(t,o.methods.removePaymentManager,r)).then(function(e){var i=o.methods.removePaymentManager(r),s=i.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.setPaymentCollector,r))}catch(e){return Promise.reject(e)}},t.setPaymentCollector=function(e,t,r){try{var n=this,o=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(n.getDTPermissions(e,t)).then(function(i){function s(e){function i(i){function s(e){if(!a&&!c&&!(null==e?void 0:e.deployERC20))throw new Error("Caller is not Fee Manager, owner or erc20 Deployer");return Promise.resolve(A(t,o.methods.setPaymentCollector,r)).then(function(e){var i=o.methods.setPaymentCollector(r),s=i.send;return Promise.resolve(j(n.web3,n.config)).then(function(r){return Promise.resolve(s.call(i,{from:t,gas:e+1,gasPrice:r}))})})}var c=e&&i===t;return e&&!c?Promise.resolve(e&&!c&&n.nft.getNftPermissions(e,t)).then(s):s(e&&!c&&n.nft.getNftPermissions(e,t))}return e?Promise.resolve(n.nft.getNftOwner(e)).then(i):i(e)}var a=i.paymentManager;return a?s(!a&&n.getNFTAddress(e)):Promise.resolve(!a&&n.getNFTAddress(e)).then(s)})}catch(e){return Promise.reject(e)}},t.getPaymentCollector=function(e){try{var t=this,r=F(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=this,s=o||F(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(A(n,s.methods.transfer,t,r))}catch(e){return Promise.reject(e)}},t.transferWei=function(e,t,r,n){try{var o=this,i=F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(Te(function(){return Promise.resolve(A(n,i.methods.transfer,t,r)).then(function(e){var s=i.methods.transfer(t,r),a=s.send;return Promise.resolve(j(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,s){try{var a=this,c=s||F(new a.web3.eth.Contract(a.datatokensAbi,e),a.config);return Promise.resolve(A(t,c.methods.startOrder,r,n,o,i))}catch(e){return Promise.reject(e)}},t.startOrder=function(e,t,r,n,o,i){try{var s=this,a=F(new s.web3.eth.Contract(s.datatokensAbi,e),s.config);return i||(i={consumeMarketFeeAddress:y,consumeMarketFeeToken:y,consumeMarketFeeAmount:"0"}),Promise.resolve(Te(function(){return Promise.resolve(A(t,a.methods.startOrder,r,n,o,i)).then(function(e){var c=a.methods.startOrder(r,n,o,i),u=c.send;return Promise.resolve(j(s.web3,s.config)).then(function(r){return Promise.resolve(u.call(c,{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.estGasReuseOrder=function(e,t,r,n,o){try{var i=this,s=o||F(new i.web3.eth.Contract(i.datatokensAbi,e),i.config);return Promise.resolve(A(t,s.methods.reuseOrder,r,n))}catch(e){return Promise.reject(e)}},t.reuseOrder=function(e,t,r,n){try{var o=this,i=F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(Te(function(){return Promise.resolve(A(t,i.methods.reuseOrder,r,n)).then(function(e){var s=i.methods.reuseOrder(r,n),a=s.send;return Promise.resolve(j(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 call reuse order 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=o||new this.web3.eth.Contract(this.datatokensEnterpriseAbi,e);return Promise.resolve(A(t,i.methods.buyFromFreAndOrder,r,n))}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(Te(function(){var e=O(n);return Promise.resolve(A(t,i.methods.buyFromFreAndOrder,r,e)).then(function(n){var s=i.methods.buyFromFreAndOrder(r,e),a=s.send;return Promise.resolve(j(o.web3,o.config)).then(function(e){return Promise.resolve(a.call(s,{from:t,gas:n+1,gasPrice:e}))})})},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=o||new this.web3.eth.Contract(this.datatokensEnterpriseAbi,e);return Promise.resolve(A(t,i.methods.buyFromDispenserAndOrder,r,n))}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(Te(function(){return Promise.resolve(A(t,i.methods.buyFromDispenserAndOrder,r,n)).then(function(e){var s=i.methods.buyFromDispenserAndOrder(r,n),a=s.send;return Promise.resolve(j(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=this,i=n||F(new o.web3.eth.Contract(o.datatokensAbi,e),o.config);return Promise.resolve(A(t,i.methods.setData,r))}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=F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(A(t,i.methods.setData,r)).then(function(e){var o=i.methods.setData(r),s=o.send;return Promise.resolve(j(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=this,o=r||F(new n.web3.eth.Contract(n.datatokensAbi,e),n.config);return Promise.resolve(A(t,o.methods.cleanPermissions))}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=F(new r.web3.eth.Contract(r.datatokensAbi,e),r.config);return Promise.resolve(A(t,o.methods.cleanPermissions)).then(function(e){var n=o.methods.cleanPermissions(),i=n.send;return Promise.resolve(j(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=F(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=F(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=F(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=F(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=F(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)}},t.estGasSetPublishingMarketFee=function(e,t,r,n,o){try{var i=new this.web3.eth.Contract(this.datatokensAbi,e,{from:o});return Promise.resolve(A(o,i.methods.setPublishingMarketFee,t,r,n))}catch(e){return Promise.reject(e)}},t.setPublishingMarketFee=function(e,t,r,n,o){try{var i=this,s=new i.web3.eth.Contract(i.datatokensAbi,e,{from:o});return Promise.resolve(s.methods.getPublishingMarketFee().call()).then(function(a){if(a[0]!==o)throw new Error("Caller is not the Publishing Market Fee Address");return Promise.resolve(i.estGasSetPublishingMarketFee(e,t,r,n,o)).then(function(e){var a=s.methods.setPublishingMarketFee(t,r,n),c=a.send;return Promise.resolve(j(i.web3,i.config)).then(function(t){return Promise.resolve(c.call(a,{from:o,gas:e+1,gasPrice:t})).then(function(){})})})})}catch(e){return Promise.reject(e)}},t.getPublishingMarketFee=function(e,t){try{var r=new this.web3.eth.Contract(this.datatokensAbi,e,{from:t});return Promise.resolve(r.methods.getPublishingMarketFee().call()).then(function(e){return{publishMarketFeeAddress:e[0],publishMarketFeeToken:e[1],publishMarketFeeAmount:e[2]}})}catch(e){return Promise.reject(e)}},e}(),je=/*#__PURE__*/function(){function t(e,t,r,n,o){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=n||d.abi,this.web3=t,this.config=o||(new _).getConfig(r||"unknown"),this.factory721=F(new this.web3.eth.Contract(this.factory721Abi,this.factory721Address),this.config)}var r=t.prototype;return r.estGasCreateNFT=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.deployERC721Contract,t.name,t.symbol,t.templateIndex,y,y,t.tokenURI,t.transferable,t.owner))}catch(e){return Promise.reject(e)}},r.createNFT=function(e,t){try{var r=this;if(t.templateIndex||(t.templateIndex=1),!t.name||!t.symbol){var n=w(),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(A(e,r.factory721.methods.deployERC721Contract,t.name,t.symbol,t.templateIndex,y,y,t.tokenURI,t.transferable,t.owner)).then(function(n){var o=r.factory721.methods.deployERC721Contract(t.name,t.symbol,t.templateIndex,y,y,t.tokenURI,t.transferable,t.owner),i=o.send;return Promise.resolve(j(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)}},r.getCurrentNFTCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTCount().call())}catch(e){return Promise.reject(e)}},r.getCurrentTokenCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTokenCount().call())}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.factory721.methods.owner().call())}catch(e){return Promise.reject(e)}},r.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentNFTTemplateCount().call())}catch(e){return Promise.reject(e)}},r.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.factory721.methods.getCurrentTemplateCount().call())}catch(e){return Promise.reject(e)}},r.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)}},r.getTokenTemplate=function(e){try{return Promise.resolve(this.factory721.methods.getTokenTemplate(e).call())}catch(e){return Promise.reject(e)}},r.checkDatatoken=function(e){try{return Promise.resolve(this.factory721.methods.erc20List(e).call())}catch(e){return Promise.reject(e)}},r.checkNFT=function(e){try{return Promise.resolve(this.factory721.methods.erc721List(e).call())}catch(e){return Promise.reject(e)}},r.estGasAddNFTTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.add721TokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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===y)throw new Error("Template cannot be ZERO address");return Promise.resolve(A(e,r.factory721.methods.add721TokenTemplate,t)).then(function(n){var o=r.factory721.methods.add721TokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasDisableNFTTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.disable721TokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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(A(e,r.factory721.methods.disable721TokenTemplate,t)).then(function(n){var o=r.factory721.methods.disable721TokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasReactivateNFTTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.reactivate721TokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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(A(e,r.factory721.methods.reactivate721TokenTemplate,t)).then(function(n){var o=r.factory721.methods.reactivate721TokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasAddTokenTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.addTokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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===y)throw new Error("Template cannot be address ZERO");return Promise.resolve(A(e,r.factory721.methods.addTokenTemplate,t)).then(function(n){var o=r.factory721.methods.addTokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasDisableTokenTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.disableTokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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.getCurrentTokenTemplateCount()).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(!1===n.isActive)throw new Error("Template is already disabled");return Promise.resolve(A(e,r.factory721.methods.disableTokenTemplate,t)).then(function(n){var o=r.factory721.methods.disableTokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasReactivateTokenTemplate=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.reactivateTokenTemplate,t))}catch(e){return Promise.reject(e)}},r.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.getCurrentTokenTemplateCount()).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(A(e,r.factory721.methods.reactivateTokenTemplate,t)).then(function(n){var o=r.factory721.methods.reactivateTokenTemplate(t),i=o.send;return Promise.resolve(j(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)}},r.estGasStartMultipleTokenOrder=function(e,t){try{return Promise.resolve(A(e,this.factory721.methods.startMultipleTokenOrder,t))}catch(e){return Promise.reject(e)}},r.startMultipleTokenOrder=function(e,t){try{var r=this;if(t.length>50)throw new Error("Too many orders");return Promise.resolve(A(e,r.factory721.methods.startMultipleTokenOrder,t)).then(function(n){var o=r.factory721.methods.startMultipleTokenOrder(t),i=o.send;return Promise.resolve(j(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)}},r.estGasCreateNftWithErc20=function(e,t,r){try{var n=x(r);return Promise.resolve(A(e,this.factory721.methods.createNftWithErc20,t,n))}catch(e){return Promise.reject(e)}},r.createNftWithErc20=function(e,t,r){try{var n=this,o=x(r);return Promise.resolve(A(e,n.factory721.methods.createNftWithErc20,t,o)).then(function(r){var i=n.factory721.methods.createNftWithErc20(t,o),s=i.send;return Promise.resolve(j(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)}},r.estGasCreateNftErc20WithPool=function(e,t,r,n){try{var o=this,i=x(r);return Promise.resolve(E(o.web3,n)).then(function(r){return A(e,o.factory721.methods.createNftWithErc20WithPool,t,i,r)})}catch(e){return Promise.reject(e)}},r.createNftErc20WithPool=function(e,t,r,n){try{var o=this,i=x(r);return Promise.resolve(E(o.web3,n)).then(function(r){return Promise.resolve(A(e,o.factory721.methods.createNftWithErc20WithPool,t,i,r)).then(function(n){var s=o.factory721.methods.createNftWithErc20WithPool(t,i,r),a=s.send;return Promise.resolve(j(o.web3,o.config)).then(function(t){return Promise.resolve(a.call(s,{from:e,gas:n+1,gasPrice:t}))})})})}catch(e){return Promise.reject(e)}},r.estGasCreateNftErc20WithFixedRate=function(e,t,r,n){try{var o=this,i=x(r);return Promise.resolve(S(n)).then(function(r){return A(e,o.factory721.methods.createNftWithErc20WithFixedRate,t,i,r)})}catch(e){return Promise.reject(e)}},r.createNftErc20WithFixedRate=function(e,t,r,n){try{var o=this,i=x(r),s=S(n);return Promise.resolve(A(e,o.factory721.methods.createNftWithErc20WithFixedRate,t,i,s)).then(function(r){var n=o.factory721.methods.createNftWithErc20WithFixedRate(t,i,s),a=n.send;return Promise.resolve(j(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)}},r.estGasCreateNftErc20WithDispenser=function(e,t,r,n){try{var o=x(r);return Promise.resolve(A(e,this.factory721.methods.createNftWithErc20WithDispenser,t,o,n))}catch(e){return Promise.reject(e)}},r.createNftErc20WithDispenser=function(t,r,n,o){try{var i=this,s=x(n);return o.maxBalance=e.utils.toWei(o.maxBalance),o.maxTokens=e.utils.toWei(o.maxTokens),Promise.resolve(A(t,i.factory721.methods.createNftWithErc20WithDispenser,r,s,o)).then(function(e){var n=i.factory721.methods.createNftWithErc20WithDispenser(r,s,o),a=n.send;return Promise.resolve(j(i.web3,i.config)).then(function(r){return Promise.resolve(a.call(n,{from:t,gas:e+1,gasPrice:r}))})})}catch(e){return Promise.reject(e)}},t}(),Fe=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},xe=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 Oe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Se=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getEndpoints=function(e){try{return Promise.resolve(Oe(function(){return Promise.resolve(U(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,n,o,i){try{var s=function(){function s(){var e=a.getEndpointURL(i,"nonce")?a.getEndpointURL(i,"nonce").urlPath:null;return e?Oe(function(){return Promise.resolve(r(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:n})).then(function(e){return Promise.resolve(e.json()).then(function(e){return e.nonce.toString()})})},function(e){throw g.error(e),new Error("HTTP request failed")}):null}var c=function(){if(!i)return Promise.resolve(a.getServiceEndpoints(e,o)).then(function(e){i=e})}();return c&&c.then?c.then(s):s()},a=this,c=function(){if(!o)return Promise.resolve(a.getEndpoints(e)).then(function(e){o=e})}();return Promise.resolve(c&&c.then?c.then(s):s())}catch(e){return Promise.reject(e)}},t.signProviderRequest=function(e,t,r,n){try{var o=e.utils.soliditySha3({t:"bytes",v:e.utils.utf8ToHex(r)});return Promise.resolve(e&&e.currentProvider&&e.currentProvider.isMetaMask?e.eth.personal.sign(o,t,n):e.eth.sign(o,t))}catch(e){return Promise.reject(e)}},t.encrypt=function(e,t,n){try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){var i=o.getEndpointURL(t,"encrypt")?o.getEndpointURL(t,"encrypt").urlPath:null;return i?Oe(function(){return Promise.resolve(r(i,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:n})).then(function(e){return Promise.resolve(e.text())})},function(e){throw g.error(e),new Error("HTTP request failed")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(n)).then(function(s){return Promise.resolve(i.getServiceEndpoints(n,s)).then(function(n){var s={did:e,serviceId:t},a=[],c=i.getEndpointURL(n,"fileinfo")?i.getEndpointURL(n,"fileinfo").urlPath:null;return c?Oe(function(){return Promise.resolve(r(c,{method:"POST",body:JSON.stringify(s),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){return Promise.resolve(e.json()).then(function(e){for(var t,r=L(e);!(t=r()).done;)a.push(t.value);return a})})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.checkFileUrl=function(e,t,n){try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){var i={url:e,type:"url"},s=[],a=o.getEndpointURL(t,"fileinfo")?o.getEndpointURL(t,"fileinfo").urlPath:null;return a?Oe(function(){return Promise.resolve(r(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=L(e);!(t=r()).done;)s.push(t.value);return s})})},function(){return null}):null})})}catch(e){return Promise.reject(e)}},t.getComputeEnvironments=function(e,t){try{var n=this;return Promise.resolve(n.getEndpoints(e)).then(function(o){return Promise.resolve(n.getServiceEndpoints(e,o)).then(function(e){var o,i=null==(o=n.getEndpointURL(e,"computeEnvironments"))?void 0:o.urlPath;return i?Oe(function(){return Promise.resolve(r(i,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){return Promise.resolve(e.json())})},function(e){return g.error(e.message),null}):null})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,n,o,i,s,a,c,u){try{var l=this;return Promise.resolve(l.getEndpoints(i)).then(function(m){return Promise.resolve(l.getServiceEndpoints(i,m)).then(function(i){var m=l.getEndpointURL(i,"initialize")?l.getEndpointURL(i,"initialize").urlPath:null;return m?(m+="?documentId="+e,m+="&serviceId="+t,m+="&fileIndex="+n,m+="&consumerAddress="+o,a&&(m+="&userdata="+encodeURI(JSON.stringify(a))),c&&(m+="&environment="+encodeURI(c)),u&&(m+="&validUntil="+u),Oe(function(){return Promise.resolve(r(m,{method:"GET",headers:{"Content-Type":"application/json"},signal:s})).then(function(e){return 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.initializeCompute=function(e,t,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={datasets:e,algorithm:t,compute:{env:n,validUntil:o},consumerAddress:s},l=c.getEndpointURL(i,"initializeCompute")?c.getEndpointURL(i,"initializeCompute").urlPath:null;return l?Oe(function(){return Promise.resolve(r(l,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){return Promise.resolve(e.json())})},function(e){throw g.error(e),new Error("ComputeJob cannot be initialized")}):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.signProviderRequest(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,n,o,i,s,a,c,u){try{var l=this;return Promise.resolve(l.getEndpoints(e)).then(function(m){return Promise.resolve(l.getServiceEndpoints(e,m)).then(function(e){var m=l.getEndpointURL(e,"computeStart")?l.getEndpointURL(e,"computeStart").urlPath:null,h=Date.now(),f=n;return f+=i.documentId,f+=h,Promise.resolve(l.signProviderRequest(t,n,f)).then(function(e){var t=Object();return t.consumerAddress=n,t.signature=e,t.nonce=h,t.environment=o,t.dataset=i,t.algorithm=s,t.additionalDatasets&&(t.additionalDatasets=c),u&&(t.output=u),m?Oe(function(){return Promise.resolve(r(m,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){var r;function n(n){return r?n:(g.error("Compute start failed: ",e.status,e.statusText),g.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 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,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,"computeStop")?a.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(a.getNonce(o,t,s,c,u)).then(function(o){var c=t;return c+=n||"",c+=e&&""+xe(e)||"",c+=o,Promise.resolve(a.signProviderRequest(i,t,c)).then(function(o){var i=Object();return i.signature=o,i.documentId=xe(e),i.consumerAddress=t,n&&(i.jobId=n),l?Oe(function(){return Promise.resolve(r(l,{method:"PUT",body:JSON.stringify(i),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){var t;function r(r){return t?r:(g.error("Compute stop failed:",e.status,e.statusText),g.error("Payload was:",i),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 g.error("Compute stop failed:"),g.error(e),g.error("Payload was:",i),null}):null})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(e)).then(function(a){return Promise.resolve(s.getServiceEndpoints(e,a)).then(function(e){var a=s.getEndpointURL(e,"computeStatus")?s.getEndpointURL(e,"computeStatus").urlPath:null,c="?consumerAddress="+t;return c+=o&&"&documentId="+xe(o)||"",c+=n&&"&jobId="+n||"",a?Oe(function(){return Promise.resolve(r(a+c,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).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)return Promise.resolve(e.json()).then(function(e){return t=1,e})}();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.getComputeResultUrl=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(e)).then(function(s){return Promise.resolve(i.getServiceEndpoints(e,s)).then(function(e){var s=i.getEndpointURL(e,"computeResult")?i.getEndpointURL(e,"computeResult").urlPath:null,a=Date.now(),c=r;return c+=n,c+=o.toString(),c+=a,Promise.resolve(i.signProviderRequest(t,r,c)).then(function(e){if(!s)return null;var t=s;return t+="?consumerAddress="+r,t+="&jobId="+n,t+="&index="+o.toString(),(t+="&nonce="+a)+(e&&"&signature="+e||"")})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,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,"computeDelete")?a.getEndpointURL(u,"computeDelete").urlPath:null;return Promise.resolve(a.getNonce(o,t,s,c,u)).then(function(o){var c=t;return c+=n||"",c+=e&&""+xe(e)||"",c+=o,Promise.resolve(a.signProviderRequest(i,t,c)).then(function(o){var i=Object();return i.documentId=xe(e),i.consumerAddress=t,i.jobId=n,o&&(i.signature=o),l?Oe(function(){return Promise.resolve(r(l,{method:"DELETE",body:JSON.stringify(i),headers:{"Content-Type":"application/json"},signal:s})).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:",i),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 g.error("Delete compute job failed:"),g.error(e),g.error("Payload was:",i),null}):null})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(Oe(function(){return Promise.resolve(r(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 g.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},e}(),Me=new Se;export{fe as Aquarius,Fe as Config,_ as ConfigHelper,Ee as Datatoken,we as Dispenser,pe as FixedRateCreateProgressStep,ye as FixedRateExchange,C as GASLIMIT_DEFAULT,v as LogLevel,P as Logger,g as LoggerInstance,ke as Nft,je as NftFactory,Pe as Pool,Se as Provider,Me as ProviderInstance,Ae as Router,Re as SideStaking,y as ZERO_ADDRESS,K as allowance,k as amountToUnits,ee as approve,Q as balance,ce as calcMaxExactIn,ae as calcMaxExactOut,z as configHelperNetworks,X as decimals,I as downloadFile,W as downloadFileBrowser,te as estApprove,Y as estTransfer,A as estimateGas,N as fetchData,J as generateDid,w as generateDtName,U as getData,x as getErcCreationParams,j as getFairGasPrice,S as getFreCreationParams,O as getFreOrderParams,V as getHash,oe as getMaxAddLiquidity,ne as getMaxRemoveLiquidity,ie as getMaxSwapExactIn,se as getMaxSwapExactOut,E as getPoolCreationParams,M as postData,F as setContractDefaults,H as signHash,re as sleep,$ as transfer,T as unitsToAmount};
2
2
  //# sourceMappingURL=lib.module.js.map