From c9a8fb26845c8d26802819e0afd09c60341979de Mon Sep 17 00:00:00 2001 From: yenda Date: Wed, 3 Apr 2019 15:57:09 +0200 Subject: [PATCH] [fix] contract call effect should destructure keys not vector - return params decoding should return nil and not "0x" Signed-off-by: yenda --- src/status_im/utils/ethereum/abi_spec.cljs | 3 ++- src/status_im/utils/ethereum/contracts.cljs | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/status_im/utils/ethereum/abi_spec.cljs b/src/status_im/utils/ethereum/abi_spec.cljs index f9854a43db..64bf5f13c7 100644 --- a/src/status_im/utils/ethereum/abi_spec.cljs +++ b/src/status_im/utils/ethereum/abi_spec.cljs @@ -390,4 +390,5 @@ (let [bytes (subs bytes 2)] (when-not (empty? bytes) (let [offsets (get-offsets types)] - (map (dec-type bytes) offsets types)))))) + (map #(when-not (= "0x" %) %) + (map (dec-type bytes) offsets types))))))) diff --git a/src/status_im/utils/ethereum/contracts.cljs b/src/status_im/utils/ethereum/contracts.cljs index 67e9587d78..e4197f9e15 100644 --- a/src/status_im/utils/ethereum/contracts.cljs +++ b/src/status_im/utils/ethereum/contracts.cljs @@ -34,7 +34,7 @@ (re-frame/reg-fx ::call - (fn [[address data callback]] + (fn [{:keys [address data callback]}] (ethereum/call {:to address :data data} callback))) @@ -60,4 +60,6 @@ :on-result on-result}) {::call {:address contract-address :data data - :callback #(callback (abi-spec/decode % return-params))}}))))) + :callback #(callback (if (empty? return-params) + % + (abi-spec/decode % return-params)))}})))))