|
7 | 7 | [status-im.contexts.wallet.sheets.network-selection.view :as network-selection]
|
8 | 8 | [taoensso.timbre :as log]
|
9 | 9 | [utils.address :as address]
|
| 10 | + [utils.i18n :as i18n] |
10 | 11 | [utils.number]))
|
11 | 12 |
|
12 | 13 | (rf/reg-event-fx :wallet.swap/start
|
|
243 | 244 | :always (assoc-in [:wallet :ui :swap :transaction-ids] transaction-ids)
|
244 | 245 | approval-transaction? (assoc-in [:wallet :ui :swap :approval-transaction-id]
|
245 | 246 | (first transaction-ids)))})))
|
| 247 | + |
| 248 | +(rf/reg-event-fx :wallet.swap/approve-transaction-update |
| 249 | + (fn [{:keys [db]} [status]] |
| 250 | + (let [{:keys [amount asset-to-pay swap-proposal]} (get-in db [:wallet :ui :swap]) |
| 251 | + provider-name (:bridge-name swap-proposal) |
| 252 | + token-symbol (:symbol asset-to-pay) |
| 253 | + current-viewing-account-address (get-in db |
| 254 | + [:wallet :current-viewing-account-address]) |
| 255 | + account-name (get-in db |
| 256 | + [:wallet :accounts |
| 257 | + current-viewing-account-address :name]) |
| 258 | + transaction-confirmed-or-failed? (#{:confirmed :failed} status) |
| 259 | + transaction-confirmed? (= status :confirmed)] |
| 260 | + (when transaction-confirmed-or-failed? |
| 261 | + (cond-> {:fx |
| 262 | + [[:dispatch |
| 263 | + [:toasts/upsert |
| 264 | + {:id :approve-transaction-update |
| 265 | + :type (if transaction-confirmed? :positive :negative) |
| 266 | + :text (if transaction-confirmed? |
| 267 | + (i18n/label :t/spending-cap-set |
| 268 | + {:amount amount |
| 269 | + :token-symbol token-symbol |
| 270 | + :provider-name provider-name |
| 271 | + :account-name account-name}) |
| 272 | + (i18n/label :t/spending-cap-failed |
| 273 | + {:amount amount |
| 274 | + :token-symbol token-symbol |
| 275 | + :provider-name provider-name |
| 276 | + :account-name account-name}))}]]]} |
| 277 | + (not transaction-confirmed?) |
| 278 | + (assoc :db (update-in db [:wallet :ui :swap] dissoc :approval-transaction-id))))))) |
0 commit comments