UNPKG

casinocronos-msdk-extra

Version:

đź›  A specific SDK/toolkit for building applications on top of the Elephant Dex.

3 lines (2 loc) • 8.58 kB
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t,n,i=require("casinocronos-msdk"),s=e(require("lodash.random")),r=e(require("casinocronos-mdefault-token-list"));(n=exports.Blockchain||(exports.Blockchain={}))[n.ETHEREUM=1]="ETHEREUM",n[n.BINANCE_SMART_CHAIN=2]="BINANCE_SMART_CHAIN",n[n.CRONOS=3]="CRONOS",n[n.HARMONY=4]="HARMONY";var a,h=function(){function e(e,t,n,i,s,r,a){this.chainId=e,this.rpcAPIKey=s,this.setBlockchain(t),this.setName(n),this.setRpcURLs(i),this.setExplorerURL(r),this.setCurrency(),this.setBlocktime(a)}var t=e.prototype;return t.setBlockchain=function(e){if(e)this.blockchain=e;else switch(this.chainId){case 25:case 338:this.blockchain=exports.Blockchain.CRONOS;break;case 56:case 97:this.blockchain=exports.Blockchain.BINANCE_SMART_CHAIN;break;case 16666e5:case 16667e5:this.blockchain=exports.Blockchain.HARMONY;break;default:this.blockchain=exports.Blockchain.ETHEREUM}},t.setName=function(e){if(e)this.name=e;else switch(this.chainId){case 1:this.name="Ethereum Mainnet";break;case 3:this.name="Ethereum Ropsten";break;case 4:this.name="Ethereum Rinkeby";break;case 5:this.name="Ethereum Görli";break;case 25:this.name="Cronos Mainnet";break;case 42:this.name="Ethereum Kovan";break;case 56:this.name="Binance Smart Chain Mainnet";break;case 97:this.name="Binance Smart Chain Testnet";break;case 338:this.name="Cronos Testnet";break;case 16666e5:this.name="Harmony Mainnet";break;case 16667e5:this.name="Harmony Testnet";break;default:this.name="Ethereum Mainnet"}},t.setRpcURLs=function(e){if(e&&e.length>0)this.rpcURLs=e;else switch(this.chainId){case 1:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://mainnet.infura.io/v3/"+this.rpcAPIKey]:["https://mainnet.infura.io/v3/"];break;case 3:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://ropsten.infura.io/v3/"+this.rpcAPIKey]:["https://ropsten.infura.io/v3/"];break;case 4:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://rinkeby.infura.io/v3/"+this.rpcAPIKey]:["https://rinkeby.infura.io/v3/"];break;case 5:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://goerli.infura.io/v3/"+this.rpcAPIKey]:["https://goerli.infura.io/v3/"];break;case 25:this.rpcURLs=["https://evm.cronos.org/"];break;case 42:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://kovan.infura.io/v3/"+this.rpcAPIKey]:["https://kovan.infura.io/v3/"];break;case 56:this.rpcURLs=["https://bsc-dataseed.binance.org/","https://bsc-dataseed1.defibit.io/","https://bsc-dataseed1.ninicoin.io/"];break;case 97:this.rpcURLs=["https://data-seed-prebsc-1-s1.binance.org:8545/","https://data-seed-prebsc-2-s1.binance.org:8545/","https://data-seed-prebsc-1-s2.binance.org:8545/"];break;case 338:this.rpcURLs=["https://evm-t3.cronos.org"];break;case 16666e5:this.rpcURLs=["https://api.s0.t.hmny.io/","https://api.harmony.one/","https://a.api.s0.t.hmny.io/"];break;case 16667e5:this.rpcURLs=["https://api.s0.b.hmny.io/"];break;default:this.rpcURLs=this.rpcAPIKey&&""!==this.rpcAPIKey?["https://mainnet.infura.io/v3/"+this.rpcAPIKey]:["https://mainnet.infura.io/v3/"]}},t.setExplorerURL=function(e){if(e&&""!==e)this.explorerURL=e;else switch(this.chainId){case 1:this.explorerURL="https://etherscan.io/";break;case 3:this.explorerURL="https://ropsten.etherscan.io/";break;case 4:this.explorerURL="https://rinkeby.etherscan.io/";break;case 5:this.explorerURL="https://goerli.etherscan.io/";break;case 25:this.explorerURL="https://cronoscan.com/";break;case 42:this.explorerURL="https://kovan.etherscan.io/";break;case 56:this.explorerURL="https://bscscan.com/";break;case 97:this.explorerURL="https://testnet.bscscan.com/";break;case 338:this.explorerURL="https://testnet.cronoscan.com/";break;case 16666e5:this.explorerURL="https://explorer.harmony.one/#/";break;case 16667e5:this.explorerURL="https://explorer.testnet.harmony.one/#/";break;default:this.explorerURL="https://etherscan.io/"}},t.setCurrency=function(){switch(this.chainId){case 25:case 338:this.currency=i.CRO;break;case 56:case 97:this.currency=i.BINANCE_COIN;break;case 16666e5:case 16667e5:this.currency=i.HARMONY;break;default:this.currency=i.ETHER}},t.setBlocktime=function(e){if(e)this.blockTime=e;else switch(this.chainId){case 25:case 338:this.blockTime=6;break;case 56:case 97:this.blockTime=3;break;case 16666e5:case 16667e5:this.blockTime=2;break;default:this.blockTime=13}},t.randomRpcURL=function(){if(void 0!==this.rpcURLs&&0!==this.rpcURLs.length){var e=s(0,this.rpcURLs.length-1);return this.rpcURLs[e]}},t.hexChainId=function(){var e;return"0x"+(null==(e=this.chainId)?void 0:e.toString(16))},e}(),o=((t={})[i.ChainId.MAINNET]=new h(i.ChainId.MAINNET),t[i.ChainId.ROPSTEN]=new h(i.ChainId.ROPSTEN),t[i.ChainId.RINKEBY]=new h(i.ChainId.RINKEBY),t[i.ChainId.GÖRLI]=new h(i.ChainId.GÖRLI),t[i.ChainId.CRONOS_MAINNET]=new h(i.ChainId.CRONOS_MAINNET),t[i.ChainId.KOVAN]=new h(i.ChainId.KOVAN),t[i.ChainId.BSC_MAINNET]=new h(i.ChainId.BSC_MAINNET),t[i.ChainId.BSC_TESTNET]=new h(i.ChainId.BSC_TESTNET),t[i.ChainId.CRONOS_TESTNET]=new h(i.ChainId.CRONOS_MAINNET),t[i.ChainId.HARMONY_MAINNET]=new h(i.ChainId.HARMONY_MAINNET),t[i.ChainId.HARMONY_TESTNET]=new h(i.ChainId.HARMONY_TESTNET),t);function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}var d=function(){function e(e,t){void 0===t&&(t=[].concat(r.tokens)),this.chainId=e,this.rawTokens=t,this.setTokens()}var t=e.prototype;return t.setTokens=function(){this.tokens=this.convertTokens(this.rawTokens),this.chainId&&(this.tokens=this.byChainId())},t.all=function(){if(this.tokens&&0!=this.tokens.length)return this.tokens},t.byChainId=function(){var e=this;if(void 0!==this.chainId&&void 0!==this.tokens)return this.tokens.filter((function(t){return t.chainId==e.chainId}))},t.byName=function(e){return this.find("name",e)},t.bySymbol=function(e){return this.find("symbol",e)},t.byAddress=function(e){return this.find("address",e)},t.firstByName=function(e){var t;return null==(t=this.find("name",e))?void 0:t[0]},t.firstBySymbol=function(e){var t;return null==(t=this.find("symbol",e))?void 0:t[0]},t.firstByAddress=function(e){var t;return null==(t=this.find("address",e))?void 0:t[0]},t.find=function(e,t){if(void 0!==this.tokens)switch(e){case"name":return this.tokens.filter((function(e){var n;return(null==e||null==(n=e.name)?void 0:n.toLowerCase())==t.toLowerCase()}));case"symbol":return this.tokens.filter((function(e){var n;return(null==e||null==(n=e.symbol)?void 0:n.toLowerCase())==t.toLowerCase()}));case"address":return this.tokens.filter((function(e){var n;return(null==e||null==(n=e.address)?void 0:n.toLowerCase())==t.toLowerCase()}));default:return this.tokens.filter((function(e){var n;return(null==e||null==(n=e.name)?void 0:n.toLowerCase())==t.toLowerCase()}))}},t.first=function(e,t){var n;return null==(n=this.find(e,t))?void 0:n[0]},t.convertTokens=function(e){for(var t,n=[],i=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return c(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(e,void 0):void 0}}(e))){n&&(e=n);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(e);!(t=i()).done;){var s=this.convertToken(t.value);n.push(s)}return n},t.convertToken=function(e){return new i.Token(e.chainId,e.address,e.decimals,e.symbol,e.name)},e}(),p=((a={})[i.ChainId.MAINNET]=new d(i.ChainId.MAINNET),a[i.ChainId.ROPSTEN]=new d(i.ChainId.ROPSTEN),a[i.ChainId.RINKEBY]=new d(i.ChainId.RINKEBY),a[i.ChainId.GÖRLI]=new d(i.ChainId.GÖRLI),a[i.ChainId.CRONOS_MAINNET]=new d(i.ChainId.CRONOS_MAINNET),a[i.ChainId.KOVAN]=new d(i.ChainId.KOVAN),a[i.ChainId.CRONOS_TESTNET]=new d(i.ChainId.CRONOS_TESTNET),a[i.ChainId.BSC_MAINNET]=new d(i.ChainId.BSC_MAINNET),a[i.ChainId.BSC_TESTNET]=new d(i.ChainId.BSC_TESTNET),a[i.ChainId.HARMONY_MAINNET]=new d(i.ChainId.HARMONY_MAINNET),a[i.ChainId.HARMONY_TESTNET]=new d(i.ChainId.HARMONY_TESTNET),a);exports.BLOCKCHAIN_SETTINGS=o,exports.BlockchainSettings=h,exports.TOKENS=p,exports.Tokens=d; //# sourceMappingURL=casinocronos-msdk-extra.cjs.production.min.js.map