Commit Graph

207 Commits

Author SHA1 Message Date
Richard Ramos 46955bee26
feat: add /joinpublicchat and /leavepublicchat commands to join status channels on waku2 2021-08-26 15:01:46 -04:00
Eric Mastro 18d4c35f85 chore: remove unused error and defect objects 2021-08-25 11:20:26 +10:00
Eric Mastro 3efd393a40 feat: get token prices from cryptocompare.io 2021-08-25 10:11:14 +10:00
Eric Mastro 481ffa6ce4 fix: in getWalletAccount check `chat = FALSE` instead of `wallet = 0`
We're already checking `chat = FALSE` in `getWalletAccounts` (plural), and we
should do the same in `getWalletAccount` (singular).

This allows `getWalletAccount` to retrieve the address for the default created
account, a.k.a. `Status account`. That address should be usable with e.g. the
`/sendtransaction` command.

Also, in SQL statements (and some comments) switch from 0/1 to FALSE/TRUE for
boolean columns.

Closes #289.
2021-08-24 15:22:14 +10:00
Michael Bradley, Jr 14d8110f9b chore: print an error in the TUI when a nonexistent command is entered
Closes #255.
2021-08-24 12:00:08 +10:00
Eric Mastro 214c8fe305 feat: improve exception handling by switching to Result
Closes: #270.

All exception handling internally was swapped over to use nim-result instead of raising exceptions directly, as per the advice received.
2021-08-24 11:54:53 +10:00
Richard Ramos 83c0c6f343 feat: add /sendTransaction command to TUI to send eip1559 transactions 2021-08-20 13:03:04 -05:00
Michael Bradley, Jr d718146502 fix: help command should not crash if some commands don't have alias
Also fix `proc help` for `AddWalletWatchOnly`, which was incorrectly using
`"addwalletseed"` instead of `"addwalletwatch"`.

Closes #276.
2021-08-17 20:37:59 -05:00
Anthony Laibe f84efcc4b8 feat: Integrate with opensea API to fetch collectible
fixes #263
2021-08-11 10:10:53 -05:00
Richard Ramos d05b486bd1 feat: add /call command to TUI to execute eth rpc methods 2021-08-11 08:01:12 -05:00
Eric Mastro 0806e790ed feat: add exception handling
Closes: #239

Remove all `except Exception as e` where possible. In some instances, transitive dependencies out of our control were the source of this error. Even in instances of the Nim library, like `parseJson`, for example, force us to `except Exception` to prevent it from bubbling up to higher layers in the abstraction.

At the lowest levels, we are catching all errors that inherit from `CatchableError` and translating them to be useful for layers above. At the highest level, which is our public API layer, meant to be directly consumed by consumer clients, we are catching all catchable exceptions from the layers below and translating them in to a Result type.
2021-08-10 15:19:12 -05:00
Michael Bradley, Jr 1adb3045d6 refactor: create nim.cfg in examples/ and test/ so `status` lib can be imported unprefixed 2021-08-05 21:45:01 -05:00
Michael Bradley, Jr ac8771d0f3 refactor: example client does not import non-api modules of nim-status
There's one remaining import of a non-api (private) module in
`examples/client/client/tasks.nim`:

```
../../status/private/protocol
```

That one will be removed in a forthcoming PR that moves import/usage of
nim-waku from the example client to the nim-status library itself.
2021-08-05 18:52:44 -05:00
Michael Bradley, Jr 79357de59a refactor: organize non-api modules under status/private/
Also clean up import sections in all modules under examples/, status/, and
test/
2021-08-05 04:38:07 -05:00
Eric Mastro f4f5dc42e0 build: remove nim-stew
We are using `nim-stew` from `nim-waku/vendor`
2021-08-03 19:29:36 +10:00
Eric Mastro 7efda29028 build: Remove nim-result
We are currently using nim-stew/results, which comes from nim-waku/vendor.
2021-08-03 19:29:36 +10:00
Eric Mastro 42755623cb feat: first steps to enable property error handling
Related to #239
2021-08-03 19:29:36 +10:00
Eric Mastro bd852051b4 refactor: swap except Exception for except CatchableError 2021-08-03 19:29:36 +10:00
Eric Mastro f4283c6467 chore: status/client -> status/api, modularise api
Change the name from `status/client.nim` to `status/api.nim`.

