Skip to content

Conversation

iurimatias
Copy link
Member

For now just 2 APIs, to learn the paint points, see if it works etc..

@iurimatias iurimatias requested a review from dlipicar September 4, 2025 19:49
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 0% with 77 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.44%. Comparing base (63a2607) to head (fa57fc1).

Files with missing lines Patch % Lines
cshared/lib.go 0.00% 77 Missing ⚠️
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              
Files with missing lines Coverage Δ
cshared/lib.go 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

}

//export GoWSK_NewClient
func GoWSK_NewClient(rpcURL *C.char, errOut **C.char) C.ulonglong {
Copy link
Collaborator

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
@dlipicar dlipicar changed the base branch from docs_specs to master September 10, 2025 12:37
@dlipicar dlipicar changed the base branch from master to ci/minor-improvements September 10, 2025 12:43
@dlipicar dlipicar requested a review from a team as a code owner September 10, 2025 12:43
@dlipicar dlipicar changed the base branch from ci/minor-improvements to master September 10, 2025 12:43
var (
clientsMutex sync.RWMutex
nextHandle uint64 = 1
clients = map[uint64]*sdkethclient.Client{}

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())
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants