@oceanprotocol/lib 4.3.4 → 4.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@oceanprotocol/contracts/addresses/address.json"),require("fs"),require("ethers"),require("@oasisprotocol/sapphire-paratime"),require("decimal.js"),require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),require("@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json"),require("@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json"),require("@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json"),require("@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json"),require("@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json"),require("@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json"),require("@oceanprotocol/contracts/artifacts/contracts/escrow/Escrow.sol/Escrow.json"),require("cross-fetch"),require("@oceanprotocol/ddo-js"),require("jsonwebtoken"),require("crypto-js/sha256.js"),require("ethers/lib/utils.js"),require("crypto")):"function"==typeof define&&define.amd?define(["exports","@oceanprotocol/contracts/addresses/address.json","fs","ethers","@oasisprotocol/sapphire-paratime","decimal.js","@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json","@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json","@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json","@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json","@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json","@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json","@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json","@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json","@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json","@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json","@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json","@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json","@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json","@oceanprotocol/contracts/artifacts/contracts/escrow/Escrow.sol/Escrow.json","cross-fetch","@oceanprotocol/ddo-js","jsonwebtoken","crypto-js/sha256.js","ethers/lib/utils.js","crypto"],t):t((e||self).lib={},e.DefaultContractsAddresses,e.fs,e.ethers,e.sapphire,e.Decimal,e.DispenserAbi,e.FixedRateExchangeAbi,e.FactoryRouter,e.ERC20Template$1,e.ERC20TemplateEnterprise,e.ERC721Template,e.ERC721Factory,e.ERC20Template,e.ERC20Template4,e.AccessList,e.AccessListFactory,e.veOceanABI,e.veFeeABI,e.veFeeEstimate,e.veAllocateABI,e.dfRewardsABI,e.dfStrategyV1ABI,e.Escrow,e.crossFetch,e.ddoJs,e.jsonwebtoken,e.sha256,e.utils_js,e.crypto)}(this,function(e,t,r,n,o,i,s,a,c,u,l,d,h,f,m,v,g,p,P,y,w,k,b,T,A,S,E,F,j,C){function D(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function x(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var M,O,R,N=/*#__PURE__*/D(t),U=/*#__PURE__*/D(r),I=/*#__PURE__*/x(o),L=/*#__PURE__*/D(i),G=/*#__PURE__*/D(s),_=/*#__PURE__*/D(a),B=/*#__PURE__*/D(c),q=/*#__PURE__*/D(u),z=/*#__PURE__*/D(l),J=/*#__PURE__*/D(d),W=/*#__PURE__*/D(h),V=/*#__PURE__*/D(f),H=/*#__PURE__*/D(m),Z=/*#__PURE__*/D(v),X=/*#__PURE__*/D(g),K=/*#__PURE__*/D(p),$=/*#__PURE__*/D(P),Y=/*#__PURE__*/D(y),Q=/*#__PURE__*/D(w),ee=/*#__PURE__*/D(k),te=/*#__PURE__*/D(b),re=/*#__PURE__*/D(T),ne=/*#__PURE__*/D(A),oe=/*#__PURE__*/D(E),ie=/*#__PURE__*/D(F);function se(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ae(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 se(e,t);var r={}.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)?se(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.")}function ce(){return ce=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ce.apply(null,arguments)}function ue(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,le(e,t)}function le(e,t){return le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},le(e,t)}e.FileObjectType=void 0,(M=e.FileObjectType||(e.FileObjectType={})).URL="url",M.IPFS="ipfs",M.ARWEAVE="arweave",e.EncryptMethod=void 0,(O=e.EncryptMethod||(e.EncryptMethod={})).AES="AES",O.ECIES="ECIES",e.LogLevel=void 0,(R=e.LogLevel||(e.LogLevel={}))[R.None=-1]="None",R[R.Error=0]="Error",R[R.Warn=1]="Warn",R[R.Log=2]="Log",R[R.Verbose=3]="Verbose";var de=/*#__PURE__*/function(){function t(t){this.logLevel=void 0,this.logLevel=t,this.logLevel=t||e.LogLevel.Error}var r=t.prototype;return r.setLevel=function(e){this.logLevel=e},r.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},r.debug=function(){this.dispatch.apply(this,["debug",e.LogLevel.Verbose].concat([].slice.call(arguments)))},r.log=function(){this.dispatch.apply(this,["log",e.LogLevel.Log].concat([].slice.call(arguments)))},r.warn=function(){this.dispatch.apply(this,["warn",e.LogLevel.Warn].concat([].slice.call(arguments)))},r.error=function(){this.dispatch.apply(this,["error",e.LogLevel.Error].concat([].slice.call(arguments)))},r.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},t}(),he=new de,fe={chainId:null,network:"unknown",nodeUri:"http://127.0.0.1:8545",oceanNodeUri:"https://1.c2d.nodes.oceanprotocol.com:8000/",explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},me=[ce({},fe),ce({},fe,{chainId:8996,network:"development",oceanNodeUri:"https://1.c2d.nodes.oceanprotocol.com:8000/",sdk:"evm"}),ce({},fe,{chainId:11155111,network:"sepolia",nodeUri:"https://sepolia.infura.io/v3",explorerUri:"https://sepolia.etherscan.io",gasFeeMultiplier:1.1,sdk:"evm"}),ce({},fe,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05,sdk:"evm"}),ce({},fe,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",gasFeeMultiplier:1.6,sdk:"evm"}),ce({},fe,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com",sdk:"evm"}),ce({},fe,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",explorerUri:"https://mumbai.polygonscan.com",gasFeeMultiplier:1.1,sdk:"evm"}),ce({},fe,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05,sdk:"evm"}),ce({},fe,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05,sdk:"evm"}),ce({},fe,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",explorerUri:"https://moonriver.moonscan.io/",gasFeeMultiplier:1.05,sdk:"evm"}),ce({},fe,{chainId:100,network:"gen-x-testnet",nodeUri:"https://rpc.genx.minimal-gaia-x.eu",explorerUri:"https://explorer.genx.minimal-gaia-x.eu/",gasFeeMultiplier:1,sdk:"evm"}),ce({},fe,{chainId:10,network:"optimism",nodeUri:"https://mainnet.optimism.io",explorerUri:"https://optimistic.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),ce({},fe,{chainId:11155420,network:"optimism_sepolia",nodeUri:"https://sepolia.optimism.io",explorerUri:"https://sepolia-optimism.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),ce({},fe,{chainId:23294,network:"oasis_sapphire",nodeUri:"https://sapphire.oasis.io",explorerUri:"https://explorer.oasis.io/mainnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),ce({},fe,{chainId:23295,network:"oasis_sapphire_testnet",nodeUri:"https://testnet.sapphire.oasis.dev",explorerUri:"https://explorer.oasis.io/testnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),ce({},fe,{chainId:32456,network:"pontus-x-devnet",nodeUri:"https://rpc.dev.pontus-x.eu",explorerUri:"https://explorer.dev.pontus-x.eu/testnet/pontusx",sdk:"evm"})],ve=[23294,23295],ge=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r,n=function(){return process.env.NODE_URL?{oceanNodeUri:process.env.NODE_URL}:{}};if(t&&t[e]){var o=t[e];r=ce({nftFactoryAddress:o.ERC721Factory,opfCommunityFeeCollector:o.OPFCommunityFeeCollector,fixedRateExchangeAddress:o.FixedPrice,dispenserAddress:o.Dispenser,oceanTokenAddress:o.Ocean,routerFactoryAddress:o.Router,chainId:o.chainId,startBlock:o.startBlock,veAllocate:o.veAllocate,veOCEAN:o.veOCEAN,veDelegation:o.veDelegation,veFeeDistributor:o.veFeeDistributor,veDelegationProxy:o.veDelegationProxy,DFRewards:o.DFRewards,DFStrategyV1:o.DFStrategyV1,veFeeEstimate:o.veFeeEstimate,accessListFactory:o.AccessListFactory,EnterpriseFeeCollector:o.EnterpriseFeeCollector},n())}else if(N.default[e]){var i=N.default[e];r=ce({nftFactoryAddress:i.ERC721Factory,opfCommunityFeeCollector:i.OPFCommunityFeeCollector,fixedRateExchangeAddress:i.FixedPrice,dispenserAddress:i.Dispenser,oceanTokenAddress:i.Ocean,routerFactoryAddress:i.Router,chainId:i.chainId,startBlock:i.startBlock,veAllocate:i.veAllocate,veOCEAN:i.veOCEAN,veDelegation:i.veDelegation,veFeeDistributor:i.veFeeDistributor,veDelegationProxy:i.veDelegationProxy,DFRewards:i.DFRewards,DFStrategyV1:i.DFStrategyV1,veFeeEstimate:i.veFeeEstimate,accessListFactory:i.AccessListFactory,EnterpriseFeeCollector:i.EnterpriseFeeCollector},n())}return r},t.getConfig=function(e,t){var r,n="string"==typeof e?"network":"chainId",o=me.find(function(t){return t[n]===e});if(!o)return he.error("No config found for given network '"+e+"'"),null;try{r=process.env.ADDRESS_FILE?JSON.parse(U.default.readFileSync(process.env.ADDRESS_FILE,"utf8")):null}catch(e){console.log(e),r=null}var i=this.getAddressesFromEnv(o.network,r);return!i&&ve.includes(o.chainId)&&(i=this.getAddressesFromEnv(o.network.replace("sapph","saph"),r)),"sdk"in o&&null!==o.sdk||(o.sdk=ve.includes(o.chainId)?"oasis":"evm"),i&&"accessListFactory"in i&&(o.accessListFactory=i.accessListFactory),o=ce({},o,i),ce({},o,{nodeUri:t?o.nodeUri+"/"+t:o.nodeUri})},e}(),pe=[{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"}],Pe=function(e,t,r,n){try{var o=arguments;return Promise.resolve(t.provider.getNetwork()).then(function(i){var s=i.chainId;return Promise.resolve(t.provider.getFeeData()).then(function(t){var i={};if(t.maxPriorityFeePerGas){var a=t.maxPriorityFeePerGas.toString(),c=t.maxFeePerGas.toString();r>1&&(a=Math.round(t.maxPriorityFeePerGas.toNumber()*r).toString(),c=Math.round(t.maxFeePerGas.toNumber()*r).toString()),i={maxPriorityFeePerGas:(s===Fe||s===Ee)&&Number(a)<Te?Te:s===je&&Number(a)<Ae?Ae:ve.includes(s)&&Number(a)<Se?Se:Number(a),maxFeePerGas:(s===Fe||s===Ee)&&Number(c)<Te?Te:s===je&&Number(c)<Ae?Ae:ve.includes(s)&&Number(c)<Se?Se:Number(c)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),function(e,t){try{var r=Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i]))).then(function(e){return Promise.resolve(e.wait()).then(function(){return e})})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(e){return he.error("Send tx error: ",e),null})})})}catch(e){return Promise.reject(e)}},ye=function(e,t,r,o){try{var i=function(e){return"0"===e&&(e=18),n.ethers.utils.parseUnits(r,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(ke(e,t)).then(i))}catch(e){return Promise.reject(e)}},we=function(e,t,r,o){try{var i=function(e){return"0"===e&&(e=18),n.ethers.utils.formatUnits(r,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(ke(e,t)).then(i))}catch(e){return Promise.reject(e)}},ke=function(e,t){try{var r=new n.ethers.Contract(t,pe,e);return Promise.resolve(r.decimals())}catch(e){return Promise.reject(e)}},be=function(e,t){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var r=n.ethers.BigNumber.from(e.toString());return t?r.mul(t).toBigInt().toString(10):r.toString()})})}catch(e){return Promise.reject(e)}},Te=3e10,Ae=4e9,Se=1e10,Ee=137,Fe=80001,je=11155111;function Ce(e,t){return e}function De(e,t){var r;return null==e||null==(r=e.events)?void 0:r.filter(function(e){return e.event===t})[0]}var xe=/*#__PURE__*/function(){function e(e,t,r,n){this.signer=void 0,this.config=void 0,this.abi=void 0,this.signer=e,this.config=r||(new ge).getConfig(t),this.abi=n||this.getDefaultAbi()}var t=e.prototype;return t.getSignerAccordingSdk=function(){return this.config&&"sdk"in this.config&&"oasis"===this.config.sdk?I.wrap(this.signer):this.signer},t.amountToUnits=function(e,t,r){try{return Promise.resolve(ye(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t,r){try{return Promise.resolve(we(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.getFairGasPrice=function(){try{var e;return Promise.resolve(be(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},t.getContract=function(e,t){return Ce(new n.ethers.Contract(e,new n.ethers.utils.Interface(JSON.stringify(t||this.abi)),this.signer))},e}(),Me=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,r,n,o,i)||this).address=void 0,s.contract=void 0,s.address=t,s.contract=s.getContract(s.address),s}return ue(t,e),t}(xe),Oe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return G.default.abi},r.status=function(e){try{var t=this;return Promise.resolve(t.contract.status(e)).then(function(e){if(!e)throw new Error("Np dispenser found for the given datatoken address");var r=e.isMinter,n=e.owner,o=e.active;return Promise.resolve(t.unitsToAmount(null,e.maxTokens,18)).then(function(i){return Promise.resolve(t.unitsToAmount(null,e.maxBalance,18)).then(function(s){return Promise.resolve(t.unitsToAmount(null,e.balance,18)).then(function(t){return{active:o,owner:n,isMinter:r,maxTokens:i,maxBalance:s,balance:t,allowedSwapper:e.allowedSwapper}})})})})}catch(e){return Promise.reject(e)}},r.create=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.contract.estimateGas.create(e,s.amountToUnits(null,r,18),s.amountToUnits(null,n,18),t,o)).then(function(a){var c;return i?a:Promise.resolve(Pe(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.create,e,s.amountToUnits(null,r,18),s.amountToUnits(null,n,18),t,o))})}catch(e){return Promise.reject(e)}},r.activate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.activate(e,o.amountToUnits(null,t,18),o.amountToUnits(null,r,18))).then(function(i){var s;return n?i:Promise.resolve(Pe(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.activate,e,o.amountToUnits(null,t,18),o.amountToUnits(null,r,18)))})}catch(e){return Promise.reject(e)}},r.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.deactivate(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.deactivate,e))})}catch(e){return Promise.reject(e)}},r.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.setAllowedSwapper(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.setAllowedSwapper,e,t))})}catch(e){return Promise.reject(e)}},r.dispense=function(e,t,r,n){void 0===t&&(t="1");try{var o=this;return Promise.resolve(o.contract.estimateGas.dispense(e,o.amountToUnits(null,t,18),r)).then(function(i){var s;return n?i:Promise.resolve(Pe(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.dispense,e,o.amountToUnits(null,t,18),r))})}catch(e){return Promise.reject(e)}},r.ownerWithdraw=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.ownerWithdraw(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.ownerWithdraw,e))})}catch(e){return Promise.reject(e)}},r.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 L.default(e).greaterThanOrEqualTo(o.maxBalance)||new L.default(String(n)).greaterThan(o.maxTokens)||!new L.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(Me),Re="0x0000000000000000000000000000000000000000",Ne=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return _.default.abi},r.generateExchangeId=function(e,t){try{return Promise.resolve(this.contract.generateExchangeId(e,t))}catch(e){return Promise.reject(e)}},r.buyDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=Re),void 0===o&&(o="0");try{var s=this;return Promise.resolve(s.getExchange(e)).then(function(a){return Promise.resolve(s.amountToUnits(null,o,18)).then(function(o){return Promise.resolve(s.amountToUnits(a.datatoken,t,+a.dtDecimals)).then(function(t){return Promise.resolve(s.amountToUnits(a.baseToken,r,+a.btDecimals)).then(function(r){return Promise.resolve(s.contract.estimateGas.buyDT(e,t,r,n,o)).then(function(a){var c;return i?a:Promise.resolve(Pe(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.buyDT,e,t,r,n,o))})})})})})}catch(e){return Promise.reject(e)}},r.sellDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=Re),void 0===o&&(o="0");try{var s=this;return Promise.resolve(s.getExchange(e)).then(function(a){return Promise.resolve(s.amountToUnits(null,o,18)).then(function(o){return Promise.resolve(s.amountToUnits(a.datatoken,t,+a.dtDecimals)).then(function(t){return Promise.resolve(s.amountToUnits(a.baseToken,r,+a.btDecimals)).then(function(r){return Promise.resolve(s.contract.estimateGas.sellDT(e,t,r,n,o)).then(function(a){var c;return i?a:Promise.resolve(Pe(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.sellDT,e,t,r,n,o))})})})})})}catch(e){return Promise.reject(e)}},r.getNumberOfExchanges=function(){try{return Promise.resolve(this.contract.getNumberOfExchanges())}catch(e){return Promise.reject(e)}},r.setRate=function(e,t,r){try{var n=this,o=n.contract.estimateGas,i=o.setRate;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(s){return Promise.resolve(i.call(o,e,s)).then(function(o){var i;if(r)return o;var s=n.contract.setRate,a=null==(i=n.config)?void 0:i.gasFeeMultiplier,c=n.getSignerAccordingSdk();return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(Pe(o,c,a,s,e,t))})})})}catch(e){return Promise.reject(e)}},r.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.setAllowedSwapper(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.setAllowedSwapper,e,t))})}catch(e){return Promise.reject(e)}},r.activate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!0===n.active?null:Promise.resolve(r.contract.estimateGas.toggleExchangeState(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleExchangeState,e))}):null})}catch(e){return Promise.reject(e)}},r.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!1===n.active?null:Promise.resolve(r.contract.estimateGas.toggleExchangeState(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleExchangeState,e))}):null})}catch(e){return Promise.reject(e)}},r.getRate=function(e){try{var t=this;return Promise.resolve(t.contract.getRate(e)).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDatatokenSupply=function(e){try{var t=this;return Promise.resolve(t.contract.getDTSupply(e)).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)}},r.getBasetokenSupply=function(e){try{var t=this;return Promise.resolve(t.contract.getBTSupply(e)).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)}},r.getAllowedSwapper=function(e){try{return Promise.resolve(this.contract.getAllowedSwapper(e))}catch(e){return Promise.reject(e)}},r.calcBaseInGivenDatatokensOut=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.contract,s=i.calcBaseInGivenOutDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.amountToUnits(null,r,18)).then(function(r){return Promise.resolve(s.call(i,e,t,r)).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.publishMarketFeeAmount,+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)}},r.getAmountBasetokensOut=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.contract,s=i.calcBaseOutGivenInDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.amountToUnits(null,r,18)).then(function(r){return Promise.resolve(s.call(i,e,t,r)).then(function(e){return Promise.resolve(n.unitsToAmount(o.baseToken,e[0],+o.btDecimals))})})})})}catch(e){return Promise.reject(e)}},r.getExchange=function(e){try{var t=this;return Promise.resolve(t.contract.getExchange(e)).then(function(r){var n=r.btDecimals.toString(),o=r.dtDecimals.toString(),i=r.allowedSwapper,s=r.exchangeOwner,a=r.withMint,c=r.baseToken,u=r.datatoken,l=r.active;return Promise.resolve(t.unitsToAmount(r.datatoken,r.dtBalance,+r.dtDecimals)).then(function(d){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btBalance,+r.btDecimals)).then(function(h){return Promise.resolve(t.unitsToAmount(r.datatoken,r.dtSupply,+r.dtDecimals)).then(function(f){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(m){return Promise.resolve(t.unitsToAmount(null,r.fixedRate,18)).then(function(t){return{active:l,datatoken:u,baseToken:c,withMint:a,exchangeOwner:s,allowedSwapper:i,dtDecimals:o,btDecimals:n,dtBalance:d,btBalance:h,dtSupply:f,btSupply:m,fixedRate:t,exchangeId:e}})})})})})})}catch(e){return Promise.reject(e)}},r.getFeesInfo=function(e){try{var t=this;return Promise.resolve(t.contract.getFeesInfo(e)).then(function(r){return Promise.resolve(t.getExchange(e)).then(function(n){return Promise.resolve(t.unitsToAmount(null,r.opcFee.toString(),18)).then(function(o){return Promise.resolve(t.unitsToAmount(null,r.marketFee.toString(),18)).then(function(i){var s=r.marketFeeCollector;return Promise.resolve(t.unitsToAmount(n.baseToken,r.marketFeeAvailable,+n.btDecimals)).then(function(a){return Promise.resolve(t.unitsToAmount(n.baseToken,r.oceanFeeAvailable,+n.btDecimals)).then(function(t){return{opcFee:o,marketFee:i,marketFeeCollector:s,marketFeeAvailable:a,oceanFeeAvailable:t,exchangeId:e}})})})})})})}catch(e){return Promise.reject(e)}},r.getExchanges=function(){try{return Promise.resolve(this.contract.getExchanges())}catch(e){return Promise.reject(e)}},r.isActive=function(e){try{return Promise.resolve(this.contract.isActive(e))}catch(e){return Promise.reject(e)}},r.activateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!0===n.withMint?null:Promise.resolve(r.contract.estimateGas.toggleMintState(e,!0)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleMintState,e,!0))}):null})}catch(e){return Promise.reject(e)}},r.deactivateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!1===n.withMint?null:Promise.resolve(r.contract.estimateGas.toggleMintState(e,!1)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleMintState,e,!1))}):null})}catch(e){return Promise.reject(e)}},r.collectBasetokens=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){return o?Promise.resolve(n.contract.getExchange(e)).then(function(o){return Promise.resolve(n.amountToUnits(o.baseToken,t,+o.btDecimals)).then(function(t){return Promise.resolve(n.contract.estimateGas.collectBT(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.collectBT,e,t))})})}):null})}catch(e){return Promise.reject(e)}},r.collectDatatokens=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){return o?Promise.resolve(n.contract.getExchange(e)).then(function(o){return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.contract.estimateGas.collectDT(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.collectDT,e,t))})})}):null})}catch(e){return Promise.reject(e)}},r.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?Promise.resolve(r.contract.estimateGas.collectMarketFee(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.collectMarketFee,e))}):null})}catch(e){return Promise.reject(e)}},r.collectOceanFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?Promise.resolve(r.contract.estimateGas.collectOceanFee(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.collectOceanFee,e))}):null})}catch(e){return Promise.reject(e)}},r.getOPCCollector=function(){try{return Promise.resolve(this.contract.opcCollector())}catch(e){return Promise.reject(e)}},r.getRouter=function(){try{return Promise.resolve(this.contract.router())}catch(e){return Promise.reject(e)}},r.getExchangeOwner=function(e){try{return Promise.resolve(this.getExchange(e)).then(function(e){return Promise.resolve(e.exchangeOwner)})}catch(e){return Promise.reject(e)}},r.updateMarketFee=function(e,t,r){try{var n=this,o=n.contract.estimateGas,i=o.updateMarketFee;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(s){return Promise.resolve(i.call(o,e,s)).then(function(o){var i;if(r)return o;var s=n.contract.updateMarketFee,a=null==(i=n.config)?void 0:i.gasFeeMultiplier,c=n.getSignerAccordingSdk();return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(Pe(o,c,a,s,e,t))})})})}catch(e){return Promise.reject(e)}},r.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.updateMarketFeeCollector(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(Me),Ue=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return B.default.abi},r.buyDatatokenBatch=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.buyDTBatch(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.buyDTBatch,e))})}catch(e){return Promise.reject(e)}},r.isApprovedToken=function(e){try{return Promise.resolve(this.contract.isApprovedToken(e))}catch(e){return Promise.reject(e)}},r.isFixedPrice=function(e){try{return Promise.resolve(this.contract.isFixedRateContract(e))}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.routerOwner())}catch(e){return Promise.reject(e)}},r.getNFTFactory=function(){try{return Promise.resolve(this.contract.factory())}catch(e){return Promise.reject(e)}},r.addApprovedToken=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addApprovedToken(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addApprovedToken,t))})})}catch(e){return Promise.reject(e)}},r.removeApprovedToken=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeApprovedToken(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeApprovedToken,t))})})}catch(e){return Promise.reject(e)}},r.addFixedRateContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addFixedRateContract(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addFixedRateContract,t))})})}catch(e){return Promise.reject(e)}},r.removeFixedRateContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeFixedRateContract(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeFixedRateContract,t))})})}catch(e){return Promise.reject(e)}},r.addDispenserContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addDispenserContract(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addDispenserContract,t))})})}catch(e){return Promise.reject(e)}},r.removeDispenserContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeDispenserContract(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeDispenserContract,t))})})}catch(e){return Promise.reject(e)}},r.getOPCFee=function(e){try{return Promise.resolve(this.contract.getOPCFee(e))}catch(e){return Promise.reject(e)}},r.getCurrentOPCFee=function(){try{return Promise.resolve(this.contract.swapOceanFee())}catch(e){return Promise.reject(e)}},r.updateOPCFee=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getOwner()).then(function(a){if(a!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(s.contract.estimateGas.updateOPCFee(t,r,n,o)).then(function(e){var a;return i?e:Promise.resolve(Pe(e,s.getSignerAccordingSdk(),null==(a=s.config)?void 0:a.gasFeeMultiplier,s.contract.updateOPCFee,t,r,n,o))})})}catch(e){return Promise.reject(e)}},t}(Me),Ie={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 Le(e){var t=e||Ie,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}}function Ge(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var _e=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return W.default.abi},r.createNFT=function(e,t){try{var r=this;if(e.templateIndex||(e.templateIndex=1),!e.name||!e.symbol){var n=Le(),o=n.symbol;e.name=n.name,e.symbol=o}var i=e.templateIndex;return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(i>n)throw new Error("Template index doesnt exist");if(0===e.templateIndex)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(e.templateIndex)).then(function(n){if(!1===n.isActive)throw new Error("Template is not active");return Promise.resolve(r.contract.estimateGas.deployERC721Contract(e.name,e.symbol,e.templateIndex,Re,Re,e.tokenURI,e.transferable,e.owner)).then(function(n){return t?n:Ge(function(){var t;return Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(t=r.config)?void 0:t.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,Re,Re,e.tokenURI,e.transferable,e.owner)).then(function(e){if(!e){var t="Tx for deploying new NFT contract does not exist or status is not successful.";throw console.error(t),t}return Promise.resolve(e.wait()).then(function(e){return De(e,"NFTCreated").args[0]})})},function(e){console.error("Creation of NFT failed: "+e)})})})})}catch(e){return Promise.reject(e)}},r.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}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.contract.getNFTTemplate(e))})}catch(e){return Promise.reject(e)}},r.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},r.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},r.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},r.addNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Re)throw new Error("Template cannot be ZERO address");return Promise.resolve(n.contract.estimateGas.add721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.disable721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.reactivateNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.reactivate721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.addTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Re)throw new Error("Template cannot be address ZERO");return Promise.resolve(n.contract.estimateGas.addTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!1===e.isActive)throw new Error("Template is already disabled");return Promise.resolve(n.contract.estimateGas.disableTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.reactivateTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!0===e.isActive)throw new Error("Template is already active");return Promise.resolve(n.contract.estimateGas.reactivateTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.startMultipleTokenOrder=function(e,t){try{var r=this;if(e.length>50)throw new Error("Too many orders");return Promise.resolve(r.contract.estimateGas.startMultipleTokenOrder(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},r.createNftWithDatatoken=function(e,t,r){try{var n=this;return Promise.resolve(n.getErcCreationParams(t)).then(function(t){return Promise.resolve(n.contract.estimateGas.createNftWithErc20(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithFixedRate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.getFreCreationParams(r)).then(function(r){return Promise.resolve(o.contract.estimateGas.createNftWithErc20WithFixedRate(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(Pe(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.amountToUnits(null,r.maxBalance,18)).then(function(i){return r.maxBalance=i,Promise.resolve(o.amountToUnits(null,r.maxTokens,18)).then(function(i){return r.maxTokens=i,Promise.resolve(o.contract.estimateGas.createNftWithErc20WithDispenser(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(Pe(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},r.getErcCreationParams=function(e){try{var t,r,o=function(){var o=[e.minter,e.paymentCollector,e.mpFeeAddress,e.feeToken];e.filesObject&&(e.accessListFactory&&o.push(e.accessListFactory),e.allowAccessList&&o.push(e.allowAccessList),e.denyAccessList&&o.push(e.denyAccessList));var s=[e.name||t,e.symbol||r],c=e.templateIndex;return Promise.resolve(i.amountToUnits(null,e.cap,18)).then(function(t){return Promise.resolve(i.amountToUnits(null,e.feeAmount,a)).then(function(r){return{templateIndex:c,strings:s,addresses:o,uints:[t,r],bytess:e.filesObject?[n.ethers.utils.toUtf8Bytes(JSON.stringify(e.filesObject))]:[]}})})},i=this;if(!e.name||!e.symbol){var s=Le();t=s.name,r=s.symbol}var a=18,c=function(){if(e.feeToken!==Re){var t=Ge(function(){return Promise.resolve(ke(i.signer,e.feeToken)).then(function(e){a=e})},function(e){he.error("getTokenDecimals error",e)});if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}},r.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=Re);var r=!1===e.withMint?0:1,n=[e.baseTokenAddress,e.owner,e.marketFeeCollector,e.allowedConsumer],o=e.fixedRateAddress,i=e.datatokenDecimals,s=e.baseTokenDecimals;return Promise.resolve(t.amountToUnits(null,e.fixedRate,18)).then(function(a){return Promise.resolve(t.amountToUnits(null,e.marketFee,18)).then(function(e){return{fixedPriceAddress:o,addresses:n,uints:[s,i,a,e,r]}})})}catch(e){return Promise.reject(e)}},t}(Me);function Be(e,t,r){if(!e.s){if(r instanceof qe){if(!r.s)return void(r.o=Be.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Be.bind(null,e,t),Be.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var qe=/*#__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{Be(n,1,i(this.v))}catch(e){Be(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Be(n,1,t?t(o):o):r?Be(n,1,r(o)):Be(n,2,o)}catch(e){Be(n,2,e)}},n},e}();function ze(e){return e instanceof qe&&1&e.s}var Je=function(e,t,r,o){try{var i="number"==typeof r,s=new _e(t,e,o);return Promise.resolve(s.getCurrentTokenTemplateCount()).then(function(t){var o;function a(e){return o?e:-1}var c=1,u=function(e,t,r){for(var n;;){var o=e();if(ze(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!ze(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!ze(s)){n=2;break}}}var a=new qe,c=Be.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(d)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!ze(s))return void s.then(d).then(void 0,c);if(!(o=e())||ze(o)&&!o.v)return void Be(a,1,i);if(o.then)return void o.then(l).then(void 0,c);ze(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,c)}function l(e){e?(i=r())&&i.then?i.then(u).then(void 0,c):u(i):Be(a,1,i)}function d(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):Be(a,1,i)}}(function(){return!o&&c<=t},function(){return c++},function(){return Promise.resolve(s.getTokenTemplate(c)).then(function(t){var s=new n.ethers.Contract(t.templateAddress,V.default.abi,e);return i?Promise.resolve(s.connect(e).getId()).then(function(e){if(t.isActive&&e.toString()===r.toString())return o=1,c}):t.isActive&&t.templateAddress===r.toString()?(o=1,c):void 0})});return u&&u.then?u.then(a):a(u)})}catch(e){return Promise.reject(e)}},We=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return J.default.abi},r.createDatatoken=function(e,t,r,o,i,s,a,c,u,l,d,h,f,m,v,g){try{var p=this;return Promise.resolve(p.getNftPermissions(e,t)).then(function(t){if(!0!==t.deployERC20)throw new Error("Caller is not DatatokenDeployer");if(d||(d=1),!u||!l){var P=Le();u=P.name,l=P.symbol}var y=p.getContract(e);return Promise.resolve(y.provider.getNetwork()).then(function(e){var t=e.chainId;function P(){var e=y.estimateGas,t=e.createERC20,P=[u,l],w=d;return Promise.resolve(p.amountToUnits(null,c,18)).then(function(k){return Promise.resolve(p.amountToUnits(null,a,18)).then(function(b){return Promise.resolve(t.call(e,w,P,[r,o,i,s],[k,b],[])).then(function(e){var t;if(g)return e;var P=[r,o,i,s];f&&(P.push(f.toLowerCase()),P.push(m?m.toLowerCase():Re),P.push(v||Re));var w=[u,l],k=d,b=y.createERC20,T=null==(t=p.config)?void 0:t.gasFeeMultiplier,A=p.getSignerAccordingSdk();return Promise.resolve(p.amountToUnits(null,c,18)).then(function(t){return Promise.resolve(p.amountToUnits(null,a,18)).then(function(r){return Promise.resolve(Pe(e,A,T,b,k,w,P,[t,r],h?[n.ethers.utils.toUtf8Bytes(h)]:[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=De(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})}var w=function(e){try{var t=function(){try{if(process.env.ADDRESS_FILE){var e=U.default.readFileSync(process.env.ADDRESS_FILE,"utf8");return JSON.parse(e)}return N.default}catch(e){return N.default}}();if(t)for(var r=Object.keys(t),n=0,o=r;n<o.length;n++){var i=o[n];if(t[i].chainId===e)return t[i]}}catch(e){console.error(e)}return null}(t),k=function(){if(h)return Promise.resolve(Je(p.signer,w.ERC721Factory,4,t)).then(function(e){d=e})}();return k&&k.then?k.then(P):P()})})}catch(e){return Promise.reject(e)}},r.addManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(i.estimateGas.addManager(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addManager,r))})})}catch(e){return Promise.reject(e)}},r.removeManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(i.estimateGas.removeManager(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeManager,r))})})}catch(e){return Promise.reject(e)}},r.addDatatokenDeployer=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addToCreateERC20List(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToCreateERC20List,r))})})}catch(e){return Promise.reject(e)}},r.removeDatatokenDeployer=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t===r&&!0!==e.deployERC20)throw new Error("Caller is not Manager nor DatatokenDeployer");return Promise.resolve(i.estimateGas.removeFromCreateERC20List(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromCreateERC20List,r))})}var c=!0!==s.manager;return c||t!==r?a(c||t===r&&o.getNftPermissions(e,t)):Promise.resolve(c||t===r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.addMetadataUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addToMetadataList(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToMetadataList,r))})})}catch(e){return Promise.reject(e)}},r.removeMetadataUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t!==r&&!0!==e.updateMetadata)throw new Error("Caller is not Manager nor Metadata Updater");return Promise.resolve(i.estimateGas.removeFromMetadataList(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromMetadataList,r))})}var c=!0!==s.manager;return c||t===r?a(c||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(c||t!==r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.addStoreUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addTo725StoreList(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addTo725StoreList,r))})})}catch(e){return Promise.reject(e)}},r.removeStoreUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t!==r&&!0!==e.store)throw new Error("Caller is not Manager nor storeUpdater");return Promise.resolve(i.estimateGas.removeFrom725StoreList(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFrom725StoreList,r))})}var c=!0!==s.manager;return c||t===r?a(c||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(c||t!==r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.getContract(e);return Promise.resolve(n.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(o.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.cleanPermissions))})})}catch(e){return Promise.reject(e)}},r.transferNft=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(s.estimateGas.transferFrom(t,r,a)).then(function(e){var n;return o?e:Promise.resolve(Pe(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.transferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},r.safeTransferNft=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(s.estimateGas.safeTransferFrom(t,r,a)).then(function(e){var n;return o?e:Promise.resolve(Pe(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.safeTransferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},r.setMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l=this,d=l.getContract(e);return c||(c=[]),Promise.resolve(l.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(d.estimateGas.setMetaData(r,n,o,i,s,a,c)).then(function(e){var t;return u?e:Promise.resolve(Pe(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,d.setMetaData,r,n,o,i,s,a,c))})})}catch(e){return Promise.reject(e)}},r.setMetadataAndTokenURI=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");var t=ce({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(Pe(e,o.signer,null==(r=o.config)?void 0:r.gasFeeMultiplier,i.setMetaDataAndTokenURI,t))})})}catch(e){return Promise.reject(e)}},r.setMetadataState=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(i.estimateGas.setMetaDataState(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setMetaDataState,r))})})}catch(e){return Promise.reject(e)}},r.setTokenURI=function(e,t,r){try{var n=this,o=n.getContract(e);return Promise.resolve(o.estimateGas.setTokenURI("1",t)).then(function(e){var i;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,o.setTokenURI,"1",t))})}catch(e){return Promise.reject(e)}},r.getNftOwner=function(e){try{var t=this.getContract(e);return Promise.resolve(t.ownerOf(1))}catch(e){return Promise.reject(e)}},r.getNftPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.getPermissions(t))}catch(e){return Promise.reject(e)}},r.getMetadata=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getMetaData())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.setData=function(e,t,r,o,i){try{var s=this;return Promise.resolve(s.getNftPermissions(e,t)).then(function(t){if(!0!==t.store)throw new Error("User is not ERC20 store updater");var a=s.getContract(e),c=n.ethers.utils.keccak256(r),u=n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(c,u)).then(function(e){var t;return i?e:Promise.resolve(Pe(e,s.getSignerAccordingSdk(),null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,c,u))})})}catch(e){return Promise.reject(e)}},r.getData=function(e,t){try{var r=this.getContract(e),o=n.ethers.utils.keccak256(t);return Promise.resolve(r.getData(o)).then(function(e){return e?n.ethers.utils.toUtf8String(e):null})}catch(e){return Promise.reject(e)}},r.getTokenURI=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.tokenURI(t))}catch(e){return Promise.reject(e)}},r.isDatatokenDeployed=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isDeployed(t))}catch(e){return Promise.reject(e)}},t}(xe),Ve=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o)||this).abiEnterprise=void 0,s.nft=void 0,s.abiEnterprise=i||z.default.abi,s.nft=new We(s.signer,r),s}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return q.default.abi},r.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,ye(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,ye(null,null,r,18)))})}catch(e){return Promise.reject(e)}},r.createFixedRate=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!e)throw new Error("User is not Datatoken Deployer");r.allowedConsumer||(r.allowedConsumer=Re);var t=!1===r.withMint?0:1;return Promise.resolve(i.estimateGas.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t])).then(function(e){var s;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t]))})})}catch(e){return Promise.reject(e)}},r.createDispenser=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e);return n.allowedSwapper||(n.allowedSwapper=Re),n.withMint=!1!==n.withMint,Promise.resolve(s.estimateGas.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper)).then(function(e){var t;return o?e:Promise.resolve(Pe(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper))})})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getPermissions(e,t)).then(function(a){if(!0!==a.minter)throw new Error("Caller is not Minter");return Promise.resolve(i.getCap(e)).then(function(e){if(new L.default(e).gte(r))return Promise.resolve(s.estimateGas.mint(n||t,ye(null,null,r,18))).then(function(e){var a;return o?e:Promise.resolve(Pe(e,i.getSignerAccordingSdk(),null==(a=i.config)?void 0:a.gasFeeMultiplier,s.mint,n||t,ye(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},r.addMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addMinter(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},r.removeMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removeMinter(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},r.addPaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addPaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.removePaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removePaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.setPaymentCollector=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getPermissions(e,t)).then(function(s){function a(e){function s(s){function a(e){if(!c&&!u&&!(null==e?void 0:e.deployERC20))throw new Error("Caller is not Fee Manager, owner or Datatoken Deployer");return Promise.resolve(i.estimateGas.setPaymentCollector(r)).then(function(e){var t;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setPaymentCollector,r))})}var u=e&&s===t;return e&&!u?Promise.resolve(e&&!u&&o.nft.getNftPermissions(e,t)).then(a):a(e&&!u&&o.nft.getNftPermissions(e,t))}return e?Promise.resolve(o.nft.getNftOwner(e)).then(s):s(e)}var c=s.paymentManager;return c?a(!c&&o.getNFTAddress(e)):Promise.resolve(!c&&o.getNFTAddress(e)).then(a)})}catch(e){return Promise.reject(e)}},r.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},r.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(ye(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},r.transferWei=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.transfer(t,r)).then(function(e){var s;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},r.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e,s.abi);return o||(o={consumeMarketFeeAddress:Re,consumeMarketFeeToken:Re,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var c;return i?e:Promise.resolve(Pe(e,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},r.reuseOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.reuseOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},r.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(o.getFreOrderParams(r)).then(function(e){return Promise.resolve(i.estimateGas.buyFromFreAndOrder(t,e)).then(function(r){var s;return n?r:Promise.resolve(Pe(r,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},r.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(i.estimateGas.buyFromDispenserAndOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},r.setData=function(e,t,r,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e),a=n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(r));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(Pe(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.nft,i=o.getNftOwner;return Promise.resolve(n.getNFTAddress(e)).then(function(s){return Promise.resolve(i.call(o,s)).then(function(o){if(o!==t)throw new Error("Caller is NOT Nft Owner");var i=n.getContract(e);return Promise.resolve(i.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},r.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},r.getCap=function(e){try{var t=this,r=t.getContract(e);return Promise.resolve(r.cap()).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},r.getId=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getId())}catch(e){return Promise.reject(e)}},r.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},r.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},r.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},r.getFixedRates=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getFixedRates())}catch(e){return Promise.reject(e)}},r.getDispensers=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getDispensers())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.balance=function(e,t){try{var r=this,n=r.getContract(e);return Promise.resolve(n.balanceOf(t)).then(function(e){return Promise.resolve(r.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.allowance=function(e,t,r,n){void 0===n&&(n=18);try{var o=this,i=o.getContract(e);return Promise.resolve(i.allowance(t,r)).then(function(e){return Promise.resolve(o.unitsToAmount(null,e,n))})}catch(e){return Promise.reject(e)}},r.setPublishingMarketFee=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e);return Promise.resolve(a.getPublishingMarketFee()).then(function(e){if(e[0]!==o)throw new Error("Caller is not the Publishing Market Fee Address");return Promise.resolve(a.estimateGas.setPublishingMarketFee(t,r,n)).then(function(e){var o;return i?e:Promise.resolve(Pe(e,s.getSignerAccordingSdk(),null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},r.getPublishingMarketFee=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPublishingMarketFee()).then(function(e){return{publishMarketFeeAddress:e[0],publishMarketFeeToken:e[1],publishMarketFeeAmount:e[2].toString()}})}catch(e){return Promise.reject(e)}},r.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(ye(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(ye(t.signer,e.baseTokenAddress,e.swapMarketFee,e.baseTokenDecimals)).then(function(t){return{exchangeContract:n,exchangeId:r,maxBaseTokenAmount:o,swapMarketFee:t,marketFeeAddress:e.marketFeeAddress}})})}catch(e){return Promise.reject(e)}},t}(xe),He=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,n,o,i)||this).accessList=void 0,s.fileObject=void 0,s.abi=s.getDefaultAbi(),s.fileObject=r,s}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return H.default.abi},r.setFileObj=function(e){this.fileObject=e},r.getAllowlistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getAllowListContract())}catch(e){return Promise.reject(e)}},r.getDenylistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getDenyListContract())}catch(e){return Promise.reject(e)}},r.setAllowListContract=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var i=o.getContract(e);return Promise.resolve(i.estimateGas.setAllowListContract(t)).then(function(e){var r;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setAllowListContract,t))})})}catch(e){return Promise.reject(e)}},r.setDenyListContract=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var i=o.getContract(e);return Promise.resolve(i.estimateGas.setDenyListContract(t)).then(function(e){var r;return n?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setDenyListContract,t))})})}catch(e){return Promise.reject(e)}},r.setFileObject=function(e,t,r){try{var n=this;return Promise.resolve(n.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var o=n.getContract(e);return Promise.resolve(o.estimateGas.setFilesObject(n.fileObject)).then(function(e){var t;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.functions.setFilesObject,n.fileObject))})})}catch(e){return Promise.reject(e)}},r.getFileObject=function(e,t,r,n,o,i,s){try{var a=this.getContract(e,this.getDefaultAbi());return Promise.resolve(a.getFileObject(t,r,n,o,i,s))}catch(e){return Promise.reject(e)}},t}(Ve),Ze=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abiEnterprise=void 0,s.abi=i||s.getDefaultAbi(),s}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Z.default.abi},r.getTokenUri=function(e){try{return Promise.resolve(this.contract.tokenURI(e))}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getId=function(){try{return Promise.resolve(this.contract.getId())}catch(e){return Promise.reject(e)}},r.getName=function(){try{return Promise.resolve(this.contract.name())}catch(e){return Promise.reject(e)}},r.getSymbol=function(){try{return Promise.resolve(this.contract.symbol())}catch(e){return Promise.reject(e)}},r.balance=function(e){try{var t=this;return Promise.resolve(t.contract.balanceOf(e)).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.mint(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.mint,e,t))})}catch(e){return Promise.reject(e)}},r.batchMint=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.batchMint(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.batchMint,e,t))})}catch(e){return Promise.reject(e)}},r.burn=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.burn(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.burn,e))})}catch(e){return Promise.reject(e)}},r.transferOwnership=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.transferOwnership(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.transferOwnership,e))})}catch(e){return Promise.reject(e)}},r.renounceOwnership=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.renounceOwnership()).then(function(r){var n;return e?r:Promise.resolve(Pe(r,t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.renounceOwnership))})}catch(e){return Promise.reject(e)}},t}(Me),Xe=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abi=i||s.getDefaultAbi(),s}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return X.default.abi},r.deployAccessListContract=function(e,t,r,n,o,i,s){void 0===n&&(n=!1);try{var a=this;if(!e||!t){var c=Le();e=c.name,t=c.symbol}return Promise.resolve(a.contract.estimateGas.deployAccessListContract(e,t,n,o,i,r)).then(function(c){return s?c:function(s,u){try{var l=Promise.resolve(Pe(c,a.getSignerAccordingSdk(),null==(d=a.config)?void 0:d.gasFeeMultiplier,a.contract.deployAccessListContract,e,t,n,o,i,r)).then(function(e){if(!e){var t="Tx for deploying new access list was not processed on chain.";throw console.error(t),t}return Promise.resolve(e.wait()).then(function(e){return De(e,"NewAccessList").args[0]})})}catch(e){return u(e)}var d;return l&&l.then?l.then(void 0,u):l}(0,function(e){console.error("Creation of AccessList failed: "+e)})})}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.isSoulbound=function(e){try{return Promise.resolve(this.contract.isSoulBound(e))}catch(e){return Promise.reject(e)}},r.isDeployed=function(e){try{return Promise.resolve(this.contract.isDeployed(e))}catch(e){return Promise.reject(e)}},r.changeTemplateAddress=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Re)throw new Error("Template address cannot be ZERO address");return Promise.resolve(n.contract.estimateGas.changeTemplateAddress(t)).then(function(e){var o;return r?e:Promise.resolve(Pe(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.functions.changeTemplateAddress,t))})})}catch(e){return Promise.reject(e)}},t}(Me),Ke=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return K.default.abi},r.lockTokens=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,e)).then(function(e){return Promise.resolve(n.contract.estimateGas.create_lock(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o.add(2e4),n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.create_lock,e,t))})})})}catch(e){return Promise.reject(e)}},r.depositFor=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,t)).then(function(t){return Promise.resolve(n.contract.estimateGas.deposit_for(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o.add(2e4),n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.deposit_for,e,t))})})})}catch(e){return Promise.reject(e)}},r.increaseAmount=function(e,t){try{var r=this,n=r.amountToUnits;return Promise.resolve(r.getToken()).then(function(o){return Promise.resolve(n.call(r,o,e)).then(function(e){return Promise.resolve(r.contract.estimateGas.increase_amount(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.increase_amount,e))})})})}catch(e){return Promise.reject(e)}},r.increaseUnlockTime=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.increase_unlock_time(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.increase_unlock_time,e))})}catch(e){return Promise.reject(e)}},r.withdraw=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.withdraw()).then(function(r){var n;return e?r:Promise.resolve(Pe(r.add(2e4),t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.withdraw))})}catch(e){return Promise.reject(e)}},r.getVotingPower=function(e){try{return Promise.resolve(this.contract.balanceOf(e))}catch(e){return Promise.reject(e)}},r.getLockedAmount=function(e){try{var t=this;return Promise.resolve(t.contract.locked(e)).then(function(e){var r=t.unitsToAmount;return Promise.resolve(t.getToken()).then(function(n){return Promise.resolve(r.call(t,n,e.amount.toString()))})})}catch(e){return Promise.reject(e)}},r.lockEnd=function(e){try{return Promise.resolve(this.contract.locked__end(e)).then(function(e){return parseInt(e.toString())})}catch(e){return Promise.reject(e)}},r.totalSupply=function(){try{var e=this,t=e.unitsToAmount;return Promise.resolve(e.getToken()).then(function(r){return Promise.resolve(e.contract.totalSupply()).then(function(n){return Promise.resolve(t.call(e,r,n))})})}catch(e){return Promise.reject(e)}},r.getToken=function(){try{return Promise.resolve(this.contract.token())}catch(e){return Promise.reject(e)}},t}(Me),$e=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return $.default.abi},r.claim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.claim()).then(function(r){var n;return e?r:Promise.resolve(Pe(r.add(2e4),t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.claim))})}catch(e){return Promise.reject(e)}},r.claimMany=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.claim_many(e)).then(function(n){var o;return t?n:Promise.resolve(Pe(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.claim_many,e))})}catch(e){return Promise.reject(e)}},t}(Me),Ye=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Y.default.abi},r.estimateClaim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateClaim(e)).then(function(e){return Promise.resolve(t.contract.voting_escrow()).then(function(r){var n=new Ke(r,t.signer),o=t.unitsToAmount;return Promise.resolve(n.getToken()).then(function(r){return Promise.resolve(o.call(t,r,e))})})})}catch(e){return Promise.reject(e)}},t}(Me),Qe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Q.default.abi},r.setAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(Pe(i.add(2e4),o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.setAllocation,e,t,r))})}catch(e){return Promise.reject(e)}},r.setBatchAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setBatchAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(Pe(i.add(2e4),o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.setBatchAllocation,e,t,r))})}catch(e){return Promise.reject(e)}},r.getTotalAllocation=function(e){try{return Promise.resolve(this.contract.getTotalAllocation(e))}catch(e){return Promise.reject(e)}},r.getVeAllocation=function(e,t,r){try{return Promise.resolve(this.contract.getveAllocation(e,t,r))}catch(e){return Promise.reject(e)}},t}(Me);function et(e,t,r){if(!e.s){if(r instanceof tt){if(!r.s)return void(r.o=et.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(et.bind(null,e,t),et.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var tt=/*#__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{et(n,1,i(this.v))}catch(e){et(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?et(n,1,t?t(o):o):r?et(n,1,r(o)):et(n,2,o)}catch(e){et(n,2,e)}},n},e}(),rt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return ee.default.abi},r.getAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimable(e,t)).then(function(e){return Promise.resolve(r.unitsToAmount(t,e))})}catch(e){return Promise.reject(e)}},r.claimRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimFor(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimFor,e,t))})}catch(e){return Promise.reject(e)}},r.allocateRewards=function(e,t,r,n){try{var o=function(){return Promise.resolve(i.contract.estimateGas.allocate(e,t,r)).then(function(o){var s;return n?o:Promise.resolve(Pe(o,i.getSignerAccordingSdk(),null==(s=i.config)?void 0:s.gasFeeMultiplier,i.contract.allocate,e,t,r))})},i=this,s=(a=t,c=function(e){return Promise.resolve(i.amountToUnits(r,t[e])).then(function(r){t[e]=r})},d=-1,function e(t){try{for(;++d<a.length;)if((t=c(d))&&t.then){if(!((r=t)instanceof tt&&1&r.s))return void t.then(e,l||(l=et.bind(null,u=new tt,2)));t=t.v}u?et(u,1,t):u=t}catch(e){et(u||(u=new tt),2,e)}var r}(),u);return Promise.resolve(s&&s.then?s.then(o):o())}catch(e){return Promise.reject(e)}var a,c,u,l,d},t}(Me);function nt(e,t,r){if(!e.s){if(r instanceof ot){if(!r.s)return void(r.o=nt.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(nt.bind(null,e,t),nt.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var ot=/*#__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{nt(n,1,i(this.v))}catch(e){nt(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?nt(n,1,t?t(o):o):r?nt(n,1,r(o)):nt(n,2,o)}catch(e){nt(n,2,e)}},n},e}(),it=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return te.default.abi},r.getMultipleAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimables(e,t)).then(function(e){var n,o,i,s,a,c=[],u=(n=e,o=function(n){var o=c.push;return Promise.resolve(r.unitsToAmount(t[n],e[n])).then(function(e){o.call(c,e)})},a=-1,function e(t){try{for(;++a<n.length;)if((t=o(a))&&t.then){if(!((r=t)instanceof ot&&1&r.s))return void t.then(e,s||(s=nt.bind(null,i=new ot,2)));t=t.v}i?nt(i,1,t):i=t}catch(e){nt(i||(i=new ot),2,e)}var r}(),i);return u&&u.then?u.then(function(){return c}):c})}catch(e){return Promise.reject(e)}},r.claimMultipleRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimMultiple(e,t)).then(function(o){var i;return r?o:Promise.resolve(Pe(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(Me);function st(e,t,r){if(!e.s){if(r instanceof at){if(!r.s)return void(r.o=st.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(st.bind(null,e,t),st.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var at=/*#__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{st(n,1,i(this.v))}catch(e){st(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?st(n,1,t?t(o):o):r?st(n,1,r(o)):st(n,2,o)}catch(e){st(n,2,e)}},n},e}(),ct=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abiEnterprise=void 0,s.abi=i||s.getDefaultAbi(),s}ue(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return re.default.abi},r.getFunds=function(e){try{return Promise.resolve(this.contract.getFunds(e))}catch(e){return Promise.reject(e)}},r.getUserFunds=function(e,t){try{return Promise.resolve(this.contract.getUserFunds(e,t))}catch(e){return Promise.reject(e)}},r.getLocks=function(e,t,r){try{return Promise.resolve(this.contract.getLocks(e,t,r))}catch(e){return Promise.reject(e)}},r.getAuthorizations=function(e,t,r){try{return Promise.resolve(this.contract.getAuthorizations(e,t,r))}catch(e){return Promise.reject(e)}},r.verifyFundsForEscrowPayment=function(e,t,r,o,i,s){try{var a=this;return Promise.resolve(a.contract.provider.getBalance(n.ethers.utils.getAddress(t))).then(function(c){if(c===n.BigNumber.from(0))return{isValid:!1,message:"Native token balance is 0. Please add funds"};var u=new Ve(a.signer),l=u.allowance;return Promise.resolve(a.signer.getAddress()).then(function(c){return Promise.resolve(l.call(u,e,c,a.contract.address)).then(function(c){var l=n.BigNumber.from;return Promise.resolve(a.amountToUnits(e,c,18)).then(function(c){function d(){var c=u.balance;return Promise.resolve(a.signer.getAddress()).then(function(l){return Promise.resolve(c.call(u,e,l)).then(function(c){if(n.ethers.utils.parseEther(c)===n.BigNumber.from(0))return{isValid:!1,message:"Payment token balance is 0. Please add funds"};var u=a.getAuthorizations;return Promise.resolve(a.signer.getAddress()).then(function(l){return Promise.resolve(u.call(a,e,l,t)).then(function(u){var l=a.getUserFunds;return Promise.resolve(a.signer.getAddress()).then(function(d){return Promise.resolve(l.call(a,d,e)).then(function(l){function d(){var r=function(){if(0===u.length)return Promise.resolve(a.authorize(n.ethers.utils.getAddress(e),n.ethers.utils.getAddress(t),(Number(o)/2).toString(),i,s)).then(function(){})}();return r&&r.then?r.then(function(){return{isValid:!0,message:""}}):{isValid:!0,message:""}}var h=function(){if(n.BigNumber.from(l[0]).eq(n.BigNumber.from(0))){var t=function(){if(r&&n.ethers.utils.parseEther(c).lte(n.ethers.utils.parseEther(r))&&n.ethers.utils.parseEther(r)>n.BigNumber.from(o))return Promise.resolve(a.deposit(e,r)).then(function(){});var t=function(){if(n.ethers.utils.parseEther(c).lte(n.BigNumber.from(o))){var t=a.deposit;return Promise.resolve(a.unitsToAmount(e,o)).then(function(r){return Promise.resolve(t.call(a,e,r)).then(function(){})})}return Promise.resolve(a.deposit(e,c)).then(function(){})}();return t&&t.then?t.then(function(){}):void 0}();if(t&&t.then)return t.then(function(){})}}();return h&&h.then?h.then(d):d()})})})})})})}var h=function(){if(l.call(n.BigNumber,c).lt(n.BigNumber.from(o)))return Promise.resolve(u.approve(n.ethers.utils.getAddress(e),n.ethers.utils.getAddress(a.contract.address),o)).then(function(){})}();return h&&h.then?h.then(d):d()})})})})}catch(e){return Promise.reject(e)}},r.deposit=function(e,t,r){try{var n=this,o=ye(null,null,t,18);return Promise.resolve(n.contract.estimateGas.deposit(e,o)).then(function(t){var i;return r?t:Promise.resolve(Pe(t,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.deposit,e,o))})}catch(e){return Promise.reject(e)}},r.withdraw=function(e,t,r){try{var o=this,i=[],s=[];if(e.length!==t.length)throw new Error("Tokens and amounts arrays must have the same length");return Promise.resolve(o.signer.getAddress()).then(function(a){function c(){var t=s.map(function(e){return ye(null,null,e,18)});return Promise.resolve(o.contract.estimateGas.withdraw(e,t)).then(function(e){var n;return r?e:Promise.resolve(Pe(e,o.getSignerAccordingSdk(),null==(n=o.config)?void 0:n.gasFeeMultiplier,o.contract.withdraw,i,t))})}var u,l,d,h,f,m=(u=e,l=function(r){var c=e[r],u=n.BigNumber.from(t[r]);return Promise.resolve(o.getUserFunds(a,c)).then(function(e){var o=n.BigNumber.from(e[0]);u.gt(0)&&u.lte(o)?(i.push(c),s.push(t[r])):console.log("Insufficient funds for token "+c)})},f=-1,function e(t){try{for(;++f<u.length;)if((t=l(f))&&t.then){if(!((r=t)instanceof at&&1&r.s))return void t.then(e,h||(h=st.bind(null,d=new at,2)));t=t.v}d?st(d,1,t):d=t}catch(e){st(d||(d=new at),2,e)}var r}(),d);return m&&m.then?m.then(c):c()})}catch(e){return Promise.reject(e)}},r.authorize=function(e,t,r,n,o,i){try{var s=this,a=s.getAuthorizations;return Promise.resolve(s.signer.getAddress()).then(function(c){return Promise.resolve(a.call(s,e,c,t)).then(function(a){if(0!==a.length)return console.log("Payee "+t+" already authorized"),null;var c=ye(null,null,r,18),u=ye(null,null,n,18),l=ye(null,null,o,18);return Promise.resolve(s.contract.estimateGas.authorize(e,t,c,u,l)).then(function(r){var n;return i?r:Promise.resolve(Pe(r,s.getSignerAccordingSdk(),null==(n=s.config)?void 0:n.gasFeeMultiplier,s.contract.authorize,e,t,c,u,l))})})})}catch(e){return Promise.reject(e)}},r.cancelExpiredLocks=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.contract.estimateGas.cancelExpiredLocks(e,t,r,n)).then(function(s){var a;return o?s:Promise.resolve(Pe(s,i.getSignerAccordingSdk(),null==(a=i.config)?void 0:a.gasFeeMultiplier,i.contract.cancelExpiredLocks,e,t,r,n))})}catch(e){return Promise.reject(e)}},t}(Me),ut=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}},lt=function(e,t){try{var r=n.ethers.utils.solidityKeccak256(["bytes"],[n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(t))]),o=n.ethers.utils.arrayify(r);return Promise.resolve(e.getChainId()).then(function(t){return function(t,r){try{var n=Promise.resolve(e.signMessage(o))}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(r){return he.error("Sign message error: ",r),function(){if(8996===t)return console.log("Signing message with _legacySignMessage"),Promise.resolve(e._legacySignMessage(o))}()})})}catch(e){return Promise.reject(e)}};function dt(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function ht(e,t,r){if(!e.s){if(r instanceof ft){if(!r.s)return void(r.o=ht.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(ht.bind(null,e,t),ht.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var ft=/*#__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{ht(n,1,i(this.v))}catch(e){ht(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?ht(n,1,t?t(o):o):r?ht(n,1,r(o)):ht(n,2,o)}catch(e){ht(n,2,e)}},n},e}();function mt(e){return e instanceof ft&&1&e.s}var vt=/*#__PURE__*/function(){function e(e){this.aquariusURL=void 0,this.aquariusURL=e}var t=e.prototype;return t.resolve=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/ddo/"+e;return Promise.resolve(dt(function(){return Promise.resolve(ne.default(n,{method:"GET",headers:{"Content-Type":"application/json",Authorization:r},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 he.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForIndexer=function(e,t,r,n,o,i){void 0===n&&(n=3e4),void 0===o&&(o=100);try{var s,a=this,c=0;o>500&&(he.warn("Max Limit exceeded, defaulting to 500 retries."),o=500);var u=function(e,t){var r;do{var n=e();if(n&&n.then){if(!mt(n)){r=!0;break}n=n.v}var o=t();if(mt(o)&&(o=o.v),!o)return n}while(!o.then);var i=new ft,s=ht.bind(null,i,2);return(r?n.then(a):o.then(c)).then(void 0,s),i;function a(r){for(n=r;mt(o=t())&&(o=o.v),o;){if(o.then)return void o.then(c).then(void 0,s);if((n=e())&&n.then){if(!mt(n))return void n.then(a).then(void 0,s);n=n.v}}ht(i,1,n)}function c(r){if(r){do{if((n=e())&&n.then){if(!mt(n))return void n.then(a).then(void 0,s);n=n.v}if(mt(r=t())&&(r=r.v),!r)return void ht(i,1,n)}while(!r.then);r.then(c).then(void 0,s)}else ht(i,1,n)}}(function(){function o(e){return s?e:Promise.resolve(ut(n)).then(function(){c++})}var u=dt(function(){return Promise.resolve(ne.default(a.aquariusURL+"/api/aquarius/assets/ddo/"+e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:i},signal:r})).then(function(e){return function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){var r=S.DDOManager.getDDOClass(e).getAssetFields().indexedMetadata;return t?r.event&&r.event.txid===t?(s=1,e):void 0:(s=1,e)})}()})},function(){});return u&&u.then?u.then(o):o(u)},function(){return!s&&c<o});return Promise.resolve(u&&u.then?u.then(function(e){return s?e:null}):s?u:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t,r,n,o){try{var i=r+"/api/aquarius/assets/ddo/validate",s=r+"/api/services/nonce";return Promise.resolve(dt(function(){return Promise.resolve(t.getAddress()).then(function(r){return Promise.resolve(ne.default(s+"?userAddress="+r,{method:"GET",headers:{"Content-Type":"application/json",Authorization:o},signal:n})).then(function(s){return Promise.resolve(s.json()).then(function(s){var a=s.nonce;console.log("[getNonce] Consumer: "+r+" nonce: "+a),a&&null!==a||(a="0");var c=(Number(a)+1).toString();return Promise.resolve(lt(t,r+c)).then(function(t){return Promise.resolve(ne.default(i,{method:"POST",body:JSON.stringify({ddo:e,publisherAddress:r,nonce:c,signature:t}),headers:{"Content-Type":"application/octet-stream",Authorization:o},signal:n})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(200!==e.status)throw new Error("Metadata validation failed");return console.log("Ddo successfully validated"),{valid:!0,hash:t.hash,proof:{validatorAddress:t.publicKey,r:t.r[0],s:t.s[0],v:t.v}}})})})})})})},function(e){he.error("Metadata validation failed",e.message)}))}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(dt(function(){return Promise.resolve(ne.default(n,{method:"GET",headers:{"Content-Type":"application/json",Authorization:r},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("getAssetMetadata failed: "+e.status+e.statusText)})},function(e){throw he.error("Error getting metadata: ",e),new Error("Error getting metadata: "+e)}))}catch(e){return Promise.reject(e)}},t.querySearch=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/query";return Promise.resolve(dt(function(){return Promise.resolve(ne.default(n,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:r},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("querySearch failed: "+e.status+e.statusText)})},function(e){throw he.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();function gt(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var pt=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getConsumerAddress=function(e){try{return Promise.resolve("string"==typeof e?function(e){try{return oe.default.decode(e,{json:!0})}catch(e){throw new Error("Error decoding JWT")}}(e).address:e.getAddress())}catch(e){return Promise.reject(e)}},t.getSignature=function(e,t){try{return Promise.resolve("string"==typeof e?null:this.signProviderRequest(e,t))}catch(e){return Promise.reject(e)}},t.getAuthorization=function(e){return"string"==typeof e?e:void 0},t.getEndpoints=function(e,t){try{var r=this;return Promise.resolve(gt(function(){return Promise.resolve(r.getData(e,t)).then(function(e){return Promise.resolve(e.json())})},function(e){throw he.error("Finding the service endpoints failed:",e),new Error("HTTP request failed calling Provider")}))}catch(e){return Promise.reject(e)}},t.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName.toLowerCase()===t.toLowerCase()}):null},t.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints){var o={serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e.replace(/\/+$/,"")+"/"+t.serviceEndpoints[n][1].replace(/^\/+/,"")};r.push(o)}return Promise.resolve(r)}catch(e){return Promise.reject(e)}},t.getNonce=function(e,t,r,n,o){try{var i=function(){function i(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?gt(function(){return Promise.resolve(ne.default(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return Promise.resolve(e.json()).then(function(e){var r=e.nonce;return console.log("[getNonce] Consumer: "+t+" nonce: "+r),r&&null!==r?Number(r):0})})},function(e){throw he.error(e),new Error(e.message)}):null}var a=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return a&&a.then?a.then(i):i()},s=this,a=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},t.signProviderRequest=function(e,t){try{var r=n.ethers.utils.solidityKeccak256(["bytes"],[n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(t))]),o=n.ethers.utils.arrayify(r);return Promise.resolve(gt(function(){return Promise.resolve(e.signMessage(o))},function(){return Promise.resolve(e.getChainId()).then(function(t){return function(){if(8996===t)return Promise.resolve(e._legacySignMessage(o))}()})}))}catch(e){return Promise.reject(e)}},t.encrypt=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(r)).then(function(i){return Promise.resolve(o.getServiceEndpoints(r,i)).then(function(r){var i=(o.getEndpointURL(r,"encrypt")?o.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return i?gt(function(){return Promise.resolve(ne.default(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 he.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n,o){void 0===n&&(n=!1);try{var i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw he.error("File info call failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){for(var r,n=ae(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var a,c={did:e,serviceId:t,checksum:n},u=[],l=i.getEndpointURL(r,"fileinfo")?i.getEndpointURL(r,"fileinfo").urlPath:null;if(!l)return null;var d=gt(function(){return Promise.resolve(ne.default(l,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw he.error("File info call failed: "),he.error(e),new Error(e)});return d&&d.then?d.then(s):s()})})}catch(e){return Promise.reject(e)}},t.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){function i(e){var t;function r(e){return t?e:Promise.resolve(s.json()).then(function(e){throw he.error("File info call failed: ",s.status,s.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=s)&&e.ok)return Promise.resolve(s.json()).then(function(e){for(var r,n=ae(e);!(r=n()).done;)c.push(r.value);return t=1,c})}();return n&&n.then?n.then(r):r(n)}var s,a=ce({},e,{checksum:r}),c=[],u=o.getEndpointURL(t,"fileinfo")?o.getEndpointURL(t,"fileinfo").urlPath:null;if(!u)return null;var l=gt(function(){return Promise.resolve(ne.default(u,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){s=e})},function(e){throw he.error("File info call failed: "),he.error(e),new Error(e)});return l&&l.then?l.then(i):i()})})}catch(e){return Promise.reject(e)}},t.getComputeEnvironments=function(e,t){try{var r=this;return Promise.resolve(r.getEndpoints(e)).then(function(n){return Promise.resolve(r.getServiceEndpoints(e,n)).then(function(e){var n;function o(e){var t;return null!=(t=i)&&t.ok?i.json():Promise.resolve(i.json()).then(function(e){throw he.error("Fetch compute env failed: ",i.status,i.statusText,e),new Error(JSON.stringify(e))})}var i,s=null==(n=r.getEndpointURL(e,"computeEnvironments"))?void 0:n.urlPath;if(!s)return null;var a=gt(function(){return Promise.resolve(ne.default(s,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){i=e})},function(e){throw he.error("Fetch compute env failed: "),he.error(e),new Error(e)});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(o)).then(function(l){return Promise.resolve(u.getServiceEndpoints(o,l)).then(function(o){function l(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw he.error("Provider initialized failed: ",d.status,d.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(200===(null==(e=d)?void 0:e.status))return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var d,h=u.getEndpointURL(o,"initialize")?u.getEndpointURL(o,"initialize").urlPath:null;if(!h)return null;h+="?documentId="+e,h+="&serviceId="+t,h+="&fileIndex="+r,h+="&consumerAddress="+n,s&&(h+="&userdata="+encodeURI(JSON.stringify(s))),a&&(h+="&environment="+encodeURI(a)),c&&(h+="&validUntil="+c);var f=gt(function(){return Promise.resolve(ne.default(h,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){d=e})},function(e){throw he.error("Provider initialized failed: "),he.error(e),new Error("Provider initialize failed url: "+h+" ")});return f&&f.then?f.then(l):l()})})}catch(e){return Promise.reject(e)}},t.initializeComputeV1=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(n)).then(function(l){return Promise.resolve(u.getServiceEndpoints(n,l)).then(function(n){function l(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw he.error("Initialize compute failed: ",d.status,d.statusText,e),he.error("Payload was:",JSON.stringify(h)),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=d)&&e.ok)return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var d,h={datasets:e,algorithm:t,payment:{chainId:i,token:s,maxJobDuration:a},consumerAddress:o,environment:r},f=u.getEndpointURL(n,"initializeCompute")?u.getEndpointURL(n,"initializeCompute").urlPath:null;if(!f)return null;var m=gt(function(){return Promise.resolve(ne.default(f,{method:"POST",body:JSON.stringify(h),headers:{"Content-Type":"application/json"},signal:c})).then(function(e){d=e})},function(e){throw he.error("Initialize compute failed: "),he.error(e),new Error("ComputeJob cannot be initialized")});return m&&m.then?m.then(l):l()})})}catch(e){return Promise.reject(e)}},t.initializeCompute=function(e,t,r,n,o,i,s,a,c,u,l){try{var d=this;return Promise.resolve(d.getEndpoints(i)).then(function(h){return Promise.resolve(d.getServiceEndpoints(i,h)).then(function(f){var m=d.getEndpointURL(f,"initializeCompute")?d.getEndpointURL(f,"initializeCompute").urlPath:null;return m?Promise.resolve(d.getConsumerAddress(s)).then(function(v){return Promise.resolve(d.getNonce(i,v,l,h,f)).then(function(i){var h,f=(i+1).toString(),g=v;return g+=null==(h=e[0])?void 0:h.documentId,g+=f,Promise.resolve(d.getSignature(s,g)).then(function(i){function h(e){var t;function r(e){return t?e:Promise.resolve(f.json()).then(function(e){throw he.error("Initialize compute failed: ",f.status,f.statusText,e),he.error("Payload was:",JSON.stringify(g)),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=f)&&e.ok)return Promise.resolve(f.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var f,g={datasets:e,algorithm:t,environment:r,payment:{chainId:c,token:n,resources:a},maxJobDuration:o,consumerAddress:v,signature:i};u&&(g.policyServer=u);var p=gt(function(){return console.log("Initialize compute url:",m),Promise.resolve(ne.default(m,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json",Authorization:d.getAuthorization(s)},signal:l})).then(function(e){return f=e,console.log("Raw response:",f),function(){if(!f.ok)return Promise.resolve(f.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw he.error("Initialize compute failed: "),he.error(e),new Error("ComputeJob cannot be initialized: "+e.message+".")});return p&&p.then?p.then(h):h()})})}):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(o)).then(function(u){return Promise.resolve(c.getServiceEndpoints(o,u)).then(function(l){var d=c.getEndpointURL(l,"download")?c.getEndpointURL(l,"download").urlPath:null;return d?Promise.resolve(c.getConsumerAddress(i)).then(function(h){return Promise.resolve(c.getNonce(o,h,null,u,l)).then(function(o){var u=(o+1).toString();return Promise.resolve(c.getSignature(i,e+u)).then(function(o){var i=d;return i+="?fileIndex="+r,i+="&documentId="+e,i+="&transferTxId="+n,i+="&serviceId="+t,i+="&consumerAddress="+h,i+="&nonce="+u,s&&(i+="&policyServer="+encodeURI(JSON.stringify(s))),i+="&signature="+o,a&&(i+="&userdata="+encodeURI(JSON.stringify(a))),i})})}):null})})}catch(e){return Promise.reject(e)}},t.computeStartV1=function(e,t,r,n,o,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(e)).then(function(u){return Promise.resolve(c.getServiceEndpoints(e,u)).then(function(l){var d=c.getEndpointURL(l,"computeStart")?c.getEndpointURL(l,"computeStart").urlPath:null;return Promise.resolve(t.getAddress()).then(function(h){return Promise.resolve(c.getNonce(e,h,i,u,l)).then(function(e){var u=(e+1).toString(),l=h;return l+=n.documentId,l+=u,Promise.resolve(c.signProviderRequest(t,l)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=he.error,n=c.statusText,o=c.status;return Promise.resolve(c.json()).then(function(e){return r.call(he,"Compute start failed: ",o,n,e),he.error("Payload was:",l),null})}var n=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var c,l=Object();if(l.consumerAddress=h,l.signature=e,l.nonce=u,l.environment=r,l.dataset=n,l.algorithm=o,s&&(l.additionalDatasets=s),a&&(l.output=a),!d)return null;var f=gt(function(){return Promise.resolve(ne.default(d,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw he.error("Compute start failed:"),he.error(e),he.error("Payload was:",l),new Error("HTTP request failed calling Provider")});return f&&f.then?f.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,o,i,s,a,c,u,l,d,h){try{var f=this;return console.log("called new compute start method..."),console.log("datasets: ",n),console.log("algorithm: ",o),Promise.resolve(f.getEndpoints(e)).then(function(m){return Promise.resolve(f.getServiceEndpoints(e,m)).then(function(v){var g=f.getEndpointURL(v,"computeStart")?f.getEndpointURL(v,"computeStart").urlPath:null;return g?Promise.resolve(f.getConsumerAddress(t)).then(function(p){return Promise.resolve(f.getNonce(e,p,h,m,v)).then(function(e){var m,v=(e+1).toString(),P=p;return P+=null==(m=n[0])?void 0:m.documentId,P+=v,Promise.resolve(f.getSignature(t,P)).then(function(e){function m(e){var t;function r(e){if(t)return e;var r=he.error,n=P.statusText,o=P.status;return Promise.resolve(P.json()).then(function(e){return r.call(he,"Compute start failed: ",o,n,e),he.error("Payload was:",y),null})}var n=function(e){if(null!=(e=P)&&e.ok)return Promise.resolve(P.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var P,y=Object();y.consumerAddress=p,y.signature=e,y.nonce=v,y.environment=r,y.maxJobDuration=i,y.resources=a,y.dataset=n[0],y.datasets=n,y.algorithm=o,y.chainId=c,y.payment={chainId:c,token:s,maxJobDuration:i},a&&(y.payment.resources=a),u&&(y.metadata=u),l&&(y.output=l),d&&(y.policyServer=d);var w=gt(function(){return Promise.resolve(ne.default(g,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json",Authorization:f.getAuthorization(t)},signal:h})).then(function(e){P=e})},function(e){throw he.error("Compute start failed:"),he.error(e),he.error("Payload was:",y),new Error("HTTP request failed calling Provider")});return w&&w.then?w.then(m):m()})})}):(he.error("Compute start failed: Cannot get proper computeStart route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.freeComputeStart=function(e,t,r,n,o,i,s,a,c,u){try{var l=this;return console.log("called new free compute start method..."),console.log("datasets: ",n),console.log("algorithm: ",o),Promise.resolve(l.getEndpoints(e)).then(function(d){return Promise.resolve(l.getServiceEndpoints(e,d)).then(function(h){var f=l.getEndpointURL(h,"freeCompute")?l.getEndpointURL(h,"freeCompute").urlPath:null;return f?Promise.resolve(l.getConsumerAddress(t)).then(function(m){return Promise.resolve(l.getNonce(e,m,u,d,h)).then(function(e){var d=(e+1).toString(),h=d;return console.log("signatureMessage: ",h),Promise.resolve(l.getSignature(t,h)).then(function(e){function h(e){var t;function r(e){if(t)return e;var r=he.error,n=v.statusText,o=v.status;return Promise.resolve(v.json()).then(function(e){return r.call(he,"Compute start failed: ",o,n,e),he.error("Payload was:",g),null})}var n=function(e){if(null!=(e=v)&&e.ok)return Promise.resolve(v.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var v,g=Object();g.consumerAddress=m,g.signature=e,g.nonce=d,g.environment=r,g.resources=i,g.dataset=n[0],g.datasets=n,g.algorithm=o,s&&(g.metadata=s),g.output=a,c&&(g.policyServer=c);var p=gt(function(){return Promise.resolve(ne.default(f,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json",Authorization:l.getAuthorization(t)},signal:u})).then(function(e){v=e})},function(e){throw he.error("Compute start failed:"),he.error(e),he.error("Payload was:",g),new Error("HTTP request failed calling Provider")});return p&&p.then?p.then(h):h()})})}):(he.error("Compute start failed: Cannot get proper computeStart route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.computeStreamableLogs=function(e,t,r,n){try{var o=this,i="string"==typeof t;return Promise.resolve(o.getEndpoints(e)).then(function(s){return Promise.resolve(o.getServiceEndpoints(e,s)).then(function(a){var c=o.getEndpointURL(a,"computeStreamableLogs")?o.getEndpointURL(a,"computeStreamableLogs").urlPath:null;return c?Promise.resolve(o.getConsumerAddress(t)).then(function(u){return Promise.resolve(o.getNonce(e,u,n,s,a)).then(function(e){function s(){var e;function r(t){var r,n;if(null!=(r=e)&&r.ok||200===(null==(n=e)?void 0:n.status))return console.log("Response body:",e.body),e.body;var o=he.error,i=e.statusText,s=e.status;return Promise.resolve(e.json()).then(function(e){return o.call(he,"computeStreamableLogs failed: ",s,i,e),null})}var i=gt(function(){return Promise.resolve(ne.default(c+l,{method:"GET",headers:{"Content-Type":"application/json",Authorization:o.getAuthorization(t)},signal:n})).then(function(t){e=t,console.log("Raw response:",e)})},function(e){throw he.error("computeStreamableLogs failed:"),he.error(e),new Error("HTTP request failed calling Provider")});return i&&i.then?i.then(r):r()}var a=(e+1).toString(),l="?consumerAddress="+u+"&jobId="+r,d=function(){if(!i)return Promise.resolve(o.getSignature(t,""+u+r+a)).then(function(e){l+="&signature="+e,l+="&nonce="+a})}();return d&&d.then?d.then(s):s()})}):(he.error("Compute start failed: Cannot get proper computeStreamableLogs route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.getComputeStartRoutes=function(e,t){void 0===t&&(t=!1);try{var r=this;return Promise.resolve(r.getEndpoints(e)).then(function(n){return Promise.resolve(r.getServiceEndpoints(e,n)).then(function(e){return t?r.getEndpointURL(e,"freeCompute")?r.getEndpointURL(e,"freeCompute").urlPath:null:r.getEndpointURL(e,"computeStart")?r.getEndpointURL(e,"computeStart").urlPath:null})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(t)).then(function(s){return Promise.resolve(i.getServiceEndpoints(t,s)).then(function(a){var c=i.getEndpointURL(a,"computeStop")?i.getEndpointURL(a,"computeStop").urlPath:null;return Promise.resolve(i.getConsumerAddress(r)).then(function(u){return Promise.resolve(i.getNonce(t,u,o,s,a)).then(function(t){var s=(t+1).toString();return Promise.resolve(i.getSignature(r,u+(e||""))).then(function(t){function a(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw he.error("Compute stop failed: ",d.status,d.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=d)&&e.ok)return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var l=new URLSearchParams;l.set("consumerAddress",u),l.set("signature",t),l.set("nonce",s),l.set("jobId",e),n&&l.set("agreementId",n);var d,h=l.toString();if(!h)return null;var f=gt(function(){return Promise.resolve(ne.default(c+"?"+h,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:i.getAuthorization(r)},signal:o})).then(function(e){d=e})},function(e){throw he.error("Compute stop failed:"),he.error(e),new Error("HTTP request failed calling Provider")});return f&&f.then?f.then(a):a()})})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,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){function a(e){var t;function r(e){var r;if(t)return e;function n(e){return r?e:Promise.resolve(c.json()).then(function(e){throw he.error("Get compute status failed:",c.status,c.statusText,e),new Error(JSON.stringify(e))})}he.error("Get compute status failed:",c.status,c.statusText);var o=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var n=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var c,u=s.getEndpointURL(e,"computeStatus")?s.getEndpointURL(e,"computeStatus").urlPath:null,l="?consumerAddress="+t;if(l+=n&&"&agreementId="+n||"",l+=r&&"&jobId="+r||"",!u)return null;var d=gt(function(){return console.log("computeStatusUrl: ",u+l),Promise.resolve(ne.default(u+l,{method:"GET",headers:{"Content-Type":"application/json",Authorization:i},signal:o})).then(function(e){c=e})},function(e){throw he.error("Get compute status failed"),he.error(e),new Error(e)});return d&&d.then?d.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getComputeResultUrl=function(e,t,r,n){try{var o=this,i="string"==typeof t;return Promise.resolve(o.getEndpoints(e)).then(function(s){return Promise.resolve(o.getServiceEndpoints(e,s)).then(function(a){var c=o.getEndpointURL(a,"computeResult")?o.getEndpointURL(a,"computeResult").urlPath:null;return Promise.resolve(o.getConsumerAddress(t)).then(function(u){return Promise.resolve(o.getNonce(e,u,null,s,a)).then(function(e){var s=(e+1).toString(),a=u;return a+=r,a+=n.toString(),a+=s,Promise.resolve(o.getSignature(t,a)).then(function(e){if(!c)return null;var t=c;return t+="?consumerAddress="+u,t+="&jobId="+r,t+="&index="+n.toString(),i||(t+="&nonce="+s,t+="&signature="+e),t})})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(n)).then(function(s){return Promise.resolve(i.getServiceEndpoints(n,s)).then(function(a){var c=i.getEndpointURL(a,"computeDelete")?i.getEndpointURL(a,"computeDelete").urlPath:null;return Promise.resolve(i.getConsumerAddress(t)).then(function(u){return Promise.resolve(i.getNonce(n,u,o,s,a)).then(function(n){var s=(n+1).toString(),a=u;return a+=r||"",a+=e&&""+i.noZeroX(e)||"",a+=s,Promise.resolve(i.getSignature(t,a)).then(function(n){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw he.error("Delete compute job failed:",a.status,a.statusText,e),he.error("Payload was:",l),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,l=Object();if(l.documentId=e,l.consumerAddress=u,l.jobId=r,n&&(l.signature=n),!c)return null;var d=gt(function(){return Promise.resolve(ne.default(c,{method:"DELETE",body:JSON.stringify(l),headers:{"Content-Type":"application/json",Authorization:i.getAuthorization(t)},signal:o})).then(function(e){a=e})},function(e){throw he.error("Delete compute job failed:"),he.error(e),he.error("Payload was:",l),new Error("HTTP request failed calling Provider")});return d&&d.then?d.then(s):s()})})})})})}catch(e){return Promise.reject(e)}},t.generateAuthToken=function(e,t,r){try{var n=this;return Promise.resolve(e.getAddress()).then(function(o){return Promise.resolve(n.getEndpoints(t)).then(function(i){return Promise.resolve(n.getServiceEndpoints(t,i)).then(function(s){var a=n.getEndpointURL(s,"generateAuthToken").urlPath||null;return Promise.resolve(n.getNonce(t,o,r,i,s)).then(function(t){var i=(t+1).toString();return Promise.resolve(n.signProviderRequest(e,o+i)).then(function(e){return gt(function(){return Promise.resolve(ne.default(a,{method:"POST",body:JSON.stringify({address:o,signature:e,nonce:i}),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){if(null==e||!e.ok)throw new Error("Failed to generate auth token: "+e.status+" "+e.statusText);return Promise.resolve(e.json()).then(function(e){return null==e?void 0:e.token})})},function(e){throw he.error("Generate auth token failed:"),he.error(e),new Error("HTTP request failed calling Provider")})})})})})})}catch(e){return Promise.reject(e)}},t.invalidateAuthToken=function(e,t,r,n){try{var o=this;return Promise.resolve(e.getAddress()).then(function(i){return Promise.resolve(o.getEndpoints(r)).then(function(s){return Promise.resolve(o.getServiceEndpoints(r,s)).then(function(a){var c=o.getEndpointURL(a,"invalidateAuthToken").urlPath||null;return Promise.resolve(o.getNonce(r,i,n,s,a)).then(function(r){var s=(r+1).toString();return Promise.resolve(o.signProviderRequest(e,i+s)).then(function(e){return gt(function(){return Promise.resolve(ne.default(c,{method:"POST",body:JSON.stringify({address:i,signature:e,token:t,nonce:s}),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){if(null==e||!e.ok)throw new Error("Failed to invalidate auth token: "+e.status+" "+e.statusText);return Promise.resolve(e.json())})},function(e){throw he.error("Generate auth token failed:"),he.error(e),new Error("HTTP request failed calling Provider")})})})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(gt(function(){return Promise.resolve(ne.default(e,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t,r=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){if(e&&(e.providerAddress||e.providerAddresses))return t=!0})}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return he.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},t.PolicyServerPassthrough=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(e)).then(function(o){return Promise.resolve(n.getServiceEndpoints(e,o)).then(function(e){function o(e){var r;function n(e){return r?e:Promise.resolve(i.json()).then(function(e){throw he.error("PolicyServerPassthrough failed: ",i.status,i.statusText,e),he.error("Payload was:",JSON.stringify(t)),new Error(JSON.stringify(e))})}var o=function(e){if(null!=(e=i)&&e.ok)return Promise.resolve(i.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var i,s=n.getEndpointURL(e,"PolicyServerPassthrough")?n.getEndpointURL(e,"PolicyServerPassthrough").urlPath:null;if(!s)return null;var a=gt(function(){return Promise.resolve(ne.default(s,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return i=e,function(){if(!i.ok)return Promise.resolve(i.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw he.error("PolicyServerPassthrough failed: "),he.error(e),new Error("PolicyServerPassthrough failed: "+e.message+".")});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.initializePSVerification=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(e)).then(function(o){return Promise.resolve(n.getServiceEndpoints(e,o)).then(function(e){function o(e){var r;function n(e){return r?e:Promise.resolve(i.json()).then(function(e){throw he.error("initializePSVerification failed: ",i.status,i.statusText,e),he.error("Payload was:",JSON.stringify(t)),new Error(JSON.stringify(e))})}var o=function(e){if(null!=(e=i)&&e.ok)return Promise.resolve(i.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var i,s=n.getEndpointURL(e,"initializePSVerification")?n.getEndpointURL(e,"initializePSVerification").urlPath:null;if(!s)return null;var a=gt(function(){return Promise.resolve(ne.default(s,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return i=e,function(){if(!i.ok)return Promise.resolve(i.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw he.error("initializePSVerification failed: "),he.error(e),new Error("initializePSVerification failed: "+e.message+".")});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.noZeroX=function(e){return this.zeroXTransformer(e,!1)},t.zeroXTransformer=function(e,t){void 0===e&&(e="");var r=this.inputMatch(e,/^(?:0x)*([a-f0-9]+)$/i,"zeroXTransformer");return(t&&r.valid?"0x":"")+r.output},t.inputMatch=function(e,t,r){if("string"!=typeof e)throw he.debug("Not input string:"),he.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(he.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},t.getData=function(e,t){try{return Promise.resolve(ne.default(e,{method:"GET",headers:{"Content-type":"application/json",Authorization:t}}))}catch(e){return Promise.reject(e)}},e}(),Pt=new pt,yt=function(e,t,r,o){try{var i=new n.ethers.Contract(t,pe,e);return Promise.resolve(i.allowance(r,o))}catch(e){return Promise.reject(e)}},wt=function(e,t,r,o,i){try{var s=new n.ethers.Contract(t,pe,e);return Promise.resolve(s.allowance(r,o)).then(function(r){return Promise.resolve(we(e,t,r,i))})}catch(e){return Promise.reject(e)}},kt=function(e,t,r,o,i,s,a,c){void 0===a&&(a=!1);try{var u,l=function(r){if(u)return r;var n=null;return Promise.resolve(d.estimateGas.approve(i,s)).then(function(r){if(c)return r;var o=function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return Promise.resolve(Pe(r,e,null==t?void 0:t.gasFeeMultiplier,d.approve,i,s)).then(function(e){n=e})},function(e){he.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},d=new n.ethers.Contract(o,pe,e),h=function(){if(!a)return Promise.resolve(yt(e,o,r,i)).then(function(e){if(n.ethers.BigNumber.from(e).gt(n.ethers.BigNumber.from(s))){var t=n.ethers.BigNumber.from(e);return u=1,t}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},bt=function(e,t,r,o,i,s,a,c,u){void 0===a&&(a=!1);try{var l,d=function(r){return l?r:Promise.resolve(ye(e,o,s,c)).then(function(r){return Promise.resolve(h.estimateGas.approve(i,r)).then(function(n){return u?new L.default(n.toString()):Promise.resolve(Pe(n,e,null==t?void 0:t.gasFeeMultiplier,h.approve,i,r))})})},h=new n.ethers.Contract(o,pe,e),f=function(){if(!a)return Promise.resolve(wt(e,o,r,i)).then(function(e){if(new L.default(e).greaterThanOrEqualTo(new L.default(s))){var t=new L.default(e).toNumber();return l=1,t}})}();return Promise.resolve(f&&f.then?f.then(d):d(f))}catch(e){return Promise.reject(e)}},Tt={datasets:{invalid:"Datasets is not a list, as expected"},algorithm:{serviceId:{missing:"The serviceId key is missing from the algorithm s DDO.",not_found:"The provided serviceId does not exist.",service_not_access_compute:"Service type is neither access, nor compute.",main_service_compute:"If the main service is not compute for this asset when calling initialize endpoint.",compute_services_not_in_same_provider:"Files attached to the compute service are not decrypted by the correct provider. This occurs when both asset and algorithm are requested by their compute service which cannot be decrypted by a single provider as how it is supposed to be."},container:{checksum_prefix:"Container checksum does not start with the prefix sha256:.",mising_entrypoint_image_checksum:"Either entrypoint, either image, or either checksum are missing from the container dictionary from the algorithm s DDO."},documentId:{did_not_found:"The algorithm s DID could not be retrieved from the metadata store, because the algorithm asset does not exist.",missing:"The documentId key is missing from the algorithm s DDO."},transferTxId:{missing:"The transferTxId key is missing from the algorithm s DDO."},missing_meta_documentId:"Either algorithm metadata, or algorithm DID are missing.",did_not_found:"Either algorithm metadata, or algorithm DID are missing.",not_algo:"Either algorithm metadata, or algorithm DID are missing.",in_use_or_not_on_chain:"Either algorithm metadata, or algorithm DID are missing.",meta_oneof_url_rawcode_remote:"Either algorithm metadata, or algorithm DID are missing.",file_unavailable:"One possibility is that the asset could not be retrieved from Aquariuss database. Otherwise, there are issues related to services"},error:{not_trusted_algo_publisher:"The owner of the algorithm's DDO is not a trusted algorithms publishers list.",not_trusted_algo:"The algorithm's DID is not in the asset's trusted algorithms dictionary. ",no_publisherTrustedAlgorithms:"The algorithm's key publisherTrustedAlgorithms does not exist in the algorithm's DDO.",algorithm_file_checksum_mismatch:"filesChecksum from the algorithm's DDO is invalid.",algorithm_container_checksum_mismatch:"The containerChecksum from the algorithm's DDO is invalid.",no_raw_algo_allowed:"The asset does not allow raw algorithms to be run on it.","Asset malformed":"The asset published on chain is malformed, missing some required keys or not compliant with our schemas.","Asset is not consumable.":"Assets metadata status is not in the range of valid status codes for assets. The recognized states for the metadata are defined on our docs.","DID is not a valid algorithm.":"Either the algorithm assets DID is incorrectly typed, either the algorithm timeout expired.","Compute environment does not exist.":"The compute environment provided by the user does not exist, it is not served by our compute-to-data feature. The user can use get_c2d_environments to check the list of available compute environments.","The validUntil value is not correct.":"validUntil value is most probably expired.","Cannot resolve DID":"The dataset DID does not exist in the Metadata store.","Invalid serviceId":"The serviceId of that dataset is not correct.","Unable to get dataset files":"The files of that dataset could not be decrypted or retrieved","cannot decrypt files for this service.":"The files of that dataset could not be decrypted due to the fact that file object, which contains the structure and the type of specific file, is missing from the validation part.","Unsupported type ":"The file object type is not supported by Provider.","malformed file object":"The file object structure is invalid and does not contain the wanted information for the specific file."},order:{fees_not_paid:" Provider fees are not paid."},output:{invalid:"The algorithms validation after the build stage has not been decoded properly as a dictionary."}};function At(e,t,r){if(!e.s){if(r instanceof St){if(!r.s)return void(r.o=At.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(At.bind(null,e,t),At.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var St=/*#__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{At(n,1,i(this.v))}catch(e){At(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?At(n,1,t?t(o):o):r?At(n,1,r(o)):At(n,2,o)}catch(e){At(n,2,e)}},n},e}();function Et(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}e.AccessListContract=Ze,e.AccesslistFactory=Xe,e.Aquarius=vt,e.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.oceanNodeUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.nftFactoryAddress=void 0,this.routerFactoryAddress=void 0,this.datatokensABI=void 0,this.fixedRateExchangeAddress=void 0,this.fixedRateExchangeAddressABI=void 0,this.dispenserAddress=void 0,this.dispenserABI=void 0,this.opfCommunityFeeCollector=void 0,this.EnterpriseFeeCollector=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.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0,this.veAllocate=void 0,this.veOCEAN=void 0,this.veDelegation=void 0,this.veFeeDistributor=void 0,this.veDelegationProxy=void 0,this.DFRewards=void 0,this.DFStrategyV1=void 0,this.veFeeEstimate=void 0,this.sdk=void 0,this.accessListFactory=void 0},e.ConfigHelper=ge,e.DEVELOPMENT_CHAIN_ID=8996,e.Datatoken=Ve,e.Datatoken4=He,e.DfRewards=rt,e.DfStrategyV1=it,e.Dispenser=Oe,e.EscrowContract=ct,e.FEE_HISTORY_NOT_SUPPORTED="Returned error: Method eth_feeHistory not supported.",e.FixedRateExchange=Ne,e.GASLIMIT_DEFAULT=1e6,e.KNOWN_CONFIDENTIAL_EVMS=ve,e.Logger=de,e.LoggerInstance=he,e.MAX_UINT_256="115792089237316195423570985008687907853269984665640564039457584007913129639934",e.Nft=We,e.NftFactory=_e,e.Provider=pt,e.ProviderInstance=Pt,e.Router=Ue,e.SmartContract=xe,e.SmartContractWithAddress=Me,e.VeAllocate=Qe,e.VeFeeDistributor=$e,e.VeFeeEstimate=Ye,e.VeOcean=Ke,e.ZERO_ADDRESS=Re,e.allowance=wt,e.allowanceWei=yt,e.amountToUnits=ye,e.approve=bt,e.approveWei=kt,e.balance=function(e,t,r,o){try{var i=new n.ethers.Contract(t,pe,e);return Promise.resolve(i.balanceOf(r)).then(function(r){return Promise.resolve(we(e,t,r,o))})}catch(e){return Promise.reject(e)}},e.configHelperNetworks=me,e.createAccessListFactory=function(e,t,r){try{var o=new n.ethers.Contract(e,X.default.abi,t);return Promise.resolve(t.getAddress()).then(function(e){var t,n=Et(function(){return Promise.resolve(o.deployAccessListContract("AllowList","ALLOW",!0,e,r||[e],["https://oceanprotocol.com/nft/"])).then(function(e){return function(){if(e&&e.wait)return Promise.resolve(e.wait()).then(function(e){var r=De(e,"NewAccessList");return t=1,r.args[0]})}()})},function(e){console.log("ERROR createAccessListFactory(): ",e)});return n&&n.then?n.then(function(e){return t?e:null}):t?n:null})}catch(e){return Promise.reject(e)}},e.createAsset=function(t,r,o,i,s,a,c,u,l,d,h,f,m){void 0===c&&(c=!0);try{var v,g,p=S.DDOManager.getDDOClass(a),P=p.getAssetFields().indexedMetadata,y=(null==(v=p.getDDOData())||null==(v=v.stats)||null==(v=v.price)?void 0:v.value)||(null==P||null==(g=P.stats[0])||null==(g=g.prices[0])?void 0:g.price),w=p.getDDOFields(),k=w.chainId,b=w.nftAddress,T=p.getDDOFields().services;if("string"!=typeof s&&"number"!=typeof s)throw new Error('Invalid template! Must be a "number" or a "string"');return Promise.resolve(o.provider.getNetwork()).then(function(v){var g=v.chainId;if(k&&k!==g)throw new Error("Chain ID from DDO is different than the configured network.");var P=(new ge).getConfig(parseInt(String(g)));return Promise.resolve(Je(o,P.nftFactoryAddress,s,g)).then(function(s){if(s<1){if(8996!==g)throw new Error("Invalid template index: "+s);s=1}var v=new We(o,g),w=new _e(P.nftFactoryAddress,o,g);return Promise.resolve(o.getAddress()).then(function(A){var S,E;function F(e){return E?e:Promise.resolve(D.wait()).then(function(e){var t;function r(e){if(t)return e;function r(){function e(){var e=v.setMetadata,s=b;return Promise.resolve(o.getAddress()).then(function(o){return Promise.resolve(e.call(v,s,o,0,u,"",n.ethers.utils.hexlify(i),t,r)).then(function(){return a.id})})}T[0].datatokenAddress=f,T[0].serviceEndpoint=u;var t,r,i,s=p.makeDid(b=h,k.toString());a=p.updateFields({id:s,nftAddress:b});var l=function(){if(c)return Promise.resolve(Pt.encrypt(a,g,u)).then(function(e){return t=e,Promise.resolve(d.validate(a,o,u)).then(function(e){r=e.hash,i=2})});var e=JSON.stringify(a),n=Buffer.from(e);t=j.hexlify(n),r="0x"+C.createHash("sha256").update(t).digest("hex"),i=0}();return l&&l.then?l.then(e):e()}var s=function(){if("oasis"!==P.sdk)return Promise.resolve(Pt.encrypt(i,g,u)).then(function(e){T[0].files=e});T[0].files=""}();return s&&s.then?s.then(r):r()}var s=De(e,"NFTCreated"),l=De(e,"TokenCreated"),h=s.args.newTokenAddress,f=l.args.newTokenAddress;i.datatokenAddress=f,i.nftAddress=h;var m=function(){if("oasis"===P.sdk){var e=new n.ethers.Contract(f,H.default.abi,o);return Et(function(){return Promise.resolve(e.setFilesObject(n.ethers.utils.toUtf8Bytes(JSON.stringify(i)))).then(function(e){var t=function(){if(e.wait)return Promise.resolve(e.wait()).then(function(){})}();if(t&&t.then)return t.then(function(){})})},function(e){return console.log("Error updating files object with data token and nft addresses: ",e),t=1,null})}}();return m&&m.then?m.then(r):r(m)})}var D,x={name:t,symbol:r,templateIndex:1,tokenURI:"aaa",transferable:!0,owner:A},M={templateIndex:s,cap:"100000",feeAmount:"0",paymentCollector:A,feeToken:l||P.oceanTokenAddress,minter:A,mpFeeAddress:Re};null!=i&&i.files[0].type&&[e.FileObjectType.ARWEAVE,e.FileObjectType.IPFS,e.FileObjectType.URL].includes(null==i||null==(S=i.files[0])||null==(S=S.type)?void 0:S.toLowerCase())||(console.log('Missing or invalid files object type, defaulting to "url"'),i.type=e.FileObjectType.URL),"oasis"===P.sdk&&(M.filesObject=i,M.accessListFactory=h||P.accessListFactory,M.allowAccessList=f,M.denyAccessList=m);var O=Et(function(){var e=function(){if(!y)return Promise.resolve(w.createNftWithDatatoken(x,M)).then(function(e){D=e});var e=function(){if("0"===y.toString())return Promise.resolve(w.createNftWithDatatokenWithDispenser(x,M,{dispenserAddress:P.dispenserAddress,maxTokens:"1",maxBalance:"100000000",withMint:!0,allowedSwapper:Re})).then(function(e){D=e});var e={fixedRateAddress:P.fixedRateExchangeAddress,baseTokenAddress:P.oceanTokenAddress,owner:A,marketFeeCollector:A,baseTokenDecimals:18,datatokenDecimals:18,fixedRate:y.toString(),marketFee:"0",allowedConsumer:A,withMint:!0};return Promise.resolve(w.createNftWithDatatokenWithFixedRate(x,M,e)).then(function(e){D=e})}();return e&&e.then?e.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})},function(e){return console.log("ERROR creating NFT bundle",e),E=1,null});return O&&O.then?O.then(F):F(O)})})})}catch(e){return Promise.reject(e)}},e.decimals=function(e,t){try{var r=new n.ethers.Contract(t,pe,e);return Promise.resolve(r.decimals())}catch(e){return Promise.reject(e)}},e.downloadFile=function(e,t){try{return Promise.resolve(fetch(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)}},e.downloadFileBrowser=function(e){var t=new XMLHttpRequest;t.responseType="blob",t.open("GET",e),t.onload=function(){var e=t.getResponseHeader("content-disposition"),r=null==e?void 0:e.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/),n=r&&r[1]?r[1]:"file",o=window.URL.createObjectURL(t.response),i=document.createElement("a");i.href=o,i.setAttribute("download",n),document.body.appendChild(i),i.click(),i.remove(),window.URL.revokeObjectURL(o)},t.send()},e.generateDid=function(e,t){return e=n.ethers.utils.getAddress(e),"did:op:"+ie.default(e+t.toString(10)).toString()},e.generateDtName=Le,e.getErrorMessage=function(e){try{var t=JSON.parse(e),r=Object.keys(t)[0];if("error"===r){var n,o=t[r];return(null==(n=Tt[r])?void 0:n[o])||"Provider request failed: "+o}var i=t[r];return t[Object.keys(t)[1]]+" : "+i}catch(t){return he.error("[getErrorMessage] error: ",t),e}},e.getEventFromTx=De,e.getFairGasPrice=be,e.getHash=function(e){return ie.default(e).toString()},e.getTokenDecimals=ke,e.isDefined=function(e){return null!=e},e.minAbi=pe,e.orderAsset=function(e,t,r,n,o,i,s,a,c,u,l,d){void 0===c&&(c="0"),void 0===u&&(u=0),void 0===l&&(l=0),void 0===d&&(d=0);try{var h=S.DDOManager.getDDOClass(e),f=h.getAssetFields().datatokens,m=h.getDDOFields(),v=m.chainId,g=m.services;return s||(s={consumeMarketFeeAddress:"0x0000000000000000000000000000000000000000",consumeMarketFeeAmount:"0",consumeMarketFeeToken:"0x0000000000000000000000000000000000000000"}),Promise.resolve(t.provider.getNetwork()).then(function(h){if(v!==h.chainId)throw new Error("Chain ID from DDO is different than the configured network.");if(!f[u].address)throw new Error("The datatoken with index: "+u+" does not exist for the asset with did: "+e.id);if(!g[l].id)throw new Error("There is no service with index: "+l+" defined for the asset with did: "+e.id);return Promise.resolve(n.getId(f[u].address)).then(function(h){return Promise.resolve(n.getFixedRates(f[u].address)).then(function(m){return Promise.resolve(n.getDispensers(f[u].address)).then(function(v){return Promise.resolve(n.getPublishingMarketFee(f[u].address)).then(function(p){function P(e){return a?e:Promise.resolve(k.call(Pt,T,b,0,e,o||r.oceanNodeUri)).then(y)}function y(o){function v(o){function a(o){var i,a={consumer:o,serviceIndex:l,_providerFee:P,_consumeMarketFee:s};return function(e,t){var r,n=-1;e:{for(var o=0;o<t.length;o++){var i=t[o][0];if(i){var s=i();if(s&&s.then)break e;if(s===e){n=o;break}}else n=o}if(-1!==n){do{for(var a=t[n][1];!a;)n++,a=t[n][1];var c=a();if(c&&c.then){r=!0;break e}var u=t[n][2];n++}while(u&&!u());return c}}var l=new St,d=At.bind(null,l,2);return(r?c.then(h):s.then(function r(s){for(;;){if(s===e){n=o;break}if(++o===t.length){if(-1!==n)break;return void At(l,1,c)}if(i=t[o][0]){if((s=i())&&s.then)return void s.then(r).then(void 0,d)}else n=o}do{for(var a=t[n][1];!a;)n++,a=t[n][1];var c=a();if(c&&c.then)return void c.then(h).then(void 0,d);var u=t[n][2];n++}while(u&&!u());At(l,1,c)})).then(void 0,d),l;function h(e){for(;;){var r=t[n][2];if(!r||r())break;n++;for(var o=t[n][1];!o;)n++,o=t[n][1];if((e=o())&&e.then)return void e.then(h).then(void 0,d)}At(l,1,e)}}(w,[[function(){return"free"},function(){var e=function(e){var t;if(i)return e;function o(e){if(t)return e}var s=function(){if(2===h||4===h)return Promise.resolve(n.buyFromDispenserAndOrder(g[l].datatokenAddress,a,r.dispenserAddress)).then(function(e){return t=1,e})}();return s&&s.then?s.then(o):o(s)},o=function(){if(1===h){var e=new Oe(r.dispenserAddress,t),o=e.dispense,s=f[u].address;return Promise.resolve(t.getAddress()).then(function(t){return Promise.resolve(o.call(e,s,"1",t)).then(function(e){if(!e)throw new Error("Failed to dispense !");return Promise.resolve(e.wait()).then(function(){return Promise.resolve(n.startOrder(f[u].address,a.consumer,a.serviceIndex,a._providerFee,a._consumeMarketFee)).then(function(e){return i=1,e})})})})}}();return o&&o.then?o.then(e):e(o)}],[function(){return"fixed"},function(){var o=new Ne(r.fixedRateExchangeAddress,t);if(!m[d].id)throw new Error("There is no fixed rate exchange with index: "+l+" for the asset with did: "+e.id);return Promise.resolve(o.getFeesInfo(m[d].id)).then(function(e){return Promise.resolve(o.getExchange(m[d].id)).then(function(i){return Promise.resolve(o.calcBaseInGivenDatatokensOut(e.exchangeId,"1",s.consumeMarketFeeAmount)).then(function(l){var d;function m(e){var o;if(d)return e;function s(e){if(o)return e}var c=function(){if(2===h||4===h)return Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(bt(t,r,e,i.baseToken,f[u].address,v,!1)).then(function(e){function t(e){if(!e)throw new Error("Failed to confirm/mine approval transaction!");return Promise.resolve(n.buyFromFreAndOrder(f[u].address,a,g)).then(function(e){return o=1,e})}if(!e)throw new Error("Failed to approve "+i.baseToken+" !");return"number"!=typeof e?Promise.resolve("number"!=typeof e?e.wait():e).then(t):t("number"!=typeof e?e.wait():e)})})}();return c&&c.then?c.then(s):s(c)}var v=new L.default(+l.baseTokenAmount||0).add(new L.default(s.consumeMarketFeeAmount||0)).add(new L.default(+p.publishMarketFeeAmount||0)).toString(),g={exchangeContract:r.fixedRateExchangeAddress,exchangeId:e.exchangeId,maxBaseTokenAmount:v,baseTokenAddress:i.baseToken,baseTokenDecimals:parseInt(i.btDecimals)||18,swapMarketFee:c,marketFeeAddress:p.publishMarketFeeAddress},P=function(){if(1===h)return Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(bt(t,r,e,i.baseToken,r.fixedRateExchangeAddress,v,!1)).then(function(e){function t(e){if(!e)throw new Error("Failed to approve "+i.baseToken+" !");return Promise.resolve(o.buyDatatokens(i.exchangeId,"1",v,p.publishMarketFeeAddress,c)).then(function(e){return Promise.resolve(e.wait()).then(function(e){if(!e)throw new Error("Failed to buy datatoken from fixed rate!");return Promise.resolve(n.startOrder(f[u].address,a.consumer,a.serviceIndex,a._providerFee,a._consumeMarketFee)).then(function(e){return d=1,e})})})}return"number"!=typeof e?Promise.resolve("number"!=typeof e?e.wait():e).then(t):t("number"!=typeof e?e.wait():e)})})}();return P&&P.then?P.then(m):m(P)})})})}],[void 0,function(){throw new Error("Pricing schema not supported !")}]])}return i?a(i):Promise.resolve(t.getAddress()).then(a)}var P=a||o.providerFee,y=function(){if(P&&P.providerFeeAddress!==Re&&P.providerFeeAmount&&parseInt(P.providerFeeAmount)>0)return function(e,n){try{var o=Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(kt(t,r,e,P.providerFeeToken,g[0].datatokenAddress,P.providerFeeAmount)).then(function(){})})}catch(e){return n()}return o&&o.then?o.then(void 0,n):o}(0,function(){throw new Error("Failed to approve provider fee token "+P.providerFeeToken)})}();return y&&y.then?y.then(v):v()}var w=m.length>0?"fixed":v.length>0?"free":"NOT_ALLOWED",k=a||Pt.initialize,b=a||g[l].id,T=a||e.id;return a?P(y(a)):Promise.resolve(t.getAddress()).then(P)})})})})})}catch(e){return Promise.reject(e)}},e.sendTx=Pe,e.setContractDefaults=Ce,e.signHash=function(e,t){try{var r=n.ethers.utils.arrayify(t);return Promise.resolve(e._legacySignMessage(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)}},e.signRequest=lt,e.sleep=ut,e.transfer=function(e,t,r,o,i,s){try{var a=new n.ethers.Contract(r,pe,e);return Promise.resolve(ye(e,r,i)).then(function(r){return Promise.resolve(a.estimateGas.transfer(o,r)).then(function(n){return s?n:Promise.resolve(Pe(n,e,null==t?void 0:t.gasFeeMultiplier,a.transfer,o,r))})})}catch(e){return Promise.reject(e)}},e.unitsToAmount=we,e.useOasisSDK=function(e){var t=(new ge).getConfig(e);return t&&"oasis"===t.sdk}});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@oceanprotocol/contracts/addresses/address.json"),require("fs"),require("ethers"),require("@oasisprotocol/sapphire-paratime"),require("decimal.js"),require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),require("@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json"),require("@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json"),require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json"),require("@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json"),require("@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json"),require("@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json"),require("@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json"),require("@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json"),require("@oceanprotocol/contracts/artifacts/contracts/escrow/Escrow.sol/Escrow.json"),require("@oceanprotocol/contracts/artifacts/contracts/communityFee/EnterpriseFeeCollector.sol/EnterpriseFeeCollector.json"),require("cross-fetch"),require("@oceanprotocol/ddo-js"),require("jsonwebtoken"),require("crypto-js/sha256.js"),require("ethers/lib/utils.js"),require("crypto")):"function"==typeof define&&define.amd?define(["exports","@oceanprotocol/contracts/addresses/address.json","fs","ethers","@oasisprotocol/sapphire-paratime","decimal.js","@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json","@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json","@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json","@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json","@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json","@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json","@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json","@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json","@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json","@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json","@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json","@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json","@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json","@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json","@oceanprotocol/contracts/artifacts/contracts/escrow/Escrow.sol/Escrow.json","@oceanprotocol/contracts/artifacts/contracts/communityFee/EnterpriseFeeCollector.sol/EnterpriseFeeCollector.json","cross-fetch","@oceanprotocol/ddo-js","jsonwebtoken","crypto-js/sha256.js","ethers/lib/utils.js","crypto"],t):t((e||self).lib={},e.DefaultContractsAddresses,e.fs,e.ethers,e.sapphire,e.Decimal,e.DispenserAbi,e.FixedRateExchangeAbi,e.FactoryRouter,e.ERC20Template$1,e.ERC20TemplateEnterprise,e.ERC721Template,e.ERC721Factory,e.ERC20Template,e.ERC20Template4,e.AccessList,e.AccessListFactory,e.veOceanABI,e.veFeeABI,e.veFeeEstimate,e.veAllocateABI,e.dfRewardsABI,e.dfStrategyV1ABI,e.Escrow,e.ContractABI,e.crossFetch,e.ddoJs,e.jsonwebtoken,e.sha256,e.utils_js,e.crypto)}(this,function(e,t,r,n,o,i,s,a,c,u,l,d,h,f,m,v,g,p,P,y,w,k,b,T,A,F,S,E,j,C,D){function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function M(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,t}var O,R,N,U=/*#__PURE__*/x(t),I=/*#__PURE__*/x(r),L=/*#__PURE__*/M(o),G=/*#__PURE__*/x(i),_=/*#__PURE__*/x(s),B=/*#__PURE__*/x(a),q=/*#__PURE__*/x(c),z=/*#__PURE__*/x(u),J=/*#__PURE__*/x(l),W=/*#__PURE__*/x(d),V=/*#__PURE__*/x(h),H=/*#__PURE__*/x(f),Z=/*#__PURE__*/x(m),X=/*#__PURE__*/x(v),K=/*#__PURE__*/x(g),$=/*#__PURE__*/x(p),Y=/*#__PURE__*/x(P),Q=/*#__PURE__*/x(y),ee=/*#__PURE__*/x(w),te=/*#__PURE__*/x(k),re=/*#__PURE__*/x(b),ne=/*#__PURE__*/x(T),oe=/*#__PURE__*/x(A),ie=/*#__PURE__*/x(F),se=/*#__PURE__*/x(E),ae=/*#__PURE__*/x(j);function ce(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ue(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 ce(e,t);var r={}.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)?ce(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.")}function le(){return le=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},le.apply(null,arguments)}function de(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,he(e,t)}function he(e,t){return he=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},he(e,t)}e.FileObjectType=void 0,(O=e.FileObjectType||(e.FileObjectType={})).URL="url",O.IPFS="ipfs",O.ARWEAVE="arweave",e.EncryptMethod=void 0,(R=e.EncryptMethod||(e.EncryptMethod={})).AES="AES",R.ECIES="ECIES",e.LogLevel=void 0,(N=e.LogLevel||(e.LogLevel={}))[N.None=-1]="None",N[N.Error=0]="Error",N[N.Warn=1]="Warn",N[N.Log=2]="Log",N[N.Verbose=3]="Verbose";var fe=/*#__PURE__*/function(){function t(t){this.logLevel=void 0,this.logLevel=t,this.logLevel=t||e.LogLevel.Error}var r=t.prototype;return r.setLevel=function(e){this.logLevel=e},r.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},r.debug=function(){this.dispatch.apply(this,["debug",e.LogLevel.Verbose].concat([].slice.call(arguments)))},r.log=function(){this.dispatch.apply(this,["log",e.LogLevel.Log].concat([].slice.call(arguments)))},r.warn=function(){this.dispatch.apply(this,["warn",e.LogLevel.Warn].concat([].slice.call(arguments)))},r.error=function(){this.dispatch.apply(this,["error",e.LogLevel.Error].concat([].slice.call(arguments)))},r.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},t}(),me=new fe,ve={chainId:null,network:"unknown",nodeUri:"http://127.0.0.1:8545",oceanNodeUri:"https://1.c2d.nodes.oceanprotocol.com:8000/",explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},ge=[le({},ve),le({},ve,{chainId:8996,network:"development",oceanNodeUri:"https://1.c2d.nodes.oceanprotocol.com:8000/",sdk:"evm"}),le({},ve,{chainId:11155111,network:"sepolia",nodeUri:"https://sepolia.infura.io/v3",explorerUri:"https://sepolia.etherscan.io",gasFeeMultiplier:1.1,sdk:"evm"}),le({},ve,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05,sdk:"evm"}),le({},ve,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",gasFeeMultiplier:1.6,sdk:"evm"}),le({},ve,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com",sdk:"evm"}),le({},ve,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",explorerUri:"https://mumbai.polygonscan.com",gasFeeMultiplier:1.1,sdk:"evm"}),le({},ve,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05,sdk:"evm"}),le({},ve,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05,sdk:"evm"}),le({},ve,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",explorerUri:"https://moonriver.moonscan.io/",gasFeeMultiplier:1.05,sdk:"evm"}),le({},ve,{chainId:100,network:"gen-x-testnet",nodeUri:"https://rpc.genx.minimal-gaia-x.eu",explorerUri:"https://explorer.genx.minimal-gaia-x.eu/",gasFeeMultiplier:1,sdk:"evm"}),le({},ve,{chainId:10,network:"optimism",nodeUri:"https://mainnet.optimism.io",explorerUri:"https://optimistic.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),le({},ve,{chainId:11155420,network:"optimism_sepolia",nodeUri:"https://sepolia.optimism.io",explorerUri:"https://sepolia-optimism.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),le({},ve,{chainId:23294,network:"oasis_sapphire",nodeUri:"https://sapphire.oasis.io",explorerUri:"https://explorer.oasis.io/mainnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),le({},ve,{chainId:23295,network:"oasis_sapphire_testnet",nodeUri:"https://testnet.sapphire.oasis.dev",explorerUri:"https://explorer.oasis.io/testnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),le({},ve,{chainId:32456,network:"pontus-x-devnet",nodeUri:"https://rpc.dev.pontus-x.eu",explorerUri:"https://explorer.dev.pontus-x.eu/testnet/pontusx",sdk:"evm"})],pe=[23294,23295],Pe=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r,n=function(){return process.env.NODE_URL?{oceanNodeUri:process.env.NODE_URL}:{}};if(t&&t[e]){var o=t[e];r=le({nftFactoryAddress:o.ERC721Factory,opfCommunityFeeCollector:o.OPFCommunityFeeCollector,fixedRateExchangeAddress:o.FixedPrice,dispenserAddress:o.Dispenser,oceanTokenAddress:o.Ocean,routerFactoryAddress:o.Router,chainId:o.chainId,startBlock:o.startBlock,veAllocate:o.veAllocate,veOCEAN:o.veOCEAN,veDelegation:o.veDelegation,veFeeDistributor:o.veFeeDistributor,veDelegationProxy:o.veDelegationProxy,DFRewards:o.DFRewards,DFStrategyV1:o.DFStrategyV1,veFeeEstimate:o.veFeeEstimate,accessListFactory:o.AccessListFactory,EnterpriseFeeCollector:o.EnterpriseFeeCollector},n())}else if(U.default[e]){var i=U.default[e];r=le({nftFactoryAddress:i.ERC721Factory,opfCommunityFeeCollector:i.OPFCommunityFeeCollector,fixedRateExchangeAddress:i.FixedPrice,dispenserAddress:i.Dispenser,oceanTokenAddress:i.Ocean,routerFactoryAddress:i.Router,chainId:i.chainId,startBlock:i.startBlock,veAllocate:i.veAllocate,veOCEAN:i.veOCEAN,veDelegation:i.veDelegation,veFeeDistributor:i.veFeeDistributor,veDelegationProxy:i.veDelegationProxy,DFRewards:i.DFRewards,DFStrategyV1:i.DFStrategyV1,veFeeEstimate:i.veFeeEstimate,accessListFactory:i.AccessListFactory,EnterpriseFeeCollector:i.EnterpriseFeeCollector},n())}return r},t.getConfig=function(e,t){var r,n="string"==typeof e?"network":"chainId",o=ge.find(function(t){return t[n]===e});if(!o)return me.error("No config found for given network '"+e+"'"),null;try{r=process.env.ADDRESS_FILE?JSON.parse(I.default.readFileSync(process.env.ADDRESS_FILE,"utf8")):null}catch(e){console.log(e),r=null}var i=this.getAddressesFromEnv(o.network,r);return!i&&pe.includes(o.chainId)&&(i=this.getAddressesFromEnv(o.network.replace("sapph","saph"),r)),"sdk"in o&&null!==o.sdk||(o.sdk=pe.includes(o.chainId)?"oasis":"evm"),i&&"accessListFactory"in i&&(o.accessListFactory=i.accessListFactory),o=le({},o,i),le({},o,{nodeUri:t?o.nodeUri+"/"+t:o.nodeUri})},e}(),ye=[{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"}],we=function(e,t,r,n){try{var o=arguments;return Promise.resolve(t.provider.getNetwork()).then(function(i){var s=i.chainId;return Promise.resolve(t.provider.getFeeData()).then(function(t){var i={};if(t.maxPriorityFeePerGas){var a=t.maxPriorityFeePerGas.toString(),c=t.maxFeePerGas.toString();r>1&&(a=Math.round(t.maxPriorityFeePerGas.toNumber()*r).toString(),c=Math.round(t.maxFeePerGas.toNumber()*r).toString()),i={maxPriorityFeePerGas:(s===Ce||s===je)&&Number(a)<Fe?Fe:s===De&&Number(a)<Se?Se:pe.includes(s)&&Number(a)<Ee?Ee:Number(a),maxFeePerGas:(s===Ce||s===je)&&Number(c)<Fe?Fe:s===De&&Number(c)<Se?Se:pe.includes(s)&&Number(c)<Ee?Ee:Number(c)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),function(e,t){try{var r=Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i]))).then(function(e){return Promise.resolve(e.wait()).then(function(){return e})})}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(0,function(e){return me.error("Send tx error: ",e),null})})})}catch(e){return Promise.reject(e)}},ke=function(e,t,r,o){try{var i=function(e){return"0"===e&&(e=18),n.ethers.utils.parseUnits(r,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(Te(e,t)).then(i))}catch(e){return Promise.reject(e)}},be=function(e,t,r,o){try{var i=function(e){return"0"===e&&(e=18),n.ethers.utils.formatUnits(r,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(Te(e,t)).then(i))}catch(e){return Promise.reject(e)}},Te=function(e,t){try{var r=new n.ethers.Contract(t,ye,e);return Promise.resolve(r.decimals())}catch(e){return Promise.reject(e)}},Ae=function(e,t){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var r=n.ethers.BigNumber.from(e.toString());return t?r.mul(t).toBigInt().toString(10):r.toString()})})}catch(e){return Promise.reject(e)}},Fe=3e10,Se=4e9,Ee=1e10,je=137,Ce=80001,De=11155111;function xe(e,t){return e}function Me(e,t){var r;return null==e||null==(r=e.events)?void 0:r.filter(function(e){return e.event===t})[0]}var Oe=/*#__PURE__*/function(){function e(e,t,r,n){this.signer=void 0,this.config=void 0,this.abi=void 0,this.signer=e,this.config=r||(new Pe).getConfig(t),this.abi=n||this.getDefaultAbi()}var t=e.prototype;return t.getSignerAccordingSdk=function(){return this.config&&"sdk"in this.config&&"oasis"===this.config.sdk?L.wrap(this.signer):this.signer},t.amountToUnits=function(e,t,r){try{return Promise.resolve(ke(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t,r){try{return Promise.resolve(be(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.getFairGasPrice=function(){try{var e;return Promise.resolve(Ae(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},t.getContract=function(e,t){return xe(new n.ethers.Contract(e,new n.ethers.utils.Interface(JSON.stringify(t||this.abi)),this.signer))},e}(),Re=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,r,n,o,i)||this).address=void 0,s.contract=void 0,s.address=t,s.contract=s.getContract(s.address),s}return de(t,e),t}(Oe),Ne=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return _.default.abi},r.status=function(e){try{var t=this;return Promise.resolve(t.contract.status(e)).then(function(e){if(!e)throw new Error("Np dispenser found for the given datatoken address");var r=e.isMinter,n=e.owner,o=e.active;return Promise.resolve(t.unitsToAmount(null,e.maxTokens,18)).then(function(i){return Promise.resolve(t.unitsToAmount(null,e.maxBalance,18)).then(function(s){return Promise.resolve(t.unitsToAmount(null,e.balance,18)).then(function(t){return{active:o,owner:n,isMinter:r,maxTokens:i,maxBalance:s,balance:t,allowedSwapper:e.allowedSwapper}})})})})}catch(e){return Promise.reject(e)}},r.create=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.contract.estimateGas.create(e,s.amountToUnits(null,r,18),s.amountToUnits(null,n,18),t,o)).then(function(a){var c;return i?a:Promise.resolve(we(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.create,e,s.amountToUnits(null,r,18),s.amountToUnits(null,n,18),t,o))})}catch(e){return Promise.reject(e)}},r.activate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.activate(e,o.amountToUnits(null,t,18),o.amountToUnits(null,r,18))).then(function(i){var s;return n?i:Promise.resolve(we(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.activate,e,o.amountToUnits(null,t,18),o.amountToUnits(null,r,18)))})}catch(e){return Promise.reject(e)}},r.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.deactivate(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.deactivate,e))})}catch(e){return Promise.reject(e)}},r.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.setAllowedSwapper(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.setAllowedSwapper,e,t))})}catch(e){return Promise.reject(e)}},r.dispense=function(e,t,r,n){void 0===t&&(t="1");try{var o=this;return Promise.resolve(o.contract.estimateGas.dispense(e,o.amountToUnits(null,t,18),r)).then(function(i){var s;return n?i:Promise.resolve(we(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.dispense,e,o.amountToUnits(null,t,18),r))})}catch(e){return Promise.reject(e)}},r.ownerWithdraw=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.ownerWithdraw(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.ownerWithdraw,e))})}catch(e){return Promise.reject(e)}},r.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 G.default(e).greaterThanOrEqualTo(o.maxBalance)||new G.default(String(n)).greaterThan(o.maxTokens)||!new G.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(Re),Ue="0x0000000000000000000000000000000000000000",Ie=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return B.default.abi},r.generateExchangeId=function(e,t){try{return Promise.resolve(this.contract.generateExchangeId(e,t))}catch(e){return Promise.reject(e)}},r.buyDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=Ue),void 0===o&&(o="0");try{var s=this;return Promise.resolve(s.getExchange(e)).then(function(a){return Promise.resolve(s.amountToUnits(null,o,18)).then(function(o){return Promise.resolve(s.amountToUnits(a.datatoken,t,+a.dtDecimals)).then(function(t){return Promise.resolve(s.amountToUnits(a.baseToken,r,+a.btDecimals)).then(function(r){return Promise.resolve(s.contract.estimateGas.buyDT(e,t,r,n,o)).then(function(a){var c;return i?a:Promise.resolve(we(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.buyDT,e,t,r,n,o))})})})})})}catch(e){return Promise.reject(e)}},r.sellDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=Ue),void 0===o&&(o="0");try{var s=this;return Promise.resolve(s.getExchange(e)).then(function(a){return Promise.resolve(s.amountToUnits(null,o,18)).then(function(o){return Promise.resolve(s.amountToUnits(a.datatoken,t,+a.dtDecimals)).then(function(t){return Promise.resolve(s.amountToUnits(a.baseToken,r,+a.btDecimals)).then(function(r){return Promise.resolve(s.contract.estimateGas.sellDT(e,t,r,n,o)).then(function(a){var c;return i?a:Promise.resolve(we(a,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,s.contract.sellDT,e,t,r,n,o))})})})})})}catch(e){return Promise.reject(e)}},r.getNumberOfExchanges=function(){try{return Promise.resolve(this.contract.getNumberOfExchanges())}catch(e){return Promise.reject(e)}},r.setRate=function(e,t,r){try{var n=this,o=n.contract.estimateGas,i=o.setRate;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(s){return Promise.resolve(i.call(o,e,s)).then(function(o){var i;if(r)return o;var s=n.contract.setRate,a=null==(i=n.config)?void 0:i.gasFeeMultiplier,c=n.getSignerAccordingSdk();return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(we(o,c,a,s,e,t))})})})}catch(e){return Promise.reject(e)}},r.setAllowedSwapper=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.setAllowedSwapper(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.setAllowedSwapper,e,t))})}catch(e){return Promise.reject(e)}},r.activate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!0===n.active?null:Promise.resolve(r.contract.estimateGas.toggleExchangeState(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleExchangeState,e))}):null})}catch(e){return Promise.reject(e)}},r.deactivate=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!1===n.active?null:Promise.resolve(r.contract.estimateGas.toggleExchangeState(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleExchangeState,e))}):null})}catch(e){return Promise.reject(e)}},r.getRate=function(e){try{var t=this;return Promise.resolve(t.contract.getRate(e)).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDatatokenSupply=function(e){try{var t=this;return Promise.resolve(t.contract.getDTSupply(e)).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)}},r.getBasetokenSupply=function(e){try{var t=this;return Promise.resolve(t.contract.getBTSupply(e)).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)}},r.getAllowedSwapper=function(e){try{return Promise.resolve(this.contract.getAllowedSwapper(e))}catch(e){return Promise.reject(e)}},r.calcBaseInGivenDatatokensOut=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.contract,s=i.calcBaseInGivenOutDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.amountToUnits(null,r,18)).then(function(r){return Promise.resolve(s.call(i,e,t,r)).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.publishMarketFeeAmount,+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)}},r.getAmountBasetokensOut=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.contract,s=i.calcBaseOutGivenInDT;return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.amountToUnits(null,r,18)).then(function(r){return Promise.resolve(s.call(i,e,t,r)).then(function(e){return Promise.resolve(n.unitsToAmount(o.baseToken,e[0],+o.btDecimals))})})})})}catch(e){return Promise.reject(e)}},r.getExchange=function(e){try{var t=this;return Promise.resolve(t.contract.getExchange(e)).then(function(r){var n=r.btDecimals.toString(),o=r.dtDecimals.toString(),i=r.allowedSwapper,s=r.exchangeOwner,a=r.withMint,c=r.baseToken,u=r.datatoken,l=r.active;return Promise.resolve(t.unitsToAmount(r.datatoken,r.dtBalance,+r.dtDecimals)).then(function(d){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btBalance,+r.btDecimals)).then(function(h){return Promise.resolve(t.unitsToAmount(r.datatoken,r.dtSupply,+r.dtDecimals)).then(function(f){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(m){return Promise.resolve(t.unitsToAmount(null,r.fixedRate,18)).then(function(t){return{active:l,datatoken:u,baseToken:c,withMint:a,exchangeOwner:s,allowedSwapper:i,dtDecimals:o,btDecimals:n,dtBalance:d,btBalance:h,dtSupply:f,btSupply:m,fixedRate:t,exchangeId:e}})})})})})})}catch(e){return Promise.reject(e)}},r.getFeesInfo=function(e){try{var t=this;return Promise.resolve(t.contract.getFeesInfo(e)).then(function(r){return Promise.resolve(t.getExchange(e)).then(function(n){return Promise.resolve(t.unitsToAmount(null,r.opcFee.toString(),18)).then(function(o){return Promise.resolve(t.unitsToAmount(null,r.marketFee.toString(),18)).then(function(i){var s=r.marketFeeCollector;return Promise.resolve(t.unitsToAmount(n.baseToken,r.marketFeeAvailable,+n.btDecimals)).then(function(a){return Promise.resolve(t.unitsToAmount(n.baseToken,r.oceanFeeAvailable,+n.btDecimals)).then(function(t){return{opcFee:o,marketFee:i,marketFeeCollector:s,marketFeeAvailable:a,oceanFeeAvailable:t,exchangeId:e}})})})})})})}catch(e){return Promise.reject(e)}},r.getExchanges=function(){try{return Promise.resolve(this.contract.getExchanges())}catch(e){return Promise.reject(e)}},r.isActive=function(e){try{return Promise.resolve(this.contract.isActive(e))}catch(e){return Promise.reject(e)}},r.activateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!0===n.withMint?null:Promise.resolve(r.contract.estimateGas.toggleMintState(e,!0)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleMintState,e,!0))}):null})}catch(e){return Promise.reject(e)}},r.deactivateMint=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?!1===n.withMint?null:Promise.resolve(r.contract.estimateGas.toggleMintState(e,!1)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.toggleMintState,e,!1))}):null})}catch(e){return Promise.reject(e)}},r.collectBasetokens=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){return o?Promise.resolve(n.contract.getExchange(e)).then(function(o){return Promise.resolve(n.amountToUnits(o.baseToken,t,+o.btDecimals)).then(function(t){return Promise.resolve(n.contract.estimateGas.collectBT(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.collectBT,e,t))})})}):null})}catch(e){return Promise.reject(e)}},r.collectDatatokens=function(e,t,r){try{var n=this;return Promise.resolve(n.getExchange(e)).then(function(o){return o?Promise.resolve(n.contract.getExchange(e)).then(function(o){return Promise.resolve(n.amountToUnits(o.datatoken,t,+o.dtDecimals)).then(function(t){return Promise.resolve(n.contract.estimateGas.collectDT(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.collectDT,e,t))})})}):null})}catch(e){return Promise.reject(e)}},r.collectMarketFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?Promise.resolve(r.contract.estimateGas.collectMarketFee(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.collectMarketFee,e))}):null})}catch(e){return Promise.reject(e)}},r.collectOceanFee=function(e,t){try{var r=this;return Promise.resolve(r.getExchange(e)).then(function(n){return n?Promise.resolve(r.contract.estimateGas.collectOceanFee(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.collectOceanFee,e))}):null})}catch(e){return Promise.reject(e)}},r.getOPCCollector=function(){try{return Promise.resolve(this.contract.opcCollector())}catch(e){return Promise.reject(e)}},r.getRouter=function(){try{return Promise.resolve(this.contract.router())}catch(e){return Promise.reject(e)}},r.getExchangeOwner=function(e){try{return Promise.resolve(this.getExchange(e)).then(function(e){return Promise.resolve(e.exchangeOwner)})}catch(e){return Promise.reject(e)}},r.updateMarketFee=function(e,t,r){try{var n=this,o=n.contract.estimateGas,i=o.updateMarketFee;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(s){return Promise.resolve(i.call(o,e,s)).then(function(o){var i;if(r)return o;var s=n.contract.updateMarketFee,a=null==(i=n.config)?void 0:i.gasFeeMultiplier,c=n.getSignerAccordingSdk();return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(we(o,c,a,s,e,t))})})})}catch(e){return Promise.reject(e)}},r.updateMarketFeeCollector=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.updateMarketFeeCollector(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(Re),Le=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return q.default.abi},r.buyDatatokenBatch=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.buyDTBatch(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.buyDTBatch,e))})}catch(e){return Promise.reject(e)}},r.isApprovedToken=function(e){try{return Promise.resolve(this.contract.isApprovedToken(e))}catch(e){return Promise.reject(e)}},r.isFixedPrice=function(e){try{return Promise.resolve(this.contract.isFixedRateContract(e))}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.routerOwner())}catch(e){return Promise.reject(e)}},r.getNFTFactory=function(){try{return Promise.resolve(this.contract.factory())}catch(e){return Promise.reject(e)}},r.addApprovedToken=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addApprovedToken(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addApprovedToken,t))})})}catch(e){return Promise.reject(e)}},r.removeApprovedToken=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeApprovedToken(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeApprovedToken,t))})})}catch(e){return Promise.reject(e)}},r.addFixedRateContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addFixedRateContract(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addFixedRateContract,t))})})}catch(e){return Promise.reject(e)}},r.removeFixedRateContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeFixedRateContract(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeFixedRateContract,t))})})}catch(e){return Promise.reject(e)}},r.addDispenserContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.addDispenserContract(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addDispenserContract,t))})})}catch(e){return Promise.reject(e)}},r.removeDispenserContract=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(n.contract.estimateGas.removeDispenserContract(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.removeDispenserContract,t))})})}catch(e){return Promise.reject(e)}},r.getOPCFee=function(e){try{return Promise.resolve(this.contract.getOPCFee(e))}catch(e){return Promise.reject(e)}},r.getCurrentOPCFee=function(){try{return Promise.resolve(this.contract.swapOceanFee())}catch(e){return Promise.reject(e)}},r.updateOPCFee=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getOwner()).then(function(a){if(a!==e)throw new Error("Caller is not Router Owner");return Promise.resolve(s.contract.estimateGas.updateOPCFee(t,r,n,o)).then(function(e){var a;return i?e:Promise.resolve(we(e,s.getSignerAccordingSdk(),null==(a=s.config)?void 0:a.gasFeeMultiplier,s.contract.updateOPCFee,t,r,n,o))})})}catch(e){return Promise.reject(e)}},t}(Re),Ge={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 _e(e){var t=e||Ge,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}}function Be(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var qe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return V.default.abi},r.createNFT=function(e,t){try{var r=this;if(e.templateIndex||(e.templateIndex=1),!e.name||!e.symbol){var n=_e(),o=n.symbol;e.name=n.name,e.symbol=o}var i=e.templateIndex;return Promise.resolve(r.getCurrentNFTTemplateCount()).then(function(n){if(i>n)throw new Error("Template index doesnt exist");if(0===e.templateIndex)throw new Error("Template index cannot be ZERO");return Promise.resolve(r.getNFTTemplate(e.templateIndex)).then(function(n){if(!1===n.isActive)throw new Error("Template is not active");return Promise.resolve(r.contract.estimateGas.deployERC721Contract(e.name,e.symbol,e.templateIndex,Ue,Ue,e.tokenURI,e.transferable,e.owner)).then(function(n){return t?n:Be(function(){var t;return Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(t=r.config)?void 0:t.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,Ue,Ue,e.tokenURI,e.transferable,e.owner)).then(function(e){if(!e){var t="Tx for deploying new NFT contract does not exist or status is not successful.";throw console.error(t),t}return Promise.resolve(e.wait()).then(function(e){return Me(e,"NFTCreated").args[0]})})},function(e){console.error("Creation of NFT failed: "+e)})})})})}catch(e){return Promise.reject(e)}},r.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}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.contract.getNFTTemplate(e))})}catch(e){return Promise.reject(e)}},r.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},r.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},r.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},r.addNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Ue)throw new Error("Template cannot be ZERO address");return Promise.resolve(n.contract.estimateGas.add721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.disable721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.reactivateNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.reactivate721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.addTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Ue)throw new Error("Template cannot be address ZERO");return Promise.resolve(n.contract.estimateGas.addTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!1===e.isActive)throw new Error("Template is already disabled");return Promise.resolve(n.contract.estimateGas.disableTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.reactivateTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!0===e.isActive)throw new Error("Template is already active");return Promise.resolve(n.contract.estimateGas.reactivateTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.startMultipleTokenOrder=function(e,t){try{var r=this;if(e.length>50)throw new Error("Too many orders");return Promise.resolve(r.contract.estimateGas.startMultipleTokenOrder(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},r.createNftWithDatatoken=function(e,t,r){try{var n=this;return Promise.resolve(n.getErcCreationParams(t)).then(function(t){return Promise.resolve(n.contract.estimateGas.createNftWithErc20(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithFixedRate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.getFreCreationParams(r)).then(function(r){return Promise.resolve(o.contract.estimateGas.createNftWithErc20WithFixedRate(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(we(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.amountToUnits(null,r.maxBalance,18)).then(function(i){return r.maxBalance=i,Promise.resolve(o.amountToUnits(null,r.maxTokens,18)).then(function(i){return r.maxTokens=i,Promise.resolve(o.contract.estimateGas.createNftWithErc20WithDispenser(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(we(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},r.getErcCreationParams=function(e){try{var t,r,o=function(){var o=[e.minter,e.paymentCollector,e.mpFeeAddress,e.feeToken];e.filesObject&&(e.accessListFactory&&o.push(e.accessListFactory),e.allowAccessList&&o.push(e.allowAccessList),e.denyAccessList&&o.push(e.denyAccessList));var s=[e.name||t,e.symbol||r],c=e.templateIndex;return Promise.resolve(i.amountToUnits(null,e.cap,18)).then(function(t){return Promise.resolve(i.amountToUnits(null,e.feeAmount,a)).then(function(r){return{templateIndex:c,strings:s,addresses:o,uints:[t,r],bytess:e.filesObject?[n.ethers.utils.toUtf8Bytes(JSON.stringify(e.filesObject))]:[]}})})},i=this;if(!e.name||!e.symbol){var s=_e();t=s.name,r=s.symbol}var a=18,c=function(){if(e.feeToken!==Ue){var t=Be(function(){return Promise.resolve(Te(i.signer,e.feeToken)).then(function(e){a=e})},function(e){me.error("getTokenDecimals error",e)});if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(c&&c.then?c.then(o):o())}catch(e){return Promise.reject(e)}},r.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=Ue);var r=!1===e.withMint?0:1,n=[e.baseTokenAddress,e.owner,e.marketFeeCollector,e.allowedConsumer],o=e.fixedRateAddress,i=e.datatokenDecimals,s=e.baseTokenDecimals;return Promise.resolve(t.amountToUnits(null,e.fixedRate,18)).then(function(a){return Promise.resolve(t.amountToUnits(null,e.marketFee,18)).then(function(e){return{fixedPriceAddress:o,addresses:n,uints:[s,i,a,e,r]}})})}catch(e){return Promise.reject(e)}},t}(Re);function ze(e,t,r){if(!e.s){if(r instanceof Je){if(!r.s)return void(r.o=ze.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(ze.bind(null,e,t),ze.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var Je=/*#__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{ze(n,1,i(this.v))}catch(e){ze(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?ze(n,1,t?t(o):o):r?ze(n,1,r(o)):ze(n,2,o)}catch(e){ze(n,2,e)}},n},e}();function We(e){return e instanceof Je&&1&e.s}var Ve=function(e,t,r,o){try{var i="number"==typeof r,s=new qe(t,e,o);return Promise.resolve(s.getCurrentTokenTemplateCount()).then(function(t){var o;function a(e){return o?e:-1}var c=1,u=function(e,t,r){for(var n;;){var o=e();if(We(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!We(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!We(s)){n=2;break}}}var a=new Je,c=ze.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(d)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!We(s))return void s.then(d).then(void 0,c);if(!(o=e())||We(o)&&!o.v)return void ze(a,1,i);if(o.then)return void o.then(l).then(void 0,c);We(i=r())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,c)}function l(e){e?(i=r())&&i.then?i.then(u).then(void 0,c):u(i):ze(a,1,i)}function d(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):ze(a,1,i)}}(function(){return!o&&c<=t},function(){return c++},function(){return Promise.resolve(s.getTokenTemplate(c)).then(function(t){var s=new n.ethers.Contract(t.templateAddress,H.default.abi,e);return i?Promise.resolve(s.connect(e).getId()).then(function(e){if(t.isActive&&e.toString()===r.toString())return o=1,c}):t.isActive&&t.templateAddress===r.toString()?(o=1,c):void 0})});return u&&u.then?u.then(a):a(u)})}catch(e){return Promise.reject(e)}};function He(){try{if(process.env.ADDRESS_FILE){var e=I.default.readFileSync(process.env.ADDRESS_FILE,"utf8");return JSON.parse(e)}return U.default}catch(e){return U.default}}function Ze(e){try{var t=He();if(t)for(var r=Object.keys(t),n=0,o=r;n<o.length;n++){var i=o[n];if(t[i].chainId===e)return t[i]}}catch(e){console.error(e)}return null}var Xe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return W.default.abi},r.createDatatoken=function(e,t,r,o,i,s,a,c,u,l,d,h,f,m,v,g){try{var p=this;return Promise.resolve(p.getNftPermissions(e,t)).then(function(t){if(!0!==t.deployERC20)throw new Error("Caller is not DatatokenDeployer");if(d||(d=1),!u||!l){var P=_e();u=P.name,l=P.symbol}var y=p.getContract(e);return Promise.resolve(y.provider.getNetwork()).then(function(e){var t=e.chainId;function P(){var e=y.estimateGas,t=e.createERC20,P=[u,l],w=d;return Promise.resolve(p.amountToUnits(null,c,18)).then(function(k){return Promise.resolve(p.amountToUnits(null,a,18)).then(function(b){return Promise.resolve(t.call(e,w,P,[r,o,i,s],[k,b],[])).then(function(e){var t;if(g)return e;var P=[r,o,i,s];f&&(P.push(f.toLowerCase()),P.push(m?m.toLowerCase():Ue),P.push(v||Ue));var w=[u,l],k=d,b=y.createERC20,T=null==(t=p.config)?void 0:t.gasFeeMultiplier,A=p.getSignerAccordingSdk();return Promise.resolve(p.amountToUnits(null,c,18)).then(function(t){return Promise.resolve(p.amountToUnits(null,a,18)).then(function(r){return Promise.resolve(we(e,A,T,b,k,w,P,[t,r],h?[n.ethers.utils.toUtf8Bytes(h)]:[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=Me(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})}var w=Ze(t),k=function(){if(h)return Promise.resolve(Ve(p.signer,w.ERC721Factory,4,t)).then(function(e){d=e})}();return k&&k.then?k.then(P):P()})})}catch(e){return Promise.reject(e)}},r.addManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(i.estimateGas.addManager(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addManager,r))})})}catch(e){return Promise.reject(e)}},r.removeManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(i.estimateGas.removeManager(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeManager,r))})})}catch(e){return Promise.reject(e)}},r.addDatatokenDeployer=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addToCreateERC20List(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToCreateERC20List,r))})})}catch(e){return Promise.reject(e)}},r.removeDatatokenDeployer=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t===r&&!0!==e.deployERC20)throw new Error("Caller is not Manager nor DatatokenDeployer");return Promise.resolve(i.estimateGas.removeFromCreateERC20List(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromCreateERC20List,r))})}var c=!0!==s.manager;return c||t!==r?a(c||t===r&&o.getNftPermissions(e,t)):Promise.resolve(c||t===r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.addMetadataUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addToMetadataList(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToMetadataList,r))})})}catch(e){return Promise.reject(e)}},r.removeMetadataUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t!==r&&!0!==e.updateMetadata)throw new Error("Caller is not Manager nor Metadata Updater");return Promise.resolve(i.estimateGas.removeFromMetadataList(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromMetadataList,r))})}var c=!0!==s.manager;return c||t===r?a(c||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(c||t!==r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.addStoreUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!0!==e.manager)throw new Error("Caller is not Manager");return Promise.resolve(i.estimateGas.addTo725StoreList(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addTo725StoreList,r))})})}catch(e){return Promise.reject(e)}},r.removeStoreUpdater=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(s){function a(e){if(c||t!==r&&!0!==e.store)throw new Error("Caller is not Manager nor storeUpdater");return Promise.resolve(i.estimateGas.removeFrom725StoreList(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFrom725StoreList,r))})}var c=!0!==s.manager;return c||t===r?a(c||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(c||t!==r&&o.getNftPermissions(e,t)).then(a)})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.getContract(e);return Promise.resolve(n.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");return Promise.resolve(o.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.cleanPermissions))})})}catch(e){return Promise.reject(e)}},r.transferNft=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(s.estimateGas.transferFrom(t,r,a)).then(function(e){var n;return o?e:Promise.resolve(we(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.transferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},r.safeTransferNft=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getNftOwner(e)).then(function(e){if(e!==t)throw new Error("Caller is not NFT Owner");var a=n||1;return Promise.resolve(s.estimateGas.safeTransferFrom(t,r,a)).then(function(e){var n;return o?e:Promise.resolve(we(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.safeTransferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},r.setMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l=this,d=l.getContract(e);return c||(c=[]),Promise.resolve(l.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(d.estimateGas.setMetaData(r,n,o,i,s,a,c)).then(function(e){var t;return u?e:Promise.resolve(we(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,d.setMetaData,r,n,o,i,s,a,c))})})}catch(e){return Promise.reject(e)}},r.setMetadataAndTokenURI=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");var t=le({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(we(e,o.signer,null==(r=o.config)?void 0:r.gasFeeMultiplier,i.setMetaDataAndTokenURI,t))})})}catch(e){return Promise.reject(e)}},r.setMetadataState=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getNftPermissions(e,t)).then(function(e){if(!e.updateMetadata)throw new Error("Caller is not Metadata updater");return Promise.resolve(i.estimateGas.setMetaDataState(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setMetaDataState,r))})})}catch(e){return Promise.reject(e)}},r.setTokenURI=function(e,t,r){try{var n=this,o=n.getContract(e);return Promise.resolve(o.estimateGas.setTokenURI("1",t)).then(function(e){var i;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,o.setTokenURI,"1",t))})}catch(e){return Promise.reject(e)}},r.getNftOwner=function(e){try{var t=this.getContract(e);return Promise.resolve(t.ownerOf(1))}catch(e){return Promise.reject(e)}},r.getNftPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.getPermissions(t))}catch(e){return Promise.reject(e)}},r.getMetadata=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getMetaData())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.setData=function(e,t,r,o,i){try{var s=this;return Promise.resolve(s.getNftPermissions(e,t)).then(function(t){if(!0!==t.store)throw new Error("User is not ERC20 store updater");var a=s.getContract(e),c=n.ethers.utils.keccak256(r),u=n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(c,u)).then(function(e){var t;return i?e:Promise.resolve(we(e,s.getSignerAccordingSdk(),null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,c,u))})})}catch(e){return Promise.reject(e)}},r.getData=function(e,t){try{var r=this.getContract(e),o=n.ethers.utils.keccak256(t);return Promise.resolve(r.getData(o)).then(function(e){return e?n.ethers.utils.toUtf8String(e):null})}catch(e){return Promise.reject(e)}},r.getTokenURI=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.tokenURI(t))}catch(e){return Promise.reject(e)}},r.isDatatokenDeployed=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isDeployed(t))}catch(e){return Promise.reject(e)}},t}(Oe),Ke=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o)||this).abiEnterprise=void 0,s.nft=void 0,s.abiEnterprise=i||J.default.abi,s.nft=new Xe(s.signer,r),s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return z.default.abi},r.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,ke(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,ke(null,null,r,18)))})}catch(e){return Promise.reject(e)}},r.createFixedRate=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!e)throw new Error("User is not Datatoken Deployer");r.allowedConsumer||(r.allowedConsumer=Ue);var t=!1===r.withMint?0:1;return Promise.resolve(i.estimateGas.createFixedRate(r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t])).then(function(e){var s;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t]))})})}catch(e){return Promise.reject(e)}},r.createDispenser=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e);return n.allowedSwapper||(n.allowedSwapper=Ue),n.withMint=!1!==n.withMint,Promise.resolve(s.estimateGas.createDispenser(r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper)).then(function(e){var t;return o?e:Promise.resolve(we(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper))})})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getPermissions(e,t)).then(function(a){if(!0!==a.minter)throw new Error("Caller is not Minter");return Promise.resolve(i.getCap(e)).then(function(e){if(new G.default(e).gte(r))return Promise.resolve(s.estimateGas.mint(n||t,ke(null,null,r,18))).then(function(e){var a;return o?e:Promise.resolve(we(e,i.getSignerAccordingSdk(),null==(a=i.config)?void 0:a.gasFeeMultiplier,s.mint,n||t,ke(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},r.addMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addMinter(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},r.removeMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removeMinter(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},r.addPaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addPaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.removePaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removePaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.setPaymentCollector=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getPermissions(e,t)).then(function(s){function a(e){function s(s){function a(e){if(!c&&!u&&!(null==e?void 0:e.deployERC20))throw new Error("Caller is not Fee Manager, owner or Datatoken Deployer");return Promise.resolve(i.estimateGas.setPaymentCollector(r)).then(function(e){var t;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setPaymentCollector,r))})}var u=e&&s===t;return e&&!u?Promise.resolve(e&&!u&&o.nft.getNftPermissions(e,t)).then(a):a(e&&!u&&o.nft.getNftPermissions(e,t))}return e?Promise.resolve(o.nft.getNftOwner(e)).then(s):s(e)}var c=s.paymentManager;return c?a(!c&&o.getNFTAddress(e)):Promise.resolve(!c&&o.getNFTAddress(e)).then(a)})}catch(e){return Promise.reject(e)}},r.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},r.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(ke(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},r.transferWei=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.transfer(t,r)).then(function(e){var s;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},r.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e,s.abi);return o||(o={consumeMarketFeeAddress:Ue,consumeMarketFeeToken:Ue,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var c;return i?e:Promise.resolve(we(e,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},r.reuseOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.reuseOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},r.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(o.getFreOrderParams(r)).then(function(e){return Promise.resolve(i.estimateGas.buyFromFreAndOrder(t,e)).then(function(r){var s;return n?r:Promise.resolve(we(r,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},r.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(i.estimateGas.buyFromDispenserAndOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},r.setData=function(e,t,r,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e),a=n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(r));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(we(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.nft,i=o.getNftOwner;return Promise.resolve(n.getNFTAddress(e)).then(function(s){return Promise.resolve(i.call(o,s)).then(function(o){if(o!==t)throw new Error("Caller is NOT Nft Owner");var i=n.getContract(e);return Promise.resolve(i.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},r.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},r.getCap=function(e){try{var t=this,r=t.getContract(e);return Promise.resolve(r.cap()).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},r.getId=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getId())}catch(e){return Promise.reject(e)}},r.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},r.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},r.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},r.getFixedRates=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getFixedRates())}catch(e){return Promise.reject(e)}},r.getDispensers=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getDispensers())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.balance=function(e,t){try{var r=this,n=r.getContract(e);return Promise.resolve(n.balanceOf(t)).then(function(e){return Promise.resolve(r.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.allowance=function(e,t,r,n){void 0===n&&(n=18);try{var o=this,i=o.getContract(e);return Promise.resolve(i.allowance(t,r)).then(function(e){return Promise.resolve(o.unitsToAmount(null,e,n))})}catch(e){return Promise.reject(e)}},r.setPublishingMarketFee=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e);return Promise.resolve(a.getPublishingMarketFee()).then(function(e){if(e[0]!==o)throw new Error("Caller is not the Publishing Market Fee Address");return Promise.resolve(a.estimateGas.setPublishingMarketFee(t,r,n)).then(function(e){var o;return i?e:Promise.resolve(we(e,s.getSignerAccordingSdk(),null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},r.getPublishingMarketFee=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPublishingMarketFee()).then(function(e){return{publishMarketFeeAddress:e[0],publishMarketFeeToken:e[1],publishMarketFeeAmount:e[2].toString()}})}catch(e){return Promise.reject(e)}},r.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(ke(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(ke(t.signer,e.baseTokenAddress,e.swapMarketFee,e.baseTokenDecimals)).then(function(t){return{exchangeContract:n,exchangeId:r,maxBaseTokenAmount:o,swapMarketFee:t,marketFeeAddress:e.marketFeeAddress}})})}catch(e){return Promise.reject(e)}},t}(Oe),$e=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,n,o,i)||this).accessList=void 0,s.fileObject=void 0,s.abi=s.getDefaultAbi(),s.fileObject=r,s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Z.default.abi},r.setFileObj=function(e){this.fileObject=e},r.getAllowlistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getAllowListContract())}catch(e){return Promise.reject(e)}},r.getDenylistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getDenyListContract())}catch(e){return Promise.reject(e)}},r.setAllowListContract=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var i=o.getContract(e);return Promise.resolve(i.estimateGas.setAllowListContract(t)).then(function(e){var r;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setAllowListContract,t))})})}catch(e){return Promise.reject(e)}},r.setDenyListContract=function(e,t,r,n){try{var o=this;return Promise.resolve(o.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var i=o.getContract(e);return Promise.resolve(i.estimateGas.setDenyListContract(t)).then(function(e){var r;return n?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setDenyListContract,t))})})}catch(e){return Promise.reject(e)}},r.setFileObject=function(e,t,r){try{var n=this;return Promise.resolve(n.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var o=n.getContract(e);return Promise.resolve(o.estimateGas.setFilesObject(n.fileObject)).then(function(e){var t;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.functions.setFilesObject,n.fileObject))})})}catch(e){return Promise.reject(e)}},r.getFileObject=function(e,t,r,n,o,i,s){try{var a=this.getContract(e,this.getDefaultAbi());return Promise.resolve(a.getFileObject(t,r,n,o,i,s))}catch(e){return Promise.reject(e)}},t}(Ke),Ye=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abiEnterprise=void 0,s.abi=i||s.getDefaultAbi(),s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return X.default.abi},r.getTokenUri=function(e){try{return Promise.resolve(this.contract.tokenURI(e))}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getId=function(){try{return Promise.resolve(this.contract.getId())}catch(e){return Promise.reject(e)}},r.getName=function(){try{return Promise.resolve(this.contract.name())}catch(e){return Promise.reject(e)}},r.getSymbol=function(){try{return Promise.resolve(this.contract.symbol())}catch(e){return Promise.reject(e)}},r.balance=function(e){try{var t=this;return Promise.resolve(t.contract.balanceOf(e)).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.mint(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.mint,e,t))})}catch(e){return Promise.reject(e)}},r.batchMint=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.batchMint(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.batchMint,e,t))})}catch(e){return Promise.reject(e)}},r.burn=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.burn(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.burn,e))})}catch(e){return Promise.reject(e)}},r.transferOwnership=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.transferOwnership(e)).then(function(n){var o;return t?n:Promise.resolve(we(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.transferOwnership,e))})}catch(e){return Promise.reject(e)}},r.renounceOwnership=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.renounceOwnership()).then(function(r){var n;return e?r:Promise.resolve(we(r,t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.renounceOwnership))})}catch(e){return Promise.reject(e)}},t}(Re),Qe=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abi=i||s.getDefaultAbi(),s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return K.default.abi},r.deployAccessListContract=function(e,t,r,n,o,i,s){void 0===n&&(n=!1);try{var a=this;if(!e||!t){var c=_e();e=c.name,t=c.symbol}return Promise.resolve(a.contract.estimateGas.deployAccessListContract(e,t,n,o,i,r)).then(function(c){return s?c:function(s,u){try{var l=Promise.resolve(we(c,a.getSignerAccordingSdk(),null==(d=a.config)?void 0:d.gasFeeMultiplier,a.contract.deployAccessListContract,e,t,n,o,i,r)).then(function(e){if(!e){var t="Tx for deploying new access list was not processed on chain.";throw console.error(t),t}return Promise.resolve(e.wait()).then(function(e){return Me(e,"NewAccessList").args[0]})})}catch(e){return u(e)}var d;return l&&l.then?l.then(void 0,u):l}(0,function(e){console.error("Creation of AccessList failed: "+e)})})}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.isSoulbound=function(e){try{return Promise.resolve(this.contract.isSoulBound(e))}catch(e){return Promise.reject(e)}},r.isDeployed=function(e){try{return Promise.resolve(this.contract.isDeployed(e))}catch(e){return Promise.reject(e)}},r.changeTemplateAddress=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===Ue)throw new Error("Template address cannot be ZERO address");return Promise.resolve(n.contract.estimateGas.changeTemplateAddress(t)).then(function(e){var o;return r?e:Promise.resolve(we(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.functions.changeTemplateAddress,t))})})}catch(e){return Promise.reject(e)}},t}(Re),et=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return $.default.abi},r.lockTokens=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,e)).then(function(e){return Promise.resolve(n.contract.estimateGas.create_lock(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o.add(2e4),n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.create_lock,e,t))})})})}catch(e){return Promise.reject(e)}},r.depositFor=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,t)).then(function(t){return Promise.resolve(n.contract.estimateGas.deposit_for(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o.add(2e4),n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.deposit_for,e,t))})})})}catch(e){return Promise.reject(e)}},r.increaseAmount=function(e,t){try{var r=this,n=r.amountToUnits;return Promise.resolve(r.getToken()).then(function(o){return Promise.resolve(n.call(r,o,e)).then(function(e){return Promise.resolve(r.contract.estimateGas.increase_amount(e)).then(function(n){var o;return t?n:Promise.resolve(we(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.increase_amount,e))})})})}catch(e){return Promise.reject(e)}},r.increaseUnlockTime=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.increase_unlock_time(e)).then(function(n){var o;return t?n:Promise.resolve(we(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.increase_unlock_time,e))})}catch(e){return Promise.reject(e)}},r.withdraw=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.withdraw()).then(function(r){var n;return e?r:Promise.resolve(we(r.add(2e4),t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.withdraw))})}catch(e){return Promise.reject(e)}},r.getVotingPower=function(e){try{return Promise.resolve(this.contract.balanceOf(e))}catch(e){return Promise.reject(e)}},r.getLockedAmount=function(e){try{var t=this;return Promise.resolve(t.contract.locked(e)).then(function(e){var r=t.unitsToAmount;return Promise.resolve(t.getToken()).then(function(n){return Promise.resolve(r.call(t,n,e.amount.toString()))})})}catch(e){return Promise.reject(e)}},r.lockEnd=function(e){try{return Promise.resolve(this.contract.locked__end(e)).then(function(e){return parseInt(e.toString())})}catch(e){return Promise.reject(e)}},r.totalSupply=function(){try{var e=this,t=e.unitsToAmount;return Promise.resolve(e.getToken()).then(function(r){return Promise.resolve(e.contract.totalSupply()).then(function(n){return Promise.resolve(t.call(e,r,n))})})}catch(e){return Promise.reject(e)}},r.getToken=function(){try{return Promise.resolve(this.contract.token())}catch(e){return Promise.reject(e)}},t}(Re),tt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Y.default.abi},r.claim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.claim()).then(function(r){var n;return e?r:Promise.resolve(we(r.add(2e4),t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.claim))})}catch(e){return Promise.reject(e)}},r.claimMany=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.claim_many(e)).then(function(n){var o;return t?n:Promise.resolve(we(n.add(2e4),r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.claim_many,e))})}catch(e){return Promise.reject(e)}},t}(Re),rt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return Q.default.abi},r.estimateClaim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateClaim(e)).then(function(e){return Promise.resolve(t.contract.voting_escrow()).then(function(r){var n=new et(r,t.signer),o=t.unitsToAmount;return Promise.resolve(n.getToken()).then(function(r){return Promise.resolve(o.call(t,r,e))})})})}catch(e){return Promise.reject(e)}},t}(Re),nt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return ee.default.abi},r.setAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(we(i.add(2e4),o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.setAllocation,e,t,r))})}catch(e){return Promise.reject(e)}},r.setBatchAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setBatchAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(we(i.add(2e4),o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.setBatchAllocation,e,t,r))})}catch(e){return Promise.reject(e)}},r.getTotalAllocation=function(e){try{return Promise.resolve(this.contract.getTotalAllocation(e))}catch(e){return Promise.reject(e)}},r.getVeAllocation=function(e,t,r){try{return Promise.resolve(this.contract.getveAllocation(e,t,r))}catch(e){return Promise.reject(e)}},t}(Re);function ot(e,t,r){if(!e.s){if(r instanceof it){if(!r.s)return void(r.o=ot.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(ot.bind(null,e,t),ot.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var it=/*#__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{ot(n,1,i(this.v))}catch(e){ot(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?ot(n,1,t?t(o):o):r?ot(n,1,r(o)):ot(n,2,o)}catch(e){ot(n,2,e)}},n},e}(),st=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return te.default.abi},r.getAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimable(e,t)).then(function(e){return Promise.resolve(r.unitsToAmount(t,e))})}catch(e){return Promise.reject(e)}},r.claimRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimFor(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimFor,e,t))})}catch(e){return Promise.reject(e)}},r.allocateRewards=function(e,t,r,n){try{var o=function(){return Promise.resolve(i.contract.estimateGas.allocate(e,t,r)).then(function(o){var s;return n?o:Promise.resolve(we(o,i.getSignerAccordingSdk(),null==(s=i.config)?void 0:s.gasFeeMultiplier,i.contract.allocate,e,t,r))})},i=this,s=(a=t,c=function(e){return Promise.resolve(i.amountToUnits(r,t[e])).then(function(r){t[e]=r})},d=-1,function e(t){try{for(;++d<a.length;)if((t=c(d))&&t.then){if(!((r=t)instanceof it&&1&r.s))return void t.then(e,l||(l=ot.bind(null,u=new it,2)));t=t.v}u?ot(u,1,t):u=t}catch(e){ot(u||(u=new it),2,e)}var r}(),u);return Promise.resolve(s&&s.then?s.then(o):o())}catch(e){return Promise.reject(e)}var a,c,u,l,d},t}(Re);function at(e,t,r){if(!e.s){if(r instanceof ct){if(!r.s)return void(r.o=at.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(at.bind(null,e,t),at.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var ct=/*#__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{at(n,1,i(this.v))}catch(e){at(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?at(n,1,t?t(o):o):r?at(n,1,r(o)):at(n,2,o)}catch(e){at(n,2,e)}},n},e}(),ut=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return re.default.abi},r.getMultipleAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimables(e,t)).then(function(e){var n,o,i,s,a,c=[],u=(n=e,o=function(n){var o=c.push;return Promise.resolve(r.unitsToAmount(t[n],e[n])).then(function(e){o.call(c,e)})},a=-1,function e(t){try{for(;++a<n.length;)if((t=o(a))&&t.then){if(!((r=t)instanceof ct&&1&r.s))return void t.then(e,s||(s=at.bind(null,i=new ct,2)));t=t.v}i?at(i,1,t):i=t}catch(e){at(i||(i=new ct),2,e)}var r}(),i);return u&&u.then?u.then(function(){return c}):c})}catch(e){return Promise.reject(e)}},r.claimMultipleRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimMultiple(e,t)).then(function(o){var i;return r?o:Promise.resolve(we(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(Re);function lt(e,t,r){if(!e.s){if(r instanceof dt){if(!r.s)return void(r.o=lt.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(lt.bind(null,e,t),lt.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var dt=/*#__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{lt(n,1,i(this.v))}catch(e){lt(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?lt(n,1,t?t(o):o):r?lt(n,1,r(o)):lt(n,2,o)}catch(e){lt(n,2,e)}},n},e}(),ht=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abiEnterprise=void 0,s.abi=i||s.getDefaultAbi(),s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return ne.default.abi},r.getFunds=function(e){try{return Promise.resolve(this.contract.getFunds(e))}catch(e){return Promise.reject(e)}},r.getUserFunds=function(e,t){try{return Promise.resolve(this.contract.getUserFunds(e,t))}catch(e){return Promise.reject(e)}},r.getLocks=function(e,t,r){try{return Promise.resolve(this.contract.getLocks(e,t,r))}catch(e){return Promise.reject(e)}},r.getAuthorizations=function(e,t,r){try{return Promise.resolve(this.contract.getAuthorizations(e,t,r))}catch(e){return Promise.reject(e)}},r.verifyFundsForEscrowPayment=function(e,t,r,o,i,s){try{var a=this;return Promise.resolve(a.contract.provider.getBalance(n.ethers.utils.getAddress(t))).then(function(c){if(c===n.BigNumber.from(0))return{isValid:!1,message:"Native token balance is 0. Please add funds"};var u=new Ke(a.signer),l=u.allowance;return Promise.resolve(a.signer.getAddress()).then(function(c){return Promise.resolve(l.call(u,e,c,a.contract.address)).then(function(c){var l=n.BigNumber.from;return Promise.resolve(a.amountToUnits(e,c,18)).then(function(c){function d(){var c=u.balance;return Promise.resolve(a.signer.getAddress()).then(function(l){return Promise.resolve(c.call(u,e,l)).then(function(c){if(n.ethers.utils.parseEther(c)===n.BigNumber.from(0))return{isValid:!1,message:"Payment token balance is 0. Please add funds"};var u=a.getAuthorizations;return Promise.resolve(a.signer.getAddress()).then(function(l){return Promise.resolve(u.call(a,e,l,t)).then(function(u){var l=a.getUserFunds;return Promise.resolve(a.signer.getAddress()).then(function(d){return Promise.resolve(l.call(a,d,e)).then(function(l){function d(){var r=function(){if(0===u.length)return Promise.resolve(a.authorize(n.ethers.utils.getAddress(e),n.ethers.utils.getAddress(t),(Number(o)/2).toString(),i,s)).then(function(){})}();return r&&r.then?r.then(function(){return{isValid:!0,message:""}}):{isValid:!0,message:""}}var h=function(){if(n.BigNumber.from(l[0]).eq(n.BigNumber.from(0))){var t=function(){if(r&&n.ethers.utils.parseEther(c).lte(n.ethers.utils.parseEther(r))&&n.ethers.utils.parseEther(r)>n.BigNumber.from(o))return Promise.resolve(a.deposit(e,r)).then(function(){});var t=function(){if(n.ethers.utils.parseEther(c).lte(n.BigNumber.from(o))){var t=a.deposit;return Promise.resolve(a.unitsToAmount(e,o)).then(function(r){return Promise.resolve(t.call(a,e,r)).then(function(){})})}return Promise.resolve(a.deposit(e,c)).then(function(){})}();return t&&t.then?t.then(function(){}):void 0}();if(t&&t.then)return t.then(function(){})}}();return h&&h.then?h.then(d):d()})})})})})})}var h=function(){if(l.call(n.BigNumber,c).lt(n.BigNumber.from(o)))return Promise.resolve(u.approve(n.ethers.utils.getAddress(e),n.ethers.utils.getAddress(a.contract.address),o)).then(function(){})}();return h&&h.then?h.then(d):d()})})})})}catch(e){return Promise.reject(e)}},r.deposit=function(e,t,r){try{var n=this,o=ke(null,null,t,18);return Promise.resolve(n.contract.estimateGas.deposit(e,o)).then(function(t){var i;return r?t:Promise.resolve(we(t,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.deposit,e,o))})}catch(e){return Promise.reject(e)}},r.withdraw=function(e,t,r){try{var o=this,i=[],s=[];if(e.length!==t.length)throw new Error("Tokens and amounts arrays must have the same length");return Promise.resolve(o.signer.getAddress()).then(function(a){function c(){var t=s.map(function(e){return ke(null,null,e,18)});return Promise.resolve(o.contract.estimateGas.withdraw(e,t)).then(function(e){var n;return r?e:Promise.resolve(we(e,o.getSignerAccordingSdk(),null==(n=o.config)?void 0:n.gasFeeMultiplier,o.contract.withdraw,i,t))})}var u,l,d,h,f,m=(u=e,l=function(r){var c=e[r],u=n.BigNumber.from(t[r]);return Promise.resolve(o.getUserFunds(a,c)).then(function(e){var o=n.BigNumber.from(e[0]);u.gt(0)&&u.lte(o)?(i.push(c),s.push(t[r])):console.log("Insufficient funds for token "+c)})},f=-1,function e(t){try{for(;++f<u.length;)if((t=l(f))&&t.then){if(!((r=t)instanceof dt&&1&r.s))return void t.then(e,h||(h=lt.bind(null,d=new dt,2)));t=t.v}d?lt(d,1,t):d=t}catch(e){lt(d||(d=new dt),2,e)}var r}(),d);return m&&m.then?m.then(c):c()})}catch(e){return Promise.reject(e)}},r.authorize=function(e,t,r,n,o,i){try{var s=this,a=s.getAuthorizations;return Promise.resolve(s.signer.getAddress()).then(function(c){return Promise.resolve(a.call(s,e,c,t)).then(function(a){if(0!==a.length)return console.log("Payee "+t+" already authorized"),null;var c=ke(null,null,r,18),u=ke(null,null,n,18),l=ke(null,null,o,18);return Promise.resolve(s.contract.estimateGas.authorize(e,t,c,u,l)).then(function(r){var n;return i?r:Promise.resolve(we(r,s.getSignerAccordingSdk(),null==(n=s.config)?void 0:n.gasFeeMultiplier,s.contract.authorize,e,t,c,u,l))})})})}catch(e){return Promise.reject(e)}},r.cancelExpiredLocks=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.contract.estimateGas.cancelExpiredLocks(e,t,r,n)).then(function(s){var a;return o?s:Promise.resolve(we(s,i.getSignerAccordingSdk(),null==(a=i.config)?void 0:a.gasFeeMultiplier,i.contract.cancelExpiredLocks,e,t,r,n))})}catch(e){return Promise.reject(e)}},t}(Re),ft=/*#__PURE__*/function(e){function t(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abi=i||s.getDefaultAbi(),s}de(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return oe.default.abi},r.isTokenAllowed=function(e){try{return Promise.resolve(this.contract.isTokenAllowed(e))}catch(e){return Promise.reject(e)}},r.getToken=function(e){try{return Promise.resolve(this.contract.getToken(e))}catch(e){return Promise.reject(e)}},r.calculateFee=function(e,t){try{var r=this,n=r.amountToUnits(e,t.toString());return Promise.resolve(r.contract.calculateFee(e,n)).then(function(t){return r.unitsToAmount(e,t)})}catch(e){return Promise.reject(e)}},t}(Re),mt=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}},vt=function(e,t){try{var r=n.ethers.utils.solidityKeccak256(["bytes"],[n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(t))]),o=n.ethers.utils.arrayify(r);return Promise.resolve(e.getChainId()).then(function(t){return function(t,r){try{var n=Promise.resolve(e.signMessage(o))}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(r){return me.error("Sign message error: ",r),function(){if(8996===t)return console.log("Signing message with _legacySignMessage"),Promise.resolve(e._legacySignMessage(o))}()})})}catch(e){return Promise.reject(e)}};function gt(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function pt(e,t,r){if(!e.s){if(r instanceof Pt){if(!r.s)return void(r.o=pt.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(pt.bind(null,e,t),pt.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Pt=/*#__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{pt(n,1,i(this.v))}catch(e){pt(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?pt(n,1,t?t(o):o):r?pt(n,1,r(o)):pt(n,2,o)}catch(e){pt(n,2,e)}},n},e}();function yt(e){return e instanceof Pt&&1&e.s}var wt=/*#__PURE__*/function(){function e(e){this.aquariusURL=void 0,this.aquariusURL=e}var t=e.prototype;return t.resolve=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/ddo/"+e;return Promise.resolve(gt(function(){return Promise.resolve(ie.default(n,{method:"GET",headers:{"Content-Type":"application/json",Authorization:r},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 me.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForIndexer=function(e,t,r,n,o,i){void 0===n&&(n=3e4),void 0===o&&(o=100);try{var s,a=this,c=0;o>500&&(me.warn("Max Limit exceeded, defaulting to 500 retries."),o=500);var u=function(e,t){var r;do{var n=e();if(n&&n.then){if(!yt(n)){r=!0;break}n=n.v}var o=t();if(yt(o)&&(o=o.v),!o)return n}while(!o.then);var i=new Pt,s=pt.bind(null,i,2);return(r?n.then(a):o.then(c)).then(void 0,s),i;function a(r){for(n=r;yt(o=t())&&(o=o.v),o;){if(o.then)return void o.then(c).then(void 0,s);if((n=e())&&n.then){if(!yt(n))return void n.then(a).then(void 0,s);n=n.v}}pt(i,1,n)}function c(r){if(r){do{if((n=e())&&n.then){if(!yt(n))return void n.then(a).then(void 0,s);n=n.v}if(yt(r=t())&&(r=r.v),!r)return void pt(i,1,n)}while(!r.then);r.then(c).then(void 0,s)}else pt(i,1,n)}}(function(){function o(e){return s?e:Promise.resolve(mt(n)).then(function(){c++})}var u=gt(function(){return Promise.resolve(ie.default(a.aquariusURL+"/api/aquarius/assets/ddo/"+e,{method:"GET",headers:{"Content-Type":"application/json",Authorization:i},signal:r})).then(function(e){return function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){var r=S.DDOManager.getDDOClass(e).getAssetFields().indexedMetadata;return t?r.event&&r.event.txid===t?(s=1,e):void 0:(s=1,e)})}()})},function(){});return u&&u.then?u.then(o):o(u)},function(){return!s&&c<o});return Promise.resolve(u&&u.then?u.then(function(e){return s?e:null}):s?u:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t,r,n,o){try{var i=r+"/api/aquarius/assets/ddo/validate",s=r+"/api/services/nonce";return Promise.resolve(gt(function(){return Promise.resolve(t.getAddress()).then(function(r){return Promise.resolve(ie.default(s+"?userAddress="+r,{method:"GET",headers:{"Content-Type":"application/json",Authorization:o},signal:n})).then(function(s){return Promise.resolve(s.json()).then(function(s){var a=s.nonce;console.log("[getNonce] Consumer: "+r+" nonce: "+a),a&&null!==a||(a="0");var c=(Number(a)+1).toString();return Promise.resolve(vt(t,r+c)).then(function(t){return Promise.resolve(ie.default(i,{method:"POST",body:JSON.stringify({ddo:e,publisherAddress:r,nonce:c,signature:t}),headers:{"Content-Type":"application/octet-stream",Authorization:o},signal:n})).then(function(e){return Promise.resolve(e.json()).then(function(t){if(200!==e.status)throw new Error("Metadata validation failed");return console.log("Ddo successfully validated"),{valid:!0,hash:t.hash,proof:{validatorAddress:t.publicKey,r:t.r[0],s:t.s[0],v:t.v}}})})})})})})},function(e){me.error("Metadata validation failed",e.message)}))}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(gt(function(){return Promise.resolve(ie.default(n,{method:"GET",headers:{"Content-Type":"application/json",Authorization:r},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("getAssetMetadata failed: "+e.status+e.statusText)})},function(e){throw me.error("Error getting metadata: ",e),new Error("Error getting metadata: "+e)}))}catch(e){return Promise.reject(e)}},t.querySearch=function(e,t,r){try{var n=this.aquariusURL+"/api/aquarius/assets/query";return Promise.resolve(gt(function(){return Promise.resolve(ie.default(n,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json",Authorization:r},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("querySearch failed: "+e.status+e.statusText)})},function(e){throw me.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();function kt(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var bt=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getConsumerAddress=function(e){try{return Promise.resolve("string"==typeof e?function(e){try{return se.default.decode(e,{json:!0})}catch(e){throw new Error("Error decoding JWT")}}(e).address:e.getAddress())}catch(e){return Promise.reject(e)}},t.getSignature=function(e,t){try{return Promise.resolve("string"==typeof e?null:this.signProviderRequest(e,t))}catch(e){return Promise.reject(e)}},t.getAuthorization=function(e){return"string"==typeof e?e:void 0},t.getEndpoints=function(e,t){try{var r=this;return Promise.resolve(kt(function(){return Promise.resolve(r.getData(e,t)).then(function(e){return Promise.resolve(e.json())})},function(e){throw me.error("Finding the service endpoints failed:",e),new Error("HTTP request failed calling Provider")}))}catch(e){return Promise.reject(e)}},t.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName.toLowerCase()===t.toLowerCase()}):null},t.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints){var o={serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e.replace(/\/+$/,"")+"/"+t.serviceEndpoints[n][1].replace(/^\/+/,"")};r.push(o)}return Promise.resolve(r)}catch(e){return Promise.reject(e)}},t.getNonce=function(e,t,r,n,o){try{var i=function(){function i(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?kt(function(){return Promise.resolve(ie.default(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return Promise.resolve(e.json()).then(function(e){var r=e.nonce;return console.log("[getNonce] Consumer: "+t+" nonce: "+r),r&&null!==r?Number(r):0})})},function(e){throw me.error(e),new Error(e.message)}):null}var a=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return a&&a.then?a.then(i):i()},s=this,a=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},t.signProviderRequest=function(e,t){try{var r=n.ethers.utils.solidityKeccak256(["bytes"],[n.ethers.utils.hexlify(n.ethers.utils.toUtf8Bytes(t))]),o=n.ethers.utils.arrayify(r);return Promise.resolve(kt(function(){return Promise.resolve(e.signMessage(o))},function(){return Promise.resolve(e.getChainId()).then(function(t){return function(){if(8996===t)return Promise.resolve(e._legacySignMessage(o))}()})}))}catch(e){return Promise.reject(e)}},t.encrypt=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(r)).then(function(i){return Promise.resolve(o.getServiceEndpoints(r,i)).then(function(r){var i=(o.getEndpointURL(r,"encrypt")?o.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return i?kt(function(){return Promise.resolve(ie.default(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 me.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n,o){void 0===n&&(n=!1);try{var i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw me.error("File info call failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){for(var r,n=ue(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var a,c={did:e,serviceId:t,checksum:n},u=[],l=i.getEndpointURL(r,"fileinfo")?i.getEndpointURL(r,"fileinfo").urlPath:null;if(!l)return null;var d=kt(function(){return Promise.resolve(ie.default(l,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw me.error("File info call failed: "),me.error(e),new Error(e)});return d&&d.then?d.then(s):s()})})}catch(e){return Promise.reject(e)}},t.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){function i(e){var t;function r(e){return t?e:Promise.resolve(s.json()).then(function(e){throw me.error("File info call failed: ",s.status,s.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=s)&&e.ok)return Promise.resolve(s.json()).then(function(e){for(var r,n=ue(e);!(r=n()).done;)c.push(r.value);return t=1,c})}();return n&&n.then?n.then(r):r(n)}var s,a=le({},e,{checksum:r}),c=[],u=o.getEndpointURL(t,"fileinfo")?o.getEndpointURL(t,"fileinfo").urlPath:null;if(!u)return null;var l=kt(function(){return Promise.resolve(ie.default(u,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){s=e})},function(e){throw me.error("File info call failed: "),me.error(e),new Error(e)});return l&&l.then?l.then(i):i()})})}catch(e){return Promise.reject(e)}},t.getComputeEnvironments=function(e,t){try{var r=this;return Promise.resolve(r.getEndpoints(e)).then(function(n){return Promise.resolve(r.getServiceEndpoints(e,n)).then(function(e){var n;function o(e){var t;return null!=(t=i)&&t.ok?i.json():Promise.resolve(i.json()).then(function(e){throw me.error("Fetch compute env failed: ",i.status,i.statusText,e),new Error(JSON.stringify(e))})}var i,s=null==(n=r.getEndpointURL(e,"computeEnvironments"))?void 0:n.urlPath;if(!s)return null;var a=kt(function(){return Promise.resolve(ie.default(s,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){i=e})},function(e){throw me.error("Fetch compute env failed: "),me.error(e),new Error(e)});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(o)).then(function(l){return Promise.resolve(u.getServiceEndpoints(o,l)).then(function(o){function l(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw me.error("Provider initialized failed: ",d.status,d.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(200===(null==(e=d)?void 0:e.status))return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var d,h=u.getEndpointURL(o,"initialize")?u.getEndpointURL(o,"initialize").urlPath:null;if(!h)return null;h+="?documentId="+e,h+="&serviceId="+t,h+="&fileIndex="+r,h+="&consumerAddress="+n,s&&(h+="&userdata="+encodeURI(JSON.stringify(s))),a&&(h+="&environment="+encodeURI(a)),c&&(h+="&validUntil="+c);var f=kt(function(){return Promise.resolve(ie.default(h,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){d=e})},function(e){throw me.error("Provider initialized failed: "),me.error(e),new Error("Provider initialize failed url: "+h+" ")});return f&&f.then?f.then(l):l()})})}catch(e){return Promise.reject(e)}},t.initializeComputeV1=function(e,t,r,n,o,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(n)).then(function(l){return Promise.resolve(u.getServiceEndpoints(n,l)).then(function(n){function l(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw me.error("Initialize compute failed: ",d.status,d.statusText,e),me.error("Payload was:",JSON.stringify(h)),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=d)&&e.ok)return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var d,h={datasets:e,algorithm:t,payment:{chainId:i,token:s,maxJobDuration:a},consumerAddress:o,environment:r},f=u.getEndpointURL(n,"initializeCompute")?u.getEndpointURL(n,"initializeCompute").urlPath:null;if(!f)return null;var m=kt(function(){return Promise.resolve(ie.default(f,{method:"POST",body:JSON.stringify(h),headers:{"Content-Type":"application/json"},signal:c})).then(function(e){d=e})},function(e){throw me.error("Initialize compute failed: "),me.error(e),new Error("ComputeJob cannot be initialized")});return m&&m.then?m.then(l):l()})})}catch(e){return Promise.reject(e)}},t.initializeCompute=function(e,t,r,n,o,i,s,a,c,u,l){try{var d=this;return Promise.resolve(d.getEndpoints(i)).then(function(h){return Promise.resolve(d.getServiceEndpoints(i,h)).then(function(f){var m=d.getEndpointURL(f,"initializeCompute")?d.getEndpointURL(f,"initializeCompute").urlPath:null;return m?Promise.resolve(d.getConsumerAddress(s)).then(function(v){return Promise.resolve(d.getNonce(i,v,l,h,f)).then(function(i){var h,f=(i+1).toString(),g=v;return g+=null==(h=e[0])?void 0:h.documentId,g+=f,Promise.resolve(d.getSignature(s,g)).then(function(i){function h(e){var t;function r(e){return t?e:Promise.resolve(f.json()).then(function(e){throw me.error("Initialize compute failed: ",f.status,f.statusText,e),me.error("Payload was:",JSON.stringify(g)),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=f)&&e.ok)return Promise.resolve(f.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var f,g={datasets:e,algorithm:t,environment:r,payment:{chainId:c,token:n,resources:a},maxJobDuration:o,consumerAddress:v,signature:i};u&&(g.policyServer=u);var p=kt(function(){return console.log("Initialize compute url:",m),Promise.resolve(ie.default(m,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json",Authorization:d.getAuthorization(s)},signal:l})).then(function(e){return f=e,console.log("Raw response:",f),function(){if(!f.ok)return Promise.resolve(f.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw me.error("Initialize compute failed: "),me.error(e),new Error("ComputeJob cannot be initialized: "+e.message+".")});return p&&p.then?p.then(h):h()})})}):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(o)).then(function(u){return Promise.resolve(c.getServiceEndpoints(o,u)).then(function(l){var d=c.getEndpointURL(l,"download")?c.getEndpointURL(l,"download").urlPath:null;return d?Promise.resolve(c.getConsumerAddress(i)).then(function(h){return Promise.resolve(c.getNonce(o,h,null,u,l)).then(function(o){var u=(o+1).toString();return Promise.resolve(c.getSignature(i,e+u)).then(function(o){var i=d;return i+="?fileIndex="+r,i+="&documentId="+e,i+="&transferTxId="+n,i+="&serviceId="+t,i+="&consumerAddress="+h,i+="&nonce="+u,s&&(i+="&policyServer="+encodeURI(JSON.stringify(s))),i+="&signature="+o,a&&(i+="&userdata="+encodeURI(JSON.stringify(a))),i})})}):null})})}catch(e){return Promise.reject(e)}},t.computeStartV1=function(e,t,r,n,o,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(e)).then(function(u){return Promise.resolve(c.getServiceEndpoints(e,u)).then(function(l){var d=c.getEndpointURL(l,"computeStart")?c.getEndpointURL(l,"computeStart").urlPath:null;return Promise.resolve(t.getAddress()).then(function(h){return Promise.resolve(c.getNonce(e,h,i,u,l)).then(function(e){var u=(e+1).toString(),l=h;return l+=n.documentId,l+=u,Promise.resolve(c.signProviderRequest(t,l)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=me.error,n=c.statusText,o=c.status;return Promise.resolve(c.json()).then(function(e){return r.call(me,"Compute start failed: ",o,n,e),me.error("Payload was:",l),null})}var n=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var c,l=Object();if(l.consumerAddress=h,l.signature=e,l.nonce=u,l.environment=r,l.dataset=n,l.algorithm=o,s&&(l.additionalDatasets=s),a&&(l.output=a),!d)return null;var f=kt(function(){return Promise.resolve(ie.default(d,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw me.error("Compute start failed:"),me.error(e),me.error("Payload was:",l),new Error("HTTP request failed calling Provider")});return f&&f.then?f.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,o,i,s,a,c,u,l,d,h){try{var f=this;return console.log("called new compute start method..."),console.log("datasets: ",n),console.log("algorithm: ",o),Promise.resolve(f.getEndpoints(e)).then(function(m){return Promise.resolve(f.getServiceEndpoints(e,m)).then(function(v){var g=f.getEndpointURL(v,"computeStart")?f.getEndpointURL(v,"computeStart").urlPath:null;return g?Promise.resolve(f.getConsumerAddress(t)).then(function(p){return Promise.resolve(f.getNonce(e,p,h,m,v)).then(function(e){var m,v=(e+1).toString(),P=p;return P+=null==(m=n[0])?void 0:m.documentId,P+=v,Promise.resolve(f.getSignature(t,P)).then(function(e){function m(e){var t;function r(e){if(t)return e;var r=me.error,n=P.statusText,o=P.status;return Promise.resolve(P.json()).then(function(e){return r.call(me,"Compute start failed: ",o,n,e),me.error("Payload was:",y),null})}var n=function(e){if(null!=(e=P)&&e.ok)return Promise.resolve(P.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var P,y=Object();y.consumerAddress=p,y.signature=e,y.nonce=v,y.environment=r,y.maxJobDuration=i,y.resources=a,y.dataset=n[0],y.datasets=n,y.algorithm=o,y.chainId=c,y.payment={chainId:c,token:s,maxJobDuration:i},a&&(y.payment.resources=a),u&&(y.metadata=u),l&&(y.output=l),d&&(y.policyServer=d);var w=kt(function(){return Promise.resolve(ie.default(g,{method:"POST",body:JSON.stringify(y),headers:{"Content-Type":"application/json",Authorization:f.getAuthorization(t)},signal:h})).then(function(e){P=e})},function(e){throw me.error("Compute start failed:"),me.error(e),me.error("Payload was:",y),new Error("HTTP request failed calling Provider")});return w&&w.then?w.then(m):m()})})}):(me.error("Compute start failed: Cannot get proper computeStart route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.freeComputeStart=function(e,t,r,n,o,i,s,a,c,u){try{var l=this;return console.log("called new free compute start method..."),console.log("datasets: ",n),console.log("algorithm: ",o),Promise.resolve(l.getEndpoints(e)).then(function(d){return Promise.resolve(l.getServiceEndpoints(e,d)).then(function(h){var f=l.getEndpointURL(h,"freeCompute")?l.getEndpointURL(h,"freeCompute").urlPath:null;return f?Promise.resolve(l.getConsumerAddress(t)).then(function(m){return Promise.resolve(l.getNonce(e,m,u,d,h)).then(function(e){var d=(e+1).toString(),h=d;return console.log("signatureMessage: ",h),Promise.resolve(l.getSignature(t,h)).then(function(e){function h(e){var t;function r(e){if(t)return e;var r=me.error,n=v.statusText,o=v.status;return Promise.resolve(v.json()).then(function(e){return r.call(me,"Compute start failed: ",o,n,e),me.error("Payload was:",g),null})}var n=function(e){if(null!=(e=v)&&e.ok)return Promise.resolve(v.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var v,g=Object();g.consumerAddress=m,g.signature=e,g.nonce=d,g.environment=r,g.resources=i,g.dataset=n[0],g.datasets=n,g.algorithm=o,s&&(g.metadata=s),g.output=a,c&&(g.policyServer=c);var p=kt(function(){return Promise.resolve(ie.default(f,{method:"POST",body:JSON.stringify(g),headers:{"Content-Type":"application/json",Authorization:l.getAuthorization(t)},signal:u})).then(function(e){v=e})},function(e){throw me.error("Compute start failed:"),me.error(e),me.error("Payload was:",g),new Error("HTTP request failed calling Provider")});return p&&p.then?p.then(h):h()})})}):(me.error("Compute start failed: Cannot get proper computeStart route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.computeStreamableLogs=function(e,t,r,n){try{var o=this,i="string"==typeof t;return Promise.resolve(o.getEndpoints(e)).then(function(s){return Promise.resolve(o.getServiceEndpoints(e,s)).then(function(a){var c=o.getEndpointURL(a,"computeStreamableLogs")?o.getEndpointURL(a,"computeStreamableLogs").urlPath:null;return c?Promise.resolve(o.getConsumerAddress(t)).then(function(u){return Promise.resolve(o.getNonce(e,u,n,s,a)).then(function(e){function s(){var e;function r(t){var r,n;if(null!=(r=e)&&r.ok||200===(null==(n=e)?void 0:n.status))return console.log("Response body:",e.body),e.body;var o=me.error,i=e.statusText,s=e.status;return Promise.resolve(e.json()).then(function(e){return o.call(me,"computeStreamableLogs failed: ",s,i,e),null})}var i=kt(function(){return Promise.resolve(ie.default(c+l,{method:"GET",headers:{"Content-Type":"application/json",Authorization:o.getAuthorization(t)},signal:n})).then(function(t){e=t,console.log("Raw response:",e)})},function(e){throw me.error("computeStreamableLogs failed:"),me.error(e),new Error("HTTP request failed calling Provider")});return i&&i.then?i.then(r):r()}var a=(e+1).toString(),l="?consumerAddress="+u+"&jobId="+r,d=function(){if(!i)return Promise.resolve(o.getSignature(t,""+u+r+a)).then(function(e){l+="&signature="+e,l+="&nonce="+a})}();return d&&d.then?d.then(s):s()})}):(me.error("Compute start failed: Cannot get proper computeStreamableLogs route (perhaps not implemented on provider?)"),null)})})}catch(e){return Promise.reject(e)}},t.getComputeStartRoutes=function(e,t){void 0===t&&(t=!1);try{var r=this;return Promise.resolve(r.getEndpoints(e)).then(function(n){return Promise.resolve(r.getServiceEndpoints(e,n)).then(function(e){return t?r.getEndpointURL(e,"freeCompute")?r.getEndpointURL(e,"freeCompute").urlPath:null:r.getEndpointURL(e,"computeStart")?r.getEndpointURL(e,"computeStart").urlPath:null})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(t)).then(function(s){return Promise.resolve(i.getServiceEndpoints(t,s)).then(function(a){var c=i.getEndpointURL(a,"computeStop")?i.getEndpointURL(a,"computeStop").urlPath:null;return Promise.resolve(i.getConsumerAddress(r)).then(function(u){return Promise.resolve(i.getNonce(t,u,o,s,a)).then(function(t){var s=(t+1).toString();return Promise.resolve(i.getSignature(r,u+(e||""))).then(function(t){function a(e){var t;function r(e){return t?e:Promise.resolve(d.json()).then(function(e){throw me.error("Compute stop failed: ",d.status,d.statusText,e),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=d)&&e.ok)return Promise.resolve(d.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var l=new URLSearchParams;l.set("consumerAddress",u),l.set("signature",t),l.set("nonce",s),l.set("jobId",e),n&&l.set("agreementId",n);var d,h=l.toString();if(!h)return null;var f=kt(function(){return Promise.resolve(ie.default(c+"?"+h,{method:"PUT",headers:{"Content-Type":"application/json",Authorization:i.getAuthorization(r)},signal:o})).then(function(e){d=e})},function(e){throw me.error("Compute stop failed:"),me.error(e),new Error("HTTP request failed calling Provider")});return f&&f.then?f.then(a):a()})})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,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){function a(e){var t;function r(e){var r;if(t)return e;function n(e){return r?e:Promise.resolve(c.json()).then(function(e){throw me.error("Get compute status failed:",c.status,c.statusText,e),new Error(JSON.stringify(e))})}me.error("Get compute status failed:",c.status,c.statusText);var o=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var n=function(e){if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var c,u=s.getEndpointURL(e,"computeStatus")?s.getEndpointURL(e,"computeStatus").urlPath:null,l="?consumerAddress="+t;if(l+=n&&"&agreementId="+n||"",l+=r&&"&jobId="+r||"",!u)return null;var d=kt(function(){return console.log("computeStatusUrl: ",u+l),Promise.resolve(ie.default(u+l,{method:"GET",headers:{"Content-Type":"application/json",Authorization:i},signal:o})).then(function(e){c=e})},function(e){throw me.error("Get compute status failed"),me.error(e),new Error(e)});return d&&d.then?d.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getComputeResultUrl=function(e,t,r,n){try{var o=this,i="string"==typeof t;return Promise.resolve(o.getEndpoints(e)).then(function(s){return Promise.resolve(o.getServiceEndpoints(e,s)).then(function(a){var c=o.getEndpointURL(a,"computeResult")?o.getEndpointURL(a,"computeResult").urlPath:null;return Promise.resolve(o.getConsumerAddress(t)).then(function(u){return Promise.resolve(o.getNonce(e,u,null,s,a)).then(function(e){var s=(e+1).toString(),a=u;return a+=r,a+=n.toString(),a+=s,Promise.resolve(o.getSignature(t,a)).then(function(e){if(!c)return null;var t=c;return t+="?consumerAddress="+u,t+="&jobId="+r,t+="&index="+n.toString(),i||(t+="&nonce="+s,t+="&signature="+e),t})})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(n)).then(function(s){return Promise.resolve(i.getServiceEndpoints(n,s)).then(function(a){var c=i.getEndpointURL(a,"computeDelete")?i.getEndpointURL(a,"computeDelete").urlPath:null;return Promise.resolve(i.getConsumerAddress(t)).then(function(u){return Promise.resolve(i.getNonce(n,u,o,s,a)).then(function(n){var s=(n+1).toString(),a=u;return a+=r||"",a+=e&&""+i.noZeroX(e)||"",a+=s,Promise.resolve(i.getSignature(t,a)).then(function(n){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw me.error("Delete compute job failed:",a.status,a.statusText,e),me.error("Payload was:",l),new Error(JSON.stringify(e))})}var n=function(e){if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,l=Object();if(l.documentId=e,l.consumerAddress=u,l.jobId=r,n&&(l.signature=n),!c)return null;var d=kt(function(){return Promise.resolve(ie.default(c,{method:"DELETE",body:JSON.stringify(l),headers:{"Content-Type":"application/json",Authorization:i.getAuthorization(t)},signal:o})).then(function(e){a=e})},function(e){throw me.error("Delete compute job failed:"),me.error(e),me.error("Payload was:",l),new Error("HTTP request failed calling Provider")});return d&&d.then?d.then(s):s()})})})})})}catch(e){return Promise.reject(e)}},t.generateAuthToken=function(e,t,r){try{var n=this;return Promise.resolve(e.getAddress()).then(function(o){return Promise.resolve(n.getEndpoints(t)).then(function(i){return Promise.resolve(n.getServiceEndpoints(t,i)).then(function(s){var a=n.getEndpointURL(s,"generateAuthToken").urlPath||null;return Promise.resolve(n.getNonce(t,o,r,i,s)).then(function(t){var i=(t+1).toString();return Promise.resolve(n.signProviderRequest(e,o+i)).then(function(e){return kt(function(){return Promise.resolve(ie.default(a,{method:"POST",body:JSON.stringify({address:o,signature:e,nonce:i}),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){if(null==e||!e.ok)throw new Error("Failed to generate auth token: "+e.status+" "+e.statusText);return Promise.resolve(e.json()).then(function(e){return null==e?void 0:e.token})})},function(e){throw me.error("Generate auth token failed:"),me.error(e),new Error("HTTP request failed calling Provider")})})})})})})}catch(e){return Promise.reject(e)}},t.invalidateAuthToken=function(e,t,r,n){try{var o=this;return Promise.resolve(e.getAddress()).then(function(i){return Promise.resolve(o.getEndpoints(r)).then(function(s){return Promise.resolve(o.getServiceEndpoints(r,s)).then(function(a){var c=o.getEndpointURL(a,"invalidateAuthToken").urlPath||null;return Promise.resolve(o.getNonce(r,i,n,s,a)).then(function(r){var s=(r+1).toString();return Promise.resolve(o.signProviderRequest(e,i+s)).then(function(e){return kt(function(){return Promise.resolve(ie.default(c,{method:"POST",body:JSON.stringify({address:i,signature:e,token:t,nonce:s}),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){if(null==e||!e.ok)throw new Error("Failed to invalidate auth token: "+e.status+" "+e.statusText);return Promise.resolve(e.json())})},function(e){throw me.error("Generate auth token failed:"),me.error(e),new Error("HTTP request failed calling Provider")})})})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(kt(function(){return Promise.resolve(ie.default(e,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t,r=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){if(e&&(e.providerAddress||e.providerAddresses))return t=!0})}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return me.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},t.PolicyServerPassthrough=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(e)).then(function(o){return Promise.resolve(n.getServiceEndpoints(e,o)).then(function(e){function o(e){var r;function n(e){return r?e:Promise.resolve(i.json()).then(function(e){throw me.error("PolicyServerPassthrough failed: ",i.status,i.statusText,e),me.error("Payload was:",JSON.stringify(t)),new Error(JSON.stringify(e))})}var o=function(e){if(null!=(e=i)&&e.ok)return Promise.resolve(i.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var i,s=n.getEndpointURL(e,"PolicyServerPassthrough")?n.getEndpointURL(e,"PolicyServerPassthrough").urlPath:null;if(!s)return null;var a=kt(function(){return Promise.resolve(ie.default(s,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return i=e,function(){if(!i.ok)return Promise.resolve(i.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw me.error("PolicyServerPassthrough failed: "),me.error(e),new Error("PolicyServerPassthrough failed: "+e.message+".")});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.initializePSVerification=function(e,t,r){try{var n=this;return Promise.resolve(n.getEndpoints(e)).then(function(o){return Promise.resolve(n.getServiceEndpoints(e,o)).then(function(e){function o(e){var r;function n(e){return r?e:Promise.resolve(i.json()).then(function(e){throw me.error("initializePSVerification failed: ",i.status,i.statusText,e),me.error("Payload was:",JSON.stringify(t)),new Error(JSON.stringify(e))})}var o=function(e){if(null!=(e=i)&&e.ok)return Promise.resolve(i.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}var i,s=n.getEndpointURL(e,"initializePSVerification")?n.getEndpointURL(e,"initializePSVerification").urlPath:null;if(!s)return null;var a=kt(function(){return Promise.resolve(ie.default(s,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return i=e,function(){if(!i.ok)return Promise.resolve(i.text()).then(function(e){throw new Error(""+e)})}()})},function(e){throw me.error("initializePSVerification failed: "),me.error(e),new Error("initializePSVerification failed: "+e.message+".")});return a&&a.then?a.then(o):o()})})}catch(e){return Promise.reject(e)}},t.noZeroX=function(e){return this.zeroXTransformer(e,!1)},t.zeroXTransformer=function(e,t){void 0===e&&(e="");var r=this.inputMatch(e,/^(?:0x)*([a-f0-9]+)$/i,"zeroXTransformer");return(t&&r.valid?"0x":"")+r.output},t.inputMatch=function(e,t,r){if("string"!=typeof e)throw me.debug("Not input string:"),me.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(me.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},t.getData=function(e,t){try{return Promise.resolve(ie.default(e,{method:"GET",headers:{"Content-type":"application/json",Authorization:t}}))}catch(e){return Promise.reject(e)}},e}(),Tt=new bt,At=function(e,t,r,o){try{var i=new n.ethers.Contract(t,ye,e);return Promise.resolve(i.allowance(r,o))}catch(e){return Promise.reject(e)}},Ft=function(e,t,r,o,i){try{var s=new n.ethers.Contract(t,ye,e);return Promise.resolve(s.allowance(r,o)).then(function(r){return Promise.resolve(be(e,t,r,i))})}catch(e){return Promise.reject(e)}},St=function(e,t,r,o,i,s,a,c){void 0===a&&(a=!1);try{var u,l=function(r){if(u)return r;var n=null;return Promise.resolve(d.estimateGas.approve(i,s)).then(function(r){if(c)return r;var o=function(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}(function(){return Promise.resolve(we(r,e,null==t?void 0:t.gasFeeMultiplier,d.approve,i,s)).then(function(e){n=e})},function(e){me.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},d=new n.ethers.Contract(o,ye,e),h=function(){if(!a)return Promise.resolve(At(e,o,r,i)).then(function(e){if(n.ethers.BigNumber.from(e).gt(n.ethers.BigNumber.from(s))){var t=n.ethers.BigNumber.from(e);return u=1,t}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},Et=function(e,t,r,o,i,s,a,c,u){void 0===a&&(a=!1);try{var l,d=function(r){return l?r:Promise.resolve(ke(e,o,s,c)).then(function(r){return Promise.resolve(h.estimateGas.approve(i,r)).then(function(n){return u?new G.default(n.toString()):Promise.resolve(we(n,e,null==t?void 0:t.gasFeeMultiplier,h.approve,i,r))})})},h=new n.ethers.Contract(o,ye,e),f=function(){if(!a)return Promise.resolve(Ft(e,o,r,i)).then(function(e){if(new G.default(e).greaterThanOrEqualTo(new G.default(s))){var t=new G.default(e).toNumber();return l=1,t}})}();return Promise.resolve(f&&f.then?f.then(d):d(f))}catch(e){return Promise.reject(e)}},jt={datasets:{invalid:"Datasets is not a list, as expected"},algorithm:{serviceId:{missing:"The serviceId key is missing from the algorithm s DDO.",not_found:"The provided serviceId does not exist.",service_not_access_compute:"Service type is neither access, nor compute.",main_service_compute:"If the main service is not compute for this asset when calling initialize endpoint.",compute_services_not_in_same_provider:"Files attached to the compute service are not decrypted by the correct provider. This occurs when both asset and algorithm are requested by their compute service which cannot be decrypted by a single provider as how it is supposed to be."},container:{checksum_prefix:"Container checksum does not start with the prefix sha256:.",mising_entrypoint_image_checksum:"Either entrypoint, either image, or either checksum are missing from the container dictionary from the algorithm s DDO."},documentId:{did_not_found:"The algorithm s DID could not be retrieved from the metadata store, because the algorithm asset does not exist.",missing:"The documentId key is missing from the algorithm s DDO."},transferTxId:{missing:"The transferTxId key is missing from the algorithm s DDO."},missing_meta_documentId:"Either algorithm metadata, or algorithm DID are missing.",did_not_found:"Either algorithm metadata, or algorithm DID are missing.",not_algo:"Either algorithm metadata, or algorithm DID are missing.",in_use_or_not_on_chain:"Either algorithm metadata, or algorithm DID are missing.",meta_oneof_url_rawcode_remote:"Either algorithm metadata, or algorithm DID are missing.",file_unavailable:"One possibility is that the asset could not be retrieved from Aquariuss database. Otherwise, there are issues related to services"},error:{not_trusted_algo_publisher:"The owner of the algorithm's DDO is not a trusted algorithms publishers list.",not_trusted_algo:"The algorithm's DID is not in the asset's trusted algorithms dictionary. ",no_publisherTrustedAlgorithms:"The algorithm's key publisherTrustedAlgorithms does not exist in the algorithm's DDO.",algorithm_file_checksum_mismatch:"filesChecksum from the algorithm's DDO is invalid.",algorithm_container_checksum_mismatch:"The containerChecksum from the algorithm's DDO is invalid.",no_raw_algo_allowed:"The asset does not allow raw algorithms to be run on it.","Asset malformed":"The asset published on chain is malformed, missing some required keys or not compliant with our schemas.","Asset is not consumable.":"Assets metadata status is not in the range of valid status codes for assets. The recognized states for the metadata are defined on our docs.","DID is not a valid algorithm.":"Either the algorithm assets DID is incorrectly typed, either the algorithm timeout expired.","Compute environment does not exist.":"The compute environment provided by the user does not exist, it is not served by our compute-to-data feature. The user can use get_c2d_environments to check the list of available compute environments.","The validUntil value is not correct.":"validUntil value is most probably expired.","Cannot resolve DID":"The dataset DID does not exist in the Metadata store.","Invalid serviceId":"The serviceId of that dataset is not correct.","Unable to get dataset files":"The files of that dataset could not be decrypted or retrieved","cannot decrypt files for this service.":"The files of that dataset could not be decrypted due to the fact that file object, which contains the structure and the type of specific file, is missing from the validation part.","Unsupported type ":"The file object type is not supported by Provider.","malformed file object":"The file object structure is invalid and does not contain the wanted information for the specific file."},order:{fees_not_paid:" Provider fees are not paid."},output:{invalid:"The algorithms validation after the build stage has not been decoded properly as a dictionary."}};function Ct(e,t,r){if(!e.s){if(r instanceof Dt){if(!r.s)return void(r.o=Ct.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Ct.bind(null,e,t),Ct.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Dt=/*#__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{Ct(n,1,i(this.v))}catch(e){Ct(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ct(n,1,t?t(o):o):r?Ct(n,1,r(o)):Ct(n,2,o)}catch(e){Ct(n,2,e)}},n},e}();function xt(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}e.AccessListContract=Ye,e.AccesslistFactory=Qe,e.Aquarius=wt,e.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.oceanNodeUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.nftFactoryAddress=void 0,this.routerFactoryAddress=void 0,this.datatokensABI=void 0,this.fixedRateExchangeAddress=void 0,this.fixedRateExchangeAddressABI=void 0,this.dispenserAddress=void 0,this.dispenserABI=void 0,this.opfCommunityFeeCollector=void 0,this.EnterpriseFeeCollector=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.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0,this.veAllocate=void 0,this.veOCEAN=void 0,this.veDelegation=void 0,this.veFeeDistributor=void 0,this.veDelegationProxy=void 0,this.DFRewards=void 0,this.DFStrategyV1=void 0,this.veFeeEstimate=void 0,this.sdk=void 0,this.accessListFactory=void 0},e.ConfigHelper=Pe,e.DEVELOPMENT_CHAIN_ID=8996,e.Datatoken=Ke,e.Datatoken4=$e,e.DfRewards=st,e.DfStrategyV1=ut,e.Dispenser=Ne,e.EnterpriseFeeCollectorContract=ft,e.EscrowContract=ht,e.FEE_HISTORY_NOT_SUPPORTED="Returned error: Method eth_feeHistory not supported.",e.FixedRateExchange=Ie,e.GASLIMIT_DEFAULT=1e6,e.KNOWN_CONFIDENTIAL_EVMS=pe,e.Logger=fe,e.LoggerInstance=me,e.MAX_UINT_256="115792089237316195423570985008687907853269984665640564039457584007913129639934",e.Nft=Xe,e.NftFactory=qe,e.Provider=bt,e.ProviderInstance=Tt,e.Router=Le,e.SmartContract=Oe,e.SmartContractWithAddress=Re,e.VeAllocate=nt,e.VeFeeDistributor=tt,e.VeFeeEstimate=rt,e.VeOcean=et,e.ZERO_ADDRESS=Ue,e.allowance=Ft,e.allowanceWei=At,e.amountToUnits=ke,e.approve=Et,e.approveWei=St,e.balance=function(e,t,r,o){try{var i=new n.ethers.Contract(t,ye,e);return Promise.resolve(i.balanceOf(r)).then(function(r){return Promise.resolve(be(e,t,r,o))})}catch(e){return Promise.reject(e)}},e.calculateActiveTemplateIndex=Ve,e.configHelperNetworks=ge,e.createAccessListFactory=function(e,t,r){try{var o=new n.ethers.Contract(e,K.default.abi,t);return Promise.resolve(t.getAddress()).then(function(e){var t,n=xt(function(){return Promise.resolve(o.deployAccessListContract("AllowList","ALLOW",!0,e,r||[e],["https://oceanprotocol.com/nft/"])).then(function(e){return function(){if(e&&e.wait)return Promise.resolve(e.wait()).then(function(e){var r=Me(e,"NewAccessList");return t=1,r.args[0]})}()})},function(e){console.log("ERROR createAccessListFactory(): ",e)});return n&&n.then?n.then(function(e){return t?e:null}):t?n:null})}catch(e){return Promise.reject(e)}},e.createAsset=function(t,r,o,i,s,a,c,u,l,d,h,f,m){void 0===c&&(c=!0);try{var v,g,p=S.DDOManager.getDDOClass(a),P=p.getAssetFields().indexedMetadata,y=(null==(v=p.getDDOData())||null==(v=v.stats)||null==(v=v.price)?void 0:v.value)||(null==P||null==(g=P.stats[0])||null==(g=g.prices[0])?void 0:g.price),w=p.getDDOFields(),k=w.chainId,b=w.nftAddress,T=p.getDDOFields().services;if("string"!=typeof s&&"number"!=typeof s)throw new Error('Invalid template! Must be a "number" or a "string"');return Promise.resolve(o.provider.getNetwork()).then(function(v){var g=v.chainId;if(k&&k!==g)throw new Error("Chain ID from DDO is different than the configured network.");var P=(new Pe).getConfig(parseInt(String(g)));return Promise.resolve(Ve(o,P.nftFactoryAddress,s,g)).then(function(s){if(s<1){if(8996!==g)throw new Error("Invalid template index: "+s);s=1}var v=new Xe(o,g),w=new qe(P.nftFactoryAddress,o,g);return Promise.resolve(o.getAddress()).then(function(A){var F,S;function E(e){return S?e:Promise.resolve(j.wait()).then(function(e){var t;function r(e){if(t)return e;function r(){function e(){var e=v.setMetadata,s=b;return Promise.resolve(o.getAddress()).then(function(o){return Promise.resolve(e.call(v,s,o,0,u,"",n.ethers.utils.hexlify(i),t,r)).then(function(){return a.id})})}T[0].datatokenAddress=f,T[0].serviceEndpoint=u;var t,r,i,s=p.makeDid(b=h,k.toString());a=p.updateFields({id:s,nftAddress:b});var l=function(){if(c)return Promise.resolve(Tt.encrypt(a,g,u)).then(function(e){return t=e,Promise.resolve(d.validate(a,o,u)).then(function(e){r=e.hash,i=2})});var e=JSON.stringify(a),n=Buffer.from(e);t=C.hexlify(n),r="0x"+D.createHash("sha256").update(t).digest("hex"),i=0}();return l&&l.then?l.then(e):e()}var s=function(){if("oasis"!==P.sdk)return Promise.resolve(Tt.encrypt(i,g,u)).then(function(e){T[0].files=e});T[0].files=""}();return s&&s.then?s.then(r):r()}var s=Me(e,"NFTCreated"),l=Me(e,"TokenCreated"),h=s.args.newTokenAddress,f=l.args.newTokenAddress;i.datatokenAddress=f,i.nftAddress=h;var m=function(){if("oasis"===P.sdk){var e=new n.ethers.Contract(f,Z.default.abi,o);return xt(function(){return Promise.resolve(e.setFilesObject(n.ethers.utils.toUtf8Bytes(JSON.stringify(i)))).then(function(e){var t=function(){if(e.wait)return Promise.resolve(e.wait()).then(function(){})}();if(t&&t.then)return t.then(function(){})})},function(e){return console.log("Error updating files object with data token and nft addresses: ",e),t=1,null})}}();return m&&m.then?m.then(r):r(m)})}var j,x={name:t,symbol:r,templateIndex:1,tokenURI:"aaa",transferable:!0,owner:A},M={templateIndex:s,cap:"100000",feeAmount:"0",paymentCollector:A,feeToken:l||P.oceanTokenAddress,minter:A,mpFeeAddress:Ue};null!=i&&i.files[0].type&&[e.FileObjectType.ARWEAVE,e.FileObjectType.IPFS,e.FileObjectType.URL].includes(null==i||null==(F=i.files[0])||null==(F=F.type)?void 0:F.toLowerCase())||(console.log('Missing or invalid files object type, defaulting to "url"'),i.type=e.FileObjectType.URL),"oasis"===P.sdk&&(M.filesObject=i,M.accessListFactory=h||P.accessListFactory,M.allowAccessList=f,M.denyAccessList=m);var O=xt(function(){var e=function(){if(!y)return Promise.resolve(w.createNftWithDatatoken(x,M)).then(function(e){j=e});var e=function(){if("0"===y.toString())return Promise.resolve(w.createNftWithDatatokenWithDispenser(x,M,{dispenserAddress:P.dispenserAddress,maxTokens:"1",maxBalance:"100000000",withMint:!0,allowedSwapper:Ue})).then(function(e){j=e});var e={fixedRateAddress:P.fixedRateExchangeAddress,baseTokenAddress:P.oceanTokenAddress,owner:A,marketFeeCollector:A,baseTokenDecimals:18,datatokenDecimals:18,fixedRate:y.toString(),marketFee:"0",allowedConsumer:A,withMint:!0};return Promise.resolve(w.createNftWithDatatokenWithFixedRate(x,M,e)).then(function(e){j=e})}();return e&&e.then?e.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})},function(e){return console.log("ERROR creating NFT bundle",e),S=1,null});return O&&O.then?O.then(E):E(O)})})})}catch(e){return Promise.reject(e)}},e.decimals=function(e,t){try{var r=new n.ethers.Contract(t,ye,e);return Promise.resolve(r.decimals())}catch(e){return Promise.reject(e)}},e.downloadFile=function(e,t){try{return Promise.resolve(fetch(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)}},e.downloadFileBrowser=function(e){var t=new XMLHttpRequest;t.responseType="blob",t.open("GET",e),t.onload=function(){var e=t.getResponseHeader("content-disposition"),r=null==e?void 0:e.match(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/),n=r&&r[1]?r[1]:"file",o=window.URL.createObjectURL(t.response),i=document.createElement("a");i.href=o,i.setAttribute("download",n),document.body.appendChild(i),i.click(),i.remove(),window.URL.revokeObjectURL(o)},t.send()},e.generateDid=function(e,t){return e=n.ethers.utils.getAddress(e),"did:op:"+ae.default(e+t.toString(10)).toString()},e.generateDtName=_e,e.getErrorMessage=function(e){try{var t=JSON.parse(e),r=Object.keys(t)[0];if("error"===r){var n,o=t[r];return(null==(n=jt[r])?void 0:n[o])||"Provider request failed: "+o}var i=t[r];return t[Object.keys(t)[1]]+" : "+i}catch(t){return me.error("[getErrorMessage] error: ",t),e}},e.getEventFromTx=Me,e.getFairGasPrice=Ae,e.getHash=function(e){return ae.default(e).toString()},e.getOceanArtifactsAddresses=He,e.getOceanArtifactsAddressesByChainId=Ze,e.getTokenDecimals=Te,e.isDefined=function(e){return null!=e},e.minAbi=ye,e.orderAsset=function(e,t,r,n,o,i,s,a,c,u,l,d){void 0===c&&(c="0"),void 0===u&&(u=0),void 0===l&&(l=0),void 0===d&&(d=0);try{var h=S.DDOManager.getDDOClass(e),f=h.getAssetFields().datatokens,m=h.getDDOFields(),v=m.chainId,g=m.services;return s||(s={consumeMarketFeeAddress:"0x0000000000000000000000000000000000000000",consumeMarketFeeAmount:"0",consumeMarketFeeToken:"0x0000000000000000000000000000000000000000"}),Promise.resolve(t.provider.getNetwork()).then(function(h){if(v!==h.chainId)throw new Error("Chain ID from DDO is different than the configured network.");if(!f[u].address)throw new Error("The datatoken with index: "+u+" does not exist for the asset with did: "+e.id);if(!g[l].id)throw new Error("There is no service with index: "+l+" defined for the asset with did: "+e.id);return Promise.resolve(n.getId(f[u].address)).then(function(h){return Promise.resolve(n.getFixedRates(f[u].address)).then(function(m){return Promise.resolve(n.getDispensers(f[u].address)).then(function(v){return Promise.resolve(n.getPublishingMarketFee(f[u].address)).then(function(p){function P(e){return a?e:Promise.resolve(k.call(Tt,T,b,0,e,o||r.oceanNodeUri)).then(y)}function y(o){function v(o){function a(o){var i,a={consumer:o,serviceIndex:l,_providerFee:P,_consumeMarketFee:s};return function(e,t){var r,n=-1;e:{for(var o=0;o<t.length;o++){var i=t[o][0];if(i){var s=i();if(s&&s.then)break e;if(s===e){n=o;break}}else n=o}if(-1!==n){do{for(var a=t[n][1];!a;)n++,a=t[n][1];var c=a();if(c&&c.then){r=!0;break e}var u=t[n][2];n++}while(u&&!u());return c}}var l=new Dt,d=Ct.bind(null,l,2);return(r?c.then(h):s.then(function r(s){for(;;){if(s===e){n=o;break}if(++o===t.length){if(-1!==n)break;return void Ct(l,1,c)}if(i=t[o][0]){if((s=i())&&s.then)return void s.then(r).then(void 0,d)}else n=o}do{for(var a=t[n][1];!a;)n++,a=t[n][1];var c=a();if(c&&c.then)return void c.then(h).then(void 0,d);var u=t[n][2];n++}while(u&&!u());Ct(l,1,c)})).then(void 0,d),l;function h(e){for(;;){var r=t[n][2];if(!r||r())break;n++;for(var o=t[n][1];!o;)n++,o=t[n][1];if((e=o())&&e.then)return void e.then(h).then(void 0,d)}Ct(l,1,e)}}(w,[[function(){return"free"},function(){var e=function(e){var t;if(i)return e;function o(e){if(t)return e}var s=function(){if(2===h||4===h)return Promise.resolve(n.buyFromDispenserAndOrder(g[l].datatokenAddress,a,r.dispenserAddress)).then(function(e){return t=1,e})}();return s&&s.then?s.then(o):o(s)},o=function(){if(1===h){var e=new Ne(r.dispenserAddress,t),o=e.dispense,s=f[u].address;return Promise.resolve(t.getAddress()).then(function(t){return Promise.resolve(o.call(e,s,"1",t)).then(function(e){if(!e)throw new Error("Failed to dispense !");return Promise.resolve(e.wait()).then(function(){return Promise.resolve(n.startOrder(f[u].address,a.consumer,a.serviceIndex,a._providerFee,a._consumeMarketFee)).then(function(e){return i=1,e})})})})}}();return o&&o.then?o.then(e):e(o)}],[function(){return"fixed"},function(){var o=new Ie(r.fixedRateExchangeAddress,t);if(!m[d].id)throw new Error("There is no fixed rate exchange with index: "+l+" for the asset with did: "+e.id);return Promise.resolve(o.getFeesInfo(m[d].id)).then(function(e){return Promise.resolve(o.getExchange(m[d].id)).then(function(i){return Promise.resolve(o.calcBaseInGivenDatatokensOut(e.exchangeId,"1",s.consumeMarketFeeAmount)).then(function(l){var d;function m(e){var o;if(d)return e;function s(e){if(o)return e}var c=function(){if(2===h||4===h)return Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(Et(t,r,e,i.baseToken,f[u].address,v,!1)).then(function(e){function t(e){if(!e)throw new Error("Failed to confirm/mine approval transaction!");return Promise.resolve(n.buyFromFreAndOrder(f[u].address,a,g)).then(function(e){return o=1,e})}if(!e)throw new Error("Failed to approve "+i.baseToken+" !");return"number"!=typeof e?Promise.resolve("number"!=typeof e?e.wait():e).then(t):t("number"!=typeof e?e.wait():e)})})}();return c&&c.then?c.then(s):s(c)}var v=new G.default(+l.baseTokenAmount||0).add(new G.default(s.consumeMarketFeeAmount||0)).add(new G.default(+p.publishMarketFeeAmount||0)).toString(),g={exchangeContract:r.fixedRateExchangeAddress,exchangeId:e.exchangeId,maxBaseTokenAmount:v,baseTokenAddress:i.baseToken,baseTokenDecimals:parseInt(i.btDecimals)||18,swapMarketFee:c,marketFeeAddress:p.publishMarketFeeAddress},P=function(){if(1===h)return Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(Et(t,r,e,i.baseToken,r.fixedRateExchangeAddress,v,!1)).then(function(e){function t(e){if(!e)throw new Error("Failed to approve "+i.baseToken+" !");return Promise.resolve(o.buyDatatokens(i.exchangeId,"1",v,p.publishMarketFeeAddress,c)).then(function(e){return Promise.resolve(e.wait()).then(function(e){if(!e)throw new Error("Failed to buy datatoken from fixed rate!");return Promise.resolve(n.startOrder(f[u].address,a.consumer,a.serviceIndex,a._providerFee,a._consumeMarketFee)).then(function(e){return d=1,e})})})}return"number"!=typeof e?Promise.resolve("number"!=typeof e?e.wait():e).then(t):t("number"!=typeof e?e.wait():e)})})}();return P&&P.then?P.then(m):m(P)})})})}],[void 0,function(){throw new Error("Pricing schema not supported !")}]])}return i?a(i):Promise.resolve(t.getAddress()).then(a)}var P=a||o.providerFee,y=function(){if(P&&P.providerFeeAddress!==Ue&&P.providerFeeAmount&&parseInt(P.providerFeeAmount)>0)return function(e,n){try{var o=Promise.resolve(t.getAddress()).then(function(e){return Promise.resolve(St(t,r,e,P.providerFeeToken,g[0].datatokenAddress,P.providerFeeAmount)).then(function(){})})}catch(e){return n()}return o&&o.then?o.then(void 0,n):o}(0,function(){throw new Error("Failed to approve provider fee token "+P.providerFeeToken)})}();return y&&y.then?y.then(v):v()}var w=m.length>0?"fixed":v.length>0?"free":"NOT_ALLOWED",k=a||Tt.initialize,b=a||g[l].id,T=a||e.id;return a?P(y(a)):Promise.resolve(t.getAddress()).then(P)})})})})})}catch(e){return Promise.reject(e)}},e.sendTx=we,e.setContractDefaults=xe,e.signHash=function(e,t){try{var r=n.ethers.utils.arrayify(t);return Promise.resolve(e._legacySignMessage(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)}},e.signRequest=vt,e.sleep=mt,e.transfer=function(e,t,r,o,i,s){try{var a=new n.ethers.Contract(r,ye,e);return Promise.resolve(ke(e,r,i)).then(function(r){return Promise.resolve(a.estimateGas.transfer(o,r)).then(function(n){return s?n:Promise.resolve(we(n,e,null==t?void 0:t.gasFeeMultiplier,a.transfer,o,r))})})}catch(e){return Promise.reject(e)}},e.unitsToAmount=be,e.useOasisSDK=function(e){var t=(new Pe).getConfig(e);return t&&"oasis"===t.sdk}});
2
2
  //# sourceMappingURL=lib.umd.js.map