@oceanprotocol/lib 3.4.3 → 4.0.0-next.1

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.
@@ -1,2 +1,2 @@
1
- import e from"@oceanprotocol/contracts/addresses/address.json";import t from"fs";import{ethers as r}from"ethers";import n from"crypto-js/sha256";import o from"cross-fetch";import i from"decimal.js";import*as s from"@oasisprotocol/sapphire-paratime";import a from"@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json";import c from"@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json";import u from"@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json";import l from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json";import m from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json";import h from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json";import{SHA256 as d}from"crypto-js";import{hexlify as v}from"ethers/lib/utils";import{createHash as f}from"crypto";import g from"@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json";import p from"@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json";import P from"@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json";import y from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json";import w from"@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json";import k from"@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json";import b from"@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json";import T from"@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json";import A from"@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json";import F from"@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json";import S from"@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json";var C=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.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.sideStakingAddress=void 0,this.startBlock=void 0,this.verbose=void 0,this.authMessage=void 0,this.authTokenExpiration=void 0,this.parityUri=void 0,this.threshold=void 0,this.chainId=void 0,this.network=void 0,this.subgraphUri=void 0,this.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0,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};function E(){return E=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},E.apply(this,arguments)}function j(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,D(e,t)}function D(e,t){return D=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},D(e,t)}function x(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function M(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 x(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?x(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var O="0x0000000000000000000000000000000000000000",U=1e6,R="115792089237316195423570985008687907853269984665640564039457584007913129639934",I="Returned error: Method eth_feeHistory not supported.";function N(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var L=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===Z||s===V)&&Number(a)<W?W:s===H&&Number(a)<J?J:qe.includes(s)&&Number(a)<z?z:Number(a),maxFeePerGas:(s===Z||s===V)&&Number(c)<W?W:s===H&&Number(c)<J?J:qe.includes(s)&&Number(c)<z?z:Number(c)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),N(function(){return Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i]))).then(function(e){return Promise.resolve(e.wait()).then(function(){return e})})},function(e){return se.error("Send tx error: ",e),null})})})}catch(e){return Promise.reject(e)}},G=function(e,t,n,o){try{var i=function(e){return"0"===e&&(e=18),r.utils.parseUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(B(e,t)).then(i))}catch(e){return Promise.reject(e)}},_=function(e,t,n,o){try{var i=function(e){return"0"===e&&(e=18),r.utils.formatUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(B(e,t)).then(i))}catch(e){return Promise.reject(e)}},B=function(e,t){try{var n=new r.Contract(t,ae,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},q=function(e,t){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var n=r.BigNumber.from(e.toString());return t?n.mul(t).toBigInt().toString(10):n.toString()})})}catch(e){return Promise.reject(e)}},W=3e10,J=4e9,z=1e10,V=137,Z=80001,H=11155111;function X(e,t){return e}function Q(e,t){var r;return null==e||null==(r=e.events)?void 0:r.filter(function(e){return e.event===t})[0]}var K={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){var t=e||K,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 Y(e,t){return e=r.utils.getAddress(e),"did:op:"+n(e+t.toString(10)).toString()}function ee(e){return n(e).toString()}var te=function(e,t){try{return Promise.resolve(o(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)}};function re(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()}var ne,oe=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}};!function(e){e[e.None=-1]="None",e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Log=2]="Log",e[e.Verbose=3]="Verbose"}(ne||(ne={}));var ie=/*#__PURE__*/function(){function e(e){this.logLevel=void 0,this.logLevel=e,this.logLevel=e||ne.Error}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",ne.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",ne.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",ne.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",ne.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),se=new ie,ae=[{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"}],ce=function(e,t){try{var n=r.utils.arrayify(t);return Promise.resolve(e._legacySignMessage(n)).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)}},ue=function(e,t){try{var n=new r.Contract(t,ae,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},le=function(e,t,n,o){try{var i=new r.Contract(t,ae,e);return Promise.resolve(i.allowance(n,o))}catch(e){return Promise.reject(e)}},me=function(e,t,n,o){try{var i=new r.Contract(t,ae,e);return Promise.resolve(i.balanceOf(n)).then(function(r){return Promise.resolve(_(e,t,r,o))})}catch(e){return Promise.reject(e)}},he=function(e,t,n,o,i){try{var s=new r.Contract(t,ae,e);return Promise.resolve(s.allowance(n,o)).then(function(r){return Promise.resolve(_(e,t,r,i))})}catch(e){return Promise.reject(e)}},de=function(e,t,n,o,i,s){try{var a=new r.Contract(n,ae,e);return Promise.resolve(G(e,n,i)).then(function(r){return Promise.resolve(a.estimateGas.transfer(o,r)).then(function(n){return s?n:Promise.resolve(L(n,e,null==t?void 0:t.gasFeeMultiplier,a.transfer,o,r))})})}catch(e){return Promise.reject(e)}},ve=function(e,t,n,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(m.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(L(r,e,null==t?void 0:t.gasFeeMultiplier,m.approve,i,s)).then(function(e){n=e})},function(e){se.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},m=new r.Contract(o,ae,e),h=function(){if(!a)return Promise.resolve(le(e,o,n,i)).then(function(e){if(r.BigNumber.from(e).gt(r.BigNumber.from(s))){var t=r.BigNumber.from(e);return u=1,t}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},fe=function(e,t,n,o,s,a,c,u,l){void 0===c&&(c=!1);try{var m,h=function(r){return m?r:Promise.resolve(G(e,o,a,u)).then(function(r){return Promise.resolve(d.estimateGas.approve(s,r)).then(function(n){return l?new i(n.toString()):Promise.resolve(L(n,e,null==t?void 0:t.gasFeeMultiplier,d.approve,s,r))})})},d=new r.Contract(o,ae,e),v=function(){if(!c)return Promise.resolve(he(e,o,n,s)).then(function(e){if(new i(e).greaterThanOrEqualTo(new i(a))){var t=new i(e).toNumber();return m=1,t}})}();return Promise.resolve(v&&v.then?v.then(h):h(v))}catch(e){return Promise.reject(e)}},ge={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 pe(e){try{var t=JSON.parse(e),r=Object.keys(t)[0];if("error"===r){var n=t[r];return ge[r][n]||"Provider request failed: "+n}var o=t[r];return t[Object.keys(t)[1]]+" : "+o}catch(t){return se.error("[getErrorMessage] error: ",t),e}}function Pe(e,t,r){if(!e.s){if(r instanceof ye){if(!r.s)return void(r.o=Pe.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Pe.bind(null,e,t),Pe.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var ye=/*#__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{Pe(n,1,i(this.v))}catch(e){Pe(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Pe(n,1,t?t(o):o):r?Pe(n,1,r(o)):Pe(n,2,o)}catch(e){Pe(n,2,e)}},n},e}(),we=function(e,t,r,n,o,s,a,c,u,l,m,h){void 0===u&&(u="0"),void 0===l&&(l=0),void 0===m&&(m=0),void 0===h&&(h=0);try{if(a||(a={consumeMarketFeeAddress:"0x0000000000000000000000000000000000000000",consumeMarketFeeAmount:"0",consumeMarketFeeToken:e.stats.price.tokenAddress||"0x0000000000000000000000000000000000000000"}),!e.datatokens[l].address)throw new Error("The datatoken with index: "+l+" does not exist for the asset with did: "+e.id);if(!e.services[m].id)throw new Error("There is no service with index: "+m+" defined for the asset with did: "+e.id);return Promise.resolve(n.getId(e.datatokens[l].address)).then(function(d){return Promise.resolve(n.getFixedRates(e.datatokens[l].address)).then(function(v){return Promise.resolve(n.getDispensers(e.datatokens[l].address)).then(function(f){return Promise.resolve(n.getPublishingMarketFee(e.datatokens[l].address)).then(function(g){function p(e){return c?e:Promise.resolve(w.call(Ee,b,k,0,e,o||r.providerUri)).then(P)}function P(o){function f(o){function c(o){var s,c={consumer:o,serviceIndex:m,_providerFee:p,_consumeMarketFee:a};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 ye,m=Pe.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 Pe(l,1,c)}if(i=t[o][0]){if((s=i())&&s.then)return void s.then(r).then(void 0,m)}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,m);var u=t[n][2];n++}while(u&&!u());Pe(l,1,c)})).then(void 0,m),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,m)}Pe(l,1,e)}}(y,[[function(){return"free"},function(){var o=function(t){var o;if(s)return t;function i(e){if(o)return e}var a=function(){if(2===d||4===d)return Promise.resolve(n.buyFromDispenserAndOrder(e.services[m].datatokenAddress,c,r.dispenserAddress)).then(function(e){return o=1,e})}();return a&&a.then?a.then(i):i(a)},i=function(){if(1===d){var o=new Je(r.dispenserAddress,t),i=o.dispense,a=e.datatokens[l].address;return Promise.resolve(t.getAddress()).then(function(t){return Promise.resolve(i.call(o,a,"1",t)).then(function(t){if(!t)throw new Error("Failed to dispense !");return Promise.resolve(t.wait()).then(function(){return Promise.resolve(n.startOrder(e.datatokens[l].address,c.consumer,c.serviceIndex,c._providerFee,c._consumeMarketFee)).then(function(e){return s=1,e})})})})}}();return i&&i.then?i.then(o):o(i)}],[function(){return"fixed"},function(){var o=new ze(r.fixedRateExchangeAddress,t);if(!v[h].id)throw new Error("There is no fixed rate exchange with index: "+m+" for the asset with did: "+e.id);return Promise.resolve(o.getFeesInfo(v[h].id)).then(function(s){return Promise.resolve(o.getExchange(v[h].id)).then(function(m){return Promise.resolve(o.calcBaseInGivenDatatokensOut(s.exchangeId,"1",a.consumeMarketFeeAmount)).then(function(h){var v;function f(o){var i;if(v)return o;function s(e){if(i)return e}var a=function(){if(2===d||4===d)return Promise.resolve(t.getAddress()).then(function(o){return Promise.resolve(fe(t,r,o,m.baseToken,e.datatokens[l].address,p,!1)).then(function(t){function r(t){if(!t)throw new Error("Failed to confirm/mine approval transaction!");return Promise.resolve(n.buyFromFreAndOrder(e.datatokens[l].address,c,P)).then(function(e){return i=1,e})}if(!t)throw new Error("Failed to approve "+m.baseToken+" !");return"number"!=typeof t?Promise.resolve("number"!=typeof t?t.wait():t).then(r):r("number"!=typeof t?t.wait():t)})})}();return a&&a.then?a.then(s):s(a)}var p=new i(+h.baseTokenAmount||0).add(new i(a.consumeMarketFeeAmount||0)).add(new i(+g.publishMarketFeeAmount||0)).toString(),P={exchangeContract:r.fixedRateExchangeAddress,exchangeId:s.exchangeId,maxBaseTokenAmount:p,baseTokenAddress:m.baseToken,baseTokenDecimals:parseInt(m.btDecimals)||18,swapMarketFee:u,marketFeeAddress:g.publishMarketFeeAddress},y=function(){if(1===d)return Promise.resolve(t.getAddress()).then(function(i){return Promise.resolve(fe(t,r,i,m.baseToken,r.fixedRateExchangeAddress,p,!1)).then(function(t){function r(t){if(!t)throw new Error("Failed to approve "+m.baseToken+" !");return Promise.resolve(o.buyDatatokens(m.exchangeId,"1",p,g.publishMarketFeeAddress,u)).then(function(t){return Promise.resolve(t.wait()).then(function(t){if(!t)throw new Error("Failed to buy datatoken from fixed rate!");return Promise.resolve(n.startOrder(e.datatokens[l].address,c.consumer,c.serviceIndex,c._providerFee,c._consumeMarketFee)).then(function(e){return v=1,e})})})}return"number"!=typeof t?Promise.resolve("number"!=typeof t?t.wait():t).then(r):r("number"!=typeof t?t.wait():t)})})}();return y&&y.then?y.then(f):f(y)})})})}],[void 0,function(){throw new Error("Pricing schema not supported !")}]])}return s?c(s):Promise.resolve(t.getAddress()).then(c)}var p=c||o.providerFee,P=function(){if(p&&p.providerFeeAddress!==O&&p.providerFeeAmount&&parseInt(p.providerFeeAmount)>0)return function(n,o){try{var i=Promise.resolve(t.getAddress()).then(function(n){return Promise.resolve(ve(t,r,n,p.providerFeeToken,e.services[0].datatokenAddress,p.providerFeeAmount)).then(function(){})})}catch(e){return o()}return i&&i.then?i.then(void 0,o):i}(0,function(){throw new Error("Failed to approve provider fee token "+p.providerFeeToken)})}();return P&&P.then?P.then(f):f()}var y=v.length>0?"fixed":f.length>0?"free":"NOT_ALLOWED",w=c||Ee.initialize,k=c||e.services[m].id,b=c||e.id;return c?p(P(c)):Promise.resolve(t.getAddress()).then(p)})})})})}catch(e){return Promise.reject(e)}},ke=/*#__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 We).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?s.wrap(this.signer):this.signer},t.amountToUnits=function(e,t,r){try{return Promise.resolve(G(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t,r){try{return Promise.resolve(_(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.getFairGasPrice=function(){try{var e;return Promise.resolve(q(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},t.getContract=function(e,t){return X(new r.Contract(e,new r.utils.Interface(JSON.stringify(t||this.abi)),this.signer))},e}(),be=/*#__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 j(t,e),t}(ke);function Te(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Ae=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var n=t.prototype;return n.getDefaultAbi=function(){return g.abi},n.createNFT=function(e,t){try{var r=this;if(e.templateIndex||(e.templateIndex=1),!e.name||!e.symbol){var n=$(),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,O,O,e.tokenURI,e.transferable,e.owner)).then(function(n){return t?n:Te(function(){var t;return Promise.resolve(L(n,r.getSignerAccordingSdk(),null==(t=r.config)?void 0:t.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,O,O,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 Q(e,"NFTCreated").args[0]})})},function(e){console.error("Creation of NFT failed: "+e)})})})})}catch(e){return Promise.reject(e)}},n.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},n.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},n.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},n.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},n.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}catch(e){return Promise.reject(e)}},n.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)}},n.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},n.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},n.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},n.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===O)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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},n.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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},n.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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},n.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===O)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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},n.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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},n.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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},n.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(L(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},n.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(L(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},n.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(L(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},n.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(L(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},n.getErcCreationParams=function(e){try{var t,n,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||n],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(n){return{templateIndex:c,strings:s,addresses:o,uints:[t,n],bytess:e.filesObject?[r.utils.toUtf8Bytes(JSON.stringify(e.filesObject))]:[]}})})},i=this;if(!e.name||!e.symbol){var s=$();t=s.name,n=s.symbol}var a=18,c=function(){if(e.feeToken!==O){var t=Te(function(){return Promise.resolve(B(i.signer,e.feeToken)).then(function(e){a=e})},function(e){se.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)}},n.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=O);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}(be),Fe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var n=t.prototype;return n.getDefaultAbi=function(){return h.abi},n.createDatatoken=function(e,t,n,o,i,s,a,c,u,l,m,h,d,v,f,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(m||(m=1),!u||!l){var P=$();u=P.name,l=P.symbol}var y=p.getContract(e);return Promise.resolve(y.provider.getNetwork()).then(function(e){function t(){var e=y.estimateGas,t=e.createERC20,P=[u,l],w=m;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,[n,o,i,s],[k,b],[])).then(function(e){var t;if(g)return e;var P=[n,o,i,s];d&&(P.push(d.toLowerCase()),P.push(v?v.toLowerCase():O),P.push(f||O));var w=[u,l],k=m,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(n){return Promise.resolve(L(e,A,T,b,k,w,P,[t,n],h?[r.utils.toUtf8Bytes(h)]:[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=Q(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})}var P=Ge(e.chainId),w=function(){if(h)return Promise.resolve(Re(p.signer,P.ERC721Factory,4)).then(function(e){m=e})}();return w&&w.then?w.then(t):t()})})}catch(e){return Promise.reject(e)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addManager,r))})})}catch(e){return Promise.reject(e)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeManager,r))})})}catch(e){return Promise.reject(e)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToCreateERC20List,r))})})}catch(e){return Promise.reject(e)}},n.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(L(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)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToMetadataList,r))})})}catch(e){return Promise.reject(e)}},n.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(L(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)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addTo725StoreList,r))})})}catch(e){return Promise.reject(e)}},n.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(L(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)}},n.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(L(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.cleanPermissions))})})}catch(e){return Promise.reject(e)}},n.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(L(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.transferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},n.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(L(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.safeTransferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},n.setMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l=this,m=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(m.estimateGas.setMetaData(r,n,o,i,s,a,c)).then(function(e){var t;return u?e:Promise.resolve(L(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,m.setMetaData,r,n,o,i,s,a,c))})})}catch(e){return Promise.reject(e)}},n.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=E({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(L(e,o.signer,null==(r=o.config)?void 0:r.gasFeeMultiplier,i.setMetaDataAndTokenURI,t))})})}catch(e){return Promise.reject(e)}},n.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setMetaDataState,r))})})}catch(e){return Promise.reject(e)}},n.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(L(e,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,o.setTokenURI,"1",t))})}catch(e){return Promise.reject(e)}},n.getNftOwner=function(e){try{var t=this.getContract(e);return Promise.resolve(t.ownerOf(1))}catch(e){return Promise.reject(e)}},n.getNftPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.getPermissions(t))}catch(e){return Promise.reject(e)}},n.getMetadata=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getMetaData())}catch(e){return Promise.reject(e)}},n.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},n.setData=function(e,t,n,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=r.utils.keccak256(n),u=r.utils.hexlify(r.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(c,u)).then(function(e){var t;return i?e:Promise.resolve(L(e,s.getSignerAccordingSdk(),null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,c,u))})})}catch(e){return Promise.reject(e)}},n.getData=function(e,t){try{var n=this.getContract(e),o=r.utils.keccak256(t);return Promise.resolve(n.getData(o)).then(function(e){return e?r.utils.toUtf8String(e):null})}catch(e){return Promise.reject(e)}},n.getTokenURI=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.tokenURI(t))}catch(e){return Promise.reject(e)}},n.isDatatokenDeployed=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isDeployed(t))}catch(e){return Promise.reject(e)}},t}(ke);function Se(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Ce=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getEndpoints=function(e){try{var t=this;return Promise.resolve(Se(function(){return Promise.resolve(t.getData(e)).then(function(e){return Promise.resolve(e.json())})},function(e){throw se.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,i){try{var s=function(){function s(){var e=a.getEndpointURL(i,"nonce")?a.getEndpointURL(i,"nonce").urlPath:null;return e?Se(function(){return Promise.resolve(o(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 se.error(e),new Error(e.message)}):null}var c=function(){if(!i)return Promise.resolve(a.getServiceEndpoints(e,n)).then(function(e){i=e})}();return c&&c.then?c.then(s):s()},a=this,c=function(){if(!n)return Promise.resolve(a.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(c&&c.then?c.then(s):s())}catch(e){return Promise.reject(e)}},t.signProviderRequest=function(e,t){try{var n=r.utils.solidityKeccak256(["bytes"],[r.utils.hexlify(r.utils.toUtf8Bytes(t))]),o=r.utils.arrayify(n);return Promise.resolve(e.getChainId()).then(function(t){return Se(function(){return Promise.resolve(e.signMessage(o))},function(r){return se.error("Sign provider message error: ",r),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 i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){var s=(i.getEndpointURL(r,"encrypt")?i.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return s?Se(function(){return Promise.resolve(o(s,{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 se.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n,i){void 0===n&&(n=!1);try{var s=this;return Promise.resolve(s.getEndpoints(r)).then(function(a){return Promise.resolve(s.getServiceEndpoints(r,a)).then(function(r){function a(e){var t;function r(e){return t?e:Promise.resolve(c.json()).then(function(e){throw se.error("File info call failed: ",c.status,c.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){for(var r,n=M(e);!(r=n()).done;)l.push(r.value);return t=1,l})}();return n&&n.then?n.then(r):r(n)}var c,u={did:e,serviceId:t,checksum:n},l=[],m=s.getEndpointURL(r,"fileinfo")?s.getEndpointURL(r,"fileinfo").urlPath:null;if(!m)return null;var h=Se(function(){return Promise.resolve(o(m,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw se.error("File info call failed: "),se.error(e),new Error(e)});return h&&h.then?h.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var i=this;return Promise.resolve(i.getEndpoints(t)).then(function(s){return Promise.resolve(i.getServiceEndpoints(t,s)).then(function(t){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw se.error("File info call failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){for(var r,n=M(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var a,c=E({},e,{checksum:r}),u=[],l=i.getEndpointURL(t,"fileinfo")?i.getEndpointURL(t,"fileinfo").urlPath:null;if(!l)return null;var m=Se(function(){return Promise.resolve(o(l,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){a=e})},function(e){throw se.error("File info call failed: "),se.error(e),new Error(e)});return m&&m.then?m.then(s):s()})})}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 i;function s(e){var t;if(null!=(t=a)&&t.ok){var r,o=a.json();return Array.isArray(o)?((r={})[n.chainId]=o,r):o}return Promise.resolve(a.json()).then(function(e){throw se.error("Fetch compute env failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var a,c=null==(i=r.getEndpointURL(e,"computeEnvironments"))?void 0:i.urlPath;if(!c)return null;var u=Se(function(){return Promise.resolve(o(c,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){a=e})},function(e){throw se.error("Fetch compute env failed: "),se.error(e),new Error(e)});return u&&u.then?u.then(s):s()})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,i,s,a,c,u){try{var l=this;return Promise.resolve(l.getEndpoints(i)).then(function(m){return Promise.resolve(l.getServiceEndpoints(i,m)).then(function(i){function m(e){var t;function r(e){return t?e:Promise.resolve(h.json()).then(function(e){throw se.error("Provider initialized failed: ",h.status,h.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(200===(null==(e=h)?void 0:e.status))return Promise.resolve(h.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var h,d=l.getEndpointURL(i,"initialize")?l.getEndpointURL(i,"initialize").urlPath:null;if(!d)return null;d+="?documentId="+e,d+="&serviceId="+t,d+="&fileIndex="+r,d+="&consumerAddress="+n,a&&(d+="&userdata="+encodeURI(JSON.stringify(a))),c&&(d+="&environment="+encodeURI(c)),u&&(d+="&validUntil="+u);var v=Se(function(){return Promise.resolve(o(d,{method:"GET",headers:{"Content-Type":"application/json"},signal:s})).then(function(e){h=e})},function(e){throw se.error("Provider initialized failed: "),se.error(e),new Error("Provider initialize failed url: "+d+" ")});return v&&v.then?v.then(m):m()})})}catch(e){return Promise.reject(e)}},t.initializeCompute=function(e,t,r,n,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(i)).then(function(u){return Promise.resolve(c.getServiceEndpoints(i,u)).then(function(i){function u(e){var t;function r(e){return t?e:Promise.resolve(l.json()).then(function(e){throw se.error("Initialize compute failed: ",l.status,l.statusText,e),se.error("Payload was:",m),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=l)&&e.ok)return Promise.resolve(l.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var l,m={datasets:e,algorithm:t,compute:{env:r,validUntil:n},consumerAddress:s},h=c.getEndpointURL(i,"initializeCompute")?c.getEndpointURL(i,"initializeCompute").urlPath:null;if(!h)return null;var d=Se(function(){return Promise.resolve(o(h,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){l=e})},function(e){throw se.error("Initialize compute failed: "),se.error(e),new Error("ComputeJob cannot be initialized")});return d&&d.then?d.then(u):u()})})}catch(e){return Promise.reject(e)}},t.getDownloadUrl=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(c){return Promise.resolve(a.getServiceEndpoints(o,c)).then(function(u){var l=a.getEndpointURL(u,"download")?a.getEndpointURL(u,"download").urlPath:null;return l?Promise.resolve(i.getAddress()).then(function(m){return Promise.resolve(a.getNonce(o,m,null,c,u)).then(function(o){var c=(o+1).toString();return Promise.resolve(a.signProviderRequest(i,e+c)).then(function(o){var i=l;return i+="?fileIndex="+r,i+="&documentId="+e,i+="&transferTxId="+n,i+="&serviceId="+t,i+="&consumerAddress="+m,i+="&nonce="+c,i+="&signature="+o,s&&(i+="&userdata="+encodeURI(JSON.stringify(s))),i})})}):null})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(e)).then(function(l){return Promise.resolve(u.getServiceEndpoints(e,l)).then(function(m){var h=u.getEndpointURL(m,"computeStart")?u.getEndpointURL(m,"computeStart").urlPath:null;return Promise.resolve(t.getAddress()).then(function(d){return Promise.resolve(u.getNonce(e,d,s,l,m)).then(function(e){var l=(e+1).toString(),m=d;return m+=n.documentId,m+=l,Promise.resolve(u.signProviderRequest(t,m)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=se.error,n=u.statusText,o=u.status;return Promise.resolve(u.json()).then(function(e){return r.call(se,"Compute start failed: ",o,n,e),se.error("Payload was:",m),null})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,m=Object();if(m.consumerAddress=d,m.signature=e,m.nonce=l,m.environment=r,m.dataset=n,m.algorithm=i,a&&(m.additionalDatasets=a),c&&(m.output=c),!h)return null;var v=Se(function(){return Promise.resolve(o(h,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){u=e})},function(e){throw se.error("Compute start failed:"),se.error(e),se.error("Payload was:",m),new Error("HTTP request failed calling Provider")});return v&&v.then?v.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(n)).then(function(e){return Promise.resolve(c.getServiceEndpoints(n,e)).then(function(u){var l=c.getEndpointURL(u,"computeStop")?c.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(c.getNonce(n,t,a,e,u)).then(function(e){var n=(e+1).toString(),u=t;return Promise.resolve(c.signProviderRequest(i,u+=r||"")).then(function(e){function i(e){var t;function r(e){return t?e:Promise.resolve(u.json()).then(function(e){throw se.error("Compute stop failed: ",u.status,u.statusText,e),se.error("Payload was:",m),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,m=Object();if(m.signature=e,m.agreementId=c.noZeroX(s),m.consumerAddress=t,m.nonce=n,r&&(m.jobId=r),!l)return null;var h=Se(function(){return Promise.resolve(o(l,{method:"PUT",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){u=e})},function(e){throw se.error("Compute stop failed:"),se.error(e),se.error("Payload was:",m),new Error("HTTP request failed calling Provider")});return h&&h.then?h.then(i):i()})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,n,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 se.error("Get compute status failed:",c.status,c.statusText,e),new Error(JSON.stringify(e))})}se.error("Get compute status failed:",c.status,c.statusText);var o=function(){var 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(){var 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="+s.noZeroX(n)||"",l+=r&&"&jobId="+r||"",!u)return null;var m=Se(function(){return Promise.resolve(o(u+l,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw se.error("Get compute status failed"),se.error(e),new Error(e)});return m&&m.then?m.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getComputeResultUrl=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(e)).then(function(i){return Promise.resolve(o.getServiceEndpoints(e,i)).then(function(s){var a=o.getEndpointURL(s,"computeResult")?o.getEndpointURL(s,"computeResult").urlPath:null,c=o.getNonce;return Promise.resolve(t.getAddress()).then(function(u){return Promise.resolve(c.call(o,e,u,null,i,s)).then(function(e){var i=(e+1).toString();return Promise.resolve(t.getAddress()).then(function(e){return e+=r,e+=n.toString(),e+=i,Promise.resolve(o.signProviderRequest(t,e)).then(function(e){if(!a)return null;var o=a;return Promise.resolve(t.getAddress()).then(function(t){return o+="?consumerAddress="+t,o+="&jobId="+r,o+="&index="+n.toString(),o+="&nonce="+i,o+=e&&"&signature="+e||""})})})})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(c){var u=s.getEndpointURL(c,"computeDelete")?s.getEndpointURL(c,"computeDelete").urlPath:null,l=s.getNonce;return Promise.resolve(t.getAddress()).then(function(m){return Promise.resolve(l.call(s,n,m,i,a,c)).then(function(n){var a=(n+1).toString();return Promise.resolve(t.getAddress()).then(function(n){return n+=r||"",n+=e&&""+s.noZeroX(e)||"",n+=a,Promise.resolve(s.signProviderRequest(t,n)).then(function(n){var a=Object();return a.documentId=s.noZeroX(e),Promise.resolve(t.getAddress()).then(function(e){var t;function s(e){var r;function n(e){return r?e:Promise.resolve(t.json()).then(function(e){throw se.error("Delete compute job failed:",t.status,t.statusText,e),se.error("Payload was:",a),new Error(JSON.stringify(e))})}var o=function(){var e;if(null!=(e=t)&&e.ok)return Promise.resolve(t.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}if(a.consumerAddress=e,a.jobId=r,n&&(a.signature=n),!u)return null;var c=Se(function(){return Promise.resolve(o(u,{method:"DELETE",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){t=e})},function(e){throw se.error("Delete compute job failed:"),se.error(e),se.error("Payload was:",a),new Error("HTTP request failed calling Provider")});return c&&c.then?c.then(s):s()})})})})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(Se(function(){return Promise.resolve(o(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 se.error("Error validating provider: "+e.message),!1}))}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 se.debug("Not input string:"),se.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(se.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},t.getData=function(e){try{return Promise.resolve(o(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},e}(),Ee=new Ce;function je(e,t,r){if(!e.s){if(r instanceof De){if(!r.s)return void(r.o=je.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(je.bind(null,e,t),je.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var De=/*#__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{je(n,1,i(this.v))}catch(e){je(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?je(n,1,t?t(o):o):r?je(n,1,r(o)):je(n,2,o)}catch(e){je(n,2,e)}},n},e}();function xe(e){return e instanceof De&&1&e.s}function Me(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Oe=function(e,t,n){try{var o=new r.Contract(e,P.abi,t);return Promise.resolve(t.getAddress()).then(function(e){var t,r=Me(function(){return Promise.resolve(o.deployAccessListContract("AllowList","ALLOW",!0,e,n||[e],["https://oceanprotocol.com/nft/"])).then(function(e){return function(){if(e&&e.wait)return Promise.resolve(e.wait()).then(function(e){var r=Q(e,"NewAccessList");return t=1,r.args[0]})}()})},function(e){console.log("ERROR createAccessListFactory(): ",e)});return r&&r.then?r.then(function(e){return t?e:null}):t?r:null})}catch(e){return Promise.reject(e)}},Ue=function(e,t,n,o,i,s,a,c,u,l,m,h,g){void 0===a&&(a=!0);try{if("string"!=typeof i&&"number"!=typeof i)throw new Error('Invalid template! Must be a "number" or a "string"');return Promise.resolve(n.provider.getNetwork()).then(function(p){var P=p.chainId;if(s.chainId!==P)throw new Error("Chain ID from DDO is different than the configured network.");if(s.id)throw new Error("DID already filled in.");var w=(new We).getConfig(parseInt(String(P)));return Promise.resolve(Re(n,w.nftFactoryAddress,i)).then(function(i){if(i<1){if(P!==Ie)throw new Error("Invalid template index: "+i);i=1}var p=new Fe(n,P),k=new Ae(w.nftFactoryAddress,n);return Promise.resolve(n.getAddress()).then(function(b){var T;function A(e){return T?e:Promise.resolve(F.wait()).then(function(e){var t;function i(e){if(t)return e;function i(){function e(){var e=p.setMetadata;return Promise.resolve(n.getAddress()).then(function(n){return Promise.resolve(e.call(p,h,n,0,c,"",r.utils.hexlify(i),t,o)).then(function(){return s.id})})}var t,o,i;s.services[0].datatokenAddress=g,s.services[0].serviceEndpoint=c,s.nftAddress=h,s.id="did:op:"+d(r.utils.getAddress(h)+P.toString(10));var u=function(){if(a)return Promise.resolve(Ee.encrypt(s,P,c)).then(function(e){return t=e,Promise.resolve(l.validate(s)).then(function(e){o=e.hash,i=2})});var e=JSON.stringify(s),r=Buffer.from(e);t=v(r),o="0x"+f("sha256").update(t).digest("hex"),i=0}();return u&&u.then?u.then(e):e()}var u=function(){if("oasis"!==w.sdk)return Promise.resolve(Ee.encrypt(o,P,c)).then(function(e){s.services[0].files=e});s.services[0].files=""}();return u&&u.then?u.then(i):i()}var u=Q(e,"NFTCreated"),m=Q(e,"TokenCreated"),h=u.args.newTokenAddress,g=m.args.newTokenAddress;o.datatokenAddress=g,o.nftAddress=h;var k=function(){if("oasis"===w.sdk){var e=new r.Contract(g,y.abi,n);return Me(function(){return Promise.resolve(e.setFilesObject(r.utils.toUtf8Bytes(JSON.stringify(o)))).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 k&&k.then?k.then(i):i(k)})}s.chainId=parseInt(P.toString(10));var F,S={name:e,symbol:t,templateIndex:1,tokenURI:"aaa",transferable:!0,owner:b},C={templateIndex:i,cap:"100000",feeAmount:"0",paymentCollector:b,feeToken:u||w.oceanTokenAddress,minter:b,mpFeeAddress:O};"oasis"===w.sdk&&(C.filesObject=o,C.accessListFactory=m||w.accessListFactory,C.allowAccessList=h,C.denyAccessList=g);var E=Me(function(){var e=function(){var e,t;if(null==(e=s.stats)||null==(t=e.price)||!t.value)return Promise.resolve(k.createNftWithDatatoken(S,C)).then(function(e){F=e});var r,n,o="0"===(null==(r=s.stats)||null==(n=r.price)?void 0:n.value)?Promise.resolve(k.createNftWithDatatokenWithDispenser(S,C,{dispenserAddress:w.dispenserAddress,maxTokens:"1",maxBalance:"100000000",withMint:!0,allowedSwapper:O})).then(function(e){F=e}):Promise.resolve(k.createNftWithDatatokenWithFixedRate(S,C,{fixedRateAddress:w.fixedRateExchangeAddress,baseTokenAddress:w.oceanTokenAddress,owner:b,marketFeeCollector:b,baseTokenDecimals:18,datatokenDecimals:18,fixedRate:s.stats.price.value,marketFee:"0",allowedConsumer:b,withMint:!0})).then(function(e){F=e});return o&&o.then?o.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})},function(e){return console.log("ERROR creating NFT bundle",e),T=1,null});return E&&E.then?E.then(A):A(E)})})})}catch(e){return Promise.reject(e)}},Re=function(e,t,n){try{var o="number"==typeof n,i=new Ae(t,e);return Promise.resolve(i.getCurrentTokenTemplateCount()).then(function(t){var s;function a(e){return s?e:-1}var c=1,u=function(e,t,r){for(var n;;){var o=e();if(xe(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!xe(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!xe(s)){n=2;break}}}var a=new De,c=je.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(m)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!xe(s))return void s.then(m).then(void 0,c);if(!(o=e())||xe(o)&&!o.v)return void je(a,1,i);if(o.then)return void o.then(l).then(void 0,c);xe(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):je(a,1,i)}function m(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):je(a,1,i)}}(function(){return!s&&c<=t},function(){return c++},function(){return Promise.resolve(i.getTokenTemplate(c)).then(function(t){var i=new r.Contract(t.templateAddress,p.abi,e);return o?Promise.resolve(i.connect(e).getId()).then(function(e){if(t.isActive&&e.toString()===n.toString())return s=1,c}):t.isActive&&t.templateAddress===n.toString()?(s=1,c):void 0})});return u&&u.then?u.then(a):a(u)})}catch(e){return Promise.reject(e)}},Ie=8996;function Ne(e){var t=(new We).getConfig(e);return t&&"oasis"===t.sdk}function Le(){try{if(process.env.ADDRESS_FILE){var r=t.readFileSync(process.env.ADDRESS_FILE,"utf8");return JSON.parse(r)}return e}catch(t){return e}}function Ge(e){try{var t=Le();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 _e={chainId:null,network:"unknown",metadataCacheUri:"https://v4.aquarius.oceanprotocol.com",nodeUri:"http://127.0.0.1:8545",providerUri:"https://v4.provider.oceanprotocol.com",subgraphUri:null,explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},Be=[E({},_e),E({},_e,{chainId:8996,network:"development",metadataCacheUri:"http://172.15.0.5:5000",providerUri:"http://172.15.0.4:8030",subgraphUri:"https://172.15.0.15:8000",sdk:"evm"}),E({},_e,{chainId:11155111,network:"sepolia",nodeUri:"https://sepolia.infura.io/v3",subgraphUri:"https://v4.subgraph.sepolia.oceanprotocol.com",explorerUri:"https://sepolia.etherscan.io",gasFeeMultiplier:1.1,sdk:"evm"}),E({},_e,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",subgraphUri:"https://v4.subgraph.mainnet.oceanprotocol.com",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05,sdk:"evm"}),E({},_e,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",subgraphUri:"https://v4.subgraph.polygon.oceanprotocol.com",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",gasFeeMultiplier:1.6,sdk:"evm"}),E({},_e,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",providerUri:"https://v4.provider.gaiaxtestnet.oceanprotocol.com",subgraphUri:"https://v4.subgraph.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com",sdk:"evm"}),E({},_e,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",subgraphUri:"https://v4.subgraph.mumbai.oceanprotocol.com",explorerUri:"https://mumbai.polygonscan.com",gasFeeMultiplier:1.1,sdk:"evm"}),E({},_e,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",subgraphUri:"https://v4.subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05,sdk:"evm"}),E({},_e,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",subgraphUri:"https://v4.subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05,sdk:"evm"}),E({},_e,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",subgraphUri:"https://v4.subgraph.moonriver.oceanprotocol.com",explorerUri:"https://moonriver.moonscan.io/",gasFeeMultiplier:1.05,sdk:"evm"}),E({},_e,{chainId:100,network:"gen-x-testnet",nodeUri:"https://rpc.genx.minimal-gaia-x.eu",metadataCacheUri:"https://aquarius.v4.delta-dao.com",providerUri:"https://provider.v4.genx.delta-dao.com",subgraphUri:"https://subgraph.v4.genx.minimal-gaia-x.eu",explorerUri:"https://explorer.genx.minimal-gaia-x.eu/",gasFeeMultiplier:1,sdk:"evm"}),E({},_e,{chainId:10,network:"optimism",nodeUri:"https://mainnet.optimism.io",subgraphUri:"https://v4.subgraph.optimism.oceanprotocol.com",explorerUri:"https://optimistic.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),E({},_e,{chainId:11155420,network:"optimism_sepolia",nodeUri:"https://sepolia.optimism.io",subgraphUri:"https://v4.subgraph.optimism-sepolia.oceanprotocol.com",explorerUri:"https://sepolia-optimism.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),E({},_e,{chainId:23294,network:"oasis_sapphire",nodeUri:"https://sapphire.oasis.io",subgraphUri:"https://v4.subgraph.sapphire-mainnet.oceanprotocol.com/",explorerUri:"https://explorer.oasis.io/mainnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),E({},_e,{chainId:23295,network:"oasis_sapphire_testnet",nodeUri:"https://testnet.sapphire.oasis.dev",subgraphUri:"https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph",explorerUri:"https://explorer.oasis.io/testnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),E({},_e,{chainId:32456,network:"pontus-x-devnet",nodeUri:"https://rpc.dev.pontus-x.eu",metadataCacheUri:"https://aquarius.dev.pontus-x.eu",providerUri:"https://provider.dev.pontus-x.eu",subgraphUri:"https://subgraph.dev.pontus-x.eu",explorerUri:"https://explorer.dev.pontus-x.eu/testnet/pontusx",sdk:"evm"})],qe=[23294,23295],We=/*#__PURE__*/function(){function r(){}var n=r.prototype;return n.getAddressesFromEnv=function(t,r){var n;if(r&&r[t]){var o=r[t];n=E({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},process.env.AQUARIUS_URL&&{metadataCacheUri:process.env.AQUARIUS_URL},process.env.PROVIDER_URL&&{providerUri:process.env.PROVIDER_URL})}else if(e[t]){var i=e[t];n=E({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},process.env.AQUARIUS_URL&&{metadataCacheUri:process.env.AQUARIUS_URL},process.env.PROVIDER_URL&&{providerUri:process.env.PROVIDER_URL})}return n},n.getConfig=function(e,r){var n,o="string"==typeof e?"network":"chainId",i=Be.find(function(t){return t[o]===e});if(!i)return se.error("No config found for given network '"+e+"'"),null;try{n=process.env.ADDRESS_FILE?JSON.parse(t.readFileSync(process.env.ADDRESS_FILE,"utf8")):null}catch(e){console.log(e),n=null}var s=this.getAddressesFromEnv(i.network,n);return!s&&qe.includes(i.chainId)&&(s=this.getAddressesFromEnv(i.network.replace("sapph","saph"),n)),"sdk"in i&&null!==i.sdk||(i.sdk=qe.includes(i.chainId)?"oasis":"evm"),i.accessListFactory=s.accessListFactory,i=E({},i,s),E({},i,{nodeUri:r?i.nodeUri+"/"+r:i.nodeUri})},r}(),Je=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return a.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[2],n=e[1],o=e[0];return Promise.resolve(t.unitsToAmount(null,e[3],18)).then(function(i){return Promise.resolve(t.unitsToAmount(null,e[4],18)).then(function(s){return Promise.resolve(t.unitsToAmount(null,e[5],18)).then(function(t){return{active:o,owner:n,isMinter:r,maxTokens:i,maxBalance:s,balance:t,allowedSwapper:e[6]}})})})})}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(L(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(L(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(L(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(L(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(L(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(L(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 i(e).greaterThanOrEqualTo(o.maxBalance)||new i(String(n)).greaterThan(o.maxTokens)||!new i(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(be),ze=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return c.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=O),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(L(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=O),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(L(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(L(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(L(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(L(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(L(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(m){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(d){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(v){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:m,btBalance:h,dtSupply:d,btSupply:v,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(L(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(L(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(L(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(L(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(L(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(L(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(L(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(L(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(be),Ve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return u.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(L(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(L(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(L(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(L(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(L(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(L(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(L(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(L(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}(be),Ze=/*#__PURE__*/function(e){j(n,e);var t=n.prototype;function n(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||m.abi,s.nft=new Fe(s.signer,r),s}return t.getDefaultAbi=function(){return l.abi},t.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,G(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(L(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,G(null,null,r,18)))})}catch(e){return Promise.reject(e)}},t.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=O);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(L(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)}},t.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=O),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(L(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)}},t.mint=function(e,t,r,n,o){try{var s=this,a=s.getContract(e);return Promise.resolve(s.getPermissions(e,t)).then(function(c){if(!0!==c.minter)throw new Error("Caller is not Minter");return Promise.resolve(s.getCap(e)).then(function(e){if(new i(e).gte(r))return Promise.resolve(a.estimateGas.mint(n||t,G(null,null,r,18))).then(function(e){var i;return o?e:Promise.resolve(L(e,s.getSignerAccordingSdk(),null==(i=s.config)?void 0:i.gasFeeMultiplier,a.mint,n||t,G(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},t.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(L(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)}},t.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},t.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(G(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},t.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e,s.abi);return o||(o={consumeMarketFeeAddress:O,consumeMarketFeeToken:O,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var c;return i?e:Promise.resolve(L(e,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},t.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(L(r,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},t.setData=function(e,t,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),a=r.utils.hexlify(r.utils.toUtf8Bytes(n));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(L(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},t.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(L(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},t.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},t.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)}},t.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},t.getId=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getId())}catch(e){return Promise.reject(e)}},t.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},t.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},t.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},t.getFixedRates=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getFixedRates())}catch(e){return Promise.reject(e)}},t.getDispensers=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getDispensers())}catch(e){return Promise.reject(e)}},t.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},t.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)}},t.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(L(e,s.getSignerAccordingSdk(),null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},t.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)}},t.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(G(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(G(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)}},n}(ke),He=/*#__PURE__*/function(e){j(r,e);var t=r.prototype;function r(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}return t.getDefaultAbi=function(){return y.abi},t.setFileObj=function(e){this.fileObject=e},t.getAllowlistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getAllowListContract())}catch(e){return Promise.reject(e)}},t.getDenylistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getDenyListContract())}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setAllowListContract,t))})})}catch(e){return Promise.reject(e)}},t.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(L(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setDenyListContract,t))})})}catch(e){return Promise.reject(e)}},t.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(L(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.functions.setFilesObject,n.fileObject))})})}catch(e){return Promise.reject(e)}},t.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)}},r}(Ze),Xe=/*#__PURE__*/function(e){j(r,e);var t=r.prototype;function r(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}return t.getDefaultAbi=function(){return w.abi},t.getTokenUri=function(e){try{return Promise.resolve(this.contract.tokenURI(e))}catch(e){return Promise.reject(e)}},t.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},t.getId=function(){try{return Promise.resolve(this.contract.getId())}catch(e){return Promise.reject(e)}},t.getName=function(){try{return Promise.resolve(this.contract.name())}catch(e){return Promise.reject(e)}},t.getSymbol=function(){try{return Promise.resolve(this.contract.symbol())}catch(e){return Promise.reject(e)}},t.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)}},t.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(L(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.mint,e,t))})}catch(e){return Promise.reject(e)}},t.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(L(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.batchMint,e,t))})}catch(e){return Promise.reject(e)}},t.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(L(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.burn,e))})}catch(e){return Promise.reject(e)}},t.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(L(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.transferOwnership,e))})}catch(e){return Promise.reject(e)}},t.renounceOwnership=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.renounceOwnership()).then(function(r){var n;return e?r:Promise.resolve(L(r,t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.renounceOwnership))})}catch(e){return Promise.reject(e)}},r}(be),Qe=/*#__PURE__*/function(e){j(r,e);var t=r.prototype;function r(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abi=i||s.getDefaultAbi(),s}return t.getDefaultAbi=function(){return P.abi},t.deployAccessListContract=function(e,t,r,n,o,i,s){void 0===n&&(n=!1);try{var a=this;if(!e||!t){var c=$();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(L(c,a.getSignerAccordingSdk(),null==(m=a.config)?void 0:m.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 Q(e,"NewAccessList").args[0]})})}catch(e){return u(e)}var m;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)}},t.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},t.isSoulbound=function(e){try{return Promise.resolve(this.contract.isSoulBound(e))}catch(e){return Promise.reject(e)}},t.isDeployed=function(e){try{return Promise.resolve(this.contract.isDeployed(e))}catch(e){return Promise.reject(e)}},t.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===O)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(L(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.functions.changeTemplateAddress,t))})})}catch(e){return Promise.reject(e)}},r}(be),Ke=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return k.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(L(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(L(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(L(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(L(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(L(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}(be),$e=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return b.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(L(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(L(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}(be),Ye=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return T.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}(be),et=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return A.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(L(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(L(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}(be);function tt(e,t,r){if(!e.s){if(r instanceof rt){if(!r.s)return void(r.o=tt.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(tt.bind(null,e,t),tt.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var rt=/*#__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{tt(n,1,i(this.v))}catch(e){tt(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?tt(n,1,t?t(o):o):r?tt(n,1,r(o)):tt(n,2,o)}catch(e){tt(n,2,e)}},n},e}(),nt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return F.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(L(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(L(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})},m=-1,function e(t){try{for(;++m<a.length;)if((t=c(m))&&t.then){if(!((r=t)instanceof rt&&1&r.s))return void t.then(e,l||(l=tt.bind(null,u=new rt,2)));t=t.v}u?tt(u,1,t):u=t}catch(e){tt(u||(u=new rt),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,m},t}(be);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}j(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return S.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 it&&1&r.s))return void t.then(e,s||(s=ot.bind(null,i=new it,2)));t=t.v}i?ot(i,1,t):i=t}catch(e){ot(i||(i=new it),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(L(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(be);function at(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function ct(e,t,r){if(!e.s){if(r instanceof ut){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 ut=/*#__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 lt(e){return e instanceof ut&&1&e.s}var mt=/*#__PURE__*/function(){function e(e){this.aquariusURL=void 0,this.aquariusURL=e}var t=e.prototype;return t.resolve=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/ddo/"+e;return Promise.resolve(at(function(){return Promise.resolve(o(r,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return Promise.resolve(e.json());throw new Error("HTTP request failed with status "+e.status)})},function(e){throw se.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForAqua=function(e,t,r){try{var n,i=this,s=0,a=function(e,t){var r;do{var n=e();if(n&&n.then){if(!lt(n)){r=!0;break}n=n.v}var o=t();if(lt(o)&&(o=o.v),!o)return n}while(!o.then);var i=new ut,s=ct.bind(null,i,2);return(r?n.then(a):o.then(c)).then(void 0,s),i;function a(r){for(n=r;lt(o=t())&&(o=o.v),o;){if(o.then)return void o.then(c).then(void 0,s);if((n=e())&&n.then){if(!lt(n))return void n.then(a).then(void 0,s);n=n.v}}ct(i,1,n)}function c(r){if(r){do{if((n=e())&&n.then){if(!lt(n))return void n.then(a).then(void 0,s);n=n.v}if(lt(r=t())&&(r=r.v),!r)return void ct(i,1,n)}while(!r.then);r.then(c).then(void 0,s)}else ct(i,1,n)}}(function(){function a(e){return n?e:Promise.resolve(oe(1500)).then(function(){s++})}var c=at(function(){return Promise.resolve(o(i.aquariusURL+"/api/aquarius/assets/ddo/"+e,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){return t?e.event&&e.event.txid===t?(n=1,e):void 0:(n=1,e)})}()})},function(){});return c&&c.then?c.then(a):a(c)},function(){return!n&&s<100});return Promise.resolve(a&&a.then?a.then(function(e){return n?e:null}):n?a:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t){try{var r,n=this,i={valid:!1},s=at(function(){return Promise.resolve(o(n.aquariusURL+"/api/aquarius/assets/ddo/validate",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:t})).then(function(e){return Promise.resolve(e.json()).then(function(t){r=t,200===e.status?(i.valid=!0,i.hash=r.hash,i.proof={validatorAddress:r.publicKey,r:r.r[0],s:r.s[0],v:r.v}):(i.errors=r,se.error("validate Metadata failed:",e.status,i.errors))})})},function(e){se.error("Error validating metadata: ",e)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(at(function(){return Promise.resolve(o(r,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("getAssetMetadata failed: "+e.status+e.statusText)})},function(e){throw se.error("Error getting metadata: ",e),new Error("Error getting metadata: "+e)}))}catch(e){return Promise.reject(e)}},t.querySearch=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/query";return Promise.resolve(at(function(){return Promise.resolve(o(r,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("querySearch failed: "+e.status+e.statusText)})},function(e){throw se.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();export{Xe as AccessListContract,Qe as AccesslistFactory,mt as Aquarius,C as Config,We as ConfigHelper,Ie as DEVELOPMENT_CHAIN_ID,Ze as Datatoken,He as Datatoken4,nt as DfRewards,st as DfStrategyV1,Je as Dispenser,I as FEE_HISTORY_NOT_SUPPORTED,ze as FixedRateExchange,U as GASLIMIT_DEFAULT,qe as KNOWN_CONFIDENTIAL_EVMS,ne as LogLevel,ie as Logger,se as LoggerInstance,R as MAX_UINT_256,Fe as Nft,Ae as NftFactory,Ce as Provider,Ee as ProviderInstance,Ve as Router,ke as SmartContract,be as SmartContractWithAddress,et as VeAllocate,$e as VeFeeDistributor,Ye as VeFeeEstimate,Ke as VeOcean,O as ZERO_ADDRESS,he as allowance,le as allowanceWei,G as amountToUnits,fe as approve,ve as approveWei,me as balance,Re as calculateActiveTemplateIndex,Be as configHelperNetworks,Oe as createAccessListFactory,Ue as createAsset,ue as decimals,te as downloadFile,re as downloadFileBrowser,Y as generateDid,$ as generateDtName,pe as getErrorMessage,Q as getEventFromTx,q as getFairGasPrice,ee as getHash,Le as getOceanArtifactsAdresses,Ge as getOceanArtifactsAdressesByChainId,B as getTokenDecimals,ae as minAbi,we as orderAsset,L as sendTx,X as setContractDefaults,ce as signHash,oe as sleep,de as transfer,_ as unitsToAmount,Ne as useOasisSDK};
1
+ import e from"@oceanprotocol/contracts/addresses/address.json";import t from"fs";import{ethers as r}from"ethers";import n from"crypto-js/sha256";import o from"cross-fetch";import i from"decimal.js";import*as s from"@oasisprotocol/sapphire-paratime";import a from"@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json";import c from"@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json";import u from"@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json";import l from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json";import m from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json";import h from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json";import{SHA256 as d}from"crypto-js";import{hexlify as v}from"ethers/lib/utils";import{createHash as f}from"crypto";import g from"@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json";import p from"@oceanprotocol/contracts/artifacts/contracts/interfaces/IERC20Template.sol/IERC20Template.json";import P from"@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessListFactory.sol/AccessListFactory.json";import y from"@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template4.sol/ERC20Template4.json";import w from"@oceanprotocol/contracts/artifacts/contracts/accesslists/AccessList.sol/AccessList.json";import k from"@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json";import b from"@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json";import T from"@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json";import A from"@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json";import F from"@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json";import S from"@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json";var E,C;!function(e){e.URL="url",e.IPFS="ipfs",e.ARWEAVE="arweave"}(E||(E={})),function(e){e.AES="AES",e.ECIES="ECIES"}(C||(C={}));var j=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.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.sideStakingAddress=void 0,this.startBlock=void 0,this.verbose=void 0,this.authMessage=void 0,this.authTokenExpiration=void 0,this.parityUri=void 0,this.threshold=void 0,this.chainId=void 0,this.network=void 0,this.subgraphUri=void 0,this.explorerUri=void 0,this.oceanTokenSymbol=void 0,this.transactionBlockTimeout=void 0,this.transactionConfirmationBlocks=void 0,this.transactionPollingTimeout=void 0,this.gasFeeMultiplier=void 0,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};function D(){return D=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},D.apply(this,arguments)}function x(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,M(e,t)}function M(e,t){return M=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},M(e,t)}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function O(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 U(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?U(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var R="0x0000000000000000000000000000000000000000",I=1e6,N="115792089237316195423570985008687907853269984665640564039457584007913129639934",L="Returned error: Method eth_feeHistory not supported.";function G(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var _=function(e,t,r,n){try{var o=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===X||s===H)&&Number(a)<z?z:s===Q&&Number(a)<V?V:Je.includes(s)&&Number(a)<Z?Z:Number(a),maxFeePerGas:(s===X||s===H)&&Number(c)<z?z:s===Q&&Number(c)<V?V:Je.includes(s)&&Number(c)<Z?Z:Number(c)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),G(function(){return Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i]))).then(function(e){return Promise.resolve(e.wait()).then(function(){return e})})},function(e){return ce.error("Send tx error: ",e),null})})})}catch(e){return Promise.reject(e)}},B=function(e,t,n,o){try{var i=function(e){return"0"===e&&(e=18),r.utils.parseUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(W(e,t)).then(i))}catch(e){return Promise.reject(e)}},q=function(e,t,n,o){try{var i=function(e){return"0"===e&&(e=18),r.utils.formatUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(W(e,t)).then(i))}catch(e){return Promise.reject(e)}},W=function(e,t){try{var n=new r.Contract(t,ue,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},J=function(e,t){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var n=r.BigNumber.from(e.toString());return t?n.mul(t).toBigInt().toString(10):n.toString()})})}catch(e){return Promise.reject(e)}},z=3e10,V=4e9,Z=1e10,H=137,X=80001,Q=11155111;function K(e,t){return e}function $(e,t){var r;return null==e||null==(r=e.events)?void 0:r.filter(function(e){return e.event===t})[0]}var Y={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 ee(e){var t=e||Y,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 te(e,t){return e=r.utils.getAddress(e),"did:op:"+n(e+t.toString(10)).toString()}function re(e){return n(e).toString()}var ne=function(e,t){try{return Promise.resolve(o(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)}};function oe(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()}var ie,se=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}};!function(e){e[e.None=-1]="None",e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Log=2]="Log",e[e.Verbose=3]="Verbose"}(ie||(ie={}));var ae=/*#__PURE__*/function(){function e(e){this.logLevel=void 0,this.logLevel=e,this.logLevel=e||ie.Error}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",ie.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",ie.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",ie.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",ie.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),ce=new ae,ue=[{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"}],le=function(e,t){try{var n=r.utils.arrayify(t);return Promise.resolve(e._legacySignMessage(n)).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)}},me=function(e,t){try{var n=new r.Contract(t,ue,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},he=function(e,t,n,o){try{var i=new r.Contract(t,ue,e);return Promise.resolve(i.allowance(n,o))}catch(e){return Promise.reject(e)}},de=function(e,t,n,o){try{var i=new r.Contract(t,ue,e);return Promise.resolve(i.balanceOf(n)).then(function(r){return Promise.resolve(q(e,t,r,o))})}catch(e){return Promise.reject(e)}},ve=function(e,t,n,o,i){try{var s=new r.Contract(t,ue,e);return Promise.resolve(s.allowance(n,o)).then(function(r){return Promise.resolve(q(e,t,r,i))})}catch(e){return Promise.reject(e)}},fe=function(e,t,n,o,i,s){try{var a=new r.Contract(n,ue,e);return Promise.resolve(B(e,n,i)).then(function(r){return Promise.resolve(a.estimateGas.transfer(o,r)).then(function(n){return s?n:Promise.resolve(_(n,e,null==t?void 0:t.gasFeeMultiplier,a.transfer,o,r))})})}catch(e){return Promise.reject(e)}},ge=function(e,t,n,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(m.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(_(r,e,null==t?void 0:t.gasFeeMultiplier,m.approve,i,s)).then(function(e){n=e})},function(e){ce.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},m=new r.Contract(o,ue,e),h=function(){if(!a)return Promise.resolve(he(e,o,n,i)).then(function(e){if(r.BigNumber.from(e).gt(r.BigNumber.from(s))){var t=r.BigNumber.from(e);return u=1,t}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},pe=function(e,t,n,o,s,a,c,u,l){void 0===c&&(c=!1);try{var m,h=function(r){return m?r:Promise.resolve(B(e,o,a,u)).then(function(r){return Promise.resolve(d.estimateGas.approve(s,r)).then(function(n){return l?new i(n.toString()):Promise.resolve(_(n,e,null==t?void 0:t.gasFeeMultiplier,d.approve,s,r))})})},d=new r.Contract(o,ue,e),v=function(){if(!c)return Promise.resolve(ve(e,o,n,s)).then(function(e){if(new i(e).greaterThanOrEqualTo(new i(a))){var t=new i(e).toNumber();return m=1,t}})}();return Promise.resolve(v&&v.then?v.then(h):h(v))}catch(e){return Promise.reject(e)}},Pe={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 ye(e){try{var t=JSON.parse(e),r=Object.keys(t)[0];if("error"===r){var n=t[r];return Pe[r][n]||"Provider request failed: "+n}var o=t[r];return t[Object.keys(t)[1]]+" : "+o}catch(t){return ce.error("[getErrorMessage] error: ",t),e}}function we(e,t,r){if(!e.s){if(r instanceof ke){if(!r.s)return void(r.o=we.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(we.bind(null,e,t),we.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var ke=/*#__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{we(n,1,i(this.v))}catch(e){we(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?we(n,1,t?t(o):o):r?we(n,1,r(o)):we(n,2,o)}catch(e){we(n,2,e)}},n},e}(),be=function(e,t,r,n,o,s,a,c,u,l,m,h){void 0===u&&(u="0"),void 0===l&&(l=0),void 0===m&&(m=0),void 0===h&&(h=0);try{if(a||(a={consumeMarketFeeAddress:"0x0000000000000000000000000000000000000000",consumeMarketFeeAmount:"0",consumeMarketFeeToken:e.stats.price.tokenAddress||"0x0000000000000000000000000000000000000000"}),!e.datatokens[l].address)throw new Error("The datatoken with index: "+l+" does not exist for the asset with did: "+e.id);if(!e.services[m].id)throw new Error("There is no service with index: "+m+" defined for the asset with did: "+e.id);return Promise.resolve(n.getId(e.datatokens[l].address)).then(function(d){return Promise.resolve(n.getFixedRates(e.datatokens[l].address)).then(function(v){return Promise.resolve(n.getDispensers(e.datatokens[l].address)).then(function(f){return Promise.resolve(n.getPublishingMarketFee(e.datatokens[l].address)).then(function(g){function p(e){return c?e:Promise.resolve(w.call(De,b,k,0,e,o||r.providerUri)).then(P)}function P(o){function f(o){function c(o){var s,c={consumer:o,serviceIndex:m,_providerFee:p,_consumeMarketFee:a};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 ke,m=we.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 we(l,1,c)}if(i=t[o][0]){if((s=i())&&s.then)return void s.then(r).then(void 0,m)}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,m);var u=t[n][2];n++}while(u&&!u());we(l,1,c)})).then(void 0,m),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,m)}we(l,1,e)}}(y,[[function(){return"free"},function(){var o=function(t){var o;if(s)return t;function i(e){if(o)return e}var a=function(){if(2===d||4===d)return Promise.resolve(n.buyFromDispenserAndOrder(e.services[m].datatokenAddress,c,r.dispenserAddress)).then(function(e){return o=1,e})}();return a&&a.then?a.then(i):i(a)},i=function(){if(1===d){var o=new Ve(r.dispenserAddress,t),i=o.dispense,a=e.datatokens[l].address;return Promise.resolve(t.getAddress()).then(function(t){return Promise.resolve(i.call(o,a,"1",t)).then(function(t){if(!t)throw new Error("Failed to dispense !");return Promise.resolve(t.wait()).then(function(){return Promise.resolve(n.startOrder(e.datatokens[l].address,c.consumer,c.serviceIndex,c._providerFee,c._consumeMarketFee)).then(function(e){return s=1,e})})})})}}();return i&&i.then?i.then(o):o(i)}],[function(){return"fixed"},function(){var o=new Ze(r.fixedRateExchangeAddress,t);if(!v[h].id)throw new Error("There is no fixed rate exchange with index: "+m+" for the asset with did: "+e.id);return Promise.resolve(o.getFeesInfo(v[h].id)).then(function(s){return Promise.resolve(o.getExchange(v[h].id)).then(function(m){return Promise.resolve(o.calcBaseInGivenDatatokensOut(s.exchangeId,"1",a.consumeMarketFeeAmount)).then(function(h){var v;function f(o){var i;if(v)return o;function s(e){if(i)return e}var a=function(){if(2===d||4===d)return Promise.resolve(t.getAddress()).then(function(o){return Promise.resolve(pe(t,r,o,m.baseToken,e.datatokens[l].address,p,!1)).then(function(t){function r(t){if(!t)throw new Error("Failed to confirm/mine approval transaction!");return Promise.resolve(n.buyFromFreAndOrder(e.datatokens[l].address,c,P)).then(function(e){return i=1,e})}if(!t)throw new Error("Failed to approve "+m.baseToken+" !");return"number"!=typeof t?Promise.resolve("number"!=typeof t?t.wait():t).then(r):r("number"!=typeof t?t.wait():t)})})}();return a&&a.then?a.then(s):s(a)}var p=new i(+h.baseTokenAmount||0).add(new i(a.consumeMarketFeeAmount||0)).add(new i(+g.publishMarketFeeAmount||0)).toString(),P={exchangeContract:r.fixedRateExchangeAddress,exchangeId:s.exchangeId,maxBaseTokenAmount:p,baseTokenAddress:m.baseToken,baseTokenDecimals:parseInt(m.btDecimals)||18,swapMarketFee:u,marketFeeAddress:g.publishMarketFeeAddress},y=function(){if(1===d)return Promise.resolve(t.getAddress()).then(function(i){return Promise.resolve(pe(t,r,i,m.baseToken,r.fixedRateExchangeAddress,p,!1)).then(function(t){function r(t){if(!t)throw new Error("Failed to approve "+m.baseToken+" !");return Promise.resolve(o.buyDatatokens(m.exchangeId,"1",p,g.publishMarketFeeAddress,u)).then(function(t){return Promise.resolve(t.wait()).then(function(t){if(!t)throw new Error("Failed to buy datatoken from fixed rate!");return Promise.resolve(n.startOrder(e.datatokens[l].address,c.consumer,c.serviceIndex,c._providerFee,c._consumeMarketFee)).then(function(e){return v=1,e})})})}return"number"!=typeof t?Promise.resolve("number"!=typeof t?t.wait():t).then(r):r("number"!=typeof t?t.wait():t)})})}();return y&&y.then?y.then(f):f(y)})})})}],[void 0,function(){throw new Error("Pricing schema not supported !")}]])}return s?c(s):Promise.resolve(t.getAddress()).then(c)}var p=c||o.providerFee,P=function(){if(p&&p.providerFeeAddress!==R&&p.providerFeeAmount&&parseInt(p.providerFeeAmount)>0)return function(n,o){try{var i=Promise.resolve(t.getAddress()).then(function(n){return Promise.resolve(ge(t,r,n,p.providerFeeToken,e.services[0].datatokenAddress,p.providerFeeAmount)).then(function(){})})}catch(e){return o()}return i&&i.then?i.then(void 0,o):i}(0,function(){throw new Error("Failed to approve provider fee token "+p.providerFeeToken)})}();return P&&P.then?P.then(f):f()}var y=v.length>0?"fixed":f.length>0?"free":"NOT_ALLOWED",w=c||De.initialize,k=c||e.services[m].id,b=c||e.id;return c?p(P(c)):Promise.resolve(t.getAddress()).then(p)})})})})}catch(e){return Promise.reject(e)}},Te=/*#__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 ze).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?s.wrap(this.signer):this.signer},t.amountToUnits=function(e,t,r){try{return Promise.resolve(B(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.unitsToAmount=function(e,t,r){try{return Promise.resolve(q(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},t.getFairGasPrice=function(){try{var e;return Promise.resolve(J(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},t.getContract=function(e,t){return K(new r.Contract(e,new r.utils.Interface(JSON.stringify(t||this.abi)),this.signer))},e}(),Ae=/*#__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 x(t,e),t}(Te);function Fe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Se=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var n=t.prototype;return n.getDefaultAbi=function(){return g.abi},n.createNFT=function(e,t){try{var r=this;if(e.templateIndex||(e.templateIndex=1),!e.name||!e.symbol){var n=ee(),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,R,R,e.tokenURI,e.transferable,e.owner)).then(function(n){return t?n:Fe(function(){var t;return Promise.resolve(_(n,r.getSignerAccordingSdk(),null==(t=r.config)?void 0:t.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,R,R,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 $(e,"NFTCreated").args[0]})})},function(e){console.error("Creation of NFT failed: "+e)})})})})}catch(e){return Promise.reject(e)}},n.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},n.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},n.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},n.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},n.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}catch(e){return Promise.reject(e)}},n.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)}},n.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},n.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},n.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},n.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===R)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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},n.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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},n.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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},n.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===R)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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},n.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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},n.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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},n.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(_(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},n.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(_(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},n.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(_(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},n.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(_(i,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},n.getErcCreationParams=function(e){try{var t,n,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||n],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(n){return{templateIndex:c,strings:s,addresses:o,uints:[t,n],bytess:e.filesObject?[r.utils.toUtf8Bytes(JSON.stringify(e.filesObject))]:[]}})})},i=this;if(!e.name||!e.symbol){var s=ee();t=s.name,n=s.symbol}var a=18,c=function(){if(e.feeToken!==R){var t=Fe(function(){return Promise.resolve(W(i.signer,e.feeToken)).then(function(e){a=e})},function(e){ce.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)}},n.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=R);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}(Ae),Ee=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var n=t.prototype;return n.getDefaultAbi=function(){return h.abi},n.createDatatoken=function(e,t,n,o,i,s,a,c,u,l,m,h,d,v,f,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(m||(m=1),!u||!l){var P=ee();u=P.name,l=P.symbol}var y=p.getContract(e);return Promise.resolve(y.provider.getNetwork()).then(function(e){function t(){var e=y.estimateGas,t=e.createERC20,P=[u,l],w=m;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,[n,o,i,s],[k,b],[])).then(function(e){var t;if(g)return e;var P=[n,o,i,s];d&&(P.push(d.toLowerCase()),P.push(v?v.toLowerCase():R),P.push(f||R));var w=[u,l],k=m,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(n){return Promise.resolve(_(e,A,T,b,k,w,P,[t,n],h?[r.utils.toUtf8Bytes(h)]:[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=$(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})}var P=Be(e.chainId),w=function(){if(h)return Promise.resolve(Ne(p.signer,P.ERC721Factory,4)).then(function(e){m=e})}();return w&&w.then?w.then(t):t()})})}catch(e){return Promise.reject(e)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addManager,r))})})}catch(e){return Promise.reject(e)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeManager,r))})})}catch(e){return Promise.reject(e)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToCreateERC20List,r))})})}catch(e){return Promise.reject(e)}},n.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(_(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)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addToMetadataList,r))})})}catch(e){return Promise.reject(e)}},n.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(_(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)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addTo725StoreList,r))})})}catch(e){return Promise.reject(e)}},n.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(_(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)}},n.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(_(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.cleanPermissions))})})}catch(e){return Promise.reject(e)}},n.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(_(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.transferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},n.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(_(e,i.getSignerAccordingSdk(),null==(n=i.config)?void 0:n.gasFeeMultiplier,s.safeTransferFrom,t,r,a))})})}catch(e){return Promise.reject(e)}},n.setMetadata=function(e,t,r,n,o,i,s,a,c,u){try{var l=this,m=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(m.estimateGas.setMetaData(r,n,o,i,s,a,c)).then(function(e){var t;return u?e:Promise.resolve(_(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,m.setMetaData,r,n,o,i,s,a,c))})})}catch(e){return Promise.reject(e)}},n.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=D({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(_(e,o.signer,null==(r=o.config)?void 0:r.gasFeeMultiplier,i.setMetaDataAndTokenURI,t))})})}catch(e){return Promise.reject(e)}},n.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setMetaDataState,r))})})}catch(e){return Promise.reject(e)}},n.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(_(e,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,o.setTokenURI,"1",t))})}catch(e){return Promise.reject(e)}},n.getNftOwner=function(e){try{var t=this.getContract(e);return Promise.resolve(t.ownerOf(1))}catch(e){return Promise.reject(e)}},n.getNftPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.getPermissions(t))}catch(e){return Promise.reject(e)}},n.getMetadata=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getMetaData())}catch(e){return Promise.reject(e)}},n.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},n.setData=function(e,t,n,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=r.utils.keccak256(n),u=r.utils.hexlify(r.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(c,u)).then(function(e){var t;return i?e:Promise.resolve(_(e,s.getSignerAccordingSdk(),null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,c,u))})})}catch(e){return Promise.reject(e)}},n.getData=function(e,t){try{var n=this.getContract(e),o=r.utils.keccak256(t);return Promise.resolve(n.getData(o)).then(function(e){return e?r.utils.toUtf8String(e):null})}catch(e){return Promise.reject(e)}},n.getTokenURI=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.tokenURI(t))}catch(e){return Promise.reject(e)}},n.isDatatokenDeployed=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isDeployed(t))}catch(e){return Promise.reject(e)}},t}(Te);function Ce(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var je=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getEndpoints=function(e){try{var t=this;return Promise.resolve(Ce(function(){return Promise.resolve(t.getData(e)).then(function(e){return Promise.resolve(e.json())})},function(e){throw ce.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,i){try{var s=function(){function s(){var e=a.getEndpointURL(i,"nonce")?a.getEndpointURL(i,"nonce").urlPath:null;return e?Ce(function(){return Promise.resolve(o(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 ce.error(e),new Error(e.message)}):null}var c=function(){if(!i)return Promise.resolve(a.getServiceEndpoints(e,n)).then(function(e){i=e})}();return c&&c.then?c.then(s):s()},a=this,c=function(){if(!n)return Promise.resolve(a.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(c&&c.then?c.then(s):s())}catch(e){return Promise.reject(e)}},t.signProviderRequest=function(e,t){try{var n=r.utils.solidityKeccak256(["bytes"],[r.utils.hexlify(r.utils.toUtf8Bytes(t))]),o=r.utils.arrayify(n);return Promise.resolve(e.getChainId()).then(function(t){return Ce(function(){return Promise.resolve(e.signMessage(o))},function(r){return ce.error("Sign provider message error: ",r),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 i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){var s=(i.getEndpointURL(r,"encrypt")?i.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return s?Ce(function(){return Promise.resolve(o(s,{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 ce.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},t.checkDidFiles=function(e,t,r,n,i){void 0===n&&(n=!1);try{var s=this;return Promise.resolve(s.getEndpoints(r)).then(function(a){return Promise.resolve(s.getServiceEndpoints(r,a)).then(function(r){function a(e){var t;function r(e){return t?e:Promise.resolve(c.json()).then(function(e){throw ce.error("File info call failed: ",c.status,c.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=c)&&e.ok)return Promise.resolve(c.json()).then(function(e){for(var r,n=O(e);!(r=n()).done;)l.push(r.value);return t=1,l})}();return n&&n.then?n.then(r):r(n)}var c,u={did:e,serviceId:t,checksum:n},l=[],m=s.getEndpointURL(r,"fileinfo")?s.getEndpointURL(r,"fileinfo").urlPath:null;if(!m)return null;var h=Ce(function(){return Promise.resolve(o(m,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw ce.error("File info call failed: "),ce.error(e),new Error(e)});return h&&h.then?h.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var i=this;return Promise.resolve(i.getEndpoints(t)).then(function(s){return Promise.resolve(i.getServiceEndpoints(t,s)).then(function(t){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw ce.error("File info call failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){for(var r,n=O(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var a,c=D({},e,{checksum:r}),u=[],l=i.getEndpointURL(t,"fileinfo")?i.getEndpointURL(t,"fileinfo").urlPath:null;if(!l)return null;var m=Ce(function(){return Promise.resolve(o(l,{method:"POST",body:JSON.stringify(c),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){a=e})},function(e){throw ce.error("File info call failed: "),ce.error(e),new Error(e)});return m&&m.then?m.then(s):s()})})}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 i;function s(e){var t;if(null!=(t=a)&&t.ok){var r,o=a.json();return Array.isArray(o)?((r={})[n.chainId]=o,r):o}return Promise.resolve(a.json()).then(function(e){throw ce.error("Fetch compute env failed: ",a.status,a.statusText,e),new Error(JSON.stringify(e))})}var a,c=null==(i=r.getEndpointURL(e,"computeEnvironments"))?void 0:i.urlPath;if(!c)return null;var u=Ce(function(){return Promise.resolve(o(c,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){a=e})},function(e){throw ce.error("Fetch compute env failed: "),ce.error(e),new Error(e)});return u&&u.then?u.then(s):s()})})}catch(e){return Promise.reject(e)}},t.initialize=function(e,t,r,n,i,s,a,c,u){try{var l=this;return Promise.resolve(l.getEndpoints(i)).then(function(m){return Promise.resolve(l.getServiceEndpoints(i,m)).then(function(i){function m(e){var t;function r(e){return t?e:Promise.resolve(h.json()).then(function(e){throw ce.error("Provider initialized failed: ",h.status,h.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(200===(null==(e=h)?void 0:e.status))return Promise.resolve(h.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var h,d=l.getEndpointURL(i,"initialize")?l.getEndpointURL(i,"initialize").urlPath:null;if(!d)return null;d+="?documentId="+e,d+="&serviceId="+t,d+="&fileIndex="+r,d+="&consumerAddress="+n,a&&(d+="&userdata="+encodeURI(JSON.stringify(a))),c&&(d+="&environment="+encodeURI(c)),u&&(d+="&validUntil="+u);var v=Ce(function(){return Promise.resolve(o(d,{method:"GET",headers:{"Content-Type":"application/json"},signal:s})).then(function(e){h=e})},function(e){throw ce.error("Provider initialized failed: "),ce.error(e),new Error("Provider initialize failed url: "+d+" ")});return v&&v.then?v.then(m):m()})})}catch(e){return Promise.reject(e)}},t.initializeComputeV1=function(e,t,r,n,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(i)).then(function(u){return Promise.resolve(c.getServiceEndpoints(i,u)).then(function(i){function u(e){var t;function r(e){return t?e:Promise.resolve(l.json()).then(function(e){throw ce.error("Initialize compute failed: ",l.status,l.statusText,e),ce.error("Payload was:",m),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=l)&&e.ok)return Promise.resolve(l.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var l,m={datasets:e,algorithm:t,compute:{env:r,validUntil:n},consumerAddress:s},h=c.getEndpointURL(i,"initializeCompute")?c.getEndpointURL(i,"initializeCompute").urlPath:null;if(!h)return null;var d=Ce(function(){return Promise.resolve(o(h,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){l=e})},function(e){throw ce.error("Initialize compute failed: "),ce.error(e),new Error("ComputeJob cannot be initialized")});return d&&d.then?d.then(u):u()})})}catch(e){return Promise.reject(e)}},t.initializeCompute=function(e,t,r,n,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(i)).then(function(u){return Promise.resolve(c.getServiceEndpoints(i,u)).then(function(l){return Promise.resolve(s.getAddress()).then(function(m){return Promise.resolve(c.getNonce(i,m,a,u,l)).then(function(i){var u=(i+1).toString(),h=m;return h+=e[0].documentId,h+=u,Promise.resolve(c.signProviderRequest(s,h)).then(function(i){function s(e){var t;function r(e){return t?e:Promise.resolve(u.json()).then(function(e){throw ce.error("Initialize compute failed: ",u.status,u.statusText,e),ce.error("Payload was:",h),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,h={datasets:e,algorithm:t,compute:{env:r,validUntil:n},consumerAddress:m,signature:i},d=c.getEndpointURL(l,"initializeCompute")?c.getEndpointURL(l,"initializeCompute").urlPath:null;if(!d)return null;var v=Ce(function(){return Promise.resolve(o(d,{method:"POST",body:JSON.stringify(h),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){u=e})},function(e){throw ce.error("Initialize compute failed: "),ce.error(e),new Error("ComputeJob cannot be initialized")});return v&&v.then?v.then(s):s()})})})})})}catch(e){return Promise.reject(e)}},t.getDownloadUrl=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(c){return Promise.resolve(a.getServiceEndpoints(o,c)).then(function(u){var l=a.getEndpointURL(u,"download")?a.getEndpointURL(u,"download").urlPath:null;return l?Promise.resolve(i.getAddress()).then(function(m){return Promise.resolve(a.getNonce(o,m,null,c,u)).then(function(o){var c=(o+1).toString();return Promise.resolve(a.signProviderRequest(i,e+c)).then(function(o){var i=l;return i+="?fileIndex="+r,i+="&documentId="+e,i+="&transferTxId="+n,i+="&serviceId="+t,i+="&consumerAddress="+m,i+="&nonce="+c,i+="&signature="+o,s&&(i+="&userdata="+encodeURI(JSON.stringify(s))),i})})}):null})})}catch(e){return Promise.reject(e)}},t.computeStartV1=function(e,t,r,n,i,s,a,c){try{var u=this;return Promise.resolve(u.getEndpoints(e)).then(function(l){return Promise.resolve(u.getServiceEndpoints(e,l)).then(function(m){var h=u.getEndpointURL(m,"computeStart")?u.getEndpointURL(m,"computeStart").urlPath:null;return Promise.resolve(t.getAddress()).then(function(d){return Promise.resolve(u.getNonce(e,d,s,l,m)).then(function(e){var l=(e+1).toString(),m=d;return m+=n.documentId,m+=l,Promise.resolve(u.signProviderRequest(t,m)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=ce.error,n=u.statusText,o=u.status;return Promise.resolve(u.json()).then(function(e){return r.call(ce,"Compute start failed: ",o,n,e),ce.error("Payload was:",m),null})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,m=Object();if(m.consumerAddress=d,m.signature=e,m.nonce=l,m.environment=r,m.dataset=n,m.algorithm=i,a&&(m.additionalDatasets=a),c&&(m.output=c),!h)return null;var v=Ce(function(){return Promise.resolve(o(h,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){u=e})},function(e){throw ce.error("Compute start failed:"),ce.error(e),ce.error("Payload was:",m),new Error("HTTP request failed calling Provider")});return v&&v.then?v.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},t.computeStart=function(e,t,r,n,i,s,a,c){try{var u=this;return console.log("called new compute start method..."),console.log("datasets: ",n),console.log("algorithm: ",i),Promise.resolve(u.getEndpoints(e)).then(function(l){return Promise.resolve(u.getServiceEndpoints(e,l)).then(function(m){var h;return h=c?u.getEndpointURL(m,"freeCompute")?u.getEndpointURL(m,"freeCompute").urlPath:null:u.getEndpointURL(m,"computeStart")?u.getEndpointURL(m,"computeStart").urlPath:null,Promise.resolve(t.getAddress()).then(function(c){return Promise.resolve(u.getNonce(e,c,s,l,m)).then(function(e){var l=(e+1).toString(),m=c;return m+=n[0].documentId,m+=l,Promise.resolve(u.signProviderRequest(t,m)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=ce.error,n=u.statusText,o=u.status;return Promise.resolve(u.json()).then(function(e){return r.call(ce,"Compute start failed: ",o,n,e),ce.error("Payload was:",m),null})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,m=Object();if(m.consumerAddress=c,m.signature=e,m.nonce=l,m.environment=r,m.dataset=n[0],m.datasets=n,m.algorithm=i,a&&(m.output=a),!h)return null;var d=Ce(function(){return Promise.resolve(o(h,{method:"POST",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){u=e})},function(e){throw ce.error("Compute start failed:"),ce.error(e),ce.error("Payload was:",m),new Error("HTTP request failed calling Provider")});return d&&d.then?d.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},t.computeStop=function(e,t,r,n,i,s,a){try{var c=this;return Promise.resolve(c.getEndpoints(n)).then(function(e){return Promise.resolve(c.getServiceEndpoints(n,e)).then(function(u){var l=c.getEndpointURL(u,"computeStop")?c.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(c.getNonce(n,t,a,e,u)).then(function(e){var n=(e+1).toString(),u=t;return Promise.resolve(c.signProviderRequest(i,u+=r||"")).then(function(e){function i(e){var t;function r(e){return t?e:Promise.resolve(u.json()).then(function(e){throw ce.error("Compute stop failed: ",u.status,u.statusText,e),ce.error("Payload was:",m),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=u)&&e.ok)return Promise.resolve(u.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var u,m=Object();if(m.signature=e,m.agreementId=c.noZeroX(s),m.consumerAddress=t,m.nonce=n,r&&(m.jobId=r),!l)return null;var h=Ce(function(){return Promise.resolve(o(l,{method:"PUT",body:JSON.stringify(m),headers:{"Content-Type":"application/json"},signal:a})).then(function(e){u=e})},function(e){throw ce.error("Compute stop failed:"),ce.error(e),ce.error("Payload was:",m),new Error("HTTP request failed calling Provider")});return h&&h.then?h.then(i):i()})})})})}catch(e){return Promise.reject(e)}},t.computeStatus=function(e,t,r,n,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 ce.error("Get compute status failed:",c.status,c.statusText,e),new Error(JSON.stringify(e))})}ce.error("Get compute status failed:",c.status,c.statusText);var o=function(){var 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(){var 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="+s.noZeroX(n)||"",l+=r&&"&jobId="+r||"",!u)return null;var m=Ce(function(){return Promise.resolve(o(u+l,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){c=e})},function(e){throw ce.error("Get compute status failed"),ce.error(e),new Error(e)});return m&&m.then?m.then(a):a()})})}catch(e){return Promise.reject(e)}},t.getComputeResultUrl=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(e)).then(function(i){return Promise.resolve(o.getServiceEndpoints(e,i)).then(function(s){var a=o.getEndpointURL(s,"computeResult")?o.getEndpointURL(s,"computeResult").urlPath:null,c=o.getNonce;return Promise.resolve(t.getAddress()).then(function(u){return Promise.resolve(c.call(o,e,u,null,i,s)).then(function(e){var i=(e+1).toString();return Promise.resolve(t.getAddress()).then(function(e){return e+=r,e+=n.toString(),e+=i,Promise.resolve(o.signProviderRequest(t,e)).then(function(e){if(!a)return null;var o=a;return Promise.resolve(t.getAddress()).then(function(t){return o+="?consumerAddress="+t,o+="&jobId="+r,o+="&index="+n.toString(),o+="&nonce="+i,o+=e&&"&signature="+e||""})})})})})})})}catch(e){return Promise.reject(e)}},t.computeDelete=function(e,t,r,n,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(c){var u=s.getEndpointURL(c,"computeDelete")?s.getEndpointURL(c,"computeDelete").urlPath:null,l=s.getNonce;return Promise.resolve(t.getAddress()).then(function(m){return Promise.resolve(l.call(s,n,m,i,a,c)).then(function(n){var a=(n+1).toString();return Promise.resolve(t.getAddress()).then(function(n){return n+=r||"",n+=e&&""+s.noZeroX(e)||"",n+=a,Promise.resolve(s.signProviderRequest(t,n)).then(function(n){var a=Object();return a.documentId=s.noZeroX(e),Promise.resolve(t.getAddress()).then(function(e){var t;function s(e){var r;function n(e){return r?e:Promise.resolve(t.json()).then(function(e){throw ce.error("Delete compute job failed:",t.status,t.statusText,e),ce.error("Payload was:",a),new Error(JSON.stringify(e))})}var o=function(){var e;if(null!=(e=t)&&e.ok)return Promise.resolve(t.json()).then(function(e){return r=1,e})}();return o&&o.then?o.then(n):n(o)}if(a.consumerAddress=e,a.jobId=r,n&&(a.signature=n),!u)return null;var c=Ce(function(){return Promise.resolve(o(u,{method:"DELETE",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){t=e})},function(e){throw ce.error("Delete compute job failed:"),ce.error(e),ce.error("Payload was:",a),new Error("HTTP request failed calling Provider")});return c&&c.then?c.then(s):s()})})})})})})})}catch(e){return Promise.reject(e)}},t.isValidProvider=function(e,t){try{return Promise.resolve(Ce(function(){return Promise.resolve(o(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 ce.error("Error validating provider: "+e.message),!1}))}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 ce.debug("Not input string:"),ce.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(ce.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},t.getData=function(e){try{return Promise.resolve(o(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},e}(),De=new je;function xe(e,t,r){if(!e.s){if(r instanceof Me){if(!r.s)return void(r.o=xe.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(xe.bind(null,e,t),xe.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var Me=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,r){var n=new e,o=this.s;if(o){var i=1&o?t:r;if(i){try{xe(n,1,i(this.v))}catch(e){xe(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?xe(n,1,t?t(o):o):r?xe(n,1,r(o)):xe(n,2,o)}catch(e){xe(n,2,e)}},n},e}();function Ue(e){return e instanceof Me&&1&e.s}function Oe(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Re=function(e,t,n){try{var o=new r.Contract(e,P.abi,t);return Promise.resolve(t.getAddress()).then(function(e){var t,r=Oe(function(){return Promise.resolve(o.deployAccessListContract("AllowList","ALLOW",!0,e,n||[e],["https://oceanprotocol.com/nft/"])).then(function(e){return function(){if(e&&e.wait)return Promise.resolve(e.wait()).then(function(e){var r=$(e,"NewAccessList");return t=1,r.args[0]})}()})},function(e){console.log("ERROR createAccessListFactory(): ",e)});return r&&r.then?r.then(function(e){return t?e:null}):t?r:null})}catch(e){return Promise.reject(e)}},Ie=function(e,t,n,o,i,s,a,c,u,l,m,h,g){void 0===a&&(a=!0);try{if("string"!=typeof i&&"number"!=typeof i)throw new Error('Invalid template! Must be a "number" or a "string"');return Promise.resolve(n.provider.getNetwork()).then(function(p){var P=p.chainId;if(s.chainId!==P)throw new Error("Chain ID from DDO is different than the configured network.");if(s.id)throw new Error("DID already filled in.");var w=(new ze).getConfig(parseInt(String(P)));return Promise.resolve(Ne(n,w.nftFactoryAddress,i)).then(function(i){if(i<1){if(P!==Le)throw new Error("Invalid template index: "+i);i=1}var p=new Ee(n,P),k=new Se(w.nftFactoryAddress,n);return Promise.resolve(n.getAddress()).then(function(b){var T;function A(e){return T?e:Promise.resolve(F.wait()).then(function(e){var t;function i(e){if(t)return e;function i(){function e(){var e=p.setMetadata;return Promise.resolve(n.getAddress()).then(function(n){return Promise.resolve(e.call(p,h,n,0,c,"",r.utils.hexlify(i),t,o)).then(function(){return s.id})})}var t,o,i;s.services[0].datatokenAddress=g,s.services[0].serviceEndpoint=c,s.nftAddress=h,s.id="did:op:"+d(r.utils.getAddress(h)+P.toString(10));var u=function(){if(a)return Promise.resolve(De.encrypt(s,P,c)).then(function(e){return t=e,Promise.resolve(l.validate(s)).then(function(e){o=e.hash,i=2})});var e=JSON.stringify(s),r=Buffer.from(e);t=v(r),o="0x"+f("sha256").update(t).digest("hex"),i=0}();return u&&u.then?u.then(e):e()}var u=function(){if("oasis"!==w.sdk)return Promise.resolve(De.encrypt(o,P,c)).then(function(e){s.services[0].files=e});s.services[0].files=""}();return u&&u.then?u.then(i):i()}var u=$(e,"NFTCreated"),m=$(e,"TokenCreated"),h=u.args.newTokenAddress,g=m.args.newTokenAddress;o.datatokenAddress=g,o.nftAddress=h;var k=function(){if("oasis"===w.sdk){var e=new r.Contract(g,y.abi,n);return Oe(function(){return Promise.resolve(e.setFilesObject(r.utils.toUtf8Bytes(JSON.stringify(o)))).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 k&&k.then?k.then(i):i(k)})}s.chainId=parseInt(P.toString(10));var F,S={name:e,symbol:t,templateIndex:1,tokenURI:"aaa",transferable:!0,owner:b},C={templateIndex:i,cap:"100000",feeAmount:"0",paymentCollector:b,feeToken:u||w.oceanTokenAddress,minter:b,mpFeeAddress:R};o.type&&[E.ARWEAVE,E.IPFS,E.URL].includes(o.type.toLowerCase())||(console.log('Missing or invalid files object type, defaulting to "url"'),o.type=E.URL),"oasis"===w.sdk&&(C.filesObject=o,C.accessListFactory=m||w.accessListFactory,C.allowAccessList=h,C.denyAccessList=g);var j=Oe(function(){var e=function(){var e,t;if(null==(e=s.stats)||null==(t=e.price)||!t.value)return Promise.resolve(k.createNftWithDatatoken(S,C)).then(function(e){F=e});var r,n,o="0"===(null==(r=s.stats)||null==(n=r.price)?void 0:n.value)?Promise.resolve(k.createNftWithDatatokenWithDispenser(S,C,{dispenserAddress:w.dispenserAddress,maxTokens:"1",maxBalance:"100000000",withMint:!0,allowedSwapper:R})).then(function(e){F=e}):Promise.resolve(k.createNftWithDatatokenWithFixedRate(S,C,{fixedRateAddress:w.fixedRateExchangeAddress,baseTokenAddress:w.oceanTokenAddress,owner:b,marketFeeCollector:b,baseTokenDecimals:18,datatokenDecimals:18,fixedRate:s.stats.price.value,marketFee:"0",allowedConsumer:b,withMint:!0})).then(function(e){F=e});return o&&o.then?o.then(function(){}):void 0}();if(e&&e.then)return e.then(function(){})},function(e){return console.log("ERROR creating NFT bundle",e),T=1,null});return j&&j.then?j.then(A):A(j)})})})}catch(e){return Promise.reject(e)}},Ne=function(e,t,n){try{var o="number"==typeof n,i=new Se(t,e);return Promise.resolve(i.getCurrentTokenTemplateCount()).then(function(t){var s;function a(e){return s?e:-1}var c=1,u=function(e,t,r){for(var n;;){var o=e();if(Ue(o)&&(o=o.v),!o)return i;if(o.then){n=0;break}var i=r();if(i&&i.then){if(!Ue(i)){n=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!Ue(s)){n=2;break}}}var a=new Me,c=xe.bind(null,a,2);return(0===n?o.then(l):1===n?i.then(u):s.then(m)).then(void 0,c),a;function u(n){i=n;do{if(t&&(s=t())&&s.then&&!Ue(s))return void s.then(m).then(void 0,c);if(!(o=e())||Ue(o)&&!o.v)return void xe(a,1,i);if(o.then)return void o.then(l).then(void 0,c);Ue(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):xe(a,1,i)}function m(){(o=e())?o.then?o.then(l).then(void 0,c):l(o):xe(a,1,i)}}(function(){return!s&&c<=t},function(){return c++},function(){return Promise.resolve(i.getTokenTemplate(c)).then(function(t){var i=new r.Contract(t.templateAddress,p.abi,e);return o?Promise.resolve(i.connect(e).getId()).then(function(e){if(t.isActive&&e.toString()===n.toString())return s=1,c}):t.isActive&&t.templateAddress===n.toString()?(s=1,c):void 0})});return u&&u.then?u.then(a):a(u)})}catch(e){return Promise.reject(e)}},Le=8996;function Ge(e){var t=(new ze).getConfig(e);return t&&"oasis"===t.sdk}function _e(){try{if(process.env.ADDRESS_FILE){var r=t.readFileSync(process.env.ADDRESS_FILE,"utf8");return JSON.parse(r)}return e}catch(t){return e}}function Be(e){try{var t=_e();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 qe={chainId:null,network:"unknown",metadataCacheUri:"https://v4.aquarius.oceanprotocol.com",nodeUri:"http://127.0.0.1:8545",providerUri:"https://v4.provider.oceanprotocol.com",subgraphUri:null,explorerUri:null,oceanTokenAddress:null,oceanTokenSymbol:"OCEAN",fixedRateExchangeAddress:null,dispenserAddress:null,startBlock:0,transactionBlockTimeout:50,transactionConfirmationBlocks:1,transactionPollingTimeout:750,gasFeeMultiplier:1},We=[D({},qe),D({},qe,{chainId:8996,network:"development",metadataCacheUri:"http://172.15.0.5:5000",providerUri:"http://172.15.0.4:8030",subgraphUri:"https://172.15.0.15:8000",sdk:"evm"}),D({},qe,{chainId:11155111,network:"sepolia",nodeUri:"https://sepolia.infura.io/v3",subgraphUri:"https://v4.subgraph.sepolia.oceanprotocol.com",explorerUri:"https://sepolia.etherscan.io",gasFeeMultiplier:1.1,sdk:"evm"}),D({},qe,{chainId:1,network:"mainnet",nodeUri:"https://mainnet.infura.io/v3",subgraphUri:"https://v4.subgraph.mainnet.oceanprotocol.com",explorerUri:"https://etherscan.io",startBlock:11105459,transactionBlockTimeout:150,transactionConfirmationBlocks:5,transactionPollingTimeout:1750,gasFeeMultiplier:1.05,sdk:"evm"}),D({},qe,{chainId:137,network:"polygon",nodeUri:"https://polygon-mainnet.infura.io/v3",subgraphUri:"https://v4.subgraph.polygon.oceanprotocol.com",explorerUri:"https://polygonscan.com",oceanTokenSymbol:"mOCEAN",gasFeeMultiplier:1.6,sdk:"evm"}),D({},qe,{chainId:2021e3,network:"gaiaxtestnet",nodeUri:"https://rpc.gaiaxtestnet.oceanprotocol.com",providerUri:"https://v4.provider.gaiaxtestnet.oceanprotocol.com",subgraphUri:"https://v4.subgraph.gaiaxtestnet.oceanprotocol.com",explorerUri:"https://blockscout.gaiaxtestnet.oceanprotocol.com",sdk:"evm"}),D({},qe,{chainId:80001,network:"mumbai",nodeUri:"https://polygon-mumbai.infura.io/v3",subgraphUri:"https://v4.subgraph.mumbai.oceanprotocol.com",explorerUri:"https://mumbai.polygonscan.com",gasFeeMultiplier:1.1,sdk:"evm"}),D({},qe,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",subgraphUri:"https://v4.subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05,sdk:"evm"}),D({},qe,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",subgraphUri:"https://v4.subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05,sdk:"evm"}),D({},qe,{chainId:1285,network:"moonriver",nodeUri:"https://moonriver.api.onfinality.io/public",subgraphUri:"https://v4.subgraph.moonriver.oceanprotocol.com",explorerUri:"https://moonriver.moonscan.io/",gasFeeMultiplier:1.05,sdk:"evm"}),D({},qe,{chainId:100,network:"gen-x-testnet",nodeUri:"https://rpc.genx.minimal-gaia-x.eu",metadataCacheUri:"https://aquarius.v4.delta-dao.com",providerUri:"https://provider.v4.genx.delta-dao.com",subgraphUri:"https://subgraph.v4.genx.minimal-gaia-x.eu",explorerUri:"https://explorer.genx.minimal-gaia-x.eu/",gasFeeMultiplier:1,sdk:"evm"}),D({},qe,{chainId:10,network:"optimism",nodeUri:"https://mainnet.optimism.io",subgraphUri:"https://v4.subgraph.optimism.oceanprotocol.com",explorerUri:"https://optimistic.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),D({},qe,{chainId:11155420,network:"optimism_sepolia",nodeUri:"https://sepolia.optimism.io",subgraphUri:"https://v4.subgraph.optimism-sepolia.oceanprotocol.com",explorerUri:"https://sepolia-optimism.etherscan.io/",gasFeeMultiplier:1.1,sdk:"evm"}),D({},qe,{chainId:23294,network:"oasis_sapphire",nodeUri:"https://sapphire.oasis.io",subgraphUri:"https://v4.subgraph.sapphire-mainnet.oceanprotocol.com/",explorerUri:"https://explorer.oasis.io/mainnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),D({},qe,{chainId:23295,network:"oasis_sapphire_testnet",nodeUri:"https://testnet.sapphire.oasis.dev",subgraphUri:"https://v4.subgraph.sapphire-testnet.oceanprotocol.com/subgraphs/name/oceanprotocol/ocean-subgraph",explorerUri:"https://explorer.oasis.io/testnet/sapphire/",gasFeeMultiplier:1,sdk:"oasis"}),D({},qe,{chainId:32456,network:"pontus-x-devnet",nodeUri:"https://rpc.dev.pontus-x.eu",metadataCacheUri:"https://aquarius.dev.pontus-x.eu",providerUri:"https://provider.dev.pontus-x.eu",subgraphUri:"https://subgraph.dev.pontus-x.eu",explorerUri:"https://explorer.dev.pontus-x.eu/testnet/pontusx",sdk:"evm"})],Je=[23294,23295],ze=/*#__PURE__*/function(){function r(){}var n=r.prototype;return n.getAddressesFromEnv=function(t,r){var n;if(r&&r[t]){var o=r[t];n=D({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},process.env.AQUARIUS_URL&&{metadataCacheUri:process.env.AQUARIUS_URL},process.env.PROVIDER_URL&&{providerUri:process.env.PROVIDER_URL})}else if(e[t]){var i=e[t];n=D({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},process.env.AQUARIUS_URL&&{metadataCacheUri:process.env.AQUARIUS_URL},process.env.PROVIDER_URL&&{providerUri:process.env.PROVIDER_URL})}return n},n.getConfig=function(e,r){var n,o="string"==typeof e?"network":"chainId",i=We.find(function(t){return t[o]===e});if(!i)return ce.error("No config found for given network '"+e+"'"),null;try{n=process.env.ADDRESS_FILE?JSON.parse(t.readFileSync(process.env.ADDRESS_FILE,"utf8")):null}catch(e){console.log(e),n=null}var s=this.getAddressesFromEnv(i.network,n);return!s&&Je.includes(i.chainId)&&(s=this.getAddressesFromEnv(i.network.replace("sapph","saph"),n)),"sdk"in i&&null!==i.sdk||(i.sdk=Je.includes(i.chainId)?"oasis":"evm"),i.accessListFactory=s.accessListFactory,i=D({},i,s),D({},i,{nodeUri:r?i.nodeUri+"/"+r:i.nodeUri})},r}(),Ve=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return a.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[2],n=e[1],o=e[0];return Promise.resolve(t.unitsToAmount(null,e[3],18)).then(function(i){return Promise.resolve(t.unitsToAmount(null,e[4],18)).then(function(s){return Promise.resolve(t.unitsToAmount(null,e[5],18)).then(function(t){return{active:o,owner:n,isMinter:r,maxTokens:i,maxBalance:s,balance:t,allowedSwapper:e[6]}})})})})}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(_(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(_(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(_(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(_(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(_(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(_(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 i(e).greaterThanOrEqualTo(o.maxBalance)||new i(String(n)).greaterThan(o.maxTokens)||!new i(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(Ae),Ze=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return c.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=R),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(_(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=R),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(_(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(_(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(_(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(_(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(_(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(m){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(d){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(v){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:m,btBalance:h,dtSupply:d,btSupply:v,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(_(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(_(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(_(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(_(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(_(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(_(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(_(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(_(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(Ae),He=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return u.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(_(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(_(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(_(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(_(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(_(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(_(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(_(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(_(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}(Ae),Xe=/*#__PURE__*/function(e){x(n,e);var t=n.prototype;function n(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||m.abi,s.nft=new Ee(s.signer,r),s}return t.getDefaultAbi=function(){return l.abi},t.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,B(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(_(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,B(null,null,r,18)))})}catch(e){return Promise.reject(e)}},t.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=R);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(_(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)}},t.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=R),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(_(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)}},t.mint=function(e,t,r,n,o){try{var s=this,a=s.getContract(e);return Promise.resolve(s.getPermissions(e,t)).then(function(c){if(!0!==c.minter)throw new Error("Caller is not Minter");return Promise.resolve(s.getCap(e)).then(function(e){if(new i(e).gte(r))return Promise.resolve(a.estimateGas.mint(n||t,B(null,null,r,18))).then(function(e){var i;return o?e:Promise.resolve(_(e,s.getSignerAccordingSdk(),null==(i=s.config)?void 0:i.gasFeeMultiplier,a.mint,n||t,B(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},t.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(_(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)}},t.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},t.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(B(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},t.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e,s.abi);return o||(o={consumeMarketFeeAddress:R,consumeMarketFeeToken:R,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var c;return i?e:Promise.resolve(_(e,s.getSignerAccordingSdk(),null==(c=s.config)?void 0:c.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},t.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(_(r,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},t.setData=function(e,t,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),a=r.utils.hexlify(r.utils.toUtf8Bytes(n));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(_(e,i.getSignerAccordingSdk(),null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},t.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(_(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},t.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},t.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)}},t.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},t.getId=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getId())}catch(e){return Promise.reject(e)}},t.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},t.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},t.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},t.getFixedRates=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getFixedRates())}catch(e){return Promise.reject(e)}},t.getDispensers=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getDispensers())}catch(e){return Promise.reject(e)}},t.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},t.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)}},t.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(_(e,s.getSignerAccordingSdk(),null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},t.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)}},t.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(B(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(B(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)}},n}(Te),Qe=/*#__PURE__*/function(e){x(r,e);var t=r.prototype;function r(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}return t.getDefaultAbi=function(){return y.abi},t.setFileObj=function(e){this.fileObject=e},t.getAllowlistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getAllowListContract())}catch(e){return Promise.reject(e)}},t.getDenylistContract=function(e){try{var t=this.getContract(e,this.getDefaultAbi());return Promise.resolve(t.getDenyListContract())}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setAllowListContract,t))})})}catch(e){return Promise.reject(e)}},t.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(_(e,o.getSignerAccordingSdk(),null==(r=o.config)?void 0:r.gasFeeMultiplier,i.functions.setDenyListContract,t))})})}catch(e){return Promise.reject(e)}},t.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(_(e,n.getSignerAccordingSdk(),null==(t=n.config)?void 0:t.gasFeeMultiplier,o.functions.setFilesObject,n.fileObject))})})}catch(e){return Promise.reject(e)}},t.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)}},r}(Xe),Ke=/*#__PURE__*/function(e){x(r,e);var t=r.prototype;function r(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}return t.getDefaultAbi=function(){return w.abi},t.getTokenUri=function(e){try{return Promise.resolve(this.contract.tokenURI(e))}catch(e){return Promise.reject(e)}},t.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},t.getId=function(){try{return Promise.resolve(this.contract.getId())}catch(e){return Promise.reject(e)}},t.getName=function(){try{return Promise.resolve(this.contract.name())}catch(e){return Promise.reject(e)}},t.getSymbol=function(){try{return Promise.resolve(this.contract.symbol())}catch(e){return Promise.reject(e)}},t.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)}},t.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(_(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.mint,e,t))})}catch(e){return Promise.reject(e)}},t.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(_(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.batchMint,e,t))})}catch(e){return Promise.reject(e)}},t.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(_(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.burn,e))})}catch(e){return Promise.reject(e)}},t.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(_(n,r.getSignerAccordingSdk(),null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.transferOwnership,e))})}catch(e){return Promise.reject(e)}},t.renounceOwnership=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.renounceOwnership()).then(function(r){var n;return e?r:Promise.resolve(_(r,t.getSignerAccordingSdk(),null==(n=t.config)?void 0:n.gasFeeMultiplier,t.contract.renounceOwnership))})}catch(e){return Promise.reject(e)}},r}(Ae),$e=/*#__PURE__*/function(e){x(r,e);var t=r.prototype;function r(t,r,n,o,i){var s;return(s=e.call(this,t,r,n,o,i)||this).abi=i||s.getDefaultAbi(),s}return t.getDefaultAbi=function(){return P.abi},t.deployAccessListContract=function(e,t,r,n,o,i,s){void 0===n&&(n=!1);try{var a=this;if(!e||!t){var c=ee();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(_(c,a.getSignerAccordingSdk(),null==(m=a.config)?void 0:m.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 $(e,"NewAccessList").args[0]})})}catch(e){return u(e)}var m;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)}},t.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},t.isSoulbound=function(e){try{return Promise.resolve(this.contract.isSoulBound(e))}catch(e){return Promise.reject(e)}},t.isDeployed=function(e){try{return Promise.resolve(this.contract.isDeployed(e))}catch(e){return Promise.reject(e)}},t.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===R)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(_(e,n.getSignerAccordingSdk(),null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.functions.changeTemplateAddress,t))})})}catch(e){return Promise.reject(e)}},r}(Ae),Ye=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return k.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(_(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(_(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(_(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(_(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(_(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}(Ae),et=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return b.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(_(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(_(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}(Ae),tt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return T.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 Ye(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}(Ae),rt=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return A.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(_(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(_(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}(Ae);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}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return F.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(_(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(_(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})},m=-1,function e(t){try{for(;++m<a.length;)if((t=c(m))&&t.then){if(!((r=t)instanceof ot&&1&r.s))return void t.then(e,l||(l=nt.bind(null,u=new ot,2)));t=t.v}u?nt(u,1,t):u=t}catch(e){nt(u||(u=new ot),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,m},t}(Ae);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(){return e.apply(this,arguments)||this}x(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return S.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 at&&1&r.s))return void t.then(e,s||(s=st.bind(null,i=new at,2)));t=t.v}i?st(i,1,t):i=t}catch(e){st(i||(i=new at),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(_(o,n.getSignerAccordingSdk(),null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(Ae);function ut(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function lt(e,t,r){if(!e.s){if(r instanceof mt){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;var n=e.o;n&&n(e)}}var mt=/*#__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}();function ht(e){return e instanceof mt&&1&e.s}var dt=/*#__PURE__*/function(){function e(e){this.aquariusURL=void 0,this.aquariusURL=e}var t=e.prototype;return t.resolve=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/ddo/"+e;return Promise.resolve(ut(function(){return Promise.resolve(o(r,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return Promise.resolve(e.json());throw new Error("HTTP request failed with status "+e.status)})},function(e){throw ce.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForAqua=function(e,t,r){try{var n,i=this,s=0,a=function(e,t){var r;do{var n=e();if(n&&n.then){if(!ht(n)){r=!0;break}n=n.v}var o=t();if(ht(o)&&(o=o.v),!o)return n}while(!o.then);var i=new mt,s=lt.bind(null,i,2);return(r?n.then(a):o.then(c)).then(void 0,s),i;function a(r){for(n=r;ht(o=t())&&(o=o.v),o;){if(o.then)return void o.then(c).then(void 0,s);if((n=e())&&n.then){if(!ht(n))return void n.then(a).then(void 0,s);n=n.v}}lt(i,1,n)}function c(r){if(r){do{if((n=e())&&n.then){if(!ht(n))return void n.then(a).then(void 0,s);n=n.v}if(ht(r=t())&&(r=r.v),!r)return void lt(i,1,n)}while(!r.then);r.then(c).then(void 0,s)}else lt(i,1,n)}}(function(){function a(e){return n?e:Promise.resolve(se(1500)).then(function(){s++})}var c=ut(function(){return Promise.resolve(o(i.aquariusURL+"/api/aquarius/assets/ddo/"+e,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return function(){if(e.ok)return Promise.resolve(e.json()).then(function(e){return t?e.event&&e.event.txid===t?(n=1,e):void 0:(n=1,e)})}()})},function(){});return c&&c.then?c.then(a):a(c)},function(){return!n&&s<100});return Promise.resolve(a&&a.then?a.then(function(e){return n?e:null}):n?a:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t){try{var r,n=this,i={valid:!1},s=ut(function(){return Promise.resolve(o(n.aquariusURL+"/api/aquarius/assets/ddo/validate",{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:t})).then(function(e){return Promise.resolve(e.json()).then(function(t){r=t,200===e.status?(i.valid=!0,i.hash=r.hash,i.proof={validatorAddress:r.publicKey,r:r.r[0],s:r.s[0],v:r.v}):(i.errors=r,ce.error("validate Metadata failed:",e.status,i.errors))})})},function(e){ce.error("Error validating metadata: ",e)});return Promise.resolve(s&&s.then?s.then(function(){return i}):i)}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(ut(function(){return Promise.resolve(o(r,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("getAssetMetadata failed: "+e.status+e.statusText)})},function(e){throw ce.error("Error getting metadata: ",e),new Error("Error getting metadata: "+e)}))}catch(e){return Promise.reject(e)}},t.querySearch=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/query";return Promise.resolve(ut(function(){return Promise.resolve(o(r,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/json"},signal:t})).then(function(e){if(e.ok)return e.json();throw new Error("querySearch failed: "+e.status+e.statusText)})},function(e){throw ce.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();export{Ke as AccessListContract,$e as AccesslistFactory,dt as Aquarius,j as Config,ze as ConfigHelper,Le as DEVELOPMENT_CHAIN_ID,Xe as Datatoken,Qe as Datatoken4,it as DfRewards,ct as DfStrategyV1,Ve as Dispenser,C as EncryptMethod,L as FEE_HISTORY_NOT_SUPPORTED,E as FileObjectType,Ze as FixedRateExchange,I as GASLIMIT_DEFAULT,Je as KNOWN_CONFIDENTIAL_EVMS,ie as LogLevel,ae as Logger,ce as LoggerInstance,N as MAX_UINT_256,Ee as Nft,Se as NftFactory,je as Provider,De as ProviderInstance,He as Router,Te as SmartContract,Ae as SmartContractWithAddress,rt as VeAllocate,et as VeFeeDistributor,tt as VeFeeEstimate,Ye as VeOcean,R as ZERO_ADDRESS,ve as allowance,he as allowanceWei,B as amountToUnits,pe as approve,ge as approveWei,de as balance,Ne as calculateActiveTemplateIndex,We as configHelperNetworks,Re as createAccessListFactory,Ie as createAsset,me as decimals,ne as downloadFile,oe as downloadFileBrowser,te as generateDid,ee as generateDtName,ye as getErrorMessage,$ as getEventFromTx,J as getFairGasPrice,re as getHash,_e as getOceanArtifactsAdresses,Be as getOceanArtifactsAdressesByChainId,W as getTokenDecimals,ue as minAbi,be as orderAsset,_ as sendTx,K as setContractDefaults,le as signHash,se as sleep,fe as transfer,q as unitsToAmount,Ge as useOasisSDK};
2
2
  //# sourceMappingURL=lib.module.js.map