From 673c73855dac54c8e7d4e0724a5ea31e7f57b06c Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 6 Apr 2022 11:39:48 +0800 Subject: [PATCH] add simulate method --- src/libs/fetch.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/libs/fetch.js b/src/libs/fetch.js index 410f5ad7..445eef49 100644 --- a/src/libs/fetch.js +++ b/src/libs/fetch.js @@ -389,16 +389,12 @@ export default class ChainFetch { } // Simulate Execution of tx - async simulate(tx, config = null) { - return this.post('/cosmos/tx/v1beta1/simulate', tx, config).then(res => { - if (res.code && res.code !== 0) { - throw new Error(res.message) - } - if (res.tx_response && res.tx_response.code !== 0) { - throw new Error(res.tx_response.raw_log) - } - return res - }) + async simulate(bodyBytes, config = null) { + const txString = toBase64(TxRaw.encode(bodyBytes).finish()) + const txRaw = { + tx_bytes: txString, + } + return this.post('/cosmos/tx/v1beta1/simulate', txRaw, config) } // Tx Submit