Skip to content

Commit

Permalink
wasm act working
Browse files Browse the repository at this point in the history
  • Loading branch information
asabya committed Nov 7, 2024
1 parent 7d60699 commit f079cea
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion pkg/dfs/act_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (a *API) OpenACTPod(sessionId, actName string) error {
if err != nil {
return err
}

info, err := ui.GetPod().ReceivePodInfo(utils.NewReference(addr.Bytes()))
if err != nil {
return err
Expand Down
11 changes: 5 additions & 6 deletions pkg/dfs/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ func NewDfsAPI(ctx context.Context, opts *Options) (*API, error) {
logger.Errorf("dfs: bee client initialisation failed")
return nil, errBeeClient
}
// Setting cache size 0 will disable the cache. This is to change the default behaviour of lru itself.
// We have this -1 check hard coded in the feed package. -1 will disable the feed pool off. and write directly to swarm.
if opts.FeedCacheSize == 0 {
opts.FeedCacheSize = -1
}
users := user.NewUsers(c, ens, opts.FeedCacheSize, opts.FeedCacheTTL, logger)

var sm subscriptionManager.SubscriptionManager
Expand All @@ -91,12 +96,6 @@ func NewDfsAPI(ctx context.Context, opts *Options) (*API, error) {
}
}

// Setting cache size 0 will disable the cache. This is to change the default behaviour of lru itself.
// We have this -1 check hard coded in the feed package. -1 will disable the feed pool off. and write directly to swarm.
if opts.FeedCacheSize == 0 {
opts.FeedCacheSize = -1
}

// discard tm logs as it creates too much noise
tmLogger := logging.New(io.Discard, 0)
ctx2, cancel := context.WithCancel(ctx)
Expand Down
1 change: 0 additions & 1 deletion pkg/dfs/pod_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ func (a *API) CreatePod(podName, sessionId string) (*pod.Info, error) {
if ui == nil {
return nil, ErrUserNotLoggedIn
}

// open the pod
pi, err := a.prepareOwnPod(ui, podName)
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/feed/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ retry:
}
return epoch, nil, err
}

return req.Epoch, address, nil
}

Expand Down
2 changes: 0 additions & 2 deletions pkg/pod/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ func (p *Pod) CreatePod(podName, addressString, podPassword string) (*Info, erro
if err != nil {
return nil, err
}

// check if pods is present and get free index
podList, err := p.PodList()
if err != nil { // skipcq: TCV-001
Expand All @@ -56,7 +55,6 @@ func (p *Pod) CreatePod(podName, addressString, podPassword string) (*Info, erro
for _, pod := range podList.SharedPods {
sharedPods[pod.Address] = pod.Name
}

var accountInfo *account.Info
var fd *feed.API
var file *f.File
Expand Down
8 changes: 7 additions & 1 deletion wasm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"strings"
"syscall/js"

"github.com/ethereum/go-ethereum/crypto"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/dustin/go-humanize"
"github.com/fairdatasociety/fairOS-dfs/pkg/act"
Expand Down Expand Up @@ -201,6 +203,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} {
EnsConfig: config,
SubscriptionConfig: subConfig,
Logger: logger,
FeedCacheSize: 0,
}
api, err = dfs.NewDfsAPI(
ctx,
Expand Down Expand Up @@ -294,7 +297,7 @@ func login(_ js.Value, funcArgs []js.Value) interface{} {
go func() {
loginResp, err := api.LoginUserV2(username, password, "")
if err != nil {
reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error()))
reject.Invoke(fmt.Sprintf("Failed to login : %s", err.Error()))
return
}
ui, nameHash := loginResp.UserInfo, loginResp.NameHash
Expand All @@ -303,6 +306,7 @@ func login(_ js.Value, funcArgs []js.Value) interface{} {
addr := ui.GetAccount().GetUserAccountInfo().GetAddress()
object.Set("address", addr.Hex())
object.Set("nameHash", nameHash)
object.Set("publicKey", hex.EncodeToString(crypto.FromECDSAPub(ui.GetAccount().GetUserAccountInfo().GetPublicKey())))
object.Set("sessionId", ui.GetSessionId())

resolve.Invoke(object)
Expand Down Expand Up @@ -343,6 +347,7 @@ func walletLogin(_ js.Value, funcArgs []js.Value) interface{} {
addr := ui.GetAccount().GetUserAccountInfo().GetAddress()
object.Set("address", addr.Hex())
object.Set("nameHash", nameHash)
object.Set("publicKey", hex.EncodeToString(crypto.FromECDSAPub(ui.GetAccount().GetUserAccountInfo().GetPublicKey())))
object.Set("sessionId", ui.GetSessionId())
resolve.Invoke(object)
}()
Expand Down Expand Up @@ -380,6 +385,7 @@ func signatureLogin(_ js.Value, funcArgs []js.Value) interface{} {
object := js.Global().Get("Object").New()
object.Set("user", ui.GetUserName())
object.Set("address", lr.Address)
object.Set("publicKey", lr.PublicKey)
object.Set("sessionId", ui.GetSessionId())
resolve.Invoke(object)
}()
Expand Down

0 comments on commit f079cea

Please sign in to comment.