Commit Graph

41 Commits

Author SHA1 Message Date
Michael Bradley, Jr da2d335b4b feat: introduce a module for nim-status/status-go hybrid procs 2021-02-05 12:08:09 -06:00
Michael Bradley, Jr 89706420d4 test: refactor tests so they can all be compiled and run in one pass
Make consistent use of the "test helpers" `procSuite` and `asyncTest`.

A couple of test suites are presently disabled: `accounts` and
`login_and_logout`. Changes out of scope for this PR need to be introduced and
the tests need to be refactored accordingly.
2021-02-05 12:08:09 -06:00
Michael Bradley, Jr f57891970d feat: reorganize for clearer non-shim vs. shim entrypoints 2021-02-05 12:08:09 -06:00
Michael Bradley, Jr d08933a1c1
chore: delete executable that was accidentally committed 2021-01-26 15:07:10 -06:00
Michael Bradley, Jr 802792d757 refactor: organization of waku v2's types has changed 2021-01-19 17:16:07 -06:00
Vitaliy Vlasov 38ebc0403e feat: Add CRUD for pending_transactions 2021-01-07 19:41:56 -06:00
Vitaliy Vlasov 403cee385d feat: add muteChat/unmuteChat/blockContact 2021-01-07 18:49:04 -06:00
emizzle 28107dc6dd feat: dapp permissions CRUD
feat: add toDbValue that handles sequences, so we don't have to manually encode sequences to bytes.
2021-01-07 15:54:37 -06:00
Vitaliy Vlasov 121a29a086 Messages/Chats CRUD 2021-01-07 14:33:27 -06:00
Vitaliy Vlasov d559f70f23 Add accounts CRUD
Post-rebase adjustments

Fix test errors
2021-01-07 14:29:46 -06:00
Iuri Matias 983402d5fd feat: custom tokens CRUD 2021-01-06 08:24:28 -05:00
Jonathan Rainville f51abf3b83 feat: add function to sign a message 2021-01-05 13:12:25 -05:00
Jonathan Rainville cedbaa45b5 feat: add derive pub key function 2021-01-05 13:12:25 -05:00
Jonathan Rainville 034756b7b0 feat: add createAccount function to create a random account 2021-01-05 13:12:25 -05:00
emizzle 2bf3001894
feat: Add EnsVerificationRetries as a column in the DB 2021-01-05 11:49:00 -04:00
Richard Ramos 6605a5e608
feat: contacts
Contacts CRUD

