|
41 | 41 | [:wallet-connect/process-eth-send-transaction
|
42 | 42 | {:on-success (fn [] (rf/dispatch [:wallet-connect/show-request-modal]))}]]
|
43 | 43 |
|
44 |
| - constants/wallet-connect-eth-sign-method |
45 |
| - [:dispatch [:wallet-connect/process-eth-sign]] |
46 |
| - |
47 |
| - constants/wallet-connect-eth-sign-transaction-method |
48 |
| - [:dispatch [:wallet-connect/process-eth-sign-transaction]] |
49 |
| - |
50 | 44 | constants/wallet-connect-eth-sign-typed-method
|
51 | 45 | [:dispatch [:wallet-connect/process-sign-typed]]
|
52 | 46 |
|
|
57 | 51 | [:dispatch [:wallet-connect/process-personal-sign]])]}))))
|
58 | 52 |
|
59 | 53 | (rf/reg-event-fx
|
60 |
| - :wallet-connect/process-personal-sign |
61 |
| - (fn [{:keys [db]}] |
62 |
| - (let [[raw-data address] (data-store/get-db-current-request-params db) |
63 |
| - parsed-data (native-module/hex-to-utf8 raw-data)] |
64 |
| - {:db (update-in db |
65 |
| - [:wallet-connect/current-request] |
66 |
| - assoc |
67 |
| - :address (string/lower-case address) |
68 |
| - :raw-data raw-data |
69 |
| - :display-data (or parsed-data raw-data)) |
70 |
| - :fx [[:dispatch [:wallet-connect/show-request-modal]]]}))) |
| 54 | + :wallet-connect/store-prepared-hash |
| 55 | + (fn [{:keys [db]} [prepared-hash]] |
| 56 | + {:db (assoc-in db |
| 57 | + [:wallet-connect/current-request :prepared-hash] |
| 58 | + prepared-hash)})) |
71 | 59 |
|
72 | 60 | (rf/reg-event-fx
|
73 |
| - :wallet-connect/process-eth-sign |
| 61 | + :wallet-connect/process-personal-sign |
74 | 62 | (fn [{:keys [db]}]
|
75 |
| - (let [[address raw-data] (data-store/get-db-current-request-params db) |
| 63 | + (let [[raw-data address] (data-store/get-db-current-request-params db) |
76 | 64 | parsed-data (native-module/hex-to-utf8 raw-data)]
|
77 | 65 | {:db (update-in db
|
78 | 66 | [:wallet-connect/current-request]
|
79 | 67 | assoc
|
80 | 68 | :address (string/lower-case address)
|
81 |
| - :raw-data raw-data |
82 | 69 | :display-data (or parsed-data raw-data))
|
83 |
| - :fx [[:dispatch [:wallet-connect/show-request-modal]]]}))) |
| 70 | + :fx [[:effects.wallet-connect/hash-message |
| 71 | + {:message raw-data |
| 72 | + :on-success #(rf/dispatch [:wallet-connect/store-prepared-hash %]) |
| 73 | + :on-fail #(rf/dispatch [:wallet-connect/on-processing-error %])}] |
| 74 | + [:dispatch [:wallet-connect/show-request-modal]]]}))) |
84 | 75 |
|
85 | 76 | (rf/reg-event-fx
|
86 | 77 | :wallet-connect/prepare-transaction-success
|
87 | 78 | (fn [{:keys [db]} [prepared-tx chain-id]]
|
88 |
| - (let [{:keys [tx-args]} prepared-tx |
89 |
| - tx (bean/->clj tx-args) |
90 |
| - address (-> tx :from string/lower-case) |
91 |
| - display-data (transactions/beautify-transaction tx)] |
| 79 | + (let [{:keys [tx-args tx-hash]} prepared-tx |
| 80 | + tx (bean/->clj tx-args) |
| 81 | + address (-> tx :from string/lower-case) |
| 82 | + display-data (transactions/beautify-transaction tx)] |
92 | 83 | {:db (update-in db
|
93 | 84 | [:wallet-connect/current-request]
|
94 | 85 | assoc
|
95 | 86 | :address address
|
96 | 87 | :raw-data prepared-tx
|
97 | 88 | :transaction tx
|
98 | 89 | :chain-id chain-id
|
99 |
| - :display-data display-data)}))) |
| 90 | + :display-data display-data) |
| 91 | + :fx [[:dispatch [:wallet-connect/store-prepared-hash tx-hash]]]}))) |
100 | 92 |
|
101 | 93 | (rf/reg-event-fx
|
102 | 94 | :wallet-connect/process-eth-send-transaction
|
|
116 | 108 | (rf/call-continuation on-success)))
|
117 | 109 | :on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]}))))
|
118 | 110 |
|
119 |
| -(rf/reg-event-fx |
120 |
| - :wallet-connect/process-eth-sign-transaction |
121 |
| - (fn [{:keys [db]}] |
122 |
| - (let [event (data-store/get-db-current-request-event db) |
123 |
| - tx (-> event data-store/get-request-params first) |
124 |
| - chain-id (-> event |
125 |
| - (get-in [:params :chainId]) |
126 |
| - networks/eip155->chain-id)] |
127 |
| - {:fx [[:effects.wallet-connect/prepare-transaction |
128 |
| - {:tx tx |
129 |
| - :chain-id chain-id |
130 |
| - :on-success #(rf/dispatch [:wallet-connect/prepare-transaction-success % chain-id]) |
131 |
| - :on-error #(rf/dispatch [:wallet-connect/on-processing-error %])}]]}))) |
132 |
| - |
133 | 111 | (rf/reg-event-fx
|
134 | 112 | :wallet-connect/process-sign-typed
|
135 | 113 | (fn [{:keys [db]}]
|
136 | 114 | (try
|
137 | 115 | (let [[address raw-data] (data-store/get-db-current-request-params db)
|
| 116 | + method (-> db |
| 117 | + data-store/get-db-current-request-event |
| 118 | + data-store/get-request-method) |
138 | 119 | session-chain-id (-> (data-store/get-db-current-request-event db)
|
139 | 120 | (get-in [:params :chainId])
|
140 | 121 | networks/eip155->chain-id)
|
|
154 | 135 | :address (string/lower-case address)
|
155 | 136 | :display-data (typed-data/flatten-typed-data typed-data)
|
156 | 137 | :raw-data raw-data)
|
157 |
| - :fx [[:dispatch [:wallet-connect/show-request-modal]]]})) |
| 138 | + :fx [[:effects.wallet-connect/hash-typed-data |
| 139 | + {:message raw-data |
| 140 | + :legacy? (not= constants/wallet-connect-eth-sign-typed-v4-method |
| 141 | + method) |
| 142 | + :on-success #(rf/dispatch [:wallet-connect/store-prepared-hash %]) |
| 143 | + :on-fail #(rf/dispatch [:wallet-connect/on-processing-error %])}] |
| 144 | + [:dispatch [:wallet-connect/show-request-modal]]]})) |
158 | 145 | (catch js/Error err
|
159 | 146 | {:fx [[:dispatch
|
160 | 147 | [:wallet-connect/on-processing-error
|
|
0 commit comments