From efe2790db6cf5e3f01d4b3265d2a671fed70e2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rich=CE=9Brd?= Date: Fri, 10 Sep 2021 11:29:10 -0400 Subject: [PATCH] feat: dynamic library - pt1 (#9) * feat: statuslib dynamic library * fix: library versions --- .gitignore | 3 + .gitmodules | 87 ++++++++++++++++ Makefile | 130 ++++++++++++++++++++++++ build/.gitignore | 2 + status/accounts.nim | 4 +- status/constants.nim | 7 -- status/libstatus/accounts.nim | 14 +-- status/libstatus/accounts/constants.nim | 43 ++------ status/status.nim | 38 +++++-- status/wallet.nim | 8 +- status/wallet2.nim | 8 +- statuslib.nim | 6 ++ test/main.c | 21 ++++ vendor/edn.nim | 1 + vendor/isaac | 1 + vendor/nbaser | 1 + vendor/news | 1 + vendor/nim-base32 | 1 + vendor/nim-bearssl | 1 + vendor/nim-chronicles | 1 + vendor/nim-chronos | 1 + vendor/nim-confutils | 1 + vendor/nim-eth | 1 + vendor/nim-faststreams | 1 + vendor/nim-http-utils | 1 + vendor/nim-json-rpc | 1 + vendor/nim-json-serialization | 1 + vendor/nim-libp2p | 1 + vendor/nim-metrics | 1 + vendor/nim-secp256k1 | 1 + vendor/nim-serialization | 1 + vendor/nim-status-go | 1 + vendor/nim-stew | 1 + vendor/nim-stint | 1 + vendor/nim-task-runner | 1 + vendor/nim-web3 | 1 + vendor/nim-websock | 1 + vendor/nim-zlib | 1 + vendor/nimbus-build-system | 1 + vendor/nimcrypto | 1 + vendor/status-go | 1 + vendor/uuids | 1 + 42 files changed, 332 insertions(+), 68 deletions(-) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Makefile create mode 100644 build/.gitignore create mode 100644 statuslib.nim create mode 100644 test/main.c create mode 160000 vendor/edn.nim create mode 160000 vendor/isaac create mode 160000 vendor/nbaser create mode 160000 vendor/news create mode 160000 vendor/nim-base32 create mode 160000 vendor/nim-bearssl create mode 160000 vendor/nim-chronicles create mode 160000 vendor/nim-chronos create mode 160000 vendor/nim-confutils create mode 160000 vendor/nim-eth create mode 160000 vendor/nim-faststreams create mode 160000 vendor/nim-http-utils create mode 160000 vendor/nim-json-rpc create mode 160000 vendor/nim-json-serialization create mode 160000 vendor/nim-libp2p create mode 160000 vendor/nim-metrics create mode 160000 vendor/nim-secp256k1 create mode 160000 vendor/nim-serialization create mode 160000 vendor/nim-status-go create mode 160000 vendor/nim-stew create mode 160000 vendor/nim-stint create mode 160000 vendor/nim-task-runner create mode 160000 vendor/nim-web3 create mode 160000 vendor/nim-websock create mode 160000 vendor/nim-zlib create mode 160000 vendor/nimbus-build-system create mode 160000 vendor/nimcrypto create mode 160000 vendor/status-go create mode 160000 vendor/uuids diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12ecdcb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.update.timestamp +nimcache +vendor/.nimble diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..2e427f3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,87 @@ +[submodule "vendor/nimbus-build-system"] + path = vendor/nimbus-build-system + url = https://github.com/status-im/nimbus-build-system +[submodule "vendor/status-go"] + path = vendor/status-go + url = https://github.com/status-im/status-go +[submodule "vendor/nimcrypto"] + path = vendor/nimcrypto + url = https://github.com/cheatfate/nimcrypto.git +[submodule "vendor/uuids"] + path = vendor/uuids + url = https://github.com/pragmagic/uuids.git +[submodule "vendor/isaac"] + path = vendor/isaac + url = https://github.com/pragmagic/isaac.git +[submodule "vendor/nim-json-serialization"] + path = vendor/nim-json-serialization + url = https://github.com/status-im/nim-json-serialization.git +[submodule "vendor/nim-serialization"] + path = vendor/nim-serialization + url = https://github.com/status-im/nim-serialization.git +[submodule "vendor/nim-stew"] + path = vendor/nim-stew + url = https://github.com/status-im/nim-stew.git +[submodule "vendor/nim-faststreams"] + path = vendor/nim-faststreams + url = https://github.com/status-im/nim-faststreams.git +[submodule "vendor/nim-chronicles"] + path = vendor/nim-chronicles + url = https://github.com/status-im/nim-chronicles.git +[submodule "vendor/nim-status-go"] + path = vendor/nim-status-go + url = https://github.com/status-im/nim-status-go.git +[submodule "vendor/nim-stint"] + path = vendor/nim-stint + url = https://github.com/status-im/nim-stint.git +[submodule "vendor/nim-web3"] + path = vendor/nim-web3 + url = https://github.com/status-im/nim-web3.git +[submodule "vendor/nim-http-utils"] + path = vendor/nim-http-utils + url = https://github.com/status-im/nim-http-utils +[submodule "vendor/nim-chronos"] + path = vendor/nim-chronos + url = https://github.com/status-im/nim-chronos.git +[submodule "vendor/nim-json-rpc"] + path = vendor/nim-json-rpc + url = https://github.com/status-im/nim-json-rpc +[submodule "vendor/news"] + path = vendor/news + url = https://github.com/Tormund/news +[submodule "vendor/nim-websock"] + path = vendor/nim-websock + url = https://github.com/status-im/nim-websock +[submodule "vendor/nim-bearssl"] + path = vendor/nim-bearssl + url = https://github.com/status-im/nim-bearssl +[submodule "vendor/nim-zlib"] + path = vendor/nim-zlib + url = https://github.com/status-im/nim-zlib +[submodule "vendor/nim-eth"] + path = vendor/nim-eth + url = https://github.com/status-im/nim-eth +[submodule "vendor/nim-secp256k1"] + path = vendor/nim-secp256k1 + url = https://github.com/status-im/nim-secp256k1 +[submodule "vendor/nim-metrics"] + path = vendor/nim-metrics + url = https://github.com/status-im/nim-metrics +[submodule "vendor/nim-confutils"] + path = vendor/nim-confutils + url = https://github.com/status-im/nim-confutils.git +[submodule "vendor/nim-libp2p"] + path = vendor/nim-libp2p + url = https://github.com/status-im/nim-libp2p +[submodule "vendor/nim-task-runner"] + path = vendor/nim-task-runner + url = https://github.com/status-im/nim-task-runner.git +[submodule "vendor/nbaser"] + path = vendor/nbaser + url = https://github.com/D-Nice/nbaser/ +[submodule "vendor/nim-base32"] + path = vendor/nim-base32 + url = https://github.com/elktree/nim-base32 +[submodule "vendor/edn.nim"] + path = vendor/edn.nim + url = https://github.com/status-im/edn.nim diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c8f4e3b --- /dev/null +++ b/Makefile @@ -0,0 +1,130 @@ +# Copyright (c) 2021 Status Research & Development GmbH. Licensed under +# either of: +# - Apache License, version 2.0 +# - MIT license +# at your option. This file may not be copied, modified, or distributed except +# according to those terms. + +SHELL := bash # the shell used internally by Make + +# used inside the included makefiles +BUILD_SYSTEM_DIR := vendor/nimbus-build-system + +# we don't want an error here, so we can handle things later, in the ".DEFAULT" target +-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk + +.PHONY: \ + all \ + bottles \ + clean \ + deps \ + libstatuslib \ + status-go \ + update \ + build_ctest \ + ctest + +ifeq ($(NIM_PARAMS),) +# "variables.mk" was not included, so we update the submodules. +GIT_SUBMODULE_UPDATE := git submodule update --init --recursive +.DEFAULT: + +@ echo -e "Git submodules not found. Running '$(GIT_SUBMODULE_UPDATE)'.\n"; \ + $(GIT_SUBMODULE_UPDATE); \ + echo +# Now that the included *.mk files appeared, and are newer than this file, Make will restart itself: +# https://www.gnu.org/software/make/manual/make.html#Remaking-Makefiles +# +# After restarting, it will execute its original goal, so we don't have to start a child Make here +# with "$(MAKE) $(MAKECMDGOALS)". Isn't hidden control flow great? + +else # "variables.mk" was included. Business as usual until the end of this file. + +all: libstatuslib + +# must be included after the default target +-include $(BUILD_SYSTEM_DIR)/makefiles/targets.mk + +ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10... + detected_OS := Windows +else + detected_OS := $(strip $(shell uname)) +endif + +ifeq ($(detected_OS),Darwin) + CFLAGS := -mmacosx-version-min=10.14 + export CFLAGS + CGO_CFLAGS := -mmacosx-version-min=10.14 + export CGO_CFLAGS + LIBSTATUS_EXT := dylib + MACOSX_DEPLOYMENT_TARGET := 10.14 + export MACOSX_DEPLOYMENT_TARGET +else ifeq ($(detected_OS),Windows) + LIBSTATUS_EXT := dll +else + LIBSTATUS_EXT := so +endif + + +ifeq ($(detected_OS),Darwin) +bottles/openssl: + ./scripts/fetch-brew-bottle.sh openssl + +bottles/pcre: bottles/openssl + ./scripts/fetch-brew-bottle.sh pcre + +bottles: bottles/openssl bottles/pcre +endif + +deps: | deps-common bottles + +update: | update-common + + +RELEASE ?= false +ifeq ($(RELEASE),false) + # We need `-d:debug` to get Nim's default stack traces + NIM_PARAMS += -d:debug + # Enable debugging symbols in DOtherSide, in case we need GDB backtraces + CFLAGS += -g + CXXFLAGS += -g +else + # Additional optimization flags for release builds are not included at present; + # adding them will involve refactoring config.nims in the root of this repo + NIM_PARAMS += -d:release +endif + +NIM_PARAMS += --outdir:./build + +STATUSGO := vendor/status-go/build/bin/libstatus.$(LIBSTATUS_EXT) +STATUSGO_LIBDIR := $(shell pwd)/$(shell dirname "$(STATUSGO)") +export STATUSGO_LIBDIR + +status-go: $(STATUSGO) +$(STATUSGO): | deps + echo -e $(BUILD_MSG) "status-go" + + cd vendor/status-go && \ + $(MAKE) statusgo-shared-library $(HANDLE_OUTPUT) + +libstatuslib: | $(STATUSGO) + echo -e $(BUILD_MSG) "$@" && \ + $(ENV_SCRIPT) nim c $(NIM_PARAMS) $(NIM_EXTRA_PARAMS) -o:build/$@.$(LIBSTATUS_EXT).0 -d:ssl --app:lib --noMain --header --nimcache:nimcache/libstatuslib statuslib.nim && \ + rm -f build/$@.$(LIBSTATUS_EXT) && \ + ln -s $@.$(LIBSTATUS_EXT).0 build/$@.so && \ + cp nimcache/libstatuslib/*.h build/. && \ + [[ $$? = 0 ]] + +# libraries for dynamic linking of non-Nim objects +EXTRA_LIBS_DYNAMIC := -L"$(CURDIR)/build" -lstatuslib -lm -L"$(STATUSGO_LIBDIR)" -lstatus +build_ctest: | libstatuslib build deps + echo -e $(BUILD_MSG) "build/ctest" && \ + $(CC) test/main.c -Wl,-rpath,'$$ORIGIN' -I./vendor/nimbus-build-system/vendor/Nim/lib $(EXTRA_LIBS_DYNAMIC) -g -o build/ctest + +ctest: | build_ctest + echo -e "Running ctest:" && \ + LD_LIBRARY_PATH="$(STATUSGO_LIBDIR)" \ + ./build/ctest + +clean: | clean-common + rm -rf bin/* node_modules bottles/* pkg/* tmp/* $(STATUSGO) + +endif # "variables.mk" was not included diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..d6b7ef3 --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/status/accounts.nim b/status/accounts.nim index f74ca80..e05d708 100644 --- a/status/accounts.nim +++ b/status/accounts.nim @@ -25,8 +25,8 @@ proc generateAddresses*(self: AccountModel): seq[GeneratedAccount] = self.generatedAddresses.add(account) result = self.generatedAddresses -proc openAccounts*(self: AccountModel): seq[NodeAccount] = - result = status_accounts.openAccounts() +proc openAccounts*(self: AccountModel, statusGoDir: string): seq[NodeAccount] = + result = status_accounts.openAccounts(statusGoDir) proc login*(self: AccountModel, selectedAccountIndex: int, password: string): NodeAccount = let currentNodeAccount = self.nodeAccounts[selectedAccountIndex] diff --git a/status/constants.nim b/status/constants.nim index b356974..64ff1ee 100644 --- a/status/constants.nim +++ b/status/constants.nim @@ -1,11 +1,4 @@ import libstatus/accounts/constants -export OPENURI -export DATADIR -export STATUSGODIR -export KEYSTOREDIR -export TMPDIR -export LOGDIR - const APP_UPDATES_ENS* = "desktop.status.eth" const CHECK_VERSION_TIMEOUT_MS* = 5000 diff --git a/status/libstatus/accounts.nim b/status/libstatus/accounts.nim index dc208c6..999bb03 100644 --- a/status/libstatus/accounts.nim +++ b/status/libstatus/accounts.nim @@ -58,10 +58,10 @@ proc generateAlias*(publicKey: string): string = proc generateIdenticon*(publicKey: string): string = result = $status_go.identicon(publicKey) -proc initNode*() = - createDir(STATUSGODIR) - createDir(KEYSTOREDIR) - discard $status_go.initKeystore(KEYSTOREDIR) +proc initNode*(statusGoDir, keystoreDir: string) = + createDir(statusGoDir) + createDir(keystoreDir) + discard $status_go.initKeystore(keystoreDir) proc parseIdentityImage*(images: JsonNode): IdentityImage = result = IdentityImage() @@ -73,7 +73,7 @@ proc parseIdentityImage*(images: JsonNode): IdentityImage = elif (image["type"].getStr == "large"): result.large = image["uri"].getStr -proc openAccounts*(): seq[NodeAccount] = +proc openAccounts*(STATUSGODIR: string): seq[NodeAccount] = let strNodeAccounts = status_go.openAccounts(STATUSGODIR).parseJson # FIXME fix serialization result = @[] @@ -226,9 +226,9 @@ proc loadAccount*(address: string, password: string): GeneratedAccount = raise newException(StatusGoException, "Error loading wallet account: " & error) -proc verifyAccountPassword*(address: string, password: string): bool = +proc verifyAccountPassword*(address: string, password: string, keystoreDir: string): bool = let hashedPassword = hashPassword(password) - let verifyResult = $status_go.verifyAccountPassword(KEYSTOREDIR, address, hashedPassword) + let verifyResult = $status_go.verifyAccountPassword(keystoreDir, address, hashedPassword) let error = parseJson(verifyResult)["error"].getStr if error == "": diff --git a/status/libstatus/accounts/constants.nim b/status/libstatus/accounts/constants.nim index 3d13502..f01b8b8 100644 --- a/status/libstatus/accounts/constants.nim +++ b/status/libstatus/accounts/constants.nim @@ -1,9 +1,6 @@ import # std libs json, os, sequtils, strutils -import # vendor libs - confutils - const GENERATED* = "generated" const SEED* = "seed" const KEY* = "key" @@ -271,37 +268,13 @@ proc defaultDataDir(): string = targetDir absolutePath(joinPath(parentDir, "Status")) -type StatusDesktopConfig = object - dataDir* {. - defaultValue: defaultDataDir() - desc: "Status Desktop data directory" - abbr: "d" .}: string - uri* {. - defaultValue: "" - desc: "status-im:// URI to open a chat or other" - name: "uri" .}: string -# On macOS the first time when a user gets the "App downloaded from the -# internet" warning, and clicks the Open button, the OS passes a unique process -# serial number (PSN) as -psn_... command-line argument, which we remove before -# processing the arguments with nim-confutils. -# Credit: https://github.com/bitcoin/bitcoin/blame/b6e34afe9735faf97d6be7a90fafd33ec18c0cbb/src/util/system.cpp#L383-L389 +proc ensureDirectories*(dataDir, tmpDir, logDir: string) = + createDir(dataDir) + createDir(tmpDir) + createDir(logDir) -var cliParams = commandLineParams() -if defined(macosx): - cliParams.keepIf(proc(p: string): bool = not p.startsWith("-psn_")) - -let desktopConfig = StatusDesktopConfig.load(cliParams) - -let - baseDir = absolutePath(expandTilde(desktopConfig.dataDir)) - OPENURI* = desktopConfig.uri - DATADIR* = baseDir & sep - STATUSGODIR* = joinPath(baseDir, "data") & sep - KEYSTOREDIR* = joinPath(baseDir, "data", "keystore") & sep - TMPDIR* = joinPath(baseDir, "tmp") & sep - LOGDIR* = joinPath(baseDir, "logs") & sep - -createDir(DATADIR) -createDir(TMPDIR) -createDir(LOGDIR) +# C Helpers +# ============================================================================== +proc ensureDirectories*(dataDir, tmpDir, logDir: cstring) {.exportc, dynlib.} = + ensureDirectories($dataDir, $tmpDir, $logDir) diff --git a/status/status.nim b/status/status.nim index cef1dd3..044c934 100644 --- a/status/status.nim +++ b/status/status.nim @@ -9,7 +9,7 @@ import ./types/[setting] export chat, accounts, node, messages, contacts, profile, network, permissions, fleet, eventemitter -type Status* = ref object +type Status* = ref object events*: EventEmitter fleet*: FleetModel chat*: ChatModel @@ -53,13 +53,13 @@ proc newStatusInstance*(fleetConfig: string): Status = result.provider = provider.newProviderModel(result.events, result.permissions) result.osnotifications = newOsNotifications(result.events) -proc initNode*(self: Status) = - libstatus_accounts.initNode() +proc initNode*(self: Status, statusGoDir, keystoreDir: string) = + libstatus_accounts.initNode(statusGoDir, keystoreDir) -proc startMessenger*(self: Status) = +proc startMessenger*(self: Status) {.exportc, dynlib.} = libstatus_core.startMessenger() -proc reset*(self: Status) = +proc reset*(self: Status) {.exportc, dynlib.} = # TODO: remove this once accounts are not tracked in the AccountsModel self.accounts.reset() @@ -71,19 +71,39 @@ proc reset*(self: Status) = # TODO: add all resets here -proc getNodeVersion*(self: Status): string = +proc getNodeVersion*(self: Status): string {.exportc, dynlib.} = libstatus_settings.getWeb3ClientVersion() # TODO: duplicated?? proc saveSetting*(self: Status, setting: Setting, value: string | bool) = discard libstatus_settings.saveSetting(setting, value) -proc getBloomFilter*(self: Status): string = +proc getBloomFilter*(self: Status): string {.exportc, dynlib.} = result = libstatus_core.getBloomFilter() -proc getBloomFilterBitsSet*(self: Status): int = +proc getBloomFilterBitsSet*(self: Status): int {.exportc, dynlib.} = let bloomFilter = libstatus_core.getBloomFilter() var bitCount = 0; for b in hexToSeqByte(bloomFilter): bitCount += countSetBits(b) - return bitCount \ No newline at end of file + return bitCount + +# C Helpers +# ============================================================================== +# This creates extra functions with a simpler API for C interop. This is to avoid +# having to manually create nim strings, (we can use cstring) instead, and also +# because functions that accept more than one type for the same parameter are not +# exported correctly + + +proc newStatusInstance*(fleetConfig: cstring): Status {.exportc, dynlib.} = + newStatusInstance($fleetConfig) + +proc initNode*(self: Status, statusGoDir, keystoreDir: cstring) {.exportc, dynlib.} = + self.initNode($statusGoDir, $keystoreDir) + +proc saveStringSetting*(self: Status, setting: Setting, value: cstring) {.exportc, dynlib.} = + self.saveSetting(setting, $value) + +proc saveBoolSetting*(self: Status, setting: Setting, value: bool) {.exportc, dynlib.} = + self.saveSetting(setting, value) \ No newline at end of file diff --git a/status/wallet.nim b/status/wallet.nim index 445ba2b..753b397 100644 --- a/status/wallet.nim +++ b/status/wallet.nim @@ -281,24 +281,24 @@ proc generateNewAccount*(self: WalletModel, password: string, accountName: strin if statusGoResult.error != "": error "Error storing the latest wallet index", msg=statusGoResult.error -proc addAccountsFromSeed*(self: WalletModel, seed: string, password: string, accountName: string, color: string) = +proc addAccountsFromSeed*(self: WalletModel, seed: string, password: string, accountName: string, color: string, keystoreDir: string) = let mnemonic = replace(seed, ',', ' ') var generatedAccount = status_accounts.multiAccountImportMnemonic(mnemonic) generatedAccount.derived = status_accounts.deriveAccounts(generatedAccount.id) let defaultAccount = status_accounts.getDefaultAccount() - isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password) + isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password, keystoreDir) if not isPasswordOk: raise newException(StatusGoException, "Error generating new account: invalid password") self.addNewGeneratedAccount(generatedAccount, password, accountName, color, constants.SEED) -proc addAccountsFromPrivateKey*(self: WalletModel, privateKey: string, password: string, accountName: string, color: string) = +proc addAccountsFromPrivateKey*(self: WalletModel, privateKey: string, password: string, accountName: string, color: string, keystoreDir: string) = let generatedAccount = status_accounts.MultiAccountImportPrivateKey(privateKey) defaultAccount = status_accounts.getDefaultAccount() - isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password) + isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password, keystoreDir) if not isPasswordOk: raise newException(StatusGoException, "Error generating new account: invalid password") diff --git a/status/wallet2.nim b/status/wallet2.nim index 50f2cd9..809308c 100644 --- a/status/wallet2.nim +++ b/status/wallet2.nim @@ -158,24 +158,24 @@ proc generateNewAccount*(self: StatusWalletController, password: string, account if statusGoResult.error != "": error "Error storing the latest wallet index", msg=statusGoResult.error -proc addAccountsFromSeed*(self: StatusWalletController, seed: string, password: string, accountName: string, color: string) = +proc addAccountsFromSeed*(self: StatusWalletController, seed: string, password: string, accountName: string, color: string, keystoreDir: string) = let mnemonic = replace(seed, ',', ' ') var generatedAccount = status_accounts.multiAccountImportMnemonic(mnemonic) generatedAccount.derived = status_accounts.deriveAccounts(generatedAccount.id) let defaultAccount = status_accounts.getDefaultAccount() - isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password) + isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password, keystoreDir) if not isPasswordOk: raise newException(StatusGoException, "Error generating new account: invalid password") self.addNewGeneratedAccount(generatedAccount, password, accountName, color, constants.SEED) -proc addAccountsFromPrivateKey*(self: StatusWalletController, privateKey: string, password: string, accountName: string, color: string) = +proc addAccountsFromPrivateKey*(self: StatusWalletController, privateKey: string, password: string, accountName: string, color: string, keystoreDir: string) = let generatedAccount = status_accounts.MultiAccountImportPrivateKey(privateKey) defaultAccount = status_accounts.getDefaultAccount() - isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password) + isPasswordOk = status_accounts.verifyAccountPassword(defaultAccount, password, keystoreDir) if not isPasswordOk: raise newException(StatusGoException, "Error generating new account: invalid password") diff --git a/statuslib.nim b/statuslib.nim new file mode 100644 index 0000000..b3cec96 --- /dev/null +++ b/statuslib.nim @@ -0,0 +1,6 @@ +# TODO: Import all the files that contain {.exportc.} +import status/status + +proc helloWorld() {.exportc, dynlib.} = + echo "hello world" + diff --git a/test/main.c b/test/main.c new file mode 100644 index 0000000..eebe403 --- /dev/null +++ b/test/main.c @@ -0,0 +1,21 @@ +#include +#include + +#include "../build/statuslib.h" + +void NimMain(); + +int main(int argc, char *argv[]) +{ + NimMain(); + + helloWorld(); + + ensureDirectories("./build/A", "./build/B", "./build/C"); + + char fleetConfigStr[] = "{\"fleets\":{\"eth.prod\":{\"boot\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"enode://6e6554fb3034b211398fcd0f0082cbb6bd13619e1a7e76ba66e1809aaa0c5f1ac53c9ae79cf2fd4a7bacb10d12010899b370c75fed19b991d9c0cdd02891abad@47.75.99.169:443\"},\"mail\":{\"mail-01.ac-cn-hongkong-c.eth.prod\":\"enode://606ae04a71e5db868a722c77a21c8244ae38f1bd6e81687cc6cfe88a3063fa1c245692232f64f45bd5408fed5133eab8ed78049332b04f9c110eac7f71c1b429@47.75.247.214:443\"},\"rendezvous\":{\"boot-01.ac-cn-hongkong-c.eth.prod\":\"/ip4/47.75.99.169/tcp/30703/ethv4/16Uiu2HAmV8Hq9e3zm9TMVP4zrVHo3BjqW5D6bDVV6VQntQd687e4\"},\"whisper\":{\"node-01.ac-cn-hongkong-c.eth.prod\":\"enode://b957e51f41e4abab8382e1ea7229e88c6e18f34672694c6eae389eac22dab8655622bbd4a08192c321416b9becffaab11c8e2b7a5d0813b922aa128b82990dab@47.75.222.178:443\"}}},\"meta\":{\"hostname\":\"node-01.do-ams3.proxy.misc\",\"timestamp\":\"2021-09-09T00:00:14.760436\"}}"; + void *statusObj = newStatusInstance(fleetConfigStr); + + initNode(statusObj, "./build/A", "./build/B"); + +} \ No newline at end of file diff --git a/vendor/edn.nim b/vendor/edn.nim new file mode 160000 index 0000000..3305e41 --- /dev/null +++ b/vendor/edn.nim @@ -0,0 +1 @@ +Subproject commit 3305e41f9da3f2f21c56bd23b74b0a3589f3bf3e diff --git a/vendor/isaac b/vendor/isaac new file mode 160000 index 0000000..45a5cbb --- /dev/null +++ b/vendor/isaac @@ -0,0 +1 @@ +Subproject commit 45a5cbbd54ff59ba3ed94242620c818b9aad1b5b diff --git a/vendor/nbaser b/vendor/nbaser new file mode 160000 index 0000000..0c989e0 --- /dev/null +++ b/vendor/nbaser @@ -0,0 +1 @@ +Subproject commit 0c989e0d9580b4a6c14e11976dba3a0d503ecfcd diff --git a/vendor/news b/vendor/news new file mode 160000 index 0000000..e1d6356 --- /dev/null +++ b/vendor/news @@ -0,0 +1 @@ +Subproject commit e1d63564a2a411f264e75694b8f7c66e50c3a4cb diff --git a/vendor/nim-base32 b/vendor/nim-base32 new file mode 160000 index 0000000..660680c --- /dev/null +++ b/vendor/nim-base32 @@ -0,0 +1 @@ +Subproject commit 660680c1cbdf6b1294b669fdb8b6e9c89794cb5b diff --git a/vendor/nim-bearssl b/vendor/nim-bearssl new file mode 160000 index 0000000..dc62f4f --- /dev/null +++ b/vendor/nim-bearssl @@ -0,0 +1 @@ +Subproject commit dc62f4fccd2d40c884009ae8f2b14bb6a86a55cf diff --git a/vendor/nim-chronicles b/vendor/nim-chronicles new file mode 160000 index 0000000..fc3f2d3 --- /dev/null +++ b/vendor/nim-chronicles @@ -0,0 +1 @@ +Subproject commit fc3f2d3755e035387ebcf20d87a45eb9dcefadbb diff --git a/vendor/nim-chronos b/vendor/nim-chronos new file mode 160000 index 0000000..bce0f87 --- /dev/null +++ b/vendor/nim-chronos @@ -0,0 +1 @@ +Subproject commit bce0f878d16bea14395dc8944ff8dbdeffe33496 diff --git a/vendor/nim-confutils b/vendor/nim-confutils new file mode 160000 index 0000000..7176de4 --- /dev/null +++ b/vendor/nim-confutils @@ -0,0 +1 @@ +Subproject commit 7176de4ddb3a628a5c3abfcd430010bf0229deb1 diff --git a/vendor/nim-eth b/vendor/nim-eth new file mode 160000 index 0000000..3ddb498 --- /dev/null +++ b/vendor/nim-eth @@ -0,0 +1 @@ +Subproject commit 3ddb498f2a41e1e470d780757faeedc0b8cb3a21 diff --git a/vendor/nim-faststreams b/vendor/nim-faststreams new file mode 160000 index 0000000..d3ef34b --- /dev/null +++ b/vendor/nim-faststreams @@ -0,0 +1 @@ +Subproject commit d3ef34b325eafca43405ee2b8390e1b6f218b644 diff --git a/vendor/nim-http-utils b/vendor/nim-http-utils new file mode 160000 index 0000000..33d70b9 --- /dev/null +++ b/vendor/nim-http-utils @@ -0,0 +1 @@ +Subproject commit 33d70b9f378591e074838d6608a4468940137357 diff --git a/vendor/nim-json-rpc b/vendor/nim-json-rpc new file mode 160000 index 0000000..dff46c9 --- /dev/null +++ b/vendor/nim-json-rpc @@ -0,0 +1 @@ +Subproject commit dff46c991d8ff533991ce9ae7fbeda07f18e6956 diff --git a/vendor/nim-json-serialization b/vendor/nim-json-serialization new file mode 160000 index 0000000..1dccd4b --- /dev/null +++ b/vendor/nim-json-serialization @@ -0,0 +1 @@ +Subproject commit 1dccd4b2ef14c5e3ce30ad3f3a0962e0b98da6a3 diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p new file mode 160000 index 0000000..70deac9 --- /dev/null +++ b/vendor/nim-libp2p @@ -0,0 +1 @@ +Subproject commit 70deac9e0d16f7d00a0d4404ed191042dbf079be diff --git a/vendor/nim-metrics b/vendor/nim-metrics new file mode 160000 index 0000000..f91deb7 --- /dev/null +++ b/vendor/nim-metrics @@ -0,0 +1 @@ +Subproject commit f91deb74228ecb14fb82575e4d0f387ad9732b8a diff --git a/vendor/nim-secp256k1 b/vendor/nim-secp256k1 new file mode 160000 index 0000000..fb96997 --- /dev/null +++ b/vendor/nim-secp256k1 @@ -0,0 +1 @@ +Subproject commit fb9699702b44f194b5926c8ab4a004cff676b435 diff --git a/vendor/nim-serialization b/vendor/nim-serialization new file mode 160000 index 0000000..474bdbf --- /dev/null +++ b/vendor/nim-serialization @@ -0,0 +1 @@ +Subproject commit 474bdbf49cf1634ba504888ad1a1927a2703bd3f diff --git a/vendor/nim-status-go b/vendor/nim-status-go new file mode 160000 index 0000000..b60faf9 --- /dev/null +++ b/vendor/nim-status-go @@ -0,0 +1 @@ +Subproject commit b60faf96449cb9ba9c6494abf7a3fcbaa7849c17 diff --git a/vendor/nim-stew b/vendor/nim-stew new file mode 160000 index 0000000..1db43c7 --- /dev/null +++ b/vendor/nim-stew @@ -0,0 +1 @@ +Subproject commit 1db43c7234acb9554e3e80bf2e7b61c4cf0435cf diff --git a/vendor/nim-stint b/vendor/nim-stint new file mode 160000 index 0000000..9e49b00 --- /dev/null +++ b/vendor/nim-stint @@ -0,0 +1 @@ +Subproject commit 9e49b00148884a01d61478ae5d2c69b543b93ceb diff --git a/vendor/nim-task-runner b/vendor/nim-task-runner new file mode 160000 index 0000000..a87f3f8 --- /dev/null +++ b/vendor/nim-task-runner @@ -0,0 +1 @@ +Subproject commit a87f3f85be052fb3332358f95079a059cf1daf15 diff --git a/vendor/nim-web3 b/vendor/nim-web3 new file mode 160000 index 0000000..bf6805d --- /dev/null +++ b/vendor/nim-web3 @@ -0,0 +1 @@ +Subproject commit bf6805dff9f5e2f5dfc4d5e3cb3f8c076caae849 diff --git a/vendor/nim-websock b/vendor/nim-websock new file mode 160000 index 0000000..f354dfe --- /dev/null +++ b/vendor/nim-websock @@ -0,0 +1 @@ +Subproject commit f354dfebe9f45ba33e6ad3b6f3163d516c9d0727 diff --git a/vendor/nim-zlib b/vendor/nim-zlib new file mode 160000 index 0000000..6bbc67d --- /dev/null +++ b/vendor/nim-zlib @@ -0,0 +1 @@ +Subproject commit 6bbc67d09e624d69052d62b2353878f491186942 diff --git a/vendor/nimbus-build-system b/vendor/nimbus-build-system new file mode 160000 index 0000000..6589ced --- /dev/null +++ b/vendor/nimbus-build-system @@ -0,0 +1 @@ +Subproject commit 6589cedffa2eb083f838d15c70c45ce000596859 diff --git a/vendor/nimcrypto b/vendor/nimcrypto new file mode 160000 index 0000000..30d0cea --- /dev/null +++ b/vendor/nimcrypto @@ -0,0 +1 @@ +Subproject commit 30d0ceaba02c0b966515f98873a0404786fbf796 diff --git a/vendor/status-go b/vendor/status-go new file mode 160000 index 0000000..07651d4 --- /dev/null +++ b/vendor/status-go @@ -0,0 +1 @@ +Subproject commit 07651d4d0696a2810666d49baaebcebc308c992a diff --git a/vendor/uuids b/vendor/uuids new file mode 160000 index 0000000..c5039c1 --- /dev/null +++ b/vendor/uuids @@ -0,0 +1 @@ +Subproject commit c5039c1cc6a8a93fc2f3c03a206372eb4412e63b