Break up `api.nim` in to modules, and put the modules in to the `status/api` directory.

Update the tests.
2021-08-03 17:52:36 +10:00
Michael Bradley, Jr e705359ad8 feat(client): basic support for backspace
Note: on mac keyboards the delete key is backspace and on mac laptop keyboards
fn+delete is delete ("forward delete"). Some mac keyboards have a separate key,
also named delete, for performing forward deletion.
2021-08-02 10:11:24 -05:00
Michael Bradley, Jr bbf19c4342 build: attempt to detect whether linux distro is based on debian
Set INCLUDE/LIB dirs accordingly after detection.
2021-07-30 13:59:11 -05:00
Michael Bradley, Jr 2b0af118fd
chore: fix centering of "nim-status client" title at top of output window 2021-07-30 10:57:38 -05:00
Michael Bradley, Jr 5c318ab209 refactor: modify TopicHandler proc to satisfy {.raises.} analysis 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 4aa8fc9d5e refactor: WakuNode.init -> WakuNode.new in client/tasks 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 463a1ac22e refactor: create const aliases for LogLevel.ERROR/NONE
Changes in re-exports related to waku introduced an ambiguity.
2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 67e279ee87 chore: remove unused imports 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 99a56e8aff refactor: all tests should write to `test/build/` relative to the root of the repo 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 24b8da461e refactor: update modules in examples/waku/ re: changes to the originals in nim-waku/examples/v2/ 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr d45400f20e refactor: WakuNode.init -> WakuNode.new in status/waku
`status/waku.nim` is an older module that provided just enough waku v2
integration to allow for a test.

This commit modifies it re: the recent nim-waku refactor efforts so that it and
the test for it works correctly.

The module will soon be overhauled by moving the example client's waku
logic (with some adaptations) into `status/waku.nim`.
2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 66ffd48fd4 build: bump vendor/nimbus-build-system 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 754d78e920 build: bump vendor/nim-sqlcipher 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 73922446a2 build: bump vendor/nim-web3 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 64340cf0e1 build: bump vendor/nim-waku 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr 8a97ba3ad0 build: bump vendor/nim-task-runner 2021-07-29 19:05:24 -05:00
Michael Bradley, Jr a583204253 build: bump vendor/nim-chronos 2021-07-29 19:05:24 -05:00
Eric Mastro 1d1ba36380 feat: delete wallet account
Closes #225.

Deletes wallet account by wallet index.

Add account db tests for additional account procs: getWalletAccount, getWalletAccounts, and deleteWalletAccount

Add account generator tests for additional generator procs: deleteKeyFile
2021-07-29 18:53:26 -05:00
Michael Bradley, Jr af1584d617 refactor: examples/chat -> examples/client
The example client we're building is more than a "chat" program: it
has (beginnings of) support for wallets and eventually the full range of
capabilities implemented in nim-status.

Rename `examples/chat.nim` to `examples/client.nim` and make a number of
related changes/renamings that help to make it more clear that the example
client is a "client in general", not just a chat client.

Also, put the copied example waku chat2 code under `examples/waku/`.
2021-07-29 15:06:15 -05:00
Michael Bradley, Jr 54cb3d746f refactor: nim_status -> status
The name of the repo is not being changed. But instead of doing:

```nim
import nim_status
```

You would do:

```nim
import status
```

This is in line with nim-chronos (`import chronos`), nim-waku (`import waku`),
and many other Nim libs.
2021-07-29 14:23:26 -05:00
Michael Bradley, Jr 3c4af4d9f3
feat: en/decode Status payloads when sending/receiving messages (first steps)
Copy protobuf specs from status-go, make necessary adjustments for use via
nim-protobuf-serialization. Many thanks to @richard-ramos for his help with
this aspect and others!

Implement "first steps" towards encoding and decoding Status payloads when
sending and receiving messages.

That consists of using an incomplete
`ProtocolMessage(ApplicationMetadataMessage(ChatMessage)))` wrapping of
messages, assuming all messages currently being sent correspond to public
chats. It's incomplete because there are many fields for which values are not
being derived, and there is no encryption performed.

