[Fixes: #10777] Always convert value to string

When calling `SendTransaction` sometimes the value would be a string
(most cases), sometimes the value would instead big a `BigInt`, which
would be serialized to an integer, and status-go would be unable to
parse it as it expects values to be a string.
This commit makes sure that values are always serialized as string
before sending them over.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2020-12-04 14:48:42 +01:00
parent 1b4dcb7103
commit 8748280279
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
1 changed files with 4 additions and 2 deletions

View File

@ -232,7 +232,9 @@
{:events [:sign/send-transaction-message]}
[cofx chat-id value contract transaction-hash signature]
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendTransaction")
:params [chat-id value contract transaction-hash
;; We make sure `value` is serialized as string, and not
;; as an integer or big-int
:params [chat-id (str value) contract transaction-hash
(or (:result (types/json->clj signature))
(ethereum/normalized-hex signature))]
:on-success
@ -512,4 +514,4 @@
(when (and from nonce)
(sign cofx {:tx-obj (-> tx
(select-keys [:from :to :value :input :gas :nonce :hash])
(clojure.set/rename-keys {:input :data}))})))
(clojure.set/rename-keys {:input :data}))})))