@oceanprotocol/lib 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,9 +4,28 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v3.0.3](https://github.com/oceanprotocol/ocean.js/compare/v3.0.2...v3.0.3)
8
+
9
+ - Update provider nonce handling [`#1747`](https://github.com/oceanprotocol/ocean.js/pull/1747)
10
+
11
+ #### [v3.0.2](https://github.com/oceanprotocol/ocean.js/compare/v3.0.1...v3.0.2)
12
+
13
+ > 14 July 2023
14
+
15
+ - Update codeExamples dependencies [`#1742`](https://github.com/oceanprotocol/ocean.js/pull/1742)
16
+ - Updates to Provider errors handling [`#1745`](https://github.com/oceanprotocol/ocean.js/pull/1745)
17
+ - Feature/sepolia [`#1749`](https://github.com/oceanprotocol/ocean.js/pull/1749)
18
+ - Fixing fee token decimals [`#1748`](https://github.com/oceanprotocol/ocean.js/pull/1748)
19
+ - Release 3.0.2 [`ff5fcd7`](https://github.com/oceanprotocol/ocean.js/commit/ff5fcd7f2256d9baa0a2df6db68c85041d0c93ce)
20
+ - Merge 8699e4a8bb30b3ecb7ee894412ebe85267fddd67 into ae2ff1ccde53ace9841844c316a855de271f9a3f [`9da0268`](https://github.com/oceanprotocol/ocean.js/commit/9da0268be6ddfb1e4f110ee48725e8c9a492f6fb)
21
+ - Adding tests to check if the number of decimals is correct for the publishMarketFee [`8699e4a`](https://github.com/oceanprotocol/ocean.js/commit/8699e4a8bb30b3ecb7ee894412ebe85267fddd67)
22
+
7
23
  #### [v3.0.1](https://github.com/oceanprotocol/ocean.js/compare/v3.0.1-next.0...v3.0.1)
8
24
 
25
+ > 6 June 2023
26
+
9
27
  - set min gas fee 30 gwei on priority fees for polygon and mumbai as well [`#1736`](https://github.com/oceanprotocol/ocean.js/pull/1736)
28
+ - Release 3.0.1 [`ae2ff1c`](https://github.com/oceanprotocol/ocean.js/commit/ae2ff1ccde53ace9841844c316a855de271f9a3f)
10
29
 
11
30
  #### [v3.0.1-next.0](https://github.com/oceanprotocol/ocean.js/compare/v3.0.0...v3.0.1-next.0)
12
31
 
package/CodeExamples.md CHANGED
@@ -61,23 +61,12 @@ cat > marketplace.js
61
61
  # On linux press CTRL + D to save
62
62
  ```
63
63
 
64
- ## 3. Install dependancies
64
+ ## 3. Install dependencies
65
65
 
66
- Open the package.json file in a text editor and update the dependancies to include the following:
67
-
68
- ```JSON
69
- "dependencies": {
70
- "@oceanprotocol/contracts": "1.0.0-alpha.28",
71
- "@oceanprotocol/lib": "1.0.0-next.37",
72
- "crypto-js": "^4.1.1",
73
- "ethers": "^5.7.2"
74
- }
75
- ```
76
-
77
- Now in your terminal run the following command:
66
+ Install dependencies running the following command in your terminal:
78
67
 
79
68
  ```bash
80
- npm install
69
+ npm install @oceanprotocol/lib crypto-js ethers@5.7.2 typescript @types/node ts-node
81
70
  ```
82
71
 
83
72
  ## 4. Import dependencies and add variables and constants
@@ -119,7 +108,8 @@ import {
119
108
  amountToUnits,
120
109
  ValidateMetadata,
121
110
  getEventFromTx,
122
- DDO
111
+ DDO,
112
+ LoggerInstance
123
113
  } from '@oceanprotocol/lib'
124
114
  ```
125
115
 
@@ -575,6 +565,7 @@ Lets check that the download URL was successfully received
575
565
  const fileData = await downloadFile(downloadURL)
576
566
  console.log(fileData)
577
567
  } catch (e) {
568
+ LoggerInstance.error('Download failed', e)
578
569
  assert.fail('Download failed')
579
570
  }
580
571
 
@@ -104,7 +104,7 @@ node dist/compute.js
104
104
  Install dependencies running the following command in your terminal:
105
105
 
106
106
  ```bash
107
- npm install @oceanprotocol/lib crypto-js ethers typescript @types/node ts-node
107
+ npm install @oceanprotocol/lib crypto-js ethers@5.7.2 typescript @types/node ts-node
108
108
  ```
109
109
 
110
110
  ## 4. Import dependencies and add variables, constants and helper methods
package/dist/lib.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=require("@oceanprotocol/contracts/addresses/address.json"),t=require("ethers"),r=require("crypto-js/sha256"),n=require("cross-fetch"),o=require("decimal.js"),i=require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),s=require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),a=require("@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json"),u=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),c=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),l=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),m=require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json"),h=require("@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json"),v=require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json"),f=require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json"),d=require("@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json"),p=require("@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json"),g=require("@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json");function P(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=/*#__PURE__*/P(e),w=/*#__PURE__*/P(r),T=/*#__PURE__*/P(n),b=/*#__PURE__*/P(o),F=/*#__PURE__*/P(i),E=/*#__PURE__*/P(s),k=/*#__PURE__*/P(a),C=/*#__PURE__*/P(u),j=/*#__PURE__*/P(c),x=/*#__PURE__*/P(l),D=/*#__PURE__*/P(m),M=/*#__PURE__*/P(h),A=/*#__PURE__*/P(v),U=/*#__PURE__*/P(f),R=/*#__PURE__*/P(d),O=/*#__PURE__*/P(p),S=/*#__PURE__*/P(g);function N(){return N=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},N.apply(this,arguments)}function I(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,G(e,t)}function G(e,t){return G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},G(e,t)}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return _(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)?_(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var q="0x0000000000000000000000000000000000000000";function B(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var W=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(),u=t.maxFeePerGas.toString();r>1&&(a=Math.round(t.maxPriorityFeePerGas.toNumber()*r).toString(),u=Math.round(t.maxFeePerGas.toNumber()*r).toString()),i={maxPriorityFeePerGas:(s===Q||s===X)&&Number(a)<J?J:Number(a),maxFeePerGas:(s===Q||s===X)&&Number(u)<J?J:Number(u)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),B(function(){return Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i])))},function(){return null})})})}catch(e){return Promise.reject(e)}},z=function(e,r,n,o){try{var i=function(e){return"0"===e&&(e=18),t.ethers.utils.parseUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(V(e,r)).then(i))}catch(e){return Promise.reject(e)}},H=function(e,r,n,o){try{var i=function(e){return"0"===e&&(e=18),t.ethers.utils.formatUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(V(e,r)).then(i))}catch(e){return Promise.reject(e)}},V=function(e,r){try{var n=new t.ethers.Contract(r,ie,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},Z=function(e,r){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var n=t.ethers.BigNumber.from(e.toString());return r?n.mul(r).toBigInt().toString(10):n.toString()})})}catch(e){return Promise.reject(e)}},J=3e10,X=137,Q=80001;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}}var te,re=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}};exports.LogLevel=void 0,(te=exports.LogLevel||(exports.LogLevel={}))[te.None=-1]="None",te[te.Error=0]="Error",te[te.Warn=1]="Warn",te[te.Log=2]="Log",te[te.Verbose=3]="Verbose";var ne=/*#__PURE__*/function(){function e(e){void 0===e&&(e=exports.LogLevel.Error),this.logLevel=void 0,this.logLevel=e}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",exports.LogLevel.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",exports.LogLevel.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",exports.LogLevel.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",exports.LogLevel.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),oe=new ne,ie=[{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"}],se=function(e,r,n,o){try{var i=new t.ethers.Contract(r,ie,e);return Promise.resolve(i.allowance(n,o))}catch(e){return Promise.reject(e)}},ae=function(e,r,n,o,i){try{var s=new t.ethers.Contract(r,ie,e);return Promise.resolve(s.allowance(n,o)).then(function(t){return Promise.resolve(H(e,r,t,i))})}catch(e){return Promise.reject(e)}},ue={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."}},ce={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},le=[N({},ce),N({},ce,{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"}),N({},ce,{chainId:5,network:"goerli",nodeUri:"https://goerli.infura.io/v3",subgraphUri:"https://v4.subgraph.goerli.oceanprotocol.com",explorerUri:"https://goerli.etherscan.io",gasFeeMultiplier:1.1}),N({},ce,{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}),N({},ce,{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}),N({},ce,{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"}),N({},ce,{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}),N({},ce,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",subgraphUri:"https://v4.subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05}),N({},ce,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",subgraphUri:"https://v4.subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05}),N({},ce,{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})],me=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r;if(t){var n=t[e];r=N({nftFactoryAddress:n.ERC721Factory,opfCommunityFeeCollector:n.OPFCommunityFeeCollector,fixedRateExchangeAddress:n.FixedPrice,dispenserAddress:n.Dispenser,oceanTokenAddress:n.Ocean,chainId:n.chainId,startBlock:n.startBlock,veAllocate:n.veAllocate,veOCEAN:n.veOCEAN,veDelegation:n.veDelegation,veFeeDistributor:n.veFeeDistributor,veDelegationProxy:n.veDelegationProxy,DFRewards:n.DFRewards,DFStrategyV1:n.DFStrategyV1,veFeeEstimate:n.veFeeEstimate},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}else if(y.default[e]){var o=y.default[e];r=N({nftFactoryAddress:o.ERC721Factory,opfCommunityFeeCollector:o.OPFCommunityFeeCollector,fixedRateExchangeAddress:o.FixedPrice,dispenserAddress:o.Dispenser,oceanTokenAddress:o.Ocean,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},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}return r},t.getConfig=function(e,t){var r="string"==typeof e?"network":"chainId",n=le.find(function(t){return t[r]===e});return n?(n=N({},n,this.getAddressesFromEnv(n.network)),N({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(oe.error("No config found for given network '"+e+"'"),null)},e}(),he=/*#__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 me).getConfig(t||"unknown"),this.abi=n||this.getDefaultAbi()}var r=e.prototype;return r.amountToUnits=function(e,t,r){try{return Promise.resolve(z(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},r.unitsToAmount=function(e,t,r){try{return Promise.resolve(H(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},r.getFairGasPrice=function(){try{var e;return Promise.resolve(Z(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},r.getContract=function(e,r){return K(new t.ethers.Contract(e,new t.ethers.utils.Interface(JSON.stringify(r||this.abi)),this.signer))},e}(),ve=/*#__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 I(t,e),t}(he),fe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return F.default.abi},r.status=function(e){try{var t=this;return Promise.resolve(t.contract.status(e)).then(function(e){if(!e)throw new Error("Np dispenser found for the given datatoken address");var r=e[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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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(W(i,o.signer,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(W(n,r.signer,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(W(o,n.signer,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(W(i,o.signer,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(W(n,r.signer,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 b.default(e).greaterThanOrEqualTo(o.maxBalance)||new b.default(String(n)).greaterThan(o.maxTokens)||!new b.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(ve),de=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return E.default.abi},r.generateExchangeId=function(e,t){try{return Promise.resolve(this.contract.generateExchangeId(e,t))}catch(e){return Promise.reject(e)}},r.buyDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=q),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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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=q),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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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,u=n.signer;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(W(o,u,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(W(o,n.signer,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(W(n,r.signer,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(W(n,r.signer,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,u=r.baseToken,c=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(v){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(f){return Promise.resolve(t.unitsToAmount(null,r.fixedRate,18)).then(function(t){return{active:l,datatoken:c,baseToken:u,withMint:a,exchangeOwner:s,allowedSwapper:i,dtDecimals:o,btDecimals:n,dtBalance:m,btBalance:h,dtSupply:v,btSupply:f,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(W(n,r.signer,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(W(n,r.signer,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(W(o,n.signer,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(W(o,n.signer,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(W(n,r.signer,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(W(n,r.signer,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,u=n.signer;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(W(o,u,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(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(ve),pe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return k.default.abi},r.buyDatatokenBatch=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.buyDTBatch(e)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,s.signer,null==(a=s.config)?void 0:a.gasFeeMultiplier,s.contract.updateOPCFee,t,r,n,o))})})}catch(e){return Promise.reject(e)}},t}(ve),ge=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}I(r,e);var n=r.prototype;return n.getDefaultAbi=function(){return x.default.abi},n.createDatatoken=function(e,t,r,n,o,i,s,a,u,c,l,m){try{var h=this;return Promise.resolve(h.getNftPermissions(e,t)).then(function(t){if(!0!==t.deployERC20)throw new Error("Caller is not DatatokenDeployer");if(l||(l=1),!u||!c){var v=ee();u=v.name,c=v.symbol}var f=h.getContract(e),d=f.estimateGas,p=d.createERC20,g=[u,c],P=l;return Promise.resolve(h.amountToUnits(null,a,18)).then(function(e){return Promise.resolve(h.amountToUnits(null,s,18)).then(function(t){return Promise.resolve(p.call(d,P,g,[r,n,o,i],[e,t],[])).then(function(e){var t;if(m)return e;var v=[u,c],d=l,p=f.createERC20,g=null==(t=h.config)?void 0:t.gasFeeMultiplier,P=h.signer;return Promise.resolve(h.amountToUnits(null,a,18)).then(function(t){return Promise.resolve(h.amountToUnits(null,s,18)).then(function(s){return Promise.resolve(W(e,P,g,p,d,v,[r,n,o,i],[t,s],[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=$(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})})}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(W(e,o.signer,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(W(e,o.signer,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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromCreateERC20List,r))})}var u=!0!==s.manager;return u||t!==r?a(u||t===r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromMetadataList,r))})}var u=!0!==s.manager;return u||t===r?a(u||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFrom725StoreList,r))})}var u=!0!==s.manager;return u||t===r?a(u||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,n.signer,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(W(e,i.signer,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(W(e,i.signer,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,u,c){try{var l=this,m=l.getContract(e);return u||(u=[]),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,u)).then(function(e){var t;return c?e:Promise.resolve(W(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,m.setMetaData,r,n,o,i,s,a,u))})})}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=N({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(W(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(W(e,o.signer,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(W(e,n.signer,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,r,n,o,i){try{var s=this;return Promise.resolve(s.getNftPermissions(e,r)).then(function(r){if(!0!==r.store)throw new Error("User is not ERC20 store updater");var a=s.getContract(e),u=t.ethers.utils.keccak256(n),c=t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(u,c)).then(function(e){var t;return i?e:Promise.resolve(W(e,s.signer,null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,u,c))})})}catch(e){return Promise.reject(e)}},n.getData=function(e,r){try{var n=this.getContract(e),o=t.ethers.utils.keccak256(r);return Promise.resolve(n.getData(o)).then(function(e){return e?t.ethers.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)}},r}(he),Pe=/*#__PURE__*/function(e){I(n,e);var r=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||j.default.abi,s.nft=new ge(s.signer),s}return r.getDefaultAbi=function(){return C.default.abi},r.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,z(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,z(null,null,r,18)))})}catch(e){return Promise.reject(e)}},r.createFixedRate=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!e)throw new Error("User is not Datatoken Deployer");r.allowedConsumer||(r.allowedConsumer=q);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(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t]))})})}catch(e){return Promise.reject(e)}},r.createDispenser=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e);return n.allowedSwapper||(n.allowedSwapper=q),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(W(e,i.signer,null==(t=i.config)?void 0:t.gasFeeMultiplier,s.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper))})})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getPermissions(e,t)).then(function(a){if(!0!==a.minter)throw new Error("Caller is not Minter");return Promise.resolve(i.getCap(e)).then(function(e){if(new b.default(e).gte(r))return Promise.resolve(s.estimateGas.mint(n||t,z(null,null,r,18))).then(function(e){var a;return o?e:Promise.resolve(W(e,i.signer,null==(a=i.config)?void 0:a.gasFeeMultiplier,s.mint,n||t,z(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},r.addMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addMinter(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},r.removeMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removeMinter(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},r.addPaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addPaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.removePaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removePaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.setPaymentCollector=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getPermissions(e,t)).then(function(s){function a(e){function s(s){function a(e){if(!u&&!c&&!(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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setPaymentCollector,r))})}var c=e&&s===t;return e&&!c?Promise.resolve(e&&!c&&o.nft.getNftPermissions(e,t)).then(a):a(e&&!c&&o.nft.getNftPermissions(e,t))}return e?Promise.resolve(o.nft.getNftOwner(e)).then(s):s(e)}var u=s.paymentManager;return u?a(!u&&o.getNFTAddress(e)):Promise.resolve(!u&&o.getNFTAddress(e)).then(a)})}catch(e){return Promise.reject(e)}},r.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},r.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(z(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},r.transferWei=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.transfer(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},r.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e);return o||(o={consumeMarketFeeAddress:q,consumeMarketFeeToken:q,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var u;return i?e:Promise.resolve(W(e,s.signer,null==(u=s.config)?void 0:u.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},r.reuseOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.reuseOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},r.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(o.getFreOrderParams(r)).then(function(e){return Promise.resolve(i.estimateGas.buyFromFreAndOrder(t,e)).then(function(r){var s;return n?r:Promise.resolve(W(r,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},r.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(i.estimateGas.buyFromDispenserAndOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},r.setData=function(e,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e),a=t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(n));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(W(e,i.signer,null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.nft,i=o.getNftOwner;return Promise.resolve(n.getNFTAddress(e)).then(function(s){return Promise.resolve(i.call(o,s)).then(function(o){if(o!==t)throw new Error("Caller is NOT Nft Owner");var i=n.getContract(e);return Promise.resolve(i.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(W(e,n.signer,null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},r.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},r.getCap=function(e){try{var t=this,r=t.getContract(e);return Promise.resolve(r.cap()).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},r.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},r.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},r.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.balance=function(e,t){try{var r=this,n=r.getContract(e);return Promise.resolve(n.balanceOf(t)).then(function(e){return Promise.resolve(r.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.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(W(e,s.signer,null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},r.getPublishingMarketFee=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPublishingMarketFee()).then(function(e){return{publishMarketFeeAddress:e[0],publishMarketFeeToken:e[1],publishMarketFeeAmount:e[2].toString()}})}catch(e){return Promise.reject(e)}},r.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(z(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(z(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}(he),ye=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return D.default.abi},r.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,q,q,e.tokenURI,e.transferable,e.owner)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,q,q,e.tokenURI,e.transferable,e.owner)).then(function(e){return Promise.resolve(e.wait()).then(function(e){return $(e,"NFTCreated").args[0]})})})})})}catch(e){return Promise.reject(e)}},r.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}catch(e){return Promise.reject(e)}},r.getNFTTemplate=function(e){try{var t=this;return Promise.resolve(t.getCurrentNFTTemplateCount()).then(function(r){if(e>r)throw new Error("Template index doesnt exist");if(0===e)throw new Error("Template index cannot be ZERO");return Promise.resolve(t.contract.getNFTTemplate(e))})}catch(e){return Promise.reject(e)}},r.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},r.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},r.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},r.addNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===q)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(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.disable721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.reactivateNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.reactivate721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.addTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===q)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(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!1===e.isActive)throw new Error("Template is already disabled");return Promise.resolve(n.contract.estimateGas.disableTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.reactivateTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!0===e.isActive)throw new Error("Template is already active");return Promise.resolve(n.contract.estimateGas.reactivateTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.startMultipleTokenOrder=function(e,t){try{var r=this;if(e.length>50)throw new Error("Too many orders");return Promise.resolve(r.contract.estimateGas.startMultipleTokenOrder(e)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},r.createNftWithDatatoken=function(e,t,r){try{var n=this;return Promise.resolve(n.getErcCreationParams(t)).then(function(t){return Promise.resolve(n.contract.estimateGas.createNftWithErc20(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithFixedRate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.getFreCreationParams(r)).then(function(r){return Promise.resolve(o.contract.estimateGas.createNftWithErc20WithFixedRate(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.amountToUnits(null,r.maxBalance,18)).then(function(i){return r.maxBalance=i,Promise.resolve(o.amountToUnits(null,r.maxTokens,18)).then(function(i){return r.maxTokens=i,Promise.resolve(o.contract.estimateGas.createNftWithErc20WithDispenser(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},r.getErcCreationParams=function(e){try{var t,r,n=this;if(!e.name||!e.symbol){var o=ee();t=o.name,r=o.symbol}var i=[e.minter,e.paymentCollector,e.mpFeeAddress,e.feeToken],s=[e.name||t,e.symbol||r],a=e.templateIndex;return Promise.resolve(n.amountToUnits(null,e.cap,18)).then(function(t){return Promise.resolve(n.amountToUnits(null,e.feeAmount,18)).then(function(e){return{templateIndex:a,strings:s,addresses:i,uints:[t,e],bytess:[]}})})}catch(e){return Promise.reject(e)}},r.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=q);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}(ve),we=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return M.default.abi},r.lockTokens=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,e)).then(function(e){return Promise.resolve(n.contract.estimateGas.create_lock(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o.add(2e4),n.signer,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(W(o.add(2e4),n.signer,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(W(n.add(2e4),r.signer,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(W(n.add(2e4),r.signer,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(W(r.add(2e4),t.signer,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}(ve),Te=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return A.default.abi},r.claim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.claim()).then(function(r){var n;return e?r:Promise.resolve(W(r.add(2e4),t.signer,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(W(n.add(2e4),r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.claim_many,e))})}catch(e){return Promise.reject(e)}},t}(ve),be=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return U.default.abi},r.estimateClaim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateClaim(e)).then(function(e){return Promise.resolve(t.contract.voting_escrow()).then(function(r){var n=new we(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}(ve),Fe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return R.default.abi},r.setAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i.add(2e4),o.signer,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(W(i.add(2e4),o.signer,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}(ve);function Ee(e,t,r){if(!e.s){if(r instanceof ke){if(!r.s)return void(r.o=Ee.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Ee.bind(null,e,t),Ee.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var 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{Ee(n,1,i(this.v))}catch(e){Ee(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ee(n,1,t?t(o):o):r?Ee(n,1,r(o)):Ee(n,2,o)}catch(e){Ee(n,2,e)}},n},e}(),Ce=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return O.default.abi},r.getAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimable(e,t)).then(function(e){return Promise.resolve(r.unitsToAmount(t,e))})}catch(e){return Promise.reject(e)}},r.claimRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimFor(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o,n.signer,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(W(o,i.signer,null==(s=i.config)?void 0:s.gasFeeMultiplier,i.contract.allocate,e,t,r))})},i=this,s=(a=t,u=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=u(m))&&t.then){if(!((r=t)instanceof ke&&1&r.s))return void t.then(e,l||(l=Ee.bind(null,c=new ke,2)));t=t.v}c?Ee(c,1,t):c=t}catch(e){Ee(c||(c=new ke),2,e)}var r}(),c);return Promise.resolve(s&&s.then?s.then(o):o())}catch(e){return Promise.reject(e)}var a,u,c,l,m},t}(ve);function je(e,t,r){if(!e.s){if(r instanceof xe){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 xe=/*#__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}(),De=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return S.default.abi},r.getMultipleAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimables(e,t)).then(function(e){var n,o,i,s,a,u=[],c=(n=e,o=function(n){var o=u.push;return Promise.resolve(r.unitsToAmount(t[n],e[n])).then(function(e){o.call(u,e)})},a=-1,function e(t){try{for(;++a<n.length;)if((t=o(a))&&t.then){if(!((r=t)instanceof xe&&1&r.s))return void t.then(e,s||(s=je.bind(null,i=new xe,2)));t=t.v}i?je(i,1,t):i=t}catch(e){je(i||(i=new xe),2,e)}var r}(),i);return c&&c.then?c.then(function(){return u}):u})}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(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(ve);function Me(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function Ae(e,t,r){if(!e.s){if(r instanceof Ue){if(!r.s)return void(r.o=Ae.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Ae.bind(null,e,t),Ae.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Ue=/*#__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{Ae(n,1,i(this.v))}catch(e){Ae(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ae(n,1,t?t(o):o):r?Ae(n,1,r(o)):Ae(n,2,o)}catch(e){Ae(n,2,e)}},n},e}();function Re(e){return e instanceof Ue&&1&e.s}var Oe=/*#__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(Me(function(){return Promise.resolve(T.default(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 oe.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForAqua=function(e,t,r){try{var n,o=this,i=0,s=function(e,t){var r;do{var n=e();if(n&&n.then){if(!Re(n)){r=!0;break}n=n.v}var o=t();if(Re(o)&&(o=o.v),!o)return n}while(!o.then);var i=new Ue,s=Ae.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;Re(o=t())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=e())&&n.then){if(!Re(n))return void n.then(a).then(void 0,s);n=n.v}}Ae(i,1,n)}function u(r){if(r){do{if((n=e())&&n.then){if(!Re(n))return void n.then(a).then(void 0,s);n=n.v}if(Re(r=t())&&(r=r.v),!r)return void Ae(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else Ae(i,1,n)}}(function(){function s(e){return n?e:Promise.resolve(re(1500)).then(function(){i++})}var a=Me(function(){return Promise.resolve(T.default(o.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 a&&a.then?a.then(s):s(a)},function(){return!n&&i<100});return Promise.resolve(s&&s.then?s.then(function(e){return n?e:null}):n?s:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t){try{var r,n=this,o={valid:!1},i=Me(function(){return Promise.resolve(T.default(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?(o.valid=!0,o.hash=r.hash,o.proof={validatorAddress:r.publicKey,r:r.r[0],s:r.s[0],v:r.v}):(o.errors=r,oe.error("validate Metadata failed:",e.status,o.errors))})})},function(e){oe.error("Error validating metadata: ",e)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(Me(function(){return Promise.resolve(T.default(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 oe.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(Me(function(){return Promise.resolve(T.default(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 oe.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();function Se(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Ne=/*#__PURE__*/function(){function e(){}var r=e.prototype;return r.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 oe.error("Finding the service endpoints failed:",e),new Error("HTTP request failed calling Provider")}))}catch(e){return Promise.reject(e)}},r.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName===t}):null},r.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints)r.push({serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e+t.serviceEndpoints[n][1]});return Promise.resolve(r)}catch(e){return Promise.reject(e)}},r.getNonce=function(e,t,r,n,o){try{var i=function(){function i(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?Se(function(){return Promise.resolve(T.default(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return Promise.resolve(e.json()).then(function(e){return e.nonce.toString()})})},function(e){throw oe.error(e),new Error("HTTP request failed calling Provider")}):null}var a=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return a&&a.then?a.then(i):i()},s=this,a=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},r.signProviderRequest=function(e,r){try{var n=t.ethers.utils.solidityKeccak256(["bytes"],[t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(r))]),o=t.ethers.utils.arrayify(n);return Promise.resolve(e.getChainId()).then(function(t){var r;function n(t){return r?t:Promise.resolve(e.signMessage(o))}var i=function(){if(8996===t)return Promise.resolve(e._legacySignMessage(o)).then(function(e){return r=1,e})}();return i&&i.then?i.then(n):n(i)})}catch(e){return Promise.reject(e)}},r.encrypt=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(r)).then(function(i){return Promise.resolve(o.getServiceEndpoints(r,i)).then(function(r){var i=(o.getEndpointURL(r,"encrypt")?o.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return i?Se(function(){return Promise.resolve(T.default(i,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:n})).then(function(e){return Promise.resolve(e.text())})},function(e){throw oe.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},r.checkDidFiles=function(e,t,r,n,o){void 0===n&&(n=!1);try{var i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw oe.error("File info call failed: ",a.status,a.statusText,e),new Error(null==e?void 0:e.error)})}var n=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){for(var r,n=L(e);!(r=n()).done;)c.push(r.value);return t=1,c})}();return n&&n.then?n.then(r):r(n)}var a,u={did:e,serviceId:t,checksum:n},c=[],l=i.getEndpointURL(r,"fileinfo")?i.getEndpointURL(r,"fileinfo").urlPath:null;if(!l)return null;var m=Se(function(){return Promise.resolve(T.default(l,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw oe.error("File info call failed: "),oe.error(e),new Error(e)});return m&&m.then?m.then(s):s()})})}catch(e){return Promise.reject(e)}},r.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){function i(e){var t;function r(e){return t?e:Promise.resolve(s.json()).then(function(e){throw oe.error("File info call failed: ",s.status,s.statusText,e),new Error(null==e?void 0:e.error)})}var n=function(){var e;if(null!=(e=s)&&e.ok)return Promise.resolve(s.json()).then(function(e){for(var r,n=L(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var s,a=N({},e,{checksum:r}),u=[],c=o.getEndpointURL(t,"fileinfo")?o.getEndpointURL(t,"fileinfo").urlPath:null;if(!c)return null;var l=Se(function(){return Promise.resolve(T.default(c,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){s=e})},function(e){throw oe.error("File info call failed: "),oe.error(e),new Error(e)});return l&&l.then?l.then(i):i()})})}catch(e){return Promise.reject(e)}},r.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 o;function i(e){var t;if(null!=(t=s)&&t.ok){var r,o=s.json();return Array.isArray(o)?((r={})[n.chainId]=o,r):o}return Promise.resolve(s.json()).then(function(e){throw oe.error("Fetch compute env failed: ",s.status,s.statusText,e),new Error(null==e?void 0:e.error)})}var s,a=null==(o=r.getEndpointURL(e,"computeEnvironments"))?void 0:o.urlPath;if(!a)return null;var u=Se(function(){return Promise.resolve(T.default(a,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){s=e})},function(e){throw oe.error("Fetch compute env failed: "),oe.error(e),new Error(e)});return u&&u.then?u.then(i):i()})})}catch(e){return Promise.reject(e)}},r.initialize=function(e,t,r,n,o,i,s,a,u){try{var c=this;return Promise.resolve(c.getEndpoints(o)).then(function(l){return Promise.resolve(c.getServiceEndpoints(o,l)).then(function(o){function l(e){var t;function r(e){return t?e:Promise.resolve(m.json()).then(function(e){throw oe.error("Provider initialized failed: ",m.status,m.statusText,e),new Error(null==e?void 0:e.error)})}var n=function(){var e;if(null!=(e=m)&&e.ok)return Promise.resolve(m.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var m,h=c.getEndpointURL(o,"initialize")?c.getEndpointURL(o,"initialize").urlPath:null;if(!h)return null;h+="?documentId="+e,h+="&serviceId="+t,h+="&fileIndex="+r,h+="&consumerAddress="+n,s&&(h+="&userdata="+encodeURI(JSON.stringify(s))),a&&(h+="&environment="+encodeURI(a)),u&&(h+="&validUntil="+u);var v=Se(function(){return Promise.resolve(T.default(h,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){m=e})},function(e){throw oe.error("Provider initialized failed: "),oe.error(e),new Error("Provider initialize failed url: "+h+" ")});return v&&v.then?v.then(l):l()})})}catch(e){return Promise.reject(e)}},r.initializeCompute=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(u){return Promise.resolve(a.getServiceEndpoints(o,u)).then(function(o){function u(e){var t;function r(e){return t?e:Promise.resolve(c.json()).then(function(e){throw oe.error("Initialize compute failed: ",c.status,c.statusText,e),oe.error("Payload was:",l),new Error(null==e?void 0:e.error)})}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,l={datasets:e,algorithm:t,compute:{env:r,validUntil:n},consumerAddress:i},m=a.getEndpointURL(o,"initializeCompute")?a.getEndpointURL(o,"initializeCompute").urlPath:null;if(!m)return null;var h=Se(function(){return Promise.resolve(T.default(m,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){c=e})},function(e){throw oe.error("Initialize compute failed: "),oe.error(e),new Error("ComputeJob cannot be initialized")});return h&&h.then?h.then(u):u()})})}catch(e){return Promise.reject(e)}},r.getDownloadUrl=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(u){return Promise.resolve(a.getServiceEndpoints(o,u)).then(function(o){var u=a.getEndpointURL(o,"download")?a.getEndpointURL(o,"download").urlPath:null;if(!u)return null;var c=Date.now();return Promise.resolve(a.signProviderRequest(i,e+c)).then(function(o){var a=u;return a+="?fileIndex="+r,a+="&documentId="+e,a+="&transferTxId="+n,a+="&serviceId="+t,Promise.resolve(i.getAddress()).then(function(e){return a+="&consumerAddress="+e,a+="&nonce="+c,a+="&signature="+o,s&&(a+="&userdata="+encodeURI(JSON.stringify(s))),a})})})})}catch(e){return Promise.reject(e)}},r.computeStart=function(e,t,r,n,o,i,s,a){try{var u=this;return Promise.resolve(u.getEndpoints(e)).then(function(c){return Promise.resolve(u.getServiceEndpoints(e,c)).then(function(e){var c=u.getEndpointURL(e,"computeStart")?u.getEndpointURL(e,"computeStart").urlPath:null,l=Date.now();return Promise.resolve(t.getAddress()).then(function(e){return e+=n.documentId,e+=l,Promise.resolve(u.signProviderRequest(t,e)).then(function(e){var u=Object();return Promise.resolve(t.getAddress()).then(function(t){var m;function h(e){var t;function r(e){if(t)return e;var r=oe.error,n=m.statusText,o=m.status;return Promise.resolve(m.json()).then(function(e){return r.call(oe,"Compute start failed: ",o,n,e),oe.error("Payload was:",u),null})}var n=function(){var e;if(null!=(e=m)&&e.ok)return Promise.resolve(m.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}if(u.consumerAddress=t,u.signature=e,u.nonce=l,u.environment=r,u.dataset=n,u.algorithm=o,u.additionalDatasets&&(u.additionalDatasets=s),a&&(u.output=a),!c)return null;var v=Se(function(){return Promise.resolve(T.default(c,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){m=e})},function(e){throw oe.error("Compute start failed:"),oe.error(e),oe.error("Payload was:",u),new Error("HTTP request failed calling Provider")});return v&&v.then?v.then(h):h()})})})})})}catch(e){return Promise.reject(e)}},r.computeStop=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(u){var c=s.getEndpointURL(u,"computeStop")?s.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,u)).then(function(n){var a=t;return a+=r||"",a+=e&&""+s.noZeroX(e)||"",a+=n,Promise.resolve(s.signProviderRequest(o,a)).then(function(n){function o(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw oe.error("Compute stop failed: ",a.status,a.statusText,e),oe.error("Payload was:",u),new Error(null==e?void 0:e.error)})}var n=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,u=Object();if(u.signature=n,u.documentId=s.noZeroX(e),u.consumerAddress=t,r&&(u.jobId=r),!c)return null;var l=Se(function(){return Promise.resolve(T.default(c,{method:"PUT",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){a=e})},function(e){throw oe.error("Compute stop failed:"),oe.error(e),oe.error("Payload was:",u),new Error("HTTP request failed calling Provider")});return l&&l.then?l.then(o):o()})})})})}catch(e){return Promise.reject(e)}},r.computeStatus=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(e)).then(function(s){return Promise.resolve(i.getServiceEndpoints(e,s)).then(function(e){function s(e){var t;function r(e){var r;if(t)return e;function n(e){return r?e:Promise.resolve(a.json()).then(function(e){throw oe.error("Get compute status failed:",a.status,a.statusText,e),new Error(null==e?void 0:e.error)})}oe.error("Get compute status failed:",a.status,a.statusText);var o=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.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=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,u=i.getEndpointURL(e,"computeStatus")?i.getEndpointURL(e,"computeStatus").urlPath:null,c="?consumerAddress="+t;if(c+=n&&"&documentId="+i.noZeroX(n)||"",c+=r&&"&jobId="+r||"",!u)return null;var l=Se(function(){return Promise.resolve(T.default(u+c,{method:"GET",headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw oe.error("Get compute status failed"),oe.error(e),new Error(e)});return l&&l.then?l.then(s):s()})})}catch(e){return Promise.reject(e)}},r.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(e){var i=o.getEndpointURL(e,"computeResult")?o.getEndpointURL(e,"computeResult").urlPath:null,s=Date.now();return Promise.resolve(t.getAddress()).then(function(e){return e+=r,e+=n.toString(),e+=s,Promise.resolve(o.signProviderRequest(t,e)).then(function(e){if(!i)return null;var o=i;return Promise.resolve(t.getAddress()).then(function(t){return o+="?consumerAddress="+t,o+="&jobId="+r,o+="&index="+n.toString(),o+="&nonce="+s,o+=e&&"&signature="+e||""})})})})})}catch(e){return Promise.reject(e)}},r.computeDelete=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(n)).then(function(s){return Promise.resolve(i.getServiceEndpoints(n,s)).then(function(a){var u=i.getEndpointURL(a,"computeDelete")?i.getEndpointURL(a,"computeDelete").urlPath:null,c=i.getNonce;return Promise.resolve(t.getAddress()).then(function(l){return Promise.resolve(c.call(i,n,l,o,s,a)).then(function(n){return Promise.resolve(t.getAddress()).then(function(s){return s+=r||"",s+=e&&""+i.noZeroX(e)||"",s+=n,Promise.resolve(i.signProviderRequest(t,s)).then(function(n){var s=Object();return s.documentId=i.noZeroX(e),Promise.resolve(t.getAddress()).then(function(e){var t;function i(e){var r;function n(e){return r?e:Promise.resolve(t.json()).then(function(e){throw oe.error("Delete compute job failed:",t.status,t.statusText,e),oe.error("Payload was:",s),new Error(null==e?void 0:e.error)})}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(s.consumerAddress=e,s.jobId=r,n&&(s.signature=n),!u)return null;var a=Se(function(){return Promise.resolve(T.default(u,{method:"DELETE",body:JSON.stringify(s),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){t=e})},function(e){throw oe.error("Delete compute job failed:"),oe.error(e),oe.error("Payload was:",s),new Error("HTTP request failed calling Provider")});return a&&a.then?a.then(i):i()})})})})})})})}catch(e){return Promise.reject(e)}},r.isValidProvider=function(e,t){try{return Promise.resolve(Se(function(){return Promise.resolve(T.default(e,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t,r=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){if(e&&(e.providerAddress||e.providerAddresses))return t=!0})}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return oe.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},r.noZeroX=function(e){return this.zeroXTransformer(e,!1)},r.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},r.inputMatch=function(e,t,r){if("string"!=typeof e)throw oe.debug("Not input string:"),oe.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(oe.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},r.getData=function(e){try{return Promise.resolve(T.default(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},e}(),Ie=new Ne;exports.Aquarius=Oe,exports.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.nftFactoryAddress=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},exports.ConfigHelper=me,exports.Datatoken=Pe,exports.DfRewards=Ce,exports.DfStrategyV1=De,exports.Dispenser=fe,exports.FEE_HISTORY_NOT_SUPPORTED="Returned error: Method eth_feeHistory not supported.",exports.FixedRateExchange=de,exports.GASLIMIT_DEFAULT=1e6,exports.Logger=ne,exports.LoggerInstance=oe,exports.MAX_UINT_256="115792089237316195423570985008687907853269984665640564039457584007913129639934",exports.Nft=ge,exports.NftFactory=ye,exports.Provider=Ne,exports.ProviderInstance=Ie,exports.Router=pe,exports.SmartContract=he,exports.SmartContractWithAddress=ve,exports.VeAllocate=Fe,exports.VeFeeDistributor=Te,exports.VeFeeEstimate=be,exports.VeOcean=we,exports.ZERO_ADDRESS=q,exports.allowance=ae,exports.allowanceWei=se,exports.amountToUnits=z,exports.approve=function(e,r,n,o,i,s,a,u,c){void 0===a&&(a=!1);try{var l,m=function(t){return l?t:Promise.resolve(z(e,o,s,u)).then(function(t){return Promise.resolve(h.estimateGas.approve(i,t)).then(function(n){return c?new b.default(n.toString()):Promise.resolve(W(n,e,null==r?void 0:r.gasFeeMultiplier,h.approve,i,t))})})},h=new t.ethers.Contract(o,ie,e),v=function(){if(!a)return Promise.resolve(ae(e,o,n,i)).then(function(e){if(new b.default(e).greaterThanOrEqualTo(new b.default(s))){var t=new b.default(e).toNumber();return l=1,t}})}();return Promise.resolve(v&&v.then?v.then(m):m(v))}catch(e){return Promise.reject(e)}},exports.approveWei=function(e,r,n,o,i,s,a,u){void 0===a&&(a=!1);try{var c,l=function(t){if(c)return t;var n=null;return Promise.resolve(m.estimateGas.approve(i,s)).then(function(t){if(u)return t;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(W(t,e,null==r?void 0:r.gasFeeMultiplier,m.approve,i,s)).then(function(e){n=e})},function(e){oe.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},m=new t.ethers.Contract(o,ie,e),h=function(){if(!a)return Promise.resolve(se(e,o,n,i)).then(function(e){if(t.ethers.BigNumber.from(e).gt(t.ethers.BigNumber.from(s))){var r=t.ethers.BigNumber.from(e);return c=1,r}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},exports.balance=function(e,r,n,o){try{var i=new t.ethers.Contract(r,ie,e);return Promise.resolve(i.balanceOf(n)).then(function(t){return Promise.resolve(H(e,r,t,o))})}catch(e){return Promise.reject(e)}},exports.configHelperNetworks=le,exports.decimals=function(e,r){try{var n=new t.ethers.Contract(r,ie,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},exports.downloadFile=function(e,t){try{return Promise.resolve(T.default(e)).then(function(r){if(!r.ok)throw new Error("Response error.");var n;try{n=r.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]}catch(r){try{n=e.split("/").pop()}catch(e){n="file"+t}}return Promise.resolve(r.arrayBuffer()).then(function(e){return{data:e,filename:n}})})}catch(e){return Promise.reject(e)}},exports.downloadFileBrowser=function(e){try{return Promise.resolve(T.default(e,{method:"HEAD"})).then(function(t){var r=t.headers.get("content-disposition"),n=null!=r&&r.split("=")[1]?null==r?void 0:r.split("=")[1]:"file",o=new XMLHttpRequest;o.responseType="blob",o.open("GET",e),o.onload=function(){var e=window.URL.createObjectURL(o.response),t=document.createElement("a");t.href=e,t.setAttribute("download",n),document.body.appendChild(t),t.click(),t.remove(),window.URL.revokeObjectURL(e)},o.send(null)})}catch(e){return Promise.reject(e)}},exports.generateDid=function(e,r){return e=t.ethers.utils.getAddress(e),"did:op:"+w.default(e+r.toString(10)).toString()},exports.generateDtName=ee,exports.getErrorMessage=function(e){oe.log("lib error: ",e);var t=Object.keys(e)[0];if(oe.log("error key: ",t),"error"===t){var r=e[t];oe.log("error message: ",r);var n=ue[t][r]||"Provider request failed: "+r;return oe.log("returned error message: ",r),n}var o=e[t];oe.log("error message: ",o);var i=Object.keys(e)[1];oe.log("error message key: ",i);var s=e[i];return oe.log("returned error message: ",s+" : "+o),s+" : "+o},exports.getEventFromTx=$,exports.getFairGasPrice=Z,exports.getHash=function(e){return w.default(e).toString()},exports.getTokenDecimals=V,exports.minAbi=ie,exports.sendTx=W,exports.setContractDefaults=K,exports.signHash=function(e,r){try{var n=t.ethers.utils.arrayify(r);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)}},exports.sleep=re,exports.transfer=function(e,r,n,o,i,s){try{var a=new t.ethers.Contract(n,ie,e);return Promise.resolve(z(e,n,i)).then(function(t){return Promise.resolve(a.estimateGas.transfer(o,t)).then(function(n){return s?n:Promise.resolve(W(n,e,null==r?void 0:r.gasFeeMultiplier,a.transfer,o,t))})})}catch(e){return Promise.reject(e)}},exports.unitsToAmount=H;
1
+ var e=require("@oceanprotocol/contracts/addresses/address.json"),t=require("ethers"),r=require("crypto-js/sha256"),n=require("cross-fetch"),o=require("decimal.js"),i=require("@oceanprotocol/contracts/artifacts/contracts/pools/dispenser/Dispenser.sol/Dispenser.json"),s=require("@oceanprotocol/contracts/artifacts/contracts/pools/fixedRate/FixedRateExchange.sol/FixedRateExchange.json"),a=require("@oceanprotocol/contracts/artifacts/contracts/pools/FactoryRouter.sol/FactoryRouter.json"),u=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20Template.sol/ERC20Template.json"),c=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC20TemplateEnterprise.sol/ERC20TemplateEnterprise.json"),l=require("@oceanprotocol/contracts/artifacts/contracts/templates/ERC721Template.sol/ERC721Template.json"),m=require("@oceanprotocol/contracts/artifacts/contracts/ERC721Factory.sol/ERC721Factory.json"),h=require("@oceanprotocol/contracts/artifacts/contracts/ve/veOCEAN.vy/veOCEAN.json"),v=require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeDistributor.vy/veFeeDistributor.json"),f=require("@oceanprotocol/contracts/artifacts/contracts/ve/veFeeEstimate.vy/veFeeEstimate.json"),d=require("@oceanprotocol/contracts/artifacts/contracts/ve/veAllocate.sol/veAllocate.json"),p=require("@oceanprotocol/contracts/artifacts/contracts/df/DFRewards.sol/DFRewards.json"),g=require("@oceanprotocol/contracts/artifacts/contracts/df/DFStrategyV1.sol/DFStrategyV1.json");function P(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=/*#__PURE__*/P(e),w=/*#__PURE__*/P(r),T=/*#__PURE__*/P(n),b=/*#__PURE__*/P(o),F=/*#__PURE__*/P(i),E=/*#__PURE__*/P(s),k=/*#__PURE__*/P(a),C=/*#__PURE__*/P(u),j=/*#__PURE__*/P(c),x=/*#__PURE__*/P(l),D=/*#__PURE__*/P(m),M=/*#__PURE__*/P(h),A=/*#__PURE__*/P(v),U=/*#__PURE__*/P(f),O=/*#__PURE__*/P(d),R=/*#__PURE__*/P(p),S=/*#__PURE__*/P(g);function N(){return N=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},N.apply(this,arguments)}function I(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,G(e,t)}function G(e,t){return G=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},G(e,t)}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function L(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return _(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)?_(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var q="0x0000000000000000000000000000000000000000";function B(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var W=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(),u=t.maxFeePerGas.toString();r>1&&(a=Math.round(t.maxPriorityFeePerGas.toNumber()*r).toString(),u=Math.round(t.maxFeePerGas.toNumber()*r).toString()),i={maxPriorityFeePerGas:(s===Q||s===X)&&Number(a)<Z?Z:Number(a),maxFeePerGas:(s===Q||s===X)&&Number(u)<Z?Z:Number(u)}}else i={gasPrice:t.gasPrice};return i.gasLimit=e.add(2e4),B(function(){return Promise.resolve(n.apply(void 0,[].slice.call(o,4).concat([i])))},function(){return null})})})}catch(e){return Promise.reject(e)}},J=function(e,r,n,o){try{var i=function(e){return"0"===e&&(e=18),t.ethers.utils.parseUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(V(e,r)).then(i))}catch(e){return Promise.reject(e)}},z=function(e,r,n,o){try{var i=function(e){return"0"===e&&(e=18),t.ethers.utils.formatUnits(n,e).toString()};return Promise.resolve(o?i(o):Promise.resolve(V(e,r)).then(i))}catch(e){return Promise.reject(e)}},V=function(e,r){try{var n=new t.ethers.Contract(r,ie,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},H=function(e,r){try{return Promise.resolve(e.provider.getFeeData()).then(function(e){return Promise.resolve(e.gasPrice).then(function(e){var n=t.ethers.BigNumber.from(e.toString());return r?n.mul(r).toBigInt().toString(10):n.toString()})})}catch(e){return Promise.reject(e)}},Z=3e10,X=137,Q=80001;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}}var te,re=function(e){try{return Promise.resolve(new Promise(function(t){setTimeout(t,e)}))}catch(e){return Promise.reject(e)}};exports.LogLevel=void 0,(te=exports.LogLevel||(exports.LogLevel={}))[te.None=-1]="None",te[te.Error=0]="Error",te[te.Warn=1]="Warn",te[te.Log=2]="Log",te[te.Verbose=3]="Verbose";var ne=/*#__PURE__*/function(){function e(e){void 0===e&&(e=exports.LogLevel.Error),this.logLevel=void 0,this.logLevel=e}var t=e.prototype;return t.setLevel=function(e){this.logLevel=e},t.bypass=function(){this.dispatch.apply(this,["log",-Infinity].concat([].slice.call(arguments)))},t.debug=function(){this.dispatch.apply(this,["debug",exports.LogLevel.Verbose].concat([].slice.call(arguments)))},t.log=function(){this.dispatch.apply(this,["log",exports.LogLevel.Log].concat([].slice.call(arguments)))},t.warn=function(){this.dispatch.apply(this,["warn",exports.LogLevel.Warn].concat([].slice.call(arguments)))},t.error=function(){this.dispatch.apply(this,["error",exports.LogLevel.Error].concat([].slice.call(arguments)))},t.dispatch=function(e,t){var r;this.logLevel>=t&&(r=console)[e].apply(r,[].slice.call(arguments,2))},e}(),oe=new ne,ie=[{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"}],se=function(e,r,n,o){try{var i=new t.ethers.Contract(r,ie,e);return Promise.resolve(i.allowance(n,o))}catch(e){return Promise.reject(e)}},ae=function(e,r,n,o,i){try{var s=new t.ethers.Contract(r,ie,e);return Promise.resolve(s.allowance(n,o)).then(function(t){return Promise.resolve(z(e,r,t,i))})}catch(e){return Promise.reject(e)}},ue={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."}},ce={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},le=[N({},ce),N({},ce,{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"}),N({},ce,{chainId:5,network:"goerli",nodeUri:"https://goerli.infura.io/v3",subgraphUri:"https://v4.subgraph.goerli.oceanprotocol.com",explorerUri:"https://goerli.etherscan.io",gasFeeMultiplier:1.1}),N({},ce,{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}),N({},ce,{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}),N({},ce,{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}),N({},ce,{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"}),N({},ce,{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}),N({},ce,{chainId:56,network:"bsc",nodeUri:"https://bsc-dataseed.binance.org",subgraphUri:"https://v4.subgraph.bsc.oceanprotocol.com",explorerUri:"https://bscscan.com/",gasFeeMultiplier:1.05}),N({},ce,{chainId:246,network:"energyweb",nodeUri:"https://rpc.energyweb.org",subgraphUri:"https://v4.subgraph.energyweb.oceanprotocol.com",explorerUri:"https://explorer.energyweb.org",gasFeeMultiplier:1.05}),N({},ce,{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})],me=/*#__PURE__*/function(){function e(){}var t=e.prototype;return t.getAddressesFromEnv=function(e,t){var r;if(t){var n=t[e];r=N({nftFactoryAddress:n.ERC721Factory,opfCommunityFeeCollector:n.OPFCommunityFeeCollector,fixedRateExchangeAddress:n.FixedPrice,dispenserAddress:n.Dispenser,oceanTokenAddress:n.Ocean,chainId:n.chainId,startBlock:n.startBlock,veAllocate:n.veAllocate,veOCEAN:n.veOCEAN,veDelegation:n.veDelegation,veFeeDistributor:n.veFeeDistributor,veDelegationProxy:n.veDelegationProxy,DFRewards:n.DFRewards,DFStrategyV1:n.DFStrategyV1,veFeeEstimate:n.veFeeEstimate},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}else if(y.default[e]){var o=y.default[e];r=N({nftFactoryAddress:o.ERC721Factory,opfCommunityFeeCollector:o.OPFCommunityFeeCollector,fixedRateExchangeAddress:o.FixedPrice,dispenserAddress:o.Dispenser,oceanTokenAddress:o.Ocean,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},process.env.AQUARIUS_URI&&{metadataCacheUri:process.env.AQUARIUS_URI})}return r},t.getConfig=function(e,t){var r="string"==typeof e?"network":"chainId",n=le.find(function(t){return t[r]===e});return n?(n=N({},n,this.getAddressesFromEnv(n.network)),N({},n,{nodeUri:t?n.nodeUri+"/"+t:n.nodeUri})):(oe.error("No config found for given network '"+e+"'"),null)},e}(),he=/*#__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 me).getConfig(t||"unknown"),this.abi=n||this.getDefaultAbi()}var r=e.prototype;return r.amountToUnits=function(e,t,r){try{return Promise.resolve(J(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},r.unitsToAmount=function(e,t,r){try{return Promise.resolve(z(this.signer,e,t,r))}catch(e){return Promise.reject(e)}},r.getFairGasPrice=function(){try{var e;return Promise.resolve(H(this.signer,null==(e=this.config)?void 0:e.gasFeeMultiplier))}catch(e){return Promise.reject(e)}},r.getContract=function(e,r){return K(new t.ethers.Contract(e,new t.ethers.utils.Interface(JSON.stringify(r||this.abi)),this.signer))},e}(),ve=/*#__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 I(t,e),t}(he),fe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return F.default.abi},r.status=function(e){try{var t=this;return Promise.resolve(t.contract.status(e)).then(function(e){if(!e)throw new Error("Np dispenser found for the given datatoken address");var r=e[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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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(W(i,o.signer,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(W(n,r.signer,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(W(o,n.signer,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(W(i,o.signer,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(W(n,r.signer,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 b.default(e).greaterThanOrEqualTo(o.maxBalance)||new b.default(String(n)).greaterThan(o.maxTokens)||!new b.default(o.balance).greaterThanOrEqualTo(n)&&!0!==o.isMinter)})})}catch(e){return Promise.reject(e)}},t}(ve),de=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return E.default.abi},r.generateExchangeId=function(e,t){try{return Promise.resolve(this.contract.generateExchangeId(e,t))}catch(e){return Promise.reject(e)}},r.buyDatatokens=function(e,t,r,n,o,i){void 0===n&&(n=q),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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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=q),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 u;return i?a:Promise.resolve(W(a,s.signer,null==(u=s.config)?void 0:u.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,u=n.signer;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(W(o,u,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(W(o,n.signer,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(W(n,r.signer,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(W(n,r.signer,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,u=r.baseToken,c=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(v){return Promise.resolve(t.unitsToAmount(r.baseToken,r.btSupply,+r.btDecimals)).then(function(f){return Promise.resolve(t.unitsToAmount(null,r.fixedRate,18)).then(function(t){return{active:l,datatoken:c,baseToken:u,withMint:a,exchangeOwner:s,allowedSwapper:i,dtDecimals:o,btDecimals:n,dtBalance:m,btBalance:h,dtSupply:v,btSupply:f,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(W(n,r.signer,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(W(n,r.signer,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(W(o,n.signer,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(W(o,n.signer,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(W(n,r.signer,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(W(n,r.signer,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,u=n.signer;return Promise.resolve(n.amountToUnits(null,t,18)).then(function(t){return Promise.resolve(W(o,u,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(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.updateMarketFeeCollector,e,t))})}catch(e){return Promise.reject(e)}},t}(ve),pe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return k.default.abi},r.buyDatatokenBatch=function(e,t){try{var r=this;return Promise.resolve(r.contract.estimateGas.buyDTBatch(e)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,n.signer,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(W(e,s.signer,null==(a=s.config)?void 0:a.gasFeeMultiplier,s.contract.updateOPCFee,t,r,n,o))})})}catch(e){return Promise.reject(e)}},t}(ve),ge=/*#__PURE__*/function(e){function r(){return e.apply(this,arguments)||this}I(r,e);var n=r.prototype;return n.getDefaultAbi=function(){return x.default.abi},n.createDatatoken=function(e,t,r,n,o,i,s,a,u,c,l,m){try{var h=this;return Promise.resolve(h.getNftPermissions(e,t)).then(function(t){if(!0!==t.deployERC20)throw new Error("Caller is not DatatokenDeployer");if(l||(l=1),!u||!c){var v=ee();u=v.name,c=v.symbol}var f=h.getContract(e),d=f.estimateGas,p=d.createERC20,g=[u,c],P=l;return Promise.resolve(h.amountToUnits(null,a,18)).then(function(e){return Promise.resolve(h.amountToUnits(null,s,18)).then(function(t){return Promise.resolve(p.call(d,P,g,[r,n,o,i],[e,t],[])).then(function(e){var t;if(m)return e;var v=[u,c],d=l,p=f.createERC20,g=null==(t=h.config)?void 0:t.gasFeeMultiplier,P=h.signer;return Promise.resolve(h.amountToUnits(null,a,18)).then(function(t){return Promise.resolve(h.amountToUnits(null,s,18)).then(function(s){return Promise.resolve(W(e,P,g,p,d,v,[r,n,o,i],[t,s],[])).then(function(e){return Promise.resolve(e.wait()).then(function(e){var t=$(e,"TokenCreated");return null==t?void 0:t.args[0]})})})})})})})})}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(W(e,o.signer,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(W(e,o.signer,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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromCreateERC20List,r))})}var u=!0!==s.manager;return u||t!==r?a(u||t===r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFromMetadataList,r))})}var u=!0!==s.manager;return u||t===r?a(u||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,o.signer,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(u||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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeFrom725StoreList,r))})}var u=!0!==s.manager;return u||t===r?a(u||t!==r&&o.getNftPermissions(e,t)):Promise.resolve(u||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(W(e,n.signer,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(W(e,i.signer,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(W(e,i.signer,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,u,c){try{var l=this,m=l.getContract(e);return u||(u=[]),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,u)).then(function(e){var t;return c?e:Promise.resolve(W(e,l.signer,null==(t=l.config)?void 0:t.gasFeeMultiplier,m.setMetaData,r,n,o,i,s,a,u))})})}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=N({},r,{metadataProofs:r.metadataProofs||[]});return Promise.resolve(i.estimateGas.setMetaDataAndTokenURI(t)).then(function(e){var r;return n?e:Promise.resolve(W(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(W(e,o.signer,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(W(e,n.signer,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,r,n,o,i){try{var s=this;return Promise.resolve(s.getNftPermissions(e,r)).then(function(r){if(!0!==r.store)throw new Error("User is not ERC20 store updater");var a=s.getContract(e),u=t.ethers.utils.keccak256(n),c=t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(o));return Promise.resolve(a.estimateGas.setNewData(u,c)).then(function(e){var t;return i?e:Promise.resolve(W(e,s.signer,null==(t=s.config)?void 0:t.gasFeeMultiplier,a.setNewData,u,c))})})}catch(e){return Promise.reject(e)}},n.getData=function(e,r){try{var n=this.getContract(e),o=t.ethers.utils.keccak256(r);return Promise.resolve(n.getData(o)).then(function(e){return e?t.ethers.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)}},r}(he),Pe=/*#__PURE__*/function(e){I(n,e);var r=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||j.default.abi,s.nft=new ge(s.signer),s}return r.getDefaultAbi=function(){return C.default.abi},r.approve=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.approve(t,J(null,null,r,18))).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.approve,t,J(null,null,r,18)))})}catch(e){return Promise.reject(e)}},r.createFixedRate=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!e)throw new Error("User is not Datatoken Deployer");r.allowedConsumer||(r.allowedConsumer=q);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(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.createFixedRate,r.fixedRateAddress,[r.baseTokenAddress,r.owner,r.marketFeeCollector,r.allowedConsumer],[r.baseTokenDecimals,r.datatokenDecimals,r.fixedRate,r.marketFee,t]))})})}catch(e){return Promise.reject(e)}},r.createDispenser=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,t)).then(function(t){if(!t)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e);return n.allowedSwapper||(n.allowedSwapper=q),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(W(e,i.signer,null==(t=i.config)?void 0:t.gasFeeMultiplier,s.createDispenser,r,n.maxTokens,n.maxBalance,n.withMint,n.allowedSwapper))})})}catch(e){return Promise.reject(e)}},r.mint=function(e,t,r,n,o){try{var i=this,s=i.getContract(e);return Promise.resolve(i.getPermissions(e,t)).then(function(a){if(!0!==a.minter)throw new Error("Caller is not Minter");return Promise.resolve(i.getCap(e)).then(function(e){if(new b.default(e).gte(r))return Promise.resolve(s.estimateGas.mint(n||t,J(null,null,r,18))).then(function(e){var a;return o?e:Promise.resolve(W(e,i.signer,null==(a=i.config)?void 0:a.gasFeeMultiplier,s.mint,n||t,J(null,null,r,18)))});throw new Error("Mint amount exceeds cap available")})})}catch(e){return Promise.reject(e)}},r.addMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addMinter(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addMinter,r))})})}catch(e){return Promise.reject(e)}},r.removeMinter=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removeMinter(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removeMinter,r))})})}catch(e){return Promise.reject(e)}},r.addPaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.addPaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.addPaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.removePaymentManager=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.isDatatokenDeployer(e,t)).then(function(e){if(!0!==e)throw new Error("Caller is not DatatokenDeployer");return Promise.resolve(i.estimateGas.removePaymentManager(r)).then(function(e){var t;return n?e:Promise.resolve(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.removePaymentManager,r))})})}catch(e){return Promise.reject(e)}},r.setPaymentCollector=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(o.getPermissions(e,t)).then(function(s){function a(e){function s(s){function a(e){if(!u&&!c&&!(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(W(e,o.signer,null==(t=o.config)?void 0:t.gasFeeMultiplier,i.setPaymentCollector,r))})}var c=e&&s===t;return e&&!c?Promise.resolve(e&&!c&&o.nft.getNftPermissions(e,t)).then(a):a(e&&!c&&o.nft.getNftPermissions(e,t))}return e?Promise.resolve(o.nft.getNftOwner(e)).then(s):s(e)}var u=s.paymentManager;return u?a(!u&&o.getNFTAddress(e)):Promise.resolve(!u&&o.getNFTAddress(e)).then(a)})}catch(e){return Promise.reject(e)}},r.getPaymentCollector=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPaymentCollector())}catch(e){return Promise.reject(e)}},r.transfer=function(e,t,r,n){try{var o=this,i=o.transferWei;return Promise.resolve(J(null,null,r,18)).then(function(r){return i.call(o,e,t,r,n)})}catch(e){return Promise.reject(e)}},r.transferWei=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.transfer(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.transfer,t,r))})}catch(e){return Promise.reject(e)}},r.startOrder=function(e,t,r,n,o,i){try{var s=this,a=s.getContract(e);return o||(o={consumeMarketFeeAddress:q,consumeMarketFeeToken:q,consumeMarketFeeAmount:"0"}),Promise.resolve(a.estimateGas.startOrder(t,r,n,o)).then(function(e){var u;return i?e:Promise.resolve(W(e,s.signer,null==(u=s.config)?void 0:u.gasFeeMultiplier,a.startOrder,t,r,n,o))})}catch(e){return Promise.reject(e)}},r.reuseOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e);return Promise.resolve(i.estimateGas.reuseOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.reuseOrder,t,r))})}catch(e){return Promise.reject(e)}},r.buyFromFreAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(o.getFreOrderParams(r)).then(function(e){return Promise.resolve(i.estimateGas.buyFromFreAndOrder(t,e)).then(function(r){var s;return n?r:Promise.resolve(W(r,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromFreAndOrder,t,e))})})}catch(e){return Promise.reject(e)}},r.buyFromDispenserAndOrder=function(e,t,r,n){try{var o=this,i=o.getContract(e,o.abiEnterprise);return Promise.resolve(i.estimateGas.buyFromDispenserAndOrder(t,r)).then(function(e){var s;return n?e:Promise.resolve(W(e,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,i.buyFromDispenserAndOrder,t,r))})}catch(e){return Promise.reject(e)}},r.setData=function(e,r,n,o){try{var i=this;return Promise.resolve(i.isDatatokenDeployer(e,r)).then(function(r){if(!r)throw new Error("User is not Datatoken Deployer");var s=i.getContract(e),a=t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(n));return Promise.resolve(s.estimateGas.setData(a)).then(function(e){var t;return o?e:Promise.resolve(W(e,i.signer,null==(t=i.config)?void 0:t.gasFeeMultiplier,s.setData,a))})})}catch(e){return Promise.reject(e)}},r.cleanPermissions=function(e,t,r){try{var n=this,o=n.nft,i=o.getNftOwner;return Promise.resolve(n.getNFTAddress(e)).then(function(s){return Promise.resolve(i.call(o,s)).then(function(o){if(o!==t)throw new Error("Caller is NOT Nft Owner");var i=n.getContract(e);return Promise.resolve(i.estimateGas.cleanPermissions()).then(function(e){var t;return r?e:Promise.resolve(W(e,n.signer,null==(t=n.config)?void 0:t.gasFeeMultiplier,i.cleanPermissions))})})})}catch(e){return Promise.reject(e)}},r.getPermissions=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.permissions(t))}catch(e){return Promise.reject(e)}},r.getCap=function(e){try{var t=this,r=t.getContract(e);return Promise.resolve(r.cap()).then(function(e){return Promise.resolve(t.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.getDecimals=function(e){try{var t=this.getContract(e);return Promise.resolve(t.decimals())}catch(e){return Promise.reject(e)}},r.getSymbol=function(e){try{var t=this.getContract(e);return Promise.resolve(t.symbol())}catch(e){return Promise.reject(e)}},r.getName=function(e){try{var t=this.getContract(e);return Promise.resolve(t.name())}catch(e){return Promise.reject(e)}},r.getNFTAddress=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getERC721Address())}catch(e){return Promise.reject(e)}},r.isDatatokenDeployer=function(e,t){try{var r=this.getContract(e);return Promise.resolve(r.isERC20Deployer(t))}catch(e){return Promise.reject(e)}},r.balance=function(e,t){try{var r=this,n=r.getContract(e);return Promise.resolve(n.balanceOf(t)).then(function(e){return Promise.resolve(r.unitsToAmount(null,e,18))})}catch(e){return Promise.reject(e)}},r.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(W(e,s.signer,null==(o=s.config)?void 0:o.gasFeeMultiplier,a.setPublishingMarketFee,t,r,n))})})}catch(e){return Promise.reject(e)}},r.getPublishingMarketFee=function(e){try{var t=this.getContract(e);return Promise.resolve(t.getPublishingMarketFee()).then(function(e){return{publishMarketFeeAddress:e[0],publishMarketFeeToken:e[1],publishMarketFeeAmount:e[2].toString()}})}catch(e){return Promise.reject(e)}},r.getFreOrderParams=function(e){try{var t=this,r=e.exchangeId,n=e.exchangeContract;return Promise.resolve(J(t.signer,e.baseTokenAddress,e.maxBaseTokenAmount,e.baseTokenDecimals)).then(function(o){return Promise.resolve(J(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}(he),ye=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return D.default.abi},r.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,q,q,e.tokenURI,e.transferable,e.owner)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.deployERC721Contract,e.name,e.symbol,e.templateIndex,q,q,e.tokenURI,e.transferable,e.owner)).then(function(e){return Promise.resolve(e.wait()).then(function(e){return $(e,"NFTCreated").args[0]})})})})})}catch(e){return Promise.reject(e)}},r.getCurrentNFTCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenCount=function(){try{return Promise.resolve(this.contract.getCurrentTokenCount())}catch(e){return Promise.reject(e)}},r.getOwner=function(){try{return Promise.resolve(this.contract.owner())}catch(e){return Promise.reject(e)}},r.getCurrentNFTTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentNFTTemplateCount())}catch(e){return Promise.reject(e)}},r.getCurrentTokenTemplateCount=function(){try{return Promise.resolve(this.contract.getCurrentTemplateCount())}catch(e){return Promise.reject(e)}},r.getNFTTemplate=function(e){try{var t=this;return Promise.resolve(t.getCurrentNFTTemplateCount()).then(function(r){if(e>r)throw new Error("Template index doesnt exist");if(0===e)throw new Error("Template index cannot be ZERO");return Promise.resolve(t.contract.getNFTTemplate(e))})}catch(e){return Promise.reject(e)}},r.getTokenTemplate=function(e){try{return Promise.resolve(this.contract.getTokenTemplate(e))}catch(e){return Promise.reject(e)}},r.checkDatatoken=function(e){try{return Promise.resolve(this.contract.erc20List(e))}catch(e){return Promise.reject(e)}},r.checkNFT=function(e){try{return Promise.resolve(this.contract.erc721List(e))}catch(e){return Promise.reject(e)}},r.addNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===q)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(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.add721TokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.disable721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disable721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.reactivateNFTTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentNFTTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.contract.estimateGas.reactivate721TokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivate721TokenTemplate,t))})})})}catch(e){return Promise.reject(e)}},r.addTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");if(t===q)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(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.addTokenTemplate,t))})})}catch(e){return Promise.reject(e)}},r.disableTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!1===e.isActive)throw new Error("Template is already disabled");return Promise.resolve(n.contract.estimateGas.disableTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.disableTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.reactivateTokenTemplate=function(e,t,r){try{var n=this;return Promise.resolve(n.getOwner()).then(function(o){if(o!==e)throw new Error("Caller is not Factory Owner");return Promise.resolve(n.getCurrentTokenTemplateCount()).then(function(e){if(t>e)throw new Error("Template index doesnt exist");if(0===t)throw new Error("Template index cannot be ZERO");return Promise.resolve(n.getTokenTemplate(t)).then(function(e){if(!0===e.isActive)throw new Error("Template is already active");return Promise.resolve(n.contract.estimateGas.reactivateTokenTemplate(t)).then(function(e){var o;return r?e:Promise.resolve(W(e,n.signer,null==(o=n.config)?void 0:o.gasFeeMultiplier,n.contract.reactivateTokenTemplate,t))})})})})}catch(e){return Promise.reject(e)}},r.startMultipleTokenOrder=function(e,t){try{var r=this;if(e.length>50)throw new Error("Too many orders");return Promise.resolve(r.contract.estimateGas.startMultipleTokenOrder(e)).then(function(n){var o;return t?n:Promise.resolve(W(n,r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.startMultipleTokenOrder,e))})}catch(e){return Promise.reject(e)}},r.createNftWithDatatoken=function(e,t,r){try{var n=this;return Promise.resolve(n.getErcCreationParams(t)).then(function(t){return Promise.resolve(n.contract.estimateGas.createNftWithErc20(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.createNftWithErc20,e,t))})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithFixedRate=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.getFreCreationParams(r)).then(function(r){return Promise.resolve(o.contract.estimateGas.createNftWithErc20WithFixedRate(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithFixedRate,e,t,r))})})})}catch(e){return Promise.reject(e)}},r.createNftWithDatatokenWithDispenser=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getErcCreationParams(t)).then(function(t){return Promise.resolve(o.amountToUnits(null,r.maxBalance,18)).then(function(i){return r.maxBalance=i,Promise.resolve(o.amountToUnits(null,r.maxTokens,18)).then(function(i){return r.maxTokens=i,Promise.resolve(o.contract.estimateGas.createNftWithErc20WithDispenser(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i,o.signer,null==(s=o.config)?void 0:s.gasFeeMultiplier,o.contract.createNftWithErc20WithDispenser,e,t,r))})})})})}catch(e){return Promise.reject(e)}},r.getErcCreationParams=function(e){try{var t,r,n=function(){var n=[e.minter,e.paymentCollector,e.mpFeeAddress,e.feeToken],i=[e.name||t,e.symbol||r],a=e.templateIndex;return Promise.resolve(o.amountToUnits(null,e.cap,18)).then(function(t){return Promise.resolve(o.amountToUnits(null,e.feeAmount,s)).then(function(e){return{templateIndex:a,strings:i,addresses:n,uints:[t,e],bytess:[]}})})},o=this;if(!e.name||!e.symbol){var i=ee();t=i.name,r=i.symbol}var s=18,a=function(){if(e.feeToken!==q){var t=function(t,r){try{var n=Promise.resolve(V(o.signer,e.feeToken)).then(function(e){s=e})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){oe.error("getTokenDecimals error",e)});if(t&&t.then)return t.then(function(){})}}();return Promise.resolve(a&&a.then?a.then(n):n())}catch(e){return Promise.reject(e)}},r.getFreCreationParams=function(e){try{var t=this;e.allowedConsumer||(e.allowedConsumer=q);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}(ve),we=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return M.default.abi},r.lockTokens=function(e,t,r){try{var n=this,o=n.amountToUnits;return Promise.resolve(n.getToken()).then(function(i){return Promise.resolve(o.call(n,i,e)).then(function(e){return Promise.resolve(n.contract.estimateGas.create_lock(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o.add(2e4),n.signer,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(W(o.add(2e4),n.signer,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(W(n.add(2e4),r.signer,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(W(n.add(2e4),r.signer,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(W(r.add(2e4),t.signer,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}(ve),Te=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return A.default.abi},r.claim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateGas.claim()).then(function(r){var n;return e?r:Promise.resolve(W(r.add(2e4),t.signer,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(W(n.add(2e4),r.signer,null==(o=r.config)?void 0:o.gasFeeMultiplier,r.contract.claim_many,e))})}catch(e){return Promise.reject(e)}},t}(ve),be=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return U.default.abi},r.estimateClaim=function(e){try{var t=this;return Promise.resolve(t.contract.estimateClaim(e)).then(function(e){return Promise.resolve(t.contract.voting_escrow()).then(function(r){var n=new we(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}(ve),Fe=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return O.default.abi},r.setAllocation=function(e,t,r,n){try{var o=this;return Promise.resolve(o.contract.estimateGas.setAllocation(e,t,r)).then(function(i){var s;return n?i:Promise.resolve(W(i.add(2e4),o.signer,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(W(i.add(2e4),o.signer,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}(ve);function Ee(e,t,r){if(!e.s){if(r instanceof ke){if(!r.s)return void(r.o=Ee.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Ee.bind(null,e,t),Ee.bind(null,e,2));e.s=t,e.v=r;const n=e.o;n&&n(e)}}var 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{Ee(n,1,i(this.v))}catch(e){Ee(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ee(n,1,t?t(o):o):r?Ee(n,1,r(o)):Ee(n,2,o)}catch(e){Ee(n,2,e)}},n},e}(),Ce=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return R.default.abi},r.getAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimable(e,t)).then(function(e){return Promise.resolve(r.unitsToAmount(t,e))})}catch(e){return Promise.reject(e)}},r.claimRewards=function(e,t,r){try{var n=this;return Promise.resolve(n.contract.estimateGas.claimFor(e,t)).then(function(o){var i;return r?o:Promise.resolve(W(o,n.signer,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(W(o,i.signer,null==(s=i.config)?void 0:s.gasFeeMultiplier,i.contract.allocate,e,t,r))})},i=this,s=(a=t,u=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=u(m))&&t.then){if(!((r=t)instanceof ke&&1&r.s))return void t.then(e,l||(l=Ee.bind(null,c=new ke,2)));t=t.v}c?Ee(c,1,t):c=t}catch(e){Ee(c||(c=new ke),2,e)}var r}(),c);return Promise.resolve(s&&s.then?s.then(o):o())}catch(e){return Promise.reject(e)}var a,u,c,l,m},t}(ve);function je(e,t,r){if(!e.s){if(r instanceof xe){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 xe=/*#__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}(),De=/*#__PURE__*/function(e){function t(){return e.apply(this,arguments)||this}I(t,e);var r=t.prototype;return r.getDefaultAbi=function(){return S.default.abi},r.getMultipleAvailableRewards=function(e,t){try{var r=this;return Promise.resolve(r.contract.claimables(e,t)).then(function(e){var n,o,i,s,a,u=[],c=(n=e,o=function(n){var o=u.push;return Promise.resolve(r.unitsToAmount(t[n],e[n])).then(function(e){o.call(u,e)})},a=-1,function e(t){try{for(;++a<n.length;)if((t=o(a))&&t.then){if(!((r=t)instanceof xe&&1&r.s))return void t.then(e,s||(s=je.bind(null,i=new xe,2)));t=t.v}i?je(i,1,t):i=t}catch(e){je(i||(i=new xe),2,e)}var r}(),i);return c&&c.then?c.then(function(){return u}):u})}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(W(o,n.signer,null==(i=n.config)?void 0:i.gasFeeMultiplier,n.contract.claimMultiple,e,t))})}catch(e){return Promise.reject(e)}},t}(ve);function Me(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}function Ae(e,t,r){if(!e.s){if(r instanceof Ue){if(!r.s)return void(r.o=Ae.bind(null,e,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(Ae.bind(null,e,t),Ae.bind(null,e,2));e.s=t,e.v=r;var n=e.o;n&&n(e)}}var Ue=/*#__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{Ae(n,1,i(this.v))}catch(e){Ae(n,2,e)}return n}return this}return this.o=function(e){try{var o=e.v;1&e.s?Ae(n,1,t?t(o):o):r?Ae(n,1,r(o)):Ae(n,2,o)}catch(e){Ae(n,2,e)}},n},e}();function Oe(e){return e instanceof Ue&&1&e.s}var Re=/*#__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(Me(function(){return Promise.resolve(T.default(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 oe.error(e),new Error("HTTP request failed")}))}catch(e){return Promise.reject(e)}},t.waitForAqua=function(e,t,r){try{var n,o=this,i=0,s=function(e,t){var r;do{var n=e();if(n&&n.then){if(!Oe(n)){r=!0;break}n=n.v}var o=t();if(Oe(o)&&(o=o.v),!o)return n}while(!o.then);var i=new Ue,s=Ae.bind(null,i,2);return(r?n.then(a):o.then(u)).then(void 0,s),i;function a(r){for(n=r;Oe(o=t())&&(o=o.v),o;){if(o.then)return void o.then(u).then(void 0,s);if((n=e())&&n.then){if(!Oe(n))return void n.then(a).then(void 0,s);n=n.v}}Ae(i,1,n)}function u(r){if(r){do{if((n=e())&&n.then){if(!Oe(n))return void n.then(a).then(void 0,s);n=n.v}if(Oe(r=t())&&(r=r.v),!r)return void Ae(i,1,n)}while(!r.then);r.then(u).then(void 0,s)}else Ae(i,1,n)}}(function(){function s(e){return n?e:Promise.resolve(re(1500)).then(function(){i++})}var a=Me(function(){return Promise.resolve(T.default(o.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 a&&a.then?a.then(s):s(a)},function(){return!n&&i<100});return Promise.resolve(s&&s.then?s.then(function(e){return n?e:null}):n?s:null)}catch(e){return Promise.reject(e)}},t.validate=function(e,t){try{var r,n=this,o={valid:!1},i=Me(function(){return Promise.resolve(T.default(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?(o.valid=!0,o.hash=r.hash,o.proof={validatorAddress:r.publicKey,r:r.r[0],s:r.s[0],v:r.v}):(o.errors=r,oe.error("validate Metadata failed:",e.status,o.errors))})})},function(e){oe.error("Error validating metadata: ",e)});return Promise.resolve(i&&i.then?i.then(function(){return o}):o)}catch(e){return Promise.reject(e)}},t.getAssetMetadata=function(e,t){try{var r=this.aquariusURL+"/api/aquarius/assets/metadata/"+e;return Promise.resolve(Me(function(){return Promise.resolve(T.default(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 oe.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(Me(function(){return Promise.resolve(T.default(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 oe.error("Error querying metadata: ",e),new Error("Error querying metadata: "+e)}))}catch(e){return Promise.reject(e)}},e}();function Se(e,t){try{var r=e()}catch(e){return t(e)}return r&&r.then?r.then(void 0,t):r}var Ne=/*#__PURE__*/function(){function e(){}var r=e.prototype;return r.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 oe.error("Finding the service endpoints failed:",e),new Error("HTTP request failed calling Provider")}))}catch(e){return Promise.reject(e)}},r.getEndpointURL=function(e,t){return e?e.find(function(e){return e.serviceName===t}):null},r.getServiceEndpoints=function(e,t){try{var r=[];for(var n in t.serviceEndpoints)r.push({serviceName:n,method:t.serviceEndpoints[n][0],urlPath:e+t.serviceEndpoints[n][1]});return Promise.resolve(r)}catch(e){return Promise.reject(e)}},r.getNonce=function(e,t,r,n,o){try{var i=function(){function i(){var e=s.getEndpointURL(o,"nonce")?s.getEndpointURL(o,"nonce").urlPath:null;return e?Se(function(){return Promise.resolve(T.default(e+"?userAddress="+t,{method:"GET",headers:{"Content-Type":"application/json"},signal:r})).then(function(e){return Promise.resolve(e.json()).then(function(e){var r=e.nonce;return console.log("[getNonce] Consumer: "+t+" nonce: "+r),r&&null!==r?r:"0"})})},function(e){throw oe.error(e),new Error(e.message)}):null}var a=function(){if(!o)return Promise.resolve(s.getServiceEndpoints(e,n)).then(function(e){o=e})}();return a&&a.then?a.then(i):i()},s=this,a=function(){if(!n)return Promise.resolve(s.getEndpoints(e)).then(function(e){n=e})}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},r.signProviderRequest=function(e,r){try{var n=t.ethers.utils.solidityKeccak256(["bytes"],[t.ethers.utils.hexlify(t.ethers.utils.toUtf8Bytes(r))]),o=t.ethers.utils.arrayify(n);return Promise.resolve(e.getChainId()).then(function(t){var r;function n(t){return r?t:Promise.resolve(e.signMessage(o))}var i=function(){if(8996===t)return Promise.resolve(e._legacySignMessage(o)).then(function(e){return r=1,e})}();return i&&i.then?i.then(n):n(i)})}catch(e){return Promise.reject(e)}},r.encrypt=function(e,t,r,n){try{var o=this;return Promise.resolve(o.getEndpoints(r)).then(function(i){return Promise.resolve(o.getServiceEndpoints(r,i)).then(function(r){var i=(o.getEndpointURL(r,"encrypt")?o.getEndpointURL(r,"encrypt").urlPath:null)+"?chainId="+t;return i?Se(function(){return Promise.resolve(T.default(i,{method:"POST",body:JSON.stringify(e),headers:{"Content-Type":"application/octet-stream"},signal:n})).then(function(e){return Promise.resolve(e.text())})},function(e){throw oe.error(e),new Error("HTTP request failed calling Provider")}):null})})}catch(e){return Promise.reject(e)}},r.checkDidFiles=function(e,t,r,n,o){void 0===n&&(n=!1);try{var i=this;return Promise.resolve(i.getEndpoints(r)).then(function(s){return Promise.resolve(i.getServiceEndpoints(r,s)).then(function(r){function s(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw oe.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=L(e);!(r=n()).done;)c.push(r.value);return t=1,c})}();return n&&n.then?n.then(r):r(n)}var a,u={did:e,serviceId:t,checksum:n},c=[],l=i.getEndpointURL(r,"fileinfo")?i.getEndpointURL(r,"fileinfo").urlPath:null;if(!l)return null;var m=Se(function(){return Promise.resolve(T.default(l,{method:"POST",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw oe.error("File info call failed: "),oe.error(e),new Error(e)});return m&&m.then?m.then(s):s()})})}catch(e){return Promise.reject(e)}},r.getFileInfo=function(e,t,r,n){void 0===r&&(r=!1);try{var o=this;return Promise.resolve(o.getEndpoints(t)).then(function(i){return Promise.resolve(o.getServiceEndpoints(t,i)).then(function(t){function i(e){var t;function r(e){return t?e:Promise.resolve(s.json()).then(function(e){throw oe.error("File info call failed: ",s.status,s.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=s)&&e.ok)return Promise.resolve(s.json()).then(function(e){for(var r,n=L(e);!(r=n()).done;)u.push(r.value);return t=1,u})}();return n&&n.then?n.then(r):r(n)}var s,a=N({},e,{checksum:r}),u=[],c=o.getEndpointURL(t,"fileinfo")?o.getEndpointURL(t,"fileinfo").urlPath:null;if(!c)return null;var l=Se(function(){return Promise.resolve(T.default(c,{method:"POST",body:JSON.stringify(a),headers:{"Content-Type":"application/json"},signal:n})).then(function(e){s=e})},function(e){throw oe.error("File info call failed: "),oe.error(e),new Error(e)});return l&&l.then?l.then(i):i()})})}catch(e){return Promise.reject(e)}},r.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 o;function i(e){var t;if(null!=(t=s)&&t.ok){var r,o=s.json();return Array.isArray(o)?((r={})[n.chainId]=o,r):o}return Promise.resolve(s.json()).then(function(e){throw oe.error("Fetch compute env failed: ",s.status,s.statusText,e),new Error(JSON.stringify(e))})}var s,a=null==(o=r.getEndpointURL(e,"computeEnvironments"))?void 0:o.urlPath;if(!a)return null;var u=Se(function(){return Promise.resolve(T.default(a,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){s=e})},function(e){throw oe.error("Fetch compute env failed: "),oe.error(e),new Error(e)});return u&&u.then?u.then(i):i()})})}catch(e){return Promise.reject(e)}},r.initialize=function(e,t,r,n,o,i,s,a,u){try{var c=this;return Promise.resolve(c.getEndpoints(o)).then(function(l){return Promise.resolve(c.getServiceEndpoints(o,l)).then(function(o){function l(e){var t;function r(e){return t?e:Promise.resolve(m.json()).then(function(e){throw oe.error("Provider initialized failed: ",m.status,m.statusText,e),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=m)&&e.ok)return Promise.resolve(m.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var m,h=c.getEndpointURL(o,"initialize")?c.getEndpointURL(o,"initialize").urlPath:null;if(!h)return null;h+="?documentId="+e,h+="&serviceId="+t,h+="&fileIndex="+r,h+="&consumerAddress="+n,s&&(h+="&userdata="+encodeURI(JSON.stringify(s))),a&&(h+="&environment="+encodeURI(a)),u&&(h+="&validUntil="+u);var v=Se(function(){return Promise.resolve(T.default(h,{method:"GET",headers:{"Content-Type":"application/json"},signal:i})).then(function(e){m=e})},function(e){throw oe.error("Provider initialized failed: "),oe.error(e),new Error("Provider initialize failed url: "+h+" ")});return v&&v.then?v.then(l):l()})})}catch(e){return Promise.reject(e)}},r.initializeCompute=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(u){return Promise.resolve(a.getServiceEndpoints(o,u)).then(function(o){function u(e){var t;function r(e){return t?e:Promise.resolve(c.json()).then(function(e){throw oe.error("Initialize compute failed: ",c.status,c.statusText,e),oe.error("Payload was:",l),new Error(JSON.stringify(e))})}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,l={datasets:e,algorithm:t,compute:{env:r,validUntil:n},consumerAddress:i},m=a.getEndpointURL(o,"initializeCompute")?a.getEndpointURL(o,"initializeCompute").urlPath:null;if(!m)return null;var h=Se(function(){return Promise.resolve(T.default(m,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json"},signal:s})).then(function(e){c=e})},function(e){throw oe.error("Initialize compute failed: "),oe.error(e),new Error("ComputeJob cannot be initialized")});return h&&h.then?h.then(u):u()})})}catch(e){return Promise.reject(e)}},r.getDownloadUrl=function(e,t,r,n,o,i,s){try{var a=this;return Promise.resolve(a.getEndpoints(o)).then(function(u){return Promise.resolve(a.getServiceEndpoints(o,u)).then(function(c){var l=a.getEndpointURL(c,"download")?a.getEndpointURL(c,"download").urlPath:null;return l?Promise.resolve(i.getAddress()).then(function(m){return Promise.resolve(a.getNonce(o,m,null,u,c)).then(function(o){var u=(o+1).toString();return Promise.resolve(a.signProviderRequest(i,e+u)).then(function(o){var i=l;return i+="?fileIndex="+r,i+="&documentId="+e,i+="&transferTxId="+n,i+="&serviceId="+t,i+="&consumerAddress="+m,i+="&nonce="+u,i+="&signature="+o,s&&(i+="&userdata="+encodeURI(JSON.stringify(s))),i})})}):null})})}catch(e){return Promise.reject(e)}},r.computeStart=function(e,t,r,n,o,i,s,a){try{var u=this;return Promise.resolve(u.getEndpoints(e)).then(function(c){return Promise.resolve(u.getServiceEndpoints(e,c)).then(function(l){var m=u.getEndpointURL(l,"computeStart")?u.getEndpointURL(l,"computeStart").urlPath:null;return Promise.resolve(t.getAddress()).then(function(h){return Promise.resolve(u.getNonce(e,h,i,c,l)).then(function(e){var c=(e+1).toString(),l=h;return l+=n.documentId,l+=c,Promise.resolve(u.signProviderRequest(t,l)).then(function(e){function t(e){var t;function r(e){if(t)return e;var r=oe.error,n=u.statusText,o=u.status;return Promise.resolve(u.json()).then(function(e){return r.call(oe,"Compute start failed: ",o,n,e),oe.error("Payload was:",l),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,l=Object();if(l.consumerAddress=h,l.signature=e,l.nonce=c,l.environment=r,l.dataset=n,l.algorithm=o,l.additionalDatasets&&(l.additionalDatasets=s),a&&(l.output=a),!m)return null;var v=Se(function(){return Promise.resolve(T.default(m,{method:"POST",body:JSON.stringify(l),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){u=e})},function(e){throw oe.error("Compute start failed:"),oe.error(e),oe.error("Payload was:",l),new Error("HTTP request failed calling Provider")});return v&&v.then?v.then(t):t()})})})})})}catch(e){return Promise.reject(e)}},r.computeStop=function(e,t,r,n,o,i){try{var s=this;return Promise.resolve(s.getEndpoints(n)).then(function(a){return Promise.resolve(s.getServiceEndpoints(n,a)).then(function(u){var c=s.getEndpointURL(u,"computeStop")?s.getEndpointURL(u,"computeStop").urlPath:null;return Promise.resolve(s.getNonce(n,t,i,a,u)).then(function(n){var a=(n+1).toString(),u=t;return u+=r||"",u+=e&&""+s.noZeroX(e)||"",u+=a,Promise.resolve(s.signProviderRequest(o,u)).then(function(n){function o(e){var t;function r(e){return t?e:Promise.resolve(a.json()).then(function(e){throw oe.error("Compute stop failed: ",a.status,a.statusText,e),oe.error("Payload was:",u),new Error(JSON.stringify(e))})}var n=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,u=Object();if(u.signature=n,u.documentId=s.noZeroX(e),u.consumerAddress=t,r&&(u.jobId=r),!c)return null;var l=Se(function(){return Promise.resolve(T.default(c,{method:"PUT",body:JSON.stringify(u),headers:{"Content-Type":"application/json"},signal:i})).then(function(e){a=e})},function(e){throw oe.error("Compute stop failed:"),oe.error(e),oe.error("Payload was:",u),new Error("HTTP request failed calling Provider")});return l&&l.then?l.then(o):o()})})})})}catch(e){return Promise.reject(e)}},r.computeStatus=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(e)).then(function(s){return Promise.resolve(i.getServiceEndpoints(e,s)).then(function(e){function s(e){var t;function r(e){var r;if(t)return e;function n(e){return r?e:Promise.resolve(a.json()).then(function(e){throw oe.error("Get compute status failed:",a.status,a.statusText,e),new Error(JSON.stringify(e))})}oe.error("Get compute status failed:",a.status,a.statusText);var o=function(){var e;if(null!=(e=a)&&e.ok)return Promise.resolve(a.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=a)&&e.ok)return Promise.resolve(a.json()).then(function(e){return t=1,e})}();return n&&n.then?n.then(r):r(n)}var a,u=i.getEndpointURL(e,"computeStatus")?i.getEndpointURL(e,"computeStatus").urlPath:null,c="?consumerAddress="+t;if(c+=n&&"&documentId="+i.noZeroX(n)||"",c+=r&&"&jobId="+r||"",!u)return null;var l=Se(function(){return Promise.resolve(T.default(u+c,{method:"GET",headers:{"Content-Type":"application/json"},signal:o})).then(function(e){a=e})},function(e){throw oe.error("Get compute status failed"),oe.error(e),new Error(e)});return l&&l.then?l.then(s):s()})})}catch(e){return Promise.reject(e)}},r.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,u=o.getNonce;return Promise.resolve(t.getAddress()).then(function(c){return Promise.resolve(u.call(o,e,c,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)}},r.computeDelete=function(e,t,r,n,o){try{var i=this;return Promise.resolve(i.getEndpoints(n)).then(function(s){return Promise.resolve(i.getServiceEndpoints(n,s)).then(function(a){var u=i.getEndpointURL(a,"computeDelete")?i.getEndpointURL(a,"computeDelete").urlPath:null,c=i.getNonce;return Promise.resolve(t.getAddress()).then(function(l){return Promise.resolve(c.call(i,n,l,o,s,a)).then(function(n){var s=(n+1).toString();return Promise.resolve(t.getAddress()).then(function(n){return n+=r||"",n+=e&&""+i.noZeroX(e)||"",n+=s,Promise.resolve(i.signProviderRequest(t,n)).then(function(n){var s=Object();return s.documentId=i.noZeroX(e),Promise.resolve(t.getAddress()).then(function(e){var t;function i(e){var r;function n(e){return r?e:Promise.resolve(t.json()).then(function(e){throw oe.error("Delete compute job failed:",t.status,t.statusText,e),oe.error("Payload was:",s),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(s.consumerAddress=e,s.jobId=r,n&&(s.signature=n),!u)return null;var a=Se(function(){return Promise.resolve(T.default(u,{method:"DELETE",body:JSON.stringify(s),headers:{"Content-Type":"application/json"},signal:o})).then(function(e){t=e})},function(e){throw oe.error("Delete compute job failed:"),oe.error(e),oe.error("Payload was:",s),new Error("HTTP request failed calling Provider")});return a&&a.then?a.then(i):i()})})})})})})})}catch(e){return Promise.reject(e)}},r.isValidProvider=function(e,t){try{return Promise.resolve(Se(function(){return Promise.resolve(T.default(e,{method:"GET",headers:{"Content-Type":"application/json"},signal:t})).then(function(e){var t,r=function(){if(null!=e&&e.ok)return Promise.resolve(e.json()).then(function(e){if(e&&(e.providerAddress||e.providerAddresses))return t=!0})}();return r&&r.then?r.then(function(e){return!!t&&e}):!!t&&r})},function(e){return oe.error("Error validating provider: "+e.message),!1}))}catch(e){return Promise.reject(e)}},r.noZeroX=function(e){return this.zeroXTransformer(e,!1)},r.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},r.inputMatch=function(e,t,r){if("string"!=typeof e)throw oe.debug("Not input string:"),oe.debug(e),new Error("["+r+"] Expected string, input type: "+typeof e);var n=e.match(t);return n?{valid:!0,output:n[1]}:(oe.warn("["+r+"] Input transformation failed."),{valid:!1,output:e})},r.getData=function(e){try{return Promise.resolve(T.default(e,{method:"GET",headers:{"Content-type":"application/json"}}))}catch(e){return Promise.reject(e)}},e}(),Ie=new Ne;exports.Aquarius=Re,exports.Config=function(){this.nodeUri=void 0,this.providerAddress=void 0,this.metadataCacheUri=void 0,this.providerUri=void 0,this.web3Provider=void 0,this.oceanTokenAddress=void 0,this.nftFactoryAddress=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},exports.ConfigHelper=me,exports.Datatoken=Pe,exports.DfRewards=Ce,exports.DfStrategyV1=De,exports.Dispenser=fe,exports.FEE_HISTORY_NOT_SUPPORTED="Returned error: Method eth_feeHistory not supported.",exports.FixedRateExchange=de,exports.GASLIMIT_DEFAULT=1e6,exports.Logger=ne,exports.LoggerInstance=oe,exports.MAX_UINT_256="115792089237316195423570985008687907853269984665640564039457584007913129639934",exports.Nft=ge,exports.NftFactory=ye,exports.Provider=Ne,exports.ProviderInstance=Ie,exports.Router=pe,exports.SmartContract=he,exports.SmartContractWithAddress=ve,exports.VeAllocate=Fe,exports.VeFeeDistributor=Te,exports.VeFeeEstimate=be,exports.VeOcean=we,exports.ZERO_ADDRESS=q,exports.allowance=ae,exports.allowanceWei=se,exports.amountToUnits=J,exports.approve=function(e,r,n,o,i,s,a,u,c){void 0===a&&(a=!1);try{var l,m=function(t){return l?t:Promise.resolve(J(e,o,s,u)).then(function(t){return Promise.resolve(h.estimateGas.approve(i,t)).then(function(n){return c?new b.default(n.toString()):Promise.resolve(W(n,e,null==r?void 0:r.gasFeeMultiplier,h.approve,i,t))})})},h=new t.ethers.Contract(o,ie,e),v=function(){if(!a)return Promise.resolve(ae(e,o,n,i)).then(function(e){if(new b.default(e).greaterThanOrEqualTo(new b.default(s))){var t=new b.default(e).toNumber();return l=1,t}})}();return Promise.resolve(v&&v.then?v.then(m):m(v))}catch(e){return Promise.reject(e)}},exports.approveWei=function(e,r,n,o,i,s,a,u){void 0===a&&(a=!1);try{var c,l=function(t){if(c)return t;var n=null;return Promise.resolve(m.estimateGas.approve(i,s)).then(function(t){if(u)return t;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(W(t,e,null==r?void 0:r.gasFeeMultiplier,m.approve,i,s)).then(function(e){n=e})},function(e){oe.error("ERROR: Failed to approve spender to spend tokens : "+e.message)});return o&&o.then?o.then(function(){return n}):n})},m=new t.ethers.Contract(o,ie,e),h=function(){if(!a)return Promise.resolve(se(e,o,n,i)).then(function(e){if(t.ethers.BigNumber.from(e).gt(t.ethers.BigNumber.from(s))){var r=t.ethers.BigNumber.from(e);return c=1,r}})}();return Promise.resolve(h&&h.then?h.then(l):l(h))}catch(e){return Promise.reject(e)}},exports.balance=function(e,r,n,o){try{var i=new t.ethers.Contract(r,ie,e);return Promise.resolve(i.balanceOf(n)).then(function(t){return Promise.resolve(z(e,r,t,o))})}catch(e){return Promise.reject(e)}},exports.configHelperNetworks=le,exports.decimals=function(e,r){try{var n=new t.ethers.Contract(r,ie,e);return Promise.resolve(n.decimals())}catch(e){return Promise.reject(e)}},exports.downloadFile=function(e,t){try{return Promise.resolve(T.default(e)).then(function(r){if(!r.ok)throw new Error("Response error.");var n;try{n=r.headers.get("content-disposition").match(/attachment;filename=(.+)/)[1]}catch(r){try{n=e.split("/").pop()}catch(e){n="file"+t}}return Promise.resolve(r.arrayBuffer()).then(function(e){return{data:e,filename:n}})})}catch(e){return Promise.reject(e)}},exports.downloadFileBrowser=function(e){try{return Promise.resolve(T.default(e,{method:"HEAD"})).then(function(t){var r=t.headers.get("content-disposition"),n=null!=r&&r.split("=")[1]?null==r?void 0:r.split("=")[1]:"file",o=new XMLHttpRequest;o.responseType="blob",o.open("GET",e),o.onload=function(){var e=window.URL.createObjectURL(o.response),t=document.createElement("a");t.href=e,t.setAttribute("download",n),document.body.appendChild(t),t.click(),t.remove(),window.URL.revokeObjectURL(e)},o.send(null)})}catch(e){return Promise.reject(e)}},exports.generateDid=function(e,r){return e=t.ethers.utils.getAddress(e),"did:op:"+w.default(e+r.toString(10)).toString()},exports.generateDtName=ee,exports.getErrorMessage=function(e){var t=Object.keys(e)[0];if("error"===t){var r=e[t];return ue[t][r]||"Provider request failed: "+r}var n=e[t];return e[Object.keys(e)[1]]+" : "+n},exports.getEventFromTx=$,exports.getFairGasPrice=H,exports.getHash=function(e){return w.default(e).toString()},exports.getTokenDecimals=V,exports.minAbi=ie,exports.sendTx=W,exports.setContractDefaults=K,exports.signHash=function(e,r){try{var n=t.ethers.utils.arrayify(r);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)}},exports.sleep=re,exports.transfer=function(e,r,n,o,i,s){try{var a=new t.ethers.Contract(n,ie,e);return Promise.resolve(J(e,n,i)).then(function(t){return Promise.resolve(a.estimateGas.transfer(o,t)).then(function(n){return s?n:Promise.resolve(W(n,e,null==r?void 0:r.gasFeeMultiplier,a.transfer,o,t))})})}catch(e){return Promise.reject(e)}},exports.unitsToAmount=z;
2
2
  //# sourceMappingURL=lib.js.map