fix: code review pt1
2021-01-05 11:48:55 -04:00
Iuri Matias 6ec7ae077a
Merge pull request #86 from status-im/feat/bip32
feat: bip32
2021-01-05 10:38:05 -05:00
Richard Ramos 02b80a7db8
test: eip1581 2021-01-05 09:42:36 -04:00
Richard Ramos 2ba3c35b96
feat: bip32 keys 2021-01-05 09:41:21 -04:00
Richard Ramos 50503194d2
fix: invalid network 2021-01-05 09:29:28 -04:00
Richard Ramos bcb3e6d5c8
fix: db initialization 2021-01-05 09:05:58 -04:00
Richard Ramos 4d88163de1
feat: open/close db connection and connect to web3 when calling a login()/logout() proc 2021-01-05 09:05:56 -04:00
Michael Bradley, Jr ab3f83f274 feat: mailservers CRUD 2020-12-22 15:20:20 -06:00
RichΛrd 5a5e7532d6
feat: migrations (#83)
* feat: migrations
* Verify if there are more migrations executed in the db than in the code
* fix - code review
* fix: missing text
* test: cat content of sql_scripts.nim
* fix: unwanted stdout/stderr in sql_scripts.nim

Co-authored-by: Michael Bradley, Jr <michaelsbradleyjr@gmail.com>
2020-12-22 16:24:58 -04:00
emizzle 5e36681002 fix: Change networks to seq[Network]
- Support serialization
- Add unit tests
2020-12-20 17:48:55 -06:00
emizzle 75a4a014ab feat: update to new apis 2020-12-20 17:48:55 -06:00
Michael Bradley, Jr a35c48e33d chore: bump nim-waku in vendor/ and adjust imports 2020-12-18 13:46:20 -06:00
RichΛrd f56f8834d2
feat: pass requests done via callRPC to infura (#114) 2020-12-04 17:35:35 -04:00
emizzle 76379b4125 feat: support column names
Support getting row data by column name.

fix: change intVal of 0 to false, combine bool type tests

fix: try forcing val to be read through toOption

feat: handle bool option conversion

feat: switch from using a custom `toOption` proc to using the `fromDbValue` procs defined in nim-sqlcipher. The `fromDbValue` overload that creates `Option[T]` was changed so that we can handle cases when we have null values for `sqliteText` and `sqliteInteger`.

Support typecasting a row (seq[DbColumn]) in to an object type.

Update to execQuery, remove need to cast row

chore: bump nim-sqlcipher
2020-11-26 12:05:28 +11:00
Richard Ramos 2a3599c94a fix: code review pt. 2 2020-11-26 11:49:43 +11:00
Richard Ramos 247ebd61a4 fix: code review pt.1 2020-11-26 11:49:43 +11:00
Richard Ramos c536ae205d feat: save settings 2020-11-26 11:49:43 +11:00
Richard Ramos a727016068 feat: createSettings and getSettings 2020-11-26 11:49:43 +11:00
Michael Bradley, Jr 1574a2a13a test: make the db_smoke test identical to the same test in the nim-sqlcipher repo 2020-11-19 07:54:47 -06:00
Michael Bradley, Jr e9785f0386 refactor: upgrade to waku v2, impl/test minimum viable usage 2020-11-18 14:18:37 -06:00
Michael Bradley, Jr b88f736a32 feat: integrate nim-sqlcipher 2020-11-18 13:34:24 -06:00
Michael Bradley, Jr 6f3998180e feat: introduce Nim impl of hashMessage in reorganized library
Introduce a Nim implementation of `hashMessage` situated in a reorganized
library with *Nim-oriented* and *C-oriented* entry points inspired by the
[shim strategy][shim-strat] suggested by @arnetheduck.

The goal of this approach (per @iurimatias, at least as I understood what was
discussed and tasked) is for Nim implementations of equivalent functionality to
eventually supersede existing [status-go][sgo] implementations.

These changes will benefit from feedback by @arnetheduck, @zah,
@stefantalpalaru, @siphiuel, other members of stimbus/desktop, et al. – my dev
experiences with Nim and C are quite limited to date. Some of the changes may
be problematic, unnecessary, suboptimal, etc. I may have reified the *"shim
strategy"* badly. Please shred this PR apart and lead me to the 💡
light. Thanks for your help!

N.B. `tests/nim/login.nim` and `tests/c/login.c` use loops that never
terminate (introduced prior to this PR). Future work will attempt to remedy
that shortcoming but it's out of scope for this PR.

The reorganized library can be grouped into two trees of `.nim` sources, but
note that `import` statements interlink some of them.

**Nim-oriented**
```
├── src
│   ├── nim_status
│   │   ├── go
│   │   │   └── shim.nim
│   │   ├── lib
│   │   │   ├── shim.nim
│   │   │   └── util.nim
│   │   ├── lib.nim
│   │   └── types.nim
│   └── nim_status.nim
```

**C-oriented**
```
├── src
│   ├── nim_status
│   │   ├── c
│   │   │   ├── go
│   │   │   │   └── shim.nim
│   │   │   ├── lib
│   │   │   │   └── shim.nim
│   │   │   ├── lib.nim
│   │   │   ├── nim_status.nim
│   │   │   └── sys.nim
```

The key difference between the Nim sources in one tree and the other is that
the Nim-oriented sources are intended to be consumed by other Nim
sources (e.g. [status-im/nim-status-client][nsc] via Nim's built-in `import`),
while the C-oriented sources are intended to be compiled to a C
library (e.g. `nim_status.a`) and then linked/called by other C code. To that
end, the former use e.g. `string` in call signatures while the latter use
`cstring`. Along the same lines, the C-oriented `proc`s may return pointers to
memory allocated with `c_malloc` such that it's up to the caller to free the
memory occupied by the return values.

Both `src/nim_status/go/shim.nim` and `src/nim_status/c/go/shim.nim` are pure
shims around status-go, the main difference being their call signatures.

With `src/nim_status/lib.nim` the intention is to implement functionality in a
manner independent of status-go's idioms.

In `src/nim_status/[c/]lib/shim.nim` the intention is to wrap around
`src/nim_status/lib.nim` in a way that preserves status-go's call signatures
and formatting. For example, the `hashMessage` proc introduced in this PR in
`src/nim_status/lib.nim` returns a hex string like `0xabcd...` while
`lib/shim.nim` returns JSON that's a match for status-go:
`{"result":"0xabcd..."}`.

Both `src/nim_status.nim` and `src/nim_status/c/nim_status.nim` represent a
hybrid of `go/shim.nim` and `lib/shim.nim`. Again, the goal is that over time
more and more `proc`s implemented in Nim replace the shims around status-go.

Callers that don't need to consume return values formatted according to
status-go conventions can use `lib.nim` directly, e.g. via `import
nim_status/lib` or by compiling `src/nim_status/c/lib.nim` and linking/calling
from C.

`c_malloc` has been copied (in `src/nim_status/c/sys.nim`) from the source of
Nim's `system/ansi_c` because `ansi_c` is an undocumented internal API.

A Nim template or pragma might be useful with respect to usgae of `c_malloc` in
`src/nim_status/c/*`, i.e. to cut down on repetition.

Use of `{.exportc.}` is limited to the `src/nim_status/c/nim_status.nim` hybrid
shim to avoid imposing exported symbols on C-oriented library consumers who may
wish to compose things in a different manner.

With respect to the Nim implementation of `hashMessage`, both Nim-oriented and
C-oriented tests have been implemented. Whether doubling up the tests is really
necessary/desirable for all `proc`s is probably worth discussing.

Adjust `.gitignore` and refactor `Makefile` accordingly; apply some lessons
learned while working on [status-im/nim-status-client][nsc].

Closes #34.

[shim-strat]: https://github.com/status-im/nim-status/issues/5#issuecomment-647497745
[sgo]: https://github.com/status-im/status-go
[nsc]: https://github.com/status-im/nim-status-client
2020-08-10 11:45:02 -05:00
Richard Ramos d007fdba2f
feat: add setup and teardown foreign thread gc functions and nim-tests target 2020-07-13 10:26:31 -04:00
Richard Ramos 93f3c08e19
chore: verify signalCallback can be used with a pointer to a function 2020-07-06 10:01:07 -04:00
Richard Ramos 2ae7d70f50
Adding missing functions 2020-07-02 15:54:45 -04:00
Richard Ramos 80d9d2c8b7
feat: build nim_status.a static library and create simple test file in C 2020-07-02 14:40:49 -04:00