mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-17 20:24:21 +01:00
wasm: export browser package already initialized and cleanup to example (#245)
* refactor sdk wasm * remove example go.mod * go work sync * revert default port change
This commit is contained in:
@@ -4,13 +4,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
inmemorystore "github.com/ark-network/ark/pkg/client-sdk/store/inmemory"
|
||||
"github.com/ark-network/ark/pkg/client-sdk/wasm/browser"
|
||||
)
|
||||
|
||||
func main() {
|
||||
c := make(chan struct{}, 0)
|
||||
var (
|
||||
ctx = context.Background()
|
||||
)
|
||||
store, err := browser.NewLocalStorageStore()
|
||||
if err != nil {
|
||||
browser.ConsoleError(err)
|
||||
return
|
||||
}
|
||||
if store != nil {
|
||||
if err := browser.NewCovenantlessClient(ctx, store); err != nil {
|
||||
browser.ConsoleError(err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
storeSvc, err := inmemorystore.NewConfigStore()
|
||||
if err != nil {
|
||||
browser.ConsoleError(err)
|
||||
return
|
||||
}
|
||||
if err := browser.NewCovenantlessClient(ctx, storeSvc); err != nil {
|
||||
browser.ConsoleError(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
println("ARK SDK WebAssembly module initialized")
|
||||
browser.InitWrapper()
|
||||
<-c
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user