From 6b220532424a914e510bafc6faacff63b223da32 Mon Sep 17 00:00:00 2001 From: Sebastian Pape Date: Mon, 9 Aug 2021 16:46:57 +0200 Subject: [PATCH] v1.0.0 built --- dist/cjs/index.js | 44 +++++++++++++++++++++++++++++ dist/es/index.js | 36 +++++++++++++++++++++++ dist/umd/{index.dev.js => index.js} | 4 +-- 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 dist/cjs/index.js create mode 100644 dist/es/index.js rename dist/umd/{index.dev.js => index.js} (86%) diff --git a/dist/cjs/index.js b/dist/cjs/index.js new file mode 100644 index 0000000..e64aeaa --- /dev/null +++ b/dist/cjs/index.js @@ -0,0 +1,44 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var React = require('react'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var React__default = /*#__PURE__*/_interopDefaultLegacy(React); + +const _jsxFileName = "/Users/sebastian/Work/DePay/depay-react-token-image/src/index.jsx"; +let TokenImage = function(props){ + + const [src, setSrc] = React.useState(); + const [source, setSource] = React.useState('trustwallet'); + + const blockchain = props.blockchain.toLowerCase(); + const address = props.address; + + React.useEffect(()=>setSrc(trustWalletAddress({ blockchain, address })), [blockchain, address]); + + const trustWalletAddress = ({ blockchain, address })=> { + return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${blockchain}/assets/${address}/logo.png` + }; + + const handleLoadError = (error)=> { + if(source == 'trustwallet') { + setSource('depay'); + setSrc(`https://api.depay.pro/v1/images/tokens/${blockchain}/${address}`); + } else { + setSource('unknown'); + setSrc('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAAGFBMVEVHcEz///////////////////////////8dS1W+AAAAB3RSTlMAHklzmMLqCsLrGwAAAQ9JREFUeNrtlrsOgkAQRRdFbDcae4IFrZEYazXRVitqQ2Hrk/19BVdX7XYuiQX3VDZzMsxrVYQQQkibGIyzLNHi8OHaVJRLWXgwMy8KLYnfGEchEFTxjp2/wHxRalBg9v4CNAXzwxYVXCSC2ypJstx+g6/ATaAdqImvoHxHzEVFcPGqWwtOnoLFx++6DGdgq9NnG+T0K8EVEPTqnrZbEKGCFO1CDs2BG2UZbpnABEwMJIA1IRSeZfdCgV8wsjdVnEBuLyKyBu51Fb+xpfhPRgdsgYqeM6DlQwQmoA62AvISgIsc2j0EaxgDL0ojx/CCCs4KPGYnVHCk4CEg7SbIKqbqfyeRAgoaERBCCCGESLgDeRfMNogh3QMAAAAASUVORK5CYII='); + } + }; + + return( + React__default['default'].createElement('img', { + src: src , + onError: handleLoadError , __self: this, __source: {fileName: _jsxFileName, lineNumber: 28}} + ) + ) +}; + +exports.TokenImage = TokenImage; diff --git a/dist/es/index.js b/dist/es/index.js new file mode 100644 index 0000000..023ec0b --- /dev/null +++ b/dist/es/index.js @@ -0,0 +1,36 @@ +import React, { useState, useEffect } from 'react'; + +const _jsxFileName = "/Users/sebastian/Work/DePay/depay-react-token-image/src/index.jsx"; +let TokenImage = function(props){ + + const [src, setSrc] = useState(); + const [source, setSource] = useState('trustwallet'); + + const blockchain = props.blockchain.toLowerCase(); + const address = props.address; + + useEffect(()=>setSrc(trustWalletAddress({ blockchain, address })), [blockchain, address]); + + const trustWalletAddress = ({ blockchain, address })=> { + return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${blockchain}/assets/${address}/logo.png` + }; + + const handleLoadError = (error)=> { + if(source == 'trustwallet') { + setSource('depay'); + setSrc(`https://api.depay.pro/v1/images/tokens/${blockchain}/${address}`); + } else { + setSource('unknown'); + setSrc('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAAGFBMVEVHcEz///////////////////////////8dS1W+AAAAB3RSTlMAHklzmMLqCsLrGwAAAQ9JREFUeNrtlrsOgkAQRRdFbDcae4IFrZEYazXRVitqQ2Hrk/19BVdX7XYuiQX3VDZzMsxrVYQQQkibGIyzLNHi8OHaVJRLWXgwMy8KLYnfGEchEFTxjp2/wHxRalBg9v4CNAXzwxYVXCSC2ypJstx+g6/ATaAdqImvoHxHzEVFcPGqWwtOnoLFx++6DGdgq9NnG+T0K8EVEPTqnrZbEKGCFO1CDs2BG2UZbpnABEwMJIA1IRSeZfdCgV8wsjdVnEBuLyKyBu51Fb+xpfhPRgdsgYqeM6DlQwQmoA62AvISgIsc2j0EaxgDL0ojx/CCCs4KPGYnVHCk4CEg7SbIKqbqfyeRAgoaERBCCCGESLgDeRfMNogh3QMAAAAASUVORK5CYII='); + } + }; + + return( + React.createElement('img', { + src: src , + onError: handleLoadError , __self: this, __source: {fileName: _jsxFileName, lineNumber: 28}} + ) + ) +}; + +export { TokenImage }; diff --git a/dist/umd/index.dev.js b/dist/umd/index.js similarity index 86% rename from dist/umd/index.dev.js rename to dist/umd/index.js index 4ac9815..2d9a2f8 100644 --- a/dist/umd/index.dev.js +++ b/dist/umd/index.js @@ -1,5 +1,3 @@ - -(function(l, r) { if (!l || l.getElementById('livereloadscript')) return; r = l.createElement('script'); r.async = 1; r.src = '//' + (self.location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1'; r.id = 'livereloadscript'; l.getElementsByTagName('head')[0].appendChild(r) })(self.document); (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) : typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) : @@ -19,7 +17,7 @@ const blockchain = props.blockchain.toLowerCase(); const address = props.address; - React.useEffect(()=>setSrc(trustWalletAddress({ blockchain, address })), [props.blockchain, props.address]); + React.useEffect(()=>setSrc(trustWalletAddress({ blockchain, address })), [blockchain, address]); const trustWalletAddress = ({ blockchain, address })=> { return `https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/${blockchain}/assets/${address}/logo.png`