From f61fa18835e947a0034f79f446fb8d2edc0ff1bd Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 19 Oct 2024 16:38:01 -0500 Subject: [PATCH] Remove cryptocurrency-icons package, vendor in the most popular open source cryptocurrencies --- package.json | 1 - src/assets/cryptocurrency/LICENSE.md | 121 ++++++++++++++++++ src/assets/cryptocurrency/aave.svg | 1 + src/assets/cryptocurrency/ada.svg | 1 + src/assets/cryptocurrency/algo.svg | 1 + src/assets/cryptocurrency/atom.svg | 1 + src/assets/cryptocurrency/avax.svg | 1 + src/assets/cryptocurrency/bch.svg | 1 + src/assets/cryptocurrency/btc.svg | 1 + src/assets/cryptocurrency/dot.svg | 1 + src/assets/cryptocurrency/eos.svg | 1 + src/assets/cryptocurrency/etc.svg | 1 + src/assets/cryptocurrency/eth.svg | 1 + src/assets/cryptocurrency/fil.svg | 1 + src/assets/cryptocurrency/generic.svg | 1 + src/assets/cryptocurrency/icp.svg | 1 + src/assets/cryptocurrency/link.svg | 1 + src/assets/cryptocurrency/ltc.svg | 1 + src/assets/cryptocurrency/matic.svg | 1 + src/assets/cryptocurrency/sol.svg | 1 + src/assets/cryptocurrency/vet.svg | 1 + src/assets/cryptocurrency/xlm.svg | 1 + src/assets/cryptocurrency/xmr.svg | 1 + src/assets/cryptocurrency/xrp.svg | 1 + src/assets/cryptocurrency/xtz.svg | 1 + src/assets/cryptocurrency/zec.svg | 1 + .../crypto-donate/components/crypto-icon.tsx | 11 +- .../crypto-donate/utils/block-explorer.ts | 4 +- src/features/crypto-donate/utils/coin-db.ts | 39 ++++-- .../crypto-donate/utils/manifest-map.ts | 11 -- yarn.lock | 5 - 31 files changed, 181 insertions(+), 35 deletions(-) create mode 100644 src/assets/cryptocurrency/LICENSE.md create mode 100644 src/assets/cryptocurrency/aave.svg create mode 100644 src/assets/cryptocurrency/ada.svg create mode 100644 src/assets/cryptocurrency/algo.svg create mode 100644 src/assets/cryptocurrency/atom.svg create mode 100644 src/assets/cryptocurrency/avax.svg create mode 100644 src/assets/cryptocurrency/bch.svg create mode 100644 src/assets/cryptocurrency/btc.svg create mode 100644 src/assets/cryptocurrency/dot.svg create mode 100644 src/assets/cryptocurrency/eos.svg create mode 100644 src/assets/cryptocurrency/etc.svg create mode 100644 src/assets/cryptocurrency/eth.svg create mode 100644 src/assets/cryptocurrency/fil.svg create mode 100644 src/assets/cryptocurrency/generic.svg create mode 100644 src/assets/cryptocurrency/icp.svg create mode 100644 src/assets/cryptocurrency/link.svg create mode 100644 src/assets/cryptocurrency/ltc.svg create mode 100644 src/assets/cryptocurrency/matic.svg create mode 100644 src/assets/cryptocurrency/sol.svg create mode 100644 src/assets/cryptocurrency/vet.svg create mode 100644 src/assets/cryptocurrency/xlm.svg create mode 100644 src/assets/cryptocurrency/xmr.svg create mode 100644 src/assets/cryptocurrency/xrp.svg create mode 100644 src/assets/cryptocurrency/xtz.svg create mode 100644 src/assets/cryptocurrency/zec.svg delete mode 100644 src/features/crypto-donate/utils/manifest-map.ts diff --git a/package.json b/package.json index c36bb704c..d7098c29a 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,6 @@ "browserslist": "^4.16.6", "clsx": "^2.0.0", "comlink": "^4.4.1", - "cryptocurrency-icons": "^0.18.1", "cssnano": "^6.0.0", "detect-passive-events": "^2.0.0", "emoji-datasource": "15.0.1", diff --git a/src/assets/cryptocurrency/LICENSE.md b/src/assets/cryptocurrency/LICENSE.md new file mode 100644 index 000000000..0e259d42c --- /dev/null +++ b/src/assets/cryptocurrency/LICENSE.md @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/src/assets/cryptocurrency/aave.svg b/src/assets/cryptocurrency/aave.svg new file mode 100644 index 000000000..0fc31d983 --- /dev/null +++ b/src/assets/cryptocurrency/aave.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/ada.svg b/src/assets/cryptocurrency/ada.svg new file mode 100644 index 000000000..d558f0d80 --- /dev/null +++ b/src/assets/cryptocurrency/ada.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/algo.svg b/src/assets/cryptocurrency/algo.svg new file mode 100644 index 000000000..42d635f5a --- /dev/null +++ b/src/assets/cryptocurrency/algo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/atom.svg b/src/assets/cryptocurrency/atom.svg new file mode 100644 index 000000000..f957f2ce0 --- /dev/null +++ b/src/assets/cryptocurrency/atom.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/avax.svg b/src/assets/cryptocurrency/avax.svg new file mode 100644 index 000000000..7bd97adeb --- /dev/null +++ b/src/assets/cryptocurrency/avax.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/bch.svg b/src/assets/cryptocurrency/bch.svg new file mode 100644 index 000000000..06d99d779 --- /dev/null +++ b/src/assets/cryptocurrency/bch.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/btc.svg b/src/assets/cryptocurrency/btc.svg new file mode 100644 index 000000000..5dc8a39dc --- /dev/null +++ b/src/assets/cryptocurrency/btc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/dot.svg b/src/assets/cryptocurrency/dot.svg new file mode 100644 index 000000000..7751a9c8a --- /dev/null +++ b/src/assets/cryptocurrency/dot.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/eos.svg b/src/assets/cryptocurrency/eos.svg new file mode 100644 index 000000000..4ca4e48fc --- /dev/null +++ b/src/assets/cryptocurrency/eos.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/etc.svg b/src/assets/cryptocurrency/etc.svg new file mode 100644 index 000000000..8e11cf9e6 --- /dev/null +++ b/src/assets/cryptocurrency/etc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/eth.svg b/src/assets/cryptocurrency/eth.svg new file mode 100644 index 000000000..c761cef49 --- /dev/null +++ b/src/assets/cryptocurrency/eth.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/fil.svg b/src/assets/cryptocurrency/fil.svg new file mode 100644 index 000000000..144440bf0 --- /dev/null +++ b/src/assets/cryptocurrency/fil.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/generic.svg b/src/assets/cryptocurrency/generic.svg new file mode 100644 index 000000000..b599951e7 --- /dev/null +++ b/src/assets/cryptocurrency/generic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/icp.svg b/src/assets/cryptocurrency/icp.svg new file mode 100644 index 000000000..642b81568 --- /dev/null +++ b/src/assets/cryptocurrency/icp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/link.svg b/src/assets/cryptocurrency/link.svg new file mode 100644 index 000000000..f7e000a15 --- /dev/null +++ b/src/assets/cryptocurrency/link.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/ltc.svg b/src/assets/cryptocurrency/ltc.svg new file mode 100644 index 000000000..9afc70625 --- /dev/null +++ b/src/assets/cryptocurrency/ltc.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/matic.svg b/src/assets/cryptocurrency/matic.svg new file mode 100644 index 000000000..31361b8b1 --- /dev/null +++ b/src/assets/cryptocurrency/matic.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/sol.svg b/src/assets/cryptocurrency/sol.svg new file mode 100644 index 000000000..ce2713055 --- /dev/null +++ b/src/assets/cryptocurrency/sol.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/vet.svg b/src/assets/cryptocurrency/vet.svg new file mode 100644 index 000000000..040000e27 --- /dev/null +++ b/src/assets/cryptocurrency/vet.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/xlm.svg b/src/assets/cryptocurrency/xlm.svg new file mode 100644 index 000000000..1d1c2a838 --- /dev/null +++ b/src/assets/cryptocurrency/xlm.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/xmr.svg b/src/assets/cryptocurrency/xmr.svg new file mode 100644 index 000000000..360a39a6e --- /dev/null +++ b/src/assets/cryptocurrency/xmr.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/xrp.svg b/src/assets/cryptocurrency/xrp.svg new file mode 100644 index 000000000..250cbfa60 --- /dev/null +++ b/src/assets/cryptocurrency/xrp.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/xtz.svg b/src/assets/cryptocurrency/xtz.svg new file mode 100644 index 000000000..5f9c35bab --- /dev/null +++ b/src/assets/cryptocurrency/xtz.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/cryptocurrency/zec.svg b/src/assets/cryptocurrency/zec.svg new file mode 100644 index 000000000..52ee264a4 --- /dev/null +++ b/src/assets/cryptocurrency/zec.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/features/crypto-donate/components/crypto-icon.tsx b/src/features/crypto-donate/components/crypto-icon.tsx index a6ffb45d2..e829f9bbd 100644 --- a/src/features/crypto-donate/components/crypto-icon.tsx +++ b/src/features/crypto-donate/components/crypto-icon.tsx @@ -1,12 +1,13 @@ -import genericIcon from 'cryptocurrency-icons/svg/color/generic.svg'; import React from 'react'; +import genericIcon from 'soapbox/assets/cryptocurrency/generic.svg'; + /** Get crypto icon URL by ticker symbol, or fall back to generic icon */ -const getIcon = (ticker: string): string => { - const modules: Record = import.meta.glob('../../../../node_modules/cryptocurrency-icons/svg/color/*.svg', { eager: true }); - const key = `../../../../node_modules/cryptocurrency-icons/svg/color/${ticker}.svg`; +function getIcon(ticker: string): string { + const modules: Record = import.meta.glob('../../../assets/cryptocurrency/*.svg', { eager: true }); + const key = `../../../assets/cryptocurrency/${ticker}.svg`; return modules[key]?.default || genericIcon; -}; +} interface ICryptoIcon { ticker: string; diff --git a/src/features/crypto-donate/utils/block-explorer.ts b/src/features/crypto-donate/utils/block-explorer.ts index b0f7a6965..af3db6788 100644 --- a/src/features/crypto-donate/utils/block-explorer.ts +++ b/src/features/crypto-donate/utils/block-explorer.ts @@ -2,8 +2,8 @@ import blockExplorers from './block-explorers.json'; type BlockExplorers = Record; -export const getExplorerUrl = (ticker: string, address: string): string | null => { +export function getExplorerUrl(ticker: string, address: string): string | null { const template = (blockExplorers as BlockExplorers)[ticker]; if (!template) return null; return template.replace('{address}', address); -}; +} diff --git a/src/features/crypto-donate/utils/coin-db.ts b/src/features/crypto-donate/utils/coin-db.ts index 1949a62cf..ea5b05891 100644 --- a/src/features/crypto-donate/utils/coin-db.ts +++ b/src/features/crypto-donate/utils/coin-db.ts @@ -1,13 +1,30 @@ -import { fromJS } from 'immutable'; - -import manifestMap from './manifest-map'; - -// All this does is converts the result from manifest_map.js into an ImmutableMap -const coinDB = fromJS(manifestMap); -export default coinDB; +const coins: Record = { + AAVE: 'Aave', + ADA: 'Cardano', + ALGO: 'Algorand', + ATOM: 'Cosmos', + AVAX: 'Avalanche', + BCH: 'Bitcoin Cash', + BTC: 'Bitcoin', + DOT: 'Polkadot', + EOS: 'EOS', + ETC: 'Ethereum Classic', + ETH: 'Ethereum', + FIL: 'Filecoin', + ICP: 'Internet Computer', + LINK: 'Chainlink', + LTC: 'Litecoin', + MATIC: 'Polygon', + SOL: 'Solana', + VET: 'VeChain', + XLM: 'Stellar', + XMR: 'Monero', + XRP: 'Ripple', + XTZ: 'Tezos', + ZEC: 'Zcash', +}; /** Get title from CoinDB based on ticker symbol */ -export const getTitle = (ticker: string): string => { - const title = coinDB.getIn([ticker, 'name']); - return typeof title === 'string' ? title : ''; -}; +export function getTitle(ticker: string): string { + return coins[ticker] ?? ''; +} diff --git a/src/features/crypto-donate/utils/manifest-map.ts b/src/features/crypto-donate/utils/manifest-map.ts deleted file mode 100644 index b89ba6ef2..000000000 --- a/src/features/crypto-donate/utils/manifest-map.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Converts cryptocurrency-icon's manifest file from a list to a map. -// See: https://github.com/spothq/cryptocurrency-icons/blob/master/manifest.json - -import manifest from 'cryptocurrency-icons/manifest.json'; -import { List as ImmutableList, Map as ImmutableMap, fromJS } from 'immutable'; - -const manifestMap = (fromJS(manifest) as ImmutableList>).reduce((acc: ImmutableMap>, entry: ImmutableMap) => { - return acc.set(entry.get('symbol')!.toLowerCase(), entry); -}, ImmutableMap()); - -export default manifestMap.toJS(); diff --git a/yarn.lock b/yarn.lock index 3318d8cbd..f44a44aae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3886,11 +3886,6 @@ crypto-random-string@^2.0.0: resolved "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -cryptocurrency-icons@^0.18.1: - version "0.18.1" - resolved "https://registry.yarnpkg.com/cryptocurrency-icons/-/cryptocurrency-icons-0.18.1.tgz#b1bdbfb4b78996ec003e63dbd7ec0b830d23b89c" - integrity sha512-dvR5O8JOmav3559Yb0Igpkia+3vpt/aeNvMu5ZIVUG2Bzpq9wNcOJRIQas49XJrPjtZ98GAEn3aDQO+w7uhS2w== - css-declaration-sorter@^6.3.1: version "6.4.1" resolved "https://registry.yarnpkg.com/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz#28beac7c20bad7f1775be3a7129d7eae409a3a71"