Skip to content

Commit

Permalink
v1.0.0 built
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Aug 9, 2021
1 parent 5c9d89c commit 6b22053
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 3 deletions.
44 changes: 44 additions & 0 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
@@ -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;
36 changes: 36 additions & 0 deletions dist/es/index.js
Original file line number Diff line number Diff line change
@@ -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 };
4 changes: 1 addition & 3 deletions dist/umd/index.dev.js → dist/umd/index.js
Original file line number Diff line number Diff line change
@@ -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) :
Expand All @@ -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`
Expand Down

0 comments on commit 6b22053

Please sign in to comment.