-
Notifications
You must be signed in to change notification settings - Fork 0
feat(cshared/,examples/c-app): Support compiling wallet SDK as a C library #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## docs_specs #13 +/- ##
==============================================
- Coverage 19.64% 18.44% -1.21%
==============================================
Files 17 18 +1
Lines 1181 1258 +77
==============================================
Hits 232 232
- Misses 945 1022 +77
Partials 4 4
🚀 New features to boost your workflow:
|
fa57fc1
to
0efa824
Compare
} | ||
|
||
//export GoWSK_NewClient | ||
func GoWSK_NewClient(rpcURL *C.char, errOut **C.char) C.ulonglong { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably want to "namespace" our function names a bit more, call this something like GoWSK_ethclient_NewClient
…brary; add simple example feat(cshared/,examples/c-app): Support compiling wallet SDK as a C library; add simple example feat(cshared/,examples/c-app): Support compiling wallet SDK as a C library; add simple example initial attempt some fixes; docs more fixes fix linting errors
0efa824
to
de483fe
Compare
var ( | ||
clientsMutex sync.RWMutex | ||
nextHandle uint64 = 1 | ||
clients = map[uint64]*sdkethclient.Client{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't expect to have logic in this layer. Expected to have C bindings to expose wallet SDK functionality to a client. In that case, a client would take care of concurrency, storing ethcleints and so on.
for example:
func GoWSK_NewClient(rpcURL *C.char, errOut **C.char) C.uintptr_t {
if rpcURL == nil {
if errOut != nil {
*errOut = C.CString("rpcURL is NULL")
}
return 0
}
url := C.GoString(rpcURL)
rpcClient, err := gethrpc.Dial(url)
if err != nil {
if errOut != nil {
*errOut = C.CString(err.Error())
}
return 0
}
client := sdkethclient.NewClient(rpcClient)
h := cgo.NewHandle(client)
return C.uintptr_t(h)
}
func GoWSK_ChainID(handle C.uintptr_t, errOut **C.char) *C.char {
client := cgo.Handle(handle).Value().(*sdkethclient.Client)
id, err := client.EthChainId(context.Background())
if err != nil {
if errOut != nil {
*errOut = C.CString(err.Error())
}
return nil
}
return C.CString(id.String())
}
For now just 2 APIs, to learn the paint points, see if it works etc..