Add lock transaction

parent bea92671
Pipeline #23813036 passed with stages
in 1 minute and 52 seconds
......@@ -212,6 +212,24 @@
:value "Generate"}]]
[generated-tx tx]])))
(defn lock-tx-form []
(let [locked-until (r/atom nil)
account (r/atom nil)
tx (r/atom nil)]
(fn []
[:div
[:p
[:label "Locked until"]
[:input {:type :number
:value @locked-until
:on-change #(reset! locked-until (-> % .-target .-value js/parseInt))}]]
(account-select "Account" account)
[:p
[:input {:type :button
:on-click #(reset! tx (tx/lock-tx @locked-until @account))
:value "Generate"}]]
[generated-tx tx]])))
(defn genesis-tx-form []
(let [from (r/atom nil)
locked (r/atom false)
......@@ -246,21 +264,19 @@
(defn transaction-form []
(let [selected-type (r/atom :transfer)
types [:transfer
:account
:genesis]]
types (array-map :transfer transfer-tx-form
:account account-tx-form
:lock lock-tx-form
:genesis genesis-tx-form)]
(fn []
[:div
[:select
(for [type types]
(for [[type _] types]
^{:key type}
[:option {:value type
:on-click #(reset! selected-type type)}
type])]
(case @selected-type
:transfer [transfer-tx-form]
:account [account-tx-form]
:genesis [genesis-tx-form])
[(get types @selected-type)]
])))
(defn new-account-form []
......
......@@ -35,6 +35,13 @@
(::a/address to))]
(sign to-sign from)))
(defn lock-tx [locked-until account]
(let [to-sign (concat
[2]
(uint/uint->vec locked-until 4)
(::a/address account))]
(sign to-sign account)))
(defn genesis-tx [from locked-until]
(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