From ae554ab4cb4695707c6f2dd7b65e2d89ccb53385 Mon Sep 17 00:00:00 2001 From: mosshqq <145656181+mosshqq@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:43:41 +0800 Subject: [PATCH] Fix/tx status db (#1494) * feat: update db * feat: version --- .yarn/versions/2d40fc80.yml | 6 ++++++ packages/db/src/main/cfxjs/db/queries.cljs | 7 +++++++ packages/spec/src/main/cfxjs/spec/core.cljs | 10 +++++----- 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 .yarn/versions/2d40fc80.yml diff --git a/.yarn/versions/2d40fc80.yml b/.yarn/versions/2d40fc80.yml new file mode 100644 index 000000000..cac7b1d7b --- /dev/null +++ b/.yarn/versions/2d40fc80.yml @@ -0,0 +1,6 @@ +releases: + "@fluent-wallet/db": patch + "@fluent-wallet/spec": patch + +declined: + - helios diff --git a/packages/db/src/main/cfxjs/db/queries.cljs b/packages/db/src/main/cfxjs/db/queries.cljs index 2e3095a1b..e0d296cf0 100644 --- a/packages/db/src/main/cfxjs/db/queries.cljs +++ b/packages/db/src/main/cfxjs/db/queries.cljs @@ -1614,6 +1614,12 @@ {:db/id [:tx/hash hash] :tx/status 2 :tx/pendingAt (or pending-at (.now js/Date))}])))) +(defn force-set-tx-status [{:keys [hash status error]}] + (let [txs [{:db/id [:tx/hash hash] :tx/status status}]] + (if error + (concat txs {:db/id [:tx/hash hash] :tx/err error}) + (concat txs [:db.fn/retractAttribute [:tx/hash hash] :tx/err])) + (t txs))) (defn set-tx-packaged [{:keys [hash blockHash]}] (when-not (tx-end-state? hash) (t [[:db.fn/retractAttribute [:tx/hash hash] :tx/skippedChecked] @@ -2308,6 +2314,7 @@ :setTxConfirmed set-tx-confirmed :setTxChainSwitched set-tx-chain-switched :setTxUnsent set-tx-unsent + :forceSetTxStatus force-set-tx-status :getTxsToEnrich get-txs-to-enrich :cleanupTx cleanup-tx :findApp get-apps diff --git a/packages/spec/src/main/cfxjs/spec/core.cljs b/packages/spec/src/main/cfxjs/spec/core.cljs index 365623dbb..b976b042e 100644 --- a/packages/spec/src/main/cfxjs/spec/core.cljs +++ b/packages/spec/src/main/cfxjs/spec/core.cljs @@ -406,17 +406,17 @@ (def export-block-tag (update-properties - [:enum "latest" "earliest" "pending" nil] + [:enum "latest" "earliest" "pending" "safe" "finalized" nil] :type :epoch-tag - :error/message "invalid block tag, must be one of latest pending or earliest" - :doc "one of latest pending or earliest, default to latest")) + :error/message "invalid block tag, must be one of latest pending earliest safe or finalized" + :doc "one of latest pending earliest safe or finalized, default to latest")) (def export-block-ref (update-properties [:or export-block-tag Uint] :type :epoch-ref - :error/message "invalid block ref, must be one of latest, pending, earliest, block number or null" - :doc "one of latest, pending, earliest, block number or null")) + :error/message "invalid block ref, must be one of latest, pending, earliest, safe, finalized, block number or null" + :doc "one of latest, pending, earliest, safe, finalized, block number or null")) (def export-address-type (update-properties