A series of future pull requests will fill in the missing pieces and expand our
usage of the protobuf specs, i.e. allow nim-status to send and receive more
kinds of Status messages.

Note that the waku v2 content topics are not yet using a hash of the
user-supplied topic name; that will also be addressed in a future pull request.

It's also important to note that a refactor is pending re: moving the import
and usage of nim-waku inside the `nim_status` library, as well refactorings re:
exception handling, imports and exports, and other aspects that have been
commented upon in other recent pull requests. This commit builds on the work
done to date in the same way as before, but there is already awareness of what
should be changed and can be improved.

Ensure that joined waku v2 content topics (whether joined in the TUI or
specified on the command-line) conform to the recommendations in
[23/WAKU2-TOPICS](https://rfc.vac.dev/spec/23/).

Unrelated to the main focus of this commit: use a fixed-length array instead of
a sequence for collecting bytes of user input (keyboard and mouse) in the
`input` worker thread. It's more efficient to do it that way: less allocation
and garbage collection.

---

Closes #217.
2021-07-29 12:27:06 +03:00
Vitaliy Vlasov b8ffb5e1ea
Custom tokens support in example client app 2021-07-29 12:26:58 +03:00
Eric Mastro 5a33df2f47 feat: Add watch-only wallet account
Closes: #226

Add command (`/addwalletwatch`, `/addwatch`) that allows adding a watch-only account to the example client.
2021-07-26 12:03:27 +10:00
Eric Mastro dde6957cab feat: import wallet account via mnemonic
Closes: #224.

Allows a user to import a wallet account via 12-word mnemonic seed.

The account is first imported in the account generator. Then a wallet account is derived at the root wallet path (m/44'/60’/0’/0/0) from the master key of the mnemonic. This account is then stored in the Accounts table of the user’s db.
2021-07-25 16:55:43 +10:00
Michael Bradley, Jr 651f533f1c refactor: use SQLCipher v4 defaults re: algorithms, iterations, etc.
Comment out and provide an explanatory comment re: the custom settings that we
originally carried over from status-go.

Closes #209.
2021-07-22 10:39:50 -05:00
Michael Bradley, Jr a570e8b2db refactor: use now().utc when generating keystore files 2021-07-22 15:55:36 +10:00
Eric Mastro ba3aea2393 feat: support importing wallet accout via private key
Add funcs to support importing a wallet account via private key.

Support password validation before importing the keystore file. Prevent duplicate keystore files from being imported.

Add keystore file unit tests for storing and loading of key files

Add import wallet pk command to example chat client

Refactor web3_conversions imports to insteaad import `nim_status/conversions`.
2021-07-22 15:55:36 +10:00
Eric Mastro d0a3e4ff01 refactor: add Event suffix to all event types 2021-07-22 12:19:57 +10:00
Michael Bradley, Jr e3626d1379 fix: restore topic to constructor call for UserMessage 2021-07-22 12:19:57 +10:00
Eric Mastro e2596a0c18 feat: generate wallet account
Closes: #214, #215.

Almost all the work for #197 is included in this PR.

Generate a new wallet account using `/add`, `/addaccount`

feat: create settings when creating/importing a login account
When creating or importing a new account (a login account, not a wallet account), settings are now created.

feat: list wallet accounts
Wallet accounts can be listed using `/wallets`, `/listwalletaccounts`, and `/listwallets`. This gets all accounts in the user db that are not chat accounts. It would be much better to store all wallet accounts in the db using the `wallet` flag, however status-go did not do this, reserving that flag for the root wallet account and creating a unique db constraint on that column.
2021-07-22 12:19:57 +10:00
Michael Bradley, Jr faa16c2078 build: switch from MSYS2 MINGW64 to MSYS2 UCRT64
Gives better compatibility at compile and runtime, and notably better
performance re: e.g. disk IO.
2021-07-18 23:19:39 -05:00
Michael Bradley, Jr 185edf73e1 refactor: import task_runner from vendor and remove task_runnner modules under examples/chat 2021-07-18 23:19:15 -05:00