fix #9903 hide buttons of actions that are not yet implemented

fix ens release button which showed a hardcoded date
link to release instructions on hackmd

Signed-off-by: yenda <eric@status.im>
This commit is contained in:
yenda 2020-01-27 16:34:06 +01:00
parent b41df2f2fc
commit cc3ae6c693
No known key found for this signature in database
GPG Key ID: 0095623C0069DCE6
15 changed files with 109 additions and 54 deletions

View File

@ -3,6 +3,7 @@
[re-frame.core :as re-frame]
[status-im.ens.db :as ens.db]
[taoensso.timbre :as log]
[status-im.utils.datetime :as datetime]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.ethereum.abi-spec :as abi-spec]
@ -42,6 +43,11 @@
(fn [[registry name cb]]
(resolver/pubkey registry name cb)))
(re-frame/reg-fx
::get-expiration-time
(fn [[registrar label-hash cb]]
(stateofus/get-expiration-time registrar label-hash cb)))
(fx/defn set-state
{:events [::name-resolved]}
[{:keys [db]} username state]
@ -249,15 +255,33 @@
[{:keys [db]} username public-key]
{:db (assoc-in db [:ens/names username :public-key] public-key)})
(fx/defn store-expiration-date
{:events [::get-expiration-time-success]}
[{:keys [now db]} username timestamp]
{:db (-> db
(assoc-in [:ens/names username :expiration-date]
(datetime/timestamp->year-month-day-date timestamp))
(assoc-in [:ens/names username :releasable?] (<= timestamp now)))})
(fx/defn navigate-to-name
{:events [::navigate-to-name]}
[{:keys [db] :as cofx} username]
(let [registry (get ens/ens-registries (ethereum/chain-keyword db))]
(let [chain (ethereum/chain-keyword db)
registry (get ens/ens-registries chain)
registrar (get stateofus/registrars chain)]
(fx/merge cofx
{::resolve-address [registry username
#(re-frame/dispatch [::address-resolved username %])]
::resolve-pubkey [registry username
#(re-frame/dispatch [::public-key-resolved username %])]}
{::get-expiration-time
[registrar
(-> username
stateofus/username
ethereum/sha3)
#(re-frame/dispatch [::get-expiration-time-success username %])]
::resolve-address
[registry username
#(re-frame/dispatch [::address-resolved username %])]
::resolve-pubkey
[registry username
#(re-frame/dispatch [::public-key-resolved username %])]}
(navigation/navigate-to-cofx :ens-name-details username))))
(fx/defn start-registration

View File

@ -1,5 +1,6 @@
(ns status-im.ethereum.stateofus
(:require [clojure.string :as string]))
(:require [clojure.string :as string]
[status-im.ethereum.json-rpc :as json-rpc]))
(def domain "stateofus.eth")
@ -24,3 +25,15 @@
(boolean
(and (lower-case? username)
(re-find #"^[a-z0-9]+$" username))))
(defn get-expiration-time
[registrar label-hash cb]
(json-rpc/eth-call
{:contract registrar
:method "getExpirationTime(bytes32)"
:params [label-hash]
:outputs ["uint256"]
:on-success
(fn [[release-time]]
;;NOTE: returns a timestamp in s and we want ms
(cb (* release-time 1000)))}))

View File

@ -2007,7 +2007,7 @@
:<- [:get-screen-params :ens-name-details]
:<- [:ens/names]
(fn [[name ens]]
(let [{:keys [address public-key]} (get ens name)
(let [{:keys [address public-key expiration-date releasable?]} (get ens name)
pending? (nil? address)]
(cond-> {:name name
:custom-domain? (not (string/ends-with? name ".stateofus.eth"))}
@ -2015,7 +2015,9 @@
(assoc :pending? true)
(not pending?)
(assoc :address address
:public-key public-key)))))
:public-key public-key
:releasable? releasable?
:expiration-date expiration-date)))))
(re-frame/reg-sub
:ens.main/screen

View File

@ -476,8 +476,14 @@
;;; NAME DETAILS SCREEN
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:const release-instructions-link "https://our.status.im/managing-your-ens-name-in-v1/")
(defn open-release-instructions-link! []
(.openURL react/linking release-instructions-link))
(views/defview name-details []
(views/letsubs [{:keys [name address custom-domain? public-key pending?]}
(views/letsubs [{:keys [name address custom-domain? public-key
expiration-date releasable? pending?]}
[:ens.name/screen]]
[react/view {:style {:flex 1}}
[topbar/topbar {:title name}]
@ -502,23 +508,32 @@
[section {:title (i18n/label :t/key)
:content public-key}]])
[react/view {:style {:margin-top 16 :margin-bottom 32}}
[list/big-list-item {:text (i18n/label :t/ens-remove-username)
:subtext (i18n/label :t/ens-remove-hints)
:text-color colors/gray
:text-style {:font-weight "500"}
:icon :main-icons/close
:icon-color colors/gray
:hide-chevron? true}]
;;TODO: re-enable once feature is developped
#_[list/big-list-item {:text (i18n/label :t/ens-remove-username)
:subtext (i18n/label :t/ens-remove-hints)
:text-color colors/gray
:text-style {:font-weight "500"}
:icon :main-icons/close
:icon-color colors/gray
:hide-chevron? true}]
(when-not custom-domain?
[react/view {:style {:margin-top 18}}
[list/big-list-item {:text (i18n/label :t/ens-release-username)
:text-color colors/gray
:text-color (if releasable?
colors/blue
colors/gray)
:text-style {:font-weight "500"}
:subtext (i18n/label :t/ens-locked)
:subtext (when (and expiration-date
(not releasable?))
(i18n/label :t/ens-locked
{:date expiration-date}))
:icon :main-icons/delete
:icon-color colors/gray
:active? false
:hide-chevron? true}]])]]]]))
:icon-color (if releasable?
colors/blue
colors/gray)
:active? releasable?
:hide-chevron? true
:action-fn #(open-release-instructions-link!)}]])]]]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; WELCOME SCREEN

View File

@ -33,24 +33,25 @@
:icon :main-icons/add
:accessories [:chevron]
:on-press #(re-frame/dispatch [:wallet.accounts/start-adding-new-account {:type :generate}])}]
[list-item/list-item
{:type :section-header
:container-margin-top 24
:title (i18n/label :t/advanced)}]
[list-item/list-item
{:title (i18n/label :t/enter-a-seed-phrase)
:theme :action
:icon :main-icons/add
:accessories [:chevron]
:disabled? true
:on-press #(re-frame/dispatch [:wallet.accounts/start-adding-new-account {:type :seed}])}]
[list-item/list-item
{:title (i18n/label :t/enter-a-private-key)
:theme :action
:icon :main-icons/add
:accessories [:chevron]
:disabled? true
:on-press #(re-frame/dispatch [:wallet.accounts/start-adding-new-account {:type :key}])}]]])
;;TODO: implement adding account by seedphrase and private key
#_[list-item/list-item
{:type :section-header
:container-margin-top 24
:title (i18n/label :t/advanced)}]
#_[list-item/list-item
{:title (i18n/label :t/enter-a-seed-phrase)
:theme :action
:icon :main-icons/add
:accessories [:chevron]
:disabled? true
:on-press #(re-frame/dispatch [:wallet.accounts/start-adding-new-account {:type :seed}])}]
#_[list-item/list-item
{:title (i18n/label :t/enter-a-private-key)
:theme :action
:icon :main-icons/add
:accessories [:chevron]
:disabled? true
:on-press #(re-frame/dispatch [:wallet.accounts/start-adding-new-account {:type :key}])}]]])
(def input-container
{:flex-direction :row

View File

@ -404,7 +404,7 @@
"ens-displayed-with": "يتم عرض الرسائل الخاصة بك للآخرين مع",
"ens-get-name": "الحصول علي اسم مستخدم عالمي",
"ens-got-it": "حسنا، تابع",
"ens-locked": "اسم المستخدم مقفل. لن تكون قادرا علي اصداره حتى 25.05.2020",
"ens-locked": "{{date}} اسم المستخدم مقفل. لن تكون قادرا علي اصداره حتى",
"ens-name-content": "اسم مستعار مخصص لمفتاح الدردشة الذي يمكنك تسجيله باستخدام خدمة Ethereum Name Service. أسماء ENS هي أسماء مستخدمين لا مركزية.",
"ens-name-title": "اسم ENS",
"ens-network-restriction": "متوفر فقط على Mainnet",

View File

@ -365,7 +365,7 @@
"ens-displayed-with": "Your messages are displayed to others with",
"ens-get-name": "Get a universal username",
"ens-got-it": "Ok, got it",
"ens-locked": "Username locked. You wont be able to release it until 25.05.2020",
"ens-locked": "Username locked. You wont be able to release it until {{date}}",
"ens-network-restriction": "Only available on Mainnet",
"ens-no-usernames": "You don't have any username connected",
"ens-powered-by": "Powered by Ethereum Name Services",

View File

@ -367,7 +367,7 @@
"ens-displayed-with": "Vos messages sont affichés aux autres avec",
"ens-get-name": "Obtenir un nom d'utilisateur universel",
"ens-got-it": "Ok, j'ai compris",
"ens-locked": "Nom d'utilisateur verrouillé. Vous ne pourrez pas le déverrouiller avant le 25.05.2020",
"ens-locked": "Nom d'utilisateur verrouillé. Vous ne pourrez pas le déverrouiller avant le {{date}}",
"ens-network-restriction": "Disponible uniquement sur Mainnet",
"ens-no-usernames": "Vous n'avez aucun nom d'utilisateur connecté",
"ens-powered-by": "Propulsé par Ethereum Name Services",
@ -1129,4 +1129,4 @@
"your-data-belongs-to-you-description": "Status ne peut pas vous aider à récupérer votre multi-compte si vous perdez votre phrase de récupération. Vous êtes responsable de la sécurité de vos données. La sauvegarde de votre phrase de récupération constitue la meilleure protection.",
"your-recovery-phrase": "Votre phrase de récupération",
"your-recovery-phrase-description": "Ceci est votre phrase de récupération. Vous l'utilisez pour prouver qu'il s'agit de votre portefeuille. Vous ne le voyez qu'une fois! Ecrivez-le sur du papier et conservez-le dans un endroit sûr. Vous en aurez besoin si vous perdez ou réinstallez votre portefeuille."
}
}

View File

@ -379,7 +379,7 @@
"ens-displayed-with": "I tuoi messaggi vengono visualizzati agli altri con",
"ens-get-name": "Ottieni un nome utente universale",
"ens-got-it": "Ok capito",
"ens-locked": "Nome utente bloccato. Non sarà possibile rilasciarlo fino al 25.05.2020",
"ens-locked": "Nome utente bloccato. Non sarà possibile rilasciarlo fino al {{date}}",
"ens-name-content": "Alias personalizzato per la tua chiave di chat che puoi registrare usando Ethereum Name Service. I nomi ENS sono nomi utente decentralizzati.",
"ens-name-title": "Nome ENS",
"ens-network-restriction": "Disponibile solo su Mainnet",
@ -1169,4 +1169,4 @@
"your-data-belongs-to-you-description": "Status non può aiutarti a recuperare il tuo Multi-Account se perdi la frase di recupero. Sei responsabile della sicurezza dei tuoi dati e il backup della tua frase di recupero è la migliore salvaguardia.",
"your-recovery-phrase": "La tua frase di recupero",
"your-recovery-phrase-description": "Questa è la tua frase di recupero. La usi per dimostrare che questo è il tuo portafoglio. Puoi vederlo solo una volta! Scrivilo su carta e conservalo in un luogo sicuro. Ne avrai bisogno se perdi o reinstalli il tuo portafoglio."
}
}

View File

@ -339,7 +339,7 @@
"ens-displayed-with": "あなたのメッセージは他の人に表示されます",
"ens-get-name": "ユニバーサルユーザー名を取得",
"ens-got-it": "わかりました",
"ens-locked": "ユーザー名がロックされています。あなたは25.05.2020まで手放すことはできません",
"ens-locked": "ユーザー名がロックされています。あなたは{{date}}まで手放すことはできません",
"ens-network-restriction": "Mainnetまたはropstenでのみ利用可能",
"ens-no-usernames": "接続しているユーザー名がありません",
"ens-powered-by": "Ethereum Name Servicesを利用しています",

View File

@ -372,7 +372,7 @@
"ens-displayed-with": "귀하의 메시지가 다른 사용자에게 다음과 같이 표시됩니다",
"ens-get-name": "사용자 이름 등록",
"ens-got-it": "알겠습니다",
"ens-locked": "사용자 이름이 등록되었습니다. 2020.05.25까지 해지 할 수 없습니다.",
"ens-locked": "사용자 이름이 등록되었습니다. {{date}}까지 해지 할 수 없습니다.",
"ens-name-content": "이더리움 네임 서비스(Ethereum Name Service)로 채팅키와 연결되는 커스텀 닉네임. ENS 이름은 탈중앙화된 사용자 명입니다.",
"ens-name-title": "ENS 이름",
"ens-network-restriction": "Mainnet에서만 사용 가능",
@ -1158,4 +1158,4 @@
"your-data-belongs-to-you-description": "스테이터스는 사용자가 시드 구문을 잃어버릴 경우, 계정을 복구하는 것을 도와드릴 수 없습니다. 데이터 보안을 위해 시드 구문을 반드시 따로 백업해 두시는 것을 권장합니다.",
"your-recovery-phrase": "시드 구문",
"your-recovery-phrase-description": "위 12단어가 사용자의 시드 구문입니다. 이 구문은 사용자의 지갑을 증명하기 위해 반드시 필요하며, 이번 한번만 확인할 수 있습니다. 지갑을 분실하거나 재설치하는 경우 반드시 필요하므로 안전한 장소에 보관하세요."
}
}

View File

@ -382,7 +382,7 @@
"ens-displayed-with": "Ваши сообщения остальным пользователям показываются с ",
"ens-get-name": "Получить универсальное имя пользователя",
"ens-got-it": "Ок, понятно",
"ens-locked": "Имя пользователя зарезервировано. Вы не сможете освободить его до 25.05.2020",
"ens-locked": "Имя пользователя зарезервировано. Вы не сможете освободить его до {{date}} ",
"ens-network-restriction": "Доступно только на Mainnet или Ropsten",
"ens-no-usernames": "Нет присоединенного имени пользователя",
"ens-powered-by": "При поддержке Ethereum Name Services",
@ -1147,4 +1147,4 @@
"your-data-belongs-to-you-description": "Status не сможет помочь восстановить ваш мультиаккаунт, если вы потеряете фразу восстановления. Вы отвечаете за безопасность своих данных и резервная копия фразы восстановления - лучшая защита.",
"your-recovery-phrase": "Ваша фраза восстановления",
"your-recovery-phrase-description": "Это ваша фраза восстановления. Используйте её, чтобы доказать, что это ваш кошелёк. Вы увидите её только один раз. Запишите все слова на бумаге и держите в надежном месте. Они вам понадобятся, если вы потеряете или переустановите свой кошелёк."
}
}

View File

@ -373,7 +373,7 @@
"ens-displayed-with": "您的消息会显示给其他人",
"ens-get-name": "获取用户名",
"ens-got-it": "好的, 知道了",
"ens-locked": "用户名已锁定。您将无法在25.05.2020之前释放它",
"ens-locked": "用户名已锁定。您将无法在{{date}}之前释放它",
"ens-name-content": "您可以为您的聊天码使用以太坊名称服务ENS注册的自定义昵称。 ENS名称是去中心化的用户名。",
"ens-name-title": "ENS名称",
"ens-network-restriction": "仅适用于主网",
@ -1160,4 +1160,4 @@
"your-data-belongs-to-you-description": "如果您丢失了助记词Status无法帮助您恢复多帐户。您需对数据的安全性负责备份助记词是最佳保障。",
"your-recovery-phrase": "您的助记词",
"your-recovery-phrase-description": "这是您的助记词。您需要用它来证明这个钱包属于您。您只能查看一次!请将其写在纸上并保存在安全的地方。如果丢失或重新安装钱包,您将需要用到这些助记词。"
}
}

View File

@ -349,7 +349,7 @@
"ens-displayed-with": "您的消息会显示给其他人",
"ens-get-name": "获取通用用户名",
"ens-got-it": "好的, 明白了",
"ens-locked": "用户名已锁定。您将无法在25.05.2020之前释放它",
"ens-locked": "用户名已锁定。您将无法在{{date}}之前释放它",
"ens-network-restriction": "仅适用于主网或ropsten",
"ens-no-usernames": "您没有关联任何用户名",
"ens-powered-by": "由以太坊名称服务提供支持",

View File

@ -323,7 +323,7 @@
"ens-displayed-with": "您的消息会显示给其他人",
"ens-get-name": "获取通用用户名",
"ens-got-it": "好的, 明白了",
"ens-locked": "用户名已锁定。您将无法在25.05.2020之前释放它",
"ens-locked": "用户名已锁定。您将无法在{{date}}之前释放它",
"ens-network-restriction": "仅适用于主网或ropsten",
"ens-no-usernames": "您没有关联任何用户名",
"ens-powered-by": "由以太坊名称服务提供支持",