From e55cb6b47b2a91c574dee0a84159d7ecc5229a08 Mon Sep 17 00:00:00 2001 From: andrey Date: Thu, 24 Sep 2020 16:47:45 +0200 Subject: [PATCH] [#11218] Hard code fix for SUPR NFT support Drop collectibles details support --- resources/images/tokens/mainnet/SUPRR.png | Bin 0 -> 1084 bytes src/status_im/ethereum/tokens.cljs | 4 + src/status_im/events.cljs | 1 - .../ui/screens/routing/wallet_stack.cljs | 3 - src/status_im/ui/screens/views.cljs | 5 - .../ui/screens/wallet/account/views.cljs | 58 ++++-- .../collectibles/cryptokitties/views.cljs | 27 --- .../collectibles/cryptostrikers/views.cljs | 26 --- .../wallet/collectibles/etheremon/views.cljs | 26 --- .../wallet/collectibles/kudos/views.cljs | 26 --- .../screens/wallet/collectibles/styles.cljs | 27 --- .../wallet/collectibles/superrare/views.cljs | 26 --- .../ui/screens/wallet/collectibles/views.cljs | 34 --- src/status_im/wallet/collectibles/core.cljs | 197 ------------------ src/status_im/wallet/core.cljs | 2 +- translations/en.json | 1 + 16 files changed, 42 insertions(+), 421 deletions(-) create mode 100644 resources/images/tokens/mainnet/SUPRR.png delete mode 100644 src/status_im/ui/screens/wallet/collectibles/cryptokitties/views.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/cryptostrikers/views.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/etheremon/views.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/kudos/views.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/styles.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/superrare/views.cljs delete mode 100644 src/status_im/ui/screens/wallet/collectibles/views.cljs delete mode 100644 src/status_im/wallet/collectibles/core.cljs diff --git a/resources/images/tokens/mainnet/SUPRR.png b/resources/images/tokens/mainnet/SUPRR.png new file mode 100644 index 0000000000000000000000000000000000000000..7d8faa483d0615edaf804bc6763457017cd0b103 GIT binary patch literal 1084 zcmeAS@N?(olHy`uVBq!ia0vp^0U*r53?z4+XPOVBS^|7RT!A!&KtMo1K|#U5z`()5 zAs`?iK0ZDnAt66Mzo4L?zP`Spp`pLOf5L9{`2S0-@kwV z{rmU-|Nk%lUb6w{2+@)tzhDLd1qc6t_=Nm|`iA}q^B1h&fByb^#;g>e0_Gr37srr_ zTWc=0Cb~Fsums$AuV?Ugy3}`>*XtQdG#Yjn?sxg%^gcUYYFW*l+@|`J_n*4VmLJ+w zKBXhQb@~^*^>cjFx=cA1dH5UNY0XGKa&NIxA`0DKh9)U zuCU}f>|n9;o^{y~t0fa`ckcQBd#<=5AMd@rM)995{?#q=-hkj@$b8zx6Zxw zFrmN2y&>>TNByJUQztJ^%h1nb-YNModL`$QgIn$`QCDtRUVp1L_V#b3rs)ef=d5kd zzQ(tEq0T8~TTY%E?NMpQK3ifE<3F19C3k`Ja-Fuk#j-!71ui!@D82IE zdFjWCU19@}BvMGIA7?(2LY=fac--PcsnWn3(Fbx;bC`yz~D-&C> zS0FmxciYDB-^5t;uB8CO~7Tqjg;lF!3o5oGWPdyH?#mSTQ znK$NHdm^)-1P7XMX9 z-Y05oZ|8n+`t;{@a{R`d4ht}b$5p5($OxWs@A-JfNUrHv@Kp&P=k@a(>?&X8D`f6d zxGaBS=>^^u+zar@|7g316-S3j3^P6token all-tokens symbol))] - (load-token 0 items-number contract address symbol)))) - -(handlers/register-handler-fx - :show-collectibles-list - (fn [{:keys [db]} [_ {:keys [symbol amount] :as collectible} address]] - (let [all-tokens (:wallet/all-tokens db) - items-number (money/to-number amount) - loaded-items-number (count (get-in db [:collectibles symbol]))] - (merge (when (not= items-number loaded-items-number) - (load-collectibles-fx all-tokens symbol items-number address)) - {:dispatch [:navigate-to :collectibles-list collectible]})))) - -;; Crypto Kitties -(def ck :CK) - -(handlers/register-handler-fx - :load-kitties - (fn [{db :db} [_ ids]] - {:db (update-in db [:collectibles] merge {ck (sorted-map-by >)}) - :http-get-n (mapv (fn [id] - {:url (str "https://api.cryptokitties.co/kitties/" id) - :on-success (fn [o] - (re-frame/dispatch [:load-collectible-success ck {id (http/parse-payload o)}])) - :on-error (fn [o] - (re-frame/dispatch [:load-collectible-failure ck {id (http/parse-payload o)}]))}) - ids)})) - -(defmethod load-collectibles-fx ck [_ _ items-number address _] - {:http-get-n (mapv (fn [offset] - {:url (str "https://api.cryptokitties.co/kitties?limit=20&offset=" - offset - "&owner_wallet_address=" - address - "&parents=false") - :on-success (fn [o] - (re-frame/dispatch [:load-kitties (map :id (:kitties (http/parse-payload o)))])) - :on-error (fn [o] - (re-frame/dispatch [:load-collectibles-failure (http/parse-payload o)])) - :timeout-ms 10000}) - (range 0 items-number 20))}) ;; Cryptokitties API limited to 20 items per request - -;; Crypto Strikers -(def strikers :STRK) - -(defmethod load-collectible-fx strikers [_ _ id] - {:http-get {:url (str "https://us-central1-cryptostrikers-prod.cloudfunctions.net/cards/" id) - :on-success (fn [o] - (re-frame/dispatch [:load-collectible-success strikers {id (http/parse-payload o)}])) - :on-error (fn [o] - (re-frame/dispatch [:load-collectible-failure strikers {id (http/parse-payload o)}]))}}) - -;;Etheremona -(def emona :EMONA) - -(defmethod load-collectible-fx emona [_ _ id] - {:http-get {:url (str "https://www.etheremon.com/api/monster/get_data?monster_ids=" id) - :on-success (fn [o] - (re-frame/dispatch [:load-collectible-success emona (:data (http/parse-payload o))])) - :on-error (fn [o] - (re-frame/dispatch [:load-collectible-failure emona {id (http/parse-payload o)}]))}}) - -;;Kudos -(def kudos :KDO) - -(defmethod load-collectible-fx kudos [{db :db} symbol id] - {:erc721-token-uri [(:wallet/all-tokens db) symbol id]}) - -(re-frame/reg-fx - :erc721-token-uri - (fn [[all-tokens symbol tokenId]] - (let [contract (:address (tokens/symbol->token all-tokens symbol))] - (erc721/token-uri contract - tokenId - #(re-frame/dispatch [:token-uri-success - tokenId - (when % - (subs % (.indexOf ^js % "http")))]))))) ;; extra chars in rinkeby - -;;Superrare -(def superrare :SUPR) - -(defmethod load-collectible-fx superrare [_ _ ids] - {:http-get-n (mapv (fn [id] - {:url id - :on-success (fn [o] - (re-frame/dispatch [:load-collectible-success superrare {id (http/parse-payload o)}])) - :on-error (fn [o] - (re-frame/dispatch [:load-collectible-failure superrare {id (http/parse-payload o)}]))}) - ids)}) - -(def graphql-url "https://api.pixura.io/graphql") - -(defn graphql-query [address] - (str "{ - collectiblesByOwner: allErc721Tokens(condition: {owner: \"" address "\"}) { - collectibles: nodes { - tokenId, - metadata: erc721MetadatumByTokenId { - metadataUri, - description, - name, - imageUri - }}}}")) - -(defmethod load-collectibles-fx superrare [_ _ _ address _] - {:http-post {:url graphql-url - :data (types/clj->json {:query (graphql-query (ethereum/naked-address address))}) - :opts {:headers {"Content-Type" "application/json"}} - :on-success (fn [{:keys [response-body]}] - (re-frame/dispatch [:store-collectibles superrare - (get-in (http/parse-payload response-body) - [:data :collectiblesByOwner :collectibles])])) - :on-error (fn [{:keys [response-body]}] - (re-frame/dispatch [:load-collectibles-failure (http/parse-payload response-body)])) - :timeout-ms 10000}}) - -(handlers/register-handler-fx - :token-uri-success - (fn [_ [_ tokenId token-uri]] - {:http-get {:url - token-uri - :on-success - (fn [o] - (re-frame/dispatch [:load-collectible-success kudos - {tokenId (update (http/parse-payload o) - :image - string/replace - #"http:" - "https:")}])) ;; http in mainnet - :on-error - (fn [o] - (re-frame/dispatch [:load-collectible-failure kudos {tokenId (http/parse-payload o)}]))}})) - -(handlers/register-handler-fx - :load-collectible - (fn [cofx [_ symbol token-id]] - (load-collectible-fx cofx symbol token-id))) - -(handlers/register-handler-fx - :store-collectibles - (fn [{db :db} [_ symbol collectibles]] - {:db (update-in db [:collectibles symbol] merge - (reduce #(assoc %1 (:tokenId %2) %2) {} collectibles))})) - -(handlers/register-handler-fx - :load-collectible-success - (fn [{db :db} [_ symbol collectibles]] - {:db (update-in db [:collectibles symbol] merge collectibles)})) - -(handlers/register-handler-fx - :load-collectibles-failure - (fn [{db :db} [_ reason]] - {:db (update-in db [:collectibles symbol :errors] merge reason)})) - -(handlers/register-handler-fx - :load-collectible-failure - (fn [{db :db} [_]] - {:db db})) - -(handlers/register-handler-fx - :open-collectible-in-browser - (fn [cofx [_ url]] - (browser/open-url cofx url))) diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 332f8577c5..ff5b08b9fd 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -88,7 +88,7 @@ (defn- validate-token-symbol! [{:keys [address symbol]}] - (when-not (= symbol :DCN) ;; ignore this symbol because it has weird symbol + (when-not (or (= symbol :DCN) (= symbol :SUPRR)) ;; ignore this symbol because it has weird symbol (json-rpc/eth-call {:contract address :method "symbol()" diff --git a/translations/en.json b/translations/en.json index ab929eacd2..d616329dc7 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1203,6 +1203,7 @@ "cant-report-bug": "Can't report a bug", "mail-should-be-configured": "Mail client should be configured", "check-on-etherscan": "Check on etherscan", + "check-on-opensea": "Check on opensea", "transactions-load-more": "Load more", "private-key": "Private key", "generate-an-account": "Generate an account",