diff --git a/src/status_im/acquisition/gateway.cljs b/src/status_im/acquisition/gateway.cljs index f3b1aba031..76cdbf024f 100644 --- a/src/status_im/acquisition/gateway.cljs +++ b/src/status_im/acquisition/gateway.cljs @@ -39,7 +39,7 @@ network (ethereum/chain-keyword db)] {:db (assoc-in db [:acquisition :network-status] (get network-statuses :initiated)) - ::json-rpc/call [{:method (json-rpc/call-ext-method "signMessageWithChatKey") + ::json-rpc/call [{:method "wakuext_signMessageWithChatKey" :params [msg] :on-error #(re-frame/dispatch [::on-error (i18n/label :t/sign-request-failed)]) :on-success #(re-frame/dispatch [::call-acquisition-gateway diff --git a/src/status_im/backup/core.cljs b/src/status_im/backup/core.cljs index 7ad48ec1fa..29de285791 100644 --- a/src/status_im/backup/core.cljs +++ b/src/status_im/backup/core.cljs @@ -18,7 +18,7 @@ {:events [:multiaccounts.ui/perform-backup-pressed]} [{:keys [db]}] {:db (assoc db :backup/performing-backup true) - ::json-rpc/call [{:method (json-rpc/call-ext-method "backupData") + ::json-rpc/call [{:method "wakuext_backupData" :params [] :on-error #(do (log/error "failed to perfom backup" %) diff --git a/src/status_im/chat/models.cljs b/src/status_im/chat/models.cljs index f577a4e1f8..18c87eafa6 100644 --- a/src/status_im/chat/models.cljs +++ b/src/status_im/chat/models.cljs @@ -393,9 +393,9 @@ (fx/defn mute-chat {:events [::mute-chat-toggled]} [{:keys [db] :as cofx} chat-id muted?] - (let [method (if muted? "muteChat" "unmuteChat")] + (let [method (if muted? "wakuext_muteChat" "wakuext_unmuteChat")] {:db (assoc-in db [:chats chat-id :muted] muted?) - ::json-rpc/call [{:method (json-rpc/call-ext-method method) + ::json-rpc/call [{:method method :params [chat-id] :on-error #(re-frame/dispatch [::mute-chat-failed chat-id muted? %]) :on-success #(log/debug "muted chat successfully")}]})) diff --git a/src/status_im/chat/models/link_preview.cljs b/src/status_im/chat/models/link_preview.cljs index 3459aca41d..26cf90d468 100644 --- a/src/status_im/chat/models/link_preview.cljs +++ b/src/status_im/chat/models/link_preview.cljs @@ -59,7 +59,7 @@ {:events [::resolve-community-info]} [{:keys [db]} community-id] {:db (community-resolving db community-id) - ::json-rpc/call [{:method (json-rpc/call-ext-method "requestCommunityInfoFromMailserver") + ::json-rpc/call [{:method "wakuext_requestCommunityInfoFromMailserver" :params [community-id] :on-success #(re-frame/dispatch [::community-resolved community-id %]) :on-error #(do @@ -69,7 +69,7 @@ (fx/defn load-link-preview-data {:events [::load-link-preview-data]} [cofx link] - {::json-rpc/call [{:method (json-rpc/call-ext-method "getLinkPreviewData") + {::json-rpc/call [{:method "wakuext_getLinkPreviewData" :params [link] :on-success #(re-frame/dispatch [::cache-link-preview-data link %]) :on-error #(re-frame/dispatch [::cache-link-preview-data @@ -100,7 +100,7 @@ (fx/defn request-link-preview-whitelist [_] - {::json-rpc/call [{:method (json-rpc/call-ext-method "getLinkPreviewWhitelist") + {::json-rpc/call [{:method "wakuext_getLinkPreviewWhitelist" :params [] :on-success #(re-frame/dispatch [::link-preview-whitelist-received %]) :on-error #(log/error "Failed to get link preview whitelist")}]}) diff --git a/src/status_im/chat/models/loading.cljs b/src/status_im/chat/models/loading.cljs index c4179b8746..8c789eb4e8 100644 --- a/src/status_im/chat/models/loading.cljs +++ b/src/status_im/chat/models/loading.cljs @@ -46,7 +46,7 @@ (fx/defn load-chat [_ chat-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "chat") + {::json-rpc/call [{:method "wakuext_chat" :params [chat-id] :on-success #(re-frame/dispatch [:chats-list/load-chat-success %]) :on-failure #(log/error "failed to fetch chats" 0 -1 %)}]}) @@ -84,7 +84,7 @@ [{db :db} chat-id] {:clear-message-notifications [[chat-id] (get-in db [:multiaccount :remote-push-notifications-enabled?])] - ::json-rpc/call [{:method (json-rpc/call-ext-method "markAllRead") + ::json-rpc/call [{:method "wakuext_markAllRead" :params [chat-id] :on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]}) @@ -95,7 +95,7 @@ (keys (get-in db [:communities community-id :chats])))] {:clear-message-notifications [community-chat-ids (get-in db [:multiaccount :remote-push-notifications-enabled?])] - ::json-rpc/call [{:method (json-rpc/call-ext-method "markAllReadInCommunity") + ::json-rpc/call [{:method "wakuext_markAllReadInCommunity" :params [community-id] :on-success #(re-frame/dispatch [::mark-all-read-in-community-successful %])}]})) diff --git a/src/status_im/chat/models/message.cljs b/src/status_im/chat/models/message.cljs index 9fa211758b..ff84e5314a 100644 --- a/src/status_im/chat/models/message.cljs +++ b/src/status_im/chat/models/message.cljs @@ -174,7 +174,7 @@ (fx/defn resend-message [{:keys [db] :as cofx} chat-id message-id] (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method "reSendChatMessage") + {::json-rpc/call [{:method "wakuext_reSendChatMessage" :params [message-id] :on-success #(log/debug "re-sent message successfully") :on-error #(log/error "failed to re-send message" %)}]} diff --git a/src/status_im/commands/core.cljs b/src/status_im/commands/core.cljs index de6ccb5e78..2f9fae0c91 100644 --- a/src/status_im/commands/core.cljs +++ b/src/status_im/commands/core.cljs @@ -23,7 +23,7 @@ {:events [::accept-request-address-for-transaction]} [{:keys [db]} message-id address] {:db (dissoc db :commands/select-account) - ::json-rpc/call [{:method (json-rpc/call-ext-method "acceptRequestAddressForTransaction") + ::json-rpc/call [{:method "wakuext_acceptRequestAddressForTransaction" :params [message-id address] :js-response true :on-success #(re-frame/dispatch [:transport/message-sent %])}]}) @@ -31,7 +31,7 @@ (fx/defn handle-decline-request-address-for-transaction {:events [::decline-request-address-for-transaction]} [_ message-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "declineRequestAddressForTransaction") + {::json-rpc/call [{:method "wakuext_declineRequestAddressForTransaction" :params [message-id] :js-response true :on-success #(re-frame/dispatch [:transport/message-sent %])}]}) @@ -39,7 +39,7 @@ (fx/defn handle-decline-request-transaction {:events [::decline-request-transaction]} [cofx message-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "declineRequestTransaction") + {::json-rpc/call [{:method "wakuext_declineRequestTransaction" :params [message-id] :js-response true :on-success #(re-frame/dispatch [:transport/message-sent %])}]}) diff --git a/src/status_im/contact/core.cljs b/src/status_im/contact/core.cljs index c46ce7ccda..24b6f48047 100644 --- a/src/status_im/contact/core.cljs +++ b/src/status_im/contact/core.cljs @@ -70,7 +70,7 @@ {:events [::send-contact-request]} [{:keys [db] :as cofx} public-key] (let [{:keys [name profile-image]} (own-info db)] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactUpdate") + {::json-rpc/call [{:method "wakuext_sendContactUpdate" :params [public-key name profile-image] :on-success #(log/debug "contact request sent" public-key)}]})) diff --git a/src/status_im/data_store/chats.cljs b/src/status_im/data_store/chats.cljs index 465c38d8dc..de5fc3832c 100644 --- a/src/status_im/data_store/chats.cljs +++ b/src/status_im/data_store/chats.cljs @@ -103,7 +103,7 @@ unmarshal-members)) (fx/defn fetch-chats-rpc [_ {:keys [on-success]}] - {::json-rpc/call [{:method (json-rpc/call-ext-method "chatsPreview") + {::json-rpc/call [{:method "wakuext_chatsPreview" :params [] :js-response true :on-success #(on-success ^js %) diff --git a/src/status_im/data_store/contacts.cljs b/src/status_im/data_store/contacts.cljs index 9b899e2797..09a0fdf707 100644 --- a/src/status_im/data_store/contacts.cljs +++ b/src/status_im/data_store/contacts.cljs @@ -15,14 +15,14 @@ (fx/defn fetch-contacts-rpc [_ on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "contacts") + {::json-rpc/call [{:method "wakuext_contacts" :params [] :on-success #(on-success (map <-rpc %)) :on-failure #(log/error "failed to fetch contacts" %)}]}) (fx/defn add [_ public-key nickname ens-name on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "addContact") + {::json-rpc/call [{:method "wakuext_addContact" :params [{:id public-key :nickname nickname :ensName ens-name}] :js-response true :on-success #(do @@ -33,7 +33,7 @@ (fx/defn set-nickname [_ public-key nickname on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "setContactLocalNickname") + {::json-rpc/call [{:method "wakuext_setContactLocalNickname" :params [{:id public-key :nickname nickname}] :js-response true :on-success #(do @@ -43,14 +43,14 @@ :on-failure #(log/error "failed to set contact nickname " public-key nickname %)}]}) (fx/defn block [_ contact-id on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "blockContact") + {::json-rpc/call [{:method "wakuext_blockContact" :params [contact-id] :js-response true :on-success on-success :on-failure #(log/error "failed to block contact" % contact-id)}]}) (fx/defn unblock [_ contact-id on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "unblockContact") + {::json-rpc/call [{:method "wakuext_unblockContact" :params [contact-id] :on-success on-success :js-response true diff --git a/src/status_im/data_store/messages.cljs b/src/status_im/data_store/messages.cljs index 9be09ab041..65ba03006b 100644 --- a/src/status_im/data_store/messages.cljs +++ b/src/status_im/data_store/messages.cljs @@ -54,14 +54,14 @@ limit on-success on-failure] - {::json-rpc/call [{:method (json-rpc/call-ext-method "chatMessages") + {::json-rpc/call [{:method "wakuext_chatMessages" :params [chat-id cursor limit] :on-success (fn [result] (on-success (update result :messages #(map <-rpc %)))) :on-failure on-failure}]}) (defn mark-seen-rpc [chat-id ids on-success] - {::json-rpc/call [{:method (json-rpc/call-ext-method "markMessagesSeen") + {::json-rpc/call [{:method "wakuext_markMessagesSeen" :params [chat-id ids] :on-success #(do (log/debug "successfully marked as seen" %) @@ -69,19 +69,19 @@ :on-failure #(log/error "failed to get messages" %)}]}) (defn delete-message-rpc [id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessage") + {::json-rpc/call [{:method "wakuext_deleteMessage" :params [id] :on-success #(log/debug "successfully deleted message" id) :on-failure #(log/error "failed to delete message" % id)}]}) (defn delete-messages-from-rpc [author] - {::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessagesFrom") + {::json-rpc/call [{:method "wakuext_deleteMessagesFrom" :params [author] :on-success #(log/debug "successfully deleted messages from" author) :on-failure #(log/error "failed to delete messages from" % author)}]}) (defn delete-messages-by-chat-id-rpc [chat-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessagesByChatID") + {::json-rpc/call [{:method "wakuext_deleteMessagesByChatID" :params [chat-id] :on-success #(log/debug "successfully deleted messages by chat-id" chat-id) :on-failure #(log/error "failed to delete messages by chat-id" % chat-id)}]}) diff --git a/src/status_im/data_store/pin_messages.cljs b/src/status_im/data_store/pin_messages.cljs index b8443446c9..5d4e5a8ea5 100644 --- a/src/status_im/data_store/pin_messages.cljs +++ b/src/status_im/data_store/pin_messages.cljs @@ -17,7 +17,7 @@ limit on-success on-failure] - {::json-rpc/call [{:method (json-rpc/call-ext-method "chatPinnedMessages") + {::json-rpc/call [{:method "wakuext_chatPinnedMessages" :params [chat-id cursor limit] :on-success (fn [result] (let [result (clojure.set/rename-keys result {:pinnedMessages :pinned-messages})] @@ -25,7 +25,7 @@ :on-failure on-failure}]}) (fx/defn send-pin-message [cofx pin-message] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendPinMessage") + {::json-rpc/call [{:method "wakuext_sendPinMessage" :params [(messages/->rpc pin-message)] :on-success #(log/debug "successfully pinned message" pin-message) :on-failure #(log/error "failed to pin message" % pin-message)}]}) diff --git a/src/status_im/data_store/reactions.cljs b/src/status_im/data_store/reactions.cljs index d111ee33e0..561cfad7b5 100644 --- a/src/status_im/data_store/reactions.cljs +++ b/src/status_im/data_store/reactions.cljs @@ -24,7 +24,7 @@ limit on-success on-failure] - {::json-rpc/call [{:method (json-rpc/call-ext-method "emojiReactionsByChatID") + {::json-rpc/call [{:method "wakuext_emojiReactionsByChatID" :params [chat-id cursor limit] :on-success (fn [result] (on-success (map <-rpc result))) diff --git a/src/status_im/ethereum/eip165.cljs b/src/status_im/ethereum/eip165.cljs deleted file mode 100644 index 725a8edbe6..0000000000 --- a/src/status_im/ethereum/eip165.cljs +++ /dev/null @@ -1,29 +0,0 @@ -(ns status-im.ethereum.eip165 - "Utility function related to [EIP165](https://eips.ethereum.org/EIPS/eip-165)" - (:require [status-im.ethereum.abi-spec :as abi-spec] - [status-im.ethereum.json-rpc :as json-rpc])) - -(def supports-interface-hash "0x01ffc9a7") -(def marker-hash "0xffffffff") - -(defn supports-interface? - [contract hash cb] - (json-rpc/eth-call - {:contract contract - :method "supportsInterface(bytes4)" - :params [hash] - :on-success cb})) - -(defn supports? - "Calls cb with true if `supportsInterface` is supported by this contract. - See EIP for details." - [contract cb] - (supports-interface? - contract - supports-interface-hash - #(if (true? (abi-spec/hex-to-boolean %)) - (supports-interface? contract - marker-hash - (fn [response] - (cb (false? (abi-spec/hex-to-boolean response))))) - (cb false)))) diff --git a/src/status_im/ethereum/erc721.cljs b/src/status_im/ethereum/erc721.cljs deleted file mode 100644 index 9077dfffb1..0000000000 --- a/src/status_im/ethereum/erc721.cljs +++ /dev/null @@ -1,23 +0,0 @@ -(ns status-im.ethereum.erc721 - " - Helper functions to interact with [ERC721](https://eips.ethereum.org/EIPS/eip-721) smart contract - " - (:require [status-im.ethereum.json-rpc :as json-rpc])) - -(defn token-of-owner-by-index - [contract address index cb] - (json-rpc/eth-call - {:contract contract - :method "tokenOfOwnerByIndex(address,uint256)" - :params [address index] - :outputs ["uint256"] - :on-success (fn [[token]] (cb token))})) - -(defn token-uri - [contract tokenId cb] - (json-rpc/eth-call - {:contract contract - :method "tokenURI(uint256)" - :params [tokenId] - :outputs ["string"] - :on-success (fn [[uri]] (cb uri))})) diff --git a/src/status_im/ethereum/json_rpc.cljs b/src/status_im/ethereum/json_rpc.cljs index 611a7f728e..84c65131bb 100644 --- a/src/status_im/ethereum/json_rpc.cljs +++ b/src/status_im/ethereum/json_rpc.cljs @@ -2,257 +2,11 @@ (:require [clojure.string :as string] [re-frame.core :as re-frame] [status-im.ethereum.abi-spec :as abi-spec] - [status-im.ethereum.decode :as decode] [status-im.native-module.core :as status] - [status-im.utils.money :as money] [status-im.utils.types :as types] [status-im.utils.utils :as utils] [taoensso.timbre :as log])) -(def json-rpc-api - {"eth_call" {} - "eth_getBalance" - {:on-result money/bignumber} - "eth_estimateGas" - {:on-result #(money/bignumber (if (= (int %) 21000) % (int (* % 1.2))))} - "eth_gasPrice" - {:on-result money/bignumber} - "eth_getBlockByHash" - {:on-result #(-> (update % :number decode/uint) - (update :timestamp decode/uint))} - "eth_getTransactionByHash" {} - "eth_getTransactionReceipt" {} - "eth_getBlockByNumber" {} - "eth_maxPriorityFeePerGas" {} - "eth_newBlockFilter" {:subscription? true} - "eth_newFilter" {:subscription? true} - "eth_getCode" {} - "eth_syncing" {} - "eth_feeHistory" {} - "ens_publicKeyOf" {} - "ens_addressOf" {} - "ens_expireAt" {} - "ens_ownerOf" {} - "ens_contentHash" {} - "ens_resourceURL" {} - "ens_registerPrepareTx" {} - "ens_setPubKeyPrepareTx" {} - "net_version" {} - "web3_clientVersion" {} - "shh_generateSymKeyFromPassword" {} - "shh_getSymKey" {} - "shh_markTrustedPeer" {} - "waku_generateSymKeyFromPassword" {} - "waku_getSymKey" {} - "waku_markTrustedPeer" {} - "wakuext_post" {} - "wakuext_requestAllHistoricMessagesWithRetries" {} - "wakuext_toggleUseMailservers" {} - "wakuext_editMessage" {} - "wakuext_deleteMessageAndSend" {} - "wakuext_fillGaps" {} - "wakuext_syncChatFromSyncedFrom" {} - "wakuext_createPublicChat" {} - "wakuext_createOneToOneChat" {} - "wakuext_createProfileChat" {} - "wakuext_startMessenger" {} - "wakuext_sendPairInstallation" {} - "wakuext_syncDevices" {} - "wakuext_syncBookmark" {} - "wakuext_requestMessages" {} - "wakuext_sendDirectMessage" {} - "wakuext_sendPublicMessage" {} - "wakuext_enableInstallation" {} - "wakuext_disableInstallation" {} - "wakuext_sendChatMessage" {} - "wakuext_sendChatMessages" {} - "wakuext_backupData" {} - "wakuext_confirmJoiningGroup" {} - "wakuext_addAdminsToGroupChat" {} - "wakuext_addMembersToGroupChat" {} - "wakuext_removeMemberFromGroupChat" {} - "wakuext_leaveGroupChat" {} - "wakuext_changeGroupChatName" {} - "wakuext_createGroupChatWithMembers" {} - "wakuext_createGroupChatFromInvitation" {} - "wakuext_reSendChatMessage" {} - "wakuext_getOurInstallations" {} - "wakuext_setInstallationMetadata" {} - "wakuext_loadFilters" {} - "wakuext_loadFilter" {} - "wakuext_removeFilters" {} - "wakuext_sendContactUpdate" {} - "wakuext_sendContactUpdates" {} - "wakuext_chatsPreview" {} - "wakuext_activeChats" {} - "wakuext_chat" {} - "wakuext_addSystemMessages" {} - "wakuext_deleteMessagesFrom" {} - "wakuext_deleteMessagesByChatID" {} - "wakuext_deleteMessage" {} - "wakuext_markMessagesSeen" {} - "wakuext_markAllRead" {} - "wakuext_markAllReadInCommunity" {} - "wakuext_confirmMessagesProcessedByID" {} - "wakuext_chatMessages" {} - "wakuext_saveChat" {} - "wakuext_muteChat" {} - "wakuext_unmuteChat" {} - "wakuext_contacts" {} - "wakuext_removeContact" {} - "wakuext_setContactLocalNickname" {} - "wakuext_clearHistory" {} - "wakuext_prepareContent" {} - "wakuext_blockContact" {} - "wakuext_unblockContact" {} - "wakuext_addContact" {} - "wakuext_updateMailservers" {} - "wakuext_sendEmojiReaction" {} - "wakuext_disconnectActiveMailserver" {} - "wakuext_sendEmojiReactionRetraction" {} - "wakuext_emojiReactionsByChatID" {} - "wakuext_getLinkPreviewWhitelist" {} - "wakuext_getLinkPreviewData" {} - "wakuext_requestCommunityInfoFromMailserver" {} - "wakuext_deactivateChat" {} - "wakuext_sendPinMessage" {} - "wakuext_setPinnedMailservers" {} - "wakuext_chatPinnedMessages" {} - ;;TODO not used anywhere? - "wakuext_deleteChat" {} - "wakuext_saveContact" {} - "wakuext_verifyENSNames" {} - "wakuext_requestAddressForTransaction" {} - "wakuext_requestTransaction" {} - "wakuext_acceptRequestAddressForTransaction" {} - "wakuext_declineRequestAddressForTransaction" {} - "wakuext_declineRequestTransaction" {} - "wakuext_sendTransaction" {} - "wakuext_acceptRequestTransaction" {} - "wakuext_signMessageWithChatKey" {} - "wakuext_sendGroupChatInvitationRequest" {} - "wakuext_sendGroupChatInvitationRejection" {} - "wakuext_getGroupChatInvitations" {} - "wakuext_registerForPushNotifications" {} - "wakuext_unregisterFromPushNotifications" {} - "wakuext_enablePushNotificationsFromContactsOnly" {} - "wakuext_disablePushNotificationsFromContactsOnly" {} - "wakuext_startPushNotificationsServer" {} - "wakuext_stopPushNotificationsServer" {} - "wakuext_disableSendingNotifications" {} - "wakuext_enableSendingNotifications" {} - "wakuext_addPushNotificationsServer" {} - "wakuext_getPushNotificationsServers" {} - "wakuext_enablePushNotificationsBlockMentions" {} - "wakuext_disablePushNotificationsBlockMentions" {} - "wakuext_unreadActivityCenterNotificationsCount" {} - "wakuext_setUserStatus" {} - "wakuext_statusUpdates" {} - "multiaccounts_getIdentityImages" {} - "multiaccounts_getIdentityImage" {} - "multiaccounts_storeIdentityImage" {} - "multiaccounts_storeIdentityImageFromURL" {} - "multiaccounts_deleteIdentityImage" {} - "wakuext_changeIdentityImageShowTo" {} - "wakuext_createCommunity" {} - "wakuext_editCommunity" {} - "wakuext_createCommunityChat" {} - "wakuext_editCommunityChat" {} - "wakuext_inviteUsersToCommunity" {} - "wakuext_shareCommunity" {} - "wakuext_removeUserFromCommunity" {} - "wakuext_banUserFromCommunity" {} - "wakuext_requestToJoinCommunity" {} - "wakuext_acceptRequestToJoinCommunity" {} - "wakuext_declineRequestToJoinCommunity" {} - "wakuext_pendingRequestsToJoinForCommunity" {} - "wakuext_joinCommunity" {} - "wakuext_leaveCommunity" {} - "wakuext_communities" {} - "wakuext_importCommunity" {} - "wakuext_exportCommunity" {} - "wakuext_createCommunityCategory" {} - "wakuext_reorderCommunityCategories" {} - "wakuext_reorderCommunityChat" {} - "wakuext_editCommunityCategory" {} - "wakuext_deleteCommunityCategory" {} - "wakuext_deleteCommunityChat" {} - "wakuext_ensVerified" {} - "wakuext_dismissActivityCenterNotifications" {} - "wakuext_acceptActivityCenterNotifications" {} - "wakuext_dismissAllActivityCenterNotifications" {} - "wakuext_acceptAllActivityCenterNotifications" {} - "wakuext_markAllActivityCenterNotificationsRead" {} - "wakuext_activityCenterNotifications" {} - "status_chats" {} - "rpcstats_getStats" {} - "rpcstats_reset" {} - "localnotifications_switchWalletNotifications" {} - "localnotifications_notificationPreferences" {} - "wallet_setInitialBlocksRange" {} - "wallet_getTransfersByAddress" {} - "wallet_watchTransaction" {} - "wallet_checkRecentHistory" {} - "wallet_getCachedBalances" {} - "wallet_storePendingTransaction" {} - "wallet_deletePendingTransaction" {} - "wallet_getPendingTransactions" {} - "wallet_getTokensBalances" {} - "wallet_getCustomTokens" {} - "wallet_addCustomToken" {} - "wallet_addFavourite" {} - "wallet_getFavourites" {} - "wallet_deleteCustomToken" {} - "wallet_getCryptoOnRamps" {} - "wallet_getOpenseaCollectionsByOwner" {} - "wallet_getOpenseaAssetsByOwnerAndCollection" {} - "wallet_loadTransferByHash" {} - "wallet_getTokens" {};, %* [chainId]} - "wallet_getTokensBalancesForChainIDs" {};, %* [@[chainId], accounts, tokens] - "wallet_fetchPrices" {} - "browsers_getBrowsers" {} - "browsers_addBrowser" {} - "browsers_deleteBrowser" {} - "browsers_getBookmarks" {} - "browsers_storeBookmark" {} - "browsers_updateBookmark" {} - "browsers_removeBookmark" {} - "mailservers_getMailserverRequestGaps" {} - "mailservers_addMailserverRequestGaps" {} - "mailservers_deleteMailserverRequestGaps" {} - "mailservers_deleteMailserverRequestGapsByChatID" {} - "permissions_addDappPermissions" {} - "permissions_getDappPermissions" {} - "permissions_deleteDappPermissions" {} - "settings_saveSetting" {} - "settings_getSettings" {} - "accounts_getAccounts" {} - "accounts_saveAccounts" {} - "accounts_deleteAccount" {} - "mailservers_ping" {} - "mailservers_addMailserver" {} - "mailservers_getMailservers" {} - "mailservers_deleteMailserver" {} - "mailservers_addMailserverTopic" {} - "mailservers_addMailserverTopics" {} - "mailservers_getMailserverTopics" {} - "mailservers_deleteMailserverTopic" {} - "mailservers_addChatRequestRange" {} - "mailservers_addChatRequestRanges" {} - "mailservers_getChatRequestRanges" {} - "mailservers_deleteChatRequestRange" {} - "appmetrics_saveAppMetrics" {} - "appmetrics_getAppMetrics" {} - "stickers_market" {} - "stickers_installed" {} - "stickers_install" {} - "stickers_addRecent" {} - "stickers_recent" {} - "stickers_buyPrepareTx" {} - "stickers_processPending" {} - "stickers_addPending" {} - "stickers_pending" {}}) - (defn on-error-retry [call-method {:keys [method number-of-retries delay on-error] :as arg}] (if (pos? number-of-retries) @@ -260,62 +14,35 @@ (let [updated-delay (if delay (min 2000 (* 2 delay)) 50)] - (log/debug "[on-error-retry]" method - "number-of-retries" number-of-retries - "delay" delay - "error" error) + (log/debug "[on-error-retry]" method "number-of-retries" number-of-retries "delay" delay "error" error) (utils/set-timeout #(call-method (-> arg (update :number-of-retries dec) (assoc :delay updated-delay))) updated-delay))) on-error)) -(defn call-ext-method [method] - (str "wakuext_" method)) - (defn call [{:keys [method params on-success on-error js-response] :as arg}] - (if-let [method-options (json-rpc-api method)] - (let [params (or params []) - {:keys [id on-result subscription?] - :or {on-result identity - id 1}} method-options - on-error (or - on-error - (on-error-retry call arg) - #(log/warn :json-rpc/error method :error % :params params))] - (if (nil? method) - (do - (log/error :json-rpc/method-not-found method) - (on-error :json-rpc/method-not-found)) - (status/call-private-rpc - (types/clj->json {:jsonrpc "2.0" - :id id - :method (if subscription? - "eth_subscribeSignal" - method) - :params (if subscription? - [method params] - params)}) - (fn [response] - (if (string/blank? response) - (on-error {:message "Blank response"}) - (let [response-js (types/json->js response)] - (if (.-error response-js) - (on-error (types/js->clj (.-error response-js))) - (if subscription? - (re-frame/dispatch - [:ethereum.callback/subscription-success - (types/js->clj (.-result response-js)) on-success]) - (on-success (on-result (if js-response - (.-result response-js) - (types/js->clj (.-result response-js))))))))))))) - (log/warn "method" method "not found" arg))) + (let [params (or params []) + on-error (or on-error (on-error-retry call arg) #(log/warn :json-rpc/error method :error % :params params))] + (status/call-private-rpc + (types/clj->json {:jsonrpc "2.0" + :id 1 + :method method + :params params}) + (fn [response] + (if (string/blank? response) + (on-error {:message "Blank response"}) + (let [response-js (types/json->js response)] + (if (.-error response-js) + (on-error (types/js->clj (.-error response-js))) + (on-success (if js-response + (.-result response-js) + (types/js->clj (.-result response-js))))))))))) (defn eth-call [{:keys [contract method params outputs on-success block] - :or {block "latest" - params []} + :or {block "latest" params []} :as arg}] (call {:method "eth_call" :params [{:to contract @@ -330,15 +57,8 @@ :on-error (on-error-retry eth-call arg)})) -;; effects (re-frame/reg-fx ::call (fn [params] (doseq [param params] - (call param)))) - -(re-frame/reg-fx - ::eth-call - (fn [params] - (doseq [param params] - (eth-call param)))) + (call param)))) \ No newline at end of file diff --git a/src/status_im/ethereum/subscriptions.cljs b/src/status_im/ethereum/subscriptions.cljs index 2bf647d9af..0c970e2868 100644 --- a/src/status_im/ethereum/subscriptions.cljs +++ b/src/status_im/ethereum/subscriptions.cljs @@ -6,23 +6,8 @@ [status-im.utils.fx :as fx] [taoensso.timbre :as log])) -(fx/defn handle-signal - [cofx {:keys [subscription_id data] :as event}] - (if-let [handler (get-in cofx [:db :ethereum/subscriptions subscription_id])] - (handler data) - (log/warn ::unknown-subscription :event event))) - -(fx/defn handle-error - [cofx {:keys [subscription_id data] :as event}] - (log/error ::error event)) - -(fx/defn register-subscription - {:events [:ethereum.callback/subscription-success]} - [{:keys [db]} id handler] - {:db (assoc-in db [:ethereum/subscriptions id] handler)}) - (fx/defn new-transfers - [{:keys [db] :as cofx} block-number accounts] + [cofx block-number accounts] (log/debug "[wallet-subs] new-transfers" "accounts" accounts "block" block-number) @@ -41,7 +26,7 @@ (assoc :dispatch event)))) (fx/defn recent-history-fetching-ended - [{:keys [db] :as cofx} {:keys [accounts blockNumber]}] + [{:keys [db]} {:keys [accounts blockNumber]}] (log/debug "[wallet-subs] recent-history-fetching-ended" "accounts" accounts "block" blockNumber) @@ -76,11 +61,11 @@ (wallet.core/after-checking-history))) (fx/defn non-archival-node-detected - [{:keys [db] :as cofx} _] + [{:keys [db]} _] {:db (assoc db :wallet/non-archival-node true)}) (fx/defn new-wallet-event - [cofx {:keys [type blockNumber accounts newTransactions] :as event}] + [cofx {:keys [type blockNumber accounts] :as event}] (log/info "[wallet-subs] new-wallet-event" "event-type" type "blockNumber" blockNumber diff --git a/src/status_im/group_chats/core.cljs b/src/status_im/group_chats/core.cljs index 7a134c499e..6b2c5e9c2c 100644 --- a/src/status_im/group_chats/core.cljs +++ b/src/status_im/group_chats/core.cljs @@ -37,7 +37,7 @@ "Format group update message and sign membership" {:events [:group-chats.ui/remove-member-pressed]} [_ chat-id member] - {::json-rpc/call [{:method (json-rpc/call-ext-method "removeMemberFromGroupChat") + {::json-rpc/call [{:method "wakuext_removeMemberFromGroupChat" :params [nil chat-id member] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]}) @@ -45,7 +45,7 @@ (fx/defn join-chat {:events [:group-chats.ui/join-pressed]} [_ chat-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "confirmJoiningGroup") + {::json-rpc/call [{:method "wakuext_confirmJoiningGroup" :params [chat-id] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]}) @@ -55,7 +55,7 @@ :interceptors [(re-frame/inject-cofx :random-guid-generator)]} [{:keys [db] :as cofx} group-name] (let [selected-contacts (:group/selected-contacts db)] - {::json-rpc/call [{:method (json-rpc/call-ext-method "createGroupChatWithMembers") + {::json-rpc/call [{:method "wakuext_createGroupChatWithMembers" :params [nil group-name (into [] selected-contacts)] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]})) @@ -65,7 +65,7 @@ (if (get-in cofx [:db :chats chat-id]) {:dispatch-n [[:accept-all-activity-center-notifications-from-chat chat-id] [:chat.ui/navigate-to-chat chat-id]]} - {::json-rpc/call [{:method (json-rpc/call-ext-method "createGroupChatFromInvitation") + {::json-rpc/call [{:method "wakuext_createGroupChatFromInvitation" :params [chat-name chat-id invitation-admin] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]})) @@ -73,7 +73,7 @@ (fx/defn make-admin {:events [:group-chats.ui/make-admin-pressed]} [_ chat-id member] - {::json-rpc/call [{:method (json-rpc/call-ext-method "addAdminsToGroupChat") + {::json-rpc/call [{:method "wakuext_addAdminsToGroupChat" :params [nil chat-id [member]] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]}) @@ -82,7 +82,7 @@ "Add members to a group chat" {:events [:group-chats.ui/add-members-pressed]} [{{:keys [current-chat-id selected-participants]} :db :as cofx}] - {::json-rpc/call [{:method (json-rpc/call-ext-method "addMembersToGroupChat") + {::json-rpc/call [{:method "wakuext_addMembersToGroupChat" :params [nil current-chat-id selected-participants] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]}) @@ -92,7 +92,7 @@ {:events [:group-chats.ui/add-members-from-invitation]} [{{:keys [current-chat-id] :as db} :db :as cofx} id participant] {:db (assoc-in db [:group-chat/invitations id :state] constants/invitation-state-approved) - ::json-rpc/call [{:method (json-rpc/call-ext-method "addMembersToGroupChat") + ::json-rpc/call [{:method "wakuext_addMembersToGroupChat" :params [nil current-chat-id [participant]] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]}) @@ -101,7 +101,7 @@ "Leave chat" {:events [:group-chats.ui/leave-chat-confirmed]} [{:keys [db] :as cofx} chat-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "leaveGroupChat") + {::json-rpc/call [{:method "wakuext_leaveGroupChat" :params [nil chat-id true] :js-response true :on-success #(re-frame/dispatch [:chat-removed %])}]}) @@ -126,7 +126,7 @@ [{:keys [db] :as cofx} chat-id new-name] (when (valid-name? new-name) {:db (assoc-in db [:chats chat-id :name] new-name) - ::json-rpc/call [{:method (json-rpc/call-ext-method "changeGroupChatName") + ::json-rpc/call [{:method "wakuext_changeGroupChatName" :params [nil chat-id new-name] :js-response true :on-success #(re-frame/dispatch [:chat-updated %])}]})) @@ -148,7 +148,7 @@ (let [{:keys [invitation-admin]} (get chats current-chat-id) message (get-in db [:chat/memberships current-chat-id :message])] {:db (assoc-in db [:chat/memberships current-chat-id] nil) - ::json-rpc/call [{:method (json-rpc/call-ext-method "sendGroupChatInvitationRequest") + ::json-rpc/call [{:method "wakuext_sendGroupChatInvitationRequest" :params [nil current-chat-id invitation-admin message] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]})) @@ -157,7 +157,7 @@ "Send group chat membership rejection" {:events [:send-group-chat-membership-rejection]} [cofx invitation-id] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendGroupChatInvitationRejection") + {::json-rpc/call [{:method "wakuext_sendGroupChatInvitationRejection" :params [nil invitation-id] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %])}]}) diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index a78f9250f2..ffc551f0e8 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -346,7 +346,7 @@ (fx/defn get-group-chat-invitations [_] {::json-rpc/call - [{:method (json-rpc/call-ext-method "getGroupChatInvitations") + [{:method "wakuext_getGroupChatInvitations" :on-success #(re-frame/dispatch [::initialize-invitations %])}]}) (fx/defn initialize-communities-enabled diff --git a/src/status_im/multiaccounts/update/core.cljs b/src/status_im/multiaccounts/update/core.cljs index 8d9f3373ed..998076269b 100644 --- a/src/status_im/multiaccounts/update/core.cljs +++ b/src/status_im/multiaccounts/update/core.cljs @@ -6,7 +6,7 @@ (fx/defn send-multiaccount-update [{:keys [db] :as cofx}] (let [multiaccount (:multiaccount db) {:keys [name preferred-name address]} multiaccount] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactUpdates") + {::json-rpc/call [{:method "wakuext_sendContactUpdates" :params [(or preferred-name name) ""] :on-success #(log/debug "sent contact update")}]})) diff --git a/src/status_im/notifications/core.cljs b/src/status_im/notifications/core.cljs index 589463befd..25814a946d 100644 --- a/src/status_im/notifications/core.cljs +++ b/src/status_im/notifications/core.cljs @@ -119,7 +119,7 @@ (fx/defn handle-enable-notifications-event {:events [:notifications/registered-for-push-notifications]} [cofx token] - {::json-rpc/call [{:method (json-rpc/call-ext-method "registerForPushNotifications") + {::json-rpc/call [{:method "wakuext_registerForPushNotifications" :params [token (if platform/ios? config/apn-topic) (if platform/ios? apn-token-type firebase-token-type)] :on-success #(log/info "[push-notifications] register-success" %) :on-error #(re-frame/dispatch [:notifications/switch-error true %])}]}) @@ -127,7 +127,7 @@ (fx/defn handle-disable-notifications-event {:events [:notifications/unregistered-from-push-notifications]} [cofx] - {::json-rpc/call [{:method (json-rpc/call-ext-method "unregisterFromPushNotifications") + {::json-rpc/call [{:method "wakuext_unregisterFromPushNotifications" :params [] :on-success #(log/info "[push-notifications] unregister-success" %) :on-error #(re-frame/dispatch [:notifications/switch-error false %])}]}) @@ -135,7 +135,7 @@ (fx/defn logout-disable [cofx] (merge {::logout-disable nil} - {::json-rpc/call [{:method (json-rpc/call-ext-method "unregisterFromPushNotifications") + {::json-rpc/call [{:method "wakuext_unregisterFromPushNotifications" :params [] :on-success #(log/info "[push-notifications] unregister-success" %) :on-error #(log/info "[push-notifications] unregister-error" %)}]})) @@ -172,10 +172,10 @@ {:events [::switch-non-contacts]} [{:keys [db] :as cofx} enabled?] (let [method (if enabled? - "enablePushNotificationsFromContactsOnly" - "disablePushNotificationsFromContactsOnly")] + "wakuext_enablePushNotificationsFromContactsOnly" + "wakuext_disablePushNotificationsFromContactsOnly")] (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method method) + {::json-rpc/call [{:method method :params [] :on-success #(log/info "[push-notifications] contacts-notification-success" %) :on-error #(re-frame/dispatch [::non-contacts-update-error enabled? %])}]} @@ -186,11 +186,11 @@ {:events [::switch-block-mentions]} [{:keys [db] :as cofx} enabled?] (let [method (if enabled? - "enablePushNotificationsBlockMentions" - "disablePushNotificationsBlockMentions")] + "wakuext_enablePushNotificationsBlockMentions" + "wakuext_disablePushNotificationsBlockMentions")] (log/info "USING METHOD" method enabled?) (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method method) + {::json-rpc/call [{:method method :params [] :on-success #(log/info "[push-notifications] block-mentions-success" %) :on-error #(re-frame/dispatch [::block-mentions-update-error enabled? %])}]} @@ -201,10 +201,10 @@ {:events [::switch-push-notifications-server-enabled]} [{:keys [db] :as cofx} enabled?] (let [method (if enabled? - "startPushNotificationsServer" - "stopPushNotificationsServer")] + "wakuext_startPushNotificationsServer" + "wakuext_stopPushNotificationsServer")] (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method method) + {::json-rpc/call [{:method method :params [] :on-success #(log/info "[push-notifications] switch-server-enabled successful" %) :on-error #(re-frame/dispatch [::push-notifications-server-update-error enabled? %])}]} @@ -215,10 +215,10 @@ {:events [::switch-send-push-notifications]} [{:keys [db] :as cofx} enabled?] (let [method (if enabled? - "enableSendingNotifications" - "disableSendingNotifications")] + "wakuext_enableSendingNotifications" + "wakuext_disableSendingNotifications")] (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method method) + {::json-rpc/call [{:method method :params [] :on-success #(log/info "[push-notifications] switch-send-notifications successful" %) :on-error #(re-frame/dispatch [::push-notifications-send-update-error enabled? %])}]} @@ -234,7 +234,7 @@ {:events [::add-server]} [{:keys [db] :as cofx} public-key] (fx/merge cofx - {::json-rpc/call [{:method (json-rpc/call-ext-method "addPushNotificationsServer") + {::json-rpc/call [{:method "wakuext_addPushNotificationsServer" :params [public-key] :on-success #(do (log/info "[push-notifications] switch-send-notifications successful" %) @@ -249,7 +249,7 @@ (fx/defn fetch-push-notifications-servers {:events [::fetch-servers]} [cofx] - {::json-rpc/call [{:method (json-rpc/call-ext-method "getPushNotificationsServers") + {::json-rpc/call [{:method "wakuext_getPushNotificationsServers" :params [] :on-success #(do (log/info "[push-notifications] servers fetched" %) diff --git a/src/status_im/notifications_center/core.cljs b/src/status_im/notifications_center/core.cljs index 02f8bd0654..41c53677d6 100644 --- a/src/status_im/notifications_center/core.cljs +++ b/src/status_im/notifications_center/core.cljs @@ -33,7 +33,7 @@ (fx/defn get-activity-center-notifications-count {:events [:get-activity-center-notifications-count]} [_] - {::json-rpc/call [{:method (json-rpc/call-ext-method "unreadActivityCenterNotificationsCount") + {::json-rpc/call [{:method "wakuext_unreadActivityCenterNotificationsCount" :params [] :on-success #(re-frame/dispatch [:get-activity-center-notifications-count-success %]) :on-error #()}]}) @@ -48,7 +48,7 @@ [{:keys [db]} ids] {:db (update-in db [:activity.center/notifications :notifications] (fn [items] (remove #(get ids (:id %)) items))) - ::json-rpc/call [{:method (json-rpc/call-ext-method "dismissActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_dismissActivityCenterNotifications" :params [ids] :on-success #() :on-error #()}]}) @@ -59,7 +59,7 @@ (when (seq ids) {:db (update-in db [:activity.center/notifications :notifications] (fn [items] (remove #(get ids (:id %)) items))) - ::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_acceptActivityCenterNotifications" :params [ids] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %]) @@ -78,7 +78,7 @@ (update-in [:activity.center/notifications :notifications] (fn [items] (filter #(not (= chat-id (:chat-id %))) items))) (update :activity.center/notifications-count - (min (db :activity.center/notifications-count) (count notifications-from-chat-not-read)))) - ::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_acceptActivityCenterNotifications" :params [ids] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %]) @@ -89,7 +89,7 @@ [{:keys [db]} id] {:db (update-in db [:activity.center/notifications :notifications] (fn [items] (remove #(= id (:id %)) items))) - ::json-rpc/call [{:method (json-rpc/call-ext-method "acceptActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_acceptActivityCenterNotifications" :params [[id]] :js-response true :on-success #(re-frame/dispatch [:ensure-and-open-chat %]) @@ -105,7 +105,7 @@ {:events [:dismiss-all-activity-center-notifications]} [{:keys [db]}] {:db (assoc-in db [:activity.center/notifications :notifications] []) - ::json-rpc/call [{:method (json-rpc/call-ext-method "dismissAllActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_dismissAllActivityCenterNotifications" :params [] :on-success #() :on-error #()}]}) @@ -114,7 +114,7 @@ {:events [:accept-all-activity-center-notifications]} [{:keys [db]}] {:db (assoc-in db [:activity.center/notifications :notifications] []) - ::json-rpc/call [{:method (json-rpc/call-ext-method "acceptAllActivityCenterNotifications") + ::json-rpc/call [{:method "wakuext_acceptAllActivityCenterNotifications" :params [] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %]) @@ -124,7 +124,7 @@ {:events [:mark-all-activity-center-notifications-as-read]} [{:keys [db]}] {:db (assoc db :activity.center/notifications-count 0) - ::json-rpc/call [{:method (json-rpc/call-ext-method "markAllActivityCenterNotificationsRead") + ::json-rpc/call [{:method "wakuext_markAllActivityCenterNotificationsRead" :params [] :on-success #() :on-error #()}]}) @@ -132,7 +132,7 @@ (fx/defn load-notifications [{:keys [db]} cursor] (when-not (:activity.center/loading? db) {:db (assoc db :activity.center/loading? true) - ::json-rpc/call [{:method (json-rpc/call-ext-method "activityCenterNotifications") + ::json-rpc/call [{:method "wakuext_activityCenterNotifications" :params [cursor 20] :on-success #(re-frame/dispatch [:activity-center-notifications-success %]) :on-error #(re-frame/dispatch [:activity-center-notifications-error %])}]})) diff --git a/src/status_im/pairing/core.cljs b/src/status_im/pairing/core.cljs index 906f2ceb56..74caf85cd1 100644 --- a/src/status_im/pairing/core.cljs +++ b/src/status_im/pairing/core.cljs @@ -10,25 +10,25 @@ [status-im.multiaccounts.update.core :as multiaccounts.update])) (defn enable-installation-rpc [installation-id on-success on-failure] - (json-rpc/call {:method (json-rpc/call-ext-method "enableInstallation") + (json-rpc/call {:method "wakuext_enableInstallation" :params [installation-id] :on-success on-success :on-failure on-failure})) (defn disable-installation-rpc [installation-id on-success on-failure] - (json-rpc/call {:method (json-rpc/call-ext-method "disableInstallation") + (json-rpc/call {:method "wakuext_disableInstallation" :params [installation-id] :on-success on-success :on-failure on-failure})) (defn set-installation-metadata-rpc [installation-id metadata on-success on-failure] - (json-rpc/call {:method (json-rpc/call-ext-method "setInstallationMetadata") + (json-rpc/call {:method "wakuext_setInstallationMetadata" :params [installation-id metadata] :on-success on-success :on-failure on-failure})) (defn get-our-installations-rpc [on-success on-failure] - (json-rpc/call {:method (json-rpc/call-ext-method "getOurInstallations") + (json-rpc/call {:method "wakuext_getOurInstallations" :params [] :on-success on-success :on-failure on-failure})) @@ -55,7 +55,7 @@ (fx/defn send-pair-installation {:events [:pairing.ui/pair-devices-pressed]} [_] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendPairInstallation") + {::json-rpc/call [{:method "wakuext_sendPairInstallation" :params [] :on-success #(log/info "sent pair installation message")}]}) @@ -183,7 +183,7 @@ [{:keys [db]}] (let [multiaccount (:multiaccount db) {:keys [name preferred-name identicon]} multiaccount] - {::json-rpc/call [{:method (json-rpc/call-ext-method "syncDevices") + {::json-rpc/call [{:method "wakuext_syncDevices" :params [(or preferred-name name) identicon] :on-success #(log/debug "successfully synced devices")}]})) diff --git a/src/status_im/signals/core.cljs b/src/status_im/signals/core.cljs index 12a1d4c452..c9b5c49d12 100644 --- a/src/status_im/signals/core.cljs +++ b/src/status_im/signals/core.cljs @@ -71,8 +71,6 @@ "mailserver.not.working" (mailserver/handle-mailserver-not-working cofx) "discovery.summary" (summary cofx (js->clj event-js :keywordize-keys true)) "wakuv2.peerstats" (wakuv2-peer-stats cofx (js->clj event-js :keywordize-keys true)) - "subscriptions.data" (ethereum.subscriptions/handle-signal cofx (js->clj event-js :keywordize-keys true)) - "subscriptions.error" (ethereum.subscriptions/handle-error cofx (js->clj event-js :keywordize-keys true)) "messages.new" (transport.message/sanitize-messages-and-process-response cofx event-js true) "wallet" (ethereum.subscriptions/new-wallet-event cofx (js->clj event-js :keywordize-keys true)) "local-notifications" (local-notifications/process cofx (js->clj event-js :keywordize-keys true)) diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index f83833d103..68a1dfd089 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -288,7 +288,7 @@ (fx/defn send-transaction-message {:events [:sign/send-transaction-message]} [cofx chat-id value contract transaction-hash signature] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendTransaction") + {::json-rpc/call [{:method "wakuext_sendTransaction" ;; We make sure `value` is serialized as string, and not ;; as an integer or big-int :params [chat-id (str value) contract transaction-hash @@ -301,7 +301,7 @@ (fx/defn send-accept-request-transaction-message {:events [:sign/send-accept-transaction-message]} [cofx message-id transaction-hash signature] - {::json-rpc/call [{:method (json-rpc/call-ext-method "acceptRequestTransaction") + {::json-rpc/call [{:method "wakuext_acceptRequestTransaction" :params [transaction-hash message-id (or (:result (types/json->clj signature)) (ethereum/normalized-hex signature))] @@ -482,7 +482,7 @@ [to-norm amount-hex])})})) {:db db ::json-rpc/call - [{:method (json-rpc/call-ext-method "requestAddressForTransaction") + [{:method "wakuext_requestAddressForTransaction" :params [(:current-chat-id db) from-address amount diff --git a/src/status_im/signing/gas.cljs b/src/status_im/signing/gas.cljs index 5522591b1e..4292925bf6 100644 --- a/src/status_im/signing/gas.cljs +++ b/src/status_im/signing/gas.cljs @@ -298,7 +298,7 @@ (fn [] (json-rpc/call {:method "eth_gasPrice" - :on-success success-callback + :on-success #(success-callback (money/bignumber %)) :on-error (or error-callback #(log/warn "eth_gasPrice error" %))}))))) (def london-block-gas-limit (money/bignumber 30000000)) @@ -378,7 +378,7 @@ :testnet? (ethereum/testnet? (get-in networks [current-network :config :NetworkId]))))] (merge {:max-priority-fee - (max-priority-fee-hex % current-base-fee)} + (max-priority-fee-hex (money/bignumber %) current-base-fee)} base-fees))) :on-error (if error-callback #(error-callback %) @@ -387,7 +387,8 @@ (re-frame/reg-fx :signing/update-estimated-gas (fn [{:keys [obj success-event error-event]}] - (json-rpc/call {:method "eth_estimateGas" - :params [obj] - :on-success #(re-frame/dispatch [success-event %]) - :on-error #(re-frame/dispatch [error-event %])}))) + (json-rpc/call + {:method "eth_estimateGas" + :params [obj] + :on-success #(re-frame/dispatch [success-event (money/bignumber (if (= (int %) 21000) % (int (* % 1.2))))]) + :on-error #(re-frame/dispatch [error-event %])}))) diff --git a/src/status_im/transport/core.cljs b/src/status_im/transport/core.cljs index 2c6bb15da0..d18229406e 100644 --- a/src/status_im/transport/core.cljs +++ b/src/status_im/transport/core.cljs @@ -2,10 +2,8 @@ status-im.transport.core (:require [re-frame.core :as re-frame] [status-im.ethereum.json-rpc :as json-rpc] - [status-im.native-module.core :as status] [status-im.pairing.core :as pairing] [status-im.utils.fx :as fx] - [status-im.utils.handlers :as handlers] status-im.transport.shh [taoensso.timbre :as log] [status-im.utils.universal-links.core :as universal-links] @@ -16,22 +14,10 @@ [{:keys [db]} node-info] {:db (assoc db :node-info node-info)}) -(defn fetch-node-info [] - (let [args {:jsonrpc "2.0" - :id 2 - :method "admin_nodeInfo"} - payload (.stringify js/JSON (clj->js args))] - (status/call-private-rpc payload - (handlers/response-handler #(re-frame/dispatch [:transport.callback/node-info-fetched %]) - #(log/error "node-info: failed error" %))))) - -(re-frame/reg-fx - ::fetch-node-info - (fn [] - (fetch-node-info))) - -(fx/defn fetch-node-info-fx [cofx] - {::fetch-node-info []}) +(fx/defn fetch-node-info-fx [_] + {::json-rpc/call [{:method "admin_nodeInfo" + :on-success #(re-frame/dispatch [:transport.callback/node-info-fetched %]) + :on-error #(log/error "node-info: failed error" %)}]}) (defn add-mailservers [db mailservers] @@ -52,7 +38,7 @@ initializiation is completed, otherwise we might receive messages/topics when the state has not been properly initialized." [_] - {::json-rpc/call [{:method (json-rpc/call-ext-method "startMessenger") + {::json-rpc/call [{:method "wakuext_startMessenger" :on-success #(re-frame/dispatch [::messenger-started %]) :on-failure #(log/error "failed to start messenger")}]}) diff --git a/src/status_im/transport/message/protocol.cljs b/src/status_im/transport/message/protocol.cljs index 108d502e85..0eb3ae9dbf 100644 --- a/src/status_im/transport/message/protocol.cljs +++ b/src/status_im/transport/message/protocol.cljs @@ -27,23 +27,21 @@ :contentType content-type}) (fx/defn send-chat-messages [_ messages] - {::json-rpc/call [{:method (json-rpc/call-ext-method "sendChatMessages") + {::json-rpc/call [{:method "wakuext_sendChatMessages" :params [(mapv build-message messages)] :js-response true :on-success #(re-frame/dispatch [:transport/message-sent %]) :on-failure #(log/error "failed to send a message" %)}]}) (fx/defn send-reaction [_ {:keys [message-id chat-id emoji-id]}] - {::json-rpc/call [{:method (json-rpc/call-ext-method - "sendEmojiReaction") + {::json-rpc/call [{:method "wakuext_sendEmojiReaction" :params [chat-id message-id emoji-id] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %]) :on-failure #(log/error "failed to send a reaction" %)}]}) -(fx/defn send-retract-reaction [_ {:keys [emoji-reaction-id] :as reaction}] - {::json-rpc/call [{:method (json-rpc/call-ext-method - "sendEmojiReactionRetraction") +(fx/defn send-retract-reaction [_ {:keys [emoji-reaction-id]}] + {::json-rpc/call [{:method "wakuext_sendEmojiReactionRetraction" :params [emoji-reaction-id] :js-response true :on-success #(re-frame/dispatch [:sanitize-messages-and-process-response %]) diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 29170072cb..1ef7ab150d 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -36,7 +36,7 @@ (json-rpc/call {:method "eth_getBalance" :params [address "latest"] - :on-success on-success + :on-success #(on-success (money/bignumber %)) :number-of-retries 50 :on-error on-error})) @@ -489,7 +489,7 @@ identity (:current-chat-id db)] (fx/merge cofx {:db (dissoc db :wallet/prepare-transaction) - ::json-rpc/call [{:method (json-rpc/call-ext-method "requestTransaction") + ::json-rpc/call [{:method "wakuext_requestTransaction" :params [(:public-key to) amount (when-not (= symbol :ETH)