mirror of
https://github.com/status-im/status-lib.git
synced 2025-01-11 21:14:30 +00:00
Michael Bradley, Jr
555986233d
refactor: return object instead of string from stickers backend
Related to https://github.com/status-im/status-desktop/issues/3725. Introduce `type PendingTransaction` in `status/types/transaction.nim`. Refactor `proc buyPack` in `status/stickers.nim` to return an instance of that type instead of `string`. Eliminate unnecessary threading of `var success` argument through successive calls in favor of tracking `success` in a field on `PendingTransaction`. --- NOTES Several files in this project have "sticker" in their names or make reference to "sticker". All those were reviewed as candidates for changes logically-related to the purpose of this PR: `status/accounts.nim` `status/chat.nim` `status/chat/stickers.nim` `status/eth/contracts.nim` `status/eth/stickers.nim` `status/status.nim` `status/statusgo_backend/chat.nim` `status/statusgo_backend/edn_helpers.nim` `status/stickers.nim` `status/types/message.nim` `status/types/pending_transaction_type.nim` `status/types/setting.nim` `status/types/sticker.nim` `status/utils.nim` `status/wallet/collectibles.nim` `sendStickerMessage` in `status/statusgo_backend/chat.nim` returns `string` but refactoring it seems out of scope for this set of changes. A comment has been left in `status/stickers.nim` re: an additional refactor that can be made to simplify `trackPendingTransaction` as called by `buyPack`. The refactor will involve changes in other modules as well. `type Message` in `status/types/message.nim` has a `sticker*: string` field that doesn't seem to be made use of by the Nim side of status-desktop, but it it is made use of by desktop's QML side (see: `status-desktop/ui/app/AppLayouts/Chat/ChatColumn/ChatMessages.qml`). In the future it may be preferable to use a different type, or a type alias for `string`. `decodeContentHash` in `status/utils.nim` could return an instance of `type Cid` without converting it to a string, leaving it up to call sites in status-lib and status-desktop to convert to `string`. `getStickers` in `status/wallet/collectibles.nim` returns `string`, used by `{.slot.}` procs in status-desktop (see Nim sources in `status-desktop/src/app`) that expose the JSON data (as `string`) to QML. Refactoring the return value seems out of scope for this PR, given ongoing refactors in status-desktop's front-end architecture.
nim-status-lib
WIP refactor to extract business logic from status-desktop into a reusable library
Languages
Nim
91.5%
Makefile
8.1%
Shell
0.4%