Add vote transaction

parent 6f2fe011
Pipeline #31246667 passed with stages
in 4 minutes and 50 seconds
......@@ -182,18 +182,20 @@
{:on-click #(reset! account-atom account)}
(::a/label account)]))]])
(defn amount-field [amount-atom]
(let [{:keys [:resolution :symbol]} (units/get-unit @unit)]
[:p
[:label "Amount"]
[:input {:type :number
:value (unit-encode @amount-atom)
:min 0
:step (if (= 0 resolution)
1
(apply str (concat "0." (repeat (- resolution 1) 0) "1")))
:on-change #(reset! amount-atom (-> % .-target .-value (unit-decode)))}]
" " symbol]))
(defn amount-field
([amount-atom] (amount-field amount-atom "Amount"))
([amount-atom label]
(let [{:keys [:resolution :symbol]} (units/get-unit @unit)]
[:p
[:label label]
[:input {:type :number
:value (unit-encode @amount-atom)
:min 0
:step (if (= 0 resolution)
1
(apply str (concat "0." (repeat (- resolution 1) 0) "1")))
:on-change #(reset! amount-atom (-> % .-target .-value (unit-decode)))}]
" " symbol])))
(defn auto-valid-since [valid-since-atom]
(go
......@@ -294,6 +296,33 @@
:value "Generate"}]]
[generated-tx tx]])))
(defn vote-tx-form []
(let [validator (r/atom nil)
valid-since (r/atom nil)
per-tx (r/atom nil)
per-256b (r/atom nil)
per-account-day (r/atom nil)
protocol (r/atom 1)
tx (r/atom nil)]
(fn []
[:div
[account-select "Validator" validator]
[amount-field per-tx "Fee per tx"]
[amount-field per-256b "Fee per 256 bytes"]
[amount-field per-account-day "Fee per account/day"]
[:p
[:label "Protocol"]
[:input {:type :number
:value @protocol
:readonly true}]]
[valid-since-input valid-since]
[:p
[:input {:type :button
:on-click #(reset! tx (tx/vote-tx @valid-since @validator @per-tx @per-256b @per-account-day @protocol))
:value "Generate"}]]
[generated-tx tx]
])))
(defn genesis-tx-form []
(let [from (r/atom nil)
locked (r/atom false)
......@@ -334,6 +363,7 @@
types (array-map :transfer transfer-tx-form
:account account-tx-form
:lock lock-tx-form
:vote vote-tx-form
:genesis genesis-tx-form)]
(fn []
[:div
......
......@@ -43,6 +43,17 @@
(::a/address validator))]
(sign to-sign account)))
(defn vote-tx [valid-since validator per-tx per-256b per-account-day protocol]
(-> (concat
[3]
(uint/uint->vec valid-since 4)
(::a/address validator)
(uint/uint->vec per-tx 8)
(uint/uint->vec per-256b 8)
(uint/uint->vec per-account-day 8)
[protocol])
(sign validator)))
(defn genesis-tx [from locked-until validator]
(let [locked-until-vec (drop-while #(= 0 %) (uint/uint->vec (or locked-until 0) 3))
to-sign (concat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment