From 9f6d70d76f317ea2f2e71d3ef9b760135a064f72 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 8 Feb 2023 13:44:15 +0530 Subject: [PATCH 01/48] feat: pod subscription started --- pkg/pod/sharing.go | 2 +- pkg/pod/utils.go | 17 ++++ pkg/subscription/rpc/mock/rpc.go | 131 ++++++++++++++++++++++++++ pkg/subscription/rpc/rpc.go | 16 ++++ pkg/subscription/subscription.go | 77 +++++++++++++++ pkg/subscription/subscription_test.go | 71 ++++++++++++++ 6 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 pkg/subscription/rpc/mock/rpc.go create mode 100644 pkg/subscription/rpc/rpc.go create mode 100644 pkg/subscription/subscription.go create mode 100644 pkg/subscription/subscription_test.go diff --git a/pkg/pod/sharing.go b/pkg/pod/sharing.go index a788db21..058621d9 100644 --- a/pkg/pod/sharing.go +++ b/pkg/pod/sharing.go @@ -50,7 +50,7 @@ func (p *Pod) PodShare(podName, sharedPodName string) (string, error) { return "", fmt.Errorf("pod does not exist") } - // Create pod account and get the address + // Create pod account and get the address accountInfo, err := p.acc.CreatePodAccount(index, false) if err != nil { // skipcq: TCV-001 return "", err diff --git a/pkg/pod/utils.go b/pkg/pod/utils.go index 0e64d489..6ea7a61f 100644 --- a/pkg/pod/utils.go +++ b/pkg/pod/utils.go @@ -34,6 +34,23 @@ func (p *Pod) IsPodOpened(podName string) bool { return false } +// IsOwnPodPresent checks if a pod is already present for user +func (p *Pod) IsOwnPodPresent(podName string) bool { + podName, err := CleanPodName(podName) + if err != nil { + return false + } + // check if pods is present and get free index + podList, err := p.loadUserPods() + if err != nil { // skipcq: TCV-001 + return false + } + if p.checkIfPodPresent(podList, podName) { + return true + } + return false +} + // IsPodPresent checks if a pod is already present for user func (p *Pod) IsPodPresent(podName string) bool { podName, err := CleanPodName(podName) diff --git a/pkg/subscription/rpc/mock/rpc.go b/pkg/subscription/rpc/mock/rpc.go new file mode 100644 index 00000000..63a57259 --- /dev/null +++ b/pkg/subscription/rpc/mock/rpc.go @@ -0,0 +1,131 @@ +package mock + +import ( + "fmt" + "strings" + "sync" + + "github.com/ethereum/go-ethereum/common" +) + +type PodItem struct { + Name string `json:"name"` + Price uint64 `json:"price"` + Owner common.Address `json:"owner"` + IsListed bool `json:"isListed"` +} + +type requestInfo struct { + Name string `json:"name"` + Subscriber common.Address `json:"owner"` +} + +type SubscriptionManager struct { + lock sync.Mutex + listMap map[string]*PodItem + subscriptionMap map[string]*PodItem + requestMap map[string]requestInfo +} + +// NewMockSubscriptionManager returns a new mock subscription manager client +func NewMockSubscriptionManager() *SubscriptionManager { + return &SubscriptionManager{ + listMap: make(map[string]*PodItem), + subscriptionMap: make(map[string]*PodItem), + } +} + +func (s *SubscriptionManager) AddPodToMarketplace(owner common.Address, pod string, price uint64) error { + i := &PodItem{ + Name: pod, + Price: price, + Owner: owner, + IsListed: true, + } + s.lock.Lock() + defer s.lock.Unlock() + + s.listMap[owner.Hex()+pod] = i + + return nil +} + +func (s *SubscriptionManager) HidePodFromMarketplace(owner common.Address, pod string) error { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[owner.Hex()+pod] + if !ok { + return fmt.Errorf("pod not listed") + } + i.IsListed = false + return nil +} + +func (s *SubscriptionManager) RequestAccess(pod string, owner, subscriber common.Address) error { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[owner.Hex()+pod] + if !ok { + return fmt.Errorf("pod not listed") + } + if !i.IsListed { + return fmt.Errorf("pod not listed") + } + + s.requestMap[owner.Hex()+subscriber.Hex()+pod] = requestInfo{ + Name: pod, + Subscriber: subscriber, + } + return nil +} + +func (s *SubscriptionManager) AllowAccess(pod string, owner, subscriber common.Address) error { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[owner.Hex()+pod] + if !ok { + return fmt.Errorf("pod not listed") + } + if !i.IsListed { + return fmt.Errorf("pod not listed") + } + + _, ok = s.requestMap[owner.Hex()+subscriber.Hex()+pod] + if !ok { + return fmt.Errorf("request not available") + } + + s.subscriptionMap[subscriber.Hex()+pod] = i + + return nil +} + +func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*PodItem { + subscriberHex := subscriber.Hex() + pods := []*PodItem{} + for i, v := range s.subscriptionMap { + if strings.HasPrefix(i, subscriberHex) { + pods = append(pods, v) + } + } + return pods +} + +func (s *SubscriptionManager) GetAllSubscribablePods() []*PodItem { + pods := []*PodItem{} + for _, v := range s.listMap { + pods = append(pods, v) + } + return pods +} + +func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) []*PodItem { + ownerHex := owner.Hex() + pods := []*PodItem{} + for i, v := range s.listMap { + if strings.HasPrefix(i, ownerHex) { + pods = append(pods, v) + } + } + return pods +} diff --git a/pkg/subscription/rpc/rpc.go b/pkg/subscription/rpc/rpc.go new file mode 100644 index 00000000..dd021051 --- /dev/null +++ b/pkg/subscription/rpc/rpc.go @@ -0,0 +1,16 @@ +package rpc + +import ( + "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" +) + +type SubscriptionManager interface { + AddPodToMarketplace(owner common.Address, pod string, price uint64) error + HidePodFromMarketplace(owner common.Address, pod string) error + RequestAccess(pod string, owner, subscriber common.Address) error + AllowAccess(pod string, owner, subscriber common.Address) error + GetSubscriptions(subscriber common.Address) []*mock.PodItem + GetAllSubscribablePods() []*mock.PodItem + GetOwnSubscribablePods(owner common.Address) []*mock.PodItem +} diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go new file mode 100644 index 00000000..7f7bdecb --- /dev/null +++ b/pkg/subscription/subscription.go @@ -0,0 +1,77 @@ +package subscription + +import ( + "fmt" + + "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/ensm" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc" +) + +type Manager struct { + pod *pod.Pod + addr common.Address + ens ensm.ENSManager + + sm rpc.SubscriptionManager +} + +type PodItem struct { + Name string `json:"name"` + Price uint64 `json:"price"` + Owner string `json:"owner"` +} + +func New(pod *pod.Pod, addr common.Address, ensm ensm.ENSManager, sm rpc.SubscriptionManager) *Manager { + return &Manager{ + pod: pod, + addr: addr, + ens: ensm, + sm: sm, + } +} + +// ListPod will save the pod info in the subscription smart contract with its owner and price +// we keep the pod info in the smart contract, with a `list` flag +func (m *Manager) ListPod(podname string, price uint64) error { + if !m.pod.IsOwnPodPresent(podname) { + return fmt.Errorf("pod not present") + } + return m.sm.AddPodToMarketplace(m.addr, podname, price) +} + +// DelistPod will make the `list` flag false for the pod so that it's not listed in the pod marketplace +func (m *Manager) DelistPod(podname string) error { + return m.sm.HidePodFromMarketplace(m.addr, podname) +} + +// ApproveSubscription will send a subscription request to the owner of the pod +func (m *Manager) ApproveSubscription(podname string, subscriber string) error { + subscriberAddr, err := m.ens.GetOwner(subscriber) + if err != nil { + return err + } + return m.sm.AllowAccess(podname, m.addr, subscriberAddr) +} + +// RequestSubscription will send a subscription request to the owner of the pod +// will create an escrow account and deposit the `price` +func (m *Manager) RequestSubscription(pod string, owner string) error { + ownerAddr, err := m.ens.GetOwner(owner) + if err != nil { + return err + } + + return m.sm.RequestAccess(pod, ownerAddr, m.addr) +} + +func (*Manager) GetSubscriptions() ([]PodItem, error) { + // This will query the smart contract and list my subscriptions + return nil, nil +} + +func (*Manager) GetMarketplace() ([]PodItem, error) { + // This will query the smart contract make the `list` all the pod from the marketplace + return nil, nil +} diff --git a/pkg/subscription/subscription_test.go b/pkg/subscription/subscription_test.go new file mode 100644 index 00000000..d5082d02 --- /dev/null +++ b/pkg/subscription/subscription_test.go @@ -0,0 +1,71 @@ +package subscription_test + +import ( + "context" + "os" + "testing" + "time" + + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" + + "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/feed" + "github.com/fairdatasociety/fairOS-dfs/pkg/logging" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/plexsysio/taskmanager" + + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription" + rpcMock "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" +) + +func TestNew(t *testing.T) { + mockClient := mock.NewMockBeeClient() + ens := mock2.NewMockNamespaceManager() + + logger := logging.New(os.Stdout, 0) + acc := account.New(logger) + _, _, err := acc.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + fd := feed.New(acc.GetUserAccountInfo(), mockClient, logger) + tm := taskmanager.New(1, 10, time.Second*15, logger) + defer func() { + _ = tm.Stop(context.Background()) + }() + pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + addr := common.HexToAddress(acc.GetUserAccountInfo().GetAddress().Hex()) + sm := rpcMock.NewMockSubscriptionManager() + m := subscription.New(pod1, addr, ens, sm) + + randomLongPodName1, err := utils.GetRandString(64) + if err != nil { + t.Fatalf("error creating pod %s", randomLongPodName1) + } + err = m.ListPod(randomLongPodName1, 1) + if err == nil { + t.Fatal("pod should not be present") + } + + // check too long pod name + + podPassword, _ := utils.GetRandString(pod.PasswordLength) + _, err = pod1.CreatePod(randomLongPodName1, "", podPassword) + if err != nil { + t.Fatal(err) + } + + err = m.ListPod(randomLongPodName1, 1) + if err != nil { + t.Fatal(err) + } + + err = m.DelistPod(randomLongPodName1) + if err != nil { + t.Fatal(err) + } +} From 8891d990c0f315db44cc6a30c2688b45dc38cc77 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 15 Feb 2023 09:55:52 +0530 Subject: [PATCH 02/48] subscription test added --- pkg/subscription/rpc/mock/rpc.go | 5 +- pkg/subscription/subscription.go | 31 ++++---- pkg/subscription/subscription_test.go | 100 +++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 22 deletions(-) diff --git a/pkg/subscription/rpc/mock/rpc.go b/pkg/subscription/rpc/mock/rpc.go index 63a57259..e98b179f 100644 --- a/pkg/subscription/rpc/mock/rpc.go +++ b/pkg/subscription/rpc/mock/rpc.go @@ -32,6 +32,7 @@ func NewMockSubscriptionManager() *SubscriptionManager { return &SubscriptionManager{ listMap: make(map[string]*PodItem), subscriptionMap: make(map[string]*PodItem), + requestMap: make(map[string]requestInfo), } } @@ -114,7 +115,9 @@ func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*Pod func (s *SubscriptionManager) GetAllSubscribablePods() []*PodItem { pods := []*PodItem{} for _, v := range s.listMap { - pods = append(pods, v) + if v.IsListed { + pods = append(pods, v) + } } return pods } diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go index 7f7bdecb..e2c1c60a 100644 --- a/pkg/subscription/subscription.go +++ b/pkg/subscription/subscription.go @@ -3,6 +3,8 @@ package subscription import ( "fmt" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" + "github.com/ethereum/go-ethereum/common" "github.com/fairdatasociety/fairOS-dfs/pkg/ensm" "github.com/fairdatasociety/fairOS-dfs/pkg/pod" @@ -47,31 +49,22 @@ func (m *Manager) DelistPod(podname string) error { } // ApproveSubscription will send a subscription request to the owner of the pod -func (m *Manager) ApproveSubscription(podname string, subscriber string) error { - subscriberAddr, err := m.ens.GetOwner(subscriber) - if err != nil { - return err - } - return m.sm.AllowAccess(podname, m.addr, subscriberAddr) +func (m *Manager) ApproveSubscription(podname string, subscriber common.Address) error { + return m.sm.AllowAccess(podname, m.addr, subscriber) } // RequestSubscription will send a subscription request to the owner of the pod // will create an escrow account and deposit the `price` -func (m *Manager) RequestSubscription(pod string, owner string) error { - ownerAddr, err := m.ens.GetOwner(owner) - if err != nil { - return err - } - - return m.sm.RequestAccess(pod, ownerAddr, m.addr) +func (m *Manager) RequestSubscription(pod string, owner common.Address) error { + return m.sm.RequestAccess(pod, owner, m.addr) } -func (*Manager) GetSubscriptions() ([]PodItem, error) { - // This will query the smart contract and list my subscriptions - return nil, nil +// GetSubscriptions will query the smart contract and list my subscriptions +func (m *Manager) GetSubscriptions() ([]*mock.PodItem, error) { + return m.sm.GetSubscriptions(m.addr), nil } -func (*Manager) GetMarketplace() ([]PodItem, error) { - // This will query the smart contract make the `list` all the pod from the marketplace - return nil, nil +// GetMarketplace will query the smart contract make the `list` all the pod from the marketplace +func (m *Manager) GetMarketplace() ([]*mock.PodItem, error) { + return m.sm.GetAllSubscribablePods(), nil } diff --git a/pkg/subscription/subscription_test.go b/pkg/subscription/subscription_test.go index d5082d02..4efe32b0 100644 --- a/pkg/subscription/subscription_test.go +++ b/pkg/subscription/subscription_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" @@ -51,8 +53,6 @@ func TestNew(t *testing.T) { t.Fatal("pod should not be present") } - // check too long pod name - podPassword, _ := utils.GetRandString(pod.PasswordLength) _, err = pod1.CreatePod(randomLongPodName1, "", podPassword) if err != nil { @@ -69,3 +69,99 @@ func TestNew(t *testing.T) { t.Fatal(err) } } + +func TestSubscription(t *testing.T) { + mockClient := mock.NewMockBeeClient() + ens := mock2.NewMockNamespaceManager() + + logger := logging.New(os.Stdout, 0) + acc1 := account.New(logger) + _, _, err := acc1.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + fd := feed.New(acc1.GetUserAccountInfo(), mockClient, logger) + tm := taskmanager.New(1, 10, time.Second*15, logger) + defer func() { + _ = tm.Stop(context.Background()) + }() + pod1 := pod.NewPod(mockClient, fd, acc1, tm, logger) + addr1 := common.HexToAddress(acc1.GetUserAccountInfo().GetAddress().Hex()) + sm := rpcMock.NewMockSubscriptionManager() + m := subscription.New(pod1, addr1, ens, sm) + + randomLongPodName1, err := utils.GetRandString(64) + if err != nil { + t.Fatalf("error creating pod %s", randomLongPodName1) + } + + podPassword, _ := utils.GetRandString(pod.PasswordLength) + _, err = pod1.CreatePod(randomLongPodName1, "", podPassword) + if err != nil { + t.Fatal(err) + } + + err = m.ListPod(randomLongPodName1, 1) + if err != nil { + t.Fatal(err) + } + + acc2 := account.New(logger) + _, _, err = acc2.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) + pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) + addr2 := common.HexToAddress(acc2.GetUserAccountInfo().GetAddress().Hex()) + + m2 := subscription.New(pod2, addr2, ens, sm) + + err = m2.RequestSubscription(randomLongPodName1, addr1) + if err != nil { + t.Fatal(err) + } + + err = m.ApproveSubscription(randomLongPodName1, addr2) + if err != nil { + t.Fatal(err) + } + + subs, err := m2.GetSubscriptions() + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, len(subs), 1) + assert.Equal(t, subs[0].Name, randomLongPodName1) + + randomLongPodName2, err := utils.GetRandString(64) + if err != nil { + t.Fatalf("error creating pod %s", randomLongPodName2) + } + + _, err = pod1.CreatePod(randomLongPodName2, "", podPassword) + if err != nil { + t.Fatal(err) + } + + err = m2.RequestSubscription(randomLongPodName2, addr1) + if err == nil { + t.Fatal("pod is not listed") + } + + err = m.ListPod(randomLongPodName2, 1) + if err != nil { + t.Fatal(err) + } + + err = m.DelistPod(randomLongPodName2) + if err != nil { + t.Fatal(err) + } + + err = m2.RequestSubscription(randomLongPodName2, addr1) + if err == nil { + t.Fatal("pod is not listed") + } +} From 30a7e578611056476f8e98ad946e98d0157af105 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Feb 2023 17:09:35 +0530 Subject: [PATCH 03/48] open subscribed pod from reference --- pkg/pod/open.go | 39 ++++++ pkg/pod/sharing.go | 2 +- pkg/subscription/rpc/mock/rpc.go | 57 +++++--- pkg/subscription/rpc/rpc.go | 11 +- pkg/subscription/subscription.go | 78 ++++++++--- pkg/subscription/subscription_test.go | 167 ---------------------- pkg/test/subscription_test.go | 193 ++++++++++++++++++++++++++ 7 files changed, 335 insertions(+), 212 deletions(-) delete mode 100644 pkg/subscription/subscription_test.go create mode 100644 pkg/test/subscription_test.go diff --git a/pkg/pod/open.go b/pkg/pod/open.go index d80feaba..f07f0798 100644 --- a/pkg/pod/open.go +++ b/pkg/pod/open.go @@ -116,6 +116,45 @@ func (p *Pod) OpenPod(podName string) (*Info, error) { return podInfo, nil } +func (p *Pod) OpenFromReference(ref utils.Reference) (*Info, error) { + si, err := p.ReceivePodInfo(ref) + if err != nil { + return nil, err + } + + accountInfo := p.acc.GetEmptyAccountInfo() + address := utils.HexToAddress(si.Address) + accountInfo.SetAddress(address) + + fd := feed.New(accountInfo, p.client, p.logger) + file := f.NewFile(si.PodName, p.client, fd, accountInfo.GetAddress(), p.tm, p.logger) + dir := d.NewDirectory(si.PodName, p.client, fd, accountInfo.GetAddress(), file, p.tm, p.logger) + + kvStore := c.NewKeyValueStore(si.PodName, fd, accountInfo, address, p.client, p.logger) + docStore := c.NewDocumentStore(si.PodName, fd, accountInfo, address, file, p.tm, p.client, p.logger) + + podInfo := &Info{ + podName: si.PodName, + podPassword: si.Password, + userAddress: address, + accountInfo: accountInfo, + feed: fd, + dir: dir, + file: file, + kvStore: kvStore, + docStore: docStore, + } + p.addPodToPodMap(si.PodName, podInfo) + + // sync the pod's files and directories + err = p.SyncPod(si.PodName) + if err != nil && err != d.ErrResourceDeleted { // skipcq: TCV-001 + return nil, err + } + + return podInfo, nil +} + // OpenPodAsync opens a pod if it is not already opened. as part of opening the pod // it loads all the data structures related to the pod. Also, it syncs all the // files and directories under this pod from the Swarm network. diff --git a/pkg/pod/sharing.go b/pkg/pod/sharing.go index 058621d9..a192a2b2 100644 --- a/pkg/pod/sharing.go +++ b/pkg/pod/sharing.go @@ -72,7 +72,7 @@ func (p *Pod) PodShare(podName, sharedPodName string) (string, error) { if err != nil { // skipcq: TCV-001 return "", err } - ref, err := p.client.UploadBlob(data, 0, true, true) + ref, err := p.client.UploadBlob(data, 0, true, false) if err != nil { // skipcq: TCV-001 return "", err } diff --git a/pkg/subscription/rpc/mock/rpc.go b/pkg/subscription/rpc/mock/rpc.go index e98b179f..c9c926f9 100644 --- a/pkg/subscription/rpc/mock/rpc.go +++ b/pkg/subscription/rpc/mock/rpc.go @@ -4,6 +4,7 @@ import ( "fmt" "strings" "sync" + "time" "github.com/ethereum/go-ethereum/common" ) @@ -11,19 +12,29 @@ import ( type PodItem struct { Name string `json:"name"` Price uint64 `json:"price"` + Address common.Address `json:"address"` Owner common.Address `json:"owner"` IsListed bool `json:"isListed"` } +type SubbedItem struct { + Name string `json:"name"` + Address common.Address `json:"address"` + EndsAt int64 `json:"ends_at"` + Secret string `json:"secret"` + Owner common.Address `json:"owner"` +} + type requestInfo struct { Name string `json:"name"` + Address common.Address `json:"address"` Subscriber common.Address `json:"owner"` } type SubscriptionManager struct { lock sync.Mutex listMap map[string]*PodItem - subscriptionMap map[string]*PodItem + subscriptionMap map[string]*SubbedItem requestMap map[string]requestInfo } @@ -31,30 +42,30 @@ type SubscriptionManager struct { func NewMockSubscriptionManager() *SubscriptionManager { return &SubscriptionManager{ listMap: make(map[string]*PodItem), - subscriptionMap: make(map[string]*PodItem), + subscriptionMap: make(map[string]*SubbedItem), requestMap: make(map[string]requestInfo), } } -func (s *SubscriptionManager) AddPodToMarketplace(owner common.Address, pod string, price uint64) error { +func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod string, price uint64) error { i := &PodItem{ Name: pod, Price: price, + Address: podAddress, Owner: owner, IsListed: true, } s.lock.Lock() defer s.lock.Unlock() - s.listMap[owner.Hex()+pod] = i - + s.listMap[owner.Hex()+podAddress.String()] = i return nil } -func (s *SubscriptionManager) HidePodFromMarketplace(owner common.Address, pod string) error { +func (s *SubscriptionManager) HidePodFromMarketplace(podAddress, owner common.Address) error { s.lock.Lock() defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+pod] + i, ok := s.listMap[owner.Hex()+podAddress.String()] if !ok { return fmt.Errorf("pod not listed") } @@ -62,10 +73,10 @@ func (s *SubscriptionManager) HidePodFromMarketplace(owner common.Address, pod s return nil } -func (s *SubscriptionManager) RequestAccess(pod string, owner, subscriber common.Address) error { +func (s *SubscriptionManager) RequestAccess(podAddress, owner, subscriber common.Address) error { s.lock.Lock() defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+pod] + i, ok := s.listMap[owner.Hex()+podAddress.String()] if !ok { return fmt.Errorf("pod not listed") } @@ -73,17 +84,18 @@ func (s *SubscriptionManager) RequestAccess(pod string, owner, subscriber common return fmt.Errorf("pod not listed") } - s.requestMap[owner.Hex()+subscriber.Hex()+pod] = requestInfo{ - Name: pod, + s.requestMap[owner.Hex()+subscriber.Hex()+podAddress.String()] = requestInfo{ + Name: i.Name, + Address: podAddress, Subscriber: subscriber, } return nil } -func (s *SubscriptionManager) AllowAccess(pod string, owner, subscriber common.Address) error { +func (s *SubscriptionManager) AllowAccess(podAddress, owner, subscriber common.Address, secret string) error { s.lock.Lock() defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+pod] + i, ok := s.listMap[owner.Hex()+podAddress.String()] if !ok { return fmt.Errorf("pod not listed") } @@ -91,19 +103,26 @@ func (s *SubscriptionManager) AllowAccess(pod string, owner, subscriber common.A return fmt.Errorf("pod not listed") } - _, ok = s.requestMap[owner.Hex()+subscriber.Hex()+pod] + _, ok = s.requestMap[owner.Hex()+subscriber.Hex()+podAddress.String()] if !ok { return fmt.Errorf("request not available") } - s.subscriptionMap[subscriber.Hex()+pod] = i + item := &SubbedItem{ + Name: i.Name, + Address: i.Address, + EndsAt: time.Now().AddDate(0, 1, 0).Unix(), + Secret: secret, + Owner: owner, + } + s.subscriptionMap[subscriber.Hex()+podAddress.String()] = item return nil } -func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*PodItem { +func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*SubbedItem { subscriberHex := subscriber.Hex() - pods := []*PodItem{} + pods := []*SubbedItem{} for i, v := range s.subscriptionMap { if strings.HasPrefix(i, subscriberHex) { pods = append(pods, v) @@ -112,6 +131,10 @@ func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*Pod return pods } +func (s *SubscriptionManager) GetSubscription(podAddress, subscriber common.Address) *SubbedItem { + return s.subscriptionMap[subscriber.Hex()+podAddress.String()] +} + func (s *SubscriptionManager) GetAllSubscribablePods() []*PodItem { pods := []*PodItem{} for _, v := range s.listMap { diff --git a/pkg/subscription/rpc/rpc.go b/pkg/subscription/rpc/rpc.go index dd021051..fd714189 100644 --- a/pkg/subscription/rpc/rpc.go +++ b/pkg/subscription/rpc/rpc.go @@ -6,11 +6,12 @@ import ( ) type SubscriptionManager interface { - AddPodToMarketplace(owner common.Address, pod string, price uint64) error - HidePodFromMarketplace(owner common.Address, pod string) error - RequestAccess(pod string, owner, subscriber common.Address) error - AllowAccess(pod string, owner, subscriber common.Address) error - GetSubscriptions(subscriber common.Address) []*mock.PodItem + AddPodToMarketplace(podAddress, owner common.Address, pod string, price uint64) error + HidePodFromMarketplace(podAddress, owner common.Address) error + RequestAccess(podAddress, owner, subscriber common.Address) error + AllowAccess(podAddress, owner, subscriber common.Address, secret string) error + GetSubscription(podAddress, subscriber common.Address) *mock.SubbedItem + GetSubscriptions(subscriber common.Address) []*mock.SubbedItem GetAllSubscribablePods() []*mock.PodItem GetOwnSubscribablePods(owner common.Address) []*mock.PodItem } diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go index e2c1c60a..b03b5ed2 100644 --- a/pkg/subscription/subscription.go +++ b/pkg/subscription/subscription.go @@ -1,8 +1,12 @@ package subscription import ( + "crypto/ecdsa" + "crypto/sha256" "fmt" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" "github.com/ethereum/go-ethereum/common" @@ -12,55 +16,68 @@ import ( ) type Manager struct { - pod *pod.Pod - addr common.Address - ens ensm.ENSManager - - sm rpc.SubscriptionManager + pod *pod.Pod + addr common.Address + ens ensm.ENSManager + privateKey *ecdsa.PrivateKey + sm rpc.SubscriptionManager } type PodItem struct { - Name string `json:"name"` - Price uint64 `json:"price"` - Owner string `json:"owner"` + Name string `json:"name"` + Address string `json:"address"` + Price uint64 `json:"price"` + Owner string `json:"owner"` } -func New(pod *pod.Pod, addr common.Address, ensm ensm.ENSManager, sm rpc.SubscriptionManager) *Manager { +func New(pod *pod.Pod, addr common.Address, privateKey *ecdsa.PrivateKey, ensm ensm.ENSManager, sm rpc.SubscriptionManager) *Manager { return &Manager{ - pod: pod, - addr: addr, - ens: ensm, - sm: sm, + pod: pod, + addr: addr, + ens: ensm, + sm: sm, + privateKey: privateKey, } } // ListPod will save the pod info in the subscription smart contract with its owner and price // we keep the pod info in the smart contract, with a `list` flag -func (m *Manager) ListPod(podname string, price uint64) error { +func (m *Manager) ListPod(podname string, podAddress common.Address, price uint64) error { if !m.pod.IsOwnPodPresent(podname) { return fmt.Errorf("pod not present") } - return m.sm.AddPodToMarketplace(m.addr, podname, price) + return m.sm.AddPodToMarketplace(podAddress, m.addr, podname, price) } // DelistPod will make the `list` flag false for the pod so that it's not listed in the pod marketplace -func (m *Manager) DelistPod(podname string) error { - return m.sm.HidePodFromMarketplace(m.addr, podname) +func (m *Manager) DelistPod(podAddress common.Address) error { + return m.sm.HidePodFromMarketplace(podAddress, m.addr) } // ApproveSubscription will send a subscription request to the owner of the pod -func (m *Manager) ApproveSubscription(podname string, subscriber common.Address) error { - return m.sm.AllowAccess(podname, m.addr, subscriber) +func (m *Manager) ApproveSubscription(podName string, podAddress, subscriber common.Address, subscriberPublicKey *ecdsa.PublicKey) error { + a, _ := subscriberPublicKey.Curve.ScalarMult(subscriberPublicKey.X, subscriberPublicKey.Y, m.privateKey.D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + + ref, err := m.pod.PodShare(podName, "") + if err != nil { + return err + } + encRef, err := utils.EncryptBytes(secret[:], []byte(ref)) + if err != nil { + return err + } + return m.sm.AllowAccess(podAddress, m.addr, subscriber, string(encRef)) } // RequestSubscription will send a subscription request to the owner of the pod // will create an escrow account and deposit the `price` -func (m *Manager) RequestSubscription(pod string, owner common.Address) error { - return m.sm.RequestAccess(pod, owner, m.addr) +func (m *Manager) RequestSubscription(podAddress, owner common.Address) error { + return m.sm.RequestAccess(podAddress, owner, m.addr) } // GetSubscriptions will query the smart contract and list my subscriptions -func (m *Manager) GetSubscriptions() ([]*mock.PodItem, error) { +func (m *Manager) GetSubscriptions() ([]*mock.SubbedItem, error) { return m.sm.GetSubscriptions(m.addr), nil } @@ -68,3 +85,20 @@ func (m *Manager) GetSubscriptions() ([]*mock.PodItem, error) { func (m *Manager) GetMarketplace() ([]*mock.PodItem, error) { return m.sm.GetAllSubscribablePods(), nil } + +// OpenSubscribedPod will open a subscribed pod +func (m *Manager) OpenSubscribedPod(podAddress common.Address, ownerPublicKey *ecdsa.PublicKey) (*pod.Info, error) { + a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, m.privateKey.D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + item := m.sm.GetSubscription(podAddress, m.addr) + refBytes, err := utils.DecryptBytes(secret[:], []byte(item.Secret)) + if err != nil { + return nil, err + } + reference, err := utils.ParseHexReference(string(refBytes)) + if err != nil { + return nil, err + } + + return m.pod.OpenFromReference(reference) +} diff --git a/pkg/subscription/subscription_test.go b/pkg/subscription/subscription_test.go deleted file mode 100644 index 4efe32b0..00000000 --- a/pkg/subscription/subscription_test.go +++ /dev/null @@ -1,167 +0,0 @@ -package subscription_test - -import ( - "context" - "os" - "testing" - "time" - - "github.com/stretchr/testify/assert" - - "github.com/fairdatasociety/fairOS-dfs/pkg/utils" - - mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" - - "github.com/ethereum/go-ethereum/common" - "github.com/fairdatasociety/fairOS-dfs/pkg/account" - "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" - "github.com/fairdatasociety/fairOS-dfs/pkg/feed" - "github.com/fairdatasociety/fairOS-dfs/pkg/logging" - "github.com/fairdatasociety/fairOS-dfs/pkg/pod" - "github.com/plexsysio/taskmanager" - - "github.com/fairdatasociety/fairOS-dfs/pkg/subscription" - rpcMock "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" -) - -func TestNew(t *testing.T) { - mockClient := mock.NewMockBeeClient() - ens := mock2.NewMockNamespaceManager() - - logger := logging.New(os.Stdout, 0) - acc := account.New(logger) - _, _, err := acc.CreateUserAccount("") - if err != nil { - t.Fatal(err) - } - fd := feed.New(acc.GetUserAccountInfo(), mockClient, logger) - tm := taskmanager.New(1, 10, time.Second*15, logger) - defer func() { - _ = tm.Stop(context.Background()) - }() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) - addr := common.HexToAddress(acc.GetUserAccountInfo().GetAddress().Hex()) - sm := rpcMock.NewMockSubscriptionManager() - m := subscription.New(pod1, addr, ens, sm) - - randomLongPodName1, err := utils.GetRandString(64) - if err != nil { - t.Fatalf("error creating pod %s", randomLongPodName1) - } - err = m.ListPod(randomLongPodName1, 1) - if err == nil { - t.Fatal("pod should not be present") - } - - podPassword, _ := utils.GetRandString(pod.PasswordLength) - _, err = pod1.CreatePod(randomLongPodName1, "", podPassword) - if err != nil { - t.Fatal(err) - } - - err = m.ListPod(randomLongPodName1, 1) - if err != nil { - t.Fatal(err) - } - - err = m.DelistPod(randomLongPodName1) - if err != nil { - t.Fatal(err) - } -} - -func TestSubscription(t *testing.T) { - mockClient := mock.NewMockBeeClient() - ens := mock2.NewMockNamespaceManager() - - logger := logging.New(os.Stdout, 0) - acc1 := account.New(logger) - _, _, err := acc1.CreateUserAccount("") - if err != nil { - t.Fatal(err) - } - fd := feed.New(acc1.GetUserAccountInfo(), mockClient, logger) - tm := taskmanager.New(1, 10, time.Second*15, logger) - defer func() { - _ = tm.Stop(context.Background()) - }() - pod1 := pod.NewPod(mockClient, fd, acc1, tm, logger) - addr1 := common.HexToAddress(acc1.GetUserAccountInfo().GetAddress().Hex()) - sm := rpcMock.NewMockSubscriptionManager() - m := subscription.New(pod1, addr1, ens, sm) - - randomLongPodName1, err := utils.GetRandString(64) - if err != nil { - t.Fatalf("error creating pod %s", randomLongPodName1) - } - - podPassword, _ := utils.GetRandString(pod.PasswordLength) - _, err = pod1.CreatePod(randomLongPodName1, "", podPassword) - if err != nil { - t.Fatal(err) - } - - err = m.ListPod(randomLongPodName1, 1) - if err != nil { - t.Fatal(err) - } - - acc2 := account.New(logger) - _, _, err = acc2.CreateUserAccount("") - if err != nil { - t.Fatal(err) - } - fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) - pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) - addr2 := common.HexToAddress(acc2.GetUserAccountInfo().GetAddress().Hex()) - - m2 := subscription.New(pod2, addr2, ens, sm) - - err = m2.RequestSubscription(randomLongPodName1, addr1) - if err != nil { - t.Fatal(err) - } - - err = m.ApproveSubscription(randomLongPodName1, addr2) - if err != nil { - t.Fatal(err) - } - - subs, err := m2.GetSubscriptions() - if err != nil { - t.Fatal(err) - } - - assert.Equal(t, len(subs), 1) - assert.Equal(t, subs[0].Name, randomLongPodName1) - - randomLongPodName2, err := utils.GetRandString(64) - if err != nil { - t.Fatalf("error creating pod %s", randomLongPodName2) - } - - _, err = pod1.CreatePod(randomLongPodName2, "", podPassword) - if err != nil { - t.Fatal(err) - } - - err = m2.RequestSubscription(randomLongPodName2, addr1) - if err == nil { - t.Fatal("pod is not listed") - } - - err = m.ListPod(randomLongPodName2, 1) - if err != nil { - t.Fatal(err) - } - - err = m.DelistPod(randomLongPodName2) - if err != nil { - t.Fatal(err) - } - - err = m2.RequestSubscription(randomLongPodName2, addr1) - if err == nil { - t.Fatal("pod is not listed") - } -} diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go new file mode 100644 index 00000000..414c0e04 --- /dev/null +++ b/pkg/test/subscription_test.go @@ -0,0 +1,193 @@ +package test_test + +import ( + "context" + "os" + "testing" + "time" + + "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/feed" + "github.com/fairdatasociety/fairOS-dfs/pkg/logging" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscription" + rpcMock "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + "github.com/plexsysio/taskmanager" + "github.com/stretchr/testify/assert" +) + +func TestSubscription(t *testing.T) { + mockClient := mock.NewMockBeeClient() + ens := mock2.NewMockNamespaceManager() + + logger := logging.New(os.Stdout, 0) + acc1 := account.New(logger) + _, _, err := acc1.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + fd := feed.New(acc1.GetUserAccountInfo(), mockClient, logger) + tm := taskmanager.New(1, 10, time.Second*15, logger) + defer func() { + _ = tm.Stop(context.Background()) + }() + pod1 := pod.NewPod(mockClient, fd, acc1, tm, logger) + addr1 := common.HexToAddress(acc1.GetUserAccountInfo().GetAddress().Hex()) + sm := rpcMock.NewMockSubscriptionManager() + m := subscription.New(pod1, addr1, acc1.GetUserAccountInfo().GetPrivateKey(), ens, sm) + randomLongPodName1, err := utils.GetRandString(64) + if err != nil { + t.Fatalf("error creating pod %s", randomLongPodName1) + } + + podPassword, _ := utils.GetRandString(pod.PasswordLength) + p1, err := pod1.CreatePod(randomLongPodName1, "", podPassword) + if err != nil { + t.Fatal(err) + } + + // make root dir so that other directories can be added + err = p1.GetDirectory().MkRootDir(randomLongPodName1, podPassword, p1.GetPodAddress(), p1.GetFeed()) + if err != nil { + t.Fatal(err) + } + + // create some dir and files + addFilesAndDirectories(t, p1, pod1, randomLongPodName1, podPassword) + p1, err = pod1.OpenPod(randomLongPodName1) + if err != nil { + t.Fatal(err) + } + + err = m.ListPod(randomLongPodName1, common.HexToAddress(p1.GetPodAddress().Hex()), 1) + if err != nil { + t.Fatal(err) + } + + acc2 := account.New(logger) + _, _, err = acc2.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) + pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) + addr2 := common.HexToAddress(acc2.GetUserAccountInfo().GetAddress().Hex()) + + m2 := subscription.New(pod2, addr2, acc2.GetUserAccountInfo().GetPrivateKey(), ens, sm) + + err = m2.RequestSubscription(common.HexToAddress(p1.GetPodAddress().Hex()), addr1) + if err != nil { + t.Fatal(err) + } + + err = m.ApproveSubscription(p1.GetPodName(), common.HexToAddress(p1.GetPodAddress().Hex()), addr2, acc2.GetUserAccountInfo().GetPublicKey()) + if err != nil { + t.Fatal(err) + } + + subs, err := m2.GetSubscriptions() + if err != nil { + t.Fatal(err) + } + + assert.Equal(t, len(subs), 1) + assert.Equal(t, subs[0].Name, randomLongPodName1) + + randomLongPodName2, err := utils.GetRandString(64) + if err != nil { + t.Fatalf("error creating pod %s", randomLongPodName2) + } + + p2, err := pod1.CreatePod(randomLongPodName2, "", podPassword) + if err != nil { + t.Fatal(err) + } + + err = m2.RequestSubscription(common.HexToAddress(p2.GetPodAddress().Hex()), addr1) + if err == nil { + t.Fatal("pod is not listed") + } + + err = m.ListPod(randomLongPodName2, common.HexToAddress(p2.GetPodAddress().Hex()), 1) + if err != nil { + t.Fatal(err) + } + + err = m.DelistPod(common.HexToAddress(p2.GetPodAddress().Hex())) + if err != nil { + t.Fatal(err) + } + + err = m2.RequestSubscription(common.HexToAddress(p2.GetPodAddress().Hex()), addr1) + if err == nil { + t.Fatal("pod is not listed") + } + + pi, err := m2.OpenSubscribedPod(common.HexToAddress(p1.GetPodAddress().Hex()), acc1.GetUserAccountInfo().GetPublicKey()) + if err != nil { + return + } + + dirObject := pi.GetDirectory() + + dirInode1 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir1") + if dirInode1 == nil { + t.Fatalf("invalid dir entry") + } + + if dirInode1.Meta.Path != "/parentDir" { + t.Fatalf("invalid path entry") + } + if dirInode1.Meta.Name != "subDir1" { + t.Fatalf("invalid dir entry") + } + dirInode2 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir2") + if dirInode2 == nil { + t.Fatalf("invalid dir entry") + } + if dirInode2.Meta.Path != "/parentDir" { + t.Fatalf("invalid path entry") + } + if dirInode2.Meta.Name != "subDir2" { + t.Fatalf("invalid dir entry") + } + + fileObject := pi.GetFile() + fileMeta1 := fileObject.GetFromFileMap("/parentDir/file1") + if fileMeta1 == nil { + t.Fatalf("invalid file meta") + } + + if fileMeta1.Path != "/parentDir" { + t.Fatalf("invalid path entry") + } + if fileMeta1.Name != "file1" { + t.Fatalf("invalid file entry") + } + if fileMeta1.Size != uint64(100) { + t.Fatalf("invalid file size") + } + if fileMeta1.BlockSize != uint32(10) { + t.Fatalf("invalid block size") + } + fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") + if fileMeta2 == nil { + t.Fatalf("invalid file meta") + } + if fileMeta2.Path != "/parentDir" { + t.Fatalf("invalid path entry") + } + if fileMeta2.Name != "file2" { + t.Fatalf("invalid file entry") + } + if fileMeta2.Size != uint64(200) { + t.Fatalf("invalid file size") + } + if fileMeta2.BlockSize != uint32(20) { + t.Fatalf("invalid block size") + } +} From 1e97f1787f44f24492dc088d4353bb127ecc3101 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 28 Feb 2023 11:36:24 +0530 Subject: [PATCH 04/48] sub working, wasm apis added, connect wallet, login with wallet --- pkg/contracts/smail/SwarmMail.go | 2528 +++++++++++++++++ pkg/dfs/api.go | 9 + pkg/dfs/errors.go | 8 +- pkg/dfs/pod_api.go | 164 ++ pkg/dfs/user_api.go | 16 +- pkg/ensm/ensm.go | 2 + pkg/ensm/eth/eth.go | 18 +- pkg/ensm/eth/mock/eth.go | 37 + pkg/pod/open.go | 25 +- pkg/pod/pod.go | 6 +- pkg/pod/sharing.go | 34 +- pkg/pod/subscription.go | 98 + pkg/subscription/rpc/mock/rpc.go | 157 - pkg/subscription/rpc/rpc.go | 17 - pkg/subscription/subscription.go | 104 - pkg/subscriptionManager/rpc/manager.go | 359 +++ pkg/subscriptionManager/rpc/mock/rpc.go | 228 ++ .../subscriptionManager.go | 25 + pkg/test/close_test.go | 6 +- pkg/test/del_test.go | 5 +- pkg/test/delete_test.go | 6 +- pkg/test/fork_test.go | 6 +- pkg/test/lite_test.go | 7 +- pkg/test/login_test.go | 31 +- pkg/test/logout_test.go | 5 +- pkg/test/ls_test.go | 5 +- pkg/test/max_pod_test.go | 5 +- pkg/test/new_test.go | 17 +- pkg/test/open_test.go | 5 +- pkg/test/pod_new_test.go | 6 +- pkg/test/pod_sharing_test.go | 20 +- pkg/test/pod_stat_test.go | 6 +- pkg/test/stat_test.go | 5 +- pkg/test/subscription_test.go | 69 +- pkg/test/sync_test.go | 6 +- pkg/test/user_sharing_test.go | 11 +- pkg/user/ensInfo.go | 16 + pkg/user/lite.go | 6 +- pkg/user/login.go | 108 +- pkg/user/new.go | 6 +- wasm/main.go | 344 +++ 41 files changed, 4147 insertions(+), 389 deletions(-) create mode 100644 pkg/contracts/smail/SwarmMail.go create mode 100644 pkg/pod/subscription.go delete mode 100644 pkg/subscription/rpc/mock/rpc.go delete mode 100644 pkg/subscription/rpc/rpc.go delete mode 100644 pkg/subscription/subscription.go create mode 100644 pkg/subscriptionManager/rpc/manager.go create mode 100644 pkg/subscriptionManager/rpc/mock/rpc.go create mode 100644 pkg/subscriptionManager/subscriptionManager.go create mode 100644 pkg/user/ensInfo.go diff --git a/pkg/contracts/smail/SwarmMail.go b/pkg/contracts/smail/SwarmMail.go new file mode 100644 index 00000000..9d2b9513 --- /dev/null +++ b/pkg/contracts/smail/SwarmMail.go @@ -0,0 +1,2528 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package SwarmMail + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// SwarmMailActiveBid is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailActiveBid struct { + Seller common.Address + RequestHash [32]byte +} + +// SwarmMailCategory is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailCategory struct { + SubIdxs []*big.Int +} + +// SwarmMailEmail is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailEmail struct { + IsEncryption bool + Time *big.Int + From common.Address + To common.Address + SwarmLocation [32]byte + Signed bool +} + +// SwarmMailSub is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailSub struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 +} + +// SwarmMailSubItem is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailSubItem struct { + SubHash [32]byte + UnlockKeyLocation [32]byte + ValidTill *big.Int +} + +// SwarmMailSubRequest is an auto generated low-level Go binding around an user-defined struct. +type SwarmMailSubRequest struct { + FdpBuyerNameHash [32]byte + Buyer common.Address + SubHash [32]byte + RequestHash [32]byte +} + +// SwarmMailMetaData contains all meta data concerning the SwarmMail contract. +var SwarmMailMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getBoxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numInboxItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSentItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256[]\",\"name\":\"subIdxs\",\"type\":\"uint256[]\"}],\"internalType\":\"structSwarmMail.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInbox\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getInboxAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPublicKeys\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"registered\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSent\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSentAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSub\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubItemsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"types\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"swarmLocations\",\"type\":\"bytes32[]\"}],\"name\":\"removeEmails\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeInboxEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeSentEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"removeSubItem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"sendEmail\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"signEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", +} + +// SwarmMailABI is the input ABI used to generate the binding from. +// Deprecated: Use SwarmMailMetaData.ABI instead. +var SwarmMailABI = SwarmMailMetaData.ABI + +// SwarmMail is an auto generated Go binding around an Ethereum contract. +type SwarmMail struct { + SwarmMailCaller // Read-only binding to the contract + SwarmMailTransactor // Write-only binding to the contract + SwarmMailFilterer // Log filterer for contract events +} + +// SwarmMailCaller is an auto generated read-only Go binding around an Ethereum contract. +type SwarmMailCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SwarmMailTransactor is an auto generated write-only Go binding around an Ethereum contract. +type SwarmMailTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SwarmMailFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type SwarmMailFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// SwarmMailSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type SwarmMailSession struct { + Contract *SwarmMail // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SwarmMailCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type SwarmMailCallerSession struct { + Contract *SwarmMailCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// SwarmMailTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type SwarmMailTransactorSession struct { + Contract *SwarmMailTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// SwarmMailRaw is an auto generated low-level Go binding around an Ethereum contract. +type SwarmMailRaw struct { + Contract *SwarmMail // Generic contract binding to access the raw methods on +} + +// SwarmMailCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type SwarmMailCallerRaw struct { + Contract *SwarmMailCaller // Generic read-only contract binding to access the raw methods on +} + +// SwarmMailTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type SwarmMailTransactorRaw struct { + Contract *SwarmMailTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewSwarmMail creates a new instance of SwarmMail, bound to a specific deployed contract. +func NewSwarmMail(address common.Address, backend bind.ContractBackend) (*SwarmMail, error) { + contract, err := bindSwarmMail(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &SwarmMail{SwarmMailCaller: SwarmMailCaller{contract: contract}, SwarmMailTransactor: SwarmMailTransactor{contract: contract}, SwarmMailFilterer: SwarmMailFilterer{contract: contract}}, nil +} + +// NewSwarmMailCaller creates a new read-only instance of SwarmMail, bound to a specific deployed contract. +func NewSwarmMailCaller(address common.Address, caller bind.ContractCaller) (*SwarmMailCaller, error) { + contract, err := bindSwarmMail(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &SwarmMailCaller{contract: contract}, nil +} + +// NewSwarmMailTransactor creates a new write-only instance of SwarmMail, bound to a specific deployed contract. +func NewSwarmMailTransactor(address common.Address, transactor bind.ContractTransactor) (*SwarmMailTransactor, error) { + contract, err := bindSwarmMail(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &SwarmMailTransactor{contract: contract}, nil +} + +// NewSwarmMailFilterer creates a new log filterer instance of SwarmMail, bound to a specific deployed contract. +func NewSwarmMailFilterer(address common.Address, filterer bind.ContractFilterer) (*SwarmMailFilterer, error) { + contract, err := bindSwarmMail(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &SwarmMailFilterer{contract: contract}, nil +} + +// bindSwarmMail binds a generic wrapper to an already deployed contract. +func bindSwarmMail(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(SwarmMailABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SwarmMail *SwarmMailRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SwarmMail.Contract.SwarmMailCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SwarmMail *SwarmMailRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwarmMail.Contract.SwarmMailTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SwarmMail *SwarmMailRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SwarmMail.Contract.SwarmMailTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_SwarmMail *SwarmMailCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _SwarmMail.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_SwarmMail *SwarmMailTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwarmMail.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_SwarmMail *SwarmMailTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _SwarmMail.Contract.contract.Transact(opts, method, params...) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_SwarmMail *SwarmMailCaller) DEFAULTADMINROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "DEFAULT_ADMIN_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_SwarmMail *SwarmMailSession) DEFAULTADMINROLE() ([32]byte, error) { + return _SwarmMail.Contract.DEFAULTADMINROLE(&_SwarmMail.CallOpts) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_SwarmMail *SwarmMailCallerSession) DEFAULTADMINROLE() ([32]byte, error) { + return _SwarmMail.Contract.DEFAULTADMINROLE(&_SwarmMail.CallOpts) +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_SwarmMail *SwarmMailCaller) FeesCollected(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "feesCollected") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_SwarmMail *SwarmMailSession) FeesCollected() (*big.Int, error) { + return _SwarmMail.Contract.FeesCollected(&_SwarmMail.CallOpts) +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) FeesCollected() (*big.Int, error) { + return _SwarmMail.Contract.FeesCollected(&_SwarmMail.CallOpts) +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_SwarmMail *SwarmMailCaller) FundsBalance(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "fundsBalance") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_SwarmMail *SwarmMailSession) FundsBalance() (*big.Int, error) { + return _SwarmMail.Contract.FundsBalance(&_SwarmMail.CallOpts) +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) FundsBalance() (*big.Int, error) { + return _SwarmMail.Contract.FundsBalance(&_SwarmMail.CallOpts) +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_SwarmMail *SwarmMailCaller) GetActiveBidAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getActiveBidAt", addr, index) + + if err != nil { + return *new(SwarmMailActiveBid), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailActiveBid)).(*SwarmMailActiveBid) + + return out0, err + +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_SwarmMail *SwarmMailSession) GetActiveBidAt(addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { + return _SwarmMail.Contract.GetActiveBidAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_SwarmMail *SwarmMailCallerSession) GetActiveBidAt(addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { + return _SwarmMail.Contract.GetActiveBidAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_SwarmMail *SwarmMailCaller) GetActiveBids(opts *bind.CallOpts, addr common.Address) ([]SwarmMailActiveBid, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getActiveBids", addr) + + if err != nil { + return *new([]SwarmMailActiveBid), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailActiveBid)).(*[]SwarmMailActiveBid) + + return out0, err + +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_SwarmMail *SwarmMailSession) GetActiveBids(addr common.Address) ([]SwarmMailActiveBid, error) { + return _SwarmMail.Contract.GetActiveBids(&_SwarmMail.CallOpts, addr) +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_SwarmMail *SwarmMailCallerSession) GetActiveBids(addr common.Address) ([]SwarmMailActiveBid, error) { + return _SwarmMail.Contract.GetActiveBids(&_SwarmMail.CallOpts, addr) +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailCaller) GetAllSubItems(opts *bind.CallOpts, addr common.Address) ([]SwarmMailSubItem, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getAllSubItems", addr) + + if err != nil { + return *new([]SwarmMailSubItem), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) + + return out0, err + +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailSession) GetAllSubItems(addr common.Address) ([]SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetAllSubItems(&_SwarmMail.CallOpts, addr) +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailCallerSession) GetAllSubItems(addr common.Address) ([]SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetAllSubItems(&_SwarmMail.CallOpts, addr) +} + +// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. +// +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +func (_SwarmMail *SwarmMailCaller) GetBoxCount(opts *bind.CallOpts, addr common.Address) (struct { + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int +}, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getBoxCount", addr) + + outstruct := new(struct { + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.NumInboxItems = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.NumSentItems = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.NumSubRequests = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.NumSubItems = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + outstruct.NumActiveBids = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. +// +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +func (_SwarmMail *SwarmMailSession) GetBoxCount(addr common.Address) (struct { + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int +}, error) { + return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) +} + +// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. +// +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +func (_SwarmMail *SwarmMailCallerSession) GetBoxCount(addr common.Address) (struct { + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int +}, error) { + return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint256[])) +func (_SwarmMail *SwarmMailCaller) GetCategory(opts *bind.CallOpts, category [32]byte) (SwarmMailCategory, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getCategory", category) + + if err != nil { + return *new(SwarmMailCategory), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailCategory)).(*SwarmMailCategory) + + return out0, err + +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint256[])) +func (_SwarmMail *SwarmMailSession) GetCategory(category [32]byte) (SwarmMailCategory, error) { + return _SwarmMail.Contract.GetCategory(&_SwarmMail.CallOpts, category) +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint256[])) +func (_SwarmMail *SwarmMailCallerSession) GetCategory(category [32]byte) (SwarmMailCategory, error) { + return _SwarmMail.Contract.GetCategory(&_SwarmMail.CallOpts, category) +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetFee(opts *bind.CallOpts, _fee *big.Int, amount *big.Int) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getFee", _fee, amount) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_SwarmMail *SwarmMailSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { + return _SwarmMail.Contract.GetFee(&_SwarmMail.CallOpts, _fee, amount) +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { + return _SwarmMail.Contract.GetFee(&_SwarmMail.CallOpts, _fee, amount) +} + +// GetInbox is a free data retrieval call binding the contract method 0x02201681. +// +// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetInbox(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getInbox", addr) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetInbox is a free data retrieval call binding the contract method 0x02201681. +// +// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetInbox(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInbox(&_SwarmMail.CallOpts, addr) +} + +// GetInbox is a free data retrieval call binding the contract method 0x02201681. +// +// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetInbox(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInbox(&_SwarmMail.CallOpts, addr) +} + +// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. +// +// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailCaller) GetInboxAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getInboxAt", addr, index) + + if err != nil { + return *new(SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailEmail)).(*SwarmMailEmail) + + return out0, err + +} + +// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. +// +// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailSession) GetInboxAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInboxAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. +// +// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailCallerSession) GetInboxAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInboxAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_SwarmMail *SwarmMailCaller) GetListedSubs(opts *bind.CallOpts, addr common.Address) ([][32]byte, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getListedSubs", addr) + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_SwarmMail *SwarmMailSession) GetListedSubs(addr common.Address) ([][32]byte, error) { + return _SwarmMail.Contract.GetListedSubs(&_SwarmMail.CallOpts, addr) +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_SwarmMail *SwarmMailCallerSession) GetListedSubs(addr common.Address) ([][32]byte, error) { + return _SwarmMail.Contract.GetListedSubs(&_SwarmMail.CallOpts, addr) +} + +// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. +// +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr common.Address) (struct { + Registered bool + Key [32]byte + Smail [32]byte +}, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getPublicKeys", addr) + + outstruct := new(struct { + Registered bool + Key [32]byte + Smail [32]byte + }) + if err != nil { + return *outstruct, err + } + + outstruct.Registered = *abi.ConvertType(out[0], new(bool)).(*bool) + outstruct.Key = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.Smail = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) + + return *outstruct, err + +} + +// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. +// +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +func (_SwarmMail *SwarmMailSession) GetPublicKeys(addr common.Address) (struct { + Registered bool + Key [32]byte + Smail [32]byte +}, error) { + return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) +} + +// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. +// +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +func (_SwarmMail *SwarmMailCallerSession) GetPublicKeys(addr common.Address) (struct { + Registered bool + Key [32]byte + Smail [32]byte +}, error) { + return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_SwarmMail *SwarmMailCaller) GetRoleAdmin(opts *bind.CallOpts, role [32]byte) ([32]byte, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getRoleAdmin", role) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_SwarmMail *SwarmMailSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _SwarmMail.Contract.GetRoleAdmin(&_SwarmMail.CallOpts, role) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_SwarmMail *SwarmMailCallerSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _SwarmMail.Contract.GetRoleAdmin(&_SwarmMail.CallOpts, role) +} + +// GetSent is a free data retrieval call binding the contract method 0xd75d691d. +// +// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetSent(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSent", addr) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetSent is a free data retrieval call binding the contract method 0xd75d691d. +// +// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetSent(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSent(&_SwarmMail.CallOpts, addr) +} + +// GetSent is a free data retrieval call binding the contract method 0xd75d691d. +// +// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSent(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSent(&_SwarmMail.CallOpts, addr) +} + +// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. +// +// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailCaller) GetSentAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSentAt", addr, index) + + if err != nil { + return *new(SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailEmail)).(*SwarmMailEmail) + + return out0, err + +} + +// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. +// +// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailSession) GetSentAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSentAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. +// +// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) +func (_SwarmMail *SwarmMailCallerSession) GetSentAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSentAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. +// +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailCaller) GetSub(opts *bind.CallOpts, index *big.Int) (SwarmMailSub, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSub", index) + + if err != nil { + return *new(SwarmMailSub), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSub)).(*SwarmMailSub) + + return out0, err + +} + +// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. +// +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailSession) GetSub(index *big.Int) (SwarmMailSub, error) { + return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) +} + +// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. +// +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailCallerSession) GetSub(index *big.Int) (SwarmMailSub, error) { + return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailCaller) GetSubBy(opts *bind.CallOpts, subHash [32]byte) (SwarmMailSub, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubBy", subHash) + + if err != nil { + return *new(SwarmMailSub), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSub)).(*SwarmMailSub) + + return out0, err + +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { + return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +func (_SwarmMail *SwarmMailCallerSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { + return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetSubInfoBalance(opts *bind.CallOpts, subHash [32]byte, forAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubInfoBalance", subHash, forAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSubInfoBalance(&_SwarmMail.CallOpts, subHash, forAddress) +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSubInfoBalance(&_SwarmMail.CallOpts, subHash, forAddress) +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailCaller) GetSubItemAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailSubItem, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubItemAt", addr, index) + + if err != nil { + return *new(SwarmMailSubItem), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSubItem)).(*SwarmMailSubItem) + + return out0, err + +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailSession) GetSubItemAt(addr common.Address, index *big.Int) (SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItemAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailCallerSession) GetSubItemAt(addr common.Address, index *big.Int) (SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItemAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailCaller) GetSubItemBy(opts *bind.CallOpts, addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubItemBy", addr, subHash) + + if err != nil { + return *new(SwarmMailSubItem), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSubItem)).(*SwarmMailSubItem) + + return out0, err + +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailSession) GetSubItemBy(addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItemBy(&_SwarmMail.CallOpts, addr, subHash) +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_SwarmMail *SwarmMailCallerSession) GetSubItemBy(addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItemBy(&_SwarmMail.CallOpts, addr, subHash) +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailCaller) GetSubItems(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubItems", addr, start, length) + + if err != nil { + return *new([]SwarmMailSubItem), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) + + return out0, err + +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { + return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. +// +// Solidity: function getSubItemsCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetSubItemsCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubItemsCount", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. +// +// Solidity: function getSubItemsCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetSubItemsCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSubItemsCount(&_SwarmMail.CallOpts, addr) +} + +// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. +// +// Solidity: function getSubItemsCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetSubItemsCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSubItemsCount(&_SwarmMail.CallOpts, addr) +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailCaller) GetSubRequestAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubRequestAt", addr, index) + + if err != nil { + return *new(SwarmMailSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSubRequest)).(*SwarmMailSubRequest) + + return out0, err + +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailSession) GetSubRequestAt(addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequestAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailCallerSession) GetSubRequestAt(addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequestAt(&_SwarmMail.CallOpts, addr, index) +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailCaller) GetSubRequestByHash(opts *bind.CallOpts, addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubRequestByHash", addr, requestHash) + + if err != nil { + return *new(SwarmMailSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new(SwarmMailSubRequest)).(*SwarmMailSubRequest) + + return out0, err + +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequestByHash(&_SwarmMail.CallOpts, addr, requestHash) +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_SwarmMail *SwarmMailCallerSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequestByHash(&_SwarmMail.CallOpts, addr, requestHash) +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_SwarmMail *SwarmMailCaller) GetSubRequests(opts *bind.CallOpts, addr common.Address) ([]SwarmMailSubRequest, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubRequests", addr) + + if err != nil { + return *new([]SwarmMailSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailSubRequest)).(*[]SwarmMailSubRequest) + + return out0, err + +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_SwarmMail *SwarmMailSession) GetSubRequests(addr common.Address) ([]SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequests(&_SwarmMail.CallOpts, addr) +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSubRequests(addr common.Address) ([]SwarmMailSubRequest, error) { + return _SwarmMail.Contract.GetSubRequests(&_SwarmMail.CallOpts, addr) +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_SwarmMail *SwarmMailCaller) GetSubSubscribers(opts *bind.CallOpts, subHash [32]byte) ([]common.Address, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubSubscribers", subHash) + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_SwarmMail *SwarmMailSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { + return _SwarmMail.Contract.GetSubSubscribers(&_SwarmMail.CallOpts, subHash) +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_SwarmMail *SwarmMailCallerSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { + return _SwarmMail.Contract.GetSubSubscribers(&_SwarmMail.CallOpts, subHash) +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +func (_SwarmMail *SwarmMailCaller) GetSubs(opts *bind.CallOpts) ([]SwarmMailSub, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSubs") + + if err != nil { + return *new([]SwarmMailSub), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailSub)).(*[]SwarmMailSub) + + return out0, err + +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +func (_SwarmMail *SwarmMailSession) GetSubs() ([]SwarmMailSub, error) { + return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSubs() ([]SwarmMailSub, error) { + return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_SwarmMail *SwarmMailCaller) HasRole(opts *bind.CallOpts, role [32]byte, account common.Address) (bool, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "hasRole", role, account) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_SwarmMail *SwarmMailSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _SwarmMail.Contract.HasRole(&_SwarmMail.CallOpts, role, account) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_SwarmMail *SwarmMailCallerSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _SwarmMail.Contract.HasRole(&_SwarmMail.CallOpts, role, account) +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_SwarmMail *SwarmMailCaller) InEscrow(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "inEscrow") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_SwarmMail *SwarmMailSession) InEscrow() (*big.Int, error) { + return _SwarmMail.Contract.InEscrow(&_SwarmMail.CallOpts) +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) InEscrow() (*big.Int, error) { + return _SwarmMail.Contract.InEscrow(&_SwarmMail.CallOpts) +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_SwarmMail *SwarmMailCaller) MarketFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "marketFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_SwarmMail *SwarmMailSession) MarketFee() (*big.Int, error) { + return _SwarmMail.Contract.MarketFee(&_SwarmMail.CallOpts) +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) MarketFee() (*big.Int, error) { + return _SwarmMail.Contract.MarketFee(&_SwarmMail.CallOpts) +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_SwarmMail *SwarmMailCaller) MinListingFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "minListingFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_SwarmMail *SwarmMailSession) MinListingFee() (*big.Int, error) { + return _SwarmMail.Contract.MinListingFee(&_SwarmMail.CallOpts) +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) MinListingFee() (*big.Int, error) { + return _SwarmMail.Contract.MinListingFee(&_SwarmMail.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SwarmMail *SwarmMailCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SwarmMail *SwarmMailSession) Owner() (common.Address, error) { + return _SwarmMail.Contract.Owner(&_SwarmMail.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_SwarmMail *SwarmMailCallerSession) Owner() (common.Address, error) { + return _SwarmMail.Contract.Owner(&_SwarmMail.CallOpts) +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) SubscriptionIds(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "subscriptionIds", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_SwarmMail *SwarmMailSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { + return _SwarmMail.Contract.SubscriptionIds(&_SwarmMail.CallOpts, arg0) +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { + return _SwarmMail.Contract.SubscriptionIds(&_SwarmMail.CallOpts, arg0) +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 +}, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "subscriptions", arg0) + + outstruct := new(struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + }) + if err != nil { + return *outstruct, err + } + + outstruct.SubHash = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.FdpSellerNameHash = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.Seller = *abi.ConvertType(out[2], new(common.Address)).(*common.Address) + outstruct.SwarmLocation = *abi.ConvertType(out[3], new([32]byte)).(*[32]byte) + outstruct.Price = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.Active = *abi.ConvertType(out[5], new(bool)).(*bool) + outstruct.Earned = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int) + outstruct.Bids = *abi.ConvertType(out[7], new(uint32)).(*uint32) + outstruct.Sells = *abi.ConvertType(out[8], new(uint32)).(*uint32) + outstruct.Reports = *abi.ConvertType(out[9], new(uint32)).(*uint32) + + return *outstruct, err + +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +func (_SwarmMail *SwarmMailSession) Subscriptions(arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 +}, error) { + return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +func (_SwarmMail *SwarmMailCallerSession) Subscriptions(arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 +}, error) { + return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_SwarmMail *SwarmMailCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "supportsInterface", interfaceId) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_SwarmMail *SwarmMailSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _SwarmMail.Contract.SupportsInterface(&_SwarmMail.CallOpts, interfaceId) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_SwarmMail *SwarmMailCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _SwarmMail.Contract.SupportsInterface(&_SwarmMail.CallOpts, interfaceId) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_SwarmMail *SwarmMailTransactor) BidSub(opts *bind.TransactOpts, subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "bidSub", subHash, fdpBuyerNameHash) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_SwarmMail *SwarmMailSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.BidSub(&_SwarmMail.TransactOpts, subHash, fdpBuyerNameHash) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.BidSub(&_SwarmMail.TransactOpts, subHash, fdpBuyerNameHash) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_SwarmMail *SwarmMailTransactor) EnableSub(opts *bind.TransactOpts, subHash [32]byte, active bool) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "enableSub", subHash, active) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_SwarmMail *SwarmMailSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { + return _SwarmMail.Contract.EnableSub(&_SwarmMail.TransactOpts, subHash, active) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_SwarmMail *SwarmMailTransactorSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { + return _SwarmMail.Contract.EnableSub(&_SwarmMail.TransactOpts, subHash, active) +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_SwarmMail *SwarmMailTransactor) FundsTransfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "fundsTransfer") +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_SwarmMail *SwarmMailSession) FundsTransfer() (*types.Transaction, error) { + return _SwarmMail.Contract.FundsTransfer(&_SwarmMail.TransactOpts) +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_SwarmMail *SwarmMailTransactorSession) FundsTransfer() (*types.Transaction, error) { + return _SwarmMail.Contract.FundsTransfer(&_SwarmMail.TransactOpts) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactor) GrantRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "grantRole", role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.GrantRole(&_SwarmMail.TransactOpts, role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactorSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.GrantRole(&_SwarmMail.TransactOpts, role, account) +} + +// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() +func (_SwarmMail *SwarmMailTransactor) ListSub(opts *bind.TransactOpts, fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "listSub", fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +} + +// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() +func (_SwarmMail *SwarmMailSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +} + +// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +} + +// Register is a paid mutator transaction binding the contract method 0x2f926732. +// +// Solidity: function register(bytes32 key, bytes32 smail) returns() +func (_SwarmMail *SwarmMailTransactor) Register(opts *bind.TransactOpts, key [32]byte, smail [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "register", key, smail) +} + +// Register is a paid mutator transaction binding the contract method 0x2f926732. +// +// Solidity: function register(bytes32 key, bytes32 smail) returns() +func (_SwarmMail *SwarmMailSession) Register(key [32]byte, smail [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.Register(&_SwarmMail.TransactOpts, key, smail) +} + +// Register is a paid mutator transaction binding the contract method 0x2f926732. +// +// Solidity: function register(bytes32 key, bytes32 smail) returns() +func (_SwarmMail *SwarmMailTransactorSession) Register(key [32]byte, smail [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.Register(&_SwarmMail.TransactOpts, key, smail) +} + +// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. +// +// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveEmails(opts *bind.TransactOpts, types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeEmails", types, swarmLocations) +} + +// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. +// +// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() +func (_SwarmMail *SwarmMailSession) RemoveEmails(types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveEmails(&_SwarmMail.TransactOpts, types, swarmLocations) +} + +// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. +// +// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveEmails(types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveEmails(&_SwarmMail.TransactOpts, types, swarmLocations) +} + +// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. +// +// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveInboxEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeInboxEmail", swarmLocation) +} + +// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. +// +// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailSession) RemoveInboxEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveInboxEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. +// +// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveInboxEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveInboxEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. +// +// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveSentEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeSentEmail", swarmLocation) +} + +// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. +// +// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailSession) RemoveSentEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveSentEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. +// +// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveSentEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveSentEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. +// +// Solidity: function removeSubItem(uint256 index) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveSubItem(opts *bind.TransactOpts, index *big.Int) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeSubItem", index) +} + +// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. +// +// Solidity: function removeSubItem(uint256 index) returns() +func (_SwarmMail *SwarmMailSession) RemoveSubItem(index *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveSubItem(&_SwarmMail.TransactOpts, index) +} + +// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. +// +// Solidity: function removeSubItem(uint256 index) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveSubItem(index *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveSubItem(&_SwarmMail.TransactOpts, index) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveUserActiveBid(opts *bind.TransactOpts, requestHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeUserActiveBid", requestHash) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_SwarmMail *SwarmMailSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveUserActiveBid(&_SwarmMail.TransactOpts, requestHash) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveUserActiveBid(&_SwarmMail.TransactOpts, requestHash) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SwarmMail *SwarmMailTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SwarmMail *SwarmMailSession) RenounceOwnership() (*types.Transaction, error) { + return _SwarmMail.Contract.RenounceOwnership(&_SwarmMail.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_SwarmMail *SwarmMailTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _SwarmMail.Contract.RenounceOwnership(&_SwarmMail.TransactOpts) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactor) RenounceRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "renounceRole", role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.RenounceRole(&_SwarmMail.TransactOpts, role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactorSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.RenounceRole(&_SwarmMail.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactor) RevokeRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "revokeRole", role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.RevokeRole(&_SwarmMail.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_SwarmMail *SwarmMailTransactorSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.RevokeRole(&_SwarmMail.TransactOpts, role, account) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_SwarmMail *SwarmMailTransactor) SellSub(opts *bind.TransactOpts, requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "sellSub", requestHash, encryptedKeyLocation) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_SwarmMail *SwarmMailSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SellSub(&_SwarmMail.TransactOpts, requestHash, encryptedKeyLocation) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SellSub(&_SwarmMail.TransactOpts, requestHash, encryptedKeyLocation) +} + +// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. +// +// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailTransactor) SendEmail(opts *bind.TransactOpts, toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "sendEmail", toAddress, isEncryption, swarmLocation) +} + +// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. +// +// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailSession) SendEmail(toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SendEmail(&_SwarmMail.TransactOpts, toAddress, isEncryption, swarmLocation) +} + +// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. +// +// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) SendEmail(toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SendEmail(&_SwarmMail.TransactOpts, toAddress, isEncryption, swarmLocation) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_SwarmMail *SwarmMailTransactor) SetFee(opts *bind.TransactOpts, newFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "setFee", newFee) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_SwarmMail *SwarmMailSession) SetFee(newFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.SetFee(&_SwarmMail.TransactOpts, newFee) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_SwarmMail *SwarmMailTransactorSession) SetFee(newFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.SetFee(&_SwarmMail.TransactOpts, newFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_SwarmMail *SwarmMailTransactor) SetListingFee(opts *bind.TransactOpts, newListingFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "setListingFee", newListingFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_SwarmMail *SwarmMailSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.SetListingFee(&_SwarmMail.TransactOpts, newListingFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_SwarmMail *SwarmMailTransactorSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.SetListingFee(&_SwarmMail.TransactOpts, newListingFee) +} + +// SignEmail is a paid mutator transaction binding the contract method 0x87134952. +// +// Solidity: function signEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactor) SignEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "signEmail", swarmLocation) +} + +// SignEmail is a paid mutator transaction binding the contract method 0x87134952. +// +// Solidity: function signEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailSession) SignEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SignEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// SignEmail is a paid mutator transaction binding the contract method 0x87134952. +// +// Solidity: function signEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactorSession) SignEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.SignEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SwarmMail *SwarmMailTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SwarmMail *SwarmMailSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.TransferOwnership(&_SwarmMail.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_SwarmMail *SwarmMailTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.TransferOwnership(&_SwarmMail.TransactOpts, newOwner) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_SwarmMail *SwarmMailTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _SwarmMail.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_SwarmMail *SwarmMailSession) Receive() (*types.Transaction, error) { + return _SwarmMail.Contract.Receive(&_SwarmMail.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_SwarmMail *SwarmMailTransactorSession) Receive() (*types.Transaction, error) { + return _SwarmMail.Contract.Receive(&_SwarmMail.TransactOpts) +} + +// SwarmMailOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the SwarmMail contract. +type SwarmMailOwnershipTransferredIterator struct { + Event *SwarmMailOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SwarmMailOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SwarmMailOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SwarmMailOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SwarmMailOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SwarmMailOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SwarmMailOwnershipTransferred represents a OwnershipTransferred event raised by the SwarmMail contract. +type SwarmMailOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SwarmMail *SwarmMailFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SwarmMailOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &SwarmMailOwnershipTransferredIterator{contract: _SwarmMail.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SwarmMail *SwarmMailFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SwarmMailOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SwarmMailOwnershipTransferred) + if err := _SwarmMail.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_SwarmMail *SwarmMailFilterer) ParseOwnershipTransferred(log types.Log) (*SwarmMailOwnershipTransferred, error) { + event := new(SwarmMailOwnershipTransferred) + if err := _SwarmMail.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SwarmMailRoleAdminChangedIterator is returned from FilterRoleAdminChanged and is used to iterate over the raw logs and unpacked data for RoleAdminChanged events raised by the SwarmMail contract. +type SwarmMailRoleAdminChangedIterator struct { + Event *SwarmMailRoleAdminChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SwarmMailRoleAdminChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SwarmMailRoleAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SwarmMailRoleAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SwarmMailRoleAdminChanged represents a RoleAdminChanged event raised by the SwarmMail contract. +type SwarmMailRoleAdminChanged struct { + Role [32]byte + PreviousAdminRole [32]byte + NewAdminRole [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleAdminChanged is a free log retrieval operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_SwarmMail *SwarmMailFilterer) FilterRoleAdminChanged(opts *bind.FilterOpts, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (*SwarmMailRoleAdminChangedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return &SwarmMailRoleAdminChangedIterator{contract: _SwarmMail.contract, event: "RoleAdminChanged", logs: logs, sub: sub}, nil +} + +// WatchRoleAdminChanged is a free log subscription operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_SwarmMail *SwarmMailFilterer) WatchRoleAdminChanged(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleAdminChanged, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SwarmMailRoleAdminChanged) + if err := _SwarmMail.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleAdminChanged is a log parse operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_SwarmMail *SwarmMailFilterer) ParseRoleAdminChanged(log types.Log) (*SwarmMailRoleAdminChanged, error) { + event := new(SwarmMailRoleAdminChanged) + if err := _SwarmMail.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SwarmMailRoleGrantedIterator is returned from FilterRoleGranted and is used to iterate over the raw logs and unpacked data for RoleGranted events raised by the SwarmMail contract. +type SwarmMailRoleGrantedIterator struct { + Event *SwarmMailRoleGranted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SwarmMailRoleGrantedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleGranted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleGranted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SwarmMailRoleGrantedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SwarmMailRoleGrantedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SwarmMailRoleGranted represents a RoleGranted event raised by the SwarmMail contract. +type SwarmMailRoleGranted struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleGranted is a free log retrieval operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) FilterRoleGranted(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*SwarmMailRoleGrantedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &SwarmMailRoleGrantedIterator{contract: _SwarmMail.contract, event: "RoleGranted", logs: logs, sub: sub}, nil +} + +// WatchRoleGranted is a free log subscription operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) WatchRoleGranted(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleGranted, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SwarmMailRoleGranted) + if err := _SwarmMail.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleGranted is a log parse operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) ParseRoleGranted(log types.Log) (*SwarmMailRoleGranted, error) { + event := new(SwarmMailRoleGranted) + if err := _SwarmMail.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// SwarmMailRoleRevokedIterator is returned from FilterRoleRevoked and is used to iterate over the raw logs and unpacked data for RoleRevoked events raised by the SwarmMail contract. +type SwarmMailRoleRevokedIterator struct { + Event *SwarmMailRoleRevoked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *SwarmMailRoleRevokedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleRevoked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(SwarmMailRoleRevoked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *SwarmMailRoleRevokedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *SwarmMailRoleRevokedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// SwarmMailRoleRevoked represents a RoleRevoked event raised by the SwarmMail contract. +type SwarmMailRoleRevoked struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleRevoked is a free log retrieval operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) FilterRoleRevoked(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*SwarmMailRoleRevokedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &SwarmMailRoleRevokedIterator{contract: _SwarmMail.contract, event: "RoleRevoked", logs: logs, sub: sub}, nil +} + +// WatchRoleRevoked is a free log subscription operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) WatchRoleRevoked(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleRevoked, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(SwarmMailRoleRevoked) + if err := _SwarmMail.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleRevoked is a log parse operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_SwarmMail *SwarmMailFilterer) ParseRoleRevoked(log types.Log) (*SwarmMailRoleRevoked, error) { + event := new(SwarmMailRoleRevoked) + if err := _SwarmMail.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/dfs/api.go b/pkg/dfs/api.go index e5a994c6..5960d228 100644 --- a/pkg/dfs/api.go +++ b/pkg/dfs/api.go @@ -22,6 +22,9 @@ import ( "io" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore" @@ -42,6 +45,7 @@ type API struct { users *user.Users logger logging.Logger tm *taskmanager.TaskManager + sm subscriptionManager.SubscriptionManager io.Closer } @@ -60,6 +64,10 @@ func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.Config, logge } users := user.NewUsers(c, ens, logger) + sm, err := rpc.New(logger, c, c) + if err != nil { + return nil, errSubManager + } // discard tm logs as it creates too much noise tmLogger := logging.New(io.Discard, 0) @@ -68,6 +76,7 @@ func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.Config, logge users: users, logger: logger, tm: taskmanager.New(10, defaultMaxWorkers, time.Second*15, tmLogger), + sm: sm, }, nil } diff --git a/pkg/dfs/errors.go b/pkg/dfs/errors.go index 2a88b094..ae564b42 100644 --- a/pkg/dfs/errors.go +++ b/pkg/dfs/errors.go @@ -29,7 +29,9 @@ var ( ErrFileAlreadyPresent = errors.New("file already exist with new name") //ErrBeeClient - ErrBeeClient = errors.New("could not connect to bee client") - errEthClient = errors.New("could not connect to eth backend") - errReadOnlyPod = errors.New("operation not permitted: read only pod") + ErrBeeClient = errors.New("could not connect to bee client") + errEthClient = errors.New("could not connect to eth backend") + errSubManager = errors.New("subscription manager initialisation failed") + errNilSubManager = errors.New("subscription manager not initialised") + errReadOnlyPod = errors.New("operation not permitted: read only pod") ) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 6d299b56..10f43a95 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -20,6 +20,8 @@ import ( "context" "encoding/hex" + SwarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" "github.com/fairdatasociety/fairOS-dfs/pkg/user" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -390,3 +392,165 @@ func (a *API) prepareOwnPod(ui *user.Info, podName string) (*pod.Info, error) { return pi, nil } + +// ListPodInMarketplace +func (a *API) ListPodInMarketplace(podName, title, desc, thumbnail, sessionId string, price uint64, category [32]byte) error { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return ErrUserNotLoggedIn + } + + if a.sm == nil { + return errNilSubManager + } + + nameHash, err := a.users.GetNameHash(ui.GetUserName()) + if err != nil { + return err + } + + return ui.GetPod().ListPodInMarketplace(podName, title, desc, thumbnail, price, category, nameHash) +} + +// ChangePodListStatusInMarketplace +func (a *API) ChangePodListStatusInMarketplace(sessionId string, subHash [32]byte, show bool) error { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return ErrUserNotLoggedIn + } + + if a.sm == nil { + return errNilSubManager + } + + return ui.GetPod().PodStatusInMarketplace(subHash, show) +} + +// RequestSubscription +func (a *API) RequestSubscription(sessionId string, subHash [32]byte) error { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return ErrUserNotLoggedIn + } + + if a.sm == nil { + return errNilSubManager + } + + nameHash, err := a.users.GetNameHash(ui.GetUserName()) + if err != nil { + return err + } + return ui.GetPod().RequestSubscription(subHash, nameHash) +} + +// ApproveSubscription +func (a *API) ApproveSubscription(sessionId, podName string, reqHash, nameHash [32]byte) error { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return ErrUserNotLoggedIn + } + + if a.sm == nil { + return errNilSubManager + } + + _, subscriberPublicKey, err := a.users.GetUserInfoFromENS(nameHash) + if err != nil { + return err + } + + return ui.GetPod().ApproveSubscription(podName, reqHash, subscriberPublicKey) +} + +type SubscriptionInfo struct { + SubHash [32]byte + PodName string + PodAddress string + InfoLocation []byte + ValidTill int64 +} + +// GetSubscriptions +func (a *API) GetSubscriptions(sessionId string, start, limit uint64) ([]*SubscriptionInfo, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + if a.sm == nil { + return nil, errNilSubManager + } + + subscriptions, err := ui.GetPod().GetSubscriptions(start, limit) + if err != nil { + return nil, err + } + + subs := []*SubscriptionInfo{} + for _, item := range subscriptions { + info, err := ui.GetPod().GetSubscribablePodInfo(item.SubHash) + if err != nil { + return subs, err + } + sub := &SubscriptionInfo{ + SubHash: item.SubHash, + PodName: info.PodName, + PodAddress: info.PodAddress, + InfoLocation: item.UnlockKeyLocation[:], + ValidTill: item.ValidTill.Int64(), + } + subs = append(subs, sub) + } + + return subs, nil +} + +// OpenSubscribedPod +func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, error) { + + sub, err := a.sm.GetSub(subHash) + if err != nil { + return nil, err + } + + _, ownerPublicKey, err := a.users.GetUserInfoFromENS(sub.FdpSellerNameHash) + if err != nil { + return nil, err + } + + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + // open the pod + pi, err := ui.GetPod().OpenSubscribedPod(subHash, ownerPublicKey) + if err != nil { + return nil, err + } + err = pi.GetDirectory().AddRootDir(pi.GetPodName(), pi.GetPodPassword(), pi.GetPodAddress(), pi.GetFeed()) + if err != nil { + return nil, err + } + // Add podName in the login user session + ui.AddPodName(pi.GetPodName(), pi) + return pi, nil +} + +// GetSubscribablePods +func (a *API) GetSubscribablePods(sessionId string) ([]SwarmMail.SwarmMailSub, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + return ui.GetPod().GetMarketplace() +} diff --git a/pkg/dfs/user_api.go b/pkg/dfs/user_api.go index 0924a713..d565018c 100644 --- a/pkg/dfs/user_api.go +++ b/pkg/dfs/user_api.go @@ -22,17 +22,17 @@ import ( // CreateUserV2 is a controller function which calls the create user function from the user object. func (a *API) CreateUserV2(userName, passPhrase, mnemonic, sessionId string) (string, string, string, string, *user.Info, error) { - return a.users.CreateNewUserV2(userName, passPhrase, mnemonic, sessionId, a.tm) + return a.users.CreateNewUserV2(userName, passPhrase, mnemonic, sessionId, a.tm, a.sm) } // LoginUserV2 is a controller function which calls the users login function. func (a *API) LoginUserV2(userName, passPhrase, sessionId string) (*user.Info, string, string, error) { - return a.users.LoginUserV2(userName, passPhrase, a.client, a.tm, sessionId) + return a.users.LoginUserV2(userName, passPhrase, a.client, a.tm, a.sm, sessionId) } // LoadLiteUser is a controller function which loads user from mnemonic and doesn't store any user info on chain func (a *API) LoadLiteUser(userName, passPhrase, mnemonic, sessionId string) (string, string, *user.Info, error) { - return a.users.LoadLiteUser(userName, passPhrase, mnemonic, sessionId, a.tm) + return a.users.LoadLiteUser(userName, passPhrase, mnemonic, sessionId, a.tm, a.sm) } // LogoutUser is a controller function which gets the logged-in user information and logs it out. @@ -78,3 +78,13 @@ func (a *API) GetUserStat(sessionId string) (*user.Stat, error) { return a.users.GetUserStat(ui) } + +// ConnectPortableAccountWithWallet is a controller function which calls the users login function. +func (a *API) ConnectPortableAccountWithWallet(userName, passPhrase, addressHex, signature string) error { + return a.users.ConnectWallet(userName, passPhrase, addressHex, signature, a.client) +} + +// LoginWithWallet is a controller function which calls the users login function. +func (a *API) LoginWithWallet(addressHex, signature, sessionId string) (*user.Info, error) { + return a.users.LoginWithWallet(addressHex, signature, a.client, a.tm, a.sm, sessionId) +} diff --git a/pkg/ensm/ensm.go b/pkg/ensm/ensm.go index 7ee94cfd..84605f4d 100644 --- a/pkg/ensm/ensm.go +++ b/pkg/ensm/ensm.go @@ -15,4 +15,6 @@ type ENSManager interface { SetResolver(username string, owner common.Address, key *ecdsa.PrivateKey) (string, error) SetAll(username string, owner common.Address, key *ecdsa.PrivateKey) error GetInfo(username string) (*ecdsa.PublicKey, string, error) + GetInfoFromNameHash(node [32]byte) (common.Address, *ecdsa.PublicKey, string, error) + GetNameHash(username string) ([32]byte, error) } diff --git a/pkg/ensm/eth/eth.go b/pkg/ensm/eth/eth.go index f6ccd740..a077cda4 100644 --- a/pkg/ensm/eth/eth.go +++ b/pkg/ensm/eth/eth.go @@ -205,11 +205,21 @@ func (c *Client) GetInfo(username string) (*ecdsa.PublicKey, string, error) { return nil, "", err } + _, pub, nameHashStr, err := c.GetInfoFromNameHash(node) + if err != nil { + return nil, "", err + } + + return pub, nameHashStr, nil +} + +// GetInfoFromNameHash returns the public key of the user from nameHash +func (c *Client) GetInfoFromNameHash(node [32]byte) (common.Address, *ecdsa.PublicKey, string, error) { opts := &bind.CallOpts{} info, err := c.publicResolver.GetAll(opts, node) if err != nil { c.logger.Error("public resolver get all failed : ", err) - return nil, "", err + return common.Address{}, nil, "", err } x := new(big.Int) x.SetBytes(info.X[:]) @@ -222,7 +232,11 @@ func (c *Client) GetInfo(username string) (*ecdsa.PublicKey, string, error) { pub.Curve = btcec.S256() nameHash := node[:] - return pub, utils.Encode(nameHash), nil + return info.Addr, pub, utils.Encode(nameHash), nil +} + +func (c *Client) GetNameHash(username string) ([32]byte, error) { + return goens.NameHash(username + "." + c.ensConfig.ProviderDomain) } func (c *Client) newTransactor(key *ecdsa.PrivateKey, account common.Address) (*bind.TransactOpts, error) { diff --git a/pkg/ensm/eth/mock/eth.go b/pkg/ensm/eth/mock/eth.go index 1242bfd3..72bc2a8e 100644 --- a/pkg/ensm/eth/mock/eth.go +++ b/pkg/ensm/eth/mock/eth.go @@ -6,6 +6,9 @@ import ( "math/big" "sync" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + goens "github.com/wealdtech/go-ens/v3" + "github.com/btcsuite/btcd/btcec" "github.com/ethereum/go-ethereum/common" ) @@ -25,6 +28,40 @@ type NamespaceManager struct { storerMu sync.RWMutex } +func (c *NamespaceManager) GetInfoFromNameHash(node [32]byte) (common.Address, *ecdsa.PublicKey, string, error) { + c.storerMu.Lock() + defer c.storerMu.Unlock() + + for username, i := range c.publicResolver { + nh, err := goens.NameHash(username) + if err != nil { + return common.Address{}, nil, "", err + } + if nh == node { + addr := c.storer[username] + if addr == "" { + return common.Address{}, nil, "", fmt.Errorf("username not available") + } + x := new(big.Int) + x.SetBytes(i.X[:]) + + y := new(big.Int) + y.SetBytes(i.Y[:]) + pub := new(ecdsa.PublicKey) + pub.X = x + pub.Y = y + + pub.Curve = btcec.S256() + return common.HexToAddress(addr), pub, utils.Encode(nh[:]), nil + } + } + return common.Address{}, nil, "", fmt.Errorf("info not available") +} + +func (c *NamespaceManager) GetNameHash(username string) ([32]byte, error) { + return goens.NameHash(username) +} + // GetInfo returns the public key of the user func (c *NamespaceManager) GetInfo(username string) (*ecdsa.PublicKey, string, error) { c.storerMu.Lock() diff --git a/pkg/pod/open.go b/pkg/pod/open.go index f07f0798..cefae900 100644 --- a/pkg/pod/open.go +++ b/pkg/pod/open.go @@ -55,7 +55,7 @@ func (p *Pod) OpenPod(podName string) (*Info, error) { ) if sharedPodType { var addressString string - addressString, podPassword = p.getAddressPassword(podList, podName) + addressString, podPassword = p.getSharedAddressPassword(podList, podName) if addressString == "" { // skipcq: TCV-001 return nil, fmt.Errorf("shared pod does not exist") } @@ -116,12 +116,7 @@ func (p *Pod) OpenPod(podName string) (*Info, error) { return podInfo, nil } -func (p *Pod) OpenFromReference(ref utils.Reference) (*Info, error) { - si, err := p.ReceivePodInfo(ref) - if err != nil { - return nil, err - } - +func (p *Pod) OpenFromShareInfo(si *ShareInfo) (*Info, error) { accountInfo := p.acc.GetEmptyAccountInfo() address := utils.HexToAddress(si.Address) accountInfo.SetAddress(address) @@ -147,7 +142,7 @@ func (p *Pod) OpenFromReference(ref utils.Reference) (*Info, error) { p.addPodToPodMap(si.PodName, podInfo) // sync the pod's files and directories - err = p.SyncPod(si.PodName) + err := p.SyncPod(si.PodName) if err != nil && err != d.ErrResourceDeleted { // skipcq: TCV-001 return nil, err } @@ -184,7 +179,7 @@ func (p *Pod) OpenPodAsync(ctx context.Context, podName string) (*Info, error) { ) if sharedPodType { var addressString string - addressString, podPassword = p.getAddressPassword(podList, podName) + addressString, podPassword = p.getSharedAddressPassword(podList, podName) if addressString == "" { // skipcq: TCV-001 return nil, fmt.Errorf("shared pod does not exist") } @@ -253,7 +248,7 @@ func (*Pod) getIndexPassword(podList *List, podName string) (int, string) { return -1, "" // skipcq: TCV-001 } -func (*Pod) getAddressPassword(podList *List, podName string) (string, string) { +func (*Pod) getSharedAddressPassword(podList *List, podName string) (string, string) { for _, pod := range podList.SharedPods { if pod.Name == podName { return pod.Address, pod.Password @@ -261,3 +256,13 @@ func (*Pod) getAddressPassword(podList *List, podName string) (string, string) { } return "", "" } + +func (p *Pod) getAddressPassword(podList *List, podName string) (string, string) { + for _, pod := range podList.Pods { + if pod.Name == podName { + addr := p.acc.GetAddress(pod.Index) + return addr.Hex(), pod.Password + } + } + return "", "" +} diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 3f9f9567..e42dabc9 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -20,6 +20,8 @@ import ( "fmt" "sync" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" @@ -43,6 +45,7 @@ type Pod struct { podMu *sync.RWMutex logger logging.Logger tm taskmanager.TaskManagerGO + sm subscriptionManager.SubscriptionManager } // ListItem defines the structure for pod item @@ -67,7 +70,7 @@ type List struct { // NewPod creates the main pod object which has all the methods related to the pods. func NewPod(client blockstore.Client, feed *feed.API, account *account.Account, - m taskmanager.TaskManagerGO, logger logging.Logger) *Pod { + m taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, logger logging.Logger) *Pod { return &Pod{ fd: feed, acc: account, @@ -76,6 +79,7 @@ func NewPod(client blockstore.Client, feed *feed.API, account *account.Account, podMu: &sync.RWMutex{}, logger: logger, tm: m, + sm: sm, } } diff --git a/pkg/pod/sharing.go b/pkg/pod/sharing.go index a192a2b2..a9779d18 100644 --- a/pkg/pod/sharing.go +++ b/pkg/pod/sharing.go @@ -81,6 +81,39 @@ func (p *Pod) PodShare(podName, sharedPodName string) (string, error) { return shareInfoRef.String(), nil } +// GetPodSharingInfo returns the raw shareInfo +func (p *Pod) GetPodSharingInfo(podName string) (*ShareInfo, error) { + // check if pods is present and get the index of the pod + podList, err := p.loadUserPods() + if err != nil { // skipcq: TCV-001 + return nil, err + } + if !p.checkIfPodPresent(podList, podName) { + return nil, ErrInvalidPodName + } + + index, podPassword := p.getIndexPassword(podList, podName) + if index == -1 { // skipcq: TCV-001 + return nil, fmt.Errorf("pod does not exist") + } + + // Create pod account and get the address + accountInfo, err := p.acc.CreatePodAccount(index, false) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + address := accountInfo.GetAddress() + userAddress := p.acc.GetUserAccountInfo().GetAddress() + + return &ShareInfo{ + PodName: podName, + Password: podPassword, + Address: address.String(), + UserAddress: userAddress.String(), + }, nil +} + // ReceivePodInfo func (p *Pod) ReceivePodInfo(ref utils.Reference) (*ShareInfo, error) { data, resp, err := p.client.DownloadBlob(ref.Bytes()) @@ -99,7 +132,6 @@ func (p *Pod) ReceivePodInfo(ref utils.Reference) (*ShareInfo, error) { } return &shareInfo, nil - } // ReceivePod diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go new file mode 100644 index 00000000..e033f869 --- /dev/null +++ b/pkg/pod/subscription.go @@ -0,0 +1,98 @@ +package pod + +import ( + "crypto/ecdsa" + "crypto/sha256" + "fmt" + + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + + "github.com/ethereum/go-ethereum/common" + swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" +) + +// ListPodInMarketplace will save the pod info in the subscriptionManager smart contract with its owner and price +// we keep the pod info in the smart contract, with a `list` flag +func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, category, nameHash [32]byte) error { + podList, err := p.loadUserPods() + if err != nil { // skipcq: TCV-001 + return err + } + if !p.checkIfPodPresent(podList, podName) { + return ErrInvalidPodName + } + + strAddr, _ := p.getAddressPassword(podList, podName) + if strAddr == "" { // skipcq: TCV-001 + return fmt.Errorf("pod does not exist") + } + + podAddress := common.HexToAddress(strAddr) + + return p.sm.AddPodToMarketplace(podAddress, common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), podName, title, desc, thumbnail, price, category, nameHash, p.acc.GetUserAccountInfo().GetPrivateKey()) +} + +// PodStatusInMarketplace will change the `list` flag for the pod so that it's not listed or gets re listed in the pod marketplace +func (p *Pod) PodStatusInMarketplace(subHash [32]byte, show bool) error { + hide := !show + return p.sm.HidePodFromMarketplace(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), subHash, hide, p.acc.GetUserAccountInfo().GetPrivateKey()) +} + +// ApproveSubscription will send a subscriptionManager request to the owner of the pod +func (p *Pod) ApproveSubscription(podName string, requestHash [32]byte, subscriberPublicKey *ecdsa.PublicKey) error { + a, _ := subscriberPublicKey.Curve.ScalarMult(subscriberPublicKey.X, subscriberPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + + shareInfo, err := p.GetPodSharingInfo(podName) + if err != nil { + return err + } + + info := &rpc.ShareInfo{ + PodName: shareInfo.PodName, + Address: shareInfo.Address, + Password: shareInfo.Password, + UserAddress: shareInfo.UserAddress, + } + + return p.sm.AllowAccess(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), info, requestHash, secret, p.acc.GetUserAccountInfo().GetPrivateKey()) +} + +// RequestSubscription will send a subscriptionManager request to the owner of the pod +// will create an escrow account and deposit the `price` +func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error { + return p.sm.RequestAccess(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), subHash, nameHash, p.acc.GetUserAccountInfo().GetPrivateKey()) +} + +// GetSubscriptions will query the smart contract and list my subscriptions +func (p *Pod) GetSubscriptions(start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) { + return p.sm.GetSubscriptions(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), start, limit) +} + +// GetMarketplace will query the smart contract make the `list` all the pod from the marketplace +func (p *Pod) GetMarketplace() ([]swarmMail.SwarmMailSub, error) { + return p.sm.GetAllSubscribablePods() +} + +// GetSubscribablePodInfo will query the smart contract and get info by subHash +func (p *Pod) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) { + return p.sm.GetSubscribablePodInfo(subHash) +} + +// OpenSubscribedPod will open a subscribed pod +func (p *Pod) OpenSubscribedPod(subHash [32]byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { + a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + info, err := p.sm.GetSubscription(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), subHash, secret) + if err != nil { + return nil, err + } + + shareInfo := &ShareInfo{ + PodName: info.PodName, + Address: info.Address, + Password: info.Password, + UserAddress: info.UserAddress, + } + return p.OpenFromShareInfo(shareInfo) +} diff --git a/pkg/subscription/rpc/mock/rpc.go b/pkg/subscription/rpc/mock/rpc.go deleted file mode 100644 index c9c926f9..00000000 --- a/pkg/subscription/rpc/mock/rpc.go +++ /dev/null @@ -1,157 +0,0 @@ -package mock - -import ( - "fmt" - "strings" - "sync" - "time" - - "github.com/ethereum/go-ethereum/common" -) - -type PodItem struct { - Name string `json:"name"` - Price uint64 `json:"price"` - Address common.Address `json:"address"` - Owner common.Address `json:"owner"` - IsListed bool `json:"isListed"` -} - -type SubbedItem struct { - Name string `json:"name"` - Address common.Address `json:"address"` - EndsAt int64 `json:"ends_at"` - Secret string `json:"secret"` - Owner common.Address `json:"owner"` -} - -type requestInfo struct { - Name string `json:"name"` - Address common.Address `json:"address"` - Subscriber common.Address `json:"owner"` -} - -type SubscriptionManager struct { - lock sync.Mutex - listMap map[string]*PodItem - subscriptionMap map[string]*SubbedItem - requestMap map[string]requestInfo -} - -// NewMockSubscriptionManager returns a new mock subscription manager client -func NewMockSubscriptionManager() *SubscriptionManager { - return &SubscriptionManager{ - listMap: make(map[string]*PodItem), - subscriptionMap: make(map[string]*SubbedItem), - requestMap: make(map[string]requestInfo), - } -} - -func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod string, price uint64) error { - i := &PodItem{ - Name: pod, - Price: price, - Address: podAddress, - Owner: owner, - IsListed: true, - } - s.lock.Lock() - defer s.lock.Unlock() - - s.listMap[owner.Hex()+podAddress.String()] = i - return nil -} - -func (s *SubscriptionManager) HidePodFromMarketplace(podAddress, owner common.Address) error { - s.lock.Lock() - defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+podAddress.String()] - if !ok { - return fmt.Errorf("pod not listed") - } - i.IsListed = false - return nil -} - -func (s *SubscriptionManager) RequestAccess(podAddress, owner, subscriber common.Address) error { - s.lock.Lock() - defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+podAddress.String()] - if !ok { - return fmt.Errorf("pod not listed") - } - if !i.IsListed { - return fmt.Errorf("pod not listed") - } - - s.requestMap[owner.Hex()+subscriber.Hex()+podAddress.String()] = requestInfo{ - Name: i.Name, - Address: podAddress, - Subscriber: subscriber, - } - return nil -} - -func (s *SubscriptionManager) AllowAccess(podAddress, owner, subscriber common.Address, secret string) error { - s.lock.Lock() - defer s.lock.Unlock() - i, ok := s.listMap[owner.Hex()+podAddress.String()] - if !ok { - return fmt.Errorf("pod not listed") - } - if !i.IsListed { - return fmt.Errorf("pod not listed") - } - - _, ok = s.requestMap[owner.Hex()+subscriber.Hex()+podAddress.String()] - if !ok { - return fmt.Errorf("request not available") - } - - item := &SubbedItem{ - Name: i.Name, - Address: i.Address, - EndsAt: time.Now().AddDate(0, 1, 0).Unix(), - Secret: secret, - Owner: owner, - } - s.subscriptionMap[subscriber.Hex()+podAddress.String()] = item - - return nil -} - -func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) []*SubbedItem { - subscriberHex := subscriber.Hex() - pods := []*SubbedItem{} - for i, v := range s.subscriptionMap { - if strings.HasPrefix(i, subscriberHex) { - pods = append(pods, v) - } - } - return pods -} - -func (s *SubscriptionManager) GetSubscription(podAddress, subscriber common.Address) *SubbedItem { - return s.subscriptionMap[subscriber.Hex()+podAddress.String()] -} - -func (s *SubscriptionManager) GetAllSubscribablePods() []*PodItem { - pods := []*PodItem{} - for _, v := range s.listMap { - if v.IsListed { - pods = append(pods, v) - } - } - return pods -} - -func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) []*PodItem { - ownerHex := owner.Hex() - pods := []*PodItem{} - for i, v := range s.listMap { - if strings.HasPrefix(i, ownerHex) { - pods = append(pods, v) - } - } - return pods -} diff --git a/pkg/subscription/rpc/rpc.go b/pkg/subscription/rpc/rpc.go deleted file mode 100644 index fd714189..00000000 --- a/pkg/subscription/rpc/rpc.go +++ /dev/null @@ -1,17 +0,0 @@ -package rpc - -import ( - "github.com/ethereum/go-ethereum/common" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" -) - -type SubscriptionManager interface { - AddPodToMarketplace(podAddress, owner common.Address, pod string, price uint64) error - HidePodFromMarketplace(podAddress, owner common.Address) error - RequestAccess(podAddress, owner, subscriber common.Address) error - AllowAccess(podAddress, owner, subscriber common.Address, secret string) error - GetSubscription(podAddress, subscriber common.Address) *mock.SubbedItem - GetSubscriptions(subscriber common.Address) []*mock.SubbedItem - GetAllSubscribablePods() []*mock.PodItem - GetOwnSubscribablePods(owner common.Address) []*mock.PodItem -} diff --git a/pkg/subscription/subscription.go b/pkg/subscription/subscription.go deleted file mode 100644 index b03b5ed2..00000000 --- a/pkg/subscription/subscription.go +++ /dev/null @@ -1,104 +0,0 @@ -package subscription - -import ( - "crypto/ecdsa" - "crypto/sha256" - "fmt" - - "github.com/fairdatasociety/fairOS-dfs/pkg/utils" - - "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" - - "github.com/ethereum/go-ethereum/common" - "github.com/fairdatasociety/fairOS-dfs/pkg/ensm" - "github.com/fairdatasociety/fairOS-dfs/pkg/pod" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc" -) - -type Manager struct { - pod *pod.Pod - addr common.Address - ens ensm.ENSManager - privateKey *ecdsa.PrivateKey - sm rpc.SubscriptionManager -} - -type PodItem struct { - Name string `json:"name"` - Address string `json:"address"` - Price uint64 `json:"price"` - Owner string `json:"owner"` -} - -func New(pod *pod.Pod, addr common.Address, privateKey *ecdsa.PrivateKey, ensm ensm.ENSManager, sm rpc.SubscriptionManager) *Manager { - return &Manager{ - pod: pod, - addr: addr, - ens: ensm, - sm: sm, - privateKey: privateKey, - } -} - -// ListPod will save the pod info in the subscription smart contract with its owner and price -// we keep the pod info in the smart contract, with a `list` flag -func (m *Manager) ListPod(podname string, podAddress common.Address, price uint64) error { - if !m.pod.IsOwnPodPresent(podname) { - return fmt.Errorf("pod not present") - } - return m.sm.AddPodToMarketplace(podAddress, m.addr, podname, price) -} - -// DelistPod will make the `list` flag false for the pod so that it's not listed in the pod marketplace -func (m *Manager) DelistPod(podAddress common.Address) error { - return m.sm.HidePodFromMarketplace(podAddress, m.addr) -} - -// ApproveSubscription will send a subscription request to the owner of the pod -func (m *Manager) ApproveSubscription(podName string, podAddress, subscriber common.Address, subscriberPublicKey *ecdsa.PublicKey) error { - a, _ := subscriberPublicKey.Curve.ScalarMult(subscriberPublicKey.X, subscriberPublicKey.Y, m.privateKey.D.Bytes()) - secret := sha256.Sum256(a.Bytes()) - - ref, err := m.pod.PodShare(podName, "") - if err != nil { - return err - } - encRef, err := utils.EncryptBytes(secret[:], []byte(ref)) - if err != nil { - return err - } - return m.sm.AllowAccess(podAddress, m.addr, subscriber, string(encRef)) -} - -// RequestSubscription will send a subscription request to the owner of the pod -// will create an escrow account and deposit the `price` -func (m *Manager) RequestSubscription(podAddress, owner common.Address) error { - return m.sm.RequestAccess(podAddress, owner, m.addr) -} - -// GetSubscriptions will query the smart contract and list my subscriptions -func (m *Manager) GetSubscriptions() ([]*mock.SubbedItem, error) { - return m.sm.GetSubscriptions(m.addr), nil -} - -// GetMarketplace will query the smart contract make the `list` all the pod from the marketplace -func (m *Manager) GetMarketplace() ([]*mock.PodItem, error) { - return m.sm.GetAllSubscribablePods(), nil -} - -// OpenSubscribedPod will open a subscribed pod -func (m *Manager) OpenSubscribedPod(podAddress common.Address, ownerPublicKey *ecdsa.PublicKey) (*pod.Info, error) { - a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, m.privateKey.D.Bytes()) - secret := sha256.Sum256(a.Bytes()) - item := m.sm.GetSubscription(podAddress, m.addr) - refBytes, err := utils.DecryptBytes(secret[:], []byte(item.Secret)) - if err != nil { - return nil, err - } - reference, err := utils.ParseHexReference(string(refBytes)) - if err != nil { - return nil, err - } - - return m.pod.OpenFromReference(reference) -} diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go new file mode 100644 index 00000000..c9bb8391 --- /dev/null +++ b/pkg/subscriptionManager/rpc/manager.go @@ -0,0 +1,359 @@ +package rpc + +import ( + "context" + "crypto/ecdsa" + "encoding/json" + "errors" + "fmt" + "math/big" + "net/http" + "time" + + "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/ethclient" + swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + "github.com/fairdatasociety/fairOS-dfs/pkg/logging" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" +) + +const ( + additionalConfirmations = 1 + transactionReceiptTimeout = time.Minute * 2 + transactionReceiptPollingInterval = time.Second * 10 +) + +type SubscriptionInfoPutter interface { + UploadBlob(data []byte, tag uint32, pin bool, encrypt bool) (address []byte, err error) +} + +type SubscriptionInfoGetter interface { + DownloadBlob(address []byte) (data []byte, respCode int, err error) +} + +type SubscriptionItemInfo struct { + Category string `json:"category"` + Description string `json:"description"` + FdpSellerNameHash string `json:"fdpSellerNameHash"` + ImageURL string `json:"imageUrl"` + PodAddress string `json:"podAddress"` + PodName string `json:"podName"` + Price string `json:"price"` + Title string `json:"title"` +} + +type Client struct { + c *ethclient.Client + putter SubscriptionInfoPutter + getter SubscriptionInfoGetter + swarmMail *swarmMail.SwarmMail + + logger logging.Logger +} + +// ShareInfo +type ShareInfo struct { + PodName string `json:"podName"` + Address string `json:"podAddress"` + Password string `json:"password"` + UserAddress string `json:"userAddress"` +} + +func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { + info := &SubscriptionItemInfo{ + Category: utils.Encode(category[:]), + Description: desc, + FdpSellerNameHash: utils.Encode(nameHash[:]), + ImageURL: thumbnail, + PodAddress: podAddress.Hex(), + PodName: pod, + Price: fmt.Sprintf("%d", price), + Title: title, + } + opts, err := c.newTransactor(key, owner) + if err != nil { + return err + } + + data, err := json.Marshal(info) + if err != nil { // skipcq: TCV-001 + return err + } + ref, err := c.putter.UploadBlob(data, 0, true, false) + if err != nil { // skipcq: TCV-001 + return err + } + var a [32]byte + copy(a[:], ref) + + i := new(big.Int).SetUint64(price) + + tx, err := c.swarmMail.ListSub(opts, nameHash, a, i, category, podAddress) + if err != nil { + return err + } + err = c.checkReceipt(tx) + if err != nil { + c.logger.Error("ListSub failed : ", err) + return err + } + c.logger.Info("ListSub with hash : ", tx.Hash().Hex()) + + return nil +} + +func (c *Client) HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error { + opts, err := c.newTransactor(key, owner) + if err != nil { + return err + } + + tx, err := c.swarmMail.EnableSub(opts, subHash, !hide) + if err != nil { + return err + } + err = c.checkReceipt(tx) + if err != nil { + c.logger.Error("EnableSub failed : ", err) + return err + } + c.logger.Info("EnableSub with hash : ", tx.Hash().Hex()) + return nil +} + +func (c *Client) RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error { + opts, err := c.newTransactor(key, subscriber) + if err != nil { + return err + } + + tx, err := c.swarmMail.BidSub(opts, subHash, nameHash) + if err != nil { + return err + } + err = c.checkReceipt(tx) + if err != nil { + c.logger.Error("BidSub failed : ", err) + return err + } + c.logger.Info("BidSub with hash : ", tx.Hash().Hex()) + return nil +} + +func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error { + opts, err := c.newTransactor(key, owner) + if err != nil { + return err + } + + data, err := json.Marshal(shareInfo) + if err != nil { // skipcq: TCV-001 + return err + } + encData, err := utils.EncryptBytes(secret[:], data) + if err != nil { + return err + } + + ref, err := c.putter.UploadBlob(encData, 0, true, false) + var fixedRef [32]byte + copy(fixedRef[:], ref) + + tx, err := c.swarmMail.SellSub(opts, requestHash, fixedRef) + if err != nil { + return err + } + err = c.checkReceipt(tx) + if err != nil { + c.logger.Error("SellSub failed : ", err) + return err + } + c.logger.Info("SellSub with hash : ", tx.Hash().Hex()) + return nil +} + +func (c *Client) GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*ShareInfo, error) { + opts := &bind.CallOpts{} + item, err := c.swarmMail.GetSubItemBy(opts, subscriber, subHash) + if err != nil { + return nil, err + } + + encData, resp, err := c.getter.DownloadBlob(item.UnlockKeyLocation[:]) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + if resp != http.StatusOK { // skipcq: TCV-001 + return nil, fmt.Errorf("ReceivePodInfo: could not download blob") + } + + data, err := utils.DecryptBytes(secret[:], encData) + if err != nil { + return nil, err + } + var shareInfo *ShareInfo + err = json.Unmarshal(data, &shareInfo) + if err != nil { + return nil, err + } + + return shareInfo, nil +} + +func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo, error) { + opts := &bind.CallOpts{} + item, err := c.swarmMail.GetSubBy(opts, subHash) + if err != nil { + return nil, err + } + + data, respCode, err := c.getter.DownloadBlob(item.SwarmLocation[:]) + if err != nil { // skipcq: TCV-001 + return nil, err + } + if respCode != http.StatusOK { + return nil, fmt.Errorf("failed to get subscribable podInfo") + } + + info := &SubscriptionItemInfo{} + err = json.Unmarshal(data, info) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + return info, nil +} + +func (c *Client) GetSubscriptions(subscriber common.Address, start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) { + opts := &bind.CallOpts{} + return c.swarmMail.GetSubItems(opts, subscriber, new(big.Int).SetUint64(start), new(big.Int).SetUint64(limit)) +} + +func (c *Client) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { + opts := &bind.CallOpts{} + return c.swarmMail.GetSubs(opts) +} + +func (c *Client) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) { + opts := &bind.CallOpts{} + s, err := c.swarmMail.GetSubs(opts) + if err != nil { + return nil, err + } + osp := []swarmMail.SwarmMailSub{} + for _, p := range s { + if p.Seller == owner { + osp = append(osp, p) + } + } + return osp, nil +} + +func (c *Client) GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) { + opts := &bind.CallOpts{} + return c.swarmMail.GetSubRequests(opts, owner) +} + +func (c *Client) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { + opts := &bind.CallOpts{} + sub, err := c.swarmMail.GetSubBy(opts, subHash) + if err != nil { + return nil, err + } + return &sub, err +} + +func New(logger logging.Logger, getter SubscriptionInfoGetter, putter SubscriptionInfoPutter) (*Client, error) { + c, err := ethclient.Dial("http://localhost:8545") + if err != nil { + return nil, fmt.Errorf("dial eth ensm: %w", err) + } + sMail, err := swarmMail.NewSwarmMail(common.HexToAddress("0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"), c) + if err != nil { + return nil, err + } + + return &Client{ + c: c, + getter: getter, + putter: putter, + logger: logger, + swarmMail: sMail, + }, nil +} + +func (c *Client) newTransactor(key *ecdsa.PrivateKey, account common.Address) (*bind.TransactOpts, error) { + nonce, err := c.c.PendingNonceAt(context.Background(), account) + if err != nil { + return nil, err + } + gasPrice, err := c.c.SuggestGasPrice(context.Background()) + if err != nil { + return nil, err + } + chainID, err := c.c.ChainID(context.Background()) + if err != nil { + return nil, err + } + opts, err := bind.NewKeyedTransactorWithChainID(key, chainID) + if err != nil { + return nil, err + } + opts.Nonce = big.NewInt(int64(nonce)) + opts.Value = big.NewInt(0) + opts.GasLimit = uint64(1000000) + opts.GasPrice = gasPrice + opts.From = account + return opts, nil +} + +func (c *Client) checkReceipt(tx *types.Transaction) error { + ctx, cancel := context.WithTimeout(context.Background(), transactionReceiptTimeout) + defer cancel() + + pollingInterval := transactionReceiptPollingInterval + for { + receipt, err := c.c.TransactionReceipt(ctx, tx.Hash()) + if err != nil { + if !errors.Is(err, ethereum.NotFound) { + return err + } + select { + case <-time.After(pollingInterval): + case <-ctx.Done(): + return ctx.Err() + } + continue + } + if receipt.Status == types.ReceiptStatusFailed { + return fmt.Errorf("transaction %s failed", tx.Hash().Hex()) + } + bn, err := c.c.BlockNumber(ctx) + if err != nil { + return err + } + + nextBlock := receipt.BlockNumber.Uint64() + 1 + + if bn >= nextBlock+additionalConfirmations { + _, err = c.c.HeaderByNumber(ctx, new(big.Int).SetUint64(nextBlock)) + if err != nil { + if !errors.Is(err, ethereum.NotFound) { + return err + } + } else { + return nil + } + } + + select { + case <-time.After(pollingInterval): + case <-ctx.Done(): + return errors.New("context timeout") + } + } +} diff --git a/pkg/subscriptionManager/rpc/mock/rpc.go b/pkg/subscriptionManager/rpc/mock/rpc.go new file mode 100644 index 00000000..72c0944f --- /dev/null +++ b/pkg/subscriptionManager/rpc/mock/rpc.go @@ -0,0 +1,228 @@ +package mock + +import ( + "crypto/ecdsa" + "encoding/json" + "fmt" + "math/big" + "strings" + "sync" + "time" + + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + goens "github.com/wealdtech/go-ens/v3" + + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + + swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + + "github.com/ethereum/go-ethereum/common" +) + +type SubscriptionManager struct { + lock sync.Mutex + listMap map[string]*swarmMail.SwarmMailSub + subscriptionMap map[string]*swarmMail.SwarmMailSubItem + requestMap map[string]*swarmMail.SwarmMailSubRequest + subPodInfo map[string]*rpc.SubscriptionItemInfo + subscribedMap map[string][]byte +} + +func (s *SubscriptionManager) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) { + s.lock.Lock() + defer s.lock.Unlock() + + return s.subPodInfo[utils.Encode(subHash[:])], nil +} + +// NewMockSubscriptionManager returns a new mock subscriptionManager manager client +func NewMockSubscriptionManager() *SubscriptionManager { + return &SubscriptionManager{ + listMap: make(map[string]*swarmMail.SwarmMailSub), + subscriptionMap: make(map[string]*swarmMail.SwarmMailSubItem), + requestMap: make(map[string]*swarmMail.SwarmMailSubRequest), + subPodInfo: make(map[string]*rpc.SubscriptionItemInfo), + subscribedMap: make(map[string][]byte), + } +} + +func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { + subHash, err := goens.NameHash(owner.Hex() + podAddress.String()) + if err != nil { + return err + } + i := &swarmMail.SwarmMailSub{ + SubHash: subHash, + FdpSellerNameHash: nameHash, + Seller: owner, + SwarmLocation: [32]byte{}, + Price: new(big.Int).SetUint64(price), + Active: true, + Earned: nil, + Bids: 0, + Sells: 0, + Reports: 0, + } + s.lock.Lock() + defer s.lock.Unlock() + + s.listMap[utils.Encode(subHash[:])] = i + s.subPodInfo[utils.Encode(subHash[:])] = &rpc.SubscriptionItemInfo{ + PodName: pod, + PodAddress: podAddress.Hex(), + } + + return nil +} + +func (s *SubscriptionManager) HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[utils.Encode(subHash[:])] + if !ok { + return fmt.Errorf("pod not listed") + } + if i.Seller != owner { + return fmt.Errorf("not the owner") + } + i.Active = !hide + return nil +} + +func (s *SubscriptionManager) RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[utils.Encode(subHash[:])] + if !ok { + return fmt.Errorf("pod not listed") + } + if !i.Active { + return fmt.Errorf("pod not listed") + } + reqHash, err := goens.NameHash(subscriber.Hex() + utils.Encode(nameHash[:])) + if err != nil { + return err + } + s.requestMap[utils.Encode(reqHash[:])] = &swarmMail.SwarmMailSubRequest{ + FdpBuyerNameHash: nameHash, + Buyer: subscriber, + SubHash: subHash, + RequestHash: reqHash, + } + return nil +} + +func (s *SubscriptionManager) GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) { + s.lock.Lock() + defer s.lock.Unlock() + + requests := []swarmMail.SwarmMailSubRequest{} + for _, r := range s.requestMap { + sub := s.listMap[utils.Encode(r.SubHash[:])] + if sub.Seller == owner { + requests = append(requests, *r) + } + } + + return requests, nil +} + +func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error { + s.lock.Lock() + defer s.lock.Unlock() + + i, ok := s.requestMap[utils.Encode(requestHash[:])] + if !ok { + return fmt.Errorf("request not available") + } + + item := &swarmMail.SwarmMailSubItem{ + SubHash: i.SubHash, + UnlockKeyLocation: [32]byte{}, + ValidTill: new(big.Int).SetInt64(time.Now().AddDate(0, 1, 0).Unix()), + } + + s.subscriptionMap[i.Buyer.Hex()+utils.Encode(requestHash[:])] = item + + dt, err := json.Marshal(si) + if err != nil { + return err + } + + encDt, err := utils.EncryptBytes(secret[:], dt) + if err != nil { + return err + } + + s.subscribedMap[utils.Encode(i.SubHash[:])] = encDt + + return nil +} + +func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address, _, _ uint64) ([]swarmMail.SwarmMailSubItem, error) { + s.lock.Lock() + defer s.lock.Unlock() + + subscriberHex := subscriber.Hex() + pods := []swarmMail.SwarmMailSubItem{} + for i, v := range s.subscriptionMap { + if strings.HasPrefix(i, subscriberHex) { + pods = append(pods, *v) + } + } + + return pods, nil +} + +func (s *SubscriptionManager) GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) { + s.lock.Lock() + defer s.lock.Unlock() + + encDt := s.subscribedMap[utils.Encode(subHash[:])] + dt, err := utils.DecryptBytes(secret[:], encDt) + if err != nil { + return nil, err + } + + ip := &rpc.ShareInfo{} + err = json.Unmarshal(dt, ip) + if err != nil { + return nil, err + } + return ip, nil +} + +func (s *SubscriptionManager) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { + s.lock.Lock() + defer s.lock.Unlock() + pods := []swarmMail.SwarmMailSub{} + for _, v := range s.listMap { + if v.Active { + pods = append(pods, *v) + } + } + return pods, nil +} + +func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) { + s.lock.Lock() + defer s.lock.Unlock() + + pods := []swarmMail.SwarmMailSub{} + for _, v := range s.listMap { + if v.Seller == owner { + pods = append(pods, *v) + } + } + return pods, nil +} + +func (s *SubscriptionManager) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { + s.lock.Lock() + defer s.lock.Unlock() + i, ok := s.listMap[utils.Encode(subHash[:])] + if ok { + return i, nil + } + return nil, fmt.Errorf("pod not found") +} diff --git a/pkg/subscriptionManager/subscriptionManager.go b/pkg/subscriptionManager/subscriptionManager.go new file mode 100644 index 00000000..ad8ba809 --- /dev/null +++ b/pkg/subscriptionManager/subscriptionManager.go @@ -0,0 +1,25 @@ +package subscriptionManager + +import ( + "crypto/ecdsa" + + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + + swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + + "github.com/ethereum/go-ethereum/common" +) + +type SubscriptionManager interface { + AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error + HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error + RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error + AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error + GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) + GetSubscriptions(subscriber common.Address, start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) + GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) + GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) + GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) + GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) + GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) +} diff --git a/pkg/test/close_test.go b/pkg/test/close_test.go index a0ea097e..67bb5e18 100644 --- a/pkg/test/close_test.go +++ b/pkg/test/close_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/plexsysio/taskmanager" @@ -48,7 +50,9 @@ func TestClose(t *testing.T) { _ = tm.Stop(context.Background()) }() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + sm := mock2.NewMockSubscriptionManager() + + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" t.Run("close-pod", func(t *testing.T) { diff --git a/pkg/test/del_test.go b/pkg/test/del_test.go index 1f9672da..942c8233 100644 --- a/pkg/test/del_test.go +++ b/pkg/test/del_test.go @@ -24,6 +24,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/plexsysio/taskmanager" @@ -50,8 +52,9 @@ func TestPodDelete(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock2.NewMockSubscriptionManager() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" podName2 := "test2" diff --git a/pkg/test/delete_test.go b/pkg/test/delete_test.go index f400865a..9d58e483 100644 --- a/pkg/test/delete_test.go +++ b/pkg/test/delete_test.go @@ -23,12 +23,13 @@ import ( "testing" "time" - "github.com/plexsysio/taskmanager" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/user" + "github.com/plexsysio/taskmanager" ) func TestDelete(t *testing.T) { @@ -38,12 +39,13 @@ func TestDelete(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("delete-user", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/test/fork_test.go b/pkg/test/fork_test.go index 99d206fd..83851368 100644 --- a/pkg/test/fork_test.go +++ b/pkg/test/fork_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" @@ -44,7 +46,9 @@ func TestFork(t *testing.T) { _ = tm.Stop(context.Background()) }() fd := feed.New(acc.GetUserAccountInfo(), mockClient, logger) - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + sm := mock2.NewMockSubscriptionManager() + + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" t.Run("fork-pod", func(t *testing.T) { diff --git a/pkg/test/lite_test.go b/pkg/test/lite_test.go index 5060b1ca..b9180f58 100644 --- a/pkg/test/lite_test.go +++ b/pkg/test/lite_test.go @@ -7,6 +7,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" @@ -21,13 +23,14 @@ func TestLite(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("new-blank-username", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, err := userObject.LoadLiteUser("", "password1", "", "", tm) + _, _, _, err := userObject.LoadLiteUser("", "password1", "", "", tm, sm) if !errors.Is(err, user.ErrInvalidUserName) { t.Fatal(err) } @@ -38,7 +41,7 @@ func TestLite(t *testing.T) { // create user userObject := user.NewUsers(mockClient, ens, logger) - mnemonic, _, ui, err := userObject.LoadLiteUser("user1", "password1", "", "", tm) + mnemonic, _, ui, err := userObject.LoadLiteUser("user1", "password1", "", "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/test/login_test.go b/pkg/test/login_test.go index c83615ef..0102fae1 100644 --- a/pkg/test/login_test.go +++ b/pkg/test/login_test.go @@ -24,6 +24,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" @@ -40,12 +42,13 @@ func TestLogin(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("login-user", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui, err := userObject.CreateNewUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "password1twelve", "", "", tm) + _, _, _, _, ui, err := userObject.CreateNewUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } @@ -56,18 +59,18 @@ func TestLogin(t *testing.T) { t.Fatal(err) } - _, _, _, err = userObject.LoginUserV2("not_an_username", "password1", mockClient, tm, "") + _, _, _, err = userObject.LoginUserV2("not_an_username", "password1", mockClient, tm, sm, "") if !errors.Is(err, user.ErrUserNameNotFound) { t.Fatal(err) } - _, _, _, err = userObject.LoginUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "wrong_password", mockClient, tm, "") + _, _, _, err = userObject.LoginUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "wrong_password", mockClient, tm, sm, "") if !errors.Is(err, user.ErrInvalidPassword) { t.Fatal(err) } // addUserAndSessionToMap user again - ui1, _, _, err := userObject.LoginUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "password1twelve", mockClient, tm, "") + ui1, _, _, err := userObject.LoginUserV2("7e4567e7cb003804992eef11fd5c757275a4c", "password1twelve", mockClient, tm, sm, "") if err != nil { t.Fatal(err) } @@ -98,12 +101,12 @@ func TestLogin(t *testing.T) { pass := "password1password1" //create user userObject := user.NewUsers(mockClient, ens, logger) - _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if err != nil { t.Fatal(err) } - _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if !errors.Is(err, user.ErrUserAlreadyPresent) { t.Fatal(err) } @@ -129,17 +132,17 @@ func TestLogin(t *testing.T) { t.Fatalf("invalid mnemonic") } - _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm, sm) if err != nil { t.Fatal(err) } - login1, _, _, err := userObject.LoginUserV2(user1, pass, mockClient, tm, "") + login1, _, _, err := userObject.LoginUserV2(user1, pass, mockClient, tm, sm, "") if err != nil { t.Fatal(err) } - login2, _, _, err := userObject.LoginUserV2(user1, pass+pass, mockClient, tm, "") + login2, _, _, err := userObject.LoginUserV2(user1, pass+pass, mockClient, tm, sm, "") if err != nil { t.Fatal(err) } @@ -156,12 +159,12 @@ func TestLogin(t *testing.T) { //create user userObject := user.NewUsers(mockClient, ens, logger) pass := "password1password1" - _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if err != nil { t.Fatal(err) } - _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if !errors.Is(err, user.ErrUserAlreadyPresent) { t.Fatal(err) } @@ -199,17 +202,17 @@ func TestLogin(t *testing.T) { t.Fatalf("error creating pod %s : %s", podName1, err.Error()) } - _, _, _, _, ui2, err := userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm) + _, _, _, _, ui2, err := userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm, sm) if err != nil { t.Fatal(err) } - login1, _, _, err := userObject.LoginUserV2(user1, pass, mockClient, tm, "") + login1, _, _, err := userObject.LoginUserV2(user1, pass, mockClient, tm, sm, "") if err != nil { t.Fatal(err) } - login2, _, _, err := userObject.LoginUserV2(user1, pass+pass, mockClient, tm, "") + login2, _, _, err := userObject.LoginUserV2(user1, pass+pass, mockClient, tm, sm, "") if err != nil { t.Fatal(err) } diff --git a/pkg/test/logout_test.go b/pkg/test/logout_test.go index 6f1d50cc..fba41de7 100644 --- a/pkg/test/logout_test.go +++ b/pkg/test/logout_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" @@ -38,13 +40,14 @@ func TestLogout(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("logout-user", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/test/ls_test.go b/pkg/test/ls_test.go index f6e005d6..b64b9b73 100644 --- a/pkg/test/ls_test.go +++ b/pkg/test/ls_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -44,8 +46,9 @@ func TestPod_ListPods(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock2.NewMockSubscriptionManager() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) _, _, err := acc.CreateUserAccount("") if err != nil { t.Fatal(err) diff --git a/pkg/test/max_pod_test.go b/pkg/test/max_pod_test.go index df27c1ac..4d568e55 100644 --- a/pkg/test/max_pod_test.go +++ b/pkg/test/max_pod_test.go @@ -7,6 +7,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/account" @@ -30,8 +32,9 @@ func TestMaxPods(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) t.Run("create-max-pods", func(t *testing.T) { // t.SkipNow() diff --git a/pkg/test/new_test.go b/pkg/test/new_test.go index 8ff081e7..ee64b6ce 100644 --- a/pkg/test/new_test.go +++ b/pkg/test/new_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" @@ -38,13 +40,14 @@ func TestNew(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("new-blank-username", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, _, err := userObject.CreateNewUserV2("", "password1", "", "", tm) + _, _, _, _, _, err := userObject.CreateNewUserV2("", "password1", "", "", tm, sm) if !errors.Is(err, user.ErrBlankUsername) { t.Fatal(err) } @@ -55,17 +58,17 @@ func TestNew(t *testing.T) { // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, _, err := userObject.CreateNewUserV2("user1", "password1", "", "", tm) + _, _, _, _, _, err := userObject.CreateNewUserV2("user1", "password1", "", "", tm, sm) if err != nil && !errors.Is(err, user.ErrPasswordTooSmall) { t.Fatal(err) } - _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } - _, _, _, _, _, err = userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if !errors.Is(err, user.ErrUserAlreadyPresent) { t.Fatal(err) } @@ -98,12 +101,12 @@ func TestNew(t *testing.T) { //create user userObject := user.NewUsers(mockClient, ens, logger) pass := "password1password1" - _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, mnemonic, _, _, ui, err := userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if err != nil { t.Fatal(err) } - _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass, "", "", tm, sm) if !errors.Is(err, user.ErrUserAlreadyPresent) { t.Fatal(err) } @@ -129,7 +132,7 @@ func TestNew(t *testing.T) { t.Fatalf("invalid mnemonic") } - _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm) + _, _, _, _, _, err = userObject.CreateNewUserV2(user1, pass+pass, mnemonic, "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/test/open_test.go b/pkg/test/open_test.go index a7774939..8cebcc4e 100644 --- a/pkg/test/open_test.go +++ b/pkg/test/open_test.go @@ -25,6 +25,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/plexsysio/taskmanager" @@ -49,9 +51,10 @@ func TestOpen(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock2.NewMockSubscriptionManager() fd := feed.New(acc.GetUserAccountInfo(), mockClient, logger) - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" podName2 := "test2" diff --git a/pkg/test/pod_new_test.go b/pkg/test/pod_new_test.go index 89abd093..4fc6abec 100644 --- a/pkg/test/pod_new_test.go +++ b/pkg/test/pod_new_test.go @@ -24,6 +24,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -48,7 +50,9 @@ func TestPodNew(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + sm := mock2.NewMockSubscriptionManager() + + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" podName2 := "test2" diff --git a/pkg/test/pod_sharing_test.go b/pkg/test/pod_sharing_test.go index ce0b00ed..d62d118d 100644 --- a/pkg/test/pod_sharing_test.go +++ b/pkg/test/pod_sharing_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/plexsysio/taskmanager" "github.com/fairdatasociety/fairOS-dfs/pkg/account" @@ -46,7 +48,9 @@ func TestShare(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + sm := mock2.NewMockSubscriptionManager() + + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" acc2 := account.New(logger) @@ -55,7 +59,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) - pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) + pod2 := pod.NewPod(mockClient, fd2, acc2, tm, sm, logger) podName2 := "test2" acc3 := account.New(logger) @@ -64,7 +68,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd3 := feed.New(acc3.GetUserAccountInfo(), mockClient, logger) - pod3 := pod.NewPod(mockClient, fd3, acc3, tm, logger) + pod3 := pod.NewPod(mockClient, fd3, acc3, tm, sm, logger) podName3 := "test3" acc4 := account.New(logger) @@ -73,7 +77,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd4 := feed.New(acc4.GetUserAccountInfo(), mockClient, logger) - pod4 := pod.NewPod(mockClient, fd4, acc4, tm, logger) + pod4 := pod.NewPod(mockClient, fd4, acc4, tm, sm, logger) podName4 := "test4" acc5 := account.New(logger) @@ -82,7 +86,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd5 := feed.New(acc5.GetUserAccountInfo(), mockClient, logger) - pod5 := pod.NewPod(mockClient, fd5, acc5, tm, logger) + pod5 := pod.NewPod(mockClient, fd5, acc5, tm, sm, logger) podName5 := "test5" acc6 := account.New(logger) @@ -91,7 +95,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd6 := feed.New(acc6.GetUserAccountInfo(), mockClient, logger) - pod6 := pod.NewPod(mockClient, fd6, acc6, tm, logger) + pod6 := pod.NewPod(mockClient, fd6, acc6, tm, sm, logger) podName6 := "test6" t.Run("share-pod", func(t *testing.T) { @@ -416,7 +420,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd7 := feed.New(acc7.GetUserAccountInfo(), mockClient, logger) - pod7 := pod.NewPod(mockClient, fd7, acc7, tm, logger) + pod7 := pod.NewPod(mockClient, fd7, acc7, tm, sm, logger) podName7 := "test7" acc8 := account.New(logger) @@ -425,7 +429,7 @@ func TestShare(t *testing.T) { t.Fatal(err) } fd8 := feed.New(acc8.GetUserAccountInfo(), mockClient, logger) - pod8 := pod.NewPod(mockClient, fd8, acc8, tm, logger) + pod8 := pod.NewPod(mockClient, fd8, acc8, tm, sm, logger) // create sending pod and receiving pod podPassword, _ := utils.GetRandString(pod.PasswordLength) diff --git a/pkg/test/pod_stat_test.go b/pkg/test/pod_stat_test.go index a7d87971..c3555a2d 100644 --- a/pkg/test/pod_stat_test.go +++ b/pkg/test/pod_stat_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/plexsysio/taskmanager" @@ -47,7 +49,9 @@ func TestStat(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + sm := mock3.NewMockSubscriptionManager() + + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" t.Run("pod-stat", func(t *testing.T) { diff --git a/pkg/test/stat_test.go b/pkg/test/stat_test.go index dc2302f2..7d615166 100644 --- a/pkg/test/stat_test.go +++ b/pkg/test/stat_test.go @@ -23,6 +23,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/user" "github.com/plexsysio/taskmanager" @@ -39,6 +41,7 @@ func TestUserStat(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() t.Run("stat-nonexistent-user", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() @@ -56,7 +59,7 @@ func TestUserStat(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create user userObject := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, _, _, _, ui, err := userObject.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index 414c0e04..71940abf 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -9,20 +9,18 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" - mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/pod" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscription" - rpcMock "github.com/fairdatasociety/fairOS-dfs/pkg/subscription/rpc/mock" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/plexsysio/taskmanager" "github.com/stretchr/testify/assert" + goens "github.com/wealdtech/go-ens/v3" ) func TestSubscription(t *testing.T) { mockClient := mock.NewMockBeeClient() - ens := mock2.NewMockNamespaceManager() logger := logging.New(os.Stdout, 0) acc1 := account.New(logger) @@ -35,10 +33,15 @@ func TestSubscription(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() - pod1 := pod.NewPod(mockClient, fd, acc1, tm, logger) addr1 := common.HexToAddress(acc1.GetUserAccountInfo().GetAddress().Hex()) - sm := rpcMock.NewMockSubscriptionManager() - m := subscription.New(pod1, addr1, acc1.GetUserAccountInfo().GetPrivateKey(), ens, sm) + nameHash1, err := goens.NameHash(addr1.Hex()) + if err != nil { + t.Fatal(err) + } + + sm := mock2.NewMockSubscriptionManager() + pod1 := pod.NewPod(mockClient, fd, acc1, tm, sm, logger) + randomLongPodName1, err := utils.GetRandString(64) if err != nil { t.Fatalf("error creating pod %s", randomLongPodName1) @@ -62,8 +65,14 @@ func TestSubscription(t *testing.T) { if err != nil { t.Fatal(err) } + category := [32]byte{} + err = pod1.ListPodInMarketplace(randomLongPodName1, randomLongPodName1, randomLongPodName1, "", 1, category, nameHash1) + if err != nil { + t.Fatal(err) + } - err = m.ListPod(randomLongPodName1, common.HexToAddress(p1.GetPodAddress().Hex()), 1) + // sub + market, err := sm.GetAllSubscribablePods() if err != nil { t.Fatal(err) } @@ -73,63 +82,48 @@ func TestSubscription(t *testing.T) { if err != nil { t.Fatal(err) } + fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) - pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) + pod2 := pod.NewPod(mockClient, fd2, acc2, tm, sm, logger) addr2 := common.HexToAddress(acc2.GetUserAccountInfo().GetAddress().Hex()) - - m2 := subscription.New(pod2, addr2, acc2.GetUserAccountInfo().GetPrivateKey(), ens, sm) - - err = m2.RequestSubscription(common.HexToAddress(p1.GetPodAddress().Hex()), addr1) + nameHash2, err := goens.NameHash(addr2.Hex()) if err != nil { t.Fatal(err) } - - err = m.ApproveSubscription(p1.GetPodName(), common.HexToAddress(p1.GetPodAddress().Hex()), addr2, acc2.GetUserAccountInfo().GetPublicKey()) + err = pod2.RequestSubscription(market[0].SubHash, nameHash2) if err != nil { t.Fatal(err) } - subs, err := m2.GetSubscriptions() + requests, err := sm.GetSubRequests(addr1) if err != nil { t.Fatal(err) } - assert.Equal(t, len(subs), 1) - assert.Equal(t, subs[0].Name, randomLongPodName1) - - randomLongPodName2, err := utils.GetRandString(64) - if err != nil { - t.Fatalf("error creating pod %s", randomLongPodName2) + if requests[0].SubHash != market[0].SubHash { + t.Fatal("subhash mismatch") } - p2, err := pod1.CreatePod(randomLongPodName2, "", podPassword) + err = pod1.ApproveSubscription(p1.GetPodName(), requests[0].RequestHash, acc2.GetUserAccountInfo().GetPublicKey()) if err != nil { t.Fatal(err) } - err = m2.RequestSubscription(common.HexToAddress(p2.GetPodAddress().Hex()), addr1) - if err == nil { - t.Fatal("pod is not listed") - } - - err = m.ListPod(randomLongPodName2, common.HexToAddress(p2.GetPodAddress().Hex()), 1) + subs, err := pod2.GetSubscriptions(0, 10) if err != nil { t.Fatal(err) } - err = m.DelistPod(common.HexToAddress(p2.GetPodAddress().Hex())) + podInfo, err := pod2.GetSubscribablePodInfo(subs[0].SubHash) if err != nil { t.Fatal(err) } + assert.Equal(t, len(subs), 1) + assert.Equal(t, podInfo.PodName, randomLongPodName1) - err = m2.RequestSubscription(common.HexToAddress(p2.GetPodAddress().Hex()), addr1) - if err == nil { - t.Fatal("pod is not listed") - } - - pi, err := m2.OpenSubscribedPod(common.HexToAddress(p1.GetPodAddress().Hex()), acc1.GetUserAccountInfo().GetPublicKey()) + pi, err := pod2.OpenSubscribedPod(subs[0].SubHash, acc1.GetUserAccountInfo().GetPublicKey()) if err != nil { - return + t.Fatal("failed to open subscribed pod") } dirObject := pi.GetDirectory() @@ -190,4 +184,5 @@ func TestSubscription(t *testing.T) { if fileMeta2.BlockSize != uint32(20) { t.Fatalf("invalid block size") } + } diff --git a/pkg/test/sync_test.go b/pkg/test/sync_test.go index f7ea48cc..48c032ad 100644 --- a/pkg/test/sync_test.go +++ b/pkg/test/sync_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" @@ -43,8 +45,10 @@ func TestSync(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock2.NewMockSubscriptionManager() + fd := feed.New(acc.GetUserAccountInfo(), mockClient, logger) - pod1 := pod.NewPod(mockClient, fd, acc, tm, logger) + pod1 := pod.NewPod(mockClient, fd, acc, tm, sm, logger) podName1 := "test1" t.Run("sync-pod", func(t *testing.T) { diff --git a/pkg/test/user_sharing_test.go b/pkg/test/user_sharing_test.go index 86253190..b3b6616e 100644 --- a/pkg/test/user_sharing_test.go +++ b/pkg/test/user_sharing_test.go @@ -24,6 +24,8 @@ import ( "testing" "time" + mock3 "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc/mock" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee/mock" mock2 "github.com/fairdatasociety/fairOS-dfs/pkg/ensm/eth/mock" @@ -53,9 +55,10 @@ func TestSharing(t *testing.T) { defer func() { _ = tm.Stop(context.Background()) }() + sm := mock3.NewMockSubscriptionManager() fd1 := feed.New(acc1.GetUserAccountInfo(), mockClient, logger) - pod1 := pod.NewPod(mockClient, fd1, acc1, tm, logger) + pod1 := pod.NewPod(mockClient, fd1, acc1, tm, sm, logger) podName1 := "test1" acc2 := account.New(logger) @@ -68,14 +71,14 @@ func TestSharing(t *testing.T) { t.Fatal(err) } fd2 := feed.New(acc2.GetUserAccountInfo(), mockClient, logger) - pod2 := pod.NewPod(mockClient, fd2, acc2, tm, logger) + pod2 := pod.NewPod(mockClient, fd2, acc2, tm, sm, logger) podName2 := "test2" t.Run("sharing-user", func(t *testing.T) { ens := mock2.NewMockNamespaceManager() // create source user userObject1 := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui0, err := userObject1.CreateNewUserV2("user1", "password1twelve", "", "", tm) + _, _, _, _, ui0, err := userObject1.CreateNewUserV2("user1", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } @@ -112,7 +115,7 @@ func TestSharing(t *testing.T) { // create destination user userObject2 := user.NewUsers(mockClient, ens, logger) - _, _, _, _, ui, err := userObject2.CreateNewUserV2("user2", "password1twelve", "", "", tm) + _, _, _, _, ui, err := userObject2.CreateNewUserV2("user2", "password1twelve", "", "", tm, sm) if err != nil { t.Fatal(err) } diff --git a/pkg/user/ensInfo.go b/pkg/user/ensInfo.go new file mode 100644 index 00000000..2a262afa --- /dev/null +++ b/pkg/user/ensInfo.go @@ -0,0 +1,16 @@ +package user + +import ( + "crypto/ecdsa" + + "github.com/ethereum/go-ethereum/common" +) + +func (u *Users) GetUserInfoFromENS(nameHash [32]byte) (common.Address, *ecdsa.PublicKey, error) { + addr, publicKey, _, err := u.ens.GetInfoFromNameHash(nameHash) + return addr, publicKey, err +} + +func (u *Users) GetNameHash(username string) ([32]byte, error) { + return u.ens.GetNameHash(username) +} diff --git a/pkg/user/lite.go b/pkg/user/lite.go index 53898715..b447f40b 100644 --- a/pkg/user/lite.go +++ b/pkg/user/lite.go @@ -3,6 +3,8 @@ package user import ( "sync" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" + "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" "github.com/fairdatasociety/fairOS-dfs/pkg/account" @@ -16,7 +18,7 @@ import ( // LoadLiteUser creates an off chain user, that has no ens or soc in the swarm. // It only creates the required information to execute user function and stores it in memory. -func (u *Users) LoadLiteUser(userName, _, mnemonic, sessionId string, tm taskmanager.TaskManagerGO) (string, string, *Info, error) { +func (u *Users) LoadLiteUser(userName, _, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager) (string, string, *Info, error) { if !isUserNameValid(userName) { return "", "", nil, ErrInvalidUserName } @@ -33,7 +35,7 @@ func (u *Users) LoadLiteUser(userName, _, mnemonic, sessionId string, tm taskman // Instantiate pod, dir & file objects file := f.NewFile(userName, u.client, fd, accountInfo.GetAddress(), tm, u.logger) dir := d.NewDirectory(userName, u.client, fd, accountInfo.GetAddress(), file, tm, u.logger) - pod := p.NewPod(u.client, fd, acc, tm, u.logger) + pod := p.NewPod(u.client, fd, acc, tm, sm, u.logger) if sessionId == "" { sessionId = cookie.GetUniqueSessionId() } diff --git a/pkg/user/login.go b/pkg/user/login.go index 95c23e73..9ec313d5 100644 --- a/pkg/user/login.go +++ b/pkg/user/login.go @@ -17,8 +17,13 @@ limitations under the License. package user import ( + "fmt" "sync" + "github.com/ethereum/go-ethereum/common" + + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" + "github.com/fairdatasociety/fairOS-dfs/pkg/taskmanager" "github.com/ethereum/go-ethereum/crypto" @@ -34,7 +39,7 @@ import ( // LoginUserV2 checks if the user is present and logs in the user. It also creates the required information // to execute user function and stores it in memory. -func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Client, tm taskmanager.TaskManagerGO, sessionId string) (*Info, string, string, error) { +func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*Info, string, string, error) { // check if username is available (user created) if !u.IsUsernameAvailableV2(userName) { return nil, "", "", ErrUserNameNotFound @@ -69,6 +74,7 @@ func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Clien return nil, "", "", err } // load user account + err = acc.LoadUserAccountFromSeed(seed) if err != nil { // skipcq: TCV-001 return nil, "", "", err @@ -80,7 +86,7 @@ func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Clien // Instantiate pod, dir & file objects file := f.NewFile(userName, client, fd, accountInfo.GetAddress(), tm, u.logger) - pod := p.NewPod(u.client, fd, acc, tm, u.logger) + pod := p.NewPod(u.client, fd, acc, tm, sm, u.logger) dir := d.NewDirectory(userName, client, fd, accountInfo.GetAddress(), file, tm, u.logger) if sessionId == "" { sessionId = cookie.GetUniqueSessionId() @@ -133,3 +139,101 @@ func (u *Users) GetLoggedInUserInfo(sessionId string) *Info { func (u *Users) IsUserNameLoggedIn(userName string) bool { return u.isUserNameInMap(userName) } + +// ConnectWallet connects user with wallet. +func (u *Users) ConnectWallet(userName, passPhrase, walletAddressHex, signature string, client blockstore.Client) error { + // check if username is available (user created) + if !u.IsUsernameAvailableV2(userName) { + return ErrUserNameNotFound + } + + // get owner address from Subdomain registrar + address, err := u.ens.GetOwner(userName) + if err != nil { // skipcq: TCV-001 + return err + } + + // check if address matches with wallet address + if address.Hex() != walletAddressHex { + return fmt.Errorf("wallet doesnot match portable account address") + } + // create account + acc := account.New(u.logger) + accountInfo := acc.GetUserAccountInfo() + // load encrypted private key + fd := feed.New(accountInfo, client, u.logger) + key, err := u.downloadPortableAccount(utils.Address(address), userName, passPhrase, fd) + if err != nil { + u.logger.Errorf(err.Error()) + return err + } + + // decrypt and remove pad from private ley + seed, err := accountInfo.RemovePadFromSeed(key, passPhrase) + if err != nil { // skipcq: TCV-001 + return err + } + + if err = acc.LoadUserAccountFromSeed(seed); err != nil { + return err + } + + key, err = accountInfo.PadSeed(seed, passPhrase) + if err != nil { // skipcq: TCV-001 + return err + } + return u.uploadPortableAccount(accountInfo, walletAddressHex, signature, key, fd) +} + +// LoginWithWallet logs user in with wallet and signature +func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*Info, error) { + + address := common.HexToAddress(addressHex) + // create account + acc := account.New(u.logger) + accountInfo := acc.GetUserAccountInfo() + // load encrypted private key + fd := feed.New(accountInfo, client, u.logger) + key, err := u.downloadPortableAccount(utils.Address(address), addressHex, signature, fd) + if err != nil { + u.logger.Errorf(err.Error()) + return nil, ErrInvalidPassword + } + + // decrypt and remove pad from private ley + seed, err := accountInfo.RemovePadFromSeed(key, signature) + if err != nil { // skipcq: TCV-001 + return nil, err + } + // load user account + err = acc.LoadUserAccountFromSeed(seed) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + if u.IsUserLoggedIn(sessionId) { // skipcq: TCV-001 + return nil, ErrUserAlreadyLoggedIn + } + + // Instantiate pod, dir & file objects + file := f.NewFile(addressHex, client, fd, accountInfo.GetAddress(), tm, u.logger) + pod := p.NewPod(u.client, fd, acc, tm, sm, u.logger) + dir := d.NewDirectory(addressHex, client, fd, accountInfo.GetAddress(), file, tm, u.logger) + if sessionId == "" { + sessionId = cookie.GetUniqueSessionId() + } + ui := &Info{ + name: addressHex, + sessionId: sessionId, + feedApi: fd, + account: acc, + file: file, + dir: dir, + pod: pod, + openPods: make(map[string]*p.Info), + openPodsMu: &sync.RWMutex{}, + } + + // set cookie and add user to map + return ui, u.addUserAndSessionToMap(ui) +} diff --git a/pkg/user/new.go b/pkg/user/new.go index de555f21..02340b0e 100644 --- a/pkg/user/new.go +++ b/pkg/user/new.go @@ -20,6 +20,8 @@ import ( "regexp" "sync" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" + "github.com/fairdatasociety/fairOS-dfs/pkg/taskmanager" "github.com/ethereum/go-ethereum/common" @@ -41,7 +43,7 @@ const ( // CreateNewUserV2 creates a new user with the given username and password. if a mnemonic is passed // then it is used instead of creating a new one. -func (u *Users) CreateNewUserV2(userName, passPhrase, mnemonic, sessionId string, tm taskmanager.TaskManagerGO) (string, string, string, string, *Info, error) { +func (u *Users) CreateNewUserV2(userName, passPhrase, mnemonic, sessionId string, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager) (string, string, string, string, *Info, error) { if userName == "" { return "", "", "", "", nil, ErrBlankUsername } @@ -102,7 +104,7 @@ func (u *Users) CreateNewUserV2(userName, passPhrase, mnemonic, sessionId string // Instantiate pod, dir & file objects file := f.NewFile(userName, u.client, fd, accountInfo.GetAddress(), tm, u.logger) dir := d.NewDirectory(userName, u.client, fd, accountInfo.GetAddress(), file, tm, u.logger) - pod := p.NewPod(u.client, fd, acc, tm, u.logger) + pod := p.NewPod(u.client, fd, acc, tm, sm, u.logger) if sessionId == "" { sessionId = cookie.GetUniqueSessionId() } diff --git a/wasm/main.go b/wasm/main.go index f679dabd..88980c17 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -10,6 +10,7 @@ import ( "fmt" "io" "os" + "strconv" "strings" "syscall/js" @@ -39,7 +40,9 @@ func registerWasmFunctions() { js.Global().Set("connect", js.FuncOf(connect)) js.Global().Set("stop", js.FuncOf(stop)) + js.Global().Set("connectWallet", js.FuncOf(connectWallet)) js.Global().Set("login", js.FuncOf(login)) + js.Global().Set("walletLogin", js.FuncOf(walletLogin)) js.Global().Set("userPresent", js.FuncOf(userPresent)) js.Global().Set("userIsLoggedIn", js.FuncOf(userIsLoggedIn)) js.Global().Set("userLogout", js.FuncOf(userLogout)) @@ -57,6 +60,14 @@ func registerWasmFunctions() { js.Global().Set("podReceive", js.FuncOf(podReceive)) js.Global().Set("podReceiveInfo", js.FuncOf(podReceiveInfo)) + js.Global().Set("listPodInMarketplace", js.FuncOf(listPodInMarketplace)) + js.Global().Set("changePodListStatusInMarketplace", js.FuncOf(changePodListStatusInMarketplace)) + js.Global().Set("requestSubscription", js.FuncOf(requestSubscription)) + js.Global().Set("approveSubscription", js.FuncOf(approveSubscription)) + js.Global().Set("getSubscriptions", js.FuncOf(getSubscriptions)) + js.Global().Set("openSubscribedPod", js.FuncOf(openSubscribedPod)) + js.Global().Set("getSubscribablePods", js.FuncOf(getSubscribablePods)) + js.Global().Set("dirPresent", js.FuncOf(dirPresent)) js.Global().Set("dirMake", js.FuncOf(dirMake)) js.Global().Set("dirRemove", js.FuncOf(dirRemove)) @@ -179,6 +190,68 @@ func login(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func walletLogin(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"walletLogin(addressHex, signature)\"") + return nil + } + address := funcArgs[0].String() + signature := funcArgs[1].String() + + go func() { + ui, err := api.LoginWithWallet(address, signature, "") + if err != nil { + reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) + return + } + data := map[string]string{} + data["user"] = ui.GetUserName() + data["sessionId"] = ui.GetSessionId() + resp, _ := json.Marshal(data) + resolve.Invoke(string(resp)) + }() + + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func connectWallet(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 4 { + reject.Invoke("not enough arguments. \"connectWallet(username, password, walletAddress, signature)\"") + return nil + } + username := funcArgs[0].String() + password := funcArgs[1].String() + walletAddress := funcArgs[2].String() + signature := funcArgs[3].String() + + go func() { + err := api.ConnectPortableAccountWithWallet(username, password, walletAddress, signature) + if err != nil { + reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) + return + } + resolve.Invoke("wallet connected") + }() + + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func userPresent(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] @@ -1775,3 +1848,274 @@ func docIndexJson(_ js.Value, funcArgs []js.Value) interface{} { promiseConstructor := js.Global().Get("Promise") return promiseConstructor.New(handler) } + +func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 7 { + reject.Invoke("not enough arguments. \"listPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, category)\"") + return nil + } + sessionId := funcArgs[0].String() + podName := funcArgs[1].String() + title := funcArgs[2].String() + desc := funcArgs[3].String() + thumbnail := funcArgs[4].String() + priceStr := funcArgs[5].String() + categoryStr := funcArgs[6].String() + + // convert priceStr to uint64 + price, err := strconv.ParseUint(priceStr, 10, 64) + if err != nil { + reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) + return nil + } + + category, err := utils.Decode(categoryStr) + if err != nil { + reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) + return nil + } + + var c [32]byte + copy(c[:], category) + go func() { + err := api.ListPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, c) + if err != nil { + reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) + return + } + resolve.Invoke("pod listed") + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func changePodListStatusInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"changePodListStatusInMarketplace(sessionId, subHash, show)\"") + return nil + } + sessionId := funcArgs[0].String() + subHashStr := funcArgs[1].String() + showStr := funcArgs[2].String() + + subHash, err := utils.Decode(subHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("changePodListStatusInMarketplace failed : %s", err.Error())) + return nil + } + + show, err := strconv.ParseBool(showStr) + if err != nil { + reject.Invoke(fmt.Sprintf("changePodListStatusInMarketplace failed : %s", err.Error())) + return nil + } + + var s [32]byte + copy(s[:], subHash) + go func() { + err := api.ChangePodListStatusInMarketplace(sessionId, s, show) + if err != nil { + reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) + return + } + resolve.Invoke("pod list status changed successfully") + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func requestSubscription(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"requestSubscription(sessionId, subHash)\"") + return nil + } + sessionId := funcArgs[0].String() + subHashStr := funcArgs[1].String() + + subHash, err := utils.Decode(subHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("requestSubscription failed : %s", err.Error())) + return nil + } + + var s [32]byte + copy(s[:], subHash) + go func() { + err := api.RequestSubscription(sessionId, s) + if err != nil { + reject.Invoke(fmt.Sprintf("requestSubscription failed : %s", err.Error())) + return + } + resolve.Invoke("request submitted successfully") + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func approveSubscription(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 4 { + reject.Invoke("not enough arguments. \"approveSubscription(sessionId, podName, reqHash, subscriberNameHash)\"") + return nil + } + sessionId := funcArgs[0].String() + podName := funcArgs[1].String() + reqHashStr := funcArgs[2].String() + subscriberNameHashStr := funcArgs[3].String() + + reqHash, err := utils.Decode(reqHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) + return nil + } + + var r [32]byte + copy(r[:], reqHash) + + nameHash, err := utils.Decode(subscriberNameHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) + return nil + } + + var nh [32]byte + copy(nh[:], nameHash) + go func() { + err := api.ApproveSubscription(sessionId, podName, r, nh) + if err != nil { + reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) + return + } + resolve.Invoke("request approved successfully") + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"getSubscriptions(sessionId, start, limit)\"") + return nil + } + sessionId := funcArgs[0].String() + startStr := funcArgs[1].String() + limitStr := funcArgs[2].String() + + start, err := strconv.ParseUint(startStr, 10, 64) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) + return nil + } + limit, err := strconv.ParseUint(limitStr, 10, 64) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) + return nil + } + + go func() { + subs, err := api.GetSubscriptions(sessionId, start, limit) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) + return + } + resolve.Invoke(subs) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"openSubscribedPod(sessionId, subHash)\"") + return nil + } + sessionId := funcArgs[0].String() + subHashStr := funcArgs[1].String() + + subHash, err := utils.Decode(subHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("openSubscribedPod failed : %s", err.Error())) + return nil + } + + var s [32]byte + copy(s[:], subHash) + + go func() { + subs, err := api.OpenSubscribedPod(sessionId, s) + if err != nil { + reject.Invoke(fmt.Sprintf("openSubscribedPod failed : %s", err.Error())) + return + } + resolve.Invoke(subs) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func getSubscribablePods(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 1 { + reject.Invoke("not enough arguments. \"getSubscribablePods(sessionId)\"") + return nil + } + sessionId := funcArgs[0].String() + + go func() { + subs, err := api.GetSubscribablePods(sessionId) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscribablePods failed : %s", err.Error())) + return + } + resolve.Invoke(subs) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} From c176de1c0375594040d474652992e639b2b31ec1 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 28 Feb 2023 16:12:44 +0530 Subject: [PATCH 05/48] save username in soc for wallet login, wasm return types fixed --- Makefile | 2 +- pkg/account/account.go | 33 ++++ pkg/account/account_test.go | 34 ++++ pkg/subscriptionManager/rpc/manager.go | 4 +- pkg/user/login.go | 6 +- wasm/main.go | 213 ++++++++++++++++++------- 6 files changed, 227 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 6207818e..510a74e7 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ release-dry-run: .PHONY: wasm wasm: - @GOOS=js GOARCH=wasm $(GO) build -ldflags="-s -w" -o fairos.wasm + @GOOS=js GOARCH=wasm $(GO) build -ldflags="-s -w" -o fairos.wasm ./wasm @gzip -9 -v -c fairos.wasm > fairos.wasm.gz .PHONY: android diff --git a/pkg/account/account.go b/pkg/account/account.go index 472ab499..eda17223 100644 --- a/pkg/account/account.go +++ b/pkg/account/account.go @@ -38,6 +38,7 @@ const ( // seedSize is used to determine how much padding we need for portable account SOC seedSize = 64 + nameSize = 8 ) // Account is used for keeping authenticated logged-in user info in the session @@ -272,3 +273,35 @@ func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, er return decryptedBytes[:seedSize], nil } + +// func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { pads the given seed and name with random elements to be a chunk of chunkSize +func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { + usernameLength := len(username) + endIndexBytes := make([]byte, nameSize) + binary.LittleEndian.PutUint64(endIndexBytes, uint64(usernameLength)) + paddingLength := utils.MaxChunkLength - aes.BlockSize - seedSize - nameSize - usernameLength + randomBytes, err := utils.GetRandBytes(paddingLength) + if err != nil { // skipcq: TCV-001 + return nil, err + } + chunkData := make([]byte, 0, utils.MaxChunkLength) + chunkData = append(chunkData, seed...) + chunkData = append(chunkData, endIndexBytes...) + chunkData = append(chunkData, []byte(username)...) + chunkData = append(chunkData, randomBytes...) + encryptedBytes, err := utils.EncryptBytes([]byte(passphrase), chunkData) + if err != nil { // skipcq: TCV-001 + return nil, fmt.Errorf("mnemonic padding failed: %w", err) + } + return encryptedBytes, nil +} + +// RemovePadFromSeedName removes the padding of random elements from the given data and returns the seed and name +func (*Info) RemovePadFromSeedName(paddedSeed []byte, passphrase string) ([]byte, string, error) { + decryptedBytes, err := utils.DecryptBytes([]byte(passphrase), paddedSeed) + if err != nil { // skipcq: TCV-001 + return nil, "", fmt.Errorf("seed decryption failed: %w", err) + } + usernameLength := int(binary.LittleEndian.Uint64(decryptedBytes[seedSize : seedSize+nameSize])) + return decryptedBytes[:seedSize], string(decryptedBytes[seedSize+nameSize : seedSize+nameSize+usernameLength]), nil +} diff --git a/pkg/account/account_test.go b/pkg/account/account_test.go index 0685398c..8c33226e 100644 --- a/pkg/account/account_test.go +++ b/pkg/account/account_test.go @@ -132,6 +132,40 @@ func TestPadUnpadSeed(t *testing.T) { } } +func TestPadUnpadSeedName(t *testing.T) { + name := "TestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedName" + password := "letmein" + logger := logging.New(io.Discard, 0) + acc := New(logger) + _, seed, err := acc.CreateUserAccount("") + if err != nil { + t.Fatal(err) + } + + acc.wallet.seed = seed + r, err := acc.userAccount.PadSeedName(seed, name, password) + if err != nil { + t.Fatal(err) + } + + if len(r) != utils.MaxChunkLength { + t.Fatal("padded string does not match chunk size") + } + + seed2, name2, err := acc.userAccount.RemovePadFromSeedName(r, password) + if err != nil { + t.Fatal(err) + } + + if !bytes.Equal(seed, seed2) { + t.Fatal("seed and padding removed seed do not match") + } + + if name != name2 { + t.Fatal("name do not match") + } +} + func TestCreatePodAccount(t *testing.T) { logger := logging.New(io.Discard, 0) acc := New(logger) diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index c9bb8391..a540b97c 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -268,11 +268,11 @@ func (c *Client) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { } func New(logger logging.Logger, getter SubscriptionInfoGetter, putter SubscriptionInfoPutter) (*Client, error) { - c, err := ethclient.Dial("http://localhost:8545") + c, err := ethclient.Dial("http://localhost:9545") if err != nil { return nil, fmt.Errorf("dial eth ensm: %w", err) } - sMail, err := swarmMail.NewSwarmMail(common.HexToAddress("0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512"), c) + sMail, err := swarmMail.NewSwarmMail(common.HexToAddress("0x21a59654176f2689d12E828B77a783072CD26680"), c) if err != nil { return nil, err } diff --git a/pkg/user/login.go b/pkg/user/login.go index 9ec313d5..9fbe523f 100644 --- a/pkg/user/login.go +++ b/pkg/user/login.go @@ -178,7 +178,7 @@ func (u *Users) ConnectWallet(userName, passPhrase, walletAddressHex, signature return err } - key, err = accountInfo.PadSeed(seed, passPhrase) + key, err = accountInfo.PadSeedName(seed, userName, signature) if err != nil { // skipcq: TCV-001 return err } @@ -201,7 +201,7 @@ func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore. } // decrypt and remove pad from private ley - seed, err := accountInfo.RemovePadFromSeed(key, signature) + seed, username, err := accountInfo.RemovePadFromSeedName(key, signature) if err != nil { // skipcq: TCV-001 return nil, err } @@ -223,7 +223,7 @@ func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore. sessionId = cookie.GetUniqueSessionId() } ui := &Info{ - name: addressHex, + name: username, sessionId: sessionId, feedApi: fd, account: acc, diff --git a/wasm/main.go b/wasm/main.go index 88980c17..fd4175c9 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -176,11 +176,11 @@ func login(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) return } - data := map[string]string{} - data["user"] = ui.GetUserName() - data["sessionId"] = ui.GetSessionId() - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("user", ui.GetUserName()) + object.Set("sessionId", ui.GetSessionId()) + + resolve.Invoke(object) }() return nil @@ -208,11 +208,11 @@ func walletLogin(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) return } - data := map[string]string{} - data["user"] = ui.GetUserName() - data["sessionId"] = ui.GetSessionId() - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + object.Set("user", ui.GetUserName()) + object.Set("sessionId", ui.GetSessionId()) + resolve.Invoke(object) }() return nil @@ -265,10 +265,10 @@ func userPresent(_ js.Value, funcArgs []js.Value) interface{} { go func() { present := api.IsUserNameAvailableV2(username) - data := map[string]bool{} - data["present"] = present - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("present", present) + + resolve.Invoke(object) }() return nil }) @@ -290,10 +290,11 @@ func userIsLoggedIn(_ js.Value, funcArgs []js.Value) interface{} { go func() { loggedin := api.IsUserLoggedIn(username) - data := map[string]bool{} - data["loggedin"] = loggedin - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + object.Set("loggedin", loggedin) + + resolve.Invoke(object) }() return nil }) @@ -372,8 +373,12 @@ func userStat(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("userStat failed : %s", err.Error())) return } - data, _ := json.Marshal(stat) - resolve.Invoke(string(data)) + + object := js.Global().Get("Object").New() + object.Set("userName", stat.Name) + object.Set("address", stat.Reference) + + resolve.Invoke(object) }() return nil }) @@ -534,11 +539,22 @@ func podList(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("podList failed : %s", err.Error())) return } - data := map[string]interface{}{} - data["pods"] = ownPods - data["sharedPods"] = sharedPods - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + pods := js.Global().Get("Array").New(len(ownPods)) + for i, v := range ownPods { + pods.SetIndex(i, js.ValueOf(v)) + } + + sPods := js.Global().Get("Array").New(len(sharedPods)) + for i, v := range sharedPods { + sPods.SetIndex(i, js.ValueOf(v)) + } + + object.Set("pods", pods) + object.Set("sharedPods", sPods) + + resolve.Invoke(object) }() return nil }) @@ -565,8 +581,11 @@ func podStat(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("podStat failed : %s", err.Error())) return } - resp, _ := json.Marshal(stat) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("podName", stat.PodName) + object.Set("address", stat.PodAddress) + + resolve.Invoke(object) }() return nil }) @@ -594,10 +613,10 @@ func podShare(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("podShare failed : %s", err.Error())) return } - data := map[string]string{} - data["podSharingReference"] = reference - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("podSharingReference", reference) + + resolve.Invoke(object) }() return nil }) @@ -662,8 +681,14 @@ func podReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("podReceiveInfo failed : %s", err.Error())) return } - resp, _ := json.Marshal(shareInfo) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + object.Set("podName", shareInfo.PodName) + object.Set("podAddress", shareInfo.Address) + object.Set("password", shareInfo.Password) + object.Set("userAddress", shareInfo.UserAddress) + + resolve.Invoke(object) }() return nil }) @@ -691,10 +716,11 @@ func dirPresent(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("dirPresent failed : %s", err.Error())) return } - data := map[string]bool{} - data["present"] = present - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + object.Set("present", present) + + resolve.Invoke(object) }() return nil }) @@ -778,11 +804,37 @@ func dirList(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("dirList failed : %s", err.Error())) return } - data := map[string]interface{}{} - data["files"] = files - data["dirs"] = dirs - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + filesList := js.Global().Get("Array").New(len(files)) + for i, v := range files { + file := js.Global().Get("Object").New() + file.Set("name", v.Name) + file.Set("contentType", v.ContentType) + file.Set("size", v.Size) + file.Set("blockSize", v.BlockSize) + file.Set("creationTime", v.CreationTime) + file.Set("modificationTime", v.ModificationTime) + file.Set("accessTime", v.AccessTime) + file.Set("mode", v.Mode) + filesList.SetIndex(i, file) + } + dirsList := js.Global().Get("Array").New(len(dirs)) + for i, v := range dirs { + dir := js.Global().Get("Object").New() + dir.Set("name", v.Name) + dir.Set("contentType", v.ContentType) + dir.Set("size", v.Size) + dir.Set("mode", v.Mode) + dir.Set("blockSize", v.BlockSize) + dir.Set("creationTime", v.CreationTime) + dir.Set("modificationTime", v.ModificationTime) + dir.Set("accessTime", v.AccessTime) + dirsList.SetIndex(i, dir) + } + object := js.Global().Get("Object").New() + object.Set("files", filesList) + object.Set("dirs", dirsList) + + resolve.Invoke(object) }() return nil }) @@ -810,8 +862,18 @@ func dirStat(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("dirStat failed : %s", err.Error())) return } - resp, _ := json.Marshal(stat) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("podName", stat.PodName) + object.Set("dirPath", stat.DirPath) + object.Set("dirName", stat.DirName) + object.Set("mode", stat.Mode) + object.Set("creationTime", stat.CreationTime) + object.Set("modificationTime", stat.ModificationTime) + object.Set("accessTime", stat.AccessTime) + object.Set("noOfDirectories", stat.NoOfDirectories) + object.Set("noOfFiles", stat.NoOfFiles) + + resolve.Invoke(object) }() return nil }) @@ -922,10 +984,11 @@ func fileShare(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("fileShare failed : %s", err.Error())) return } - data := map[string]string{} - data["fileSharingReference"] = ref - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + + object := js.Global().Get("Object").New() + object.Set("fileSharingReference", ref) + + resolve.Invoke(object) }() return nil }) @@ -959,10 +1022,10 @@ func fileReceive(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("fileReceive failed : %s", err.Error())) return } - data := map[string]string{} - data["fileName"] = filePath - resp, _ := json.Marshal(data) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("fileName", filePath) + + resolve.Invoke(object) }() return nil }) @@ -994,8 +1057,18 @@ func fileReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("fileReceiveInfo failed : %s", err.Error())) return } - resp, _ := json.Marshal(receiveInfo) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("name", receiveInfo.FileName) + object.Set("size", receiveInfo.Size) + object.Set("blockSize", receiveInfo.BlockSize) + object.Set("numberOfBlocks", receiveInfo.NumberOfBlocks) + object.Set("contentType", receiveInfo.ContentType) + object.Set("compression", receiveInfo.Compression) + object.Set("sourceAddress", receiveInfo.Sender) + object.Set("destAddress", receiveInfo.Receiver) + object.Set("sharedTime", receiveInfo.SharedTime) + + resolve.Invoke(object) }() return nil }) @@ -1051,8 +1124,21 @@ func fileStat(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("fileStat failed : %s", err.Error())) return } - resp, _ := json.Marshal(stat) - resolve.Invoke(string(resp)) + object := js.Global().Get("Object").New() + object.Set("podName", stat.PodName) + object.Set("mode", stat.Mode) + object.Set("filePath", stat.FilePath) + object.Set("fileName", stat.FileName) + object.Set("fileSize", stat.FileSize) + object.Set("blockSize", stat.BlockSize) + object.Set("compression", stat.Compression) + object.Set("contentType", stat.ContentType) + object.Set("creationTime", stat.CreationTime) + object.Set("modificationTime", stat.ModificationTime) + object.Set("accessTime", stat.AccessTime) + object.Set("blocks", stat.Blocks) + + resolve.Invoke(object) }() return nil }) @@ -2049,7 +2135,10 @@ func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) return } - resolve.Invoke(subs) + object := js.Global().Get("Object").New() + object.Set("subs", subs) + + resolve.Invoke(object) }() return nil }) @@ -2085,7 +2174,10 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("openSubscribedPod failed : %s", err.Error())) return } - resolve.Invoke(subs) + object := js.Global().Get("Object").New() + object.Set("subs", subs) + + resolve.Invoke(object) }() return nil }) @@ -2111,7 +2203,10 @@ func getSubscribablePods(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke(fmt.Sprintf("getSubscribablePods failed : %s", err.Error())) return } - resolve.Invoke(subs) + object := js.Global().Get("Object").New() + object.Set("subs", subs) + + resolve.Invoke(object) }() return nil }) From b8cba1148bc488dd3494827f91a44291b21df3d5 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 28 Feb 2023 18:10:59 +0530 Subject: [PATCH 06/48] subscription config, other subscription apis --- cmd/dfs/cmd/server.go | 4 +- gomobile/dfs.go | 2 +- pkg/api/handler.go | 2 +- pkg/contracts/config.go | 18 ++- pkg/dfs/api.go | 4 +- pkg/dfs/pod_api.go | 23 ++++ pkg/ensm/eth/eth.go | 4 +- pkg/pod/subscription.go | 5 + pkg/subscriptionManager/rpc/manager.go | 8 +- wasm/main.go | 159 ++++++++++++++++++++----- 10 files changed, 181 insertions(+), 48 deletions(-) diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index 55b30a6d..fca2cf25 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -117,7 +117,7 @@ can consume it.`, return fmt.Errorf("postageBlockId is invalid") } } - ensConfig := &contracts.Config{} + ensConfig := &contracts.ENSConfig{} network := config.GetString("network") rpc := config.GetString(optionRPC) if rpc == "" { @@ -152,7 +152,7 @@ can consume it.`, return fmt.Errorf("ensRegistry contract address is missing") } - ensConfig = &contracts.Config{ + ensConfig = &contracts.ENSConfig{ ENSRegistryAddress: ensRegistryAddress, FDSRegistrarAddress: fdsRegistrarAddress, PublicResolverAddress: publicResolverAddress, diff --git a/gomobile/dfs.go b/gomobile/dfs.go index 37ff1866..66b79624 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -45,7 +45,7 @@ func IsConnected() bool { func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) error { logger := logging.New(os.Stdout, logrus.Level(logLevel)) var err error - var ensConfig *contracts.Config + var ensConfig *contracts.ENSConfig switch network { case "play": ensConfig = contracts.PlayConfig() diff --git a/pkg/api/handler.go b/pkg/api/handler.go index 30a88093..a6ccee7f 100644 --- a/pkg/api/handler.go +++ b/pkg/api/handler.go @@ -36,7 +36,7 @@ type Handler struct { } // New -func New(ctx context.Context, beeApi, cookieDomain, postageBlockId string, whitelistedOrigins []string, ensConfig *contracts.Config, logger logging.Logger) (*Handler, error) { +func New(ctx context.Context, beeApi, cookieDomain, postageBlockId string, whitelistedOrigins []string, ensConfig *contracts.ENSConfig, logger logging.Logger) (*Handler, error) { api, err := dfs.NewDfsAPI(beeApi, postageBlockId, ensConfig, logger) if err != nil { diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index cc04f765..9cefbfff 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -1,7 +1,7 @@ package contracts -// Config handles the ENS configuration -type Config struct { +// ENSConfig handles the ENS configuration +type ENSConfig struct { ChainID string ENSRegistryAddress string FDSRegistrarAddress string @@ -11,8 +11,8 @@ type Config struct { } // TestnetConfig defines the configuration for goerli testnet -func TestnetConfig() *Config { - return &Config{ +func TestnetConfig() *ENSConfig { + return &ENSConfig{ ChainID: "5", ENSRegistryAddress: "0x42B22483e3c8dF794f351939620572d1a3193c12", FDSRegistrarAddress: "0xF4C9Cd25031E3BB8c5618299bf35b349c1aAb6A9", @@ -22,8 +22,8 @@ func TestnetConfig() *Config { } // PlayConfig defines the configuration for fdp-play -func PlayConfig() *Config { - return &Config{ +func PlayConfig() *ENSConfig { + return &ENSConfig{ ChainID: "4020", ENSRegistryAddress: "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15", FDSRegistrarAddress: "0xA94B7f0465E98609391C623d0560C5720a3f2D33", @@ -31,3 +31,9 @@ func PlayConfig() *Config { ProviderDomain: "fds", } } + +// SubscriptionConfig handles the Subscription Management +type SubscriptionConfig struct { + RPC string + SwarmMailAddress string +} diff --git a/pkg/dfs/api.go b/pkg/dfs/api.go index 5960d228..9e37c91b 100644 --- a/pkg/dfs/api.go +++ b/pkg/dfs/api.go @@ -50,7 +50,7 @@ type API struct { } // NewDfsAPI is the main entry point for the df controller. -func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.Config, logger logging.Logger) (*API, error) { +func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.ENSConfig, subConfig *contracts.SubscriptionConfig, logger logging.Logger) (*API, error) { ens, err := ethClient.New(ensConfig, logger) if err != nil { if errors.Is(err, ethClient.ErrWrongChainID) { @@ -64,7 +64,7 @@ func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.Config, logge } users := user.NewUsers(c, ens, logger) - sm, err := rpc.New(logger, c, c) + sm, err := rpc.New(subConfig, logger, c, c) if err != nil { return nil, errSubManager } diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 10f43a95..601286c8 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -20,6 +20,8 @@ import ( "context" "encoding/hex" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + SwarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" "github.com/fairdatasociety/fairOS-dfs/pkg/pod" @@ -511,6 +513,16 @@ func (a *API) GetSubscriptions(sessionId string, start, limit uint64) ([]*Subscr return subs, nil } +// GetSubscribablePodInfo +func (a *API) GetSubscribablePodInfo(sessionId string, subHash [32]byte) (*rpc.SubscriptionItemInfo, error) { + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + return a.sm.GetSubscribablePodInfo(subHash) +} + // OpenSubscribedPod func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, error) { @@ -554,3 +566,14 @@ func (a *API) GetSubscribablePods(sessionId string) ([]SwarmMail.SwarmMailSub, e return ui.GetPod().GetMarketplace() } + +// GetSubscribablePods +func (a *API) GetSubsRequests(sessionId string) ([]SwarmMail.SwarmMailSubRequest, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + return ui.GetPod().GetSubRequests() +} diff --git a/pkg/ensm/eth/eth.go b/pkg/ensm/eth/eth.go index a077cda4..d1ab0535 100644 --- a/pkg/ensm/eth/eth.go +++ b/pkg/ensm/eth/eth.go @@ -40,7 +40,7 @@ var ( // Client is used to manage ENS type Client struct { eth *ethclient.Client - ensConfig *contracts.Config + ensConfig *contracts.ENSConfig ensRegistry *ens.ENSRegistry fdsRegistrar *fdsregistrar.FDSRegistrar publicResolver *publicresolver.PublicResolver @@ -49,7 +49,7 @@ type Client struct { } // New returns a new ENS manager Client -func New(ensConfig *contracts.Config, logger logging.Logger) (*Client, error) { +func New(ensConfig *contracts.ENSConfig, logger logging.Logger) (*Client, error) { eth, err := ethclient.Dial(ensConfig.ProviderBackend) if err != nil { return nil, fmt.Errorf("dial eth ensm: %w", err) diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index e033f869..c4496145 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -96,3 +96,8 @@ func (p *Pod) OpenSubscribedPod(subHash [32]byte, ownerPublicKey *ecdsa.PublicKe } return p.OpenFromShareInfo(shareInfo) } + +// GetSubRequests will get all owners sub requests +func (p *Pod) GetSubRequests() ([]swarmMail.SwarmMailSubRequest, error) { + return p.sm.GetSubRequests(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) +} diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index a540b97c..0673d0b2 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -10,6 +10,8 @@ import ( "net/http" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -267,12 +269,12 @@ func (c *Client) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { return &sub, err } -func New(logger logging.Logger, getter SubscriptionInfoGetter, putter SubscriptionInfoPutter) (*Client, error) { - c, err := ethclient.Dial("http://localhost:9545") +func New(subConfig *contracts.SubscriptionConfig, logger logging.Logger, getter SubscriptionInfoGetter, putter SubscriptionInfoPutter) (*Client, error) { + c, err := ethclient.Dial(subConfig.RPC) if err != nil { return nil, fmt.Errorf("dial eth ensm: %w", err) } - sMail, err := swarmMail.NewSwarmMail(common.HexToAddress("0x21a59654176f2689d12E828B77a783072CD26680"), c) + sMail, err := swarmMail.NewSwarmMail(common.HexToAddress(subConfig.SwarmMailAddress), c) if err != nil { return nil, err } diff --git a/wasm/main.go b/wasm/main.go index fd4175c9..5b602b0e 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -67,6 +67,8 @@ func registerWasmFunctions() { js.Global().Set("getSubscriptions", js.FuncOf(getSubscriptions)) js.Global().Set("openSubscribedPod", js.FuncOf(openSubscribedPod)) js.Global().Set("getSubscribablePods", js.FuncOf(getSubscribablePods)) + js.Global().Set("getSubRequests", js.FuncOf(getSubRequests)) + js.Global().Set("getSubscribablePodInfo", js.FuncOf(getSubscribablePodInfo)) js.Global().Set("dirPresent", js.FuncOf(dirPresent)) js.Global().Set("dirMake", js.FuncOf(dirMake)) @@ -111,19 +113,21 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] - if len(funcArgs) != 4 { - reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, false, rpc, play)\"") + if len(funcArgs) != 6 { + reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, false, rpc, play, subRpc, subContractAddress)\"") return nil } beeEndpoint := funcArgs[0].String() stampId := funcArgs[1].String() rpc := funcArgs[2].String() network := funcArgs[3].String() + subRpc := funcArgs[4].String() + subContractAddress := funcArgs[5].String() if network != "testnet" && network != "play" { reject.Invoke("unknown network. \"use play or testnet\"") return nil } - var config *contracts.Config + var config *contracts.ENSConfig if network == "play" { config = contracts.PlayConfig() } else { @@ -132,12 +136,18 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { config.ProviderBackend = rpc logger := logging.New(os.Stdout, logrus.DebugLevel) + subConfig := &contracts.SubscriptionConfig{ + RPC: subRpc, + SwarmMailAddress: subContractAddress, + } + go func() { var err error api, err = dfs.NewDfsAPI( beeEndpoint, stampId, config, + subConfig, logger, ) if err != nil { @@ -1136,7 +1146,6 @@ func fileStat(_ js.Value, funcArgs []js.Value) interface{} { object.Set("creationTime", stat.CreationTime) object.Set("modificationTime", stat.ModificationTime) object.Set("accessTime", stat.AccessTime) - object.Set("blocks", stat.Blocks) resolve.Invoke(object) }() @@ -1993,7 +2002,7 @@ func changePodListStatusInMarketplace(_ js.Value, funcArgs []js.Value) interface } sessionId := funcArgs[0].String() subHashStr := funcArgs[1].String() - showStr := funcArgs[2].String() + show := funcArgs[2].Bool() subHash, err := utils.Decode(subHashStr) if err != nil { @@ -2001,12 +2010,6 @@ func changePodListStatusInMarketplace(_ js.Value, funcArgs []js.Value) interface return nil } - show, err := strconv.ParseBool(showStr) - if err != nil { - reject.Invoke(fmt.Sprintf("changePodListStatusInMarketplace failed : %s", err.Error())) - return nil - } - var s [32]byte copy(s[:], subHash) go func() { @@ -2115,28 +2118,27 @@ func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { return nil } sessionId := funcArgs[0].String() - startStr := funcArgs[1].String() - limitStr := funcArgs[2].String() - - start, err := strconv.ParseUint(startStr, 10, 64) - if err != nil { - reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) - return nil - } - limit, err := strconv.ParseUint(limitStr, 10, 64) - if err != nil { - reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) - return nil - } + start := funcArgs[1].Int() + limit := funcArgs[2].Int() go func() { - subs, err := api.GetSubscriptions(sessionId, start, limit) + subs, err := api.GetSubscriptions(sessionId, uint64(start), uint64(limit)) if err != nil { reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) return } object := js.Global().Get("Object").New() - object.Set("subs", subs) + subscriptions := js.Global().Get("Array").New(len(subs)) + for i, v := range subs { + subscription := js.Global().Get("Object").New() + subscription.Set("podName", v.PodName) + subscription.Set("subHash", utils.Encode(v.SubHash[:])) + subscription.Set("podAddress", v.PodAddress) + subscription.Set("validTill", v.ValidTill) + subscription.Set("infoLocation", utils.Encode(v.InfoLocation)) + subscriptions.SetIndex(i, js.ValueOf(v)) + } + object.Set("subscriptions", subscriptions) resolve.Invoke(object) }() @@ -2169,15 +2171,13 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { copy(s[:], subHash) go func() { - subs, err := api.OpenSubscribedPod(sessionId, s) + pi, err := api.OpenSubscribedPod(sessionId, s) if err != nil { reject.Invoke(fmt.Sprintf("openSubscribedPod failed : %s", err.Error())) return } - object := js.Global().Get("Object").New() - object.Set("subs", subs) - resolve.Invoke(object) + resolve.Invoke(fmt.Sprintf("%s opened successfully", pi.GetPodName())) }() return nil }) @@ -2204,7 +2204,104 @@ func getSubscribablePods(_ js.Value, funcArgs []js.Value) interface{} { return } object := js.Global().Get("Object").New() - object.Set("subs", subs) + subscriptions := js.Global().Get("Array").New(len(subs)) + for i, v := range subs { + subscription := js.Global().Get("Object").New() + subscription.Set("subHash", utils.Encode(v.SubHash[:])) + subscription.Set("sellerNameHash", utils.Encode(v.FdpSellerNameHash[:])) + subscription.Set("seller", v.Seller.Hex()) + subscription.Set("swarmLocation", utils.Encode(v.SwarmLocation[:])) + subscription.Set("price", v.Price.Int64()) + subscription.Set("active", v.Active) + subscription.Set("earned", v.Earned.Int64()) + subscription.Set("bid", v.Bids) + subscription.Set("sells", v.Sells) + subscription.Set("reports", v.Reports) + subscriptions.SetIndex(i, js.ValueOf(v)) + } + object.Set("subscribablePods", subscriptions) + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func getSubRequests(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 1 { + reject.Invoke("not enough arguments. \"getSubRequests(sessionId)\"") + return nil + } + sessionId := funcArgs[0].String() + + go func() { + requests, err := api.GetSubsRequests(sessionId) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubRequests failed : %s", err.Error())) + return + } + object := js.Global().Get("Object").New() + subRequests := js.Global().Get("Array").New(len(requests)) + for i, v := range requests { + request := js.Global().Get("Object").New() + request.Set("subHash", utils.Encode(v.SubHash[:])) + request.Set("buyerNameHash", utils.Encode(v.FdpBuyerNameHash[:])) + request.Set("requestHash", utils.Encode(v.RequestHash[:])) + request.Set("buyer", v.Buyer.Hex()) + subRequests.SetIndex(i, js.ValueOf(v)) + } + object.Set("requests", subRequests) + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func getSubscribablePodInfo(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"getSubscribablePodInfo(sessionId, subHash)\"") + return nil + } + sessionId := funcArgs[0].String() + subHashStr := funcArgs[1].String() + + subHash, err := utils.Decode(subHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscribablePodInfo failed : %s", err.Error())) + return nil + } + + var s [32]byte + copy(s[:], subHash) + + go func() { + info, err := api.GetSubscribablePodInfo(sessionId, s) + if err != nil { + reject.Invoke(fmt.Sprintf("getSubscribablePodInfo failed : %s", err.Error())) + return + } + object := js.Global().Get("Object").New() + object.Set("category", info.Category) + object.Set("description", info.Description) + object.Set("fdpSellerNameHash", info.FdpSellerNameHash) + object.Set("imageUrl", info.ImageURL) + object.Set("podAddress", info.PodAddress) + object.Set("podName", info.PodName) + object.Set("price", info.Price) + object.Set("title", info.Title) resolve.Invoke(object) }() From b24ed57c2699d2492c88934bec5f9564b581e506 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 3 Mar 2023 10:54:17 +0530 Subject: [PATCH 07/48] add namehash --- pkg/dfs/user_api.go | 10 ++++++++++ wasm/main.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/pkg/dfs/user_api.go b/pkg/dfs/user_api.go index d565018c..9f22af70 100644 --- a/pkg/dfs/user_api.go +++ b/pkg/dfs/user_api.go @@ -88,3 +88,13 @@ func (a *API) ConnectPortableAccountWithWallet(userName, passPhrase, addressHex, func (a *API) LoginWithWallet(addressHex, signature, sessionId string) (*user.Info, error) { return a.users.LoginWithWallet(addressHex, signature, a.client, a.tm, a.sm, sessionId) } + +// GetNameHash +func (a *API) GetNameHash(sessionId string, username string) ([32]byte, error) { + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return [32]byte{}, ErrUserNotLoggedIn + } + + return a.users.GetNameHash(username) +} diff --git a/wasm/main.go b/wasm/main.go index 5b602b0e..746d8707 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -48,6 +48,7 @@ func registerWasmFunctions() { js.Global().Set("userLogout", js.FuncOf(userLogout)) js.Global().Set("userDelete", js.FuncOf(userDelete)) js.Global().Set("userStat", js.FuncOf(userStat)) + js.Global().Set("getNameHash", js.FuncOf(getNameHash)) js.Global().Set("podNew", js.FuncOf(podNew)) js.Global().Set("podOpen", js.FuncOf(podOpen)) @@ -2311,3 +2312,33 @@ func getSubscribablePodInfo(_ js.Value, funcArgs []js.Value) interface{} { promiseConstructor := js.Global().Get("Promise") return promiseConstructor.New(handler) } + +func getNameHash(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"getNameHash(sessionId, username)\"") + return nil + } + sessionId := funcArgs[0].String() + username := funcArgs[1].String() + + go func() { + nameHash, err := api.GetNameHash(sessionId, username) + if err != nil { + reject.Invoke(fmt.Sprintf("getNameHash failed : %s", err.Error())) + return + } + object := js.Global().Get("Object").New() + object.Set("namehash", utils.Encode(nameHash[:])) + + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} From 57204407e11d38debf90598668c2d432d9dd10bf Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 3 Mar 2023 12:06:26 +0530 Subject: [PATCH 08/48] getnameHash added to wasm --- gomobile/dfs.go | 1 + pkg/api/handler.go | 2 +- pkg/blockstore/bee/client.go | 16 ++++++++++------ pkg/blockstore/bee/mock/client.go | 4 ++-- pkg/blockstore/client.go | 4 ++-- pkg/collection/document.go | 4 ++-- pkg/collection/index.go | 6 +++--- pkg/collection/index_api_test.go | 4 ++-- pkg/collection/kv.go | 2 +- pkg/dfs/api.go | 12 ++++++++---- pkg/file/reader_test.go | 4 ++-- pkg/file/upload.go | 4 ++-- pkg/file/writeAt.go | 4 ++-- pkg/pod/sharing.go | 2 +- pkg/subscriptionManager/rpc/manager.go | 10 +++++++--- pkg/user/sharing.go | 2 +- 16 files changed, 47 insertions(+), 34 deletions(-) diff --git a/gomobile/dfs.go b/gomobile/dfs.go index 66b79624..a9e85947 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -61,6 +61,7 @@ func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) err beeEndpoint, postageBlockId, ensConfig, + nil, logger, ) return err diff --git a/pkg/api/handler.go b/pkg/api/handler.go index a6ccee7f..e061b946 100644 --- a/pkg/api/handler.go +++ b/pkg/api/handler.go @@ -37,7 +37,7 @@ type Handler struct { // New func New(ctx context.Context, beeApi, cookieDomain, postageBlockId string, whitelistedOrigins []string, ensConfig *contracts.ENSConfig, logger logging.Logger) (*Handler, error) { - api, err := dfs.NewDfsAPI(beeApi, postageBlockId, ensConfig, logger) + api, err := dfs.NewDfsAPI(beeApi, postageBlockId, ensConfig, nil, logger) if err != nil { return nil, err diff --git a/pkg/blockstore/bee/client.go b/pkg/blockstore/bee/client.go index 55d96ec7..6ceac069 100644 --- a/pkg/blockstore/bee/client.go +++ b/pkg/blockstore/bee/client.go @@ -67,6 +67,7 @@ type Client struct { postageBlockId string logger logging.Logger isProxy bool + shouldPin bool } func hashFunc() hash.Hash { @@ -95,7 +96,7 @@ type beeError struct { } // NewBeeClient creates a new client which connects to the Swarm bee node to access the Swarm network. -func NewBeeClient(apiUrl, postageBlockId string, logger logging.Logger) *Client { +func NewBeeClient(apiUrl, postageBlockId string, shouldPin bool, logger logging.Logger) *Client { p := bmtlegacy.NewTreePool(hashFunc, swarm.Branches, bmtlegacy.PoolSize) cache, err := lru.New(chunkCacheSize) if err != nil { @@ -119,6 +120,7 @@ func NewBeeClient(apiUrl, postageBlockId string, logger logging.Logger) *Client downloadBlockCache: downloadBlockCache, postageBlockId: postageBlockId, logger: logger, + shouldPin: shouldPin, } } @@ -190,7 +192,9 @@ func (s *Client) UploadSOC(owner, id, signature string, data []byte) (address [] // TODO change this in the future when we have some alternative to pin SOC // This is a temporary fix to force soc pinning - req.Header.Set(swarmPinHeader, "true") + if s.shouldPin { + req.Header.Set(swarmPinHeader, "true") + } response, err := s.client.Do(req) if err != nil { @@ -232,7 +236,7 @@ func (s *Client) UploadSOC(owner, id, signature string, data []byte) (address [] } // UploadChunk uploads a chunk to Swarm network. -func (s *Client) UploadChunk(ch swarm.Chunk, pin bool) (address []byte, err error) { +func (s *Client) UploadChunk(ch swarm.Chunk) (address []byte, err error) { to := time.Now() fullUrl := fmt.Sprintf(s.url + chunkUploadDownloadUrl) req, err := http.NewRequest(http.MethodPost, fullUrl, bytes.NewBuffer(ch.Data())) @@ -240,7 +244,7 @@ func (s *Client) UploadChunk(ch swarm.Chunk, pin bool) (address []byte, err erro return nil, err } - if pin { + if s.shouldPin { req.Header.Set(swarmPinHeader, "true") } @@ -333,7 +337,7 @@ func (s *Client) DownloadChunk(ctx context.Context, address []byte) (data []byte } // UploadBlob uploads a binary blob of data to Swarm network. It also optionally pins and encrypts the data. -func (s *Client) UploadBlob(data []byte, tag uint32, pin, encrypt bool) (address []byte, err error) { +func (s *Client) UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) { to := time.Now() // return the ref if this data is already in swarm @@ -347,7 +351,7 @@ func (s *Client) UploadBlob(data []byte, tag uint32, pin, encrypt bool) (address return nil, err } - if pin { + if s.shouldPin { req.Header.Set(swarmPinHeader, "true") } diff --git a/pkg/blockstore/bee/mock/client.go b/pkg/blockstore/bee/mock/client.go index 05b20add..44b2c3d5 100644 --- a/pkg/blockstore/bee/mock/client.go +++ b/pkg/blockstore/bee/mock/client.go @@ -89,7 +89,7 @@ func (m *BeeClient) UploadSOC(owner, id, signature string, data []byte) (address } // UploadChunk into swarm -func (m *BeeClient) UploadChunk(ch swarm.Chunk, _ bool) (address []byte, err error) { +func (m *BeeClient) UploadChunk(ch swarm.Chunk) (address []byte, err error) { m.storerMu.Lock() defer m.storerMu.Unlock() m.storer[ch.Address().String()] = ch.Data() @@ -107,7 +107,7 @@ func (m *BeeClient) DownloadChunk(_ context.Context, address []byte) (data []byt } // UploadBlob into swarm -func (m *BeeClient) UploadBlob(data []byte, tag uint32, _, _ bool) (address []byte, err error) { +func (m *BeeClient) UploadBlob(data []byte, tag uint32, _ bool) (address []byte, err error) { m.storerMu.Lock() defer m.storerMu.Unlock() address = make([]byte, 32) diff --git a/pkg/blockstore/client.go b/pkg/blockstore/client.go index fb5d464c..83bc28d4 100644 --- a/pkg/blockstore/client.go +++ b/pkg/blockstore/client.go @@ -26,8 +26,8 @@ import ( type Client interface { CheckConnection() bool UploadSOC(owner string, id string, signature string, data []byte) (address []byte, err error) - UploadChunk(ch swarm.Chunk, pin bool) (address []byte, err error) - UploadBlob(data []byte, tag uint32, pin bool, encrypt bool) (address []byte, err error) + UploadChunk(ch swarm.Chunk) (address []byte, err error) + UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) DownloadChunk(ctx context.Context, address []byte) (data []byte, err error) DownloadBlob(address []byte) (data []byte, respCode int, err error) DeleteReference(address []byte) error diff --git a/pkg/collection/document.go b/pkg/collection/document.go index 2aa70b0d..750e10ec 100644 --- a/pkg/collection/document.go +++ b/pkg/collection/document.go @@ -633,7 +633,7 @@ func (d *Document) Put(dbName string, doc []byte) error { } // upload the document - ref, err := d.client.UploadBlob(doc, 0, true, true) + ref, err := d.client.UploadBlob(doc, 0, true) if err != nil { // skipcq: TCV-001 d.logger.Errorf("inserting in to document db: ", err.Error()) return err @@ -1419,7 +1419,7 @@ func (d *Document) DocBatchPut(docBatch *DocBatch, doc []byte, index int64) erro } // upload the document - ref, err = d.client.UploadBlob(doc, 0, true, true) + ref, err = d.client.UploadBlob(doc, 0, true) if err != nil { // skipcq: TCV-001 d.logger.Errorf("inserting in batch: ", err.Error()) return err diff --git a/pkg/collection/index.go b/pkg/collection/index.go index 86003839..b1dc67cd 100644 --- a/pkg/collection/index.go +++ b/pkg/collection/index.go @@ -126,7 +126,7 @@ func CreateIndex(podName, collectionName, indexName, encryptionPassword string, return ErrManifestUnmarshall } - ref, err := client.UploadBlob(data, 0, true, true) + ref, err := client.UploadBlob(data, 0, true) if err != nil { // skipcq: TCV-001 return ErrManifestUnmarshall } @@ -281,7 +281,7 @@ func (idx *Index) updateManifest(manifest *Manifest, encryptionPassword string) return ErrManifestUnmarshall } - ref, err := idx.client.UploadBlob(data, 0, true, true) + ref, err := idx.client.UploadBlob(data, 0, true) if err != nil { // skipcq: TCV-001 return ErrManifestUnmarshall } @@ -303,7 +303,7 @@ func (idx *Index) storeManifest(manifest *Manifest, encryptionPassword string) e logStr := fmt.Sprintf("storing Manifest: %s, data len = %d", manifest.Name, len(data)) idx.logger.Debug(logStr) - ref, err := idx.client.UploadBlob(data, 0, true, true) + ref, err := idx.client.UploadBlob(data, 0, true) //TODO: once the tags issue is fixed i bytes. // remove the error string check if err != nil { // skipcq: TCV-001 diff --git a/pkg/collection/index_api_test.go b/pkg/collection/index_api_test.go index 8eb35389..071c3f3e 100644 --- a/pkg/collection/index_api_test.go +++ b/pkg/collection/index_api_test.go @@ -141,7 +141,7 @@ func TestIndexAPI(t *testing.T) { } func addDoc(t *testing.T, key string, value []byte, index *collection.Index, client *mock.BeeClient, apnd bool) { - ref, err := client.UploadBlob(value, 0, false, false) + ref, err := client.UploadBlob(value, 0, false) if err != nil { t.Fatalf("could not add doc %s:%s, %v", key, value, err) } @@ -277,7 +277,7 @@ func addBatchDocs(t *testing.T, batch *collection.Batch, client *mock.BeeClient) // add the documents for k, v := range kvMap { - ref, err := client.UploadBlob(v, 0, false, false) + ref, err := client.UploadBlob(v, 0, false) if err != nil { t.Fatalf("could not add doc %s:%s, %v", k, ref, err) } diff --git a/pkg/collection/kv.go b/pkg/collection/kv.go index bb006237..391dd1ae 100644 --- a/pkg/collection/kv.go +++ b/pkg/collection/kv.go @@ -264,7 +264,7 @@ func (kv *KeyValue) KVPut(name, key string, value []byte) error { } return table.index.PutNumber(fkey, value, NumberIndex, false) case BytesIndex: - ref, err := kv.client.UploadBlob(value, 0, true, true) + ref, err := kv.client.UploadBlob(value, 0, true) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/dfs/api.go b/pkg/dfs/api.go index 9e37c91b..98752e1b 100644 --- a/pkg/dfs/api.go +++ b/pkg/dfs/api.go @@ -58,16 +58,20 @@ func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.ENSConfig, su } return nil, errEthClient } - c := bee.NewBeeClient(apiUrl, postageBlockId, logger) + c := bee.NewBeeClient(apiUrl, postageBlockId, false, logger) if !c.CheckConnection() { return nil, ErrBeeClient } users := user.NewUsers(c, ens, logger) - sm, err := rpc.New(subConfig, logger, c, c) - if err != nil { - return nil, errSubManager + var sm subscriptionManager.SubscriptionManager + if subConfig != nil { + sm, err = rpc.New(subConfig, logger, c, c) + if err != nil { + return nil, errSubManager + } } + // discard tm logs as it creates too much noise tmLogger := logging.New(io.Discard, 0) diff --git a/pkg/file/reader_test.go b/pkg/file/reader_test.go index 41f0f11c..3bedf445 100644 --- a/pkg/file/reader_test.go +++ b/pkg/file/reader_test.go @@ -329,7 +329,7 @@ func createFile(t *testing.T, fileSize uint64, blockSize uint32, compression str buf = compressedData } - addr, err := mockClient.UploadBlob(buf, 0, true, true) + addr, err := mockClient.UploadBlob(buf, 0, true) if err != nil { t.Fatal(err) } @@ -453,7 +453,7 @@ func createFileWithNewlines(t *testing.T, fileSize uint64, blockSize uint32, com buf = compressedData } - addr, err := mockClient.UploadBlob(buf, 0, true, true) + addr, err := mockClient.UploadBlob(buf, 0, true) if err != nil { t.Fatal(err) } diff --git a/pkg/file/upload.go b/pkg/file/upload.go index 1acaa30d..6e0db69c 100644 --- a/pkg/file/upload.go +++ b/pkg/file/upload.go @@ -147,7 +147,7 @@ func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSiz } } - addr, uploadErr := f.client.UploadBlob(uploadData, tag, true, true) + addr, uploadErr := f.client.UploadBlob(uploadData, tag, true) if uploadErr != nil { mainErr = uploadErr return @@ -192,7 +192,7 @@ func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSiz return err } - addr, err := f.client.UploadBlob(fileInodeData, 0, true, true) + addr, err := f.client.UploadBlob(fileInodeData, 0, true) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/file/writeAt.go b/pkg/file/writeAt.go index 70448c67..2b0ed67f 100644 --- a/pkg/file/writeAt.go +++ b/pkg/file/writeAt.go @@ -204,7 +204,7 @@ func (f *File) WriteAt(podFileWithPath, podPassword string, update io.Reader, of } } - addr, uploadErr := f.client.UploadBlob(uploadData, tag, true, true) + addr, uploadErr := f.client.UploadBlob(uploadData, tag, true) if uploadErr != nil { mainErr = uploadErr return @@ -249,7 +249,7 @@ func (f *File) WriteAt(podFileWithPath, podPassword string, update io.Reader, of return 0, err } - addr, err := f.client.UploadBlob(fileInodeData, 0, true, true) + addr, err := f.client.UploadBlob(fileInodeData, 0, true) if err != nil { // skipcq: TCV-001 return 0, err } diff --git a/pkg/pod/sharing.go b/pkg/pod/sharing.go index a9779d18..78122fa4 100644 --- a/pkg/pod/sharing.go +++ b/pkg/pod/sharing.go @@ -72,7 +72,7 @@ func (p *Pod) PodShare(podName, sharedPodName string) (string, error) { if err != nil { // skipcq: TCV-001 return "", err } - ref, err := p.client.UploadBlob(data, 0, true, false) + ref, err := p.client.UploadBlob(data, 0, false) if err != nil { // skipcq: TCV-001 return "", err } diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 0673d0b2..2a550060 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -29,7 +29,7 @@ const ( ) type SubscriptionInfoPutter interface { - UploadBlob(data []byte, tag uint32, pin bool, encrypt bool) (address []byte, err error) + UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) } type SubscriptionInfoGetter interface { @@ -84,7 +84,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl if err != nil { // skipcq: TCV-001 return err } - ref, err := c.putter.UploadBlob(data, 0, true, false) + ref, err := c.putter.UploadBlob(data, 0, false) if err != nil { // skipcq: TCV-001 return err } @@ -160,7 +160,11 @@ func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, request return err } - ref, err := c.putter.UploadBlob(encData, 0, true, false) + ref, err := c.putter.UploadBlob(encData, 0, false) + if err != nil { + return err + } + var fixedRef [32]byte copy(fixedRef[:], ref) diff --git a/pkg/user/sharing.go b/pkg/user/sharing.go index 0a4bd80f..a0826e0e 100644 --- a/pkg/user/sharing.go +++ b/pkg/user/sharing.go @@ -96,7 +96,7 @@ func (u *Users) ShareFileWithUser(podName, podPassword, podFileWithPath, destina } // upload the encrypted data and get the reference - ref, err := u.client.UploadBlob(encryptedData, 0, true, true) + ref, err := u.client.UploadBlob(encryptedData, 0, true) if err != nil { // skipcq: TCV-001 return "", err } From 75210dba604c396d935035b3172efe21379b4fa6 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 3 Mar 2023 12:37:07 +0530 Subject: [PATCH 09/48] public apis added --- cmd/dfs/cmd/server.go | 3 + pkg/account/account.go | 2 +- pkg/api/public.go | 236 +++++++++++++++++++++++++++++++++++++++++ pkg/dfs/pod_api.go | 164 +++++++++++++++++++++++++++- 4 files changed, 403 insertions(+), 2 deletions(-) create mode 100644 pkg/api/public.go diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index fca2cf25..3094e0a5 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -271,6 +271,9 @@ func startHttpService(logger logging.Logger) *http.Server { httpSwagger.URL("./swagger/doc.json"), )).Methods(http.MethodGet) } + router.HandleFunc("/public/file", handler.PublicPodGetFileHandler) + router.HandleFunc("/public/dir", handler.PublicPodGetDirHandler) + router.HandleFunc("/public/{ref}/{file}", handler.PublicPodFilePathHandler) apiVersion := "v1" diff --git a/pkg/account/account.go b/pkg/account/account.go index eda17223..f93d96e1 100644 --- a/pkg/account/account.go +++ b/pkg/account/account.go @@ -274,7 +274,7 @@ func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, er return decryptedBytes[:seedSize], nil } -// func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { pads the given seed and name with random elements to be a chunk of chunkSize +// PadSeedName pads the given seed and name with random elements to be a chunk of chunkSize func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { usernameLength := len(username) endIndexBytes := make([]byte, nameSize) diff --git a/pkg/api/public.go b/pkg/api/public.go new file mode 100644 index 00000000..65f5a911 --- /dev/null +++ b/pkg/api/public.go @@ -0,0 +1,236 @@ +package api + +import ( + "io" + "net/http" + "strconv" + + "github.com/gorilla/mux" + + "github.com/fairdatasociety/fairOS-dfs/pkg/dir" + "github.com/fairdatasociety/fairOS-dfs/pkg/file" + + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + "resenje.org/jsonhttp" +) + +// PublicPodGetFileHandler godoc +// +// @Summary Receive shared pod info +// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Tags pod +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param filePath query string true "file location in the pod" +// @Success 200 {object} pod.ShareInfo +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /public [get] +func (h *Handler) PublicPodGetFileHandler(w http.ResponseWriter, r *http.Request) { + keys, ok := r.URL.Query()["sharingRef"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + + sharingRefString := keys[0] + if sharingRefString == "" { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("public pod file download: invalid reference: ", err) + jsonhttp.BadRequest(w, "public pod file download: invalid reference:"+err.Error()) + return + } + keys, ok = r.URL.Query()["filePath"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod file download: \"filePath\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") + return + } + filePath := keys[0] + if filePath == "" { + h.logger.Errorf("public pod file download: \"filePath\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") + return + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + reader, size, err := h.dfsAPI.PublicPodFileDownload(shareInfo, filePath) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + defer reader.Close() + + sizeString := strconv.FormatUint(size, 10) + w.Header().Set("Content-Length", sizeString) + + _, err = io.Copy(w, reader) + if err != nil { + h.logger.Errorf("download: %v", err) + w.Header().Set("Content-Type", " application/json") + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + } +} + +// PublicPodFilePathHandler godoc +// +// @Summary Receive shared pod info +// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Tags pod +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param filePath query string true "file location in the pod" +// @Success 200 {object} pod.ShareInfo +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /public [get] +func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Request) { + + params := mux.Vars(r) + sharingRefString, ok := params["ref"] + if !ok { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + if sharingRefString == "" { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("public pod file download: invalid reference: ", err) + jsonhttp.BadRequest(w, "public pod file download: invalid reference:"+err.Error()) + return + } + filePath, ok := params["file"] + if !ok { + h.logger.Errorf("public pod file download: \"filePath\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") + return + } + if filePath == "" { + filePath = "/index.html" + } else { + filePath = "/" + filePath + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + reader, size, err := h.dfsAPI.PublicPodFileDownload(shareInfo, filePath) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + defer reader.Close() + + sizeString := strconv.FormatUint(size, 10) + w.Header().Set("Content-Length", sizeString) + + _, err = io.Copy(w, reader) + if err != nil { + h.logger.Errorf("download: %v", err) + w.Header().Set("Content-Type", " application/json") + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + } +} + +// PublicPodGetDirHandler godoc +// +// @Summary Receive shared pod info +// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Tags pod +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param dirPath query string true "dir location in the pod" +// @Success 200 {object} pod.ShareInfo +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /public [get] +func (h *Handler) PublicPodGetDirHandler(w http.ResponseWriter, r *http.Request) { + keys, ok := r.URL.Query()["sharingRef"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + + sharingRefString := keys[0] + if sharingRefString == "" { + h.logger.Errorf("public pod file download: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"sharingRef\" argument missing") + return + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("public pod file download: invalid reference: ", err) + jsonhttp.BadRequest(w, "public pod file download: invalid reference:"+err.Error()) + return + } + keys, ok = r.URL.Query()["dirPath"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod file download: \"filePath\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") + return + } + dirPath := keys[0] + if dirPath == "" { + h.logger.Errorf("public pod file download: \"filePath\" argument missing") + jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") + return + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + dEntries, fEntries, err := h.dfsAPI.PublicPodDisLs(shareInfo, dirPath) + if err != nil { + h.logger.Errorf("public pod file download: %v", err) + jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) + return + } + + if dEntries == nil { + dEntries = make([]dir.Entry, 0) + } + if fEntries == nil { + fEntries = make([]file.Entry, 0) + } + w.Header().Set("Content-Type", "application/json") + jsonhttp.OK(w, &ListFileResponse{ + Directories: dEntries, + Files: fEntries, + }) +} diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 601286c8..a4a76a86 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -19,7 +19,18 @@ package dfs import ( "context" "encoding/hex" - + "encoding/json" + "fmt" + "io" + "net/http" + "path/filepath" + "strconv" + "strings" + + "github.com/fairdatasociety/fairOS-dfs/pkg/account" + "github.com/fairdatasociety/fairOS-dfs/pkg/dir" + "github.com/fairdatasociety/fairOS-dfs/pkg/feed" + "github.com/fairdatasociety/fairOS-dfs/pkg/file" "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" SwarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" @@ -295,6 +306,157 @@ func (a *API) PodReceiveInfo(sessionId string, ref utils.Reference) (*pod.ShareI return ui.GetPod().ReceivePodInfo(ref) } +// PublicPodReceiveInfo +func (a *API) PublicPodReceiveInfo(ref utils.Reference) (*pod.ShareInfo, error) { + data, resp, err := a.client.DownloadBlob(ref.Bytes()) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + if resp != http.StatusOK { // skipcq: TCV-001 + return nil, fmt.Errorf("ReceivePodInfo: could not download blob") + } + + var shareInfo *pod.ShareInfo + err = json.Unmarshal(data, &shareInfo) + if err != nil { + return nil, err + } + + return shareInfo, nil +} + +// PublicPodFileDownload +func (a *API) PublicPodFileDownload(pod *pod.ShareInfo, filePath string) (io.ReadCloser, uint64, error) { + + accountInfo := &account.Info{} + address := utils.HexToAddress(pod.Address) + accountInfo.SetAddress(address) + + fd := feed.New(accountInfo, a.client, a.logger) + topic := utils.HashString(filePath) + _, metaBytes, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password)) + if err != nil { + return nil, 0, err + } + + if string(metaBytes) == utils.DeletedFeedMagicWord { + a.logger.Errorf("found deleted feed for %s\n", filePath) + return nil, 0, file.ErrDeletedFeed + } + + var meta *file.MetaData + err = json.Unmarshal(metaBytes, &meta) + if err != nil { // skipcq: TCV-001 + return nil, 0, err + } + + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { // skipcq: TCV-001 + return nil, 0, err + } + + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { // skipcq: TCV-001 + return nil, 0, err + } + + reader := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + return reader, meta.Size, nil +} + +// PublicPodFileDownload +func (a *API) PublicPodDisLs(pod *pod.ShareInfo, dirPathToLs string) ([]dir.Entry, []file.Entry, error) { + + accountInfo := &account.Info{} + address := utils.HexToAddress(pod.Address) + accountInfo.SetAddress(address) + + fd := feed.New(accountInfo, a.client, a.logger) + + dirNameWithPath := filepath.ToSlash(dirPathToLs) + topic := utils.HashString(dirNameWithPath) + _, data, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password)) + if err != nil { // skipcq: TCV-001 + if dirNameWithPath == utils.PathSeparator { + return nil, nil, nil + } + return nil, nil, fmt.Errorf("list dir : %v", err) // skipcq: TCV-001 + } + + dirInode := &dir.Inode{} + err = dirInode.Unmarshal(data) + if err != nil { + return nil, nil, fmt.Errorf("list dir : %v", err) + } + + listEntries := []dir.Entry{} + var files []string + for _, fileOrDirName := range dirInode.FileOrDirNames { + if strings.HasPrefix(fileOrDirName, "_D_") { + dirName := strings.TrimPrefix(fileOrDirName, "_D_") + dirPath := utils.CombinePathAndFile(dirNameWithPath, dirName) + dirTopic := utils.HashString(dirPath) + + _, data, err := fd.GetFeedData(dirTopic, accountInfo.GetAddress(), []byte(pod.Password)) + if err != nil { // skipcq: TCV-001 + return nil, nil, fmt.Errorf("list dir : %v", err) + } + var dirInode *dir.Inode + err = json.Unmarshal(data, &dirInode) + if err != nil { // skipcq: TCV-001 + return nil, nil, fmt.Errorf("list dir : %v", err) + } + entry := dir.Entry{ + Name: dirInode.Meta.Name, + ContentType: dir.MineTypeDirectory, // per RFC2425 + CreationTime: strconv.FormatInt(dirInode.Meta.CreationTime, 10), + AccessTime: strconv.FormatInt(dirInode.Meta.AccessTime, 10), + ModificationTime: strconv.FormatInt(dirInode.Meta.ModificationTime, 10), + Mode: dirInode.Meta.Mode, + } + listEntries = append(listEntries, entry) + } else if strings.HasPrefix(fileOrDirName, "_F_") { + fileName := strings.TrimPrefix(fileOrDirName, "_F_") + filePath := utils.CombinePathAndFile(dirNameWithPath, fileName) + files = append(files, filePath) + } + } + + fileEntries := []file.Entry{} + for _, filePath := range files { + fileTopic := utils.HashString(utils.CombinePathAndFile(filePath, "")) + + _, data, err := fd.GetFeedData(fileTopic, accountInfo.GetAddress(), []byte(pod.Password)) + if err != nil { // skipcq: TCV-001 + return nil, nil, fmt.Errorf("file mtdt : %v", err) + } + if string(data) == utils.DeletedFeedMagicWord { // skipcq: TCV-001 + continue + } + var meta *file.MetaData + err = json.Unmarshal(data, &meta) + if err != nil { // skipcq: TCV-001 + return nil, nil, fmt.Errorf("file mtdt : %v", err) + } + entry := file.Entry{ + Name: meta.Name, + ContentType: meta.ContentType, + Size: strconv.FormatUint(meta.Size, 10), + BlockSize: strconv.FormatInt(int64(meta.BlockSize), 10), + CreationTime: strconv.FormatInt(meta.CreationTime, 10), + AccessTime: strconv.FormatInt(meta.AccessTime, 10), + ModificationTime: strconv.FormatInt(meta.ModificationTime, 10), + Mode: meta.Mode, + } + + fileEntries = append(fileEntries, entry) + } + + return listEntries, fileEntries, nil +} + // PodReceive func (a *API) PodReceive(sessionId, sharedPodName string, ref utils.Reference) (*pod.Info, error) { // get the logged-in user information From fb33aa7842fbe10a38341706b482d0d7874a7186 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 7 Mar 2023 10:23:04 +0530 Subject: [PATCH 10/48] file download with path params --- cmd/dfs/cmd/server.go | 12 +++- pkg/api/public.go | 130 +++++++++++++++++++++++++++++++++++------- pkg/dfs/pod_api.go | 20 +++++++ 3 files changed, 137 insertions(+), 25 deletions(-) diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index 3094e0a5..6172e178 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -271,9 +271,15 @@ func startHttpService(logger logging.Logger) *http.Server { httpSwagger.URL("./swagger/doc.json"), )).Methods(http.MethodGet) } - router.HandleFunc("/public/file", handler.PublicPodGetFileHandler) - router.HandleFunc("/public/dir", handler.PublicPodGetDirHandler) - router.HandleFunc("/public/{ref}/{file}", handler.PublicPodFilePathHandler) + router.HandleFunc("/public-file", handler.PublicPodGetFileHandler) + router.HandleFunc("/public-dir", handler.PublicPodGetDirHandler) + router.HandleFunc("/public-kv", handler.PublicPodKVEntryGetHandler) + + redirectHandler := func(w http.ResponseWriter, r *http.Request) { + http.Redirect(w, r, r.URL.Path+"/", http.StatusMovedPermanently) + } + router.HandleFunc("/public/{ref}", redirectHandler) + router.HandleFunc("/public/{ref}/{file:.*}", handler.PublicPodFilePathHandler) apiVersion := "v1" diff --git a/pkg/api/public.go b/pkg/api/public.go index 65f5a911..a8ee44ff 100644 --- a/pkg/api/public.go +++ b/pkg/api/public.go @@ -2,22 +2,23 @@ package api import ( "io" + "mime" "net/http" + "path/filepath" "strconv" - "github.com/gorilla/mux" - + "github.com/fairdatasociety/fairOS-dfs/pkg/collection" "github.com/fairdatasociety/fairOS-dfs/pkg/dir" "github.com/fairdatasociety/fairOS-dfs/pkg/file" - "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + "github.com/gorilla/mux" "resenje.org/jsonhttp" ) // PublicPodGetFileHandler godoc // -// @Summary Receive shared pod info -// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Summary download file from a shared pod +// @Description PodReceiveInfoHandler is the api handler to download file from a shared pod // @Tags pod // @Accept json // @Produce json @@ -26,7 +27,7 @@ import ( // @Success 200 {object} pod.ShareInfo // @Failure 400 {object} response // @Failure 500 {object} response -// @Router /public [get] +// @Router /public-file [get] func (h *Handler) PublicPodGetFileHandler(w http.ResponseWriter, r *http.Request) { keys, ok := r.URL.Query()["sharingRef"] if !ok || len(keys[0]) < 1 { @@ -90,17 +91,15 @@ func (h *Handler) PublicPodGetFileHandler(w http.ResponseWriter, r *http.Request // PublicPodFilePathHandler godoc // -// @Summary Receive shared pod info -// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Summary download file from a shared pod +// @Description PublicPodFilePathHandler is the api handler to download file from a shared pod // @Tags pod // @Accept json // @Produce json -// @Param sharingRef query string true "pod sharing reference" -// @Param filePath query string true "file location in the pod" // @Success 200 {object} pod.ShareInfo // @Failure 400 {object} response // @Failure 500 {object} response -// @Router /public [get] +// @Router /public/{ref}/{file} [get] func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Request) { params := mux.Vars(r) @@ -122,12 +121,7 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques jsonhttp.BadRequest(w, "public pod file download: invalid reference:"+err.Error()) return } - filePath, ok := params["file"] - if !ok { - h.logger.Errorf("public pod file download: \"filePath\" argument missing") - jsonhttp.BadRequest(w, "public pod file download: \"filePath\" argument missing") - return - } + filePath := params["file"] if filePath == "" { filePath = "/index.html" } else { @@ -140,7 +134,7 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques jsonhttp.InternalServerError(w, "public pod file download: "+err.Error()) return } - + contentType := mime.TypeByExtension(filepath.Ext(filePath)) reader, size, err := h.dfsAPI.PublicPodFileDownload(shareInfo, filePath) if err != nil { h.logger.Errorf("public pod file download: %v", err) @@ -152,7 +146,7 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques sizeString := strconv.FormatUint(size, 10) w.Header().Set("Content-Length", sizeString) - + w.Header().Set("Content-Type", contentType) _, err = io.Copy(w, reader) if err != nil { h.logger.Errorf("download: %v", err) @@ -163,8 +157,8 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques // PublicPodGetDirHandler godoc // -// @Summary Receive shared pod info -// @Description PodReceiveInfoHandler is the api handler to receive shared pod info from shared reference +// @Summary List directory content +// @Description PublicPodGetDirHandler is the api handler to list content of a directory from a public pod // @Tags pod // @Accept json // @Produce json @@ -173,7 +167,7 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques // @Success 200 {object} pod.ShareInfo // @Failure 400 {object} response // @Failure 500 {object} response -// @Router /public [get] +// @Router /public-dir [get] func (h *Handler) PublicPodGetDirHandler(w http.ResponseWriter, r *http.Request) { keys, ok := r.URL.Query()["sharingRef"] if !ok || len(keys[0]) < 1 { @@ -234,3 +228,95 @@ func (h *Handler) PublicPodGetDirHandler(w http.ResponseWriter, r *http.Request) Files: fEntries, }) } + +// PublicPodKVEntryGetHandler godoc +// +// @Summary get key from public pod +// @Description PublicPodKVEntryGetHandler is the api handler to get key from key value store from a public pod +// @Tags public +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param tableName query string true "table name" +// @Param key query string true "key to look up" +// @Success 200 {object} pod.ShareInfo +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /public-kv [get] +func (h *Handler) PublicPodKVEntryGetHandler(w http.ResponseWriter, r *http.Request) { + keys, ok := r.URL.Query()["sharingRef"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod kv get: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod kv get: \"sharingRef\" argument missing") + return + } + + sharingRefString := keys[0] + if sharingRefString == "" { + h.logger.Errorf("public pod kv get: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "public pod kv get: \"sharingRef\" argument missing") + return + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("public pod kv get: invalid reference: ", err) + jsonhttp.BadRequest(w, "public pod kv get: invalid reference:"+err.Error()) + return + } + + keys, ok = r.URL.Query()["tableName"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod kv get: \"tableName\" argument missing") + jsonhttp.BadRequest(w, &response{Message: "public pod kv get: \"tableName\" argument missing"}) + return + } + name := keys[0] + if name == "" { + h.logger.Errorf("public pod kv get: \"tableName\" argument missing") + jsonhttp.BadRequest(w, &response{Message: "public pod kv get: \"tableName\" argument missing"}) + return + } + + keys, ok = r.URL.Query()["key"] + if !ok || len(keys[0]) < 1 { + h.logger.Errorf("public pod kv get: \"key\" argument missing") + jsonhttp.BadRequest(w, &response{Message: "public pod kv get: \"key\" argument missing"}) + return + } + key := keys[0] + if key == "" { + h.logger.Errorf("public pod kv get: \"key\" argument missing") + jsonhttp.BadRequest(w, &response{Message: "public pod kv get: \"key\" argument missing"}) + return + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("public pod kv get: %v", err) + jsonhttp.InternalServerError(w, "public pod kv get: "+err.Error()) + return + } + + columns, data, err := h.dfsAPI.PublicPodKVEntryGet(shareInfo, name, key) + if err != nil { + h.logger.Errorf("public pod kv get: %v", err) + if err == collection.ErrEntryNotFound { + jsonhttp.NotFound(w, &response{Message: "public pod kv get: " + err.Error()}) + return + } + jsonhttp.InternalServerError(w, &response{Message: "public pod kv get: " + err.Error()}) + return + } + + var resp KVResponse + if columns != nil { + resp.Keys = columns + } else { + resp.Keys = []string{key} + } + resp.Values = data + + w.Header().Set("Content-Type", "application/json") + jsonhttp.OK(w, &resp) +} diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index a4a76a86..260b9349 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -27,6 +27,8 @@ import ( "strconv" "strings" + c "github.com/fairdatasociety/fairOS-dfs/pkg/collection" + "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/dir" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" @@ -366,6 +368,24 @@ func (a *API) PublicPodFileDownload(pod *pod.ShareInfo, filePath string) (io.Rea return reader, meta.Size, nil } +// PublicPodKVEntryGet +func (a *API) PublicPodKVEntryGet(pod *pod.ShareInfo, name, key string) ([]string, []byte, error) { + + accountInfo := &account.Info{} + address := utils.HexToAddress(pod.Address) + accountInfo.SetAddress(address) + + fd := feed.New(accountInfo, a.client, a.logger) + kvStore := c.NewKeyValueStore(pod.PodName, fd, accountInfo, address, a.client, a.logger) + + err := kvStore.OpenKVTable(name, pod.Password) + if err != nil { + return nil, nil, err + } + + return kvStore.KVGet(name, key) +} + // PublicPodFileDownload func (a *API) PublicPodDisLs(pod *pod.ShareInfo, dirPathToLs string) ([]dir.Entry, []file.Entry, error) { From b1b87d7b6b8d48804e0cf26a3a2b873c9a9e691d Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 6 Mar 2023 11:28:45 +0530 Subject: [PATCH 11/48] subscription approve encryption --- pkg/dfs/pod_api.go | 20 ++++++++++++++++++++ pkg/pod/subscription.go | 40 ++++++++++++++++++++++++++++++++++++++-- wasm/main.go | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 2 deletions(-) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 260b9349..a3549734 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -651,6 +651,26 @@ func (a *API) ApproveSubscription(sessionId, podName string, reqHash, nameHash [ return ui.GetPod().ApproveSubscription(podName, reqHash, subscriberPublicKey) } +// EncryptSubscription +func (a *API) EncryptSubscription(sessionId, podName string, nameHash [32]byte) (string, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return "", ErrUserNotLoggedIn + } + + if a.sm == nil { + return "", errNilSubManager + } + + _, subscriberPublicKey, err := a.users.GetUserInfoFromENS(nameHash) + if err != nil { + return "", err + } + + return ui.GetPod().EncryptUploadSubscriptionInfo(podName, subscriberPublicKey) +} + type SubscriptionInfo struct { SubHash [32]byte PodName string diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index c4496145..45b18514 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -3,12 +3,14 @@ package pod import ( "crypto/ecdsa" "crypto/sha256" + "encoding/hex" + "encoding/json" "fmt" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" - "github.com/ethereum/go-ethereum/common" swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) // ListPodInMarketplace will save the pod info in the subscriptionManager smart contract with its owner and price @@ -58,6 +60,40 @@ func (p *Pod) ApproveSubscription(podName string, requestHash [32]byte, subscrib return p.sm.AllowAccess(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), info, requestHash, secret, p.acc.GetUserAccountInfo().GetPrivateKey()) } +// EncryptUploadSubscriptionInfo will upload sub pod info into swarm +func (p *Pod) EncryptUploadSubscriptionInfo(podName string, subscriberPublicKey *ecdsa.PublicKey) (string, error) { + a, _ := subscriberPublicKey.Curve.ScalarMult(subscriberPublicKey.X, subscriberPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + + shareInfo, err := p.GetPodSharingInfo(podName) + if err != nil { + return "", err + } + + info := &rpc.ShareInfo{ + PodName: shareInfo.PodName, + Address: shareInfo.Address, + Password: shareInfo.Password, + UserAddress: shareInfo.UserAddress, + } + + data, err := json.Marshal(info) + if err != nil { // skipcq: TCV-001 + return "", err + } + encData, err := utils.EncryptBytes(secret[:], data) + if err != nil { + return "", err + } + + ref, err := p.client.UploadBlob(encData, 0, false) + if err != nil { + return "", err + } + + return hex.EncodeToString(ref), nil +} + // RequestSubscription will send a subscriptionManager request to the owner of the pod // will create an escrow account and deposit the `price` func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error { diff --git a/wasm/main.go b/wasm/main.go index 746d8707..5a404c5b 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -70,6 +70,7 @@ func registerWasmFunctions() { js.Global().Set("getSubscribablePods", js.FuncOf(getSubscribablePods)) js.Global().Set("getSubRequests", js.FuncOf(getSubRequests)) js.Global().Set("getSubscribablePodInfo", js.FuncOf(getSubscribablePodInfo)) + js.Global().Set("encryptSubscription", js.FuncOf(encryptSubscription)) js.Global().Set("dirPresent", js.FuncOf(dirPresent)) js.Global().Set("dirMake", js.FuncOf(dirMake)) @@ -2109,6 +2110,45 @@ func approveSubscription(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func encryptSubscription(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"encryptSubscription(sessionId, podName, subscriberNameHash)\"") + return nil + } + sessionId := funcArgs[0].String() + podName := funcArgs[1].String() + subscriberNameHashStr := funcArgs[2].String() + + nameHash, err := utils.Decode(subscriberNameHashStr) + if err != nil { + reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) + return nil + } + + var nh [32]byte + copy(nh[:], nameHash) + go func() { + ref, err := api.EncryptSubscription(sessionId, podName, nh) + if err != nil { + reject.Invoke(fmt.Sprintf("encryptSubscription failed : %s", err.Error())) + return + } + object := js.Global().Get("Object").New() + object.Set("reference", ref) + + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] From db3989376802e120108e2cff9b17534e5c7a7f8f Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 6 Mar 2023 12:00:52 +0530 Subject: [PATCH 12/48] subscription open decryption --- pkg/dfs/pod_api.go | 32 ++++++++++++++++++++++++++++++++ pkg/pod/subscription.go | 38 ++++++++++++++++++++++++++++++++++++++ wasm/main.go | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index a3549734..cc9c3236 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -671,6 +671,38 @@ func (a *API) EncryptSubscription(sessionId, podName string, nameHash [32]byte) return ui.GetPod().EncryptUploadSubscriptionInfo(podName, subscriberPublicKey) } +// DecryptAndOpenSubscriptionPod +func (a *API) DecryptAndOpenSubscriptionPod(sessionId, reference string, sellerNameHash [32]byte) (*pod.Info, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + + if a.sm == nil { + return nil, errNilSubManager + } + + _, publicKey, err := a.users.GetUserInfoFromENS(sellerNameHash) + if err != nil { + return nil, err + } + + pi, err := ui.GetPod().OpenSubscribedPodFromReference(reference, publicKey) + if err != nil { + return nil, err + } + + err = pi.GetDirectory().AddRootDir(pi.GetPodName(), pi.GetPodPassword(), pi.GetPodAddress(), pi.GetFeed()) + if err != nil { + return nil, err + } + // Add podName in the login user session + ui.AddPodName(pi.GetPodName(), pi) + return pi, nil + +} + type SubscriptionInfo struct { SubHash [32]byte PodName string diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index 45b18514..496a5d1a 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -6,6 +6,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "net/http" "github.com/ethereum/go-ethereum/common" swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" @@ -133,6 +134,43 @@ func (p *Pod) OpenSubscribedPod(subHash [32]byte, ownerPublicKey *ecdsa.PublicKe return p.OpenFromShareInfo(shareInfo) } +// OpenSubscribedPodFromReference will open a subscribed pod +func (p *Pod) OpenSubscribedPodFromReference(reference string, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { + a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) + secret := sha256.Sum256(a.Bytes()) + + ref, err := hex.DecodeString(reference) + if err != nil { // skipcq: TCV-001 + return nil, err + } + encData, resp, err := p.client.DownloadBlob(ref) + if err != nil { // skipcq: TCV-001 + return nil, err + } + + if resp != http.StatusOK { // skipcq: TCV-001 + return nil, fmt.Errorf("OpenSubscribedPodFromReference: could not get subscription info") + } + + data, err := utils.DecryptBytes(secret[:], encData) + if err != nil { + return nil, err + } + var info *rpc.ShareInfo + err = json.Unmarshal(data, &info) + if err != nil { + return nil, err + } + + shareInfo := &ShareInfo{ + PodName: info.PodName, + Address: info.Address, + Password: info.Password, + UserAddress: info.UserAddress, + } + return p.OpenFromShareInfo(shareInfo) +} + // GetSubRequests will get all owners sub requests func (p *Pod) GetSubRequests() ([]swarmMail.SwarmMailSubRequest, error) { return p.sm.GetSubRequests(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) diff --git a/wasm/main.go b/wasm/main.go index 5a404c5b..39567d17 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -71,6 +71,7 @@ func registerWasmFunctions() { js.Global().Set("getSubRequests", js.FuncOf(getSubRequests)) js.Global().Set("getSubscribablePodInfo", js.FuncOf(getSubscribablePodInfo)) js.Global().Set("encryptSubscription", js.FuncOf(encryptSubscription)) + js.Global().Set("openSubscribedPodFromReference", js.FuncOf(openSubscribedPodFromReference)) js.Global().Set("dirPresent", js.FuncOf(dirPresent)) js.Global().Set("dirMake", js.FuncOf(dirMake)) @@ -2227,6 +2228,44 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func openSubscribedPodFromReference(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"openSubscribedPodFromReference(sessionId, reference, sellerNameHash)\"") + return nil + } + sessionId := funcArgs[0].String() + reference := funcArgs[1].String() + sellerNameHash := funcArgs[2].String() + + subHash, err := utils.Decode(sellerNameHash) + if err != nil { + reject.Invoke(fmt.Sprintf("openSubscribedPodFromReference failed : %s", err.Error())) + return nil + } + + var s [32]byte + copy(s[:], subHash) + + go func() { + pi, err := api.DecryptAndOpenSubscriptionPod(sessionId, reference, s) + if err != nil { + reject.Invoke(fmt.Sprintf("openSubscribedPodFromReference failed : %s", err.Error())) + return + } + + resolve.Invoke(fmt.Sprintf("%s opened successfully", pi.GetPodName())) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func getSubscribablePods(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] From 8fff34c3059b53fbd923f11c0fbccadaa09121c1 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 8 Mar 2023 16:14:08 +0530 Subject: [PATCH 13/48] podStat without open --- cmd/dfs/cmd/server.go | 10 +++++++--- pkg/api/handler.go | 4 ++-- pkg/contracts/config.go | 25 ++++++++++++++---------- pkg/file/meta.go | 6 +++--- pkg/pod/stat.go | 27 +++++++++++++++++++++++--- pkg/subscriptionManager/rpc/manager.go | 1 + wasm/main.go | 19 +++++++++--------- 7 files changed, 62 insertions(+), 30 deletions(-) diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index 6172e178..2ff2f4d0 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -118,6 +118,7 @@ can consume it.`, } } ensConfig := &contracts.ENSConfig{} + var subscriptionConfig *contracts.SubscriptionConfig network := config.GetString("network") rpc := config.GetString(optionRPC) if rpc == "" { @@ -164,12 +165,15 @@ can consume it.`, fmt.Println("\nens is not available for mainnet yet") return fmt.Errorf("ens is not available for mainnet yet") case "testnet": - ensConfig = contracts.TestnetConfig() + ensConfig, subscriptionConfig = contracts.TestnetConfig() case "play": - ensConfig = contracts.PlayConfig() + ensConfig, subscriptionConfig = contracts.PlayConfig() } } ensConfig.ProviderBackend = rpc + if subscriptionConfig != nil { + subscriptionConfig.RPC = rpc + } var logger logging.Logger switch v := strings.ToLower(verbosity); v { case "0", "silent": @@ -203,7 +207,7 @@ can consume it.`, ctx, cancel := context.WithCancel(cmd.Context()) defer cancel() // datadir will be removed in some future version. it is kept for migration purpose only - hdlr, err := api.New(ctx, beeApi, cookieDomain, postageBlockId, corsOrigins, ensConfig, logger) + hdlr, err := api.New(ctx, beeApi, cookieDomain, postageBlockId, corsOrigins, ensConfig, subscriptionConfig, logger) if err != nil { logger.Error(err.Error()) return err diff --git a/pkg/api/handler.go b/pkg/api/handler.go index e061b946..14093b8f 100644 --- a/pkg/api/handler.go +++ b/pkg/api/handler.go @@ -36,8 +36,8 @@ type Handler struct { } // New -func New(ctx context.Context, beeApi, cookieDomain, postageBlockId string, whitelistedOrigins []string, ensConfig *contracts.ENSConfig, logger logging.Logger) (*Handler, error) { - api, err := dfs.NewDfsAPI(beeApi, postageBlockId, ensConfig, nil, logger) +func New(ctx context.Context, beeApi, cookieDomain, postageBlockId string, whitelistedOrigins []string, ensConfig *contracts.ENSConfig, subscriptionConfig *contracts.SubscriptionConfig, logger logging.Logger) (*Handler, error) { + api, err := dfs.NewDfsAPI(beeApi, postageBlockId, ensConfig, subscriptionConfig, logger) if err != nil { return nil, err diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 9cefbfff..05917649 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -10,30 +10,35 @@ type ENSConfig struct { ProviderBackend string } +// SubscriptionConfig handles the Subscription Management +type SubscriptionConfig struct { + RPC string + SwarmMailAddress string +} + // TestnetConfig defines the configuration for goerli testnet -func TestnetConfig() *ENSConfig { - return &ENSConfig{ +func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { + e := &ENSConfig{ ChainID: "5", ENSRegistryAddress: "0x42B22483e3c8dF794f351939620572d1a3193c12", FDSRegistrarAddress: "0xF4C9Cd25031E3BB8c5618299bf35b349c1aAb6A9", PublicResolverAddress: "0xbfeCC6c32B224F7D0026ac86506Fe40A9607BD14", ProviderDomain: "fds", } + + s := &SubscriptionConfig{ + SwarmMailAddress: "0x7Aedf45B82924B2dBF9818c7cAaB6c7557Ba09c0", + } + return e, s } // PlayConfig defines the configuration for fdp-play -func PlayConfig() *ENSConfig { +func PlayConfig() (*ENSConfig, *SubscriptionConfig) { return &ENSConfig{ ChainID: "4020", ENSRegistryAddress: "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15", FDSRegistrarAddress: "0xA94B7f0465E98609391C623d0560C5720a3f2D33", PublicResolverAddress: "0xFC628dd79137395F3C9744e33b1c5DE554D94882", ProviderDomain: "fds", - } -} - -// SubscriptionConfig handles the Subscription Management -type SubscriptionConfig struct { - RPC string - SwarmMailAddress string + }, nil } diff --git a/pkg/file/meta.go b/pkg/file/meta.go index f59750e3..7a6e2adb 100644 --- a/pkg/file/meta.go +++ b/pkg/file/meta.go @@ -32,6 +32,7 @@ var ( //ErrDeletedFeed ErrDeletedFeed = errors.New("deleted feed") + ErrUnknownFeed = errors.New("unknown value in feed") ) // MetaData @@ -69,7 +70,7 @@ func (f *File) handleMeta(meta *MetaData, podPassword string) error { totalPath := utils.CombinePathAndFile(meta.Path, meta.Name) _, err := f.GetMetaFromFileName(totalPath, podPassword, f.userAddress) if err != nil { - if err != ErrDeletedFeed { + if err != ErrDeletedFeed || err != ErrUnknownFeed { return f.uploadMeta(meta, podPassword) } } @@ -201,11 +202,10 @@ func (f *File) GetMetaFromFileName(fileNameWithPath, podPassword string, userAdd f.logger.Errorf("found deleted feed for %s\n", fileNameWithPath) return nil, ErrDeletedFeed } - var meta *MetaData err = json.Unmarshal(metaBytes, &meta) if err != nil { // skipcq: TCV-001 - return nil, err + return nil, ErrUnknownFeed } return meta, nil diff --git a/pkg/pod/stat.go b/pkg/pod/stat.go index 76db2b54..3d233947 100644 --- a/pkg/pod/stat.go +++ b/pkg/pod/stat.go @@ -16,6 +16,8 @@ limitations under the License. package pod +import "fmt" + // Stat represents a pod name and address type Stat struct { PodName string `json:"podName"` @@ -25,11 +27,30 @@ type Stat struct { // PodStat shows all the pod related information like podname and its current address. func (p *Pod) PodStat(podName string) (*Stat, error) { podInfo, _, err := p.GetPodInfoFromPodMap(podName) + if err == nil { + return &Stat{ + PodName: podInfo.GetPodName(), + PodAddress: podInfo.userAddress.String(), + }, nil + } + podList, err := p.loadUserPods() if err != nil { - return nil, ErrInvalidPodName + return nil, err + } + + index, _ := p.getIndexPassword(podList, podName) + if index == -1 { + return nil, fmt.Errorf("pod does not exist") + } + // Create pod account and other data structures + // create a child account for the userAddress and other data structures for the pod + accountInfo, err := p.acc.CreatePodAccount(index, false) + if err != nil { // skipcq: TCV-001 + return nil, err } + addr := accountInfo.GetAddress() return &Stat{ - PodName: podInfo.GetPodName(), - PodAddress: podInfo.userAddress.String(), + PodName: podName, + PodAddress: addr.String(), }, nil } diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 2a550060..e6e7ad27 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -278,6 +278,7 @@ func New(subConfig *contracts.SubscriptionConfig, logger logging.Logger, getter if err != nil { return nil, fmt.Errorf("dial eth ensm: %w", err) } + logger.Info("SwarmMailAddress : ", subConfig.SwarmMailAddress) sMail, err := swarmMail.NewSwarmMail(common.HexToAddress(subConfig.SwarmMailAddress), c) if err != nil { return nil, err diff --git a/wasm/main.go b/wasm/main.go index 39567d17..27773a03 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -117,7 +117,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { resolve := args[0] reject := args[1] if len(funcArgs) != 6 { - reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, false, rpc, play, subRpc, subContractAddress)\"") + reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, false, rpc, subRpc, subContractAddress)\"") return nil } beeEndpoint := funcArgs[0].String() @@ -130,20 +130,21 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { reject.Invoke("unknown network. \"use play or testnet\"") return nil } - var config *contracts.ENSConfig + var ( + config *contracts.ENSConfig + subConfig *contracts.SubscriptionConfig + ) + if network == "play" { - config = contracts.PlayConfig() + config, subConfig = contracts.PlayConfig() } else { - config = contracts.TestnetConfig() + config, subConfig = contracts.TestnetConfig() } config.ProviderBackend = rpc + subConfig.RPC = subRpc + subConfig.SwarmMailAddress = subContractAddress logger := logging.New(os.Stdout, logrus.DebugLevel) - subConfig := &contracts.SubscriptionConfig{ - RPC: subRpc, - SwarmMailAddress: subContractAddress, - } - go func() { var err error api, err = dfs.NewDfsAPI( From a67dd76f8c91cefcb5349bd4111ca6cffc354299 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 9 Mar 2023 16:19:35 +0530 Subject: [PATCH 14/48] add cache header for static files --- pkg/api/public.go | 4 ++++ pkg/subscriptionManager/rpc/manager.go | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/api/public.go b/pkg/api/public.go index a8ee44ff..01f88311 100644 --- a/pkg/api/public.go +++ b/pkg/api/public.go @@ -6,6 +6,7 @@ import ( "net/http" "path/filepath" "strconv" + "strings" "github.com/fairdatasociety/fairOS-dfs/pkg/collection" "github.com/fairdatasociety/fairOS-dfs/pkg/dir" @@ -147,6 +148,9 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques sizeString := strconv.FormatUint(size, 10) w.Header().Set("Content-Length", sizeString) w.Header().Set("Content-Type", contentType) + if strings.HasPrefix(filePath, "static/") { + w.Header().Set("Cache-Control", "public, max-age=31536000") + } _, err = io.Copy(w, reader) if err != nil { h.logger.Errorf("download: %v", err) diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index e6e7ad27..6e76bc2b 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -187,7 +187,6 @@ func (c *Client) GetSubscription(subscriber common.Address, subHash, secret [32] if err != nil { return nil, err } - encData, resp, err := c.getter.DownloadBlob(item.UnlockKeyLocation[:]) if err != nil { // skipcq: TCV-001 return nil, err From 5300867e4bc5e0e554f523514c444ebc427e42e5 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 10 Mar 2023 13:44:49 +0530 Subject: [PATCH 15/48] feat: eased out pod open --- cmd/dfs/cmd/server_test.go | 2 +- gomobile/dfs.go | 7 +- pkg/api/file_download.go | 2 +- pkg/api/file_status.go | 2 +- pkg/api/pod_open.go | 17 +--- pkg/dfs/doc_api.go | 93 +++---------------- pkg/dfs/fs_api.go | 168 +++++----------------------------- pkg/dfs/kv_api.go | 85 +++-------------- pkg/dfs/pod_api.go | 89 ++---------------- pkg/dir/dir_test.go | 13 ++- pkg/dir/inode.go | 19 ++++ pkg/dir/rename.go | 6 +- pkg/dir/rmdir.go | 7 +- pkg/file/chmod.go | 6 +- pkg/file/chmod_test.go | 2 +- pkg/file/download.go | 8 +- pkg/file/download_test.go | 12 +-- pkg/file/file.go | 33 +++++-- pkg/file/meta.go | 13 +-- pkg/file/reader.go | 5 +- pkg/file/rename_test.go | 17 ++-- pkg/file/rm.go | 10 +- pkg/file/rm_test.go | 8 +- pkg/file/stat.go | 6 +- pkg/file/status.go | 4 +- pkg/file/upload_test.go | 40 ++++---- pkg/file/writeAt.go | 6 +- pkg/file/writeAt_test.go | 58 +++++++----- pkg/pod/close.go | 4 - pkg/pod/del.go | 2 +- pkg/pod/fork.go | 29 ++---- pkg/pod/new.go | 7 ++ pkg/pod/open.go | 11 ++- pkg/pod/pod.go | 13 +++ pkg/pod/stat.go | 2 +- pkg/pod/sync.go | 12 +-- pkg/pod/utils.go | 12 +-- pkg/test/close_test.go | 36 +++++--- pkg/test/del_test.go | 6 +- pkg/test/fork_test.go | 21 +---- pkg/test/integration_test.go | 4 +- pkg/test/open_test.go | 4 +- pkg/test/pod_new_test.go | 4 +- pkg/test/pod_sharing_test.go | 12 +-- pkg/test/subscription_test.go | 4 +- pkg/test/sync_test.go | 8 +- pkg/test/user_sharing_test.go | 6 -- pkg/user/info.go | 10 -- pkg/user/sharing.go | 9 +- 49 files changed, 323 insertions(+), 631 deletions(-) diff --git a/cmd/dfs/cmd/server_test.go b/cmd/dfs/cmd/server_test.go index a6b481f7..9437008c 100644 --- a/cmd/dfs/cmd/server_test.go +++ b/cmd/dfs/cmd/server_test.go @@ -576,7 +576,7 @@ func TestApis(t *testing.T) { t.Fatal(err) } if renameResp.StatusCode != 200 { - t.Fatal("rename failed", u) + t.Fatal("rename failed", u, renameResp.StatusCode) } } diff --git a/gomobile/dfs.go b/gomobile/dfs.go index a9e85947..3afe3520 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -46,11 +46,12 @@ func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) err logger := logging.New(os.Stdout, logrus.Level(logLevel)) var err error var ensConfig *contracts.ENSConfig + var subConfig *contracts.SubscriptionConfig switch network { case "play": - ensConfig = contracts.PlayConfig() + ensConfig, subConfig = contracts.PlayConfig() case "testnet": - ensConfig = contracts.TestnetConfig() + ensConfig, subConfig = contracts.TestnetConfig() case "mainnet": return fmt.Errorf("not supported yet") default: @@ -61,7 +62,7 @@ func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) err beeEndpoint, postageBlockId, ensConfig, - nil, + subConfig, logger, ) return err diff --git a/pkg/api/file_download.go b/pkg/api/file_download.go index 3aad206a..3e72d884 100644 --- a/pkg/api/file_download.go +++ b/pkg/api/file_download.go @@ -125,7 +125,7 @@ func (h *Handler) handleDownload(w http.ResponseWriter, r *http.Request, podName jsonhttp.BadRequest(w, "download: "+err.Error()) return } - if err == file.ErrFileNotPresent || err == file.ErrFileNotFound { + if err == file.ErrFileNotFound { h.logger.Errorf("download: %v", err) jsonhttp.NotFound(w, "download: "+err.Error()) return diff --git a/pkg/api/file_status.go b/pkg/api/file_status.go index 1aee1424..0bc9642d 100644 --- a/pkg/api/file_status.go +++ b/pkg/api/file_status.go @@ -78,7 +78,7 @@ func (h *Handler) FileStatusHandler(w http.ResponseWriter, r *http.Request) { jsonhttp.BadRequest(w, "status: "+err.Error()) return } - if err == file.ErrFileNotPresent || err == file.ErrFileNotFound { + if err == file.ErrFileNotFound { h.logger.Errorf("status: %v", err) jsonhttp.NotFound(w, "status: "+err.Error()) return diff --git a/pkg/api/pod_open.go b/pkg/api/pod_open.go index 664da80d..ed4c8b56 100644 --- a/pkg/api/pod_open.go +++ b/pkg/api/pod_open.go @@ -145,20 +145,5 @@ func (h *Handler) PodOpenAsyncHandler(w http.ResponseWriter, r *http.Request) { jsonhttp.BadRequest(w, &response{Message: "pod open: \"cookie-id\" parameter missing in cookie"}) return } - - // open pod - _, err = h.dfsAPI.OpenPodAsync(r.Context(), pod, sessionId) - if err != nil { - if err == dfs.ErrUserNotLoggedIn || - err == p.ErrInvalidPodName { - h.logger.Errorf("pod open: %v", err) - jsonhttp.NotFound(w, &response{Message: "pod open: " + err.Error()}) - return - } - h.logger.Errorf("pod open: %v", err) - jsonhttp.InternalServerError(w, &response{Message: "pod open: " + err.Error()}) - return - } - - jsonhttp.OK(w, &response{Message: "pod opened successfully"}) + jsonhttp.BadRequest(w, &response{Message: "pod/open-async: deprecated"}) } diff --git a/pkg/dfs/doc_api.go b/pkg/dfs/doc_api.go index e394e79a..c2de067d 100644 --- a/pkg/dfs/doc_api.go +++ b/pkg/dfs/doc_api.go @@ -26,12 +26,7 @@ func (a *API) DocCreate(sessionId, podName, name string, indexes map[string]coll return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -47,12 +42,7 @@ func (a *API) DocOpen(sessionId, podName, name string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -68,12 +58,7 @@ func (a *API) DocDelete(sessionId, podName, name string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -90,12 +75,7 @@ func (a *API) DocList(sessionId, podName string) (map[string]collection.DBSchema return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -113,12 +93,7 @@ func (a *API) DocCount(sessionId, podName, name, expr string) (*collection.Table return keyCount, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return keyCount, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return keyCount, err } @@ -140,12 +115,7 @@ func (a *API) DocPut(sessionId, podName, name string, value []byte) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -162,12 +132,7 @@ func (a *API) DocGet(sessionId, podName, name, id string) ([]byte, error) { return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -184,12 +149,7 @@ func (a *API) DocDel(sessionId, podName, name, id string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -206,12 +166,7 @@ func (a *API) DocFind(sessionId, podName, name, expr string, limit int) ([][]byt return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -227,12 +182,7 @@ func (a *API) DocBatch(sessionId, podName, name string) (*collection.DocBatch, e return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -248,12 +198,7 @@ func (a *API) DocBatchPut(sessionId, podName string, doc []byte, docBatch *colle return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -269,12 +214,7 @@ func (a *API) DocBatchWrite(sessionId, podName string, docBatch *collection.DocB return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -290,18 +230,13 @@ func (a *API) DocIndexJson(sessionId, podName, name, podFileWithPath string) err return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // check if file present - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } file := podInfo.GetFile() - if !file.IsFileAlreadyPresent(podFileWithPath) { + if !file.IsFileAlreadyPresent(podInfo.GetPodPassword(), podFileWithPath) { return ErrFileNotPresent } diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index df8ff46e..3e397fb9 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -37,13 +37,8 @@ func (a *API) Mkdir(podName, dirToCreateWithPath, sessionId string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // get the dir object and make directory - podInfo, podPassword, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, podPassword, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -60,13 +55,8 @@ func (a *API) RenameDir(podName, dirToRenameWithPath, newName, sessionId string) return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // get the dir object and rename directory - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -83,13 +73,8 @@ func (a *API) IsDirPresent(podName, directoryNameWithPath, sessionId string) (bo return false, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return false, ErrPodNotOpen - } - // get pod Info - podInfo, podPassword, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, podPassword, err := ui.GetPod().GetPodInfo(podName) if err != nil { return false, err } @@ -108,13 +93,8 @@ func (a *API) RmDir(podName, directoryNameWithPath, sessionId string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // get the dir object and remove directory - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -131,13 +111,8 @@ func (a *API) ListDir(podName, currentDir, sessionId string) ([]dir.Entry, []f.E return nil, nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, nil, ErrPodNotOpen - } - // get the dir object and list directory - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, nil, err } @@ -145,7 +120,7 @@ func (a *API) ListDir(podName, currentDir, sessionId string) ([]dir.Entry, []f.E // check if directory present totalPath := utils.CombinePathAndFile(currentDir, "") - if directory.GetDirFromDirectoryMap(totalPath) == nil { + if directory.GetInode(podInfo.GetPodPassword(), totalPath) == nil { return nil, nil, dir.ErrDirectoryNotPresent } dEntries, fileList, err := directory.ListDir(currentDir, podInfo.GetPodPassword()) @@ -169,13 +144,8 @@ func (a *API) DirectoryStat(podName, directoryName, sessionId string) (*dir.Stat return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - // get the dir object and stat directory - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -196,18 +166,13 @@ func (a *API) DirectoryInode(podName, directoryName, sessionId string) (*dir.Ino return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - // get the dir object and stat directory - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } directory := podInfo.GetDirectory() - inode := directory.GetDirFromDirectoryMap(directoryName) + inode := directory.GetInode(podInfo.GetPodPassword(), directoryName) if inode == nil { a.logger.Errorf("dir not found: %s", directoryName) return nil, fmt.Errorf("dir not found") @@ -224,18 +189,8 @@ func (a *API) ChmodDir(podName, directoryNameWithPath, sessionId string, mode ui return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - // check if logged-in to pod - if !ui.GetPod().IsPodOpened(podName) { - return fmt.Errorf("login to pod to do this operation") - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -255,12 +210,7 @@ func (a *API) DeleteFile(podName, podFileWithPath, sessionId string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -295,12 +245,7 @@ func (a *API) FileStat(podName, podFileWithPath, sessionId string) (*f.Stats, er return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -322,12 +267,7 @@ func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -337,7 +277,7 @@ func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, // check if file exists, then backup the file totalPath := utils.CombinePathAndFile(podPath, podFileName) - alreadyPresent := file.IsFileAlreadyPresent(totalPath) + alreadyPresent := file.IsFileAlreadyPresent(podInfo.GetPodPassword(), totalPath) if alreadyPresent { if !overwrite { @@ -375,12 +315,7 @@ func (a *API) RenameFile(podName, fileNameWithPath, newFileNameWithPath, session return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -391,10 +326,10 @@ func (a *API) RenameFile(podName, fileNameWithPath, newFileNameWithPath, session newFileNameWithPath = filepath.ToSlash(newFileNameWithPath) // check if file exists - if !file.IsFileAlreadyPresent(fileNameWithPath) { + if !file.IsFileAlreadyPresent(podInfo.GetPodPassword(), fileNameWithPath) { return ErrFileNotPresent } - if file.IsFileAlreadyPresent(newFileNameWithPath) { + if file.IsFileAlreadyPresent(podInfo.GetPodPassword(), newFileNameWithPath) { return ErrFileAlreadyPresent } @@ -423,18 +358,8 @@ func (a *API) DownloadFile(podName, podFileWithPath, sessionId string) (io.ReadC return nil, 0, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, 0, ErrPodNotOpen - } - - // check if logged-in to pod - if !ui.GetPod().IsPodOpened(podName) { - return nil, 0, fmt.Errorf("login to pod to do this operation") - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, 0, err } @@ -458,19 +383,14 @@ func (a *API) WriteAtFile(podName, fileNameWithPath, sessionId string, update io return 0, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return 0, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return 0, err } file := podInfo.GetFile() fileNameWithPath = filepath.ToSlash(fileNameWithPath) // check if file exists - if !file.IsFileAlreadyPresent(fileNameWithPath) { + if !file.IsFileAlreadyPresent(podInfo.GetPodPassword(), fileNameWithPath) { return 0, ErrFileNotPresent } @@ -486,18 +406,8 @@ func (a *API) ReadSeekCloser(podName, podFileWithPath, sessionId string) (io.Rea return nil, 0, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, 0, ErrPodNotOpen - } - - // check if logged-in to pod - if !ui.GetPod().IsPodOpened(podName) { - return nil, 0, fmt.Errorf("login to pod to do this operation") - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, 0, err } @@ -520,13 +430,8 @@ func (a *API) ShareFile(podName, podFileWithPath, destinationUser, sessionId str return "", ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return "", ErrPodNotOpen - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return "", err } @@ -548,11 +453,6 @@ func (a *API) ReceiveFile(podName, sessionId string, sharingRef utils.SharingRef return "", ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return "", ErrPodNotOpen - } - return a.users.ReceiveFileFromUser(podName, sharingRef, ui, ui.GetPod(), dir) } @@ -577,18 +477,8 @@ func (a *API) StatusFile(podName, podFileWithPath, sessionId string) (int64, int return 0, 0, 0, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return 0, 0, 0, ErrPodNotOpen - } - - // check if logged-in to pod - if !ui.GetPod().IsPodOpened(podName) { - return 0, 0, 0, fmt.Errorf("login to pod to do this operation") - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return 0, 0, 0, err } @@ -607,18 +497,8 @@ func (a *API) ChmodFile(podName, podFileWithPath, sessionId string, mode uint32) return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - // check if logged-in to pod - if !ui.GetPod().IsPodOpened(podName) { - return fmt.Errorf("login to pod to do this operation") - } - // get podInfo and construct the path - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } diff --git a/pkg/dfs/kv_api.go b/pkg/dfs/kv_api.go index 43e80c38..e1d52760 100644 --- a/pkg/dfs/kv_api.go +++ b/pkg/dfs/kv_api.go @@ -28,12 +28,7 @@ func (a *API) KVCreate(sessionId, podName, name string, indexType collection.Ind return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -49,12 +44,7 @@ func (a *API) KVDelete(sessionId, podName, name string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -70,12 +60,7 @@ func (a *API) KVOpen(sessionId, podName, name string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -91,11 +76,7 @@ func (a *API) KVList(sessionId, podName string) (map[string][]string, error) { return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -111,12 +92,7 @@ func (a *API) KVCount(sessionId, podName, name string) (*collection.TableKeyCoun return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -132,12 +108,7 @@ func (a *API) KVPut(sessionId, podName, name, key string, value []byte) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -153,12 +124,7 @@ func (a *API) KVGet(sessionId, podName, name, key string) ([]string, []byte, err return nil, nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, nil, err } @@ -174,11 +140,7 @@ func (a *API) KVDel(sessionId, podName, name, key string) ([]byte, error) { return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -194,12 +156,7 @@ func (a *API) KVBatch(sessionId, podName, name string, columns []string) (*colle return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -215,11 +172,6 @@ func (a *API) KVBatchPut(sessionId, podName, key string, value []byte, batch *co return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - return batch.Put(key, value, false, false) } @@ -231,11 +183,6 @@ func (a *API) KVBatchWrite(sessionId, podName string, batch *collection.Batch) e return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - _, err := batch.Write("") return err } @@ -248,12 +195,7 @@ func (a *API) KVSeek(sessionId, podName, name, start, end string, limit int64) ( return nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } @@ -269,12 +211,7 @@ func (a *API) KVGetNext(sessionId, podName, name string) ([]string, string, []by return nil, "", nil, ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return nil, "", nil, ErrPodNotOpen - } - - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, "", nil, err } diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index cc9c3236..7fef16dc 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -71,7 +71,7 @@ func (a *API) DeletePod(podName, sessionId string) error { // delete all the directory, files, and database tables under this pod from // the Swarm network. - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return err } @@ -85,11 +85,8 @@ func (a *API) DeletePod(podName, sessionId string) error { return err } - // close the pod if it is open - if ui.IsPodOpen(podName) { - // remove from the login session - ui.RemovePodName(podName) - } + // remove from the login session + ui.RemovePodName(podName) return nil } @@ -104,12 +101,7 @@ func (a *API) DeletePod(podName, sessionId string) error { return err } - // close the pod if it is open - if ui.IsPodOpen(podName) { - // remove from the login session - ui.RemovePodName(podName) - } - + ui.RemovePodName(podName) return nil } @@ -120,55 +112,13 @@ func (a *API) OpenPod(podName, sessionId string) (*pod.Info, error) { if ui == nil { return nil, ErrUserNotLoggedIn } - // return if pod already open - if ui.IsPodOpen(podName) { - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) - if err != nil { - return nil, err - } - return podInfo, nil - } - // open the pod - pi, err := ui.GetPod().OpenPod(podName) - if err != nil { - return nil, err - } - err = pi.GetDirectory().AddRootDir(pi.GetPodName(), pi.GetPodPassword(), pi.GetPodAddress(), pi.GetFeed()) - if err != nil { - return nil, err - } - // Add podName in the login user session - ui.AddPodName(podName, pi) - return pi, nil -} - -// OpenPodAsync -func (a *API) OpenPodAsync(ctx context.Context, podName, sessionId string) (*pod.Info, error) { - // get the logged-in user information - ui := a.users.GetLoggedInUserInfo(sessionId) - if ui == nil { - return nil, ErrUserNotLoggedIn - } - // return if pod already open - if ui.IsPodOpen(podName) { - podInfo, _, err := ui.GetPod().GetPodInfoFromPodMap(podName) - if err != nil { - return nil, err - } - return podInfo, nil - } - // open the pod - pi, err := ui.GetPod().OpenPodAsync(ctx, podName) - if err != nil { - return nil, err - } - err = pi.GetDirectory().AddRootDir(pi.GetPodName(), pi.GetPodPassword(), pi.GetPodAddress(), pi.GetFeed()) + podInfo, _, err := ui.GetPod().GetPodInfo(podName) if err != nil { return nil, err } // Add podName in the login user session - ui.AddPodName(podName, pi) - return pi, nil + ui.AddPodName(podName, podInfo) + return podInfo, nil } // ClosePod @@ -179,11 +129,6 @@ func (a *API) ClosePod(podName, sessionId string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // close the pod err := ui.GetPod().ClosePod(podName) if err != nil { @@ -219,11 +164,6 @@ func (a *API) SyncPod(podName, sessionId string) error { return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // sync the pod err := ui.GetPod().SyncPod(podName) if err != nil { @@ -240,11 +180,6 @@ func (a *API) SyncPodAsync(ctx context.Context, podName, sessionId string) error return ErrUserNotLoggedIn } - // check if pod open - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - // sync the pod err := ui.GetPod().SyncPodAsync(ctx, podName) if err != nil { @@ -505,10 +440,6 @@ func (a *API) ForkPod(podName, forkName, sessionId string) error { return ErrUserNotLoggedIn } - if !ui.IsPodOpen(podName) { - return ErrPodNotOpen - } - if forkName == "" { return pod.ErrBlankPodName } @@ -568,12 +499,6 @@ func (a *API) prepareOwnPod(ui *user.Info, podName string) (*pod.Info, error) { return nil, err } - // create the root directory - err = pi.GetDirectory().MkRootDir(pi.GetPodName(), podPassword, pi.GetPodAddress(), pi.GetFeed()) - if err != nil { - return nil, err - } - return pi, nil } diff --git a/pkg/dir/dir_test.go b/pkg/dir/dir_test.go index 55a324d0..cc99d0ee 100644 --- a/pkg/dir/dir_test.go +++ b/pkg/dir/dir_test.go @@ -62,9 +62,18 @@ func TestDirRmAllFromMap(t *testing.T) { } dirObject.RemoveAllFromDirectoryMap() - node := dirObject.GetDirFromDirectoryMap("/baseDir") + node := dirObject.GetInode(podPassword, "/baseDir") + if node == nil { + t.Fatal("node should not be nil, metadata should be available in blockstore") + } + + err = dirObject.RmDir("/baseDir", podPassword) + if err != nil { + t.Fatal(err) + } + node = dirObject.GetInode(podPassword, "/baseDir") if node != nil { - t.Fatal("node should be nil") + t.Fatal("node should be nil") } }) } diff --git a/pkg/dir/inode.go b/pkg/dir/inode.go index 91e87d5b..5e8b2b92 100644 --- a/pkg/dir/inode.go +++ b/pkg/dir/inode.go @@ -63,3 +63,22 @@ func (in *Inode) Unmarshal(data []byte) error { } return nil } + +func (d *Directory) GetInode(podPassword, dirNameWithPath string) *Inode { + node := d.GetDirFromDirectoryMap(dirNameWithPath) + if node != nil { + return node + } + topic := utils.HashString(dirNameWithPath) + _, data, err := d.fd.GetFeedData(topic, d.getAddress(), []byte(podPassword)) + if err != nil { // skipcq: TCV-001 + return nil + } + var inode Inode + err = inode.Unmarshal(data) + if err != nil { // skipcq: TCV-001 + return nil + } + d.AddToDirectoryMap(dirNameWithPath, &inode) + return &inode +} diff --git a/pkg/dir/rename.go b/pkg/dir/rename.go index 8c5a4e69..0a5a5721 100644 --- a/pkg/dir/rename.go +++ b/pkg/dir/rename.go @@ -36,15 +36,15 @@ func (d *Directory) RenameDir(dirNameWithPath, newDirNameWithPath, podPassword s } // check if directory exists - if d.GetDirFromDirectoryMap(dirNameWithPath) == nil { // skipcq: TCV-001 + if d.GetInode(podPassword, dirNameWithPath) == nil { // skipcq: TCV-001 return ErrDirectoryNotPresent } // check if parent directory exists - if d.GetDirFromDirectoryMap(parentPath) == nil { // skipcq: TCV-001 + if d.GetInode(podPassword, parentPath) == nil { // skipcq: TCV-001 return ErrDirectoryNotPresent } - if d.GetDirFromDirectoryMap(newDirNameWithPath) != nil { + if d.GetInode(podPassword, newDirNameWithPath) != nil { return ErrDirectoryAlreadyPresent } diff --git a/pkg/dir/rmdir.go b/pkg/dir/rmdir.go index 39365774..ecf3cb54 100644 --- a/pkg/dir/rmdir.go +++ b/pkg/dir/rmdir.go @@ -46,11 +46,12 @@ func (d *Directory) RmDir(directoryNameWithPath, podPassword string) error { } else { totalPath = utils.CombinePathAndFile(parentPath, dirToDelete) } - if d.GetDirFromDirectoryMap(totalPath) == nil { + // recursive delete + dirInode := d.GetInode(podPassword, totalPath) + if dirInode == nil { return ErrDirectoryNotPresent } - // recursive delete - dirInode := d.GetDirFromDirectoryMap(totalPath) + if dirInode.FileOrDirNames != nil && len(dirInode.FileOrDirNames) > 0 { for _, fileOrDirName := range dirInode.FileOrDirNames { if strings.HasPrefix(fileOrDirName, "_F_") { diff --git a/pkg/file/chmod.go b/pkg/file/chmod.go index d5169a10..e430931b 100644 --- a/pkg/file/chmod.go +++ b/pkg/file/chmod.go @@ -15,11 +15,11 @@ func (f *File) Chmod(podFileWithPath, podPassword string, mode uint32) error { } // check if file present totalFilePath := utils.CombinePathAndFile(podFileWithPath, "") - if !f.IsFileAlreadyPresent(totalFilePath) { - return ErrFileNotPresent + if !f.IsFileAlreadyPresent(podPassword, totalFilePath) { + return ErrFileNotFound } - meta := f.GetFromFileMap(totalFilePath) + meta := f.GetInode(podPassword, totalFilePath) if meta == nil { // skipcq: TCV-001 return ErrFileNotFound } diff --git a/pkg/file/chmod_test.go b/pkg/file/chmod_test.go index 996f64db..808c2453 100644 --- a/pkg/file/chmod_test.go +++ b/pkg/file/chmod_test.go @@ -53,7 +53,7 @@ func TestChmod(t *testing.T) { assert.Equal(t, fmt.Sprintf("%o", file.S_IFREG|0600), fmt.Sprintf("%o", stats.Mode)) err = fileObject.Chmod("/dir1/file2", podPassword, 0777) - assert.Equal(t, err, file.ErrFileNotPresent) + assert.Equal(t, err, file.ErrFileNotFound) err = fileObject.Chmod("/dir1/file1", podPassword, 0777) require.NoError(t, err) diff --git a/pkg/file/download.go b/pkg/file/download.go index a3ff6d1f..0374e7d4 100644 --- a/pkg/file/download.go +++ b/pkg/file/download.go @@ -26,8 +26,6 @@ import ( ) var ( - // ErrFileNotPresent denotes file is not present - ErrFileNotPresent = errors.New("file not present") // ErrFileAlreadyPresent denotes file is present ErrFileAlreadyPresent = errors.New("file already present in the destination dir") @@ -50,11 +48,11 @@ func (f *File) Download(podFileWithPath, podPassword string) (io.ReadCloser, uin func (f *File) ReadSeeker(podFileWithPath, podPassword string) (io.ReadSeekCloser, uint64, error) { // check if file present totalFilePath := utils.CombinePathAndFile(podFileWithPath, "") - if !f.IsFileAlreadyPresent(totalFilePath) { - return nil, 0, ErrFileNotPresent + if !f.IsFileAlreadyPresent(podPassword, totalFilePath) { + return nil, 0, ErrFileNotFound } - meta := f.GetFromFileMap(totalFilePath) + meta := f.GetInode(podPassword, totalFilePath) if meta == nil { // skipcq: TCV-001 return nil, 0, ErrFileNotFound } diff --git a/pkg/file/download_test.go b/pkg/file/download_test.go index 0f772835..20dc0525 100644 --- a/pkg/file/download_test.go +++ b/pkg/file/download_test.go @@ -65,10 +65,10 @@ func TestDownload(t *testing.T) { // file existent check podFile := utils.CombinePathAndFile(filePath, fileName) - assert.Equal(t, fileObject.IsFileAlreadyPresent(podFile), false) + assert.Equal(t, fileObject.IsFileAlreadyPresent(podPassword, podFile), false) _, _, err = fileObject.Download(podFile, podPassword) - assert.Equal(t, err, file.ErrFileNotPresent) + assert.Equal(t, err, file.ErrFileNotFound) // upload a file content, err := uploadFile(t, fileObject, filePath, fileName, compression, podPassword, fileSize, blockSize) @@ -109,10 +109,10 @@ func TestDownload(t *testing.T) { // file existent check podFile := utils.CombinePathAndFile(filePath, fileName) - assert.Equal(t, fileObject.IsFileAlreadyPresent(podFile), false) + assert.Equal(t, fileObject.IsFileAlreadyPresent(podPassword, podFile), false) _, _, err = fileObject.Download(podFile, podPassword) - assert.Equal(t, err, file.ErrFileNotPresent) + assert.Equal(t, err, file.ErrFileNotFound) // upload a file content, err := uploadFile(t, fileObject, filePath, fileName, compression, podPassword, fileSize, blockSize) @@ -145,10 +145,10 @@ func TestDownload(t *testing.T) { // file existent check podFile := utils.CombinePathAndFile(filePath, fileName) - assert.Equal(t, fileObject.IsFileAlreadyPresent(podFile), false) + assert.Equal(t, fileObject.IsFileAlreadyPresent(podPassword, podFile), false) _, _, err = fileObject.Download(podFile, podPassword) - assert.Equal(t, err, file.ErrFileNotPresent) + assert.Equal(t, err, file.ErrFileNotFound) // upload a file content, err := uploadFile(t, fileObject, filePath, fileName, compression, podPassword, fileSize, blockSize) diff --git a/pkg/file/file.go b/pkg/file/file.go index 6eceff82..99d9d8c6 100644 --- a/pkg/file/file.go +++ b/pkg/file/file.go @@ -88,13 +88,8 @@ func (f *File) GetFromFileMap(filePath string) *MetaData { } // IsFileAlreadyPresent checks if a file is present in the fileMap -func (f *File) IsFileAlreadyPresent(fileWithPath string) bool { - f.fileMu.Lock() - defer f.fileMu.Unlock() - if _, ok := f.fileMap[fileWithPath]; ok { - return true - } - return false +func (f *File) IsFileAlreadyPresent(podPassword, fileWithPath string) bool { + return f.GetInode(podPassword, fileWithPath) != nil } // RemoveAllFromFileMap resets the fileMap @@ -127,6 +122,30 @@ func (f *File) DeleteFromTagMap(filePath string) { // skipcq: TCV-001 f.tagMap.Delete(filePath) } +func (f *File) GetInode(podPassword, filePath string) *MetaData { // skipcq: TCV-001 + meta := f.GetFromFileMap(filePath) + if meta != nil { + return meta + } + topic := utils.HashString(filePath) + _, metaBytes, err := f.fd.GetFeedData(topic, f.userAddress, []byte(podPassword)) + if err != nil { + return nil + } + + if string(metaBytes) == utils.DeletedFeedMagicWord { + return nil + } + + err = json.Unmarshal(metaBytes, &meta) + if err != nil { // skipcq: TCV-001 + return nil + } + + f.AddToFileMap(filePath, meta) + return meta +} + type lsTask struct { f *File topic []byte diff --git a/pkg/file/meta.go b/pkg/file/meta.go index 7a6e2adb..8ed54e9b 100644 --- a/pkg/file/meta.go +++ b/pkg/file/meta.go @@ -103,10 +103,7 @@ func (f *File) deleteMeta(meta *MetaData, podPassword string) error { if err != nil { // skipcq: TCV-001 return err } - err = f.fd.DeleteFeed(topic, f.userAddress) - if err != nil { - f.logger.Warningf("failed to remove file feed %s", totalPath) - } + return nil } @@ -159,13 +156,13 @@ func (f *File) BackupFromFileName(fileNameWithPath, podPassword string) (*MetaDa func (f *File) RenameFromFileName(fileNameWithPath, newFileNameWithPath, podPassword string) (*MetaData, error) { fileNameWithPath = filepath.ToSlash(fileNameWithPath) newFileNameWithPath = filepath.ToSlash(newFileNameWithPath) - p, err := f.GetMetaFromFileName(fileNameWithPath, podPassword, f.userAddress) - if err != nil { - return nil, err + p := f.GetInode(podPassword, fileNameWithPath) + if p == nil { + return nil, ErrFileNotFound } // remove old meta and from file map - err = f.deleteMeta(p, podPassword) + err := f.deleteMeta(p, podPassword) if err != nil { return nil, err } diff --git a/pkg/file/reader.go b/pkg/file/reader.go index 54bca979..30969e4d 100644 --- a/pkg/file/reader.go +++ b/pkg/file/reader.go @@ -20,7 +20,6 @@ import ( "bytes" "encoding/json" "errors" - "fmt" "io" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore" @@ -62,9 +61,9 @@ type Reader struct { // TODO test // skipcq: TCV-001 func (f *File) OpenFileForIndex(podFile, podPassword string) (*Reader, error) { - meta := f.GetFromFileMap(podFile) + meta := f.GetInode(podPassword, podFile) if meta == nil { - return nil, fmt.Errorf("file not found in dfs") + return nil, ErrFileNotFound } encryptedFileInodeBytes, _, err := f.getClient().DownloadBlob(meta.InodeAddress) diff --git a/pkg/file/rename_test.go b/pkg/file/rename_test.go index 275bd31c..93aad583 100644 --- a/pkg/file/rename_test.go +++ b/pkg/file/rename_test.go @@ -50,7 +50,7 @@ func TestRename(t *testing.T) { // file existent check podFile := utils.CombinePathAndFile(filePath, fileName) - if fileObject.IsFileAlreadyPresent(podFile) { + if fileObject.IsFileAlreadyPresent(podPassword, podFile) { t.Fatal("file should not be present") } _, _, err = fileObject.Download(podFile, podPassword) @@ -70,11 +70,16 @@ func TestRename(t *testing.T) { } // Download the file and read from reader - present := fileObject.IsFileAlreadyPresent(podFile) + present := fileObject.IsFileAlreadyPresent(podPassword, podFile) if present { t.Fatal("old name should not be present") } + present = fileObject.IsFileAlreadyPresent(podPassword, newPodFile) + if !present { + t.Fatal("new name should be present") + } + // Download the file and read from reader reader, rcvdSize, err := fileObject.Download(utils.CombinePathAndFile(filePath, newFileName), podPassword) if err != nil { @@ -125,7 +130,7 @@ func TestRename(t *testing.T) { // file existent check podFile := utils.CombinePathAndFile(filePath, fileName) - if fileObject.IsFileAlreadyPresent(podFile) { + if fileObject.IsFileAlreadyPresent(podPassword, podFile) { t.Fatal("file should not be present") } @@ -135,7 +140,7 @@ func TestRename(t *testing.T) { t.Fatal(err) } newPodFile := utils.CombinePathAndFile(newFilePath, fileName) - if fileObject.IsFileAlreadyPresent(newPodFile) { + if fileObject.IsFileAlreadyPresent(podPassword, newPodFile) { t.Fatal("file should not be present") } _, err = fileObject.RenameFromFileName(podFile, newPodFile, podPassword) @@ -144,12 +149,12 @@ func TestRename(t *testing.T) { } // Download the file and read from reader - present := fileObject.IsFileAlreadyPresent(podFile) + present := fileObject.IsFileAlreadyPresent(podPassword, podFile) if present { t.Fatal("old name should not be present") } - present = fileObject.IsFileAlreadyPresent(newPodFile) + present = fileObject.IsFileAlreadyPresent(podPassword, newPodFile) if !present { t.Fatal("new name should be present") } diff --git a/pkg/file/rm.go b/pkg/file/rm.go index 61fa39ad..b10e1e6b 100644 --- a/pkg/file/rm.go +++ b/pkg/file/rm.go @@ -18,7 +18,6 @@ package file import ( "encoding/json" - "errors" "fmt" "net/http" @@ -29,12 +28,9 @@ import ( // RmFile deletes all the blocks of a file, and it related metadata from the Swarm network. func (f *File) RmFile(podFileWithPath, podPassword string) error { totalFilePath := utils.CombinePathAndFile(podFileWithPath, "") - meta, err := f.GetMetaFromFileName(totalFilePath, podPassword, f.userAddress) - if errors.Is(err, ErrDeletedFeed) { // skipcq: TCV-001 - return nil - } - if err != nil { - return err + meta := f.GetInode(podPassword, totalFilePath) + if meta == nil { + return ErrFileNotFound } fileInodeBytes, respCode, err := f.client.DownloadBlob(meta.InodeAddress) if err != nil { // skipcq: TCV-001 diff --git a/pkg/file/rm_test.go b/pkg/file/rm_test.go index fdfc9fe7..aad4cddf 100644 --- a/pkg/file/rm_test.go +++ b/pkg/file/rm_test.go @@ -59,7 +59,7 @@ func TestRemoveFile(t *testing.T) { fileObject := file.NewFile("pod1", mockClient, fd, user, tm, logger) // remove file2 err = fileObject.RmFile("/dir1/file2", podPassword) - require.Equal(t, err.Error(), "feed does not exist or was not updated yet") + require.Equal(t, err.Error(), file.ErrFileNotFound.Error()) file1, _ := utils.GetRandString(12) file2, _ := utils.GetRandString(12) @@ -75,13 +75,13 @@ func TestRemoveFile(t *testing.T) { require.NoError(t, err) // validate file deletion - meta := fileObject.GetFromFileMap(utils.CombinePathAndFile("/dir1", file2)) + meta := fileObject.GetInode(podPassword, utils.CombinePathAndFile("/dir1", file2)) if meta != nil { t.Fatalf("file is not removed") } // check if other file is present - meta = fileObject.GetFromFileMap(utils.CombinePathAndFile("/dir1", file1)) + meta = fileObject.GetInode(podPassword, utils.CombinePathAndFile("/dir1", file1)) if meta == nil { t.Fatalf("file is not present") } @@ -107,7 +107,7 @@ func TestRemoveFile(t *testing.T) { require.NoError(t, err) // validate file deletion - meta := fileObject.GetFromFileMap("/dir1/" + filename) + meta := fileObject.GetInode(podPassword, "/dir1/"+filename) if meta != nil { t.Fatalf("file is not removed") } diff --git a/pkg/file/stat.go b/pkg/file/stat.go index e10af93f..1d5b1f4d 100644 --- a/pkg/file/stat.go +++ b/pkg/file/stat.go @@ -19,7 +19,6 @@ package file import ( "encoding/hex" "encoding/json" - "fmt" "strconv" ) @@ -49,9 +48,9 @@ type Blocks struct { // GetStats given a filename this function returns all the information about the file // including the block information. func (f *File) GetStats(podName, podFileWithPath, podPassword string) (*Stats, error) { - meta := f.GetFromFileMap(podFileWithPath) + meta := f.GetInode(podPassword, podFileWithPath) if meta == nil { // skipcq: TCV-001 - return nil, fmt.Errorf("file not found") + return nil, ErrFileNotFound } fileInodeBytes, _, err := f.getClient().DownloadBlob(meta.InodeAddress) @@ -74,6 +73,7 @@ func (f *File) GetStats(podName, podFileWithPath, podPassword string) (*Stats, e } fileBlocks = append(fileBlocks, fb) } + f.AddToFileMap(podFileWithPath, meta) return &Stats{ PodName: podName, FilePath: meta.Path, diff --git a/pkg/file/status.go b/pkg/file/status.go index af9f6143..706777a1 100644 --- a/pkg/file/status.go +++ b/pkg/file/status.go @@ -8,8 +8,8 @@ import ( func (f *File) Status(podFileWithPath, podPassword string) (int64, int64, int64, error) { // check if file present totalFilePath := utils.CombinePathAndFile(podFileWithPath, "") - if !f.IsFileAlreadyPresent(totalFilePath) { - return 0, 0, 0, ErrFileNotPresent + if !f.IsFileAlreadyPresent(podPassword, totalFilePath) { + return 0, 0, 0, ErrFileNotFound } tag := f.LoadFromTagMap(totalFilePath) diff --git a/pkg/file/upload_test.go b/pkg/file/upload_test.go index 286026ab..549078b0 100644 --- a/pkg/file/upload_test.go +++ b/pkg/file/upload_test.go @@ -72,7 +72,7 @@ func TestUpload(t *testing.T) { } // check for meta - meta := fileObject.GetFromFileMap(utils.CombinePathAndFile(filePath, fileName)) + meta := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filePath, fileName)) if meta == nil { t.Fatalf("file not added in file map") } @@ -124,7 +124,7 @@ func TestUpload(t *testing.T) { } // check for meta - meta := fileObject.GetFromFileMap(utils.CombinePathAndFile(filepath.ToSlash(filePath), fileName)) + meta := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filepath.ToSlash(filePath), fileName)) if meta == nil { t.Fatalf("file not added in file map") } @@ -159,7 +159,7 @@ func TestUpload(t *testing.T) { } // check for meta - meta := fileObject.GetFromFileMap(filepath.ToSlash(utils.CombinePathAndFile(filePath+fileName, ""))) + meta := fileObject.GetInode(podPassword, filepath.ToSlash(utils.CombinePathAndFile(filePath+fileName, ""))) if meta == nil { t.Fatalf("file not added in file map") } @@ -182,7 +182,7 @@ func TestUpload(t *testing.T) { t.Run("upload-small-file-at-root-with-prefix", func(t *testing.T) { podPassword, _ := utils.GetRandString(pod.PasswordLength) filePath := string(os.PathSeparator) - fileName := "file1" + fileName, _ := utils.GetRandString(20) compression := "" fileSize := int64(100) blockSize := uint32(10) @@ -193,7 +193,7 @@ func TestUpload(t *testing.T) { } // check for meta - meta := fileObject.GetFromFileMap(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) + meta := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) if meta == nil { t.Fatalf("file not added in file map") } @@ -212,9 +212,11 @@ func TestUpload(t *testing.T) { t.Fatalf("invalid block size in meta") } - fileObject.RemoveAllFromFileMap() - - meta2 := fileObject.GetFromFileMap(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } + meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -223,7 +225,7 @@ func TestUpload(t *testing.T) { t.Run("upload-small-file-at-root-with-prefix-snappy", func(t *testing.T) { podPassword, _ := utils.GetRandString(pod.PasswordLength) filePath := string(os.PathSeparator) - fileName := "file2" + fileName, _ := utils.GetRandString(20) compression := "snappy" fileSize := int64(100) blockSize := uint32(10) @@ -234,7 +236,7 @@ func TestUpload(t *testing.T) { } // check for meta - meta := fileObject.GetFromFileMap(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) + meta := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) if meta == nil { t.Fatalf("file not added in file map") } @@ -253,9 +255,12 @@ func TestUpload(t *testing.T) { t.Fatalf("invalid block size in meta") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) + meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -264,7 +269,7 @@ func TestUpload(t *testing.T) { t.Run("upload-small-file-at-root-with-prefix-gzip", func(t *testing.T) { podPassword, _ := utils.GetRandString(pod.PasswordLength) filePath := string(os.PathSeparator) - fileName := "file2" + fileName, _ := utils.GetRandString(20) compression := "gzip" fileSize := int64(100) blockSize := uint32(164000) @@ -282,7 +287,7 @@ func TestUpload(t *testing.T) { // check for meta fp := utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)) - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -309,9 +314,12 @@ func TestUpload(t *testing.T) { if err != nil { t.Fatal(err) } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } diff --git a/pkg/file/writeAt.go b/pkg/file/writeAt.go index 2b0ed67f..fc154318 100644 --- a/pkg/file/writeAt.go +++ b/pkg/file/writeAt.go @@ -15,12 +15,12 @@ import ( func (f *File) WriteAt(podFileWithPath, podPassword string, update io.Reader, offset uint64, truncate bool) (int, error) { // check file is present totalFilePath := utils.CombinePathAndFile(podFileWithPath, "") - if !f.IsFileAlreadyPresent(totalFilePath) { - return 0, ErrFileNotPresent + if !f.IsFileAlreadyPresent(podPassword, totalFilePath) { + return 0, ErrFileNotFound } // get file meta - meta := f.GetFromFileMap(totalFilePath) + meta := f.GetInode(podPassword, totalFilePath) if meta == nil { // skipcq: TCV-001 return 0, ErrFileNotFound } diff --git a/pkg/file/writeAt_test.go b/pkg/file/writeAt_test.go index 345039bf..39626176 100644 --- a/pkg/file/writeAt_test.go +++ b/pkg/file/writeAt_test.go @@ -61,7 +61,7 @@ func TestWriteAt(t *testing.T) { rewrite := &bytes.Buffer{} rewrite.Write(update) _, err = fileObject.WriteAt(fp, podPassword, rewrite, offset, false) - if !errors.Is(file.ErrFileNotPresent, err) { + if !errors.Is(file.ErrFileNotFound, err) { t.Fatal("file should not be present") } }) @@ -81,7 +81,7 @@ func TestWriteAt(t *testing.T) { fp := utils.CombinePathAndFile(filepath.ToSlash(filePath+fileName), "") // check for meta - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -156,9 +156,12 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -179,7 +182,7 @@ func TestWriteAt(t *testing.T) { fp := utils.CombinePathAndFile(filepath.ToSlash(filePath+fileName), "") // check for meta - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -279,14 +282,15 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } - - fileObject.RemoveAllFromFileMap() }) t.Run("upload-update-truncate-known-very-small-file", func(t *testing.T) { @@ -304,7 +308,7 @@ func TestWriteAt(t *testing.T) { // check for meta fp := utils.CombinePathAndFile(filepath.ToSlash(filePath+fileName), "") - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -355,9 +359,12 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -377,7 +384,7 @@ func TestWriteAt(t *testing.T) { // check for meta fp := utils.CombinePathAndFile(filepath.ToSlash(filePath), fileName) - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -435,9 +442,12 @@ func TestWriteAt(t *testing.T) { if !bytes.Equal(updatedContent, rcvdBuffer.Bytes()) { t.Fatal("content is different") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -457,7 +467,7 @@ func TestWriteAt(t *testing.T) { // check for meta fp := utils.CombinePathAndFile(filepath.ToSlash(filePath), fileName) - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -511,9 +521,12 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -537,7 +550,7 @@ func TestWriteAt(t *testing.T) { // check for meta fp := utils.CombinePathAndFile(filepath.ToSlash(filePath), fileName) - meta := fileObject.GetFromFileMap(fp) + meta := fileObject.GetInode(podPassword, fp) if meta == nil { t.Fatalf("file not added in file map") } @@ -590,9 +603,12 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different ") } - fileObject.RemoveAllFromFileMap() + err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + if err != nil { + t.Fatal(err) + } - meta2 := fileObject.GetFromFileMap(fp) + meta2 := fileObject.GetInode(podPassword, fp) if meta2 != nil { t.Fatal("meta2 should be nil") } diff --git a/pkg/pod/close.go b/pkg/pod/close.go index 2a9077d1..e341cf25 100644 --- a/pkg/pod/close.go +++ b/pkg/pod/close.go @@ -19,10 +19,6 @@ package pod // ClosePod closed an already opened pod and removes its information from directory and file // data structures. func (p *Pod) ClosePod(podName string) error { - if !p.IsPodOpened(podName) { - return ErrPodNotOpened - } - podInfo, _, err := p.GetPodInfoFromPodMap(podName) if err != nil { // skipcq: TCV-001 return err diff --git a/pkg/pod/del.go b/pkg/pod/del.go index 64824edb..7cbe06fe 100644 --- a/pkg/pod/del.go +++ b/pkg/pod/del.go @@ -40,7 +40,7 @@ func (p *Pod) DeleteOwnPod(podName string) error { } // delete tables - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err != nil { return err } diff --git a/pkg/pod/fork.go b/pkg/pod/fork.go index 002bb0eb..6be12013 100644 --- a/pkg/pod/fork.go +++ b/pkg/pod/fork.go @@ -19,11 +19,7 @@ func (p *Pod) PodFork(podName, forkName string) error { return err } - if !p.IsPodOpened(podName) { - return ErrPodNotOpened - } - - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err != nil { // skipcq: TCV-001 return err } @@ -33,16 +29,16 @@ func (p *Pod) PodFork(podName, forkName string) error { return err } - if !p.IsPodOpened(forkName) { - return ErrPodNotOpened - } - - forkInfo, _, err := p.GetPodInfoFromPodMap(forkName) + forkInfo, _, err := p.GetPodInfo(forkName) if err != nil { // skipcq: TCV-001 return err } - rootInode := podInfo.GetDirectory().GetDirFromDirectoryMap("/") + directory := podInfo.GetDirectory() + rootInode := directory.GetInode(podInfo.GetPodPassword(), "/") + if rootInode == nil { + return fmt.Errorf("root inode not found") + } return cloneFolder(podInfo, forkInfo, "/", rootInode) } @@ -96,11 +92,7 @@ func (p *Pod) forkPod(podInfo *Info, forkName string) error { return err } - if !p.IsPodOpened(forkName) { - return ErrPodNotOpened - } - - forkInfo, _, err := p.GetPodInfoFromPodMap(forkName) + forkInfo, _, err := p.GetPodInfo(forkName) if err != nil { // skipcq: TCV-001 return err } @@ -115,8 +107,7 @@ func cloneFolder(source, dst *Info, dirNameWithPath string, dirInode *d.Inode) e if strings.HasPrefix(fileOrDirName, "_F_") { fileName := strings.TrimPrefix(fileOrDirName, "_F_") filePath := utils.CombinePathAndFile(dirNameWithPath, fileName) - meta := source.GetFile().GetFromFileMap(filePath) - + meta := source.GetFile().GetInode(source.GetPodPassword(), filePath) r, _, err := source.GetFile().Download(filePath, source.GetPodPassword()) if err != nil { // skipcq: TCV-001 return err @@ -134,7 +125,7 @@ func cloneFolder(source, dst *Info, dirNameWithPath string, dirInode *d.Inode) e } else if strings.HasPrefix(fileOrDirName, "_D_") { dirName := strings.TrimPrefix(fileOrDirName, "_D_") path := utils.CombinePathAndFile(dirNameWithPath, dirName) - iNode := source.GetDirectory().GetDirFromDirectoryMap(path) + iNode := source.GetDirectory().GetInode(source.GetPodPassword(), path) err := dst.GetDirectory().MkDir(path, dst.GetPodPassword()) if err != nil { // skipcq: TCV-001 return err diff --git a/pkg/pod/new.go b/pkg/pod/new.go index 1a31cc66..cbc90c83 100644 --- a/pkg/pod/new.go +++ b/pkg/pod/new.go @@ -148,6 +148,13 @@ func (p *Pod) CreatePod(podName, addressString, podPassword string) (*Info, erro docStore: docStore, } p.addPodToPodMap(podName, podInfo) + if addressString == "" { + // create the root directory + err = podInfo.GetDirectory().MkRootDir(podInfo.GetPodName(), podPassword, podInfo.GetPodAddress(), podInfo.GetFeed()) + if err != nil { + return nil, err + } + } return podInfo, nil } diff --git a/pkg/pod/open.go b/pkg/pod/open.go index cefae900..0cec5aef 100644 --- a/pkg/pod/open.go +++ b/pkg/pod/open.go @@ -107,12 +107,13 @@ func (p *Pod) OpenPod(podName string) (*Info, error) { } p.addPodToPodMap(podName, podInfo) - - // sync the pod's files and directories - err = p.SyncPod(podName) - if err != nil && err != d.ErrResourceDeleted { // skipcq: TCV-001 - return nil, err + if !sharedPodType { + err = podInfo.GetDirectory().AddRootDir(podInfo.GetPodName(), podInfo.GetPodPassword(), podInfo.GetPodAddress(), podInfo.GetFeed()) + if err != nil { + return nil, err + } } + return podInfo, nil } diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index e42dabc9..f14c199c 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -114,3 +114,16 @@ func (p *Pod) GetFeed() *feed.API { func (p *Pod) GetAccount() *account.Account { return p.acc } + +// GetPodInfo +func (p *Pod) GetPodInfo(podName string) (*Info, string, error) { + pi, password, _ := p.GetPodInfoFromPodMap(podName) + if pi != nil { + return pi, password, nil + } + pi, err := p.OpenPod(podName) + if err != nil { + return nil, "", err + } + return pi, pi.GetPodPassword(), nil +} diff --git a/pkg/pod/stat.go b/pkg/pod/stat.go index 3d233947..6723b028 100644 --- a/pkg/pod/stat.go +++ b/pkg/pod/stat.go @@ -26,7 +26,7 @@ type Stat struct { // PodStat shows all the pod related information like podname and its current address. func (p *Pod) PodStat(podName string) (*Stat, error) { - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err == nil { return &Stat{ PodName: podInfo.GetPodName(), diff --git a/pkg/pod/sync.go b/pkg/pod/sync.go index c31056d2..5faf45f4 100644 --- a/pkg/pod/sync.go +++ b/pkg/pod/sync.go @@ -29,11 +29,7 @@ func (p *Pod) SyncPod(podName string) error { return err } - if !p.IsPodOpened(podName) { - return ErrPodNotOpened - } - - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err != nil { // skipcq: TCV-001 return err } @@ -54,11 +50,7 @@ func (p *Pod) SyncPodAsync(ctx context.Context, podName string) error { return err } - if !p.IsPodOpened(podName) { - return ErrPodNotOpened - } - - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/pod/utils.go b/pkg/pod/utils.go index 6ea7a61f..ac2d342f 100644 --- a/pkg/pod/utils.go +++ b/pkg/pod/utils.go @@ -24,16 +24,6 @@ import ( "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) -// IsPodOpened checks if a pod is open -func (p *Pod) IsPodOpened(podName string) bool { - p.podMu.Lock() - defer p.podMu.Unlock() - if _, ok := p.podMap[podName]; ok { - return true - } - return false -} - // IsOwnPodPresent checks if a pod is already present for user func (p *Pod) IsOwnPodPresent(podName string) bool { podName, err := CleanPodName(podName) @@ -89,7 +79,7 @@ func (*Pod) GetName(inode *d.Inode) string { // GetAccountInfo returns the pod account info func (p *Pod) GetAccountInfo(podName string) (*account.Info, error) { - podInfo, _, err := p.GetPodInfoFromPodMap(podName) + podInfo, _, err := p.GetPodInfo(podName) if err != nil { return nil, err } diff --git a/pkg/test/close_test.go b/pkg/test/close_test.go index 67bb5e18..7dc36d8c 100644 --- a/pkg/test/close_test.go +++ b/pkg/test/close_test.go @@ -80,23 +80,31 @@ func TestClose(t *testing.T) { if gotPodInfo != nil { t.Fatalf("pod not closed") } - dirObject := info.GetDirectory() - dirInode1 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir1") - if dirInode1 != nil { - t.Fatalf("dir not closed properly") + + gotPodInfo, _, err = pod1.GetPodInfo(podName1) + if err != nil { + t.Fatalf("pod should be open") + } + if gotPodInfo == nil { + t.Fatalf("pod should be open") + } + dirObject := gotPodInfo.GetDirectory() + dirInode1 := dirObject.GetInode(podPassword, "/parentDir/subDir1") + if dirInode1 == nil { + t.Fatalf("dir should nil be nil") } - dirInode2 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir2") - if dirInode2 != nil { - t.Fatalf("dir not closed properly") + dirInode2 := dirObject.GetInode(podPassword, "/parentDir/subDir2") + if dirInode2 == nil { + t.Fatalf("dir should nil be nil") } - fileObject := info.GetFile() - fileMeta1 := fileObject.GetFromFileMap("/parentDir/file1") - if fileMeta1 != nil { - t.Fatalf("file not closed properly") + fileObject := gotPodInfo.GetFile() + fileMeta1 := fileObject.GetInode(podPassword, "/parentDir/file1") + if fileMeta1 == nil { + t.Fatalf("file should nil be nil") } - fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") - if fileMeta2 != nil { - t.Fatalf("file not closed properly") + fileMeta2 := fileObject.GetInode(podPassword, "/parentDir/file2") + if fileMeta2 == nil { + t.Fatalf("file should nil be nil") } }) diff --git a/pkg/test/del_test.go b/pkg/test/del_test.go index 942c8233..731dbfef 100644 --- a/pkg/test/del_test.go +++ b/pkg/test/del_test.go @@ -94,7 +94,7 @@ func TestPodDelete(t *testing.T) { t.Fatalf("delete failed") } - infoGot, _, err := pod1.GetPodInfoFromPodMap(podName1) + infoGot, _, err := pod1.GetPodInfo(podName1) if err == nil { t.Fatalf("pod not deleted from map") } @@ -146,7 +146,7 @@ func TestPodDelete(t *testing.T) { t.Fatalf("delete pod failed") } - infoGot, _, err := pod1.GetPodInfoFromPodMap(podName1) + infoGot, _, err := pod1.GetPodInfo(podName1) if err == nil { t.Fatalf("pod not deleted from map") } @@ -154,7 +154,7 @@ func TestPodDelete(t *testing.T) { t.Fatalf("pod not deleted from map") } - _, _, err = pod1.GetPodInfoFromPodMap(podName2) + _, _, err = pod1.GetPodInfo(podName2) if err != nil { t.Fatalf("removed wrong pod") } diff --git a/pkg/test/fork_test.go b/pkg/test/fork_test.go index 83851368..1b22ab45 100644 --- a/pkg/test/fork_test.go +++ b/pkg/test/fork_test.go @@ -80,22 +80,9 @@ func TestFork(t *testing.T) { t.Fatal(err) } - // open fork pod - pi, err := pod1.OpenPod(forkName) - if err != nil { - t.Fatal(err) - } - - // create the root directory - err = pi.GetDirectory().MkRootDir(pi.GetPodName(), podPassword, pi.GetPodAddress(), pi.GetFeed()) - if err != nil { - t.Fatal(err) - } - err = pod1.PodFork(podName1, forkName) if err != nil { t.Fatal(err) - } // open the pod ths triggers sync too gotInfo, err := pod1.OpenPod(forkName) @@ -105,7 +92,7 @@ func TestFork(t *testing.T) { // validate if the directory and files are synced dirObject := gotInfo.GetDirectory() - dirInode1 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir1") + dirInode1 := dirObject.GetInode(podPassword, "/parentDir/subDir1") if dirInode1 == nil { t.Fatalf("invalid dir entry") } @@ -115,7 +102,7 @@ func TestFork(t *testing.T) { if dirInode1.Meta.Name != "subDir1" { t.Fatalf("invalid dir entry") } - dirInode2 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir2") + dirInode2 := dirObject.GetInode(podPassword, "/parentDir/subDir2") if dirInode2 == nil { t.Fatalf("invalid dir entry") } @@ -127,7 +114,7 @@ func TestFork(t *testing.T) { } fileObject := gotInfo.GetFile() - fileMeta1 := fileObject.GetFromFileMap("/parentDir/file1") + fileMeta1 := fileObject.GetInode(podPassword, "/parentDir/file1") if fileMeta1 == nil { t.Fatalf("invalid file meta") } @@ -143,7 +130,7 @@ func TestFork(t *testing.T) { if fileMeta1.BlockSize != uint32(10) { t.Fatalf("invalid block size") } - fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") + fileMeta2 := fileObject.GetInode(podPassword, "/parentDir/file2") if fileMeta2 == nil { t.Fatalf("invalid file meta") } diff --git a/pkg/test/integration_test.go b/pkg/test/integration_test.go index af6cc997..d571657c 100644 --- a/pkg/test/integration_test.go +++ b/pkg/test/integration_test.go @@ -301,13 +301,11 @@ func TestLiteUser(t *testing.T) { _, err := dfsApi.DirectoryStat(podRequest.PodName, v.path, sessionId) if err != nil { t.Fatal(err) - } } else { _, err := dfsApi.FileStat(podRequest.PodName, v.path, sessionId) if err != nil { - t.Fatal(err) - + t.Fatal(err, v.path) } } } diff --git a/pkg/test/open_test.go b/pkg/test/open_test.go index 8cebcc4e..1202263a 100644 --- a/pkg/test/open_test.go +++ b/pkg/test/open_test.go @@ -91,7 +91,7 @@ func TestOpen(t *testing.T) { if podInfo == nil { t.Fatalf("pod not opened") } - gotPodInfo, _, err := pod1.GetPodInfoFromPodMap(podName1) + gotPodInfo, _, err := pod1.GetPodInfo(podName1) if err != nil { t.Fatalf("pod not opened") } @@ -136,7 +136,7 @@ func TestOpen(t *testing.T) { if podInfo == nil { t.Fatalf("pod not opened") } - gotPodInfo, _, err := pod1.GetPodInfoFromPodMap(podName2) + gotPodInfo, _, err := pod1.GetPodInfo(podName2) if err != nil { t.Fatalf("pod not opened") } diff --git a/pkg/test/pod_new_test.go b/pkg/test/pod_new_test.go index 4fc6abec..8fd7d3f4 100644 --- a/pkg/test/pod_new_test.go +++ b/pkg/test/pod_new_test.go @@ -102,7 +102,7 @@ func TestPodNew(t *testing.T) { t.Fatalf("podName is not %s", podName1) } - infoGot, _, err := pod1.GetPodInfoFromPodMap(podName1) + infoGot, _, err := pod1.GetPodInfo(podName1) if err != nil { t.Fatalf("could not get pod from podMap") } @@ -136,7 +136,7 @@ func TestPodNew(t *testing.T) { t.Fatalf("podName is not %s", podName2) } - infoGot, _, err := pod1.GetPodInfoFromPodMap(podName2) + infoGot, _, err := pod1.GetPodInfo(podName2) if err != nil { t.Fatalf("could not get pod from podMap") } diff --git a/pkg/test/pod_sharing_test.go b/pkg/test/pod_sharing_test.go index d62d118d..0995e91c 100644 --- a/pkg/test/pod_sharing_test.go +++ b/pkg/test/pod_sharing_test.go @@ -497,11 +497,11 @@ func TestShare(t *testing.T) { t.Fatal(err) } dirObject8 := gotSharedPodInfo.GetDirectory() - dirInode1 := dirObject8.GetDirFromDirectoryMap("/parentDir/subDir1") + dirInode1 := dirObject8.GetInode(podPassword, "/parentDir/subDir1") if dirInode1 != nil { t.Fatalf("invalid dir entry") } - dirInode1 = dirObject8.GetDirFromDirectoryMap("/parentDir/newSubDir1") + dirInode1 = dirObject8.GetInode(podPassword, "/parentDir/newSubDir1") if dirInode1 == nil { t.Fatalf("invalid dir entry") } @@ -511,7 +511,7 @@ func TestShare(t *testing.T) { if dirInode1.Meta.Name != "newSubDir1" { t.Fatalf("invalid dir entry") } - dirInode2 := dirObject8.GetDirFromDirectoryMap("/parentDir/subDir2") + dirInode2 := dirObject8.GetInode(podPassword, "/parentDir/subDir2") if dirInode2 == nil { t.Fatalf("invalid dir entry") } @@ -523,11 +523,11 @@ func TestShare(t *testing.T) { } fileObject8 := gotInfo.GetFile() - fileMeta1 := fileObject8.GetFromFileMap("/parentDir/file1") + fileMeta1 := fileObject8.GetInode(podPassword, "/parentDir/file1") if fileMeta1 != nil { t.Fatalf("invalid file meta") } - fileMeta1 = fileObject8.GetFromFileMap("/parentDir/renamedFile1") + fileMeta1 = fileObject8.GetInode(podPassword, "/parentDir/renamedFile1") if fileMeta1 == nil { t.Fatalf("invalid file meta") } @@ -543,7 +543,7 @@ func TestShare(t *testing.T) { if fileMeta1.BlockSize != uint32(10) { t.Fatalf("invalid block size") } - fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") + fileMeta2 := fileObject.GetInode(podPassword, "/parentDir/file2") if fileMeta2 == nil { t.Fatalf("invalid file meta") } diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index 71940abf..10004cc0 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -151,7 +151,7 @@ func TestSubscription(t *testing.T) { } fileObject := pi.GetFile() - fileMeta1 := fileObject.GetFromFileMap("/parentDir/file1") + fileMeta1 := fileObject.GetInode(podPassword, "/parentDir/file1") if fileMeta1 == nil { t.Fatalf("invalid file meta") } @@ -168,7 +168,7 @@ func TestSubscription(t *testing.T) { if fileMeta1.BlockSize != uint32(10) { t.Fatalf("invalid block size") } - fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") + fileMeta2 := fileObject.GetInode(podPassword, "/parentDir/file2") if fileMeta2 == nil { t.Fatalf("invalid file meta") } diff --git a/pkg/test/sync_test.go b/pkg/test/sync_test.go index 48c032ad..75cee66f 100644 --- a/pkg/test/sync_test.go +++ b/pkg/test/sync_test.go @@ -80,7 +80,7 @@ func TestSync(t *testing.T) { // validate if the directory and files are synced dirObject := gotInfo.GetDirectory() - dirInode1 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir1") + dirInode1 := dirObject.GetInode(podPassword, "/parentDir/subDir1") if dirInode1 == nil { t.Fatalf("invalid dir entry") } @@ -90,7 +90,7 @@ func TestSync(t *testing.T) { if dirInode1.Meta.Name != "subDir1" { t.Fatalf("invalid dir entry") } - dirInode2 := dirObject.GetDirFromDirectoryMap("/parentDir/subDir2") + dirInode2 := dirObject.GetInode(podPassword, "/parentDir/subDir2") if dirInode2 == nil { t.Fatalf("invalid dir entry") } @@ -102,7 +102,7 @@ func TestSync(t *testing.T) { } fileObject := gotInfo.GetFile() - fileMeta1 := fileObject.GetFromFileMap("/parentDir/file1") + fileMeta1 := fileObject.GetInode(podPassword, "/parentDir/file1") if fileMeta1 == nil { t.Fatalf("invalid file meta") } @@ -118,7 +118,7 @@ func TestSync(t *testing.T) { if fileMeta1.BlockSize != uint32(10) { t.Fatalf("invalid block size") } - fileMeta2 := fileObject.GetFromFileMap("/parentDir/file2") + fileMeta2 := fileObject.GetInode(podPassword, "/parentDir/file2") if fileMeta2 == nil { t.Fatalf("invalid file meta") } diff --git a/pkg/test/user_sharing_test.go b/pkg/test/user_sharing_test.go index b3b6616e..95b89b79 100644 --- a/pkg/test/user_sharing_test.go +++ b/pkg/test/user_sharing_test.go @@ -197,17 +197,11 @@ func TestSharing(t *testing.T) { if files[0] != "/parentDir2/file1" { t.Fatalf("file not imported") } - if !ui0.IsPodOpen(podName1) { - t.Fatalf("pod should be open") - } // delete source pod err = pod1.DeleteOwnPod(podName1) if err != nil { t.Fatalf("error deleting pod %s", podName1) } ui0.RemovePodName(podName1) - if ui0.IsPodOpen(podName1) { - t.Fatalf("pod should have been deleted") - } }) } diff --git a/pkg/user/info.go b/pkg/user/info.go index 3bec76be..6e550401 100644 --- a/pkg/user/info.go +++ b/pkg/user/info.go @@ -78,16 +78,6 @@ func (i *Info) RemovePodName(podName string) { delete(i.openPods, podName) } -// IsPodOpen checks if users pod is open -func (i *Info) IsPodOpen(podName string) bool { - i.openPodsMu.RLock() - defer i.openPodsMu.RUnlock() - if _, ok := i.openPods[podName]; ok { - return true - } - return false -} - // GetUserDirectory returns user directory handler func (i *Info) GetUserDirectory() *d.Directory { return i.dir diff --git a/pkg/user/sharing.go b/pkg/user/sharing.go index a0826e0e..4e5c62aa 100644 --- a/pkg/user/sharing.go +++ b/pkg/user/sharing.go @@ -130,12 +130,7 @@ func (u *Users) ReceiveFileFromUser(podName string, sharingRef utils.SharingRefe return "", err } - // check if pod is open - if !pd.IsPodOpened(podName) { - return "", pod.ErrPodNotOpened - } - - podInfo, _, err := pd.GetPodInfoFromPodMap(podName) + podInfo, _, err := pd.GetPodInfo(podName) if err != nil { // skipcq: TCV-001 return "", err } @@ -146,7 +141,7 @@ func (u *Users) ReceiveFileFromUser(podName string, sharingRef utils.SharingRefe totalPath := utils.CombinePathAndFile(podDir, fileNameToAdd) // check if file is already present - if file.IsFileAlreadyPresent(totalPath) { + if file.IsFileAlreadyPresent(podInfo.GetPodPassword(), totalPath) { return "", f.ErrFileAlreadyPresent } From 10cff5b409296af9aa1bef32fe36747c5f94749d Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 10 Mar 2023 14:01:12 +0530 Subject: [PATCH 16/48] fix: tests --- pkg/test/close_test.go | 6 ------ pkg/test/open_test.go | 2 +- pkg/test/user_sharing_test.go | 4 ++-- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/pkg/test/close_test.go b/pkg/test/close_test.go index 7dc36d8c..8c64fb4f 100644 --- a/pkg/test/close_test.go +++ b/pkg/test/close_test.go @@ -63,12 +63,6 @@ func TestClose(t *testing.T) { t.Fatalf("error creating pod %s", podName1) } - // make root dir so that other directories can be added - err = info.GetDirectory().MkRootDir("pod1", podPassword, info.GetPodAddress(), info.GetFeed()) - if err != nil { - t.Fatal(err) - } - // create some dir and files addFilesAndDirectories(t, info, pod1, podName1, podPassword) diff --git a/pkg/test/open_test.go b/pkg/test/open_test.go index 1202263a..1d769391 100644 --- a/pkg/test/open_test.go +++ b/pkg/test/open_test.go @@ -235,7 +235,7 @@ func addFilesAndDirectories(t *testing.T, info *pod.Info, pod1 *pod.Pod, podName // close the pod err = pod1.ClosePod(podName1) - if !errors.Is(err, pod.ErrPodNotOpened) { + if err == nil { t.Fatal("pod should not be open") } } diff --git a/pkg/test/user_sharing_test.go b/pkg/test/user_sharing_test.go index 95b89b79..19ea61c0 100644 --- a/pkg/test/user_sharing_test.go +++ b/pkg/test/user_sharing_test.go @@ -165,8 +165,8 @@ func TestSharing(t *testing.T) { } _, err = userObject2.ReceiveFileFromUser("podName2", sharingRef, ui, pod2, "/parentDir2") - if !errors.Is(err, pod.ErrPodNotOpened) { - t.Fatal("pod does not supposed tp be open") + if err == nil { + t.Fatal("pod should not exist") } // receive file From a7aa27692b1eeb6a936117b0311d88aa45ce5991 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 10 Mar 2023 14:55:04 +0530 Subject: [PATCH 17/48] fix: tests --- pkg/file/upload_test.go | 10 +++++----- pkg/file/writeAt_test.go | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/file/upload_test.go b/pkg/file/upload_test.go index 549078b0..a43c8669 100644 --- a/pkg/file/upload_test.go +++ b/pkg/file/upload_test.go @@ -212,11 +212,11 @@ func TestUpload(t *testing.T) { t.Fatalf("invalid block size in meta") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } - meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) + meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -255,12 +255,12 @@ func TestUpload(t *testing.T) { t.Fatalf("invalid block size in meta") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } - meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName)) + meta2 := fileObject.GetInode(podPassword, utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName))) if meta2 != nil { t.Fatal("meta2 should be nil") } @@ -314,7 +314,7 @@ func TestUpload(t *testing.T) { if err != nil { t.Fatal(err) } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } diff --git a/pkg/file/writeAt_test.go b/pkg/file/writeAt_test.go index 39626176..05f3411b 100644 --- a/pkg/file/writeAt_test.go +++ b/pkg/file/writeAt_test.go @@ -156,7 +156,7 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } @@ -282,7 +282,7 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } @@ -359,7 +359,7 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } @@ -442,7 +442,7 @@ func TestWriteAt(t *testing.T) { if !bytes.Equal(updatedContent, rcvdBuffer.Bytes()) { t.Fatal("content is different") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } @@ -521,7 +521,7 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } @@ -603,7 +603,7 @@ func TestWriteAt(t *testing.T) { t.Fatal("content is different ") } - err = fileObject.RmFile(utils.CombinePathAndFile(filePath, string(os.PathSeparator)+fileName), podPassword) + err = fileObject.RmFile(utils.CombinePathAndFile(filepath.ToSlash(filePath), filepath.ToSlash(string(os.PathSeparator)+fileName)), podPassword) if err != nil { t.Fatal(err) } From 5a5071aa3fd8fa77a84920efe2a4267c6c3b91aa Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 13 Mar 2023 08:41:39 +0530 Subject: [PATCH 18/48] minor log changes --- pkg/dfs/api.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/dfs/api.go b/pkg/dfs/api.go index 98752e1b..f4595db1 100644 --- a/pkg/dfs/api.go +++ b/pkg/dfs/api.go @@ -68,6 +68,7 @@ func NewDfsAPI(apiUrl, postageBlockId string, ensConfig *contracts.ENSConfig, su if subConfig != nil { sm, err = rpc.New(subConfig, logger, c, c) if err != nil { + logger.Errorf("subscriptionManager initialisation failed %s", err.Error()) return nil, errSubManager } } From 573e859de46779834abeff6f6f2b605f59ce122e Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 13 Mar 2023 11:29:26 +0530 Subject: [PATCH 19/48] fix: merge --- gomobile/dfs.go | 7 +- pkg/contracts/smail/SwarmMail.go | 601 +++++++++++++++--- pkg/dfs/pod_api.go | 4 +- pkg/pod/subscription.go | 4 +- pkg/subscriptionManager/rpc/manager.go | 29 +- pkg/subscriptionManager/rpc/mock/rpc.go | 2 +- .../subscriptionManager.go | 2 +- pkg/test/subscription_test.go | 2 +- 8 files changed, 538 insertions(+), 113 deletions(-) diff --git a/gomobile/dfs.go b/gomobile/dfs.go index 3afe3520..57cd5200 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -46,12 +46,11 @@ func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) err logger := logging.New(os.Stdout, logrus.Level(logLevel)) var err error var ensConfig *contracts.ENSConfig - var subConfig *contracts.SubscriptionConfig switch network { case "play": - ensConfig, subConfig = contracts.PlayConfig() + ensConfig, _ = contracts.PlayConfig() case "testnet": - ensConfig, subConfig = contracts.TestnetConfig() + ensConfig, _ = contracts.TestnetConfig() case "mainnet": return fmt.Errorf("not supported yet") default: @@ -62,7 +61,7 @@ func Connect(beeEndpoint, postageBlockId, network, rpc string, logLevel int) err beeEndpoint, postageBlockId, ensConfig, - subConfig, + nil, logger, ) return err diff --git a/pkg/contracts/smail/SwarmMail.go b/pkg/contracts/smail/SwarmMail.go index 9d2b9513..6dc33dbb 100644 --- a/pkg/contracts/smail/SwarmMail.go +++ b/pkg/contracts/smail/SwarmMail.go @@ -61,6 +61,7 @@ type SwarmMailSub struct { Bids uint32 Sells uint32 Reports uint32 + DaysValid *big.Int } // SwarmMailSubItem is an auto generated low-level Go binding around an user-defined struct. @@ -80,7 +81,7 @@ type SwarmMailSubRequest struct { // SwarmMailMetaData contains all meta data concerning the SwarmMail contract. var SwarmMailMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getBoxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numInboxItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSentItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256[]\",\"name\":\"subIdxs\",\"type\":\"uint256[]\"}],\"internalType\":\"structSwarmMail.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInbox\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getInboxAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPublicKeys\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"registered\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSent\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSentAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSub\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubItemsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"internalType\":\"structSwarmMail.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"types\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"swarmLocations\",\"type\":\"bytes32[]\"}],\"name\":\"removeEmails\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeInboxEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeSentEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"removeSubItem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"sendEmail\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"signEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"}],\"name\":\"getActiveSubItemsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getBoxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numInboxItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSentItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numLockers\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSharedLockers\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256[]\",\"name\":\"subIdxs\",\"type\":\"uint256[]\"}],\"internalType\":\"structSwarmMail.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInbox\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getInboxAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInboxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getInboxRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getLocker\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getLockerCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getLockerRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPublicKeys\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"registered\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"portable\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSent\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSentAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSharedLocker\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSharedLockerCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSharedLockerRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSub\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"types\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"swarmLocations\",\"type\":\"bytes32[]\"}],\"name\":\"removeEmails\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeInboxEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeLockerEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeSentEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"removeSubItem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"sendEmail\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"withAddress\",\"type\":\"address\"}],\"name\":\"shareLockerWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"signEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"storeLocker\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"withAddress\",\"type\":\"address\"}],\"name\":\"unshareLockerWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", } // SwarmMailABI is the input ABI used to generate the binding from. @@ -384,6 +385,37 @@ func (_SwarmMail *SwarmMailCallerSession) GetActiveBids(addr common.Address) ([] return _SwarmMail.Contract.GetActiveBids(&_SwarmMail.CallOpts, addr) } +// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. +// +// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetActiveSubItemsCount(opts *bind.CallOpts, addr common.Address, start *big.Int) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getActiveSubItemsCount", addr, start) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. +// +// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetActiveSubItemsCount(addr common.Address, start *big.Int) (*big.Int, error) { + return _SwarmMail.Contract.GetActiveSubItemsCount(&_SwarmMail.CallOpts, addr, start) +} + +// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. +// +// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetActiveSubItemsCount(addr common.Address, start *big.Int) (*big.Int, error) { + return _SwarmMail.Contract.GetActiveSubItemsCount(&_SwarmMail.CallOpts, addr, start) +} + // GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. // // Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) @@ -417,23 +449,27 @@ func (_SwarmMail *SwarmMailCallerSession) GetAllSubItems(addr common.Address) ([ // GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. // -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) func (_SwarmMail *SwarmMailCaller) GetBoxCount(opts *bind.CallOpts, addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumLockers *big.Int + NumSharedLockers *big.Int }, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getBoxCount", addr) outstruct := new(struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumLockers *big.Int + NumSharedLockers *big.Int }) if err != nil { return *outstruct, err @@ -444,6 +480,8 @@ func (_SwarmMail *SwarmMailCaller) GetBoxCount(opts *bind.CallOpts, addr common. outstruct.NumSubRequests = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) outstruct.NumSubItems = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) outstruct.NumActiveBids = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.NumLockers = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) + outstruct.NumSharedLockers = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int) return *outstruct, err @@ -451,26 +489,30 @@ func (_SwarmMail *SwarmMailCaller) GetBoxCount(opts *bind.CallOpts, addr common. // GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. // -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) func (_SwarmMail *SwarmMailSession) GetBoxCount(addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumLockers *big.Int + NumSharedLockers *big.Int }, error) { return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) } // GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. // -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids) +// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) func (_SwarmMail *SwarmMailCallerSession) GetBoxCount(addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int + NumInboxItems *big.Int + NumSentItems *big.Int + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumLockers *big.Int + NumSharedLockers *big.Int }, error) { return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) } @@ -599,6 +641,68 @@ func (_SwarmMail *SwarmMailCallerSession) GetInboxAt(addr common.Address, index return _SwarmMail.Contract.GetInboxAt(&_SwarmMail.CallOpts, addr, index) } +// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. +// +// Solidity: function getInboxCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetInboxCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getInboxCount", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. +// +// Solidity: function getInboxCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetInboxCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetInboxCount(&_SwarmMail.CallOpts, addr) +} + +// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. +// +// Solidity: function getInboxCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetInboxCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetInboxCount(&_SwarmMail.CallOpts, addr) +} + +// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. +// +// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetInboxRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getInboxRange", addr, start, length) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. +// +// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetInboxRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInboxRange(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. +// +// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetInboxRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetInboxRange(&_SwarmMail.CallOpts, addr, start, length) +} + // GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. // // Solidity: function getListedSubs(address addr) view returns(bytes32[]) @@ -630,13 +734,138 @@ func (_SwarmMail *SwarmMailCallerSession) GetListedSubs(addr common.Address) ([] return _SwarmMail.Contract.GetListedSubs(&_SwarmMail.CallOpts, addr) } +// GetLocker is a free data retrieval call binding the contract method 0x919884bf. +// +// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetLocker(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getLocker", addr) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetLocker is a free data retrieval call binding the contract method 0x919884bf. +// +// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetLocker(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetLocker(&_SwarmMail.CallOpts, addr) +} + +// GetLocker is a free data retrieval call binding the contract method 0x919884bf. +// +// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetLocker(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetLocker(&_SwarmMail.CallOpts, addr) +} + +// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. +// +// Solidity: function getLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetLockerCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getLockerCount", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. +// +// Solidity: function getLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetLockerCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetLockerCount(&_SwarmMail.CallOpts, addr) +} + +// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. +// +// Solidity: function getLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetLockerCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetLockerCount(&_SwarmMail.CallOpts, addr) +} + +// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. +// +// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetLockerRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getLockerRange", addr, start, length) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. +// +// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetLockerRange(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. +// +// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetLockerRange(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_SwarmMail *SwarmMailCaller) GetPortableAddress(opts *bind.CallOpts, addr common.Address) (common.Address, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getPortableAddress", addr) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_SwarmMail *SwarmMailSession) GetPortableAddress(addr common.Address) (common.Address, error) { + return _SwarmMail.Contract.GetPortableAddress(&_SwarmMail.CallOpts, addr) +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_SwarmMail *SwarmMailCallerSession) GetPortableAddress(addr common.Address) (common.Address, error) { + return _SwarmMail.Contract.GetPortableAddress(&_SwarmMail.CallOpts, addr) +} + // GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. // -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr common.Address) (struct { Registered bool Key [32]byte Smail [32]byte + Portable common.Address }, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getPublicKeys", addr) @@ -645,6 +874,7 @@ func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr commo Registered bool Key [32]byte Smail [32]byte + Portable common.Address }) if err != nil { return *outstruct, err @@ -653,6 +883,7 @@ func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr commo outstruct.Registered = *abi.ConvertType(out[0], new(bool)).(*bool) outstruct.Key = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) outstruct.Smail = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) + outstruct.Portable = *abi.ConvertType(out[3], new(common.Address)).(*common.Address) return *outstruct, err @@ -660,22 +891,24 @@ func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr commo // GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. // -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) func (_SwarmMail *SwarmMailSession) GetPublicKeys(addr common.Address) (struct { Registered bool Key [32]byte Smail [32]byte + Portable common.Address }, error) { return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) } // GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. // -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail) +// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) func (_SwarmMail *SwarmMailCallerSession) GetPublicKeys(addr common.Address) (struct { Registered bool Key [32]byte Smail [32]byte + Portable common.Address }, error) { return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) } @@ -773,9 +1006,102 @@ func (_SwarmMail *SwarmMailCallerSession) GetSentAt(addr common.Address, index * return _SwarmMail.Contract.GetSentAt(&_SwarmMail.CallOpts, addr, index) } +// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. +// +// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetSharedLocker(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSharedLocker", addr) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. +// +// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetSharedLocker(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSharedLocker(&_SwarmMail.CallOpts, addr) +} + +// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. +// +// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSharedLocker(addr common.Address) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSharedLocker(&_SwarmMail.CallOpts, addr) +} + +// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. +// +// Solidity: function getSharedLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCaller) GetSharedLockerCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSharedLockerCount", addr) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. +// +// Solidity: function getSharedLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailSession) GetSharedLockerCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSharedLockerCount(&_SwarmMail.CallOpts, addr) +} + +// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. +// +// Solidity: function getSharedLockerCount(address addr) view returns(uint256) +func (_SwarmMail *SwarmMailCallerSession) GetSharedLockerCount(addr common.Address) (*big.Int, error) { + return _SwarmMail.Contract.GetSharedLockerCount(&_SwarmMail.CallOpts, addr) +} + +// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. +// +// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCaller) GetSharedLockerRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + var out []interface{} + err := _SwarmMail.contract.Call(opts, &out, "getSharedLockerRange", addr, start, length) + + if err != nil { + return *new([]SwarmMailEmail), err + } + + out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) + + return out0, err + +} + +// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. +// +// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailSession) GetSharedLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSharedLockerRange(&_SwarmMail.CallOpts, addr, start, length) +} + +// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. +// +// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) +func (_SwarmMail *SwarmMailCallerSession) GetSharedLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { + return _SwarmMail.Contract.GetSharedLockerRange(&_SwarmMail.CallOpts, addr, start, length) +} + // GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. // -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailCaller) GetSub(opts *bind.CallOpts, index *big.Int) (SwarmMailSub, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getSub", index) @@ -792,21 +1118,21 @@ func (_SwarmMail *SwarmMailCaller) GetSub(opts *bind.CallOpts, index *big.Int) ( // GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. // -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailSession) GetSub(index *big.Int) (SwarmMailSub, error) { return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) } // GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. // -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailCallerSession) GetSub(index *big.Int) (SwarmMailSub, error) { return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) } // GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. // -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailCaller) GetSubBy(opts *bind.CallOpts, subHash [32]byte) (SwarmMailSub, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getSubBy", subHash) @@ -823,14 +1149,14 @@ func (_SwarmMail *SwarmMailCaller) GetSubBy(opts *bind.CallOpts, subHash [32]byt // GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. // -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) } // GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. // -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)) +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) func (_SwarmMail *SwarmMailCallerSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) } @@ -930,66 +1256,49 @@ func (_SwarmMail *SwarmMailCallerSession) GetSubItemBy(addr common.Address, subH // GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. // -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailCaller) GetSubItems(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_SwarmMail *SwarmMailCaller) GetSubItems(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) (struct { + Items []SwarmMailSubItem + Last *big.Int +}, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getSubItems", addr, start, length) + outstruct := new(struct { + Items []SwarmMailSubItem + Last *big.Int + }) if err != nil { - return *new([]SwarmMailSubItem), err + return *outstruct, err } - out0 := *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) + outstruct.Items = *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) + outstruct.Last = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - return out0, err + return *outstruct, err } // GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. // -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_SwarmMail *SwarmMailSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { + Items []SwarmMailSubItem + Last *big.Int +}, error) { return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) } // GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. // -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailSubItem, error) { +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_SwarmMail *SwarmMailCallerSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { + Items []SwarmMailSubItem + Last *big.Int +}, error) { return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) } -// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. -// -// Solidity: function getSubItemsCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetSubItemsCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubItemsCount", addr) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. -// -// Solidity: function getSubItemsCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetSubItemsCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSubItemsCount(&_SwarmMail.CallOpts, addr) -} - -// GetSubItemsCount is a free data retrieval call binding the contract method 0x51b6d3c9. -// -// Solidity: function getSubItemsCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetSubItemsCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSubItemsCount(&_SwarmMail.CallOpts, addr) -} - // GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. // // Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) @@ -1116,7 +1425,7 @@ func (_SwarmMail *SwarmMailCallerSession) GetSubSubscribers(subHash [32]byte) ([ // GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. // -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) func (_SwarmMail *SwarmMailCaller) GetSubs(opts *bind.CallOpts) ([]SwarmMailSub, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "getSubs") @@ -1133,14 +1442,14 @@ func (_SwarmMail *SwarmMailCaller) GetSubs(opts *bind.CallOpts) ([]SwarmMailSub, // GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. // -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) func (_SwarmMail *SwarmMailSession) GetSubs() ([]SwarmMailSub, error) { return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) } // GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. // -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32)[]) +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) func (_SwarmMail *SwarmMailCallerSession) GetSubs() ([]SwarmMailSub, error) { return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) } @@ -1333,7 +1642,7 @@ func (_SwarmMail *SwarmMailCallerSession) SubscriptionIds(arg0 [32]byte) (*big.I // Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. // -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big.Int) (struct { SubHash [32]byte FdpSellerNameHash [32]byte @@ -1345,6 +1654,7 @@ func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big. Bids uint32 Sells uint32 Reports uint32 + DaysValid *big.Int }, error) { var out []interface{} err := _SwarmMail.contract.Call(opts, &out, "subscriptions", arg0) @@ -1360,6 +1670,7 @@ func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big. Bids uint32 Sells uint32 Reports uint32 + DaysValid *big.Int }) if err != nil { return *outstruct, err @@ -1375,6 +1686,7 @@ func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big. outstruct.Bids = *abi.ConvertType(out[7], new(uint32)).(*uint32) outstruct.Sells = *abi.ConvertType(out[8], new(uint32)).(*uint32) outstruct.Reports = *abi.ConvertType(out[9], new(uint32)).(*uint32) + outstruct.DaysValid = *abi.ConvertType(out[10], new(*big.Int)).(**big.Int) return *outstruct, err @@ -1382,7 +1694,7 @@ func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big. // Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. // -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) func (_SwarmMail *SwarmMailSession) Subscriptions(arg0 *big.Int) (struct { SubHash [32]byte FdpSellerNameHash [32]byte @@ -1394,13 +1706,14 @@ func (_SwarmMail *SwarmMailSession) Subscriptions(arg0 *big.Int) (struct { Bids uint32 Sells uint32 Reports uint32 + DaysValid *big.Int }, error) { return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) } // Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. // -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports) +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) func (_SwarmMail *SwarmMailCallerSession) Subscriptions(arg0 *big.Int) (struct { SubHash [32]byte FdpSellerNameHash [32]byte @@ -1412,6 +1725,7 @@ func (_SwarmMail *SwarmMailCallerSession) Subscriptions(arg0 *big.Int) (struct { Bids uint32 Sells uint32 Reports uint32 + DaysValid *big.Int }, error) { return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) } @@ -1531,25 +1845,25 @@ func (_SwarmMail *SwarmMailTransactorSession) GrantRole(role [32]byte, account c return _SwarmMail.Contract.GrantRole(&_SwarmMail.TransactOpts, role, account) } -// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. // -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() -func (_SwarmMail *SwarmMailTransactor) ListSub(opts *bind.TransactOpts, fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "listSub", fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() +func (_SwarmMail *SwarmMailTransactor) ListSub(opts *bind.TransactOpts, fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "listSub", fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) } -// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. // -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() -func (_SwarmMail *SwarmMailSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() +func (_SwarmMail *SwarmMailSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) } -// ListSub is a paid mutator transaction binding the contract method 0x1273b932. +// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. // -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress) +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { + return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) } // Register is a paid mutator transaction binding the contract method 0x2f926732. @@ -1615,6 +1929,27 @@ func (_SwarmMail *SwarmMailTransactorSession) RemoveInboxEmail(swarmLocation [32 return _SwarmMail.Contract.RemoveInboxEmail(&_SwarmMail.TransactOpts, swarmLocation) } +// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. +// +// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactor) RemoveLockerEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "removeLockerEmail", swarmLocation) +} + +// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. +// +// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailSession) RemoveLockerEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveLockerEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + +// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. +// +// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() +func (_SwarmMail *SwarmMailTransactorSession) RemoveLockerEmail(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.RemoveLockerEmail(&_SwarmMail.TransactOpts, swarmLocation) +} + // RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. // // Solidity: function removeSentEmail(bytes32 swarmLocation) returns() @@ -1825,6 +2160,48 @@ func (_SwarmMail *SwarmMailTransactorSession) SetListingFee(newListingFee *big.I return _SwarmMail.Contract.SetListingFee(&_SwarmMail.TransactOpts, newListingFee) } +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_SwarmMail *SwarmMailTransactor) SetPortableAddress(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "setPortableAddress", addr) +} + +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_SwarmMail *SwarmMailSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.SetPortableAddress(&_SwarmMail.TransactOpts, addr) +} + +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_SwarmMail *SwarmMailTransactorSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.SetPortableAddress(&_SwarmMail.TransactOpts, addr) +} + +// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. +// +// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailTransactor) ShareLockerWith(opts *bind.TransactOpts, swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "shareLockerWith", swarmLocation, withAddress) +} + +// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. +// +// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailSession) ShareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.ShareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) +} + +// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. +// +// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailTransactorSession) ShareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.ShareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) +} + // SignEmail is a paid mutator transaction binding the contract method 0x87134952. // // Solidity: function signEmail(bytes32 swarmLocation) returns() @@ -1846,6 +2223,27 @@ func (_SwarmMail *SwarmMailTransactorSession) SignEmail(swarmLocation [32]byte) return _SwarmMail.Contract.SignEmail(&_SwarmMail.TransactOpts, swarmLocation) } +// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. +// +// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailTransactor) StoreLocker(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "storeLocker", swarmLocation) +} + +// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. +// +// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailSession) StoreLocker(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.StoreLocker(&_SwarmMail.TransactOpts, swarmLocation) +} + +// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. +// +// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() +func (_SwarmMail *SwarmMailTransactorSession) StoreLocker(swarmLocation [32]byte) (*types.Transaction, error) { + return _SwarmMail.Contract.StoreLocker(&_SwarmMail.TransactOpts, swarmLocation) +} + // TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() @@ -1867,6 +2265,27 @@ func (_SwarmMail *SwarmMailTransactorSession) TransferOwnership(newOwner common. return _SwarmMail.Contract.TransferOwnership(&_SwarmMail.TransactOpts, newOwner) } +// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. +// +// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailTransactor) UnshareLockerWith(opts *bind.TransactOpts, swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.contract.Transact(opts, "unshareLockerWith", swarmLocation, withAddress) +} + +// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. +// +// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailSession) UnshareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.UnshareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) +} + +// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. +// +// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() +func (_SwarmMail *SwarmMailTransactorSession) UnshareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { + return _SwarmMail.Contract.UnshareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) +} + // Receive is a paid mutator transaction binding the contract receive function. // // Solidity: receive() payable returns() diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 7fef16dc..f5afef17 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -503,7 +503,7 @@ func (a *API) prepareOwnPod(ui *user.Info, podName string) (*pod.Info, error) { } // ListPodInMarketplace -func (a *API) ListPodInMarketplace(podName, title, desc, thumbnail, sessionId string, price uint64, category [32]byte) error { +func (a *API) ListPodInMarketplace(podName, title, desc, thumbnail, sessionId string, price uint64, daysValid uint, category [32]byte) error { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -519,7 +519,7 @@ func (a *API) ListPodInMarketplace(podName, title, desc, thumbnail, sessionId st return err } - return ui.GetPod().ListPodInMarketplace(podName, title, desc, thumbnail, price, category, nameHash) + return ui.GetPod().ListPodInMarketplace(podName, title, desc, thumbnail, price, daysValid, category, nameHash) } // ChangePodListStatusInMarketplace diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index 496a5d1a..67547a9b 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -16,7 +16,7 @@ import ( // ListPodInMarketplace will save the pod info in the subscriptionManager smart contract with its owner and price // we keep the pod info in the smart contract, with a `list` flag -func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, category, nameHash [32]byte) error { +func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte) error { podList, err := p.loadUserPods() if err != nil { // skipcq: TCV-001 return err @@ -32,7 +32,7 @@ func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price podAddress := common.HexToAddress(strAddr) - return p.sm.AddPodToMarketplace(podAddress, common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), podName, title, desc, thumbnail, price, category, nameHash, p.acc.GetUserAccountInfo().GetPrivateKey()) + return p.sm.AddPodToMarketplace(podAddress, common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), podName, title, desc, thumbnail, price, daysValid, category, nameHash, p.acc.GetUserAccountInfo().GetPrivateKey()) } // PodStatusInMarketplace will change the `list` flag for the pod so that it's not listed or gets re listed in the pod marketplace diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 6e76bc2b..9a2cf2e2 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -64,7 +64,7 @@ type ShareInfo struct { UserAddress string `json:"userAddress"` } -func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { +func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { info := &SubscriptionItemInfo{ Category: utils.Encode(category[:]), Description: desc, @@ -75,7 +75,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl Price: fmt.Sprintf("%d", price), Title: title, } - opts, err := c.newTransactor(key, owner) + opts, err := c.newTransactor(key, owner, nil) if err != nil { return err } @@ -91,9 +91,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl var a [32]byte copy(a[:], ref) - i := new(big.Int).SetUint64(price) - - tx, err := c.swarmMail.ListSub(opts, nameHash, a, i, category, podAddress) + tx, err := c.swarmMail.ListSub(opts, nameHash, a, new(big.Int).SetUint64(price), category, podAddress, new(big.Int).SetInt64(int64(daysValid))) if err != nil { return err } @@ -108,7 +106,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl } func (c *Client) HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error { - opts, err := c.newTransactor(key, owner) + opts, err := c.newTransactor(key, owner, nil) if err != nil { return err } @@ -127,7 +125,12 @@ func (c *Client) HidePodFromMarketplace(owner common.Address, subHash [32]byte, } func (c *Client) RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error { - opts, err := c.newTransactor(key, subscriber) + item, err := c.swarmMail.GetSubBy(&bind.CallOpts{}, subHash) + if err != nil { + return err + } + + opts, err := c.newTransactor(key, subscriber, item.Price) if err != nil { return err } @@ -146,7 +149,7 @@ func (c *Client) RequestAccess(subscriber common.Address, subHash, nameHash [32] } func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error { - opts, err := c.newTransactor(key, owner) + opts, err := c.newTransactor(key, owner, nil) if err != nil { return err } @@ -235,7 +238,11 @@ func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo func (c *Client) GetSubscriptions(subscriber common.Address, start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) { opts := &bind.CallOpts{} - return c.swarmMail.GetSubItems(opts, subscriber, new(big.Int).SetUint64(start), new(big.Int).SetUint64(limit)) + itemsStruct, err := c.swarmMail.GetSubItems(opts, subscriber, new(big.Int).SetUint64(start), new(big.Int).SetUint64(limit)) + if err != nil { + return nil, err + } + return itemsStruct.Items, nil } func (c *Client) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { @@ -292,7 +299,7 @@ func New(subConfig *contracts.SubscriptionConfig, logger logging.Logger, getter }, nil } -func (c *Client) newTransactor(key *ecdsa.PrivateKey, account common.Address) (*bind.TransactOpts, error) { +func (c *Client) newTransactor(key *ecdsa.PrivateKey, account common.Address, value *big.Int) (*bind.TransactOpts, error) { nonce, err := c.c.PendingNonceAt(context.Background(), account) if err != nil { return nil, err @@ -310,7 +317,7 @@ func (c *Client) newTransactor(key *ecdsa.PrivateKey, account common.Address) (* return nil, err } opts.Nonce = big.NewInt(int64(nonce)) - opts.Value = big.NewInt(0) + opts.Value = value opts.GasLimit = uint64(1000000) opts.GasPrice = gasPrice opts.From = account diff --git a/pkg/subscriptionManager/rpc/mock/rpc.go b/pkg/subscriptionManager/rpc/mock/rpc.go index 72c0944f..b9dcd18d 100644 --- a/pkg/subscriptionManager/rpc/mock/rpc.go +++ b/pkg/subscriptionManager/rpc/mock/rpc.go @@ -46,7 +46,7 @@ func NewMockSubscriptionManager() *SubscriptionManager { } } -func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { +func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { subHash, err := goens.NameHash(owner.Hex() + podAddress.String()) if err != nil { return err diff --git a/pkg/subscriptionManager/subscriptionManager.go b/pkg/subscriptionManager/subscriptionManager.go index ad8ba809..f78a0794 100644 --- a/pkg/subscriptionManager/subscriptionManager.go +++ b/pkg/subscriptionManager/subscriptionManager.go @@ -11,7 +11,7 @@ import ( ) type SubscriptionManager interface { - AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, category, nameHash [32]byte, key *ecdsa.PrivateKey) error + AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index 10004cc0..f624fbdf 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -66,7 +66,7 @@ func TestSubscription(t *testing.T) { t.Fatal(err) } category := [32]byte{} - err = pod1.ListPodInMarketplace(randomLongPodName1, randomLongPodName1, randomLongPodName1, "", 1, category, nameHash1) + err = pod1.ListPodInMarketplace(randomLongPodName1, randomLongPodName1, randomLongPodName1, "", 1, 10, category, nameHash1) if err != nil { t.Fatal(err) } From b1bb314867555516f42185b76e5e212d2067e10f Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 13 Mar 2023 17:04:58 +0530 Subject: [PATCH 20/48] update according to contract --- pkg/contracts/config.go | 5 ++- pkg/dfs/pod_api.go | 6 ++-- pkg/pod/subscription.go | 4 +-- pkg/subscriptionManager/rpc/manager.go | 12 +++---- pkg/subscriptionManager/rpc/mock/rpc.go | 2 +- .../subscriptionManager.go | 2 +- pkg/test/subscription_test.go | 2 +- wasm/main.go | 31 +++++++++++++------ 8 files changed, 38 insertions(+), 26 deletions(-) diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 05917649..7088a21b 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -34,11 +34,14 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { // PlayConfig defines the configuration for fdp-play func PlayConfig() (*ENSConfig, *SubscriptionConfig) { + s := &SubscriptionConfig{ + SwarmMailAddress: "0x86072CbFF48dA3C1F01824a6761A03F105BCC697", + } return &ENSConfig{ ChainID: "4020", ENSRegistryAddress: "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15", FDSRegistrarAddress: "0xA94B7f0465E98609391C623d0560C5720a3f2D33", PublicResolverAddress: "0xFC628dd79137395F3C9744e33b1c5DE554D94882", ProviderDomain: "fds", - }, nil + }, s } diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index f5afef17..9a7237cb 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -503,7 +503,7 @@ func (a *API) prepareOwnPod(ui *user.Info, podName string) (*pod.Info, error) { } // ListPodInMarketplace -func (a *API) ListPodInMarketplace(podName, title, desc, thumbnail, sessionId string, price uint64, daysValid uint, category [32]byte) error { +func (a *API) ListPodInMarketplace(sessionId, podName, title, desc, thumbnail string, price uint64, daysValid uint, category [32]byte) error { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -637,7 +637,7 @@ type SubscriptionInfo struct { } // GetSubscriptions -func (a *API) GetSubscriptions(sessionId string, start, limit uint64) ([]*SubscriptionInfo, error) { +func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -648,7 +648,7 @@ func (a *API) GetSubscriptions(sessionId string, start, limit uint64) ([]*Subscr return nil, errNilSubManager } - subscriptions, err := ui.GetPod().GetSubscriptions(start, limit) + subscriptions, err := ui.GetPod().GetSubscriptions() if err != nil { return nil, err } diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index 67547a9b..e65f8766 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -102,8 +102,8 @@ func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error { } // GetSubscriptions will query the smart contract and list my subscriptions -func (p *Pod) GetSubscriptions(start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) { - return p.sm.GetSubscriptions(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), start, limit) +func (p *Pod) GetSubscriptions() ([]swarmMail.SwarmMailSubItem, error) { + return p.sm.GetSubscriptions(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) } // GetMarketplace will query the smart contract make the `list` all the pod from the marketplace diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 9a2cf2e2..e5544759 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -26,6 +26,8 @@ const ( additionalConfirmations = 1 transactionReceiptTimeout = time.Minute * 2 transactionReceiptPollingInterval = time.Second * 10 + + listMinFee = 1000000000000000 ) type SubscriptionInfoPutter interface { @@ -75,7 +77,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl Price: fmt.Sprintf("%d", price), Title: title, } - opts, err := c.newTransactor(key, owner, nil) + opts, err := c.newTransactor(key, owner, big.NewInt(listMinFee)) if err != nil { return err } @@ -236,13 +238,9 @@ func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo return info, nil } -func (c *Client) GetSubscriptions(subscriber common.Address, start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) { +func (c *Client) GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) { opts := &bind.CallOpts{} - itemsStruct, err := c.swarmMail.GetSubItems(opts, subscriber, new(big.Int).SetUint64(start), new(big.Int).SetUint64(limit)) - if err != nil { - return nil, err - } - return itemsStruct.Items, nil + return c.swarmMail.GetAllSubItems(opts, subscriber) } func (c *Client) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { diff --git a/pkg/subscriptionManager/rpc/mock/rpc.go b/pkg/subscriptionManager/rpc/mock/rpc.go index b9dcd18d..d893b295 100644 --- a/pkg/subscriptionManager/rpc/mock/rpc.go +++ b/pkg/subscriptionManager/rpc/mock/rpc.go @@ -159,7 +159,7 @@ func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInf return nil } -func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address, _, _ uint64) ([]swarmMail.SwarmMailSubItem, error) { +func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) { s.lock.Lock() defer s.lock.Unlock() diff --git a/pkg/subscriptionManager/subscriptionManager.go b/pkg/subscriptionManager/subscriptionManager.go index f78a0794..5a4bde1c 100644 --- a/pkg/subscriptionManager/subscriptionManager.go +++ b/pkg/subscriptionManager/subscriptionManager.go @@ -16,7 +16,7 @@ type SubscriptionManager interface { RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) - GetSubscriptions(subscriber common.Address, start, limit uint64) ([]swarmMail.SwarmMailSubItem, error) + GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index f624fbdf..5462e1a6 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -109,7 +109,7 @@ func TestSubscription(t *testing.T) { t.Fatal(err) } - subs, err := pod2.GetSubscriptions(0, 10) + subs, err := pod2.GetSubscriptions() if err != nil { t.Fatal(err) } diff --git a/wasm/main.go b/wasm/main.go index 27773a03..f8f37c22 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -141,8 +141,12 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { config, subConfig = contracts.TestnetConfig() } config.ProviderBackend = rpc - subConfig.RPC = subRpc - subConfig.SwarmMailAddress = subContractAddress + if subRpc != "" { + subConfig.RPC = subRpc + } + if subContractAddress != "" { + subConfig.SwarmMailAddress = subContractAddress + } logger := logging.New(os.Stdout, logrus.DebugLevel) go func() { @@ -1953,8 +1957,8 @@ func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { resolve := args[0] reject := args[1] - if len(funcArgs) != 7 { - reject.Invoke("not enough arguments. \"listPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, category)\"") + if len(funcArgs) != 8 { + reject.Invoke("not enough arguments. \"listPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, days, category)\"") return nil } sessionId := funcArgs[0].String() @@ -1963,7 +1967,8 @@ func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { desc := funcArgs[3].String() thumbnail := funcArgs[4].String() priceStr := funcArgs[5].String() - categoryStr := funcArgs[6].String() + daysStr := funcArgs[6].String() + categoryStr := funcArgs[7].String() // convert priceStr to uint64 price, err := strconv.ParseUint(priceStr, 10, 64) @@ -1972,6 +1977,13 @@ func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { return nil } + // convert daysStr to uint64 + days, err := strconv.ParseUint(daysStr, 10, 64) + if err != nil { + reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) + return nil + } + category, err := utils.Decode(categoryStr) if err != nil { reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) @@ -1981,7 +1993,8 @@ func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { var c [32]byte copy(c[:], category) go func() { - err := api.ListPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, c) + fmt.Println("listPodInMarketplace", sessionId, podName, title, desc, thumbnail, price, days, c) + err := api.ListPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, uint(days), c) if err != nil { reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) return @@ -2157,15 +2170,13 @@ func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { reject := args[1] if len(funcArgs) != 3 { - reject.Invoke("not enough arguments. \"getSubscriptions(sessionId, start, limit)\"") + reject.Invoke("not enough arguments. \"getSubscriptions(sessionId)\"") return nil } sessionId := funcArgs[0].String() - start := funcArgs[1].Int() - limit := funcArgs[2].Int() go func() { - subs, err := api.GetSubscriptions(sessionId, uint64(start), uint64(limit)) + subs, err := api.GetSubscriptions(sessionId) if err != nil { reject.Invoke(fmt.Sprintf("getSubscriptions failed : %s", err.Error())) return From f87e4eaaa0f25a8bb0af4a89b9d55b0f15eeabb6 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 14 Mar 2023 10:38:56 +0530 Subject: [PATCH 21/48] usernameLengthSize set to 1 --- pkg/account/account.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/account/account.go b/pkg/account/account.go index f93d96e1..0a95c9d5 100644 --- a/pkg/account/account.go +++ b/pkg/account/account.go @@ -37,8 +37,8 @@ const ( UserAccountIndex = -1 // seedSize is used to determine how much padding we need for portable account SOC - seedSize = 64 - nameSize = 8 + seedSize = 64 + usernameLengthSize = 1 ) // Account is used for keeping authenticated logged-in user info in the session @@ -277,16 +277,16 @@ func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, er // PadSeedName pads the given seed and name with random elements to be a chunk of chunkSize func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { usernameLength := len(username) - endIndexBytes := make([]byte, nameSize) - binary.LittleEndian.PutUint64(endIndexBytes, uint64(usernameLength)) - paddingLength := utils.MaxChunkLength - aes.BlockSize - seedSize - nameSize - usernameLength + usernameLengthBytes := make([]byte, usernameLengthSize) + binary.LittleEndian.PutUint64(usernameLengthBytes, uint64(usernameLength)) + paddingLength := utils.MaxChunkLength - aes.BlockSize - seedSize - usernameLengthSize - usernameLength randomBytes, err := utils.GetRandBytes(paddingLength) if err != nil { // skipcq: TCV-001 return nil, err } chunkData := make([]byte, 0, utils.MaxChunkLength) chunkData = append(chunkData, seed...) - chunkData = append(chunkData, endIndexBytes...) + chunkData = append(chunkData, usernameLengthBytes...) chunkData = append(chunkData, []byte(username)...) chunkData = append(chunkData, randomBytes...) encryptedBytes, err := utils.EncryptBytes([]byte(passphrase), chunkData) @@ -302,6 +302,6 @@ func (*Info) RemovePadFromSeedName(paddedSeed []byte, passphrase string) ([]byte if err != nil { // skipcq: TCV-001 return nil, "", fmt.Errorf("seed decryption failed: %w", err) } - usernameLength := int(binary.LittleEndian.Uint64(decryptedBytes[seedSize : seedSize+nameSize])) - return decryptedBytes[:seedSize], string(decryptedBytes[seedSize+nameSize : seedSize+nameSize+usernameLength]), nil + usernameLength := int(binary.LittleEndian.Uint64(decryptedBytes[seedSize : seedSize+usernameLengthSize])) + return decryptedBytes[:seedSize], string(decryptedBytes[seedSize+usernameLengthSize : seedSize+usernameLengthSize+usernameLength]), nil } From 470a3696889cacff8005e549822ad71aff4583fa Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 14 Mar 2023 11:04:00 +0530 Subject: [PATCH 22/48] fix: #437, tests --- gomobile/dfs.go | 12 +----- pkg/account/account.go | 7 +++- pkg/account/account_test.go | 2 +- pkg/api/file_share.go | 19 +--------- pkg/api/ws.go | 15 ++------ pkg/dfs/fs_api.go | 8 ++-- pkg/test/user_sharing_test.go | 12 ++---- pkg/user/sharing.go | 70 +++++++++-------------------------- wasm/main.go | 14 +------ 9 files changed, 40 insertions(+), 119 deletions(-) diff --git a/gomobile/dfs.go b/gomobile/dfs.go index 57cd5200..6ea61927 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -270,11 +270,7 @@ func FileShare(podName, dirPath, destinationUser string) (string, error) { } func FileReceive(podName, directory, fileSharingReference string) (string, error) { - ref, err := utils.ParseSharingReference(fileSharingReference) - if err != nil { - return "", err - } - filePath, err := api.ReceiveFile(podName, sessionId, ref, directory) + filePath, err := api.ReceiveFile(podName, sessionId, fileSharingReference, directory) if err != nil { return "", err } @@ -285,11 +281,7 @@ func FileReceive(podName, directory, fileSharingReference string) (string, error } func FileReceiveInfo(podName, fileSharingReference string) (string, error) { - ref, err := utils.ParseSharingReference(fileSharingReference) - if err != nil { - return "", err - } - receiveInfo, err := api.ReceiveInfo(sessionId, ref) + receiveInfo, err := api.ReceiveInfo(sessionId, fileSharingReference) if err != nil { return "", err } diff --git a/pkg/account/account.go b/pkg/account/account.go index 0a95c9d5..24895c12 100644 --- a/pkg/account/account.go +++ b/pkg/account/account.go @@ -277,8 +277,11 @@ func (*Info) RemovePadFromSeed(paddedSeed []byte, passphrase string) ([]byte, er // PadSeedName pads the given seed and name with random elements to be a chunk of chunkSize func (*Info) PadSeedName(seed []byte, username string, passphrase string) ([]byte, error) { usernameLength := len(username) + if usernameLength > 255 { + return nil, fmt.Errorf("username length is too long") + } usernameLengthBytes := make([]byte, usernameLengthSize) - binary.LittleEndian.PutUint64(usernameLengthBytes, uint64(usernameLength)) + usernameLengthBytes[0] = byte(usernameLength) paddingLength := utils.MaxChunkLength - aes.BlockSize - seedSize - usernameLengthSize - usernameLength randomBytes, err := utils.GetRandBytes(paddingLength) if err != nil { // skipcq: TCV-001 @@ -302,6 +305,6 @@ func (*Info) RemovePadFromSeedName(paddedSeed []byte, passphrase string) ([]byte if err != nil { // skipcq: TCV-001 return nil, "", fmt.Errorf("seed decryption failed: %w", err) } - usernameLength := int(binary.LittleEndian.Uint64(decryptedBytes[seedSize : seedSize+usernameLengthSize])) + usernameLength := int(decryptedBytes[seedSize]) return decryptedBytes[:seedSize], string(decryptedBytes[seedSize+usernameLengthSize : seedSize+usernameLengthSize+usernameLength]), nil } diff --git a/pkg/account/account_test.go b/pkg/account/account_test.go index 8c33226e..018cf873 100644 --- a/pkg/account/account_test.go +++ b/pkg/account/account_test.go @@ -133,7 +133,7 @@ func TestPadUnpadSeed(t *testing.T) { } func TestPadUnpadSeedName(t *testing.T) { - name := "TestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedNameTestPadUnpadSeedName" + name := "TestPadUnpadSeedName" password := "letmein" logger := logging.New(io.Discard, 0) acc := New(logger) diff --git a/pkg/api/file_share.go b/pkg/api/file_share.go index 25dd96eb..1ff18e76 100644 --- a/pkg/api/file_share.go +++ b/pkg/api/file_share.go @@ -23,7 +23,6 @@ import ( "resenje.org/jsonhttp" "github.com/fairdatasociety/fairOS-dfs/pkg/cookie" - "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) // ReceiveFileResponse represents the response for receiving a file @@ -182,14 +181,7 @@ func (h *Handler) FileReceiveHandler(w http.ResponseWriter, r *http.Request) { return } - sharingRef, err := utils.ParseSharingReference(sharingRefString) - if err != nil { - h.logger.Errorf("file receive: invalid reference: ", err) - jsonhttp.BadRequest(w, &response{Message: "file receive: invalid reference:" + err.Error()}) - return - } - - filePath, err := h.dfsAPI.ReceiveFile(podName, sessionId, sharingRef, dir) + filePath, err := h.dfsAPI.ReceiveFile(podName, sessionId, sharingRefString, dir) if err != nil { h.logger.Errorf("file receive: %v", err) jsonhttp.InternalServerError(w, &response{Message: "file receive: " + err.Error()}) @@ -242,14 +234,7 @@ func (h *Handler) FileReceiveInfoHandler(w http.ResponseWriter, r *http.Request) return } - sharingRef, err := utils.ParseSharingReference(sharingRefString) - if err != nil { - h.logger.Errorf("file receive info: invalid reference: ", err) - jsonhttp.BadRequest(w, &response{Message: "file receive info: invalid reference:" + err.Error()}) - return - } - - receiveInfo, err := h.dfsAPI.ReceiveInfo(sessionId, sharingRef) + receiveInfo, err := h.dfsAPI.ReceiveInfo(sessionId, sharingRefString) if err != nil { h.logger.Errorf("file receive info: %v", err) jsonhttp.InternalServerError(w, &response{Message: "file receive info: " + err.Error()}) diff --git a/pkg/api/ws.go b/pkg/api/ws.go index 56567ffc..aa87ab52 100644 --- a/pkg/api/ws.go +++ b/pkg/api/ws.go @@ -1138,12 +1138,8 @@ func (h *Handler) handleEvents(conn *websocket.Conn) error { respondWithError(res, err) continue } - sharingRef, err := utils.ParseSharingReference(fsReq.SharingReference) - if err != nil { - respondWithError(res, err) - continue - } - filePath, err := h.dfsAPI.ReceiveFile(fsReq.PodName, fsReq.DirectoryPath, sharingRef, sessionID) + + filePath, err := h.dfsAPI.ReceiveFile(fsReq.PodName, fsReq.DirectoryPath, fsReq.SharingReference, sessionID) if err != nil { respondWithError(res, err) continue @@ -1175,12 +1171,7 @@ func (h *Handler) handleEvents(conn *websocket.Conn) error { respondWithError(res, err) continue } - sharingRef, err := utils.ParseSharingReference(fsReq.SharingReference) - if err != nil { - respondWithError(res, err) - continue - } - receiveInfo, err := h.dfsAPI.ReceiveInfo(sessionID, sharingRef) + receiveInfo, err := h.dfsAPI.ReceiveInfo(sessionID, fsReq.SharingReference) if err != nil { respondWithError(res, err) continue diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 3e397fb9..d8af50a8 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -446,26 +446,26 @@ func (a *API) ShareFile(podName, podFileWithPath, destinationUser, sessionId str // ReceiveFile is a controller function which validates if the user is logged-in, // pod is open and calls the ReceiveFile function to get the shared file in to the // given pod. -func (a *API) ReceiveFile(podName, sessionId string, sharingRef utils.SharingReference, dir string) (string, error) { +func (a *API) ReceiveFile(podName, sessionId, ref string, dir string) (string, error) { // get the logged-in user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { return "", ErrUserNotLoggedIn } - return a.users.ReceiveFileFromUser(podName, sharingRef, ui, ui.GetPod(), dir) + return a.users.ReceiveFileFromUser(podName, ref, ui, ui.GetPod(), dir) } // ReceiveInfo is a controller function which validates if the user is logged-in, // calls the ReceiveInfo function to display the shared file's information. -func (a *API) ReceiveInfo(sessionId string, sharingRef utils.SharingReference) (*user.ReceiveFileInfo, error) { +func (a *API) ReceiveInfo(sessionId, ref string) (*user.ReceiveFileInfo, error) { // get the logged-in user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { return nil, ErrUserNotLoggedIn } - return a.users.ReceiveFileInfo(sharingRef) + return a.users.ReceiveFileInfo(ref) } // StatusFile is a controller function which validates if the user is logged-in, diff --git a/pkg/test/user_sharing_test.go b/pkg/test/user_sharing_test.go index 19ea61c0..6e3b9ef0 100644 --- a/pkg/test/user_sharing_test.go +++ b/pkg/test/user_sharing_test.go @@ -141,11 +141,7 @@ func TestSharing(t *testing.T) { } // receive file info - sharingRef, err := utils.ParseSharingReference(sharingRefString) - if err != nil { - t.Fatal(err) - } - receiveFileInfo, err := userObject2.ReceiveFileInfo(sharingRef) + receiveFileInfo, err := userObject2.ReceiveFileInfo(sharingRefString) if err != nil { t.Fatal(err) } @@ -164,18 +160,18 @@ func TestSharing(t *testing.T) { t.Fatalf("invalid block size received") } - _, err = userObject2.ReceiveFileFromUser("podName2", sharingRef, ui, pod2, "/parentDir2") + _, err = userObject2.ReceiveFileFromUser("podName2", sharingRefString, ui, pod2, "/parentDir2") if err == nil { t.Fatal("pod should not exist") } // receive file - destinationFilePath, err := userObject2.ReceiveFileFromUser(podName2, sharingRef, ui, pod2, "/parentDir2") + destinationFilePath, err := userObject2.ReceiveFileFromUser(podName2, sharingRefString, ui, pod2, "/parentDir2") if err != nil { t.Fatal(err) } - _, err = userObject2.ReceiveFileFromUser(podName2, sharingRef, ui, pod2, "/parentDir2") + _, err = userObject2.ReceiveFileFromUser(podName2, sharingRefString, ui, pod2, "/parentDir2") if !errors.Is(err, file.ErrFileAlreadyPresent) { t.Fatal("pod does not supposed tp be open") } diff --git a/pkg/user/sharing.go b/pkg/user/sharing.go index 4e5c62aa..3357d57f 100644 --- a/pkg/user/sharing.go +++ b/pkg/user/sharing.go @@ -17,13 +17,12 @@ limitations under the License. package user import ( + "encoding/hex" "encoding/json" "net/http" "strconv" "time" - "github.com/btcsuite/btcd/btcec" - "github.com/fairdatasociety/fairOS-dfs/pkg/account" f "github.com/fairdatasociety/fairOS-dfs/pkg/file" "github.com/fairdatasociety/fairOS-dfs/pkg/pod" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -89,43 +88,30 @@ func (u *Users) ShareFileWithUser(podName, podPassword, podFileWithPath, destina return "", err } - // encrypt data - encryptedData, err := encryptData(data, now.Unix()) - if err != nil { // skipcq: TCV-001 - return "", err - } - // upload the encrypted data and get the reference - ref, err := u.client.UploadBlob(encryptedData, 0, true) + ref, err := u.client.UploadBlob(data, 0, true) if err != nil { // skipcq: TCV-001 return "", err } - // add now to the ref - sharingRef := utils.NewSharingReference(ref, now.Unix()) - return sharingRef.String(), nil + return hex.EncodeToString(ref), nil } // ReceiveFileFromUser imports an exported file in to the current user and pod by reading the sharing file entry. -func (u *Users) ReceiveFileFromUser(podName string, sharingRef utils.SharingReference, userInfo *Info, pd *pod.Pod, podDir string) (string, error) { - metaRef := sharingRef.GetRef() - unixTime := sharingRef.GetNonce() - +func (u *Users) ReceiveFileFromUser(podName string, ref string, userInfo *Info, pd *pod.Pod, podDir string) (string, error) { + refBytes, err := hex.DecodeString(ref) + if err != nil { + return "", err + } // get the encrypted meta - encryptedData, respCode, err := u.client.DownloadBlob(metaRef) + data, respCode, err := u.client.DownloadBlob(refBytes) if err != nil || respCode != http.StatusOK { return "", err } // skipcq: TCV-001 - // decrypt the data - decryptedData, err := decryptData(encryptedData, unixTime) - if err != nil { // skipcq: TCV-001 - return "", err - } - // unmarshall the entry sharingEntry := SharingEntry{} - err = json.Unmarshal(decryptedData, &sharingEntry) + err = json.Unmarshal(data, &sharingEntry) if err != nil { // skipcq: TCV-001 return "", err } @@ -174,45 +160,23 @@ func (u *Users) ReceiveFileFromUser(podName string, sharingRef utils.SharingRefe return totalPath, nil } -func encryptData(data []byte, now int64) ([]byte, error) { - pk, err := account.CreateRandomKeyPair(now) - if err != nil { // skipcq: TCV-001 - return nil, err - } - pubKey := btcec.PublicKey{Curve: pk.PublicKey.Curve, X: pk.PublicKey.X, Y: pk.PublicKey.Y} - return btcec.Encrypt(&pubKey, data) -} - -func decryptData(data []byte, now int64) ([]byte, error) { - pk, err := account.CreateRandomKeyPair(now) - if err != nil { // skipcq: TCV-001 - return nil, err - } - privateKey := btcec.PrivateKey{PublicKey: pk.PublicKey, D: pk.D} - return btcec.Decrypt(&privateKey, data) -} - // ReceiveFileInfo displays the information of the exported file. This is used to decide whether // to import the file or not. -func (u *Users) ReceiveFileInfo(sharingRef utils.SharingReference) (*ReceiveFileInfo, error) { - metaRef := sharingRef.GetRef() - unixTime := sharingRef.GetNonce() - - // get the encrypted meta - encryptedData, respCode, err := u.client.DownloadBlob(metaRef) - if err != nil || respCode != http.StatusOK { // skipcq: TCV-001 +func (u *Users) ReceiveFileInfo(ref string) (*ReceiveFileInfo, error) { + refBytes, err := hex.DecodeString(ref) + if err != nil { return nil, err } - // decrypt the data - decryptedData, err := decryptData(encryptedData, unixTime) - if err != nil { // skipcq: TCV-001 + // get the encrypted meta + data, respCode, err := u.client.DownloadBlob(refBytes) + if err != nil || respCode != http.StatusOK { // skipcq: TCV-001 return nil, err } // unmarshall the entry sharingEntry := SharingEntry{} - err = json.Unmarshal(decryptedData, &sharingEntry) + err = json.Unmarshal(data, &sharingEntry) if err != nil { // skipcq: TCV-001 return nil, err } diff --git a/wasm/main.go b/wasm/main.go index f8f37c22..9bdf0421 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -1030,12 +1030,7 @@ func fileReceive(_ js.Value, funcArgs []js.Value) interface{} { fileSharingReference := funcArgs[3].String() go func() { - ref, err := utils.ParseSharingReference(fileSharingReference) - if err != nil { - reject.Invoke(fmt.Sprintf("fileReceive failed : %s", err.Error())) - return - } - filePath, err := api.ReceiveFile(podName, sessionId, ref, directory) + filePath, err := api.ReceiveFile(podName, sessionId, fileSharingReference, directory) if err != nil { reject.Invoke(fmt.Sprintf("fileReceive failed : %s", err.Error())) return @@ -1065,12 +1060,7 @@ func fileReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { fileSharingReference := funcArgs[2].String() go func() { - ref, err := utils.ParseSharingReference(fileSharingReference) - if err != nil { - reject.Invoke(fmt.Sprintf("fileReceiveInfo failed : %s", err.Error())) - return - } - receiveInfo, err := api.ReceiveInfo(sessionId, ref) + receiveInfo, err := api.ReceiveInfo(sessionId, fileSharingReference) if err != nil { reject.Invoke(fmt.Sprintf("fileReceiveInfo failed : %s", err.Error())) return From decf481dc52e6221b51088bbef96975c0a498313 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 14 Mar 2023 11:22:45 +0530 Subject: [PATCH 23/48] remove transactional functions from wasm --- pkg/file/file.go | 2 +- wasm/main.go | 178 ----------------------------------------------- 2 files changed, 1 insertion(+), 179 deletions(-) diff --git a/pkg/file/file.go b/pkg/file/file.go index 99d9d8c6..520ff9b1 100644 --- a/pkg/file/file.go +++ b/pkg/file/file.go @@ -93,7 +93,7 @@ func (f *File) IsFileAlreadyPresent(podPassword, fileWithPath string) bool { } // RemoveAllFromFileMap resets the fileMap -func (f *File) RemoveAllFromFileMap() { +func (f *File) RemoveAllFromFileMap() { // skipcq: TCV-001 f.fileMu.Lock() defer f.fileMu.Unlock() f.fileMap = make(map[string]*MetaData) diff --git a/wasm/main.go b/wasm/main.go index 9bdf0421..044cf866 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -10,7 +10,6 @@ import ( "fmt" "io" "os" - "strconv" "strings" "syscall/js" @@ -61,10 +60,6 @@ func registerWasmFunctions() { js.Global().Set("podReceive", js.FuncOf(podReceive)) js.Global().Set("podReceiveInfo", js.FuncOf(podReceiveInfo)) - js.Global().Set("listPodInMarketplace", js.FuncOf(listPodInMarketplace)) - js.Global().Set("changePodListStatusInMarketplace", js.FuncOf(changePodListStatusInMarketplace)) - js.Global().Set("requestSubscription", js.FuncOf(requestSubscription)) - js.Global().Set("approveSubscription", js.FuncOf(approveSubscription)) js.Global().Set("getSubscriptions", js.FuncOf(getSubscriptions)) js.Global().Set("openSubscribedPod", js.FuncOf(openSubscribedPod)) js.Global().Set("getSubscribablePods", js.FuncOf(getSubscribablePods)) @@ -1942,179 +1937,6 @@ func docIndexJson(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } -func listPodInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { - handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resolve := args[0] - reject := args[1] - - if len(funcArgs) != 8 { - reject.Invoke("not enough arguments. \"listPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, days, category)\"") - return nil - } - sessionId := funcArgs[0].String() - podName := funcArgs[1].String() - title := funcArgs[2].String() - desc := funcArgs[3].String() - thumbnail := funcArgs[4].String() - priceStr := funcArgs[5].String() - daysStr := funcArgs[6].String() - categoryStr := funcArgs[7].String() - - // convert priceStr to uint64 - price, err := strconv.ParseUint(priceStr, 10, 64) - if err != nil { - reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) - return nil - } - - // convert daysStr to uint64 - days, err := strconv.ParseUint(daysStr, 10, 64) - if err != nil { - reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) - return nil - } - - category, err := utils.Decode(categoryStr) - if err != nil { - reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) - return nil - } - - var c [32]byte - copy(c[:], category) - go func() { - fmt.Println("listPodInMarketplace", sessionId, podName, title, desc, thumbnail, price, days, c) - err := api.ListPodInMarketplace(sessionId, podName, title, desc, thumbnail, price, uint(days), c) - if err != nil { - reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) - return - } - resolve.Invoke("pod listed") - }() - return nil - }) - - promiseConstructor := js.Global().Get("Promise") - return promiseConstructor.New(handler) -} - -func changePodListStatusInMarketplace(_ js.Value, funcArgs []js.Value) interface{} { - handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resolve := args[0] - reject := args[1] - - if len(funcArgs) != 3 { - reject.Invoke("not enough arguments. \"changePodListStatusInMarketplace(sessionId, subHash, show)\"") - return nil - } - sessionId := funcArgs[0].String() - subHashStr := funcArgs[1].String() - show := funcArgs[2].Bool() - - subHash, err := utils.Decode(subHashStr) - if err != nil { - reject.Invoke(fmt.Sprintf("changePodListStatusInMarketplace failed : %s", err.Error())) - return nil - } - - var s [32]byte - copy(s[:], subHash) - go func() { - err := api.ChangePodListStatusInMarketplace(sessionId, s, show) - if err != nil { - reject.Invoke(fmt.Sprintf("listPodInMarketplace failed : %s", err.Error())) - return - } - resolve.Invoke("pod list status changed successfully") - }() - return nil - }) - - promiseConstructor := js.Global().Get("Promise") - return promiseConstructor.New(handler) -} - -func requestSubscription(_ js.Value, funcArgs []js.Value) interface{} { - handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resolve := args[0] - reject := args[1] - - if len(funcArgs) != 2 { - reject.Invoke("not enough arguments. \"requestSubscription(sessionId, subHash)\"") - return nil - } - sessionId := funcArgs[0].String() - subHashStr := funcArgs[1].String() - - subHash, err := utils.Decode(subHashStr) - if err != nil { - reject.Invoke(fmt.Sprintf("requestSubscription failed : %s", err.Error())) - return nil - } - - var s [32]byte - copy(s[:], subHash) - go func() { - err := api.RequestSubscription(sessionId, s) - if err != nil { - reject.Invoke(fmt.Sprintf("requestSubscription failed : %s", err.Error())) - return - } - resolve.Invoke("request submitted successfully") - }() - return nil - }) - - promiseConstructor := js.Global().Get("Promise") - return promiseConstructor.New(handler) -} - -func approveSubscription(_ js.Value, funcArgs []js.Value) interface{} { - handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { - resolve := args[0] - reject := args[1] - - if len(funcArgs) != 4 { - reject.Invoke("not enough arguments. \"approveSubscription(sessionId, podName, reqHash, subscriberNameHash)\"") - return nil - } - sessionId := funcArgs[0].String() - podName := funcArgs[1].String() - reqHashStr := funcArgs[2].String() - subscriberNameHashStr := funcArgs[3].String() - - reqHash, err := utils.Decode(reqHashStr) - if err != nil { - reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) - return nil - } - - var r [32]byte - copy(r[:], reqHash) - - nameHash, err := utils.Decode(subscriberNameHashStr) - if err != nil { - reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) - return nil - } - - var nh [32]byte - copy(nh[:], nameHash) - go func() { - err := api.ApproveSubscription(sessionId, podName, r, nh) - if err != nil { - reject.Invoke(fmt.Sprintf("approveSubscription failed : %s", err.Error())) - return - } - resolve.Invoke("request approved successfully") - }() - return nil - }) - - promiseConstructor := js.Global().Get("Promise") - return promiseConstructor.New(handler) -} - func encryptSubscription(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] From 9b9f6488cbadd412f0509774dc91bc371e6c7e87 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 15 Mar 2023 11:51:53 +0530 Subject: [PATCH 24/48] datahub contract added --- pkg/contracts/config.go | 8 +- pkg/contracts/datahub/Datahub.go | 2306 +++++++++++++ pkg/contracts/smail/SwarmMail.go | 2947 ----------------- pkg/dfs/pod_api.go | 12 +- pkg/pod/subscription.go | 10 +- pkg/subscriptionManager/rpc/manager.go | 65 +- pkg/subscriptionManager/rpc/mock/rpc.go | 47 +- .../subscriptionManager.go | 18 +- 8 files changed, 2382 insertions(+), 3031 deletions(-) create mode 100644 pkg/contracts/datahub/Datahub.go delete mode 100644 pkg/contracts/smail/SwarmMail.go diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 7088a21b..ebcec1fc 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -12,8 +12,8 @@ type ENSConfig struct { // SubscriptionConfig handles the Subscription Management type SubscriptionConfig struct { - RPC string - SwarmMailAddress string + RPC string + DataHubAddress string } // TestnetConfig defines the configuration for goerli testnet @@ -27,7 +27,7 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { } s := &SubscriptionConfig{ - SwarmMailAddress: "0x7Aedf45B82924B2dBF9818c7cAaB6c7557Ba09c0", + DataHubAddress: "0x43E6403948be1245f8878fE0f429798762A5d3b8", } return e, s } @@ -35,7 +35,7 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { // PlayConfig defines the configuration for fdp-play func PlayConfig() (*ENSConfig, *SubscriptionConfig) { s := &SubscriptionConfig{ - SwarmMailAddress: "0x86072CbFF48dA3C1F01824a6761A03F105BCC697", + DataHubAddress: "0x86072CbFF48dA3C1F01824a6761A03F105BCC697", } return &ENSConfig{ ChainID: "4020", diff --git a/pkg/contracts/datahub/Datahub.go b/pkg/contracts/datahub/Datahub.go new file mode 100644 index 00000000..a0fdf7e8 --- /dev/null +++ b/pkg/contracts/datahub/Datahub.go @@ -0,0 +1,2306 @@ +// Code generated - DO NOT EDIT. +// This file is a generated binding and any manual changes will be lost. + +package datahub + +import ( + "errors" + "math/big" + "strings" + + ethereum "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/event" +) + +// Reference imports to suppress errors if they are not otherwise used. +var ( + _ = errors.New + _ = big.NewInt + _ = strings.NewReader + _ = ethereum.NotFound + _ = bind.Bind + _ = common.Big1 + _ = types.BloomLookup + _ = event.NewSubscription +) + +// DataHubActiveBid is an auto generated low-level Go binding around an user-defined struct. +type DataHubActiveBid struct { + Seller common.Address + RequestHash [32]byte +} + +// DataHubCategory is an auto generated low-level Go binding around an user-defined struct. +type DataHubCategory struct { + SubIdxs []uint64 +} + +// DataHubSub is an auto generated low-level Go binding around an user-defined struct. +type DataHubSub struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + DaysValid uint16 +} + +// DataHubSubItem is an auto generated low-level Go binding around an user-defined struct. +type DataHubSubItem struct { + SubHash [32]byte + UnlockKeyLocation [32]byte + ValidTill *big.Int +} + +// DataHubSubRequest is an auto generated low-level Go binding around an user-defined struct. +type DataHubSubRequest struct { + FdpBuyerNameHash [32]byte + Buyer common.Address + SubHash [32]byte + RequestHash [32]byte +} + +// DatahubMetaData contains all meta data concerning the Datahub contract. +var DatahubMetaData = &bind.MetaData{ + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROLE_REPORTER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64[]\",\"name\":\"subIdxs\",\"type\":\"uint64[]\"}],\"internalType\":\"structDataHub.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubByIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getUserStats\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numListedSubs\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"release\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"reportSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", +} + +// DatahubABI is the input ABI used to generate the binding from. +// Deprecated: Use DatahubMetaData.ABI instead. +var DatahubABI = DatahubMetaData.ABI + +// Datahub is an auto generated Go binding around an Ethereum contract. +type Datahub struct { + DatahubCaller // Read-only binding to the contract + DatahubTransactor // Write-only binding to the contract + DatahubFilterer // Log filterer for contract events +} + +// DatahubCaller is an auto generated read-only Go binding around an Ethereum contract. +type DatahubCaller struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DatahubTransactor is an auto generated write-only Go binding around an Ethereum contract. +type DatahubTransactor struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DatahubFilterer is an auto generated log filtering Go binding around an Ethereum contract events. +type DatahubFilterer struct { + contract *bind.BoundContract // Generic contract wrapper for the low level calls +} + +// DatahubSession is an auto generated Go binding around an Ethereum contract, +// with pre-set call and transact options. +type DatahubSession struct { + Contract *Datahub // Generic contract binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DatahubCallerSession is an auto generated read-only Go binding around an Ethereum contract, +// with pre-set call options. +type DatahubCallerSession struct { + Contract *DatahubCaller // Generic contract caller binding to set the session for + CallOpts bind.CallOpts // Call options to use throughout this session +} + +// DatahubTransactorSession is an auto generated write-only Go binding around an Ethereum contract, +// with pre-set transact options. +type DatahubTransactorSession struct { + Contract *DatahubTransactor // Generic contract transactor binding to set the session for + TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session +} + +// DatahubRaw is an auto generated low-level Go binding around an Ethereum contract. +type DatahubRaw struct { + Contract *Datahub // Generic contract binding to access the raw methods on +} + +// DatahubCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. +type DatahubCallerRaw struct { + Contract *DatahubCaller // Generic read-only contract binding to access the raw methods on +} + +// DatahubTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. +type DatahubTransactorRaw struct { + Contract *DatahubTransactor // Generic write-only contract binding to access the raw methods on +} + +// NewDatahub creates a new instance of Datahub, bound to a specific deployed contract. +func NewDatahub(address common.Address, backend bind.ContractBackend) (*Datahub, error) { + contract, err := bindDatahub(address, backend, backend, backend) + if err != nil { + return nil, err + } + return &Datahub{DatahubCaller: DatahubCaller{contract: contract}, DatahubTransactor: DatahubTransactor{contract: contract}, DatahubFilterer: DatahubFilterer{contract: contract}}, nil +} + +// NewDatahubCaller creates a new read-only instance of Datahub, bound to a specific deployed contract. +func NewDatahubCaller(address common.Address, caller bind.ContractCaller) (*DatahubCaller, error) { + contract, err := bindDatahub(address, caller, nil, nil) + if err != nil { + return nil, err + } + return &DatahubCaller{contract: contract}, nil +} + +// NewDatahubTransactor creates a new write-only instance of Datahub, bound to a specific deployed contract. +func NewDatahubTransactor(address common.Address, transactor bind.ContractTransactor) (*DatahubTransactor, error) { + contract, err := bindDatahub(address, nil, transactor, nil) + if err != nil { + return nil, err + } + return &DatahubTransactor{contract: contract}, nil +} + +// NewDatahubFilterer creates a new log filterer instance of Datahub, bound to a specific deployed contract. +func NewDatahubFilterer(address common.Address, filterer bind.ContractFilterer) (*DatahubFilterer, error) { + contract, err := bindDatahub(address, nil, nil, filterer) + if err != nil { + return nil, err + } + return &DatahubFilterer{contract: contract}, nil +} + +// bindDatahub binds a generic wrapper to an already deployed contract. +func bindDatahub(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { + parsed, err := abi.JSON(strings.NewReader(DatahubABI)) + if err != nil { + return nil, err + } + return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Datahub *DatahubRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Datahub.Contract.DatahubCaller.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Datahub *DatahubRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Datahub.Contract.DatahubTransactor.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Datahub *DatahubRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Datahub.Contract.DatahubTransactor.contract.Transact(opts, method, params...) +} + +// Call invokes the (constant) contract method with params as input values and +// sets the output to result. The result type might be a single field for simple +// returns, a slice of interfaces for anonymous returns and a struct for named +// returns. +func (_Datahub *DatahubCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { + return _Datahub.Contract.contract.Call(opts, result, method, params...) +} + +// Transfer initiates a plain transaction to move funds to the contract, calling +// its default method if one is available. +func (_Datahub *DatahubTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Datahub.Contract.contract.Transfer(opts) +} + +// Transact invokes the (paid) contract method with params as input values. +func (_Datahub *DatahubTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { + return _Datahub.Contract.contract.Transact(opts, method, params...) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Datahub *DatahubCaller) DEFAULTADMINROLE(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "DEFAULT_ADMIN_ROLE") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Datahub *DatahubSession) DEFAULTADMINROLE() ([32]byte, error) { + return _Datahub.Contract.DEFAULTADMINROLE(&_Datahub.CallOpts) +} + +// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. +// +// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) +func (_Datahub *DatahubCallerSession) DEFAULTADMINROLE() ([32]byte, error) { + return _Datahub.Contract.DEFAULTADMINROLE(&_Datahub.CallOpts) +} + +// ROLEREPORTER is a free data retrieval call binding the contract method 0x83102c2b. +// +// Solidity: function ROLE_REPORTER() view returns(bytes32) +func (_Datahub *DatahubCaller) ROLEREPORTER(opts *bind.CallOpts) ([32]byte, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "ROLE_REPORTER") + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// ROLEREPORTER is a free data retrieval call binding the contract method 0x83102c2b. +// +// Solidity: function ROLE_REPORTER() view returns(bytes32) +func (_Datahub *DatahubSession) ROLEREPORTER() ([32]byte, error) { + return _Datahub.Contract.ROLEREPORTER(&_Datahub.CallOpts) +} + +// ROLEREPORTER is a free data retrieval call binding the contract method 0x83102c2b. +// +// Solidity: function ROLE_REPORTER() view returns(bytes32) +func (_Datahub *DatahubCallerSession) ROLEREPORTER() ([32]byte, error) { + return _Datahub.Contract.ROLEREPORTER(&_Datahub.CallOpts) +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_Datahub *DatahubCaller) FeesCollected(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "feesCollected") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_Datahub *DatahubSession) FeesCollected() (*big.Int, error) { + return _Datahub.Contract.FeesCollected(&_Datahub.CallOpts) +} + +// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. +// +// Solidity: function feesCollected() view returns(uint256) +func (_Datahub *DatahubCallerSession) FeesCollected() (*big.Int, error) { + return _Datahub.Contract.FeesCollected(&_Datahub.CallOpts) +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_Datahub *DatahubCaller) FundsBalance(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "fundsBalance") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_Datahub *DatahubSession) FundsBalance() (*big.Int, error) { + return _Datahub.Contract.FundsBalance(&_Datahub.CallOpts) +} + +// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. +// +// Solidity: function fundsBalance() view returns(uint256) +func (_Datahub *DatahubCallerSession) FundsBalance() (*big.Int, error) { + return _Datahub.Contract.FundsBalance(&_Datahub.CallOpts) +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_Datahub *DatahubCaller) GetActiveBidAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (DataHubActiveBid, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getActiveBidAt", addr, index) + + if err != nil { + return *new(DataHubActiveBid), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubActiveBid)).(*DataHubActiveBid) + + return out0, err + +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_Datahub *DatahubSession) GetActiveBidAt(addr common.Address, index *big.Int) (DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBidAt(&_Datahub.CallOpts, addr, index) +} + +// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. +// +// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) +func (_Datahub *DatahubCallerSession) GetActiveBidAt(addr common.Address, index *big.Int) (DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBidAt(&_Datahub.CallOpts, addr, index) +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_Datahub *DatahubCaller) GetActiveBids(opts *bind.CallOpts, addr common.Address) ([]DataHubActiveBid, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getActiveBids", addr) + + if err != nil { + return *new([]DataHubActiveBid), err + } + + out0 := *abi.ConvertType(out[0], new([]DataHubActiveBid)).(*[]DataHubActiveBid) + + return out0, err + +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_Datahub *DatahubSession) GetActiveBids(addr common.Address) ([]DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBids(&_Datahub.CallOpts, addr) +} + +// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. +// +// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) +func (_Datahub *DatahubCallerSession) GetActiveBids(addr common.Address) ([]DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBids(&_Datahub.CallOpts, addr) +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubCaller) GetAllSubItems(opts *bind.CallOpts, addr common.Address) ([]DataHubSubItem, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getAllSubItems", addr) + + if err != nil { + return *new([]DataHubSubItem), err + } + + out0 := *abi.ConvertType(out[0], new([]DataHubSubItem)).(*[]DataHubSubItem) + + return out0, err + +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubSession) GetAllSubItems(addr common.Address) ([]DataHubSubItem, error) { + return _Datahub.Contract.GetAllSubItems(&_Datahub.CallOpts, addr) +} + +// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. +// +// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubCallerSession) GetAllSubItems(addr common.Address) ([]DataHubSubItem, error) { + return _Datahub.Contract.GetAllSubItems(&_Datahub.CallOpts, addr) +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint64[])) +func (_Datahub *DatahubCaller) GetCategory(opts *bind.CallOpts, category [32]byte) (DataHubCategory, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getCategory", category) + + if err != nil { + return *new(DataHubCategory), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubCategory)).(*DataHubCategory) + + return out0, err + +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint64[])) +func (_Datahub *DatahubSession) GetCategory(category [32]byte) (DataHubCategory, error) { + return _Datahub.Contract.GetCategory(&_Datahub.CallOpts, category) +} + +// GetCategory is a free data retrieval call binding the contract method 0x473b084c. +// +// Solidity: function getCategory(bytes32 category) view returns((uint64[])) +func (_Datahub *DatahubCallerSession) GetCategory(category [32]byte) (DataHubCategory, error) { + return _Datahub.Contract.GetCategory(&_Datahub.CallOpts, category) +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_Datahub *DatahubCaller) GetFee(opts *bind.CallOpts, _fee *big.Int, amount *big.Int) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getFee", _fee, amount) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_Datahub *DatahubSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { + return _Datahub.Contract.GetFee(&_Datahub.CallOpts, _fee, amount) +} + +// GetFee is a free data retrieval call binding the contract method 0xd250185c. +// +// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) +func (_Datahub *DatahubCallerSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { + return _Datahub.Contract.GetFee(&_Datahub.CallOpts, _fee, amount) +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_Datahub *DatahubCaller) GetListedSubs(opts *bind.CallOpts, addr common.Address) ([][32]byte, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getListedSubs", addr) + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_Datahub *DatahubSession) GetListedSubs(addr common.Address) ([][32]byte, error) { + return _Datahub.Contract.GetListedSubs(&_Datahub.CallOpts, addr) +} + +// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. +// +// Solidity: function getListedSubs(address addr) view returns(bytes32[]) +func (_Datahub *DatahubCallerSession) GetListedSubs(addr common.Address) ([][32]byte, error) { + return _Datahub.Contract.GetListedSubs(&_Datahub.CallOpts, addr) +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_Datahub *DatahubCaller) GetPortableAddress(opts *bind.CallOpts, addr common.Address) (common.Address, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getPortableAddress", addr) + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_Datahub *DatahubSession) GetPortableAddress(addr common.Address) (common.Address, error) { + return _Datahub.Contract.GetPortableAddress(&_Datahub.CallOpts, addr) +} + +// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. +// +// Solidity: function getPortableAddress(address addr) view returns(address) +func (_Datahub *DatahubCallerSession) GetPortableAddress(addr common.Address) (common.Address, error) { + return _Datahub.Contract.GetPortableAddress(&_Datahub.CallOpts, addr) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Datahub *DatahubCaller) GetRoleAdmin(opts *bind.CallOpts, role [32]byte) ([32]byte, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getRoleAdmin", role) + + if err != nil { + return *new([32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + + return out0, err + +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Datahub *DatahubSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _Datahub.Contract.GetRoleAdmin(&_Datahub.CallOpts, role) +} + +// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. +// +// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) +func (_Datahub *DatahubCallerSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { + return _Datahub.Contract.GetRoleAdmin(&_Datahub.CallOpts, role) +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubCaller) GetSubBy(opts *bind.CallOpts, subHash [32]byte) (DataHubSub, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubBy", subHash) + + if err != nil { + return *new(DataHubSub), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSub)).(*DataHubSub) + + return out0, err + +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubSession) GetSubBy(subHash [32]byte) (DataHubSub, error) { + return _Datahub.Contract.GetSubBy(&_Datahub.CallOpts, subHash) +} + +// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. +// +// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubCallerSession) GetSubBy(subHash [32]byte) (DataHubSub, error) { + return _Datahub.Contract.GetSubBy(&_Datahub.CallOpts, subHash) +} + +// GetSubByIndex is a free data retrieval call binding the contract method 0xeed5b6e5. +// +// Solidity: function getSubByIndex(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubCaller) GetSubByIndex(opts *bind.CallOpts, index *big.Int) (DataHubSub, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubByIndex", index) + + if err != nil { + return *new(DataHubSub), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSub)).(*DataHubSub) + + return out0, err + +} + +// GetSubByIndex is a free data retrieval call binding the contract method 0xeed5b6e5. +// +// Solidity: function getSubByIndex(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubSession) GetSubByIndex(index *big.Int) (DataHubSub, error) { + return _Datahub.Contract.GetSubByIndex(&_Datahub.CallOpts, index) +} + +// GetSubByIndex is a free data retrieval call binding the contract method 0xeed5b6e5. +// +// Solidity: function getSubByIndex(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)) +func (_Datahub *DatahubCallerSession) GetSubByIndex(index *big.Int) (DataHubSub, error) { + return _Datahub.Contract.GetSubByIndex(&_Datahub.CallOpts, index) +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_Datahub *DatahubCaller) GetSubInfoBalance(opts *bind.CallOpts, subHash [32]byte, forAddress common.Address) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubInfoBalance", subHash, forAddress) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_Datahub *DatahubSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { + return _Datahub.Contract.GetSubInfoBalance(&_Datahub.CallOpts, subHash, forAddress) +} + +// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. +// +// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) +func (_Datahub *DatahubCallerSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { + return _Datahub.Contract.GetSubInfoBalance(&_Datahub.CallOpts, subHash, forAddress) +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubCaller) GetSubItemAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (DataHubSubItem, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubItemAt", addr, index) + + if err != nil { + return *new(DataHubSubItem), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSubItem)).(*DataHubSubItem) + + return out0, err + +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubSession) GetSubItemAt(addr common.Address, index *big.Int) (DataHubSubItem, error) { + return _Datahub.Contract.GetSubItemAt(&_Datahub.CallOpts, addr, index) +} + +// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. +// +// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubCallerSession) GetSubItemAt(addr common.Address, index *big.Int) (DataHubSubItem, error) { + return _Datahub.Contract.GetSubItemAt(&_Datahub.CallOpts, addr, index) +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubCaller) GetSubItemBy(opts *bind.CallOpts, addr common.Address, subHash [32]byte) (DataHubSubItem, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubItemBy", addr, subHash) + + if err != nil { + return *new(DataHubSubItem), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSubItem)).(*DataHubSubItem) + + return out0, err + +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubSession) GetSubItemBy(addr common.Address, subHash [32]byte) (DataHubSubItem, error) { + return _Datahub.Contract.GetSubItemBy(&_Datahub.CallOpts, addr, subHash) +} + +// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. +// +// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) +func (_Datahub *DatahubCallerSession) GetSubItemBy(addr common.Address, subHash [32]byte) (DataHubSubItem, error) { + return _Datahub.Contract.GetSubItemBy(&_Datahub.CallOpts, addr, subHash) +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_Datahub *DatahubCaller) GetSubItems(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) (struct { + Items []DataHubSubItem + Last *big.Int +}, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubItems", addr, start, length) + + outstruct := new(struct { + Items []DataHubSubItem + Last *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.Items = *abi.ConvertType(out[0], new([]DataHubSubItem)).(*[]DataHubSubItem) + outstruct.Last = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_Datahub *DatahubSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { + Items []DataHubSubItem + Last *big.Int +}, error) { + return _Datahub.Contract.GetSubItems(&_Datahub.CallOpts, addr, start, length) +} + +// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. +// +// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) +func (_Datahub *DatahubCallerSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { + Items []DataHubSubItem + Last *big.Int +}, error) { + return _Datahub.Contract.GetSubItems(&_Datahub.CallOpts, addr, start, length) +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubCaller) GetSubRequestAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (DataHubSubRequest, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubRequestAt", addr, index) + + if err != nil { + return *new(DataHubSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSubRequest)).(*DataHubSubRequest) + + return out0, err + +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubSession) GetSubRequestAt(addr common.Address, index *big.Int) (DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequestAt(&_Datahub.CallOpts, addr, index) +} + +// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. +// +// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubCallerSession) GetSubRequestAt(addr common.Address, index *big.Int) (DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequestAt(&_Datahub.CallOpts, addr, index) +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubCaller) GetSubRequestByHash(opts *bind.CallOpts, addr common.Address, requestHash [32]byte) (DataHubSubRequest, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubRequestByHash", addr, requestHash) + + if err != nil { + return *new(DataHubSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubSubRequest)).(*DataHubSubRequest) + + return out0, err + +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequestByHash(&_Datahub.CallOpts, addr, requestHash) +} + +// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. +// +// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) +func (_Datahub *DatahubCallerSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequestByHash(&_Datahub.CallOpts, addr, requestHash) +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_Datahub *DatahubCaller) GetSubRequests(opts *bind.CallOpts, addr common.Address) ([]DataHubSubRequest, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubRequests", addr) + + if err != nil { + return *new([]DataHubSubRequest), err + } + + out0 := *abi.ConvertType(out[0], new([]DataHubSubRequest)).(*[]DataHubSubRequest) + + return out0, err + +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_Datahub *DatahubSession) GetSubRequests(addr common.Address) ([]DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequests(&_Datahub.CallOpts, addr) +} + +// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. +// +// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) +func (_Datahub *DatahubCallerSession) GetSubRequests(addr common.Address) ([]DataHubSubRequest, error) { + return _Datahub.Contract.GetSubRequests(&_Datahub.CallOpts, addr) +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_Datahub *DatahubCaller) GetSubSubscribers(opts *bind.CallOpts, subHash [32]byte) ([]common.Address, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubSubscribers", subHash) + + if err != nil { + return *new([]common.Address), err + } + + out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) + + return out0, err + +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_Datahub *DatahubSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { + return _Datahub.Contract.GetSubSubscribers(&_Datahub.CallOpts, subHash) +} + +// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. +// +// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) +func (_Datahub *DatahubCallerSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { + return _Datahub.Contract.GetSubSubscribers(&_Datahub.CallOpts, subHash) +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)[]) +func (_Datahub *DatahubCaller) GetSubs(opts *bind.CallOpts) ([]DataHubSub, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getSubs") + + if err != nil { + return *new([]DataHubSub), err + } + + out0 := *abi.ConvertType(out[0], new([]DataHubSub)).(*[]DataHubSub) + + return out0, err + +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)[]) +func (_Datahub *DatahubSession) GetSubs() ([]DataHubSub, error) { + return _Datahub.Contract.GetSubs(&_Datahub.CallOpts) +} + +// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. +// +// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint16)[]) +func (_Datahub *DatahubCallerSession) GetSubs() ([]DataHubSub, error) { + return _Datahub.Contract.GetSubs(&_Datahub.CallOpts) +} + +// GetUserStats is a free data retrieval call binding the contract method 0x4e43603a. +// +// Solidity: function getUserStats(address addr) view returns(uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numListedSubs) +func (_Datahub *DatahubCaller) GetUserStats(opts *bind.CallOpts, addr common.Address) (struct { + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumListedSubs *big.Int +}, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getUserStats", addr) + + outstruct := new(struct { + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumListedSubs *big.Int + }) + if err != nil { + return *outstruct, err + } + + outstruct.NumSubRequests = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + outstruct.NumSubItems = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.NumActiveBids = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) + outstruct.NumListedSubs = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) + + return *outstruct, err + +} + +// GetUserStats is a free data retrieval call binding the contract method 0x4e43603a. +// +// Solidity: function getUserStats(address addr) view returns(uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numListedSubs) +func (_Datahub *DatahubSession) GetUserStats(addr common.Address) (struct { + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumListedSubs *big.Int +}, error) { + return _Datahub.Contract.GetUserStats(&_Datahub.CallOpts, addr) +} + +// GetUserStats is a free data retrieval call binding the contract method 0x4e43603a. +// +// Solidity: function getUserStats(address addr) view returns(uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numListedSubs) +func (_Datahub *DatahubCallerSession) GetUserStats(addr common.Address) (struct { + NumSubRequests *big.Int + NumSubItems *big.Int + NumActiveBids *big.Int + NumListedSubs *big.Int +}, error) { + return _Datahub.Contract.GetUserStats(&_Datahub.CallOpts, addr) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Datahub *DatahubCaller) HasRole(opts *bind.CallOpts, role [32]byte, account common.Address) (bool, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "hasRole", role, account) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Datahub *DatahubSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _Datahub.Contract.HasRole(&_Datahub.CallOpts, role, account) +} + +// HasRole is a free data retrieval call binding the contract method 0x91d14854. +// +// Solidity: function hasRole(bytes32 role, address account) view returns(bool) +func (_Datahub *DatahubCallerSession) HasRole(role [32]byte, account common.Address) (bool, error) { + return _Datahub.Contract.HasRole(&_Datahub.CallOpts, role, account) +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_Datahub *DatahubCaller) InEscrow(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "inEscrow") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_Datahub *DatahubSession) InEscrow() (*big.Int, error) { + return _Datahub.Contract.InEscrow(&_Datahub.CallOpts) +} + +// InEscrow is a free data retrieval call binding the contract method 0xb7391341. +// +// Solidity: function inEscrow() view returns(uint256) +func (_Datahub *DatahubCallerSession) InEscrow() (*big.Int, error) { + return _Datahub.Contract.InEscrow(&_Datahub.CallOpts) +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_Datahub *DatahubCaller) MarketFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "marketFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_Datahub *DatahubSession) MarketFee() (*big.Int, error) { + return _Datahub.Contract.MarketFee(&_Datahub.CallOpts) +} + +// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. +// +// Solidity: function marketFee() view returns(uint256) +func (_Datahub *DatahubCallerSession) MarketFee() (*big.Int, error) { + return _Datahub.Contract.MarketFee(&_Datahub.CallOpts) +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_Datahub *DatahubCaller) MinListingFee(opts *bind.CallOpts) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "minListingFee") + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_Datahub *DatahubSession) MinListingFee() (*big.Int, error) { + return _Datahub.Contract.MinListingFee(&_Datahub.CallOpts) +} + +// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. +// +// Solidity: function minListingFee() view returns(uint256) +func (_Datahub *DatahubCallerSession) MinListingFee() (*big.Int, error) { + return _Datahub.Contract.MinListingFee(&_Datahub.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Datahub *DatahubCaller) Owner(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "owner") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Datahub *DatahubSession) Owner() (common.Address, error) { + return _Datahub.Contract.Owner(&_Datahub.CallOpts) +} + +// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// +// Solidity: function owner() view returns(address) +func (_Datahub *DatahubCallerSession) Owner() (common.Address, error) { + return _Datahub.Contract.Owner(&_Datahub.CallOpts) +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_Datahub *DatahubCaller) SubscriptionIds(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "subscriptionIds", arg0) + + if err != nil { + return *new(*big.Int), err + } + + out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + + return out0, err + +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_Datahub *DatahubSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { + return _Datahub.Contract.SubscriptionIds(&_Datahub.CallOpts, arg0) +} + +// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. +// +// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) +func (_Datahub *DatahubCallerSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { + return _Datahub.Contract.SubscriptionIds(&_Datahub.CallOpts, arg0) +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint16 daysValid) +func (_Datahub *DatahubCaller) Subscriptions(opts *bind.CallOpts, arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + DaysValid uint16 +}, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "subscriptions", arg0) + + outstruct := new(struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + DaysValid uint16 + }) + if err != nil { + return *outstruct, err + } + + outstruct.SubHash = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) + outstruct.FdpSellerNameHash = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + outstruct.Seller = *abi.ConvertType(out[2], new(common.Address)).(*common.Address) + outstruct.SwarmLocation = *abi.ConvertType(out[3], new([32]byte)).(*[32]byte) + outstruct.Price = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) + outstruct.Active = *abi.ConvertType(out[5], new(bool)).(*bool) + outstruct.Earned = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int) + outstruct.Bids = *abi.ConvertType(out[7], new(uint32)).(*uint32) + outstruct.Sells = *abi.ConvertType(out[8], new(uint32)).(*uint32) + outstruct.Reports = *abi.ConvertType(out[9], new(uint32)).(*uint32) + outstruct.DaysValid = *abi.ConvertType(out[10], new(uint16)).(*uint16) + + return *outstruct, err + +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint16 daysValid) +func (_Datahub *DatahubSession) Subscriptions(arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + DaysValid uint16 +}, error) { + return _Datahub.Contract.Subscriptions(&_Datahub.CallOpts, arg0) +} + +// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. +// +// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint16 daysValid) +func (_Datahub *DatahubCallerSession) Subscriptions(arg0 *big.Int) (struct { + SubHash [32]byte + FdpSellerNameHash [32]byte + Seller common.Address + SwarmLocation [32]byte + Price *big.Int + Active bool + Earned *big.Int + Bids uint32 + Sells uint32 + Reports uint32 + DaysValid uint16 +}, error) { + return _Datahub.Contract.Subscriptions(&_Datahub.CallOpts, arg0) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Datahub *DatahubCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "supportsInterface", interfaceId) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Datahub *DatahubSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Datahub.Contract.SupportsInterface(&_Datahub.CallOpts, interfaceId) +} + +// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. +// +// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) +func (_Datahub *DatahubCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { + return _Datahub.Contract.SupportsInterface(&_Datahub.CallOpts, interfaceId) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_Datahub *DatahubTransactor) BidSub(opts *bind.TransactOpts, subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "bidSub", subHash, fdpBuyerNameHash) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_Datahub *DatahubSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.BidSub(&_Datahub.TransactOpts, subHash, fdpBuyerNameHash) +} + +// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. +// +// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() +func (_Datahub *DatahubTransactorSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.BidSub(&_Datahub.TransactOpts, subHash, fdpBuyerNameHash) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_Datahub *DatahubTransactor) EnableSub(opts *bind.TransactOpts, subHash [32]byte, active bool) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "enableSub", subHash, active) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_Datahub *DatahubSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { + return _Datahub.Contract.EnableSub(&_Datahub.TransactOpts, subHash, active) +} + +// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. +// +// Solidity: function enableSub(bytes32 subHash, bool active) returns() +func (_Datahub *DatahubTransactorSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { + return _Datahub.Contract.EnableSub(&_Datahub.TransactOpts, subHash, active) +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_Datahub *DatahubTransactor) FundsTransfer(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "fundsTransfer") +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_Datahub *DatahubSession) FundsTransfer() (*types.Transaction, error) { + return _Datahub.Contract.FundsTransfer(&_Datahub.TransactOpts) +} + +// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. +// +// Solidity: function fundsTransfer() payable returns() +func (_Datahub *DatahubTransactorSession) FundsTransfer() (*types.Transaction, error) { + return _Datahub.Contract.FundsTransfer(&_Datahub.TransactOpts) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactor) GrantRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "grantRole", role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Datahub *DatahubSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.GrantRole(&_Datahub.TransactOpts, role, account) +} + +// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. +// +// Solidity: function grantRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactorSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.GrantRole(&_Datahub.TransactOpts, role, account) +} + +// ListSub is a paid mutator transaction binding the contract method 0x202cff8a. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint16 daysValid) payable returns() +func (_Datahub *DatahubTransactor) ListSub(opts *bind.TransactOpts, fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid uint16) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "listSub", fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) +} + +// ListSub is a paid mutator transaction binding the contract method 0x202cff8a. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint16 daysValid) payable returns() +func (_Datahub *DatahubSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid uint16) (*types.Transaction, error) { + return _Datahub.Contract.ListSub(&_Datahub.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) +} + +// ListSub is a paid mutator transaction binding the contract method 0x202cff8a. +// +// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint16 daysValid) payable returns() +func (_Datahub *DatahubTransactorSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid uint16) (*types.Transaction, error) { + return _Datahub.Contract.ListSub(&_Datahub.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) +} + +// Release is a paid mutator transaction binding the contract method 0x0357371d. +// +// Solidity: function release(address token, uint256 amount) returns() +func (_Datahub *DatahubTransactor) Release(opts *bind.TransactOpts, token common.Address, amount *big.Int) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "release", token, amount) +} + +// Release is a paid mutator transaction binding the contract method 0x0357371d. +// +// Solidity: function release(address token, uint256 amount) returns() +func (_Datahub *DatahubSession) Release(token common.Address, amount *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.Release(&_Datahub.TransactOpts, token, amount) +} + +// Release is a paid mutator transaction binding the contract method 0x0357371d. +// +// Solidity: function release(address token, uint256 amount) returns() +func (_Datahub *DatahubTransactorSession) Release(token common.Address, amount *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.Release(&_Datahub.TransactOpts, token, amount) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_Datahub *DatahubTransactor) RemoveUserActiveBid(opts *bind.TransactOpts, requestHash [32]byte) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "removeUserActiveBid", requestHash) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_Datahub *DatahubSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.RemoveUserActiveBid(&_Datahub.TransactOpts, requestHash) +} + +// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. +// +// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() +func (_Datahub *DatahubTransactorSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.RemoveUserActiveBid(&_Datahub.TransactOpts, requestHash) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Datahub *DatahubTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "renounceOwnership") +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Datahub *DatahubSession) RenounceOwnership() (*types.Transaction, error) { + return _Datahub.Contract.RenounceOwnership(&_Datahub.TransactOpts) +} + +// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. +// +// Solidity: function renounceOwnership() returns() +func (_Datahub *DatahubTransactorSession) RenounceOwnership() (*types.Transaction, error) { + return _Datahub.Contract.RenounceOwnership(&_Datahub.TransactOpts) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactor) RenounceRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "renounceRole", role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Datahub *DatahubSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.RenounceRole(&_Datahub.TransactOpts, role, account) +} + +// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. +// +// Solidity: function renounceRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactorSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.RenounceRole(&_Datahub.TransactOpts, role, account) +} + +// ReportSub is a paid mutator transaction binding the contract method 0xd76ac1d1. +// +// Solidity: function reportSub(bytes32 subHash) returns() +func (_Datahub *DatahubTransactor) ReportSub(opts *bind.TransactOpts, subHash [32]byte) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "reportSub", subHash) +} + +// ReportSub is a paid mutator transaction binding the contract method 0xd76ac1d1. +// +// Solidity: function reportSub(bytes32 subHash) returns() +func (_Datahub *DatahubSession) ReportSub(subHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.ReportSub(&_Datahub.TransactOpts, subHash) +} + +// ReportSub is a paid mutator transaction binding the contract method 0xd76ac1d1. +// +// Solidity: function reportSub(bytes32 subHash) returns() +func (_Datahub *DatahubTransactorSession) ReportSub(subHash [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.ReportSub(&_Datahub.TransactOpts, subHash) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactor) RevokeRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "revokeRole", role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Datahub *DatahubSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.RevokeRole(&_Datahub.TransactOpts, role, account) +} + +// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. +// +// Solidity: function revokeRole(bytes32 role, address account) returns() +func (_Datahub *DatahubTransactorSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { + return _Datahub.Contract.RevokeRole(&_Datahub.TransactOpts, role, account) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_Datahub *DatahubTransactor) SellSub(opts *bind.TransactOpts, requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "sellSub", requestHash, encryptedKeyLocation) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_Datahub *DatahubSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.SellSub(&_Datahub.TransactOpts, requestHash, encryptedKeyLocation) +} + +// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. +// +// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() +func (_Datahub *DatahubTransactorSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { + return _Datahub.Contract.SellSub(&_Datahub.TransactOpts, requestHash, encryptedKeyLocation) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_Datahub *DatahubTransactor) SetFee(opts *bind.TransactOpts, newFee *big.Int) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "setFee", newFee) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_Datahub *DatahubSession) SetFee(newFee *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.SetFee(&_Datahub.TransactOpts, newFee) +} + +// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. +// +// Solidity: function setFee(uint256 newFee) returns() +func (_Datahub *DatahubTransactorSession) SetFee(newFee *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.SetFee(&_Datahub.TransactOpts, newFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_Datahub *DatahubTransactor) SetListingFee(opts *bind.TransactOpts, newListingFee *big.Int) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "setListingFee", newListingFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_Datahub *DatahubSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.SetListingFee(&_Datahub.TransactOpts, newListingFee) +} + +// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. +// +// Solidity: function setListingFee(uint256 newListingFee) returns() +func (_Datahub *DatahubTransactorSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { + return _Datahub.Contract.SetListingFee(&_Datahub.TransactOpts, newListingFee) +} + +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_Datahub *DatahubTransactor) SetPortableAddress(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "setPortableAddress", addr) +} + +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_Datahub *DatahubSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { + return _Datahub.Contract.SetPortableAddress(&_Datahub.TransactOpts, addr) +} + +// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. +// +// Solidity: function setPortableAddress(address addr) returns() +func (_Datahub *DatahubTransactorSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { + return _Datahub.Contract.SetPortableAddress(&_Datahub.TransactOpts, addr) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Datahub *DatahubTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { + return _Datahub.contract.Transact(opts, "transferOwnership", newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Datahub *DatahubSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Datahub.Contract.TransferOwnership(&_Datahub.TransactOpts, newOwner) +} + +// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. +// +// Solidity: function transferOwnership(address newOwner) returns() +func (_Datahub *DatahubTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { + return _Datahub.Contract.TransferOwnership(&_Datahub.TransactOpts, newOwner) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Datahub *DatahubTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Datahub.contract.RawTransact(opts, nil) // calldata is disallowed for receive function +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Datahub *DatahubSession) Receive() (*types.Transaction, error) { + return _Datahub.Contract.Receive(&_Datahub.TransactOpts) +} + +// Receive is a paid mutator transaction binding the contract receive function. +// +// Solidity: receive() payable returns() +func (_Datahub *DatahubTransactorSession) Receive() (*types.Transaction, error) { + return _Datahub.Contract.Receive(&_Datahub.TransactOpts) +} + +// DatahubOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the Datahub contract. +type DatahubOwnershipTransferredIterator struct { + Event *DatahubOwnershipTransferred // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DatahubOwnershipTransferredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DatahubOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DatahubOwnershipTransferred) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DatahubOwnershipTransferredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DatahubOwnershipTransferredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DatahubOwnershipTransferred represents a OwnershipTransferred event raised by the Datahub contract. +type DatahubOwnershipTransferred struct { + PreviousOwner common.Address + NewOwner common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Datahub *DatahubFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*DatahubOwnershipTransferredIterator, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Datahub.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return &DatahubOwnershipTransferredIterator{contract: _Datahub.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil +} + +// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Datahub *DatahubFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *DatahubOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { + + var previousOwnerRule []interface{} + for _, previousOwnerItem := range previousOwner { + previousOwnerRule = append(previousOwnerRule, previousOwnerItem) + } + var newOwnerRule []interface{} + for _, newOwnerItem := range newOwner { + newOwnerRule = append(newOwnerRule, newOwnerItem) + } + + logs, sub, err := _Datahub.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DatahubOwnershipTransferred) + if err := _Datahub.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. +// +// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) +func (_Datahub *DatahubFilterer) ParseOwnershipTransferred(log types.Log) (*DatahubOwnershipTransferred, error) { + event := new(DatahubOwnershipTransferred) + if err := _Datahub.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DatahubRoleAdminChangedIterator is returned from FilterRoleAdminChanged and is used to iterate over the raw logs and unpacked data for RoleAdminChanged events raised by the Datahub contract. +type DatahubRoleAdminChangedIterator struct { + Event *DatahubRoleAdminChanged // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DatahubRoleAdminChangedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DatahubRoleAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DatahubRoleAdminChanged) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DatahubRoleAdminChangedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DatahubRoleAdminChangedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DatahubRoleAdminChanged represents a RoleAdminChanged event raised by the Datahub contract. +type DatahubRoleAdminChanged struct { + Role [32]byte + PreviousAdminRole [32]byte + NewAdminRole [32]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleAdminChanged is a free log retrieval operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Datahub *DatahubFilterer) FilterRoleAdminChanged(opts *bind.FilterOpts, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (*DatahubRoleAdminChangedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _Datahub.contract.FilterLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return &DatahubRoleAdminChangedIterator{contract: _Datahub.contract, event: "RoleAdminChanged", logs: logs, sub: sub}, nil +} + +// WatchRoleAdminChanged is a free log subscription operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Datahub *DatahubFilterer) WatchRoleAdminChanged(opts *bind.WatchOpts, sink chan<- *DatahubRoleAdminChanged, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var previousAdminRoleRule []interface{} + for _, previousAdminRoleItem := range previousAdminRole { + previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) + } + var newAdminRoleRule []interface{} + for _, newAdminRoleItem := range newAdminRole { + newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) + } + + logs, sub, err := _Datahub.contract.WatchLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DatahubRoleAdminChanged) + if err := _Datahub.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleAdminChanged is a log parse operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. +// +// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) +func (_Datahub *DatahubFilterer) ParseRoleAdminChanged(log types.Log) (*DatahubRoleAdminChanged, error) { + event := new(DatahubRoleAdminChanged) + if err := _Datahub.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DatahubRoleGrantedIterator is returned from FilterRoleGranted and is used to iterate over the raw logs and unpacked data for RoleGranted events raised by the Datahub contract. +type DatahubRoleGrantedIterator struct { + Event *DatahubRoleGranted // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DatahubRoleGrantedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DatahubRoleGranted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DatahubRoleGranted) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DatahubRoleGrantedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DatahubRoleGrantedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DatahubRoleGranted represents a RoleGranted event raised by the Datahub contract. +type DatahubRoleGranted struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleGranted is a free log retrieval operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) FilterRoleGranted(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*DatahubRoleGrantedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Datahub.contract.FilterLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &DatahubRoleGrantedIterator{contract: _Datahub.contract, event: "RoleGranted", logs: logs, sub: sub}, nil +} + +// WatchRoleGranted is a free log subscription operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) WatchRoleGranted(opts *bind.WatchOpts, sink chan<- *DatahubRoleGranted, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Datahub.contract.WatchLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DatahubRoleGranted) + if err := _Datahub.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleGranted is a log parse operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. +// +// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) ParseRoleGranted(log types.Log) (*DatahubRoleGranted, error) { + event := new(DatahubRoleGranted) + if err := _Datahub.contract.UnpackLog(event, "RoleGranted", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// DatahubRoleRevokedIterator is returned from FilterRoleRevoked and is used to iterate over the raw logs and unpacked data for RoleRevoked events raised by the Datahub contract. +type DatahubRoleRevokedIterator struct { + Event *DatahubRoleRevoked // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *DatahubRoleRevokedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(DatahubRoleRevoked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(DatahubRoleRevoked) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *DatahubRoleRevokedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *DatahubRoleRevokedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// DatahubRoleRevoked represents a RoleRevoked event raised by the Datahub contract. +type DatahubRoleRevoked struct { + Role [32]byte + Account common.Address + Sender common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterRoleRevoked is a free log retrieval operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) FilterRoleRevoked(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*DatahubRoleRevokedIterator, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Datahub.contract.FilterLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return &DatahubRoleRevokedIterator{contract: _Datahub.contract, event: "RoleRevoked", logs: logs, sub: sub}, nil +} + +// WatchRoleRevoked is a free log subscription operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) WatchRoleRevoked(opts *bind.WatchOpts, sink chan<- *DatahubRoleRevoked, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { + + var roleRule []interface{} + for _, roleItem := range role { + roleRule = append(roleRule, roleItem) + } + var accountRule []interface{} + for _, accountItem := range account { + accountRule = append(accountRule, accountItem) + } + var senderRule []interface{} + for _, senderItem := range sender { + senderRule = append(senderRule, senderItem) + } + + logs, sub, err := _Datahub.contract.WatchLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(DatahubRoleRevoked) + if err := _Datahub.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseRoleRevoked is a log parse operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. +// +// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) +func (_Datahub *DatahubFilterer) ParseRoleRevoked(log types.Log) (*DatahubRoleRevoked, error) { + event := new(DatahubRoleRevoked) + if err := _Datahub.contract.UnpackLog(event, "RoleRevoked", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} diff --git a/pkg/contracts/smail/SwarmMail.go b/pkg/contracts/smail/SwarmMail.go deleted file mode 100644 index 6dc33dbb..00000000 --- a/pkg/contracts/smail/SwarmMail.go +++ /dev/null @@ -1,2947 +0,0 @@ -// Code generated - DO NOT EDIT. -// This file is a generated binding and any manual changes will be lost. - -package SwarmMail - -import ( - "errors" - "math/big" - "strings" - - ethereum "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/accounts/abi" - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/event" -) - -// Reference imports to suppress errors if they are not otherwise used. -var ( - _ = errors.New - _ = big.NewInt - _ = strings.NewReader - _ = ethereum.NotFound - _ = bind.Bind - _ = common.Big1 - _ = types.BloomLookup - _ = event.NewSubscription -) - -// SwarmMailActiveBid is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailActiveBid struct { - Seller common.Address - RequestHash [32]byte -} - -// SwarmMailCategory is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailCategory struct { - SubIdxs []*big.Int -} - -// SwarmMailEmail is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailEmail struct { - IsEncryption bool - Time *big.Int - From common.Address - To common.Address - SwarmLocation [32]byte - Signed bool -} - -// SwarmMailSub is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailSub struct { - SubHash [32]byte - FdpSellerNameHash [32]byte - Seller common.Address - SwarmLocation [32]byte - Price *big.Int - Active bool - Earned *big.Int - Bids uint32 - Sells uint32 - Reports uint32 - DaysValid *big.Int -} - -// SwarmMailSubItem is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailSubItem struct { - SubHash [32]byte - UnlockKeyLocation [32]byte - ValidTill *big.Int -} - -// SwarmMailSubRequest is an auto generated low-level Go binding around an user-defined struct. -type SwarmMailSubRequest struct { - FdpBuyerNameHash [32]byte - Buyer common.Address - SubHash [32]byte - RequestHash [32]byte -} - -// SwarmMailMetaData contains all meta data concerning the SwarmMail contract. -var SwarmMailMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"}],\"name\":\"getActiveSubItemsCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getBoxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numInboxItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSentItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numLockers\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSharedLockers\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint256[]\",\"name\":\"subIdxs\",\"type\":\"uint256[]\"}],\"internalType\":\"structSwarmMail.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInbox\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getInboxAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getInboxCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getInboxRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getLocker\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getLockerCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getLockerRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPublicKeys\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"registered\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"portable\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSent\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSentAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSharedLocker\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSharedLockerCount\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSharedLockerRange\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"time\",\"type\":\"uint256\"},{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"signed\",\"type\":\"bool\"}],\"internalType\":\"structSwarmMail.Email[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSub\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structSwarmMail.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"internalType\":\"structSwarmMail.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"key\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"smail\",\"type\":\"bytes32\"}],\"name\":\"register\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"types\",\"type\":\"uint256\"},{\"internalType\":\"bytes32[]\",\"name\":\"swarmLocations\",\"type\":\"bytes32[]\"}],\"name\":\"removeEmails\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeInboxEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeLockerEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"removeSentEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"removeSubItem\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"toAddress\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isEncryption\",\"type\":\"bool\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"sendEmail\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"withAddress\",\"type\":\"address\"}],\"name\":\"shareLockerWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"signEmail\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"}],\"name\":\"storeLocker\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"daysValid\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"withAddress\",\"type\":\"address\"}],\"name\":\"unshareLockerWith\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", -} - -// SwarmMailABI is the input ABI used to generate the binding from. -// Deprecated: Use SwarmMailMetaData.ABI instead. -var SwarmMailABI = SwarmMailMetaData.ABI - -// SwarmMail is an auto generated Go binding around an Ethereum contract. -type SwarmMail struct { - SwarmMailCaller // Read-only binding to the contract - SwarmMailTransactor // Write-only binding to the contract - SwarmMailFilterer // Log filterer for contract events -} - -// SwarmMailCaller is an auto generated read-only Go binding around an Ethereum contract. -type SwarmMailCaller struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// SwarmMailTransactor is an auto generated write-only Go binding around an Ethereum contract. -type SwarmMailTransactor struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// SwarmMailFilterer is an auto generated log filtering Go binding around an Ethereum contract events. -type SwarmMailFilterer struct { - contract *bind.BoundContract // Generic contract wrapper for the low level calls -} - -// SwarmMailSession is an auto generated Go binding around an Ethereum contract, -// with pre-set call and transact options. -type SwarmMailSession struct { - Contract *SwarmMail // Generic contract binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// SwarmMailCallerSession is an auto generated read-only Go binding around an Ethereum contract, -// with pre-set call options. -type SwarmMailCallerSession struct { - Contract *SwarmMailCaller // Generic contract caller binding to set the session for - CallOpts bind.CallOpts // Call options to use throughout this session -} - -// SwarmMailTransactorSession is an auto generated write-only Go binding around an Ethereum contract, -// with pre-set transact options. -type SwarmMailTransactorSession struct { - Contract *SwarmMailTransactor // Generic contract transactor binding to set the session for - TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session -} - -// SwarmMailRaw is an auto generated low-level Go binding around an Ethereum contract. -type SwarmMailRaw struct { - Contract *SwarmMail // Generic contract binding to access the raw methods on -} - -// SwarmMailCallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract. -type SwarmMailCallerRaw struct { - Contract *SwarmMailCaller // Generic read-only contract binding to access the raw methods on -} - -// SwarmMailTransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract. -type SwarmMailTransactorRaw struct { - Contract *SwarmMailTransactor // Generic write-only contract binding to access the raw methods on -} - -// NewSwarmMail creates a new instance of SwarmMail, bound to a specific deployed contract. -func NewSwarmMail(address common.Address, backend bind.ContractBackend) (*SwarmMail, error) { - contract, err := bindSwarmMail(address, backend, backend, backend) - if err != nil { - return nil, err - } - return &SwarmMail{SwarmMailCaller: SwarmMailCaller{contract: contract}, SwarmMailTransactor: SwarmMailTransactor{contract: contract}, SwarmMailFilterer: SwarmMailFilterer{contract: contract}}, nil -} - -// NewSwarmMailCaller creates a new read-only instance of SwarmMail, bound to a specific deployed contract. -func NewSwarmMailCaller(address common.Address, caller bind.ContractCaller) (*SwarmMailCaller, error) { - contract, err := bindSwarmMail(address, caller, nil, nil) - if err != nil { - return nil, err - } - return &SwarmMailCaller{contract: contract}, nil -} - -// NewSwarmMailTransactor creates a new write-only instance of SwarmMail, bound to a specific deployed contract. -func NewSwarmMailTransactor(address common.Address, transactor bind.ContractTransactor) (*SwarmMailTransactor, error) { - contract, err := bindSwarmMail(address, nil, transactor, nil) - if err != nil { - return nil, err - } - return &SwarmMailTransactor{contract: contract}, nil -} - -// NewSwarmMailFilterer creates a new log filterer instance of SwarmMail, bound to a specific deployed contract. -func NewSwarmMailFilterer(address common.Address, filterer bind.ContractFilterer) (*SwarmMailFilterer, error) { - contract, err := bindSwarmMail(address, nil, nil, filterer) - if err != nil { - return nil, err - } - return &SwarmMailFilterer{contract: contract}, nil -} - -// bindSwarmMail binds a generic wrapper to an already deployed contract. -func bindSwarmMail(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) { - parsed, err := abi.JSON(strings.NewReader(SwarmMailABI)) - if err != nil { - return nil, err - } - return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_SwarmMail *SwarmMailRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _SwarmMail.Contract.SwarmMailCaller.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_SwarmMail *SwarmMailRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwarmMail.Contract.SwarmMailTransactor.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_SwarmMail *SwarmMailRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _SwarmMail.Contract.SwarmMailTransactor.contract.Transact(opts, method, params...) -} - -// Call invokes the (constant) contract method with params as input values and -// sets the output to result. The result type might be a single field for simple -// returns, a slice of interfaces for anonymous returns and a struct for named -// returns. -func (_SwarmMail *SwarmMailCallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error { - return _SwarmMail.Contract.contract.Call(opts, result, method, params...) -} - -// Transfer initiates a plain transaction to move funds to the contract, calling -// its default method if one is available. -func (_SwarmMail *SwarmMailTransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwarmMail.Contract.contract.Transfer(opts) -} - -// Transact invokes the (paid) contract method with params as input values. -func (_SwarmMail *SwarmMailTransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) { - return _SwarmMail.Contract.contract.Transact(opts, method, params...) -} - -// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. -// -// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) -func (_SwarmMail *SwarmMailCaller) DEFAULTADMINROLE(opts *bind.CallOpts) ([32]byte, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "DEFAULT_ADMIN_ROLE") - - if err != nil { - return *new([32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - - return out0, err - -} - -// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. -// -// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) -func (_SwarmMail *SwarmMailSession) DEFAULTADMINROLE() ([32]byte, error) { - return _SwarmMail.Contract.DEFAULTADMINROLE(&_SwarmMail.CallOpts) -} - -// DEFAULTADMINROLE is a free data retrieval call binding the contract method 0xa217fddf. -// -// Solidity: function DEFAULT_ADMIN_ROLE() view returns(bytes32) -func (_SwarmMail *SwarmMailCallerSession) DEFAULTADMINROLE() ([32]byte, error) { - return _SwarmMail.Contract.DEFAULTADMINROLE(&_SwarmMail.CallOpts) -} - -// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. -// -// Solidity: function feesCollected() view returns(uint256) -func (_SwarmMail *SwarmMailCaller) FeesCollected(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "feesCollected") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. -// -// Solidity: function feesCollected() view returns(uint256) -func (_SwarmMail *SwarmMailSession) FeesCollected() (*big.Int, error) { - return _SwarmMail.Contract.FeesCollected(&_SwarmMail.CallOpts) -} - -// FeesCollected is a free data retrieval call binding the contract method 0xf071db5a. -// -// Solidity: function feesCollected() view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) FeesCollected() (*big.Int, error) { - return _SwarmMail.Contract.FeesCollected(&_SwarmMail.CallOpts) -} - -// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. -// -// Solidity: function fundsBalance() view returns(uint256) -func (_SwarmMail *SwarmMailCaller) FundsBalance(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "fundsBalance") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. -// -// Solidity: function fundsBalance() view returns(uint256) -func (_SwarmMail *SwarmMailSession) FundsBalance() (*big.Int, error) { - return _SwarmMail.Contract.FundsBalance(&_SwarmMail.CallOpts) -} - -// FundsBalance is a free data retrieval call binding the contract method 0x9454932c. -// -// Solidity: function fundsBalance() view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) FundsBalance() (*big.Int, error) { - return _SwarmMail.Contract.FundsBalance(&_SwarmMail.CallOpts) -} - -// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. -// -// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) -func (_SwarmMail *SwarmMailCaller) GetActiveBidAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getActiveBidAt", addr, index) - - if err != nil { - return *new(SwarmMailActiveBid), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailActiveBid)).(*SwarmMailActiveBid) - - return out0, err - -} - -// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. -// -// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) -func (_SwarmMail *SwarmMailSession) GetActiveBidAt(addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { - return _SwarmMail.Contract.GetActiveBidAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetActiveBidAt is a free data retrieval call binding the contract method 0x78ba33c6. -// -// Solidity: function getActiveBidAt(address addr, uint256 index) view returns((address,bytes32)) -func (_SwarmMail *SwarmMailCallerSession) GetActiveBidAt(addr common.Address, index *big.Int) (SwarmMailActiveBid, error) { - return _SwarmMail.Contract.GetActiveBidAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. -// -// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) -func (_SwarmMail *SwarmMailCaller) GetActiveBids(opts *bind.CallOpts, addr common.Address) ([]SwarmMailActiveBid, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getActiveBids", addr) - - if err != nil { - return *new([]SwarmMailActiveBid), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailActiveBid)).(*[]SwarmMailActiveBid) - - return out0, err - -} - -// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. -// -// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) -func (_SwarmMail *SwarmMailSession) GetActiveBids(addr common.Address) ([]SwarmMailActiveBid, error) { - return _SwarmMail.Contract.GetActiveBids(&_SwarmMail.CallOpts, addr) -} - -// GetActiveBids is a free data retrieval call binding the contract method 0xfbc4fc44. -// -// Solidity: function getActiveBids(address addr) view returns((address,bytes32)[]) -func (_SwarmMail *SwarmMailCallerSession) GetActiveBids(addr common.Address) ([]SwarmMailActiveBid, error) { - return _SwarmMail.Contract.GetActiveBids(&_SwarmMail.CallOpts, addr) -} - -// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. -// -// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetActiveSubItemsCount(opts *bind.CallOpts, addr common.Address, start *big.Int) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getActiveSubItemsCount", addr, start) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. -// -// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetActiveSubItemsCount(addr common.Address, start *big.Int) (*big.Int, error) { - return _SwarmMail.Contract.GetActiveSubItemsCount(&_SwarmMail.CallOpts, addr, start) -} - -// GetActiveSubItemsCount is a free data retrieval call binding the contract method 0x0a1043c0. -// -// Solidity: function getActiveSubItemsCount(address addr, uint256 start) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetActiveSubItemsCount(addr common.Address, start *big.Int) (*big.Int, error) { - return _SwarmMail.Contract.GetActiveSubItemsCount(&_SwarmMail.CallOpts, addr, start) -} - -// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. -// -// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailCaller) GetAllSubItems(opts *bind.CallOpts, addr common.Address) ([]SwarmMailSubItem, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getAllSubItems", addr) - - if err != nil { - return *new([]SwarmMailSubItem), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) - - return out0, err - -} - -// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. -// -// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailSession) GetAllSubItems(addr common.Address) ([]SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetAllSubItems(&_SwarmMail.CallOpts, addr) -} - -// GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. -// -// Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) -func (_SwarmMail *SwarmMailCallerSession) GetAllSubItems(addr common.Address) ([]SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetAllSubItems(&_SwarmMail.CallOpts, addr) -} - -// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. -// -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) -func (_SwarmMail *SwarmMailCaller) GetBoxCount(opts *bind.CallOpts, addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int - NumLockers *big.Int - NumSharedLockers *big.Int -}, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getBoxCount", addr) - - outstruct := new(struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int - NumLockers *big.Int - NumSharedLockers *big.Int - }) - if err != nil { - return *outstruct, err - } - - outstruct.NumInboxItems = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.NumSentItems = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - outstruct.NumSubRequests = *abi.ConvertType(out[2], new(*big.Int)).(**big.Int) - outstruct.NumSubItems = *abi.ConvertType(out[3], new(*big.Int)).(**big.Int) - outstruct.NumActiveBids = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) - outstruct.NumLockers = *abi.ConvertType(out[5], new(*big.Int)).(**big.Int) - outstruct.NumSharedLockers = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int) - - return *outstruct, err - -} - -// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. -// -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) -func (_SwarmMail *SwarmMailSession) GetBoxCount(addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int - NumLockers *big.Int - NumSharedLockers *big.Int -}, error) { - return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) -} - -// GetBoxCount is a free data retrieval call binding the contract method 0xa88b5c4f. -// -// Solidity: function getBoxCount(address addr) view returns(uint256 numInboxItems, uint256 numSentItems, uint256 numSubRequests, uint256 numSubItems, uint256 numActiveBids, uint256 numLockers, uint256 numSharedLockers) -func (_SwarmMail *SwarmMailCallerSession) GetBoxCount(addr common.Address) (struct { - NumInboxItems *big.Int - NumSentItems *big.Int - NumSubRequests *big.Int - NumSubItems *big.Int - NumActiveBids *big.Int - NumLockers *big.Int - NumSharedLockers *big.Int -}, error) { - return _SwarmMail.Contract.GetBoxCount(&_SwarmMail.CallOpts, addr) -} - -// GetCategory is a free data retrieval call binding the contract method 0x473b084c. -// -// Solidity: function getCategory(bytes32 category) view returns((uint256[])) -func (_SwarmMail *SwarmMailCaller) GetCategory(opts *bind.CallOpts, category [32]byte) (SwarmMailCategory, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getCategory", category) - - if err != nil { - return *new(SwarmMailCategory), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailCategory)).(*SwarmMailCategory) - - return out0, err - -} - -// GetCategory is a free data retrieval call binding the contract method 0x473b084c. -// -// Solidity: function getCategory(bytes32 category) view returns((uint256[])) -func (_SwarmMail *SwarmMailSession) GetCategory(category [32]byte) (SwarmMailCategory, error) { - return _SwarmMail.Contract.GetCategory(&_SwarmMail.CallOpts, category) -} - -// GetCategory is a free data retrieval call binding the contract method 0x473b084c. -// -// Solidity: function getCategory(bytes32 category) view returns((uint256[])) -func (_SwarmMail *SwarmMailCallerSession) GetCategory(category [32]byte) (SwarmMailCategory, error) { - return _SwarmMail.Contract.GetCategory(&_SwarmMail.CallOpts, category) -} - -// GetFee is a free data retrieval call binding the contract method 0xd250185c. -// -// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetFee(opts *bind.CallOpts, _fee *big.Int, amount *big.Int) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getFee", _fee, amount) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetFee is a free data retrieval call binding the contract method 0xd250185c. -// -// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) -func (_SwarmMail *SwarmMailSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { - return _SwarmMail.Contract.GetFee(&_SwarmMail.CallOpts, _fee, amount) -} - -// GetFee is a free data retrieval call binding the contract method 0xd250185c. -// -// Solidity: function getFee(uint256 _fee, uint256 amount) pure returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetFee(_fee *big.Int, amount *big.Int) (*big.Int, error) { - return _SwarmMail.Contract.GetFee(&_SwarmMail.CallOpts, _fee, amount) -} - -// GetInbox is a free data retrieval call binding the contract method 0x02201681. -// -// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetInbox(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getInbox", addr) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetInbox is a free data retrieval call binding the contract method 0x02201681. -// -// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetInbox(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInbox(&_SwarmMail.CallOpts, addr) -} - -// GetInbox is a free data retrieval call binding the contract method 0x02201681. -// -// Solidity: function getInbox(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetInbox(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInbox(&_SwarmMail.CallOpts, addr) -} - -// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. -// -// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailCaller) GetInboxAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getInboxAt", addr, index) - - if err != nil { - return *new(SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailEmail)).(*SwarmMailEmail) - - return out0, err - -} - -// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. -// -// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailSession) GetInboxAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInboxAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetInboxAt is a free data retrieval call binding the contract method 0xed354d5e. -// -// Solidity: function getInboxAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailCallerSession) GetInboxAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInboxAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. -// -// Solidity: function getInboxCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetInboxCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getInboxCount", addr) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. -// -// Solidity: function getInboxCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetInboxCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetInboxCount(&_SwarmMail.CallOpts, addr) -} - -// GetInboxCount is a free data retrieval call binding the contract method 0x762e1824. -// -// Solidity: function getInboxCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetInboxCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetInboxCount(&_SwarmMail.CallOpts, addr) -} - -// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. -// -// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetInboxRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getInboxRange", addr, start, length) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. -// -// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetInboxRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInboxRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetInboxRange is a free data retrieval call binding the contract method 0x384fb864. -// -// Solidity: function getInboxRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetInboxRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetInboxRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. -// -// Solidity: function getListedSubs(address addr) view returns(bytes32[]) -func (_SwarmMail *SwarmMailCaller) GetListedSubs(opts *bind.CallOpts, addr common.Address) ([][32]byte, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getListedSubs", addr) - - if err != nil { - return *new([][32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) - - return out0, err - -} - -// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. -// -// Solidity: function getListedSubs(address addr) view returns(bytes32[]) -func (_SwarmMail *SwarmMailSession) GetListedSubs(addr common.Address) ([][32]byte, error) { - return _SwarmMail.Contract.GetListedSubs(&_SwarmMail.CallOpts, addr) -} - -// GetListedSubs is a free data retrieval call binding the contract method 0xcddf64ea. -// -// Solidity: function getListedSubs(address addr) view returns(bytes32[]) -func (_SwarmMail *SwarmMailCallerSession) GetListedSubs(addr common.Address) ([][32]byte, error) { - return _SwarmMail.Contract.GetListedSubs(&_SwarmMail.CallOpts, addr) -} - -// GetLocker is a free data retrieval call binding the contract method 0x919884bf. -// -// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetLocker(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getLocker", addr) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetLocker is a free data retrieval call binding the contract method 0x919884bf. -// -// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetLocker(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetLocker(&_SwarmMail.CallOpts, addr) -} - -// GetLocker is a free data retrieval call binding the contract method 0x919884bf. -// -// Solidity: function getLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetLocker(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetLocker(&_SwarmMail.CallOpts, addr) -} - -// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. -// -// Solidity: function getLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetLockerCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getLockerCount", addr) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. -// -// Solidity: function getLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetLockerCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetLockerCount(&_SwarmMail.CallOpts, addr) -} - -// GetLockerCount is a free data retrieval call binding the contract method 0x71b14815. -// -// Solidity: function getLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetLockerCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetLockerCount(&_SwarmMail.CallOpts, addr) -} - -// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. -// -// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetLockerRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getLockerRange", addr, start, length) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. -// -// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetLockerRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetLockerRange is a free data retrieval call binding the contract method 0xf787b1c1. -// -// Solidity: function getLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetLockerRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. -// -// Solidity: function getPortableAddress(address addr) view returns(address) -func (_SwarmMail *SwarmMailCaller) GetPortableAddress(opts *bind.CallOpts, addr common.Address) (common.Address, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getPortableAddress", addr) - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. -// -// Solidity: function getPortableAddress(address addr) view returns(address) -func (_SwarmMail *SwarmMailSession) GetPortableAddress(addr common.Address) (common.Address, error) { - return _SwarmMail.Contract.GetPortableAddress(&_SwarmMail.CallOpts, addr) -} - -// GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. -// -// Solidity: function getPortableAddress(address addr) view returns(address) -func (_SwarmMail *SwarmMailCallerSession) GetPortableAddress(addr common.Address) (common.Address, error) { - return _SwarmMail.Contract.GetPortableAddress(&_SwarmMail.CallOpts, addr) -} - -// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. -// -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) -func (_SwarmMail *SwarmMailCaller) GetPublicKeys(opts *bind.CallOpts, addr common.Address) (struct { - Registered bool - Key [32]byte - Smail [32]byte - Portable common.Address -}, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getPublicKeys", addr) - - outstruct := new(struct { - Registered bool - Key [32]byte - Smail [32]byte - Portable common.Address - }) - if err != nil { - return *outstruct, err - } - - outstruct.Registered = *abi.ConvertType(out[0], new(bool)).(*bool) - outstruct.Key = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) - outstruct.Smail = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) - outstruct.Portable = *abi.ConvertType(out[3], new(common.Address)).(*common.Address) - - return *outstruct, err - -} - -// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. -// -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) -func (_SwarmMail *SwarmMailSession) GetPublicKeys(addr common.Address) (struct { - Registered bool - Key [32]byte - Smail [32]byte - Portable common.Address -}, error) { - return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) -} - -// GetPublicKeys is a free data retrieval call binding the contract method 0x5fcbb7d6. -// -// Solidity: function getPublicKeys(address addr) view returns(bool registered, bytes32 key, bytes32 smail, address portable) -func (_SwarmMail *SwarmMailCallerSession) GetPublicKeys(addr common.Address) (struct { - Registered bool - Key [32]byte - Smail [32]byte - Portable common.Address -}, error) { - return _SwarmMail.Contract.GetPublicKeys(&_SwarmMail.CallOpts, addr) -} - -// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. -// -// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) -func (_SwarmMail *SwarmMailCaller) GetRoleAdmin(opts *bind.CallOpts, role [32]byte) ([32]byte, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getRoleAdmin", role) - - if err != nil { - return *new([32]byte), err - } - - out0 := *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - - return out0, err - -} - -// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. -// -// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) -func (_SwarmMail *SwarmMailSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { - return _SwarmMail.Contract.GetRoleAdmin(&_SwarmMail.CallOpts, role) -} - -// GetRoleAdmin is a free data retrieval call binding the contract method 0x248a9ca3. -// -// Solidity: function getRoleAdmin(bytes32 role) view returns(bytes32) -func (_SwarmMail *SwarmMailCallerSession) GetRoleAdmin(role [32]byte) ([32]byte, error) { - return _SwarmMail.Contract.GetRoleAdmin(&_SwarmMail.CallOpts, role) -} - -// GetSent is a free data retrieval call binding the contract method 0xd75d691d. -// -// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetSent(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSent", addr) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetSent is a free data retrieval call binding the contract method 0xd75d691d. -// -// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetSent(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSent(&_SwarmMail.CallOpts, addr) -} - -// GetSent is a free data retrieval call binding the contract method 0xd75d691d. -// -// Solidity: function getSent(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSent(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSent(&_SwarmMail.CallOpts, addr) -} - -// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. -// -// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailCaller) GetSentAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSentAt", addr, index) - - if err != nil { - return *new(SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailEmail)).(*SwarmMailEmail) - - return out0, err - -} - -// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. -// -// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailSession) GetSentAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSentAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSentAt is a free data retrieval call binding the contract method 0x9d9a4f94. -// -// Solidity: function getSentAt(address addr, uint256 index) view returns((bool,uint256,address,address,bytes32,bool)) -func (_SwarmMail *SwarmMailCallerSession) GetSentAt(addr common.Address, index *big.Int) (SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSentAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. -// -// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetSharedLocker(opts *bind.CallOpts, addr common.Address) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSharedLocker", addr) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. -// -// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetSharedLocker(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSharedLocker(&_SwarmMail.CallOpts, addr) -} - -// GetSharedLocker is a free data retrieval call binding the contract method 0x1d2b242c. -// -// Solidity: function getSharedLocker(address addr) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSharedLocker(addr common.Address) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSharedLocker(&_SwarmMail.CallOpts, addr) -} - -// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. -// -// Solidity: function getSharedLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetSharedLockerCount(opts *bind.CallOpts, addr common.Address) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSharedLockerCount", addr) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. -// -// Solidity: function getSharedLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetSharedLockerCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSharedLockerCount(&_SwarmMail.CallOpts, addr) -} - -// GetSharedLockerCount is a free data retrieval call binding the contract method 0x286edb06. -// -// Solidity: function getSharedLockerCount(address addr) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetSharedLockerCount(addr common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSharedLockerCount(&_SwarmMail.CallOpts, addr) -} - -// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. -// -// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCaller) GetSharedLockerRange(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSharedLockerRange", addr, start, length) - - if err != nil { - return *new([]SwarmMailEmail), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailEmail)).(*[]SwarmMailEmail) - - return out0, err - -} - -// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. -// -// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailSession) GetSharedLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSharedLockerRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetSharedLockerRange is a free data retrieval call binding the contract method 0x9fea2a71. -// -// Solidity: function getSharedLockerRange(address addr, uint256 start, uint256 length) view returns((bool,uint256,address,address,bytes32,bool)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSharedLockerRange(addr common.Address, start *big.Int, length *big.Int) ([]SwarmMailEmail, error) { - return _SwarmMail.Contract.GetSharedLockerRange(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. -// -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailCaller) GetSub(opts *bind.CallOpts, index *big.Int) (SwarmMailSub, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSub", index) - - if err != nil { - return *new(SwarmMailSub), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSub)).(*SwarmMailSub) - - return out0, err - -} - -// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. -// -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailSession) GetSub(index *big.Int) (SwarmMailSub, error) { - return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) -} - -// GetSub is a free data retrieval call binding the contract method 0xb1bf9a22. -// -// Solidity: function getSub(uint256 index) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailCallerSession) GetSub(index *big.Int) (SwarmMailSub, error) { - return _SwarmMail.Contract.GetSub(&_SwarmMail.CallOpts, index) -} - -// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. -// -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailCaller) GetSubBy(opts *bind.CallOpts, subHash [32]byte) (SwarmMailSub, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubBy", subHash) - - if err != nil { - return *new(SwarmMailSub), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSub)).(*SwarmMailSub) - - return out0, err - -} - -// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. -// -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { - return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) -} - -// GetSubBy is a free data retrieval call binding the contract method 0x1f9ef490. -// -// Solidity: function getSubBy(bytes32 subHash) view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)) -func (_SwarmMail *SwarmMailCallerSession) GetSubBy(subHash [32]byte) (SwarmMailSub, error) { - return _SwarmMail.Contract.GetSubBy(&_SwarmMail.CallOpts, subHash) -} - -// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. -// -// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) GetSubInfoBalance(opts *bind.CallOpts, subHash [32]byte, forAddress common.Address) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubInfoBalance", subHash, forAddress) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. -// -// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) -func (_SwarmMail *SwarmMailSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSubInfoBalance(&_SwarmMail.CallOpts, subHash, forAddress) -} - -// GetSubInfoBalance is a free data retrieval call binding the contract method 0x254e287b. -// -// Solidity: function getSubInfoBalance(bytes32 subHash, address forAddress) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) GetSubInfoBalance(subHash [32]byte, forAddress common.Address) (*big.Int, error) { - return _SwarmMail.Contract.GetSubInfoBalance(&_SwarmMail.CallOpts, subHash, forAddress) -} - -// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. -// -// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailCaller) GetSubItemAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailSubItem, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubItemAt", addr, index) - - if err != nil { - return *new(SwarmMailSubItem), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSubItem)).(*SwarmMailSubItem) - - return out0, err - -} - -// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. -// -// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailSession) GetSubItemAt(addr common.Address, index *big.Int) (SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetSubItemAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSubItemAt is a free data retrieval call binding the contract method 0x80dd0d8e. -// -// Solidity: function getSubItemAt(address addr, uint256 index) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailCallerSession) GetSubItemAt(addr common.Address, index *big.Int) (SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetSubItemAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailCaller) GetSubItemBy(opts *bind.CallOpts, addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubItemBy", addr, subHash) - - if err != nil { - return *new(SwarmMailSubItem), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSubItem)).(*SwarmMailSubItem) - - return out0, err - -} - -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailSession) GetSubItemBy(addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetSubItemBy(&_SwarmMail.CallOpts, addr, subHash) -} - -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_SwarmMail *SwarmMailCallerSession) GetSubItemBy(addr common.Address, subHash [32]byte) (SwarmMailSubItem, error) { - return _SwarmMail.Contract.GetSubItemBy(&_SwarmMail.CallOpts, addr, subHash) -} - -// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. -// -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) -func (_SwarmMail *SwarmMailCaller) GetSubItems(opts *bind.CallOpts, addr common.Address, start *big.Int, length *big.Int) (struct { - Items []SwarmMailSubItem - Last *big.Int -}, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubItems", addr, start, length) - - outstruct := new(struct { - Items []SwarmMailSubItem - Last *big.Int - }) - if err != nil { - return *outstruct, err - } - - outstruct.Items = *abi.ConvertType(out[0], new([]SwarmMailSubItem)).(*[]SwarmMailSubItem) - outstruct.Last = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - - return *outstruct, err - -} - -// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. -// -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) -func (_SwarmMail *SwarmMailSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { - Items []SwarmMailSubItem - Last *big.Int -}, error) { - return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. -// -// Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) -func (_SwarmMail *SwarmMailCallerSession) GetSubItems(addr common.Address, start *big.Int, length *big.Int) (struct { - Items []SwarmMailSubItem - Last *big.Int -}, error) { - return _SwarmMail.Contract.GetSubItems(&_SwarmMail.CallOpts, addr, start, length) -} - -// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. -// -// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailCaller) GetSubRequestAt(opts *bind.CallOpts, addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubRequestAt", addr, index) - - if err != nil { - return *new(SwarmMailSubRequest), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSubRequest)).(*SwarmMailSubRequest) - - return out0, err - -} - -// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. -// -// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailSession) GetSubRequestAt(addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequestAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSubRequestAt is a free data retrieval call binding the contract method 0x84053229. -// -// Solidity: function getSubRequestAt(address addr, uint256 index) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailCallerSession) GetSubRequestAt(addr common.Address, index *big.Int) (SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequestAt(&_SwarmMail.CallOpts, addr, index) -} - -// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. -// -// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailCaller) GetSubRequestByHash(opts *bind.CallOpts, addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubRequestByHash", addr, requestHash) - - if err != nil { - return *new(SwarmMailSubRequest), err - } - - out0 := *abi.ConvertType(out[0], new(SwarmMailSubRequest)).(*SwarmMailSubRequest) - - return out0, err - -} - -// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. -// -// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequestByHash(&_SwarmMail.CallOpts, addr, requestHash) -} - -// GetSubRequestByHash is a free data retrieval call binding the contract method 0x9bde82dc. -// -// Solidity: function getSubRequestByHash(address addr, bytes32 requestHash) view returns((bytes32,address,bytes32,bytes32)) -func (_SwarmMail *SwarmMailCallerSession) GetSubRequestByHash(addr common.Address, requestHash [32]byte) (SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequestByHash(&_SwarmMail.CallOpts, addr, requestHash) -} - -// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. -// -// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) -func (_SwarmMail *SwarmMailCaller) GetSubRequests(opts *bind.CallOpts, addr common.Address) ([]SwarmMailSubRequest, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubRequests", addr) - - if err != nil { - return *new([]SwarmMailSubRequest), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailSubRequest)).(*[]SwarmMailSubRequest) - - return out0, err - -} - -// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. -// -// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) -func (_SwarmMail *SwarmMailSession) GetSubRequests(addr common.Address) ([]SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequests(&_SwarmMail.CallOpts, addr) -} - -// GetSubRequests is a free data retrieval call binding the contract method 0x92b58bc2. -// -// Solidity: function getSubRequests(address addr) view returns((bytes32,address,bytes32,bytes32)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSubRequests(addr common.Address) ([]SwarmMailSubRequest, error) { - return _SwarmMail.Contract.GetSubRequests(&_SwarmMail.CallOpts, addr) -} - -// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. -// -// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) -func (_SwarmMail *SwarmMailCaller) GetSubSubscribers(opts *bind.CallOpts, subHash [32]byte) ([]common.Address, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubSubscribers", subHash) - - if err != nil { - return *new([]common.Address), err - } - - out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) - - return out0, err - -} - -// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. -// -// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) -func (_SwarmMail *SwarmMailSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { - return _SwarmMail.Contract.GetSubSubscribers(&_SwarmMail.CallOpts, subHash) -} - -// GetSubSubscribers is a free data retrieval call binding the contract method 0x7de2e5e8. -// -// Solidity: function getSubSubscribers(bytes32 subHash) view returns(address[]) -func (_SwarmMail *SwarmMailCallerSession) GetSubSubscribers(subHash [32]byte) ([]common.Address, error) { - return _SwarmMail.Contract.GetSubSubscribers(&_SwarmMail.CallOpts, subHash) -} - -// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. -// -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) -func (_SwarmMail *SwarmMailCaller) GetSubs(opts *bind.CallOpts) ([]SwarmMailSub, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "getSubs") - - if err != nil { - return *new([]SwarmMailSub), err - } - - out0 := *abi.ConvertType(out[0], new([]SwarmMailSub)).(*[]SwarmMailSub) - - return out0, err - -} - -// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. -// -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) -func (_SwarmMail *SwarmMailSession) GetSubs() ([]SwarmMailSub, error) { - return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) -} - -// GetSubs is a free data retrieval call binding the contract method 0xb8fb1bac. -// -// Solidity: function getSubs() view returns((bytes32,bytes32,address,bytes32,uint256,bool,uint256,uint32,uint32,uint32,uint256)[]) -func (_SwarmMail *SwarmMailCallerSession) GetSubs() ([]SwarmMailSub, error) { - return _SwarmMail.Contract.GetSubs(&_SwarmMail.CallOpts) -} - -// HasRole is a free data retrieval call binding the contract method 0x91d14854. -// -// Solidity: function hasRole(bytes32 role, address account) view returns(bool) -func (_SwarmMail *SwarmMailCaller) HasRole(opts *bind.CallOpts, role [32]byte, account common.Address) (bool, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "hasRole", role, account) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// HasRole is a free data retrieval call binding the contract method 0x91d14854. -// -// Solidity: function hasRole(bytes32 role, address account) view returns(bool) -func (_SwarmMail *SwarmMailSession) HasRole(role [32]byte, account common.Address) (bool, error) { - return _SwarmMail.Contract.HasRole(&_SwarmMail.CallOpts, role, account) -} - -// HasRole is a free data retrieval call binding the contract method 0x91d14854. -// -// Solidity: function hasRole(bytes32 role, address account) view returns(bool) -func (_SwarmMail *SwarmMailCallerSession) HasRole(role [32]byte, account common.Address) (bool, error) { - return _SwarmMail.Contract.HasRole(&_SwarmMail.CallOpts, role, account) -} - -// InEscrow is a free data retrieval call binding the contract method 0xb7391341. -// -// Solidity: function inEscrow() view returns(uint256) -func (_SwarmMail *SwarmMailCaller) InEscrow(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "inEscrow") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// InEscrow is a free data retrieval call binding the contract method 0xb7391341. -// -// Solidity: function inEscrow() view returns(uint256) -func (_SwarmMail *SwarmMailSession) InEscrow() (*big.Int, error) { - return _SwarmMail.Contract.InEscrow(&_SwarmMail.CallOpts) -} - -// InEscrow is a free data retrieval call binding the contract method 0xb7391341. -// -// Solidity: function inEscrow() view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) InEscrow() (*big.Int, error) { - return _SwarmMail.Contract.InEscrow(&_SwarmMail.CallOpts) -} - -// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. -// -// Solidity: function marketFee() view returns(uint256) -func (_SwarmMail *SwarmMailCaller) MarketFee(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "marketFee") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. -// -// Solidity: function marketFee() view returns(uint256) -func (_SwarmMail *SwarmMailSession) MarketFee() (*big.Int, error) { - return _SwarmMail.Contract.MarketFee(&_SwarmMail.CallOpts) -} - -// MarketFee is a free data retrieval call binding the contract method 0x0ccf2156. -// -// Solidity: function marketFee() view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) MarketFee() (*big.Int, error) { - return _SwarmMail.Contract.MarketFee(&_SwarmMail.CallOpts) -} - -// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. -// -// Solidity: function minListingFee() view returns(uint256) -func (_SwarmMail *SwarmMailCaller) MinListingFee(opts *bind.CallOpts) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "minListingFee") - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. -// -// Solidity: function minListingFee() view returns(uint256) -func (_SwarmMail *SwarmMailSession) MinListingFee() (*big.Int, error) { - return _SwarmMail.Contract.MinListingFee(&_SwarmMail.CallOpts) -} - -// MinListingFee is a free data retrieval call binding the contract method 0x703a54b5. -// -// Solidity: function minListingFee() view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) MinListingFee() (*big.Int, error) { - return _SwarmMail.Contract.MinListingFee(&_SwarmMail.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_SwarmMail *SwarmMailCaller) Owner(opts *bind.CallOpts) (common.Address, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "owner") - - if err != nil { - return *new(common.Address), err - } - - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - - return out0, err - -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_SwarmMail *SwarmMailSession) Owner() (common.Address, error) { - return _SwarmMail.Contract.Owner(&_SwarmMail.CallOpts) -} - -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. -// -// Solidity: function owner() view returns(address) -func (_SwarmMail *SwarmMailCallerSession) Owner() (common.Address, error) { - return _SwarmMail.Contract.Owner(&_SwarmMail.CallOpts) -} - -// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. -// -// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) -func (_SwarmMail *SwarmMailCaller) SubscriptionIds(opts *bind.CallOpts, arg0 [32]byte) (*big.Int, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "subscriptionIds", arg0) - - if err != nil { - return *new(*big.Int), err - } - - out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - - return out0, err - -} - -// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. -// -// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) -func (_SwarmMail *SwarmMailSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { - return _SwarmMail.Contract.SubscriptionIds(&_SwarmMail.CallOpts, arg0) -} - -// SubscriptionIds is a free data retrieval call binding the contract method 0x0e499994. -// -// Solidity: function subscriptionIds(bytes32 ) view returns(uint256) -func (_SwarmMail *SwarmMailCallerSession) SubscriptionIds(arg0 [32]byte) (*big.Int, error) { - return _SwarmMail.Contract.SubscriptionIds(&_SwarmMail.CallOpts, arg0) -} - -// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. -// -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) -func (_SwarmMail *SwarmMailCaller) Subscriptions(opts *bind.CallOpts, arg0 *big.Int) (struct { - SubHash [32]byte - FdpSellerNameHash [32]byte - Seller common.Address - SwarmLocation [32]byte - Price *big.Int - Active bool - Earned *big.Int - Bids uint32 - Sells uint32 - Reports uint32 - DaysValid *big.Int -}, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "subscriptions", arg0) - - outstruct := new(struct { - SubHash [32]byte - FdpSellerNameHash [32]byte - Seller common.Address - SwarmLocation [32]byte - Price *big.Int - Active bool - Earned *big.Int - Bids uint32 - Sells uint32 - Reports uint32 - DaysValid *big.Int - }) - if err != nil { - return *outstruct, err - } - - outstruct.SubHash = *abi.ConvertType(out[0], new([32]byte)).(*[32]byte) - outstruct.FdpSellerNameHash = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) - outstruct.Seller = *abi.ConvertType(out[2], new(common.Address)).(*common.Address) - outstruct.SwarmLocation = *abi.ConvertType(out[3], new([32]byte)).(*[32]byte) - outstruct.Price = *abi.ConvertType(out[4], new(*big.Int)).(**big.Int) - outstruct.Active = *abi.ConvertType(out[5], new(bool)).(*bool) - outstruct.Earned = *abi.ConvertType(out[6], new(*big.Int)).(**big.Int) - outstruct.Bids = *abi.ConvertType(out[7], new(uint32)).(*uint32) - outstruct.Sells = *abi.ConvertType(out[8], new(uint32)).(*uint32) - outstruct.Reports = *abi.ConvertType(out[9], new(uint32)).(*uint32) - outstruct.DaysValid = *abi.ConvertType(out[10], new(*big.Int)).(**big.Int) - - return *outstruct, err - -} - -// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. -// -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) -func (_SwarmMail *SwarmMailSession) Subscriptions(arg0 *big.Int) (struct { - SubHash [32]byte - FdpSellerNameHash [32]byte - Seller common.Address - SwarmLocation [32]byte - Price *big.Int - Active bool - Earned *big.Int - Bids uint32 - Sells uint32 - Reports uint32 - DaysValid *big.Int -}, error) { - return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) -} - -// Subscriptions is a free data retrieval call binding the contract method 0x2d5bbf60. -// -// Solidity: function subscriptions(uint256 ) view returns(bytes32 subHash, bytes32 fdpSellerNameHash, address seller, bytes32 swarmLocation, uint256 price, bool active, uint256 earned, uint32 bids, uint32 sells, uint32 reports, uint256 daysValid) -func (_SwarmMail *SwarmMailCallerSession) Subscriptions(arg0 *big.Int) (struct { - SubHash [32]byte - FdpSellerNameHash [32]byte - Seller common.Address - SwarmLocation [32]byte - Price *big.Int - Active bool - Earned *big.Int - Bids uint32 - Sells uint32 - Reports uint32 - DaysValid *big.Int -}, error) { - return _SwarmMail.Contract.Subscriptions(&_SwarmMail.CallOpts, arg0) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_SwarmMail *SwarmMailCaller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) { - var out []interface{} - err := _SwarmMail.contract.Call(opts, &out, "supportsInterface", interfaceId) - - if err != nil { - return *new(bool), err - } - - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - - return out0, err - -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_SwarmMail *SwarmMailSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _SwarmMail.Contract.SupportsInterface(&_SwarmMail.CallOpts, interfaceId) -} - -// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7. -// -// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool) -func (_SwarmMail *SwarmMailCallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) { - return _SwarmMail.Contract.SupportsInterface(&_SwarmMail.CallOpts, interfaceId) -} - -// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. -// -// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() -func (_SwarmMail *SwarmMailTransactor) BidSub(opts *bind.TransactOpts, subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "bidSub", subHash, fdpBuyerNameHash) -} - -// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. -// -// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() -func (_SwarmMail *SwarmMailSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.BidSub(&_SwarmMail.TransactOpts, subHash, fdpBuyerNameHash) -} - -// BidSub is a paid mutator transaction binding the contract method 0xe91dbcb0. -// -// Solidity: function bidSub(bytes32 subHash, bytes32 fdpBuyerNameHash) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) BidSub(subHash [32]byte, fdpBuyerNameHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.BidSub(&_SwarmMail.TransactOpts, subHash, fdpBuyerNameHash) -} - -// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. -// -// Solidity: function enableSub(bytes32 subHash, bool active) returns() -func (_SwarmMail *SwarmMailTransactor) EnableSub(opts *bind.TransactOpts, subHash [32]byte, active bool) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "enableSub", subHash, active) -} - -// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. -// -// Solidity: function enableSub(bytes32 subHash, bool active) returns() -func (_SwarmMail *SwarmMailSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { - return _SwarmMail.Contract.EnableSub(&_SwarmMail.TransactOpts, subHash, active) -} - -// EnableSub is a paid mutator transaction binding the contract method 0x88ac2917. -// -// Solidity: function enableSub(bytes32 subHash, bool active) returns() -func (_SwarmMail *SwarmMailTransactorSession) EnableSub(subHash [32]byte, active bool) (*types.Transaction, error) { - return _SwarmMail.Contract.EnableSub(&_SwarmMail.TransactOpts, subHash, active) -} - -// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. -// -// Solidity: function fundsTransfer() payable returns() -func (_SwarmMail *SwarmMailTransactor) FundsTransfer(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "fundsTransfer") -} - -// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. -// -// Solidity: function fundsTransfer() payable returns() -func (_SwarmMail *SwarmMailSession) FundsTransfer() (*types.Transaction, error) { - return _SwarmMail.Contract.FundsTransfer(&_SwarmMail.TransactOpts) -} - -// FundsTransfer is a paid mutator transaction binding the contract method 0x567556a4. -// -// Solidity: function fundsTransfer() payable returns() -func (_SwarmMail *SwarmMailTransactorSession) FundsTransfer() (*types.Transaction, error) { - return _SwarmMail.Contract.FundsTransfer(&_SwarmMail.TransactOpts) -} - -// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. -// -// Solidity: function grantRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactor) GrantRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "grantRole", role, account) -} - -// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. -// -// Solidity: function grantRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.GrantRole(&_SwarmMail.TransactOpts, role, account) -} - -// GrantRole is a paid mutator transaction binding the contract method 0x2f2ff15d. -// -// Solidity: function grantRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactorSession) GrantRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.GrantRole(&_SwarmMail.TransactOpts, role, account) -} - -// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. -// -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() -func (_SwarmMail *SwarmMailTransactor) ListSub(opts *bind.TransactOpts, fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "listSub", fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) -} - -// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. -// -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() -func (_SwarmMail *SwarmMailSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) -} - -// ListSub is a paid mutator transaction binding the contract method 0x1f59388d. -// -// Solidity: function listSub(bytes32 fdpSellerNameHash, bytes32 dataSwarmLocation, uint256 price, bytes32 category, address podAddress, uint256 daysValid) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) ListSub(fdpSellerNameHash [32]byte, dataSwarmLocation [32]byte, price *big.Int, category [32]byte, podAddress common.Address, daysValid *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.ListSub(&_SwarmMail.TransactOpts, fdpSellerNameHash, dataSwarmLocation, price, category, podAddress, daysValid) -} - -// Register is a paid mutator transaction binding the contract method 0x2f926732. -// -// Solidity: function register(bytes32 key, bytes32 smail) returns() -func (_SwarmMail *SwarmMailTransactor) Register(opts *bind.TransactOpts, key [32]byte, smail [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "register", key, smail) -} - -// Register is a paid mutator transaction binding the contract method 0x2f926732. -// -// Solidity: function register(bytes32 key, bytes32 smail) returns() -func (_SwarmMail *SwarmMailSession) Register(key [32]byte, smail [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.Register(&_SwarmMail.TransactOpts, key, smail) -} - -// Register is a paid mutator transaction binding the contract method 0x2f926732. -// -// Solidity: function register(bytes32 key, bytes32 smail) returns() -func (_SwarmMail *SwarmMailTransactorSession) Register(key [32]byte, smail [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.Register(&_SwarmMail.TransactOpts, key, smail) -} - -// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. -// -// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveEmails(opts *bind.TransactOpts, types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeEmails", types, swarmLocations) -} - -// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. -// -// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() -func (_SwarmMail *SwarmMailSession) RemoveEmails(types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveEmails(&_SwarmMail.TransactOpts, types, swarmLocations) -} - -// RemoveEmails is a paid mutator transaction binding the contract method 0xb663ab5f. -// -// Solidity: function removeEmails(uint256 types, bytes32[] swarmLocations) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveEmails(types *big.Int, swarmLocations [][32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveEmails(&_SwarmMail.TransactOpts, types, swarmLocations) -} - -// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. -// -// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveInboxEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeInboxEmail", swarmLocation) -} - -// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. -// -// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailSession) RemoveInboxEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveInboxEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveInboxEmail is a paid mutator transaction binding the contract method 0xc34ba5f6. -// -// Solidity: function removeInboxEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveInboxEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveInboxEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. -// -// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveLockerEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeLockerEmail", swarmLocation) -} - -// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. -// -// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailSession) RemoveLockerEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveLockerEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveLockerEmail is a paid mutator transaction binding the contract method 0xc221e534. -// -// Solidity: function removeLockerEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveLockerEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveLockerEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. -// -// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveSentEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeSentEmail", swarmLocation) -} - -// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. -// -// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailSession) RemoveSentEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveSentEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveSentEmail is a paid mutator transaction binding the contract method 0xc9bdc1c5. -// -// Solidity: function removeSentEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveSentEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveSentEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. -// -// Solidity: function removeSubItem(uint256 index) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveSubItem(opts *bind.TransactOpts, index *big.Int) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeSubItem", index) -} - -// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. -// -// Solidity: function removeSubItem(uint256 index) returns() -func (_SwarmMail *SwarmMailSession) RemoveSubItem(index *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveSubItem(&_SwarmMail.TransactOpts, index) -} - -// RemoveSubItem is a paid mutator transaction binding the contract method 0x9673a9e9. -// -// Solidity: function removeSubItem(uint256 index) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveSubItem(index *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveSubItem(&_SwarmMail.TransactOpts, index) -} - -// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. -// -// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() -func (_SwarmMail *SwarmMailTransactor) RemoveUserActiveBid(opts *bind.TransactOpts, requestHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "removeUserActiveBid", requestHash) -} - -// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. -// -// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() -func (_SwarmMail *SwarmMailSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveUserActiveBid(&_SwarmMail.TransactOpts, requestHash) -} - -// RemoveUserActiveBid is a paid mutator transaction binding the contract method 0x0260f912. -// -// Solidity: function removeUserActiveBid(bytes32 requestHash) returns() -func (_SwarmMail *SwarmMailTransactorSession) RemoveUserActiveBid(requestHash [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.RemoveUserActiveBid(&_SwarmMail.TransactOpts, requestHash) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_SwarmMail *SwarmMailTransactor) RenounceOwnership(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "renounceOwnership") -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_SwarmMail *SwarmMailSession) RenounceOwnership() (*types.Transaction, error) { - return _SwarmMail.Contract.RenounceOwnership(&_SwarmMail.TransactOpts) -} - -// RenounceOwnership is a paid mutator transaction binding the contract method 0x715018a6. -// -// Solidity: function renounceOwnership() returns() -func (_SwarmMail *SwarmMailTransactorSession) RenounceOwnership() (*types.Transaction, error) { - return _SwarmMail.Contract.RenounceOwnership(&_SwarmMail.TransactOpts) -} - -// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. -// -// Solidity: function renounceRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactor) RenounceRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "renounceRole", role, account) -} - -// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. -// -// Solidity: function renounceRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.RenounceRole(&_SwarmMail.TransactOpts, role, account) -} - -// RenounceRole is a paid mutator transaction binding the contract method 0x36568abe. -// -// Solidity: function renounceRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactorSession) RenounceRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.RenounceRole(&_SwarmMail.TransactOpts, role, account) -} - -// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. -// -// Solidity: function revokeRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactor) RevokeRole(opts *bind.TransactOpts, role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "revokeRole", role, account) -} - -// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. -// -// Solidity: function revokeRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.RevokeRole(&_SwarmMail.TransactOpts, role, account) -} - -// RevokeRole is a paid mutator transaction binding the contract method 0xd547741f. -// -// Solidity: function revokeRole(bytes32 role, address account) returns() -func (_SwarmMail *SwarmMailTransactorSession) RevokeRole(role [32]byte, account common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.RevokeRole(&_SwarmMail.TransactOpts, role, account) -} - -// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. -// -// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() -func (_SwarmMail *SwarmMailTransactor) SellSub(opts *bind.TransactOpts, requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "sellSub", requestHash, encryptedKeyLocation) -} - -// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. -// -// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() -func (_SwarmMail *SwarmMailSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SellSub(&_SwarmMail.TransactOpts, requestHash, encryptedKeyLocation) -} - -// SellSub is a paid mutator transaction binding the contract method 0x3ca684e3. -// -// Solidity: function sellSub(bytes32 requestHash, bytes32 encryptedKeyLocation) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) SellSub(requestHash [32]byte, encryptedKeyLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SellSub(&_SwarmMail.TransactOpts, requestHash, encryptedKeyLocation) -} - -// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. -// -// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailTransactor) SendEmail(opts *bind.TransactOpts, toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "sendEmail", toAddress, isEncryption, swarmLocation) -} - -// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. -// -// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailSession) SendEmail(toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SendEmail(&_SwarmMail.TransactOpts, toAddress, isEncryption, swarmLocation) -} - -// SendEmail is a paid mutator transaction binding the contract method 0xd2465fab. -// -// Solidity: function sendEmail(address toAddress, bool isEncryption, bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) SendEmail(toAddress common.Address, isEncryption bool, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SendEmail(&_SwarmMail.TransactOpts, toAddress, isEncryption, swarmLocation) -} - -// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. -// -// Solidity: function setFee(uint256 newFee) returns() -func (_SwarmMail *SwarmMailTransactor) SetFee(opts *bind.TransactOpts, newFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "setFee", newFee) -} - -// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. -// -// Solidity: function setFee(uint256 newFee) returns() -func (_SwarmMail *SwarmMailSession) SetFee(newFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.SetFee(&_SwarmMail.TransactOpts, newFee) -} - -// SetFee is a paid mutator transaction binding the contract method 0x69fe0e2d. -// -// Solidity: function setFee(uint256 newFee) returns() -func (_SwarmMail *SwarmMailTransactorSession) SetFee(newFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.SetFee(&_SwarmMail.TransactOpts, newFee) -} - -// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. -// -// Solidity: function setListingFee(uint256 newListingFee) returns() -func (_SwarmMail *SwarmMailTransactor) SetListingFee(opts *bind.TransactOpts, newListingFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "setListingFee", newListingFee) -} - -// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. -// -// Solidity: function setListingFee(uint256 newListingFee) returns() -func (_SwarmMail *SwarmMailSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.SetListingFee(&_SwarmMail.TransactOpts, newListingFee) -} - -// SetListingFee is a paid mutator transaction binding the contract method 0x131dbd09. -// -// Solidity: function setListingFee(uint256 newListingFee) returns() -func (_SwarmMail *SwarmMailTransactorSession) SetListingFee(newListingFee *big.Int) (*types.Transaction, error) { - return _SwarmMail.Contract.SetListingFee(&_SwarmMail.TransactOpts, newListingFee) -} - -// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. -// -// Solidity: function setPortableAddress(address addr) returns() -func (_SwarmMail *SwarmMailTransactor) SetPortableAddress(opts *bind.TransactOpts, addr common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "setPortableAddress", addr) -} - -// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. -// -// Solidity: function setPortableAddress(address addr) returns() -func (_SwarmMail *SwarmMailSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.SetPortableAddress(&_SwarmMail.TransactOpts, addr) -} - -// SetPortableAddress is a paid mutator transaction binding the contract method 0xc6d05aee. -// -// Solidity: function setPortableAddress(address addr) returns() -func (_SwarmMail *SwarmMailTransactorSession) SetPortableAddress(addr common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.SetPortableAddress(&_SwarmMail.TransactOpts, addr) -} - -// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. -// -// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailTransactor) ShareLockerWith(opts *bind.TransactOpts, swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "shareLockerWith", swarmLocation, withAddress) -} - -// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. -// -// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailSession) ShareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.ShareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) -} - -// ShareLockerWith is a paid mutator transaction binding the contract method 0x0071f0c6. -// -// Solidity: function shareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailTransactorSession) ShareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.ShareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) -} - -// SignEmail is a paid mutator transaction binding the contract method 0x87134952. -// -// Solidity: function signEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactor) SignEmail(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "signEmail", swarmLocation) -} - -// SignEmail is a paid mutator transaction binding the contract method 0x87134952. -// -// Solidity: function signEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailSession) SignEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SignEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// SignEmail is a paid mutator transaction binding the contract method 0x87134952. -// -// Solidity: function signEmail(bytes32 swarmLocation) returns() -func (_SwarmMail *SwarmMailTransactorSession) SignEmail(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.SignEmail(&_SwarmMail.TransactOpts, swarmLocation) -} - -// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. -// -// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailTransactor) StoreLocker(opts *bind.TransactOpts, swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "storeLocker", swarmLocation) -} - -// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. -// -// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailSession) StoreLocker(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.StoreLocker(&_SwarmMail.TransactOpts, swarmLocation) -} - -// StoreLocker is a paid mutator transaction binding the contract method 0xda305b20. -// -// Solidity: function storeLocker(bytes32 swarmLocation) payable returns() -func (_SwarmMail *SwarmMailTransactorSession) StoreLocker(swarmLocation [32]byte) (*types.Transaction, error) { - return _SwarmMail.Contract.StoreLocker(&_SwarmMail.TransactOpts, swarmLocation) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_SwarmMail *SwarmMailTransactor) TransferOwnership(opts *bind.TransactOpts, newOwner common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "transferOwnership", newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_SwarmMail *SwarmMailSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.TransferOwnership(&_SwarmMail.TransactOpts, newOwner) -} - -// TransferOwnership is a paid mutator transaction binding the contract method 0xf2fde38b. -// -// Solidity: function transferOwnership(address newOwner) returns() -func (_SwarmMail *SwarmMailTransactorSession) TransferOwnership(newOwner common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.TransferOwnership(&_SwarmMail.TransactOpts, newOwner) -} - -// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. -// -// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailTransactor) UnshareLockerWith(opts *bind.TransactOpts, swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.contract.Transact(opts, "unshareLockerWith", swarmLocation, withAddress) -} - -// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. -// -// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailSession) UnshareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.UnshareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) -} - -// UnshareLockerWith is a paid mutator transaction binding the contract method 0x5daaa285. -// -// Solidity: function unshareLockerWith(bytes32 swarmLocation, address withAddress) returns() -func (_SwarmMail *SwarmMailTransactorSession) UnshareLockerWith(swarmLocation [32]byte, withAddress common.Address) (*types.Transaction, error) { - return _SwarmMail.Contract.UnshareLockerWith(&_SwarmMail.TransactOpts, swarmLocation, withAddress) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_SwarmMail *SwarmMailTransactor) Receive(opts *bind.TransactOpts) (*types.Transaction, error) { - return _SwarmMail.contract.RawTransact(opts, nil) // calldata is disallowed for receive function -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_SwarmMail *SwarmMailSession) Receive() (*types.Transaction, error) { - return _SwarmMail.Contract.Receive(&_SwarmMail.TransactOpts) -} - -// Receive is a paid mutator transaction binding the contract receive function. -// -// Solidity: receive() payable returns() -func (_SwarmMail *SwarmMailTransactorSession) Receive() (*types.Transaction, error) { - return _SwarmMail.Contract.Receive(&_SwarmMail.TransactOpts) -} - -// SwarmMailOwnershipTransferredIterator is returned from FilterOwnershipTransferred and is used to iterate over the raw logs and unpacked data for OwnershipTransferred events raised by the SwarmMail contract. -type SwarmMailOwnershipTransferredIterator struct { - Event *SwarmMailOwnershipTransferred // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *SwarmMailOwnershipTransferredIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(SwarmMailOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(SwarmMailOwnershipTransferred) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *SwarmMailOwnershipTransferredIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *SwarmMailOwnershipTransferredIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// SwarmMailOwnershipTransferred represents a OwnershipTransferred event raised by the SwarmMail contract. -type SwarmMailOwnershipTransferred struct { - PreviousOwner common.Address - NewOwner common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterOwnershipTransferred is a free log retrieval operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_SwarmMail *SwarmMailFilterer) FilterOwnershipTransferred(opts *bind.FilterOpts, previousOwner []common.Address, newOwner []common.Address) (*SwarmMailOwnershipTransferredIterator, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return &SwarmMailOwnershipTransferredIterator{contract: _SwarmMail.contract, event: "OwnershipTransferred", logs: logs, sub: sub}, nil -} - -// WatchOwnershipTransferred is a free log subscription operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_SwarmMail *SwarmMailFilterer) WatchOwnershipTransferred(opts *bind.WatchOpts, sink chan<- *SwarmMailOwnershipTransferred, previousOwner []common.Address, newOwner []common.Address) (event.Subscription, error) { - - var previousOwnerRule []interface{} - for _, previousOwnerItem := range previousOwner { - previousOwnerRule = append(previousOwnerRule, previousOwnerItem) - } - var newOwnerRule []interface{} - for _, newOwnerItem := range newOwner { - newOwnerRule = append(newOwnerRule, newOwnerItem) - } - - logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "OwnershipTransferred", previousOwnerRule, newOwnerRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(SwarmMailOwnershipTransferred) - if err := _SwarmMail.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseOwnershipTransferred is a log parse operation binding the contract event 0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0. -// -// Solidity: event OwnershipTransferred(address indexed previousOwner, address indexed newOwner) -func (_SwarmMail *SwarmMailFilterer) ParseOwnershipTransferred(log types.Log) (*SwarmMailOwnershipTransferred, error) { - event := new(SwarmMailOwnershipTransferred) - if err := _SwarmMail.contract.UnpackLog(event, "OwnershipTransferred", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// SwarmMailRoleAdminChangedIterator is returned from FilterRoleAdminChanged and is used to iterate over the raw logs and unpacked data for RoleAdminChanged events raised by the SwarmMail contract. -type SwarmMailRoleAdminChangedIterator struct { - Event *SwarmMailRoleAdminChanged // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *SwarmMailRoleAdminChangedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleAdminChanged) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleAdminChanged) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *SwarmMailRoleAdminChangedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *SwarmMailRoleAdminChangedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// SwarmMailRoleAdminChanged represents a RoleAdminChanged event raised by the SwarmMail contract. -type SwarmMailRoleAdminChanged struct { - Role [32]byte - PreviousAdminRole [32]byte - NewAdminRole [32]byte - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRoleAdminChanged is a free log retrieval operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. -// -// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) -func (_SwarmMail *SwarmMailFilterer) FilterRoleAdminChanged(opts *bind.FilterOpts, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (*SwarmMailRoleAdminChangedIterator, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var previousAdminRoleRule []interface{} - for _, previousAdminRoleItem := range previousAdminRole { - previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) - } - var newAdminRoleRule []interface{} - for _, newAdminRoleItem := range newAdminRole { - newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) - } - - logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) - if err != nil { - return nil, err - } - return &SwarmMailRoleAdminChangedIterator{contract: _SwarmMail.contract, event: "RoleAdminChanged", logs: logs, sub: sub}, nil -} - -// WatchRoleAdminChanged is a free log subscription operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. -// -// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) -func (_SwarmMail *SwarmMailFilterer) WatchRoleAdminChanged(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleAdminChanged, role [][32]byte, previousAdminRole [][32]byte, newAdminRole [][32]byte) (event.Subscription, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var previousAdminRoleRule []interface{} - for _, previousAdminRoleItem := range previousAdminRole { - previousAdminRoleRule = append(previousAdminRoleRule, previousAdminRoleItem) - } - var newAdminRoleRule []interface{} - for _, newAdminRoleItem := range newAdminRole { - newAdminRoleRule = append(newAdminRoleRule, newAdminRoleItem) - } - - logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleAdminChanged", roleRule, previousAdminRoleRule, newAdminRoleRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(SwarmMailRoleAdminChanged) - if err := _SwarmMail.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRoleAdminChanged is a log parse operation binding the contract event 0xbd79b86ffe0ab8e8776151514217cd7cacd52c909f66475c3af44e129f0b00ff. -// -// Solidity: event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole) -func (_SwarmMail *SwarmMailFilterer) ParseRoleAdminChanged(log types.Log) (*SwarmMailRoleAdminChanged, error) { - event := new(SwarmMailRoleAdminChanged) - if err := _SwarmMail.contract.UnpackLog(event, "RoleAdminChanged", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// SwarmMailRoleGrantedIterator is returned from FilterRoleGranted and is used to iterate over the raw logs and unpacked data for RoleGranted events raised by the SwarmMail contract. -type SwarmMailRoleGrantedIterator struct { - Event *SwarmMailRoleGranted // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *SwarmMailRoleGrantedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleGranted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleGranted) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *SwarmMailRoleGrantedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *SwarmMailRoleGrantedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// SwarmMailRoleGranted represents a RoleGranted event raised by the SwarmMail contract. -type SwarmMailRoleGranted struct { - Role [32]byte - Account common.Address - Sender common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRoleGranted is a free log retrieval operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. -// -// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) FilterRoleGranted(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*SwarmMailRoleGrantedIterator, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var accountRule []interface{} - for _, accountItem := range account { - accountRule = append(accountRule, accountItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - - logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) - if err != nil { - return nil, err - } - return &SwarmMailRoleGrantedIterator{contract: _SwarmMail.contract, event: "RoleGranted", logs: logs, sub: sub}, nil -} - -// WatchRoleGranted is a free log subscription operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. -// -// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) WatchRoleGranted(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleGranted, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var accountRule []interface{} - for _, accountItem := range account { - accountRule = append(accountRule, accountItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - - logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleGranted", roleRule, accountRule, senderRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(SwarmMailRoleGranted) - if err := _SwarmMail.contract.UnpackLog(event, "RoleGranted", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRoleGranted is a log parse operation binding the contract event 0x2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d. -// -// Solidity: event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) ParseRoleGranted(log types.Log) (*SwarmMailRoleGranted, error) { - event := new(SwarmMailRoleGranted) - if err := _SwarmMail.contract.UnpackLog(event, "RoleGranted", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} - -// SwarmMailRoleRevokedIterator is returned from FilterRoleRevoked and is used to iterate over the raw logs and unpacked data for RoleRevoked events raised by the SwarmMail contract. -type SwarmMailRoleRevokedIterator struct { - Event *SwarmMailRoleRevoked // Event containing the contract specifics and raw log - - contract *bind.BoundContract // Generic contract to use for unpacking event data - event string // Event name to use for unpacking event data - - logs chan types.Log // Log channel receiving the found contract events - sub ethereum.Subscription // Subscription for errors, completion and termination - done bool // Whether the subscription completed delivering logs - fail error // Occurred error to stop iteration -} - -// Next advances the iterator to the subsequent event, returning whether there -// are any more events found. In case of a retrieval or parsing error, false is -// returned and Error() can be queried for the exact failure. -func (it *SwarmMailRoleRevokedIterator) Next() bool { - // If the iterator failed, stop iterating - if it.fail != nil { - return false - } - // If the iterator completed, deliver directly whatever's available - if it.done { - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleRevoked) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - default: - return false - } - } - // Iterator still in progress, wait for either a data or an error event - select { - case log := <-it.logs: - it.Event = new(SwarmMailRoleRevoked) - if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { - it.fail = err - return false - } - it.Event.Raw = log - return true - - case err := <-it.sub.Err(): - it.done = true - it.fail = err - return it.Next() - } -} - -// Error returns any retrieval or parsing error occurred during filtering. -func (it *SwarmMailRoleRevokedIterator) Error() error { - return it.fail -} - -// Close terminates the iteration process, releasing any pending underlying -// resources. -func (it *SwarmMailRoleRevokedIterator) Close() error { - it.sub.Unsubscribe() - return nil -} - -// SwarmMailRoleRevoked represents a RoleRevoked event raised by the SwarmMail contract. -type SwarmMailRoleRevoked struct { - Role [32]byte - Account common.Address - Sender common.Address - Raw types.Log // Blockchain specific contextual infos -} - -// FilterRoleRevoked is a free log retrieval operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. -// -// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) FilterRoleRevoked(opts *bind.FilterOpts, role [][32]byte, account []common.Address, sender []common.Address) (*SwarmMailRoleRevokedIterator, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var accountRule []interface{} - for _, accountItem := range account { - accountRule = append(accountRule, accountItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - - logs, sub, err := _SwarmMail.contract.FilterLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) - if err != nil { - return nil, err - } - return &SwarmMailRoleRevokedIterator{contract: _SwarmMail.contract, event: "RoleRevoked", logs: logs, sub: sub}, nil -} - -// WatchRoleRevoked is a free log subscription operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. -// -// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) WatchRoleRevoked(opts *bind.WatchOpts, sink chan<- *SwarmMailRoleRevoked, role [][32]byte, account []common.Address, sender []common.Address) (event.Subscription, error) { - - var roleRule []interface{} - for _, roleItem := range role { - roleRule = append(roleRule, roleItem) - } - var accountRule []interface{} - for _, accountItem := range account { - accountRule = append(accountRule, accountItem) - } - var senderRule []interface{} - for _, senderItem := range sender { - senderRule = append(senderRule, senderItem) - } - - logs, sub, err := _SwarmMail.contract.WatchLogs(opts, "RoleRevoked", roleRule, accountRule, senderRule) - if err != nil { - return nil, err - } - return event.NewSubscription(func(quit <-chan struct{}) error { - defer sub.Unsubscribe() - for { - select { - case log := <-logs: - // New log arrived, parse the event and forward to the user - event := new(SwarmMailRoleRevoked) - if err := _SwarmMail.contract.UnpackLog(event, "RoleRevoked", log); err != nil { - return err - } - event.Raw = log - - select { - case sink <- event: - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - case err := <-sub.Err(): - return err - case <-quit: - return nil - } - } - }), nil -} - -// ParseRoleRevoked is a log parse operation binding the contract event 0xf6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b. -// -// Solidity: event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender) -func (_SwarmMail *SwarmMailFilterer) ParseRoleRevoked(log types.Log) (*SwarmMailRoleRevoked, error) { - event := new(SwarmMailRoleRevoked) - if err := _SwarmMail.contract.UnpackLog(event, "RoleRevoked", log); err != nil { - return nil, err - } - event.Raw = log - return event, nil -} diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 9a7237cb..abcb1b18 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -30,14 +30,12 @@ import ( c "github.com/fairdatasociety/fairOS-dfs/pkg/collection" "github.com/fairdatasociety/fairOS-dfs/pkg/account" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/datahub" "github.com/fairdatasociety/fairOS-dfs/pkg/dir" "github.com/fairdatasociety/fairOS-dfs/pkg/feed" "github.com/fairdatasociety/fairOS-dfs/pkg/file" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" - - SwarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" - "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" "github.com/fairdatasociety/fairOS-dfs/pkg/user" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) @@ -503,7 +501,7 @@ func (a *API) prepareOwnPod(ui *user.Info, podName string) (*pod.Info, error) { } // ListPodInMarketplace -func (a *API) ListPodInMarketplace(sessionId, podName, title, desc, thumbnail string, price uint64, daysValid uint, category [32]byte) error { +func (a *API) ListPodInMarketplace(sessionId, podName, title, desc, thumbnail string, price uint64, daysValid uint16, category [32]byte) error { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -716,7 +714,7 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, } // GetSubscribablePods -func (a *API) GetSubscribablePods(sessionId string) ([]SwarmMail.SwarmMailSub, error) { +func (a *API) GetSubscribablePods(sessionId string) ([]datahub.DataHubSub, error) { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -727,7 +725,7 @@ func (a *API) GetSubscribablePods(sessionId string) ([]SwarmMail.SwarmMailSub, e } // GetSubscribablePods -func (a *API) GetSubsRequests(sessionId string) ([]SwarmMail.SwarmMailSubRequest, error) { +func (a *API) GetSubsRequests(sessionId string) ([]datahub.DataHubSubRequest, error) { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index e65f8766..5e305b92 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -9,14 +9,14 @@ import ( "net/http" "github.com/ethereum/go-ethereum/common" - swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/datahub" "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) // ListPodInMarketplace will save the pod info in the subscriptionManager smart contract with its owner and price // we keep the pod info in the smart contract, with a `list` flag -func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte) error { +func (p *Pod) ListPodInMarketplace(podName, title, desc, thumbnail string, price uint64, daysValid uint16, category, nameHash [32]byte) error { podList, err := p.loadUserPods() if err != nil { // skipcq: TCV-001 return err @@ -102,12 +102,12 @@ func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error { } // GetSubscriptions will query the smart contract and list my subscriptions -func (p *Pod) GetSubscriptions() ([]swarmMail.SwarmMailSubItem, error) { +func (p *Pod) GetSubscriptions() ([]datahub.DataHubSubItem, error) { return p.sm.GetSubscriptions(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) } // GetMarketplace will query the smart contract make the `list` all the pod from the marketplace -func (p *Pod) GetMarketplace() ([]swarmMail.SwarmMailSub, error) { +func (p *Pod) GetMarketplace() ([]datahub.DataHubSub, error) { return p.sm.GetAllSubscribablePods() } @@ -172,6 +172,6 @@ func (p *Pod) OpenSubscribedPodFromReference(reference string, ownerPublicKey *e } // GetSubRequests will get all owners sub requests -func (p *Pod) GetSubRequests() ([]swarmMail.SwarmMailSubRequest, error) { +func (p *Pod) GetSubRequests() ([]datahub.DataHubSubRequest, error) { return p.sm.GetSubRequests(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) } diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index e5544759..84682569 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -10,14 +10,13 @@ import ( "net/http" "time" - "github.com/fairdatasociety/fairOS-dfs/pkg/contracts" - "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" - swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/datahub" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) @@ -50,10 +49,10 @@ type SubscriptionItemInfo struct { } type Client struct { - c *ethclient.Client - putter SubscriptionInfoPutter - getter SubscriptionInfoGetter - swarmMail *swarmMail.SwarmMail + c *ethclient.Client + putter SubscriptionInfoPutter + getter SubscriptionInfoGetter + datahub *datahub.Datahub logger logging.Logger } @@ -66,7 +65,7 @@ type ShareInfo struct { UserAddress string `json:"userAddress"` } -func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { +func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint16, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { info := &SubscriptionItemInfo{ Category: utils.Encode(category[:]), Description: desc, @@ -93,7 +92,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl var a [32]byte copy(a[:], ref) - tx, err := c.swarmMail.ListSub(opts, nameHash, a, new(big.Int).SetUint64(price), category, podAddress, new(big.Int).SetInt64(int64(daysValid))) + tx, err := c.datahub.ListSub(opts, nameHash, a, new(big.Int).SetUint64(price), category, podAddress, daysValid) if err != nil { return err } @@ -113,7 +112,7 @@ func (c *Client) HidePodFromMarketplace(owner common.Address, subHash [32]byte, return err } - tx, err := c.swarmMail.EnableSub(opts, subHash, !hide) + tx, err := c.datahub.EnableSub(opts, subHash, !hide) if err != nil { return err } @@ -127,7 +126,7 @@ func (c *Client) HidePodFromMarketplace(owner common.Address, subHash [32]byte, } func (c *Client) RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error { - item, err := c.swarmMail.GetSubBy(&bind.CallOpts{}, subHash) + item, err := c.datahub.GetSubBy(&bind.CallOpts{}, subHash) if err != nil { return err } @@ -137,7 +136,7 @@ func (c *Client) RequestAccess(subscriber common.Address, subHash, nameHash [32] return err } - tx, err := c.swarmMail.BidSub(opts, subHash, nameHash) + tx, err := c.datahub.BidSub(opts, subHash, nameHash) if err != nil { return err } @@ -173,7 +172,7 @@ func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, request var fixedRef [32]byte copy(fixedRef[:], ref) - tx, err := c.swarmMail.SellSub(opts, requestHash, fixedRef) + tx, err := c.datahub.SellSub(opts, requestHash, fixedRef) if err != nil { return err } @@ -188,7 +187,7 @@ func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, request func (c *Client) GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*ShareInfo, error) { opts := &bind.CallOpts{} - item, err := c.swarmMail.GetSubItemBy(opts, subscriber, subHash) + item, err := c.datahub.GetSubItemBy(opts, subscriber, subHash) if err != nil { return nil, err } @@ -216,7 +215,7 @@ func (c *Client) GetSubscription(subscriber common.Address, subHash, secret [32] func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo, error) { opts := &bind.CallOpts{} - item, err := c.swarmMail.GetSubBy(opts, subHash) + item, err := c.datahub.GetSubBy(opts, subHash) if err != nil { return nil, err } @@ -238,23 +237,23 @@ func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo return info, nil } -func (c *Client) GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) { +func (c *Client) GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) { opts := &bind.CallOpts{} - return c.swarmMail.GetAllSubItems(opts, subscriber) + return c.datahub.GetAllSubItems(opts, subscriber) } -func (c *Client) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { +func (c *Client) GetAllSubscribablePods() ([]datahub.DataHubSub, error) { opts := &bind.CallOpts{} - return c.swarmMail.GetSubs(opts) + return c.datahub.GetSubs(opts) } -func (c *Client) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) { +func (c *Client) GetOwnSubscribablePods(owner common.Address) ([]datahub.DataHubSub, error) { opts := &bind.CallOpts{} - s, err := c.swarmMail.GetSubs(opts) + s, err := c.datahub.GetSubs(opts) if err != nil { return nil, err } - osp := []swarmMail.SwarmMailSub{} + osp := []datahub.DataHubSub{} for _, p := range s { if p.Seller == owner { osp = append(osp, p) @@ -263,14 +262,14 @@ func (c *Client) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.Swarm return osp, nil } -func (c *Client) GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) { +func (c *Client) GetSubRequests(owner common.Address) ([]datahub.DataHubSubRequest, error) { opts := &bind.CallOpts{} - return c.swarmMail.GetSubRequests(opts, owner) + return c.datahub.GetSubRequests(opts, owner) } -func (c *Client) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { +func (c *Client) GetSub(subHash [32]byte) (*datahub.DataHubSub, error) { opts := &bind.CallOpts{} - sub, err := c.swarmMail.GetSubBy(opts, subHash) + sub, err := c.datahub.GetSubBy(opts, subHash) if err != nil { return nil, err } @@ -282,18 +281,18 @@ func New(subConfig *contracts.SubscriptionConfig, logger logging.Logger, getter if err != nil { return nil, fmt.Errorf("dial eth ensm: %w", err) } - logger.Info("SwarmMailAddress : ", subConfig.SwarmMailAddress) - sMail, err := swarmMail.NewSwarmMail(common.HexToAddress(subConfig.SwarmMailAddress), c) + logger.Info("DataHubAddress : ", subConfig.DataHubAddress) + sMail, err := datahub.NewDatahub(common.HexToAddress(subConfig.DataHubAddress), c) if err != nil { return nil, err } return &Client{ - c: c, - getter: getter, - putter: putter, - logger: logger, - swarmMail: sMail, + c: c, + getter: getter, + putter: putter, + logger: logger, + datahub: sMail, }, nil } diff --git a/pkg/subscriptionManager/rpc/mock/rpc.go b/pkg/subscriptionManager/rpc/mock/rpc.go index d893b295..5a3f7edb 100644 --- a/pkg/subscriptionManager/rpc/mock/rpc.go +++ b/pkg/subscriptionManager/rpc/mock/rpc.go @@ -9,21 +9,18 @@ import ( "sync" "time" + "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/datahub" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" goens "github.com/wealdtech/go-ens/v3" - - "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" - - swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" - - "github.com/ethereum/go-ethereum/common" ) type SubscriptionManager struct { lock sync.Mutex - listMap map[string]*swarmMail.SwarmMailSub - subscriptionMap map[string]*swarmMail.SwarmMailSubItem - requestMap map[string]*swarmMail.SwarmMailSubRequest + listMap map[string]*datahub.DataHubSub + subscriptionMap map[string]*datahub.DataHubSubItem + requestMap map[string]*datahub.DataHubSubRequest subPodInfo map[string]*rpc.SubscriptionItemInfo subscribedMap map[string][]byte } @@ -38,20 +35,20 @@ func (s *SubscriptionManager) GetSubscribablePodInfo(subHash [32]byte) (*rpc.Sub // NewMockSubscriptionManager returns a new mock subscriptionManager manager client func NewMockSubscriptionManager() *SubscriptionManager { return &SubscriptionManager{ - listMap: make(map[string]*swarmMail.SwarmMailSub), - subscriptionMap: make(map[string]*swarmMail.SwarmMailSubItem), - requestMap: make(map[string]*swarmMail.SwarmMailSubRequest), + listMap: make(map[string]*datahub.DataHubSub), + subscriptionMap: make(map[string]*datahub.DataHubSubItem), + requestMap: make(map[string]*datahub.DataHubSubRequest), subPodInfo: make(map[string]*rpc.SubscriptionItemInfo), subscribedMap: make(map[string][]byte), } } -func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { +func (s *SubscriptionManager) AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint16, category, nameHash [32]byte, key *ecdsa.PrivateKey) error { subHash, err := goens.NameHash(owner.Hex() + podAddress.String()) if err != nil { return err } - i := &swarmMail.SwarmMailSub{ + i := &datahub.DataHubSub{ SubHash: subHash, FdpSellerNameHash: nameHash, Seller: owner, @@ -103,7 +100,7 @@ func (s *SubscriptionManager) RequestAccess(subscriber common.Address, subHash, if err != nil { return err } - s.requestMap[utils.Encode(reqHash[:])] = &swarmMail.SwarmMailSubRequest{ + s.requestMap[utils.Encode(reqHash[:])] = &datahub.DataHubSubRequest{ FdpBuyerNameHash: nameHash, Buyer: subscriber, SubHash: subHash, @@ -112,11 +109,11 @@ func (s *SubscriptionManager) RequestAccess(subscriber common.Address, subHash, return nil } -func (s *SubscriptionManager) GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) { +func (s *SubscriptionManager) GetSubRequests(owner common.Address) ([]datahub.DataHubSubRequest, error) { s.lock.Lock() defer s.lock.Unlock() - requests := []swarmMail.SwarmMailSubRequest{} + requests := []datahub.DataHubSubRequest{} for _, r := range s.requestMap { sub := s.listMap[utils.Encode(r.SubHash[:])] if sub.Seller == owner { @@ -136,7 +133,7 @@ func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInf return fmt.Errorf("request not available") } - item := &swarmMail.SwarmMailSubItem{ + item := &datahub.DataHubSubItem{ SubHash: i.SubHash, UnlockKeyLocation: [32]byte{}, ValidTill: new(big.Int).SetInt64(time.Now().AddDate(0, 1, 0).Unix()), @@ -159,12 +156,12 @@ func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInf return nil } -func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) { +func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) { s.lock.Lock() defer s.lock.Unlock() subscriberHex := subscriber.Hex() - pods := []swarmMail.SwarmMailSubItem{} + pods := []datahub.DataHubSubItem{} for i, v := range s.subscriptionMap { if strings.HasPrefix(i, subscriberHex) { pods = append(pods, *v) @@ -192,10 +189,10 @@ func (s *SubscriptionManager) GetSubscription(subscriber common.Address, subHash return ip, nil } -func (s *SubscriptionManager) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) { +func (s *SubscriptionManager) GetAllSubscribablePods() ([]datahub.DataHubSub, error) { s.lock.Lock() defer s.lock.Unlock() - pods := []swarmMail.SwarmMailSub{} + pods := []datahub.DataHubSub{} for _, v := range s.listMap { if v.Active { pods = append(pods, *v) @@ -204,11 +201,11 @@ func (s *SubscriptionManager) GetAllSubscribablePods() ([]swarmMail.SwarmMailSub return pods, nil } -func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) { +func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) ([]datahub.DataHubSub, error) { s.lock.Lock() defer s.lock.Unlock() - pods := []swarmMail.SwarmMailSub{} + pods := []datahub.DataHubSub{} for _, v := range s.listMap { if v.Seller == owner { pods = append(pods, *v) @@ -217,7 +214,7 @@ func (s *SubscriptionManager) GetOwnSubscribablePods(owner common.Address) ([]sw return pods, nil } -func (s *SubscriptionManager) GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) { +func (s *SubscriptionManager) GetSub(subHash [32]byte) (*datahub.DataHubSub, error) { s.lock.Lock() defer s.lock.Unlock() i, ok := s.listMap[utils.Encode(subHash[:])] diff --git a/pkg/subscriptionManager/subscriptionManager.go b/pkg/subscriptionManager/subscriptionManager.go index 5a4bde1c..38cfb17e 100644 --- a/pkg/subscriptionManager/subscriptionManager.go +++ b/pkg/subscriptionManager/subscriptionManager.go @@ -3,23 +3,21 @@ package subscriptionManager import ( "crypto/ecdsa" - "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" - - swarmMail "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/smail" - "github.com/ethereum/go-ethereum/common" + "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/datahub" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager/rpc" ) type SubscriptionManager interface { - AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint, category, nameHash [32]byte, key *ecdsa.PrivateKey) error + AddPodToMarketplace(podAddress, owner common.Address, pod, title, desc, thumbnail string, price uint64, daysValid uint16, category, nameHash [32]byte, key *ecdsa.PrivateKey) error HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) - GetSubscriptions(subscriber common.Address) ([]swarmMail.SwarmMailSubItem, error) - GetAllSubscribablePods() ([]swarmMail.SwarmMailSub, error) - GetOwnSubscribablePods(owner common.Address) ([]swarmMail.SwarmMailSub, error) + GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) + GetAllSubscribablePods() ([]datahub.DataHubSub, error) + GetOwnSubscribablePods(owner common.Address) ([]datahub.DataHubSub, error) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) - GetSubRequests(owner common.Address) ([]swarmMail.SwarmMailSubRequest, error) - GetSub(subHash [32]byte) (*swarmMail.SwarmMailSub, error) + GetSubRequests(owner common.Address) ([]datahub.DataHubSubRequest, error) + GetSub(subHash [32]byte) (*datahub.DataHubSub, error) } From e3c77e3110c9489dfae483a05933a58f99e4ded6 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 15 Mar 2023 12:46:22 +0530 Subject: [PATCH 25/48] fix: wasm build --- wasm/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm/main.go b/wasm/main.go index 044cf866..2cfe5d0a 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -140,7 +140,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { subConfig.RPC = subRpc } if subContractAddress != "" { - subConfig.SwarmMailAddress = subContractAddress + subConfig.DataHubAddress = subContractAddress } logger := logging.New(os.Stdout, logrus.DebugLevel) From d730ea66eb66fdf92506d876c2c79a997d9a552c Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 18:39:53 +0530 Subject: [PATCH 26/48] feat: update mode while make, performance improvements --- cmd/dfs-cli/cmd/filesystem.go | 4 --- gomobile/dfs.go | 6 ++-- pkg/api/dir_mkdir.go | 2 +- pkg/api/file_upload.go | 2 +- pkg/api/ws.go | 4 +-- pkg/blockstore/bee/client.go | 2 +- pkg/dfs/fs_api.go | 55 ++++++++++++++++++++++++----------- pkg/dir/chmod_test.go | 6 ++-- pkg/dir/dir_present_test.go | 2 +- pkg/dir/dir_test.go | 2 +- pkg/dir/ls_test.go | 16 +++++----- pkg/dir/mkdir.go | 7 +++-- pkg/dir/mkdir_test.go | 10 +++---- pkg/dir/modify_dir_entry.go | 38 ++++++++---------------- pkg/dir/rename_test.go | 36 +++++++++++------------ pkg/dir/rmdir_test.go | 20 ++++++------- pkg/dir/stat_test.go | 6 ++-- pkg/dir/sync_test.go | 6 ++-- pkg/feed/api.go | 29 ++---------------- pkg/file/IFile.go | 2 +- pkg/file/chmod.go | 3 ++ pkg/file/meta.go | 15 +++------- pkg/file/mock/mock_file.go | 2 +- pkg/file/rename_test.go | 4 +-- pkg/file/stat.go | 53 +++++++-------------------------- pkg/file/upload.go | 7 +++-- pkg/file/upload_test.go | 2 +- pkg/file/writeAt_test.go | 2 +- pkg/pod/fork.go | 4 +-- pkg/test/integration_test.go | 9 ++---- pkg/test/open_test.go | 8 ++--- pkg/test/user_sharing_test.go | 4 +-- wasm/main.go | 4 +-- 33 files changed, 159 insertions(+), 213 deletions(-) diff --git a/cmd/dfs-cli/cmd/filesystem.go b/cmd/dfs-cli/cmd/filesystem.go index ed534786..e4f69132 100644 --- a/cmd/dfs-cli/cmd/filesystem.go +++ b/cmd/dfs-cli/cmd/filesystem.go @@ -122,10 +122,6 @@ func statFileOrDirectory(podName, statElement string) { fmt.Println("Cr. Time : ", time.Unix(crTime, 0).String()) fmt.Println("Mo. Time : ", time.Unix(accTime, 0).String()) fmt.Println("Ac. Time : ", time.Unix(modTime, 0).String()) - for _, b := range resp.Blocks { - blkStr := fmt.Sprintf("0x%s, %s bytes, %s bytes", b.Reference, b.Size, b.CompressedSize) - fmt.Println(blkStr) - } } else { fmt.Println("stat: ", err) return diff --git a/gomobile/dfs.go b/gomobile/dfs.go index 6ea61927..a203e971 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -214,7 +214,7 @@ func DirPresent(podName, dirPath string) (string, error) { } func DirMake(podName, dirPath string) (string, error) { - err := api.Mkdir(podName, dirPath, sessionId) + err := api.Mkdir(podName, dirPath, sessionId, 0) if err != nil { return "", err } @@ -316,12 +316,12 @@ func FileUpload(podName, filePath, dirPath, compression, blockSize string, overw if err != nil { return err } - return api.UploadFile(podName, fileInfo.Name(), sessionId, fileInfo.Size(), f, dirPath, compression, uint32(bs), overwrite) + return api.UploadFile(podName, fileInfo.Name(), sessionId, fileInfo.Size(), f, dirPath, compression, uint32(bs), 0, overwrite) } func BlobUpload(data []byte, podName, fileName, dirPath, compression string, size, blockSize int64, overwrite bool) error { r := bytes.NewReader(data) - return api.UploadFile(podName, fileName, sessionId, size, r, dirPath, compression, uint32(blockSize), overwrite) + return api.UploadFile(podName, fileName, sessionId, size, r, dirPath, compression, uint32(blockSize), 0, overwrite) } func FileDownload(podName, filePath string) ([]byte, error) { diff --git a/pkg/api/dir_mkdir.go b/pkg/api/dir_mkdir.go index 8d3bb2e9..8d16549d 100644 --- a/pkg/api/dir_mkdir.go +++ b/pkg/api/dir_mkdir.go @@ -91,7 +91,7 @@ func (h *Handler) DirectoryMkdirHandler(w http.ResponseWriter, r *http.Request) } // make directory - err = h.dfsAPI.Mkdir(podName, dirToCreateWithPath, sessionId) + err = h.dfsAPI.Mkdir(podName, dirToCreateWithPath, sessionId, 0) if err != nil { if err == dfs.ErrPodNotOpen || err == dfs.ErrUserNotLoggedIn || err == p.ErrInvalidDirectory || diff --git a/pkg/api/file_upload.go b/pkg/api/file_upload.go index 8e7f6543..bec0551a 100644 --- a/pkg/api/file_upload.go +++ b/pkg/api/file_upload.go @@ -170,5 +170,5 @@ func (h *Handler) FileUploadHandler(w http.ResponseWriter, r *http.Request) { func (h *Handler) handleFileUpload(podName, podFileName, sessionId string, fileSize int64, f multipart.File, podPath, compression string, blockSize uint32, overwrite bool) error { defer f.Close() - return h.dfsAPI.UploadFile(podName, podFileName, sessionId, fileSize, f, podPath, compression, blockSize, overwrite) + return h.dfsAPI.UploadFile(podName, podFileName, sessionId, fileSize, f, podPath, compression, blockSize, 0, overwrite) } diff --git a/pkg/api/ws.go b/pkg/api/ws.go index aa87ab52..c24eebfe 100644 --- a/pkg/api/ws.go +++ b/pkg/api/ws.go @@ -693,7 +693,7 @@ func (h *Handler) handleEvents(conn *websocket.Conn) error { respondWithError(res, err) continue } - err = h.dfsAPI.Mkdir(fsReq.PodName, fsReq.DirectoryPath, sessionID) + err = h.dfsAPI.Mkdir(fsReq.PodName, fsReq.DirectoryPath, sessionID, 0) if err != nil { respondWithError(res, err) continue @@ -1076,7 +1076,7 @@ func (h *Handler) handleEvents(conn *websocket.Conn) error { respondWithError(res, err) continue } - err = h.dfsAPI.UploadFile(fsReq.PodName, fileName, sessionID, int64(len(data.Bytes())), data, fsReq.DirPath, compression, uint32(bs), fsReq.Overwrite) + err = h.dfsAPI.UploadFile(fsReq.PodName, fileName, sessionID, int64(len(data.Bytes())), data, fsReq.DirPath, compression, uint32(bs), 0, fsReq.Overwrite) if err != nil { respondWithError(res, err) continue diff --git a/pkg/blockstore/bee/client.go b/pkg/blockstore/bee/client.go index 6ceac069..5303aa52 100644 --- a/pkg/blockstore/bee/client.go +++ b/pkg/blockstore/bee/client.go @@ -231,7 +231,7 @@ func (s *Client) UploadSOC(owner, id, signature string, data []byte) (address [] "reference": addrResp.Reference.String(), "duration": time.Since(to).String(), } - s.logger.WithFields(fields).Log(logrus.DebugLevel, "upload chunk: ") + s.logger.WithFields(fields).Log(logrus.DebugLevel, "upload soc: ") return addrResp.Reference.Bytes(), nil } diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index d8af50a8..e61e94b9 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -20,6 +20,7 @@ import ( "fmt" "io" "path/filepath" + "strings" "github.com/fairdatasociety/fairOS-dfs/pkg/dir" f "github.com/fairdatasociety/fairOS-dfs/pkg/file" @@ -30,7 +31,7 @@ import ( // Mkdir is a controller function which validates if the user is logged-in, // pod is open and calls the make directory function in the dir object. -func (a *API) Mkdir(podName, dirToCreateWithPath, sessionId string) error { +func (a *API) Mkdir(podName, dirToCreateWithPath, sessionId string, mode uint32) error { // get the logged-in user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -43,7 +44,7 @@ func (a *API) Mkdir(podName, dirToCreateWithPath, sessionId string) error { return err } directory := podInfo.GetDirectory() - return directory.MkDir(dirToCreateWithPath, podPassword) + return directory.MkDir(dirToCreateWithPath, podPassword, mode) } // RenameDir is a controller function which validates if the user is logged-in, @@ -137,7 +138,7 @@ func (a *API) ListDir(podName, currentDir, sessionId string) ([]dir.Entry, []f.E // DirectoryStat is a controller function which validates if the user is logged-in, // pod is open and calls the dir object to get the information about the given directory. -func (a *API) DirectoryStat(podName, directoryName, sessionId string) (*dir.Stats, error) { +func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stats, error) { // get the logged-in user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -150,11 +151,23 @@ func (a *API) DirectoryStat(podName, directoryName, sessionId string) (*dir.Stat return nil, err } directory := podInfo.GetDirectory() - ds, err := directory.DirStat(podName, podInfo.GetPodPassword(), directoryName) - if err != nil { - return nil, err + if directoryPath != "/" { + inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(directoryPath)) + + found := false + directoryName := filepath.Base(directoryPath) + for _, name := range inode.FileOrDirNames { + if strings.TrimPrefix(name, "_D_") == directoryName { + found = true + break + } + } + if !found { + return nil, dir.ErrDirectoryNotPresent + } } - return ds, nil + + return directory.DirStat(podName, podInfo.GetPodPassword(), directoryPath) } // DirectoryInode is a controller function which validates if the user is logged-in, @@ -249,18 +262,29 @@ func (a *API) FileStat(podName, podFileWithPath, sessionId string) (*f.Stats, er if err != nil { return nil, err } - file := podInfo.GetFile() - ds, err := file.GetStats(podName, podFileWithPath, podInfo.GetPodPassword()) - if err != nil { - return nil, err + + directory := podInfo.GetDirectory() + inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(podFileWithPath)) + + found := false + fileName := filepath.Base(podFileWithPath) + for _, name := range inode.FileOrDirNames { + if strings.TrimPrefix(name, "_F_") == fileName { + found = true + break + } + } + if !found { + return nil, f.ErrFileNotFound } - return ds, nil + file := podInfo.GetFile() + return file.GetStats(podName, podFileWithPath, podInfo.GetPodPassword()) } // UploadFile is a controller function which validates if the user is logged-in, // // pod is open and calls the upload function. -func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, fd io.Reader, podPath, compression string, blockSize uint32, overwrite bool) error { +func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, fd io.Reader, podPath, compression string, blockSize, mode uint32, overwrite bool) error { // get the logged-in user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -274,11 +298,9 @@ func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, file := podInfo.GetFile() directory := podInfo.GetDirectory() podPath = filepath.ToSlash(podPath) - // check if file exists, then backup the file totalPath := utils.CombinePathAndFile(podPath, podFileName) alreadyPresent := file.IsFileAlreadyPresent(podInfo.GetPodPassword(), totalPath) - if alreadyPresent { if !overwrite { m, err := file.BackupFromFileName(totalPath, podInfo.GetPodPassword()) @@ -295,8 +317,7 @@ func (a *API) UploadFile(podName, podFileName, sessionId string, fileSize int64, return err } } - - err = file.Upload(fd, podFileName, fileSize, blockSize, podPath, compression, podInfo.GetPodPassword()) + err = file.Upload(fd, podFileName, fileSize, blockSize, mode, podPath, compression, podInfo.GetPodPassword()) if err != nil { return err } diff --git a/pkg/dir/chmod_test.go b/pkg/dir/chmod_test.go index a10368c8..ae1e0c9e 100644 --- a/pkg/dir/chmod_test.go +++ b/pkg/dir/chmod_test.go @@ -49,15 +49,15 @@ func TestChmod(t *testing.T) { } // populate the directory with few directory and files - err := dirObject.MkDir("/dirToChmod", podPassword) + err := dirObject.MkDir("/dirToChmod", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToChmod/subDir1", podPassword) + err = dirObject.MkDir("/dirToChmod/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToChmod/subDir2", podPassword) + err = dirObject.MkDir("/dirToChmod/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/dir_present_test.go b/pkg/dir/dir_present_test.go index b636d266..537bd627 100644 --- a/pkg/dir/dir_present_test.go +++ b/pkg/dir/dir_present_test.go @@ -66,7 +66,7 @@ func TestDirPresent(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/baseDir", podPassword) + err := dirObject.MkDir("/baseDir", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/dir_test.go b/pkg/dir/dir_test.go index cc99d0ee..9f84ad6b 100644 --- a/pkg/dir/dir_test.go +++ b/pkg/dir/dir_test.go @@ -50,7 +50,7 @@ func TestDirRmAllFromMap(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/baseDir", podPassword) + err := dirObject.MkDir("/baseDir", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/ls_test.go b/pkg/dir/ls_test.go index 59a36e9c..89a7dd3a 100644 --- a/pkg/dir/ls_test.go +++ b/pkg/dir/ls_test.go @@ -67,7 +67,7 @@ func TestListDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err := dirObject.MkDir("/", podPassword) + err := dirObject.MkDir("/", podPassword, 0) if !errors.Is(err, dir.ErrInvalidDirectoryName) { t.Fatal("invalid dir name", err) } @@ -75,26 +75,26 @@ func TestListDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/"+longDirName, podPassword) + err = dirObject.MkDir("/"+longDirName, podPassword, 0) if !errors.Is(err, dir.ErrTooLongDirectoryName) { t.Fatal("dir name too long") } // create some dir and files - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if !errors.Is(err, dir.ErrDirectoryAlreadyPresent) { t.Fatal("dir already present") } // populate the directory with few directory and files - err = dirObject.MkDir("/parentDir/subDir1", podPassword) + err = dirObject.MkDir("/parentDir/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir2", podPassword) + err = dirObject.MkDir("/parentDir/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } @@ -165,12 +165,12 @@ func TestListDirectory(t *testing.T) { } // create dir - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if err != nil { t.Fatal(err) } // populate the directory with few directory and files - err = dirObject.MkDir("/parentDir/subDir1", podPassword) + err = dirObject.MkDir("/parentDir/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/mkdir.go b/pkg/dir/mkdir.go index 4acb1f1c..92b24087 100644 --- a/pkg/dir/mkdir.go +++ b/pkg/dir/mkdir.go @@ -34,7 +34,7 @@ const ( ) // MkDir -func (d *Directory) MkDir(dirToCreateWithPath, podPassword string) error { +func (d *Directory) MkDir(dirToCreateWithPath, podPassword string, mode uint32) error { parentPath := filepath.ToSlash(filepath.Dir(dirToCreateWithPath)) dirName := filepath.Base(dirToCreateWithPath) @@ -60,6 +60,9 @@ func (d *Directory) MkDir(dirToCreateWithPath, podPassword string) error { return ErrDirectoryAlreadyPresent } + if mode == 0 { + mode = S_IFDIR | defaultMode + } // create the meta data now := time.Now().Unix() meta := MetaData{ @@ -69,7 +72,7 @@ func (d *Directory) MkDir(dirToCreateWithPath, podPassword string) error { CreationTime: now, ModificationTime: now, AccessTime: now, - Mode: S_IFDIR | defaultMode, + Mode: mode, } dirInode := &Inode{ Meta: &meta, diff --git a/pkg/dir/mkdir_test.go b/pkg/dir/mkdir_test.go index d00f034a..e3b25f67 100644 --- a/pkg/dir/mkdir_test.go +++ b/pkg/dir/mkdir_test.go @@ -67,7 +67,7 @@ func TestMkdir(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/baseDir", podPassword) + err := dirObject.MkDir("/baseDir", podPassword, 0) if err != nil { t.Fatal(err) } @@ -96,22 +96,22 @@ func TestMkdir(t *testing.T) { } // try to create a new dir without creating root - err := dirObject.MkDir("/baseDir/baseDir2/baseDir3/baseDir4", podPassword) + err := dirObject.MkDir("/baseDir/baseDir2/baseDir3/baseDir4", podPassword, 0) if err == nil || err != dir.ErrDirectoryNotPresent { t.Fatal(err) } - err = dirObject.MkDir("/baseDir", podPassword) + err = dirObject.MkDir("/baseDir", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/baseDir/baseDir2", podPassword) + err = dirObject.MkDir("/baseDir/baseDir2", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/baseDir/baseDir2/baseDir3", podPassword) + err = dirObject.MkDir("/baseDir/baseDir2/baseDir3", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/modify_dir_entry.go b/pkg/dir/modify_dir_entry.go index ec22fc20..54230026 100644 --- a/pkg/dir/modify_dir_entry.go +++ b/pkg/dir/modify_dir_entry.go @@ -37,24 +37,12 @@ func (d *Directory) AddEntryToDir(parentDir, podPassword, itemToAdd string, isFi return ErrInvalidFileOrDirectoryName } + dirInode := d.GetInode(podPassword, parentDir) // check if parent directory present - if d.GetDirFromDirectoryMap(parentDir) == nil { + if dirInode == nil { return ErrDirectoryNotPresent } - // get the latest meta from swarm - topic := utils.HashString(parentDir) - _, data, err := d.fd.GetFeedData(topic, d.userAddress, []byte(podPassword)) - if err != nil { // skipcq: TCV-001 - return fmt.Errorf("modify dir entry: %v", err) - } - - var dirInode Inode - err = json.Unmarshal(data, &dirInode) - if err != nil { // skipcq: TCV-001 - return fmt.Errorf("modify dir entry : %v", err) - } - // add file or directory entry if isFile { itemToAdd = "_F_" + itemToAdd @@ -65,15 +53,17 @@ func (d *Directory) AddEntryToDir(parentDir, podPassword, itemToAdd string, isFi dirInode.Meta.ModificationTime = time.Now().Unix() // update the feed of the dir and the data structure with the latest info - data, err = json.Marshal(dirInode) + data, err := json.Marshal(dirInode) if err != nil { // skipcq: TCV-001 return fmt.Errorf("modify dir entry : %v", err) } + + topic := utils.HashString(parentDir) _, err = d.fd.UpdateFeed(topic, d.userAddress, data, []byte(podPassword)) if err != nil { // skipcq: TCV-001 return fmt.Errorf("modify dir entry : %v", err) } - d.AddToDirectoryMap(parentDir, &dirInode) + d.AddToDirectoryMap(parentDir, dirInode) return nil } @@ -90,17 +80,13 @@ func (d *Directory) RemoveEntryFromDir(parentDir, podPassword, itemToDelete stri return ErrInvalidFileOrDirectoryName } - parentHash := utils.HashString(parentDir) - _, parentData, err := d.fd.GetFeedData(parentHash, d.userAddress, []byte(podPassword)) - if err != nil { // skipcq: TCV-001 - return err + parentDirInode := d.GetInode(podPassword, parentDir) + // check if parent directory present + if parentDirInode == nil { + return ErrDirectoryNotPresent } - var parentDirInode *Inode - err = json.Unmarshal(parentData, &parentDirInode) - if err != nil { // skipcq: TCV-001 - return err - } + parentHash := utils.HashString(parentDir) if isFile { itemToDelete = "_F_" + itemToDelete @@ -117,7 +103,7 @@ func (d *Directory) RemoveEntryFromDir(parentDir, podPassword, itemToDelete stri parentDirInode.FileOrDirNames = fileNames parentDirInode.Meta.ModificationTime = time.Now().Unix() - parentData, err = json.Marshal(parentDirInode) + parentData, err := json.Marshal(parentDirInode) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/dir/rename_test.go b/pkg/dir/rename_test.go index 174454e3..5789094c 100644 --- a/pkg/dir/rename_test.go +++ b/pkg/dir/rename_test.go @@ -48,7 +48,7 @@ func TestRenameDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err := dirObject.MkDir("/", podPassword) + err := dirObject.MkDir("/", podPassword, 0) if !errors.Is(err, dir.ErrInvalidDirectoryName) { t.Fatal("invalid dir name") } @@ -56,40 +56,40 @@ func TestRenameDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/"+longDirName, podPassword) + err = dirObject.MkDir("/"+longDirName, podPassword, 0) if !errors.Is(err, dir.ErrTooLongDirectoryName) { t.Fatal("dir name too long") } // create some dir and files - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if !errors.Is(err, dir.ErrDirectoryAlreadyPresent) { t.Fatal("dir already present") } // populate the directory with few directory and files - err = dirObject.MkDir("/parentDir/subDir1", podPassword) + err = dirObject.MkDir("/parentDir/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir2", podPassword) + err = dirObject.MkDir("/parentDir/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } r := new(bytes.Buffer) - err = fileObject.Upload(r, "file1", 0, 100, "/parentDir", "", podPassword) + err = fileObject.Upload(r, "file1", 0, 100, 0, "/parentDir", "", podPassword) if err != nil { t.Fatal(err) } - err = fileObject.Upload(r, "file2", 0, 100, "/parentDir", "", podPassword) + err = fileObject.Upload(r, "file2", 0, 100, 0, "/parentDir", "", podPassword) if err != nil { t.Fatal(err) } - err = fileObject.Upload(r, "file2", 0, 100, "/parentDir/subDir2", "", podPassword) + err = fileObject.Upload(r, "file2", 0, 100, 0, "/parentDir/subDir2", "", podPassword) if err != nil { t.Fatal(err) } @@ -119,7 +119,7 @@ func TestRenameDirectory(t *testing.T) { t.Fatal("rename failed for parentDir") } - err = dirObject.MkDir("/parent", podPassword) + err = dirObject.MkDir("/parent", podPassword, 0) if err != nil { t.Fatal(err) } @@ -191,7 +191,7 @@ func TestRenameDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err := dirObject.MkDir("/", podPassword) + err := dirObject.MkDir("/", podPassword, 0) if !errors.Is(err, dir.ErrInvalidDirectoryName) { t.Fatal("invalid dir name") } @@ -199,37 +199,37 @@ func TestRenameDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/"+longDirName, podPassword) + err = dirObject.MkDir("/"+longDirName, podPassword, 0) if !errors.Is(err, dir.ErrTooLongDirectoryName) { t.Fatal("dir name too long") } // create some dir and files - err = dirObject.MkDir("/parentDir", podPassword) + err = dirObject.MkDir("/parentDir", podPassword, 0) if err != nil { t.Fatal(err) } // populate the directory with few directory and files - err = dirObject.MkDir("/parentDir/subDir1", podPassword) + err = dirObject.MkDir("/parentDir/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir1/subDir11", podPassword) + err = dirObject.MkDir("/parentDir/subDir1/subDir11", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir1/subDir11/sub111", podPassword) + err = dirObject.MkDir("/parentDir/subDir1/subDir11/sub111", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir2", podPassword) + err = dirObject.MkDir("/parentDir/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } r := new(bytes.Buffer) - err = fileObject.Upload(r, "file1", 0, 100, "/parentDir/subDir1/subDir11/sub111", "", podPassword) + err = fileObject.Upload(r, "file1", 0, 100, 0, "/parentDir/subDir1/subDir11/sub111", "", podPassword) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/rmdir_test.go b/pkg/dir/rmdir_test.go index b1f517e9..1eb2482e 100644 --- a/pkg/dir/rmdir_test.go +++ b/pkg/dir/rmdir_test.go @@ -69,7 +69,7 @@ func TestRmdir(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/dirToRemove", podPassword) + err := dirObject.MkDir("/dirToRemove", podPassword, 0) if err != nil { t.Fatal(err) } @@ -119,17 +119,17 @@ func TestRmdir(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/dirToRemove1", podPassword) + err := dirObject.MkDir("/dirToRemove1", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword, 0) if err != nil { t.Fatal(err) } @@ -198,17 +198,17 @@ func TestRmRootDirByPath(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/dirToRemove1", podPassword) + err := dirObject.MkDir("/dirToRemove1", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword, 0) if err != nil { t.Fatal(err) } @@ -290,17 +290,17 @@ func TestRmRootDir(t *testing.T) { } // create a new dir - err := dirObject.MkDir("/dirToRemove1", podPassword) + err := dirObject.MkDir("/dirToRemove1", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2", podPassword, 0) if err != nil { t.Fatal(err) } // create a new dir - err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword) + err = dirObject.MkDir("/dirToRemove1/dirToRemove2/dirToRemove", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/stat_test.go b/pkg/dir/stat_test.go index 1bf691fc..c20a772c 100644 --- a/pkg/dir/stat_test.go +++ b/pkg/dir/stat_test.go @@ -68,15 +68,15 @@ func TestStat(t *testing.T) { } // populate the directory with few directory and files - err := dirObject.MkDir("/dirToStat", podPassword) + err := dirObject.MkDir("/dirToStat", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToStat/subDir1", podPassword) + err = dirObject.MkDir("/dirToStat/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToStat/subDir2", podPassword) + err = dirObject.MkDir("/dirToStat/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/dir/sync_test.go b/pkg/dir/sync_test.go index 10ad3ae3..6a0b24b2 100644 --- a/pkg/dir/sync_test.go +++ b/pkg/dir/sync_test.go @@ -70,15 +70,15 @@ func TestSync(t *testing.T) { } // populate the directory with few directory and files - err := dirObject.MkDir("/dirToStat", podPassword) + err := dirObject.MkDir("/dirToStat", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToStat/subDir1", podPassword) + err = dirObject.MkDir("/dirToStat/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/dirToStat/subDir2", podPassword) + err = dirObject.MkDir("/dirToStat/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/feed/api.go b/pkg/feed/api.go index c78a0a85..43f734f5 100644 --- a/pkg/feed/api.go +++ b/pkg/feed/api.go @@ -104,7 +104,6 @@ func (a *API) CreateFeed(topic []byte, user utils.Address, data []byte, encrypti return nil, err } } - // fill Feed and Epoc related details copy(req.ID.Topic[:], topic) req.ID.User = user @@ -119,13 +118,11 @@ func (a *API) CreateFeed(topic []byte, user utils.Address, data []byte, encrypti if err != nil { // skipcq: TCV-001 return nil, err } - // get the payload id BMT(span, payload) payloadId, err := a.handler.getPayloadId(encryptedData) if err != nil { // skipcq: TCV-001 return nil, err } - // create the signer and the content addressed chunk signer := crypto.NewDefaultSigner(a.accountInfo.GetPrivateKey()) ch, err := utils.NewChunkWithSpan(encryptedData) @@ -137,35 +134,26 @@ func (a *API) CreateFeed(topic []byte, user utils.Address, data []byte, encrypti if err != nil { // skipcq: TCV-001 return nil, err } - // generate the data to sign toSignBytes, err := toSignDigest(id, ch.Address().Bytes()) if err != nil { // skipcq: TCV-001 return nil, err } - // sign the chunk signature, err := signer.Sign(toSignBytes) if err != nil { // skipcq: TCV-001 return nil, err } - // set the address and the data for the soc chunk req.idAddr = sch.Address() req.binaryData = sch.Data() - // set signature and binary data fields _, err = a.handler.toChunkContent(&req, id, payloadId) if err != nil { // skipcq: TCV-001 return nil, err } // send the updated soc chunk to bee - address, err := a.handler.update(id, user.ToBytes(), signature, ch.Data()) - if err != nil { // skipcq: TCV-001 - return nil, err - } - - return address, nil + return a.handler.update(id, user.ToBytes(), signature, ch.Data()) } // CreateFeedFromTopic creates a soc with the topic as identifier @@ -302,7 +290,6 @@ func (a *API) UpdateFeed(topic []byte, user utils.Address, data []byte, encrypti return nil, err } } - ctx := context.Background() f := new(Feed) f.User = user @@ -315,19 +302,16 @@ func (a *API) UpdateFeed(topic []byte, user utils.Address, data []byte, encrypti } req.Time = uint64(time.Now().Unix()) req.data = encryptedData - // create the id, hash(topic, epoc) id, err := a.handler.getId(req.Topic, req.Time, req.Level) if err != nil { // skipcq: TCV-001 return nil, err } - // get the payload id BMT(span, payload) payloadId, err := a.handler.getPayloadId(encryptedData) if err != nil { // skipcq: TCV-001 return nil, err } - // create the signer and the content addressed chunk signer := crypto.NewDefaultSigner(a.accountInfo.GetPrivateKey()) ch, err := utils.NewChunkWithSpan(encryptedData) @@ -339,34 +323,25 @@ func (a *API) UpdateFeed(topic []byte, user utils.Address, data []byte, encrypti if err != nil { // skipcq: TCV-001 return nil, err } - // generate the data to sign toSignBytes, err := toSignDigest(id, ch.Address().Bytes()) if err != nil { // skipcq: TCV-001 return nil, err } - // sign the chunk signature, err := signer.Sign(toSignBytes) if err != nil { // skipcq: TCV-001 return nil, err } - // set the address and the data for the soc chunk req.idAddr = sch.Address() req.binaryData = sch.Data() - // set signature and binary data fields _, err = a.handler.toChunkContent(req, id, payloadId) if err != nil { // skipcq: TCV-001 return nil, err } - - address, err := a.handler.update(id, user.ToBytes(), signature, ch.Data()) - if err != nil { // skipcq: TCV-001 - return nil, err - } - return address, nil + return a.handler.update(id, user.ToBytes(), signature, ch.Data()) } // DeleteFeed deleted the feed by updating with no data inside the SOC chunk. diff --git a/pkg/file/IFile.go b/pkg/file/IFile.go index 5f0aebbb..53f5ab38 100644 --- a/pkg/file/IFile.go +++ b/pkg/file/IFile.go @@ -20,7 +20,7 @@ import "io" // IFile type IFile interface { - Upload(fd io.Reader, podFileName string, fileSize int64, blockSize uint32, podPath, compression, podPassword string) error + Upload(fd io.Reader, podFileName string, fileSize int64, blockSize, uint32 uint32, podPath, compression, podPassword string) error Download(podFileWithPath, podPassword string) (io.ReadCloser, uint64, error) ListFiles(files []string, podPassword string) ([]Entry, error) GetStats(podName, podFileWithPath, podPassword string) (*Stats, error) diff --git a/pkg/file/chmod.go b/pkg/file/chmod.go index e430931b..c8def223 100644 --- a/pkg/file/chmod.go +++ b/pkg/file/chmod.go @@ -24,6 +24,9 @@ func (f *File) Chmod(podFileWithPath, podPassword string, mode uint32) error { return ErrFileNotFound } + if meta.Mode == S_IFREG|mode { + return nil + } meta.Mode = S_IFREG | mode meta.AccessTime = time.Now().Unix() diff --git a/pkg/file/meta.go b/pkg/file/meta.go index 8ed54e9b..4fba3a1d 100644 --- a/pkg/file/meta.go +++ b/pkg/file/meta.go @@ -67,14 +67,11 @@ func (f *File) LoadFileMeta(fileNameWithPath, podPassword string) error { func (f *File) handleMeta(meta *MetaData, podPassword string) error { // check if meta is present. - totalPath := utils.CombinePathAndFile(meta.Path, meta.Name) - _, err := f.GetMetaFromFileName(totalPath, podPassword, f.userAddress) + err := f.uploadMeta(meta, podPassword) if err != nil { - if err != ErrDeletedFeed || err != ErrUnknownFeed { - return f.uploadMeta(meta, podPassword) - } + return f.updateMeta(meta, podPassword) } - return f.updateMeta(meta, podPassword) + return nil } func (f *File) uploadMeta(meta *MetaData, podPassword string) error { @@ -88,11 +85,7 @@ func (f *File) uploadMeta(meta *MetaData, podPassword string) error { totalPath := utils.CombinePathAndFile(meta.Path, meta.Name) topic := utils.HashString(totalPath) _, err = f.fd.CreateFeed(topic, f.userAddress, fileMetaBytes, []byte(podPassword)) - if err != nil { // skipcq: TCV-001 - return err - } - - return nil + return err } func (f *File) deleteMeta(meta *MetaData, podPassword string) error { diff --git a/pkg/file/mock/mock_file.go b/pkg/file/mock/mock_file.go index 48ba166b..520c3831 100644 --- a/pkg/file/mock/mock_file.go +++ b/pkg/file/mock/mock_file.go @@ -32,7 +32,7 @@ func NewMockFile() *File { } // Upload -func (*File) Upload(_ io.Reader, _ string, _ int64, _ uint32, _, _, _ string) error { +func (*File) Upload(_ io.Reader, _ string, _ int64, _, _ uint32, _, _, _ string) error { return nil } diff --git a/pkg/file/rename_test.go b/pkg/file/rename_test.go index 93aad583..a28bd180 100644 --- a/pkg/file/rename_test.go +++ b/pkg/file/rename_test.go @@ -119,11 +119,11 @@ func TestRename(t *testing.T) { } // populate the directory with few directory and files - err = dirObject.MkDir(filePath, podPassword) + err = dirObject.MkDir(filePath, podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir(newFilePath, podPassword) + err = dirObject.MkDir(newFilePath, podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/file/stat.go b/pkg/file/stat.go index 1d5b1f4d..5e969099 100644 --- a/pkg/file/stat.go +++ b/pkg/file/stat.go @@ -17,32 +17,22 @@ limitations under the License. package file import ( - "encoding/hex" - "encoding/json" "strconv" ) // Stats type Stats struct { - PodName string `json:"podName"` - Mode uint32 `json:"mode"` - FilePath string `json:"filePath"` - FileName string `json:"fileName"` - FileSize string `json:"fileSize"` - BlockSize string `json:"blockSize"` - Compression string `json:"compression"` - ContentType string `json:"contentType"` - CreationTime string `json:"creationTime"` - ModificationTime string `json:"modificationTime"` - AccessTime string `json:"accessTime"` - Blocks []Blocks `json:"blocks"` -} - -// Blocks -type Blocks struct { - Reference string `json:"reference"` - Size string `json:"size"` - CompressedSize string `json:"compressedSize"` + PodName string `json:"podName"` + Mode uint32 `json:"mode"` + FilePath string `json:"filePath"` + FileName string `json:"fileName"` + FileSize string `json:"fileSize"` + BlockSize string `json:"blockSize"` + Compression string `json:"compression"` + ContentType string `json:"contentType"` + CreationTime string `json:"creationTime"` + ModificationTime string `json:"modificationTime"` + AccessTime string `json:"accessTime"` } // GetStats given a filename this function returns all the information about the file @@ -53,26 +43,6 @@ func (f *File) GetStats(podName, podFileWithPath, podPassword string) (*Stats, e return nil, ErrFileNotFound } - fileInodeBytes, _, err := f.getClient().DownloadBlob(meta.InodeAddress) - if err != nil { // skipcq: TCV-001 - return nil, err - } - - var fileInode INode - err = json.Unmarshal(fileInodeBytes, &fileInode) - if err != nil { // skipcq: TCV-001 - return nil, err - } - - var fileBlocks []Blocks - for _, b := range fileInode.Blocks { - fb := Blocks{ - Reference: hex.EncodeToString(b.Reference.Bytes()), - Size: strconv.Itoa(int(b.Size)), - CompressedSize: strconv.Itoa(int(b.CompressedSize)), - } - fileBlocks = append(fileBlocks, fb) - } f.AddToFileMap(podFileWithPath, meta) return &Stats{ PodName: podName, @@ -86,6 +56,5 @@ func (f *File) GetStats(podName, podFileWithPath, podPassword string) (*Stats, e CreationTime: strconv.FormatInt(meta.CreationTime, 10), ModificationTime: strconv.FormatInt(meta.ModificationTime, 10), AccessTime: strconv.FormatInt(meta.AccessTime, 10), - Blocks: fileBlocks, }, nil } diff --git a/pkg/file/upload.go b/pkg/file/upload.go index 6e0db69c..e9852874 100644 --- a/pkg/file/upload.go +++ b/pkg/file/upload.go @@ -50,7 +50,7 @@ var ( // Upload uploads a given blob of bytes as a file in the pod. It also splits the file into number of blocks. the // size of the block is provided during upload. This function also does compression of the blocks gzip/snappy if it is // requested during the upload. -func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSize uint32, podPath, compression, podPassword string) error { +func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSize, mode uint32, podPath, compression, podPassword string) error { podPath = filepath.ToSlash(podPath) // check compression gzip and blocksize // pgzip does not allow block size lower or equal to 163840, @@ -66,6 +66,9 @@ func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSiz return err } + if mode == 0 { + mode = S_IFREG | defaultMode + } meta := MetaData{ Version: MetaVersion, Path: podPath, @@ -76,7 +79,7 @@ func (f *File) Upload(fd io.Reader, podFileName string, fileSize int64, blockSiz CreationTime: now, AccessTime: now, ModificationTime: now, - Mode: S_IFREG | defaultMode, + Mode: mode, } var totalLength uint64 diff --git a/pkg/file/upload_test.go b/pkg/file/upload_test.go index a43c8669..ee45b377 100644 --- a/pkg/file/upload_test.go +++ b/pkg/file/upload_test.go @@ -358,5 +358,5 @@ func uploadFile(t *testing.T, fileObject *file.File, filePath, fileName, compres } // upload the temp file - return content, fileObject.Upload(f1, fileName, fileSize, blockSize, filePath, compression, podPassword) + return content, fileObject.Upload(f1, fileName, fileSize, blockSize, 0, filePath, compression, podPassword) } diff --git a/pkg/file/writeAt_test.go b/pkg/file/writeAt_test.go index 05f3411b..f2c507da 100644 --- a/pkg/file/writeAt_test.go +++ b/pkg/file/writeAt_test.go @@ -623,5 +623,5 @@ func uploadFileKnownContent(t *testing.T, fileObject *file.File, filePath, fileN t.Fatal(err) } // upload the temp file - return content, fileObject.Upload(f1, fileName, int64(len(content)), blockSize, filePath, compression, podPassword) + return content, fileObject.Upload(f1, fileName, int64(len(content)), blockSize, 0, filePath, compression, podPassword) } diff --git a/pkg/pod/fork.go b/pkg/pod/fork.go index 6be12013..abc51f39 100644 --- a/pkg/pod/fork.go +++ b/pkg/pod/fork.go @@ -113,7 +113,7 @@ func cloneFolder(source, dst *Info, dirNameWithPath string, dirInode *d.Inode) e return err } - err = dst.GetFile().Upload(r, meta.Name, int64(meta.Size), meta.BlockSize, meta.Path, meta.Compression, dst.GetPodPassword()) + err = dst.GetFile().Upload(r, meta.Name, int64(meta.Size), meta.BlockSize, 0, meta.Path, meta.Compression, dst.GetPodPassword()) if err != nil { // skipcq: TCV-001 return err } @@ -126,7 +126,7 @@ func cloneFolder(source, dst *Info, dirNameWithPath string, dirInode *d.Inode) e dirName := strings.TrimPrefix(fileOrDirName, "_D_") path := utils.CombinePathAndFile(dirNameWithPath, dirName) iNode := source.GetDirectory().GetInode(source.GetPodPassword(), path) - err := dst.GetDirectory().MkDir(path, dst.GetPodPassword()) + err := dst.GetDirectory().MkDir(path, dst.GetPodPassword(), 0) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/test/integration_test.go b/pkg/test/integration_test.go index d571657c..c9e03be8 100644 --- a/pkg/test/integration_test.go +++ b/pkg/test/integration_test.go @@ -124,14 +124,13 @@ func TestLiteUser(t *testing.T) { for _, v := range entries { if v.isDir { - - err = dfsApi.Mkdir(podRequest.PodName, v.path, sessionId) + err = dfsApi.Mkdir(podRequest.PodName, v.path, sessionId, 0) if err != nil { t.Fatal(err) } } else { reader := &io.LimitedReader{R: rand.Reader, N: v.size} - err = dfsApi.UploadFile(podRequest.PodName, filepath.Base(v.path), sessionId, v.size, reader, filepath.Dir(v.path), "", 100000, false) + err = dfsApi.UploadFile(podRequest.PodName, filepath.Base(v.path), sessionId, v.size, reader, filepath.Dir(v.path), "", 100000, 0, false) if err != nil { t.Fatal(err) } @@ -142,14 +141,12 @@ func TestLiteUser(t *testing.T) { if v.isDir { _, err := dfsApi.DirectoryStat(podRequest.PodName, v.path, sessionId) if err != nil { - t.Fatal(err) - + t.Fatal("DirectoryStat failed for ", v.path, err) } } else { _, err := dfsApi.FileStat(podRequest.PodName, v.path, sessionId) if err != nil { t.Fatal(err) - } } } diff --git a/pkg/test/open_test.go b/pkg/test/open_test.go index 1d769391..e39bdb47 100644 --- a/pkg/test/open_test.go +++ b/pkg/test/open_test.go @@ -181,13 +181,13 @@ func uploadFile(t *testing.T, fileObject *file.File, filePath, fileName, compres } // upload the temp file - return content, fileObject.Upload(f1, fileName, fileSize, blockSize, filePath, compression, podPassword) + return content, fileObject.Upload(f1, fileName, fileSize, blockSize, 0, filePath, compression, podPassword) } func addFilesAndDirectories(t *testing.T, info *pod.Info, pod1 *pod.Pod, podName1, podPassword string) { t.Helper() dirObject := info.GetDirectory() - err := dirObject.MkDir("/parentDir", podPassword) + err := dirObject.MkDir("/parentDir", podPassword, 0) if err != nil { t.Fatal(err) } @@ -201,11 +201,11 @@ func addFilesAndDirectories(t *testing.T, info *pod.Info, pod1 *pod.Pod, podName } // populate the directory with few directory and files - err = dirObject.MkDir("/parentDir/subDir1", podPassword) + err = dirObject.MkDir("/parentDir/subDir1", podPassword, 0) if err != nil { t.Fatal(err) } - err = dirObject.MkDir("/parentDir/subDir2", podPassword) + err = dirObject.MkDir("/parentDir/subDir2", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/pkg/test/user_sharing_test.go b/pkg/test/user_sharing_test.go index 6e3b9ef0..f5b0530b 100644 --- a/pkg/test/user_sharing_test.go +++ b/pkg/test/user_sharing_test.go @@ -98,7 +98,7 @@ func TestSharing(t *testing.T) { // create dir and file dirObject1 := info1.GetDirectory() - err = dirObject1.MkDir("/parentDir1", podPassword) + err = dirObject1.MkDir("/parentDir1", podPassword, 0) if err != nil { t.Fatal(err) } @@ -135,7 +135,7 @@ func TestSharing(t *testing.T) { // create dir and file dirObject2 := info2.GetDirectory() - err = dirObject2.MkDir("/parentDir2", podPassword) + err = dirObject2.MkDir("/parentDir2", podPassword, 0) if err != nil { t.Fatal(err) } diff --git a/wasm/main.go b/wasm/main.go index 2cfe5d0a..9e58b98e 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -756,7 +756,7 @@ func dirMake(_ js.Value, funcArgs []js.Value) interface{} { dirPath := funcArgs[2].String() go func() { - err := api.Mkdir(podName, dirPath, sessionId) + err := api.Mkdir(podName, dirPath, sessionId, 0) if err != nil { reject.Invoke(fmt.Sprintf("dirMake failed : %s", err.Error())) return @@ -964,7 +964,7 @@ func fileUpload(_ js.Value, funcArgs []js.Value) interface{} { js.CopyBytesToGo(inBuf, array) reader := bytes.NewReader(inBuf) - err := api.UploadFile(podName, fileName, sessionId, int64(size), reader, dirPath, compression, uint32(bs), true) + err := api.UploadFile(podName, fileName, sessionId, int64(size), reader, dirPath, compression, uint32(bs), 0, true) if err != nil { reject.Invoke(fmt.Sprintf("fileUpload failed : %s", err.Error())) return From 11396ca36c7b827f0770f38bca8c89d2d022424c Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 19:19:48 +0530 Subject: [PATCH 27/48] fix: windows test --- pkg/dfs/fs_api.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index e61e94b9..7f410561 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -151,9 +151,12 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat return nil, err } directory := podInfo.GetDirectory() - if directoryPath != "/" { + directoryPath = filepath.ToSlash(filepath.Dir(directoryPath)) + if directoryPath != utils.PathSeparator { inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(directoryPath)) - + if inode == nil { + return nil, dir.ErrDirectoryNotPresent + } found := false directoryName := filepath.Base(directoryPath) for _, name := range inode.FileOrDirNames { From 86bca4f5c1ee13159f420d668ed6ff3c8ae60a8b Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 19:52:34 +0530 Subject: [PATCH 28/48] fix: windows test --- pkg/dfs/fs_api.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 7f410561..1f0053b4 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -265,10 +265,12 @@ func (a *API) FileStat(podName, podFileWithPath, sessionId string) (*f.Stats, er if err != nil { return nil, err } - + podFileWithPath = filepath.ToSlash(podFileWithPath) directory := podInfo.GetDirectory() inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(podFileWithPath)) - + if inode == nil { + return nil, f.ErrFileNotFound + } found := false fileName := filepath.Base(podFileWithPath) for _, name := range inode.FileOrDirNames { From d4c86b9761b5b4d761b2329cd0446cf2b00294a5 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 20:15:42 +0530 Subject: [PATCH 29/48] fix: windows test --- pkg/dfs/fs_api.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 1f0053b4..2949fe98 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -266,22 +266,24 @@ func (a *API) FileStat(podName, podFileWithPath, sessionId string) (*f.Stats, er return nil, err } podFileWithPath = filepath.ToSlash(podFileWithPath) + a.logger.Debugf("file stat: %s", podFileWithPath) directory := podInfo.GetDirectory() + a.logger.Debugf("file stat parent: %s", filepath.Dir(podFileWithPath)) inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(podFileWithPath)) - if inode == nil { - return nil, f.ErrFileNotFound - } - found := false - fileName := filepath.Base(podFileWithPath) - for _, name := range inode.FileOrDirNames { - if strings.TrimPrefix(name, "_F_") == fileName { - found = true - break + if inode != nil { + found := false + fileName := filepath.Base(podFileWithPath) + for _, name := range inode.FileOrDirNames { + if strings.TrimPrefix(name, "_F_") == fileName { + found = true + break + } + } + if !found { + return nil, f.ErrFileNotFound } } - if !found { - return nil, f.ErrFileNotFound - } + file := podInfo.GetFile() return file.GetStats(podName, podFileWithPath, podInfo.GetPodPassword()) } From 1abd2aa47f26748fc510a9988257d062192157c2 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 20:36:02 +0530 Subject: [PATCH 30/48] fix: windows test --- pkg/dfs/fs_api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 2949fe98..103da08a 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -151,10 +151,12 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat return nil, err } directory := podInfo.GetDirectory() - directoryPath = filepath.ToSlash(filepath.Dir(directoryPath)) + directoryPath = filepath.ToSlash(directoryPath) + a.logger.Debugf("directory stat: %s", directoryPath) if directoryPath != utils.PathSeparator { inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(directoryPath)) if inode == nil { + a.logger.Errorf("directory stat: parent directory not present: %s", filepath.Dir(directoryPath)) return nil, dir.ErrDirectoryNotPresent } found := false @@ -166,6 +168,7 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat } } if !found { + a.logger.Errorf("directory stat: directory not present in parent: %s", directoryName) return nil, dir.ErrDirectoryNotPresent } } From 770db4dac66770679ad22a76983f33dffa170991 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 20:46:00 +0530 Subject: [PATCH 31/48] fix: windows test --- pkg/dfs/fs_api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 103da08a..08d8478a 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -152,11 +152,11 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat } directory := podInfo.GetDirectory() directoryPath = filepath.ToSlash(directoryPath) - a.logger.Debugf("directory stat: %s", directoryPath) + fmt.Println("directory stat: ", directoryPath) if directoryPath != utils.PathSeparator { inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(directoryPath)) if inode == nil { - a.logger.Errorf("directory stat: parent directory not present: %s", filepath.Dir(directoryPath)) + fmt.Println("directory stat: parent directory not present: ", filepath.Dir(directoryPath)) return nil, dir.ErrDirectoryNotPresent } found := false @@ -168,7 +168,7 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat } } if !found { - a.logger.Errorf("directory stat: directory not present in parent: %s", directoryName) + fmt.Println("directory stat: directory not present in parent: ", directoryName) return nil, dir.ErrDirectoryNotPresent } } From 601c69dc3b526e0f313af949a4f2f8c304dc1fb8 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 20:59:11 +0530 Subject: [PATCH 32/48] fix: windows test --- pkg/dfs/fs_api.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 08d8478a..219c0722 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -154,9 +154,10 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat directoryPath = filepath.ToSlash(directoryPath) fmt.Println("directory stat: ", directoryPath) if directoryPath != utils.PathSeparator { - inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(directoryPath)) + parent := filepath.ToSlash(filepath.Dir(directoryPath)) + inode := directory.GetInode(podInfo.GetPodPassword(), parent) if inode == nil { - fmt.Println("directory stat: parent directory not present: ", filepath.Dir(directoryPath)) + fmt.Println("directory stat: parent directory not present: ", parent) return nil, dir.ErrDirectoryNotPresent } found := false From 0df5272a02e38b2a93427aa2ddcdf8bcfd5a6d0c Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 16 Mar 2023 21:57:28 +0530 Subject: [PATCH 33/48] fix: cleanup --- pkg/dfs/fs_api.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 219c0722..55b53ff9 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -152,12 +152,10 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat } directory := podInfo.GetDirectory() directoryPath = filepath.ToSlash(directoryPath) - fmt.Println("directory stat: ", directoryPath) if directoryPath != utils.PathSeparator { parent := filepath.ToSlash(filepath.Dir(directoryPath)) inode := directory.GetInode(podInfo.GetPodPassword(), parent) if inode == nil { - fmt.Println("directory stat: parent directory not present: ", parent) return nil, dir.ErrDirectoryNotPresent } found := false @@ -169,7 +167,6 @@ func (a *API) DirectoryStat(podName, directoryPath, sessionId string) (*dir.Stat } } if !found { - fmt.Println("directory stat: directory not present in parent: ", directoryName) return nil, dir.ErrDirectoryNotPresent } } @@ -270,10 +267,8 @@ func (a *API) FileStat(podName, podFileWithPath, sessionId string) (*f.Stats, er return nil, err } podFileWithPath = filepath.ToSlash(podFileWithPath) - a.logger.Debugf("file stat: %s", podFileWithPath) directory := podInfo.GetDirectory() - a.logger.Debugf("file stat parent: %s", filepath.Dir(podFileWithPath)) - inode := directory.GetInode(podInfo.GetPodPassword(), filepath.Dir(podFileWithPath)) + inode := directory.GetInode(podInfo.GetPodPassword(), filepath.ToSlash(filepath.Dir(podFileWithPath))) if inode != nil { found := false fileName := filepath.Base(podFileWithPath) From 3cd151c422db38ad7e87e7ed7608985e2aaca0c9 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 17 Mar 2023 12:39:24 +0530 Subject: [PATCH 34/48] fix: public content-length --- pkg/api/public.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/api/public.go b/pkg/api/public.go index 01f88311..d449d29c 100644 --- a/pkg/api/public.go +++ b/pkg/api/public.go @@ -144,9 +144,7 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques } defer reader.Close() - - sizeString := strconv.FormatUint(size, 10) - w.Header().Set("Content-Length", sizeString) + w.Header().Set("Content-Length", strconv.Itoa(int(size))) w.Header().Set("Content-Type", contentType) if strings.HasPrefix(filePath, "static/") { w.Header().Set("Cache-Control", "public, max-age=31536000") From 3c04a34c0bfe965e4c189aceddc827a1c4f52275 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 17 Mar 2023 15:11:41 +0530 Subject: [PATCH 35/48] fix: test --- pkg/dfs/fs_api.go | 2 +- pkg/dir/modify_dir_entry.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/dfs/fs_api.go b/pkg/dfs/fs_api.go index 55b53ff9..ea1eef51 100644 --- a/pkg/dfs/fs_api.go +++ b/pkg/dfs/fs_api.go @@ -248,7 +248,7 @@ func (a *API) DeleteFile(podName, podFileWithPath, sessionId string) error { } // update the directory by removing the file from it - fileDir := filepath.Dir(podFileWithPath) + fileDir := filepath.ToSlash(filepath.Dir(podFileWithPath)) fileName := filepath.Base(podFileWithPath) return directory.RemoveEntryFromDir(fileDir, podInfo.GetPodPassword(), fileName, true) } diff --git a/pkg/dir/modify_dir_entry.go b/pkg/dir/modify_dir_entry.go index 54230026..a1b64626 100644 --- a/pkg/dir/modify_dir_entry.go +++ b/pkg/dir/modify_dir_entry.go @@ -19,6 +19,7 @@ package dir import ( "encoding/json" "fmt" + "path/filepath" "time" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -79,10 +80,11 @@ func (d *Directory) RemoveEntryFromDir(parentDir, podPassword, itemToDelete stri if itemToDelete == "" { // skipcq: TCV-001 return ErrInvalidFileOrDirectoryName } - + parentDir = filepath.ToSlash(parentDir) parentDirInode := d.GetInode(podPassword, parentDir) // check if parent directory present if parentDirInode == nil { + d.logger.Errorf("remove entry from dir: parent directory not present %s\n", parentDir) return ErrDirectoryNotPresent } From 676cc591486e0ba02f4d71571439e8ee138ac70d Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 17 Mar 2023 18:41:07 +0530 Subject: [PATCH 36/48] fix: return category in subinfo --- pkg/dfs/pod_api.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index abcb1b18..f1c2df74 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -630,6 +630,7 @@ type SubscriptionInfo struct { SubHash [32]byte PodName string PodAddress string + Category string InfoLocation []byte ValidTill int64 } @@ -663,6 +664,7 @@ func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { PodAddress: info.PodAddress, InfoLocation: item.UnlockKeyLocation[:], ValidTill: item.ValidTill.Int64(), + Category: info.Category, } subs = append(subs, sub) } From 3fff0d5b21b2012e75d0133533b904ecf78c0213 Mon Sep 17 00:00:00 2001 From: asabya Date: Sat, 18 Mar 2023 17:27:42 +0530 Subject: [PATCH 37/48] chore: update Datahub contract address --- pkg/contracts/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index ebcec1fc..481e3e38 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -27,7 +27,7 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { } s := &SubscriptionConfig{ - DataHubAddress: "0x43E6403948be1245f8878fE0f429798762A5d3b8", + DataHubAddress: "0x1949beB6CC2db0241Dd625dcaC09891DF5c3756b", } return e, s } From c0d090bf80f21c1ea877136fe73dd236498dff70 Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 20 Mar 2023 09:21:14 +0530 Subject: [PATCH 38/48] fix: mkdir present check --- pkg/dir/mkdir.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/dir/mkdir.go b/pkg/dir/mkdir.go index 92b24087..b84c90ac 100644 --- a/pkg/dir/mkdir.go +++ b/pkg/dir/mkdir.go @@ -52,11 +52,11 @@ func (d *Directory) MkDir(dirToCreateWithPath, podPassword string, mode uint32) topic := utils.HashString(totalPath) // check if parent path exists - if d.GetDirFromDirectoryMap(parentPath) == nil { + if d.GetInode(podPassword, parentPath) == nil { return ErrDirectoryNotPresent } - if d.GetDirFromDirectoryMap(totalPath) != nil { + if d.GetInode(podPassword, totalPath) != nil { return ErrDirectoryAlreadyPresent } From 0be743fb35b21a757413a64e2b4941390742bc35 Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 20 Mar 2023 09:21:46 +0530 Subject: [PATCH 39/48] chore: datahub binding --- pkg/contracts/datahub/Datahub.go | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/pkg/contracts/datahub/Datahub.go b/pkg/contracts/datahub/Datahub.go index a0fdf7e8..e670f854 100644 --- a/pkg/contracts/datahub/Datahub.go +++ b/pkg/contracts/datahub/Datahub.go @@ -71,7 +71,7 @@ type DataHubSubRequest struct { // DatahubMetaData contains all meta data concerning the Datahub contract. var DatahubMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROLE_REPORTER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64[]\",\"name\":\"subIdxs\",\"type\":\"uint64[]\"}],\"internalType\":\"structDataHub.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubByIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getUserStats\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numListedSubs\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"release\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"reportSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROLE_REPORTER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getActiveBidsByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64[]\",\"name\":\"subIdxs\",\"type\":\"uint64[]\"}],\"internalType\":\"structDataHub.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubByIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getUserStats\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numListedSubs\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"release\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"reportSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", } // DatahubABI is the input ABI used to generate the binding from. @@ -406,6 +406,37 @@ func (_Datahub *DatahubCallerSession) GetActiveBids(addr common.Address) ([]Data return _Datahub.Contract.GetActiveBids(&_Datahub.CallOpts, addr) } +// GetActiveBidsByHash is a free data retrieval call binding the contract method 0x2da82643. +// +// Solidity: function getActiveBidsByHash(address addr, bytes32 requestHash) view returns((address,bytes32)) +func (_Datahub *DatahubCaller) GetActiveBidsByHash(opts *bind.CallOpts, addr common.Address, requestHash [32]byte) (DataHubActiveBid, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getActiveBidsByHash", addr, requestHash) + + if err != nil { + return *new(DataHubActiveBid), err + } + + out0 := *abi.ConvertType(out[0], new(DataHubActiveBid)).(*DataHubActiveBid) + + return out0, err + +} + +// GetActiveBidsByHash is a free data retrieval call binding the contract method 0x2da82643. +// +// Solidity: function getActiveBidsByHash(address addr, bytes32 requestHash) view returns((address,bytes32)) +func (_Datahub *DatahubSession) GetActiveBidsByHash(addr common.Address, requestHash [32]byte) (DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBidsByHash(&_Datahub.CallOpts, addr, requestHash) +} + +// GetActiveBidsByHash is a free data retrieval call binding the contract method 0x2da82643. +// +// Solidity: function getActiveBidsByHash(address addr, bytes32 requestHash) view returns((address,bytes32)) +func (_Datahub *DatahubCallerSession) GetActiveBidsByHash(addr common.Address, requestHash [32]byte) (DataHubActiveBid, error) { + return _Datahub.Contract.GetActiveBidsByHash(&_Datahub.CallOpts, addr, requestHash) +} + // GetAllSubItems is a free data retrieval call binding the contract method 0x224b6b8c. // // Solidity: function getAllSubItems(address addr) view returns((bytes32,bytes32,uint256)[]) From a075e13a29cfa2ca140204115cb6293c736416da Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 20 Mar 2023 09:23:37 +0530 Subject: [PATCH 40/48] chore: remove play sunscription config --- pkg/contracts/config.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 481e3e38..3e3378a1 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -34,14 +34,11 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { // PlayConfig defines the configuration for fdp-play func PlayConfig() (*ENSConfig, *SubscriptionConfig) { - s := &SubscriptionConfig{ - DataHubAddress: "0x86072CbFF48dA3C1F01824a6761A03F105BCC697", - } return &ENSConfig{ ChainID: "4020", ENSRegistryAddress: "0xDb56f2e9369E0D7bD191099125a3f6C370F8ed15", FDSRegistrarAddress: "0xA94B7f0465E98609391C623d0560C5720a3f2D33", PublicResolverAddress: "0xFC628dd79137395F3C9744e33b1c5DE554D94882", ProviderDomain: "fds", - }, s + }, nil } From 522a7a8fc65fad5c6d30f92baf0d26ba9621fc8e Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 21 Feb 2023 11:18:39 +0530 Subject: [PATCH 41/48] chore: add basic documentation for gomobile --- gomobile/README.md | 63 +++++++++++++++++++++++++++++++++++++++++++++- gomobile/dfs.go | 4 --- 2 files changed, 62 insertions(+), 5 deletions(-) diff --git a/gomobile/README.md b/gomobile/README.md index ba9affe2..54f551ea 100644 --- a/gomobile/README.md +++ b/gomobile/README.md @@ -1,3 +1,5 @@ +[![Go Reference](https://pkg.go.dev/badge/github.com/fairdatasociety/fairOS-dfs@master/gomobile.svg)](https://pkg.go.dev/github.com/fairdatasociety/fairOS-dfs@master/gomobile) + # gomobile client for fairOS-dfs Now fairOS-dfs can be used as android or @@ -22,7 +24,66 @@ Coming soon ``` ### How to use in android? -Check out this [demo](https://github.com/fairDataSociety/fairOS-dfs-android-demo) + +#### API +``` + + // isConnected checks if dfs.API is already initialised + public static native boolean isConnected(); + + // connect with a bee and initialise dfs.API + public static native void connect(String beeEndpoint, String postageBlockId, String network, String rpc, long logLevel) throws Exception; + + public static native String loginUser(String username, String password) throws Exception; + public static native boolean isUserPresent(String username); + public static native boolean isUserLoggedIn(); + public static native void logoutUser() throws Exception; + public static native String statUser() throws Exception; + + public static native String newPod(String podName) throws Exception; + public static native String podOpen(String podName) throws Exception; + public static native void podClose(String podName) throws Exception; + public static native void podDelete(String podName) throws Exception; + public static native void podSync(String podName) throws Exception; + public static native String podList() throws Exception; + public static native String podStat(String podName) throws Exception; + public static native boolean isPodPresent(String podName); + public static native String podShare(String podName) throws Exception; + public static native String podReceive(String podSharingReference) throws Exception; + public static native String podReceiveInfo(String podSharingReference) throws Exception; + + public static native String dirPresent(String podName, String dirPath) throws Exception; + public static native String dirMake(String podName, String dirPath) throws Exception; + public static native String dirRemove(String podName, String dirPath) throws Exception; + public static native String dirList(String podName, String dirPath) throws Exception; + public static native String dirStat(String podName, String dirPath) throws Exception; + + public static native String fileShare(String podName, String dirPath, String destinationUser) throws Exception; + public static native String fileReceive(String podName, String directory, String fileSharingReference) throws Exception; + public static native String fileReceiveInfo(String podName, String fileSharingReference) throws Exception; + public static native void fileDelete(String podName, String filePath) throws Exception; + public static native String fileStat(String podName, String filePath) throws Exception; + public static native void fileUpload(String podName, String filePath, String dirPath, String compression, String blockSize, boolean overwrite) throws Exception; + public static native void blobUpload(byte[] data, String podName, String filePath, String dirPath, String compression, long size, long blockSize, boolean overwrite) throws Exception; + public static native byte[] fileDownload(String podName, String filePath) throws Exception; + + public static native String version(); + +``` +***Document store and KV store documentation coming soon*** + +#### API flow + +To use the fairOS-dfs in your android app you have to download the `fairos.aar` file from the downloads section + +Before calling any of the functions we need to connect with the swarm through a bee node and initialise fairos dfs API. +For that we call `connect` function with the necessary parameters. + +We follow the normal flow of tasks after that, such as login, list user pods, opening a pod and list files and directories, upload or download content. + +The function names are pretty much self-explanatory. + +Check out this working [demo](https://github.com/fairDataSociety/fairOS-dfs-android-demo). *** The code is not fully tested. Please use [fairOS-dfs](https://github.com/fairDataSociety/fairOS-dfs) for a better experience. diff --git a/gomobile/dfs.go b/gomobile/dfs.go index a203e971..f0d4abfd 100644 --- a/gomobile/dfs.go +++ b/gomobile/dfs.go @@ -94,10 +94,6 @@ func LogoutUser() error { return api.LogoutUser(sessionId) } -func DeleteUser() error { - return api.DeleteUserV2(savedPassword, sessionId) -} - func StatUser() (string, error) { stat, err := api.GetUserStat(sessionId) if err != nil { From 674241640b80e25e1955ff61f92ba6a313fcc37c Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 20 Mar 2023 10:23:20 +0530 Subject: [PATCH 42/48] chore: update dependencies --- go.mod | 36 +++++++++++++-------------- go.sum | 78 ++++++++++++++++++++++++++++++---------------------------- 2 files changed, 58 insertions(+), 56 deletions(-) diff --git a/go.mod b/go.mod index 08f2d8e2..6a74c092 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/btcsuite/btcd v0.22.3 github.com/c-bata/go-prompt v0.2.6 github.com/dustin/go-humanize v1.0.1 - github.com/ethereum/go-ethereum v1.11.1 + github.com/ethereum/go-ethereum v1.11.4 github.com/ethersphere/bee v1.12.0 github.com/ethersphere/bmt v0.1.4 github.com/fairdatasociety/fairOS-dfs-utils v0.0.0-20221230123929-aec4ed8b854d @@ -15,7 +15,7 @@ require ( github.com/gorilla/mux v1.8.0 github.com/gorilla/securecookie v1.1.1 github.com/gorilla/websocket v1.5.0 - github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d + github.com/hashicorp/golang-lru v0.6.0 github.com/klauspost/pgzip v1.2.5 github.com/miguelmota/go-ethereum-hdwallet v0.1.1 github.com/mitchellh/go-homedir v1.1.0 @@ -24,15 +24,15 @@ require ( github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.6.1 github.com/spf13/viper v1.15.0 - github.com/stretchr/testify v1.8.1 - github.com/swaggo/http-swagger v1.3.3 + github.com/stretchr/testify v1.8.2 + github.com/swaggo/http-swagger v1.3.4 github.com/swaggo/swag v1.8.10 github.com/tinygrasshopper/bettercsv v0.0.1 github.com/tyler-smith/go-bip39 v1.1.0 github.com/wealdtech/go-ens/v3 v3.5.5 - go.uber.org/goleak v1.2.0 - golang.org/x/crypto v0.1.0 - golang.org/x/term v0.5.0 + go.uber.org/goleak v1.2.1 + golang.org/x/crypto v0.4.0 + golang.org/x/term v0.6.0 gopkg.in/yaml.v2 v2.4.0 resenje.org/jsonhttp v0.2.0 ) @@ -44,7 +44,7 @@ require ( github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect - github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect @@ -55,10 +55,10 @@ require ( github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect - github.com/ipfs/go-cid v0.2.0 // indirect + github.com/ipfs/go-cid v0.3.2 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/klauspost/compress v1.15.15 // indirect - github.com/klauspost/cpuid/v2 v2.0.11 // indirect + github.com/klauspost/cpuid/v2 v2.2.1 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect @@ -68,11 +68,11 @@ require ( github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect - github.com/multiformats/go-base32 v0.0.4 // indirect - github.com/multiformats/go-base36 v0.1.0 // indirect + github.com/multiformats/go-base32 v0.1.0 // indirect + github.com/multiformats/go-base36 v0.2.0 // indirect github.com/multiformats/go-multibase v0.1.1 // indirect - github.com/multiformats/go-multihash v0.2.0 // indirect - github.com/multiformats/go-varint v0.0.6 // indirect + github.com/multiformats/go-multihash v0.2.1 // indirect + github.com/multiformats/go-varint v0.0.7 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/term v1.2.0-beta.2 // indirect @@ -90,11 +90,11 @@ require ( github.com/tklauser/numcpus v0.4.0 // indirect github.com/wealdtech/go-multicodec v1.4.0 // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - go.uber.org/atomic v1.9.0 // indirect - golang.org/x/net v0.4.0 // indirect - golang.org/x/sys v0.5.0 // indirect + go.uber.org/atomic v1.10.0 // indirect + golang.org/x/net v0.7.0 // indirect + golang.org/x/sys v0.6.0 // indirect golang.org/x/text v0.7.0 // indirect - golang.org/x/tools v0.2.0 // indirect + golang.org/x/tools v0.3.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 340181ad..c79ca2f8 100644 --- a/go.sum +++ b/go.sum @@ -142,9 +142,8 @@ github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vs github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= -github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= @@ -164,8 +163,8 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.10.4/go.mod h1:nEE0TP5MtxGzOMd7egIrbPJMQBnhVU3ELNxhBglIzhg= -github.com/ethereum/go-ethereum v1.11.1 h1:EMymmWFzpS7G9l9NvVN8G73cgdUIqDPNRf2YTSGBXlk= -github.com/ethereum/go-ethereum v1.11.1/go.mod h1:DuefStAgaxoaYGLR0FueVcVbehmn5n9QUcVrMCuOvuc= +github.com/ethereum/go-ethereum v1.11.4 h1:KG81SnUHXWk8LJB3mBcHg/E2yLvXoiPmRMCIRxgx3cE= +github.com/ethereum/go-ethereum v1.11.4/go.mod h1:it7x0DWnTDMfVFdXcU6Ti4KEFQynLHVRarcSlPr0HBo= github.com/ethersphere/bee v1.12.0 h1:dKtaKQXYFSnjB/8g0qlhIc1BVVvKJ1DCTL5NuOtz2mI= github.com/ethersphere/bee v1.12.0/go.mod h1:rm4lICvmvSMQ4EnrPYxZsWFkzMh66XqNOKpj1HSJnA4= github.com/ethersphere/bmt v0.1.4 h1:+rkWYNtMgDx6bkNqGdWu+U9DgGI1rRZplpSW3YhBr1Q= @@ -211,6 +210,7 @@ github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= @@ -298,11 +298,11 @@ github.com/graph-gophers/graphql-go v0.0.0-20201113091052-beb923fada29/go.mod h1 github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4= +github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM= @@ -324,8 +324,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/ipfs/go-cid v0.2.0 h1:01JTiihFq9en9Vz0lc0VDWvZe/uBonGpzo4THP0vcQ0= -github.com/ipfs/go-cid v0.2.0/go.mod h1:P+HXFDF4CVhaVayiEb4wkAy7zBHxBwsJyt0Y5U6MLro= +github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc= +github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw= github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= @@ -354,8 +354,8 @@ github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9 github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.0.11 h1:i2lw1Pm7Yi/4O6XCSyJWqEHI2MDw2FzUK6o/D21xn2A= -github.com/klauspost/cpuid/v2 v2.0.11/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuObKfj5c0PQa7c= +github.com/klauspost/cpuid/v2 v2.2.1 h1:U33DW0aiEj633gHYw3LoDNfkDiYnE5Q8M/TKJn2f2jI= +github.com/klauspost/cpuid/v2 v2.2.1/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/pgzip v1.2.5 h1:qnWYvvKqedOF2ulHpMG72XQol4ILEJ8k2wwRl/Km8oE= @@ -369,6 +369,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -419,16 +420,16 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= -github.com/multiformats/go-base32 v0.0.4 h1:+qMh4a2f37b4xTNs6mqitDinryCI+tfO2dRVMN9mjSE= -github.com/multiformats/go-base32 v0.0.4/go.mod h1:jNLFzjPZtp3aIARHbJRZIaPuspdH0J6q39uUM5pnABM= -github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4= -github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM= +github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE= +github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI= +github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= +github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= github.com/multiformats/go-multibase v0.1.1 h1:3ASCDsuLX8+j4kx58qnJ4YFq/JWTJpCyDW27ztsVTOI= github.com/multiformats/go-multibase v0.1.1/go.mod h1:ZEjHE+IsUrgp5mhlEAYjMtZwK1k4haNkcaPg9aoe1a8= -github.com/multiformats/go-multihash v0.2.0 h1:oytJb9ZA1OUW0r0f9ea18GiaPOo4SXyc7p2movyUuo4= -github.com/multiformats/go-multihash v0.2.0/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= -github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY= -github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= +github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= +github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= +github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= +github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= @@ -481,7 +482,6 @@ github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8u github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/tsdb v0.7.1 h1:YZcsG11NqnK4czYLrWd9mpEuAJIHVQLwdrleYfszMAA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= @@ -540,14 +540,15 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a h1:kAe4YSu0O0UFn1DowNo2MY5p6xzqtJ/wQ7LZynSvGaY= github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= -github.com/swaggo/http-swagger v1.3.3 h1:Hu5Z0L9ssyBLofaama21iYaF2VbWyA8jdohaaCGpHsc= -github.com/swaggo/http-swagger v1.3.3/go.mod h1:sE+4PjD89IxMPm77FnkDz0sdO+p5lbXzrVWT6OTVVGo= +github.com/swaggo/http-swagger v1.3.4 h1:q7t/XLx0n15H1Q9/tk3Y9L4n210XzJF5WtnDX64a5ww= +github.com/swaggo/http-swagger v1.3.4/go.mod h1:9dAh0unqMBAlbp1uE2Uc2mQTxNMU/ha4UbucIg1MFkQ= github.com/swaggo/swag v1.8.10 h1:eExW4bFa52WOjqRzRD58bgWsWfdFJso50lpbeTcmTfo= github.com/swaggo/swag v1.8.10/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk= github.com/syndtr/goleveldb v1.0.1-0.20210305035536-64b5b1c73954/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= @@ -590,10 +591,11 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= +go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -610,8 +612,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU= -golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= +golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= +golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -639,7 +641,6 @@ golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5 h1:2M3HP5CCK1Si9FQhwnzYhXdG6DXeebvUHFpre8QvbyI= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= @@ -652,7 +653,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0 h1:b9gGHsz9/HhJ3HF5DHQytPpuwocVTChQJK3AvoLRD5I= +golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -693,8 +694,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.4.0 h1:Q5QPcMlvfxFTAPV0+07Xz/MpK9NTXu2VDUuy0FeMfaU= -golang.org/x/net v0.4.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -772,14 +773,15 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.5.0 h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -846,8 +848,8 @@ golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= -golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= +golang.org/x/tools v0.3.0 h1:SrNbZl6ECOS1qFzgTdQfWXZM9XBkiA6tkFrH9YSTPHM= +golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 80361a1ef332b2fdc56a226578b5be85805cedbd Mon Sep 17 00:00:00 2001 From: asabya Date: Mon, 20 Mar 2023 12:27:08 +0530 Subject: [PATCH 43/48] chore: update swagger --- pkg/api/public.go | 14 +- swagger/docs.go | 363 +++++++++++++++++++++++++++++++++++++++---- swagger/swagger.json | 363 +++++++++++++++++++++++++++++++++++++++---- swagger/swagger.yaml | 248 ++++++++++++++++++++++++++--- 4 files changed, 900 insertions(+), 88 deletions(-) diff --git a/pkg/api/public.go b/pkg/api/public.go index d449d29c..5c3325eb 100644 --- a/pkg/api/public.go +++ b/pkg/api/public.go @@ -20,12 +20,12 @@ import ( // // @Summary download file from a shared pod // @Description PodReceiveInfoHandler is the api handler to download file from a shared pod -// @Tags pod +// @Tags public // @Accept json // @Produce json // @Param sharingRef query string true "pod sharing reference" // @Param filePath query string true "file location in the pod" -// @Success 200 {object} pod.ShareInfo +// @Success 200 {array} byte // @Failure 400 {object} response // @Failure 500 {object} response // @Router /public-file [get] @@ -94,10 +94,10 @@ func (h *Handler) PublicPodGetFileHandler(w http.ResponseWriter, r *http.Request // // @Summary download file from a shared pod // @Description PublicPodFilePathHandler is the api handler to download file from a shared pod -// @Tags pod +// @Tags public // @Accept json // @Produce json -// @Success 200 {object} pod.ShareInfo +// @Success 200 {array} byte // @Failure 400 {object} response // @Failure 500 {object} response // @Router /public/{ref}/{file} [get] @@ -161,12 +161,12 @@ func (h *Handler) PublicPodFilePathHandler(w http.ResponseWriter, r *http.Reques // // @Summary List directory content // @Description PublicPodGetDirHandler is the api handler to list content of a directory from a public pod -// @Tags pod +// @Tags public // @Accept json // @Produce json // @Param sharingRef query string true "pod sharing reference" // @Param dirPath query string true "dir location in the pod" -// @Success 200 {object} pod.ShareInfo +// @Success 200 {object} ListFileResponse // @Failure 400 {object} response // @Failure 500 {object} response // @Router /public-dir [get] @@ -241,7 +241,7 @@ func (h *Handler) PublicPodGetDirHandler(w http.ResponseWriter, r *http.Request) // @Param sharingRef query string true "pod sharing reference" // @Param tableName query string true "table name" // @Param key query string true "key to look up" -// @Success 200 {object} pod.ShareInfo +// @Success 200 {object} KVResponse // @Failure 400 {object} response // @Failure 500 {object} response // @Router /public-kv [get] diff --git a/swagger/docs.go b/swagger/docs.go index 953b9679..3afcb6de 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -20,6 +20,207 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/public-dir": { + "get": { + "description": "PublicPodGetDirHandler is the api handler to list content of a directory from a public pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "List directory content", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "dir location in the pod", + "name": "dirPath", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.ListFileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public-file": { + "get": { + "description": "PodReceiveInfoHandler is the api handler to download file from a shared pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "download file from a shared pod", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "file location in the pod", + "name": "filePath", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public-kv": { + "get": { + "description": "PublicPodKVEntryGetHandler is the api handler to get key from key value store from a public pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "get key from public pod", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "table name", + "name": "tableName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "key to look up", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.KVResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public/{ref}/{file}": { + "get": { + "description": "PublicPodFilePathHandler is the api handler to download file from a shared pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "download file from a shared pod", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/dir/chmod": { "post": { "description": "DirectoryModeHandler is the api handler to change mode of a directory", @@ -2692,6 +2893,112 @@ const docTemplate = `{ } } }, + "/v1/pod/fork": { + "post": { + "description": "PodForkHandler is the api handler to fork a pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Fork a pod", + "parameters": [ + { + "description": "pod name and user password", + "name": "pod_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.PodForkRequest" + } + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/v1/pod/fork-from-reference": { + "post": { + "description": "PodForkFromReferenceHandler is the api handler to fork a pod from a given sharing reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Fork a pod from sharing reference", + "parameters": [ + { + "description": "pod name and user password", + "name": "pod_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.PodForkFromReferenceRequest" + } + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/ls": { "get": { "description": "PodListHandler is the api handler to list all pods", @@ -3298,7 +3605,7 @@ const docTemplate = `{ "parameters": [ { "type": "string", - "description": "user name", + "description": "username", "name": "userName", "in": "query", "required": true @@ -3494,7 +3801,7 @@ const docTemplate = `{ "summary": "Login User", "parameters": [ { - "description": "user name", + "description": "username", "name": "user_request", "in": "body", "required": true, @@ -3550,7 +3857,7 @@ const docTemplate = `{ "parameters": [ { "type": "string", - "description": "user name", + "description": "username", "name": "userName", "in": "query", "required": true @@ -3587,7 +3894,7 @@ const docTemplate = `{ "summary": "Register New User", "parameters": [ { - "description": "user name", + "description": "username", "name": "user_request", "in": "body", "required": true, @@ -3939,6 +4246,28 @@ const docTemplate = `{ } } }, + "api.PodForkFromReferenceRequest": { + "type": "object", + "properties": { + "forkName": { + "type": "string" + }, + "podSharingReference": { + "type": "string" + } + } + }, + "api.PodForkRequest": { + "type": "object", + "properties": { + "forkName": { + "type": "string" + }, + "podName": { + "type": "string" + } + } + }, "api.PodListResponse": { "type": "object", "properties": { @@ -4219,20 +4548,6 @@ const docTemplate = `{ } } }, - "file.Blocks": { - "type": "object", - "properties": { - "compressedSize": { - "type": "string" - }, - "reference": { - "type": "string" - }, - "size": { - "type": "string" - } - } - }, "file.Entry": { "type": "object", "properties": { @@ -4259,9 +4574,6 @@ const docTemplate = `{ }, "size": { "type": "string" - }, - "tag": { - "type": "integer" } } }, @@ -4274,12 +4586,6 @@ const docTemplate = `{ "blockSize": { "type": "string" }, - "blocks": { - "type": "array", - "items": { - "$ref": "#/definitions/file.Blocks" - } - }, "compression": { "type": "string" }, @@ -4306,9 +4612,6 @@ const docTemplate = `{ }, "podName": { "type": "string" - }, - "tag": { - "type": "integer" } } }, diff --git a/swagger/swagger.json b/swagger/swagger.json index 3a8a544d..ba21d0d3 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -11,6 +11,207 @@ "version": "v0.0.0" }, "paths": { + "/public-dir": { + "get": { + "description": "PublicPodGetDirHandler is the api handler to list content of a directory from a public pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "List directory content", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "dir location in the pod", + "name": "dirPath", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.ListFileResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public-file": { + "get": { + "description": "PodReceiveInfoHandler is the api handler to download file from a shared pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "download file from a shared pod", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "file location in the pod", + "name": "filePath", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public-kv": { + "get": { + "description": "PublicPodKVEntryGetHandler is the api handler to get key from key value store from a public pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "get key from public pod", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "table name", + "name": "tableName", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "key to look up", + "name": "key", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.KVResponse" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/public/{ref}/{file}": { + "get": { + "description": "PublicPodFilePathHandler is the api handler to download file from a shared pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "public" + ], + "summary": "download file from a shared pod", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/dir/chmod": { "post": { "description": "DirectoryModeHandler is the api handler to change mode of a directory", @@ -2683,6 +2884,112 @@ } } }, + "/v1/pod/fork": { + "post": { + "description": "PodForkHandler is the api handler to fork a pod", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Fork a pod", + "parameters": [ + { + "description": "pod name and user password", + "name": "pod_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.PodForkRequest" + } + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, + "/v1/pod/fork-from-reference": { + "post": { + "description": "PodForkFromReferenceHandler is the api handler to fork a pod from a given sharing reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Fork a pod from sharing reference", + "parameters": [ + { + "description": "pod name and user password", + "name": "pod_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/api.PodForkFromReferenceRequest" + } + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/ls": { "get": { "description": "PodListHandler is the api handler to list all pods", @@ -3289,7 +3596,7 @@ "parameters": [ { "type": "string", - "description": "user name", + "description": "username", "name": "userName", "in": "query", "required": true @@ -3485,7 +3792,7 @@ "summary": "Login User", "parameters": [ { - "description": "user name", + "description": "username", "name": "user_request", "in": "body", "required": true, @@ -3541,7 +3848,7 @@ "parameters": [ { "type": "string", - "description": "user name", + "description": "username", "name": "userName", "in": "query", "required": true @@ -3578,7 +3885,7 @@ "summary": "Register New User", "parameters": [ { - "description": "user name", + "description": "username", "name": "user_request", "in": "body", "required": true, @@ -3930,6 +4237,28 @@ } } }, + "api.PodForkFromReferenceRequest": { + "type": "object", + "properties": { + "forkName": { + "type": "string" + }, + "podSharingReference": { + "type": "string" + } + } + }, + "api.PodForkRequest": { + "type": "object", + "properties": { + "forkName": { + "type": "string" + }, + "podName": { + "type": "string" + } + } + }, "api.PodListResponse": { "type": "object", "properties": { @@ -4210,20 +4539,6 @@ } } }, - "file.Blocks": { - "type": "object", - "properties": { - "compressedSize": { - "type": "string" - }, - "reference": { - "type": "string" - }, - "size": { - "type": "string" - } - } - }, "file.Entry": { "type": "object", "properties": { @@ -4250,9 +4565,6 @@ }, "size": { "type": "string" - }, - "tag": { - "type": "integer" } } }, @@ -4265,12 +4577,6 @@ "blockSize": { "type": "string" }, - "blocks": { - "type": "array", - "items": { - "$ref": "#/definitions/file.Blocks" - } - }, "compression": { "type": "string" }, @@ -4297,9 +4603,6 @@ }, "podName": { "type": "string" - }, - "tag": { - "type": "integer" } } }, diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 48fc0b1c..63b7752d 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -200,6 +200,20 @@ definitions: loggedin: type: boolean type: object + api.PodForkFromReferenceRequest: + properties: + forkName: + type: string + podSharingReference: + type: string + type: object + api.PodForkRequest: + properties: + forkName: + type: string + podName: + type: string + type: object api.PodListResponse: properties: pods: @@ -380,15 +394,6 @@ definitions: podName: type: string type: object - file.Blocks: - properties: - compressedSize: - type: string - reference: - type: string - size: - type: string - type: object file.Entry: properties: accessTime: @@ -407,8 +412,6 @@ definitions: type: string size: type: string - tag: - type: integer type: object file.Stats: properties: @@ -416,10 +419,6 @@ definitions: type: string blockSize: type: string - blocks: - items: - $ref: '#/definitions/file.Blocks' - type: array compression: type: string contentType: @@ -438,8 +437,6 @@ definitions: type: string podName: type: string - tag: - type: integer type: object pod.ShareInfo: properties: @@ -491,6 +488,144 @@ info: title: FairOS-dfs server version: v0.0.0 paths: + /public-dir: + get: + consumes: + - application/json + description: PublicPodGetDirHandler is the api handler to list content of a + directory from a public pod + parameters: + - description: pod sharing reference + in: query + name: sharingRef + required: true + type: string + - description: dir location in the pod + in: query + name: dirPath + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api.ListFileResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: List directory content + tags: + - public + /public-file: + get: + consumes: + - application/json + description: PodReceiveInfoHandler is the api handler to download file from + a shared pod + parameters: + - description: pod sharing reference + in: query + name: sharingRef + required: true + type: string + - description: file location in the pod + in: query + name: filePath + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + type: integer + type: array + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: download file from a shared pod + tags: + - public + /public-kv: + get: + consumes: + - application/json + description: PublicPodKVEntryGetHandler is the api handler to get key from key + value store from a public pod + parameters: + - description: pod sharing reference + in: query + name: sharingRef + required: true + type: string + - description: table name + in: query + name: tableName + required: true + type: string + - description: key to look up + in: query + name: key + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api.KVResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: get key from public pod + tags: + - public + /public/{ref}/{file}: + get: + consumes: + - application/json + description: PublicPodFilePathHandler is the api handler to download file from + a shared pod + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + type: integer + type: array + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: download file from a shared pod + tags: + - public /v1/dir/chmod: post: consumes: @@ -2312,6 +2447,77 @@ paths: summary: Delete pod tags: - pod + /v1/pod/fork: + post: + consumes: + - application/json + description: PodForkHandler is the api handler to fork a pod + parameters: + - description: pod name and user password + in: body + name: pod_request + required: true + schema: + $ref: '#/definitions/api.PodForkRequest' + - description: cookie parameter + in: header + name: Cookie + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api.response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: Fork a pod + tags: + - pod + /v1/pod/fork-from-reference: + post: + consumes: + - application/json + description: PodForkFromReferenceHandler is the api handler to fork a pod from + a given sharing reference + parameters: + - description: pod name and user password + in: body + name: pod_request + required: true + schema: + $ref: '#/definitions/api.PodForkFromReferenceRequest' + - description: cookie parameter + in: header + name: Cookie + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/api.response' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: Fork a pod from sharing reference + tags: + - pod /v1/pod/ls: get: consumes: @@ -2711,7 +2917,7 @@ paths: - application/json description: Check if the given user is logged-in parameters: - - description: user name + - description: username in: query name: userName required: true @@ -2841,7 +3047,7 @@ paths: - application/json description: login user with the new ENS based authentication parameters: - - description: user name + - description: username in: body name: user_request required: true @@ -2877,7 +3083,7 @@ paths: get: description: checks if the new user is present in the new ENS based authentication parameters: - - description: user name + - description: username in: query name: userName required: true @@ -2902,7 +3108,7 @@ paths: - application/json description: registers new user with the new ENS based authentication parameters: - - description: user name + - description: username in: body name: user_request required: true From 3ad99d005791b796f8c1b24213685e6c108d5780 Mon Sep 17 00:00:00 2001 From: asabya Date: Tue, 21 Mar 2023 09:50:35 +0530 Subject: [PATCH 44/48] temp fix for loading subscriptions --- pkg/blockstore/bee/client.go | 53 +++++++++++ pkg/blockstore/bee/mock/client.go | 5 + pkg/blockstore/client.go | 1 + pkg/contracts/config.go | 2 +- pkg/contracts/datahub/Datahub.go | 95 ++++++++++++------- pkg/dfs/pod_api.go | 19 +++- pkg/pod/subscription.go | 8 +- pkg/subscriptionManager/rpc/manager.go | 20 ++-- .../subscriptionManager.go | 4 +- wasm/main.go | 7 +- 10 files changed, 155 insertions(+), 59 deletions(-) diff --git a/pkg/blockstore/bee/client.go b/pkg/blockstore/bee/client.go index 5303aa52..f3d67546 100644 --- a/pkg/blockstore/bee/client.go +++ b/pkg/blockstore/bee/client.go @@ -46,6 +46,7 @@ const ( healthUrl = "/health" chunkUploadDownloadUrl = "/chunks" bytesUploadDownloadUrl = "/bytes" + bzzUrl = "/bzz" tagsUrl = "/tags" pinsUrl = "/pins/" _ = pinsUrl @@ -462,6 +463,58 @@ func (s *Client) DownloadBlob(address []byte) ([]byte, int, error) { return respData, response.StatusCode, nil } +// DownloadBzz downloads bzz data from the Swarm network. +func (s *Client) DownloadBzz(address []byte) ([]byte, int, error) { + to := time.Now() + + // return the data if this address is already in cache + addrString := swarm.NewAddress(address).String() + if s.inBlockCache(s.downloadBlockCache, addrString) { + return s.getFromBlockCache(s.downloadBlockCache, addrString), 200, nil + } + + fullUrl := s.url + bzzUrl + "/" + addrString + req, err := http.NewRequest(http.MethodGet, fullUrl, http.NoBody) + if err != nil { + return nil, http.StatusNotFound, err + } + + response, err := s.client.Do(req) + if err != nil { + return nil, http.StatusNotFound, err + } + defer response.Body.Close() + + req.Close = true + + respData, err := io.ReadAll(response.Body) + if err != nil { + return nil, response.StatusCode, errors.New("error downloading blob") + } + + if response.StatusCode != http.StatusOK { + var beeErr *beeError + err = json.Unmarshal(respData, &beeErr) + if err != nil { + return nil, response.StatusCode, errors.New(string(respData)) + } + return nil, response.StatusCode, errors.New(beeErr.Message) + } + + fields := logrus.Fields{ + "reference": addrString, + "size": len(respData), + "duration": time.Since(to).String(), + } + s.logger.WithFields(fields).Log(logrus.DebugLevel, "download blob: ") + + // add the data and ref if it is not in cache + if !s.inBlockCache(s.downloadBlockCache, addrString) { + s.addToBlockCache(s.downloadBlockCache, addrString, respData) + } + return respData, response.StatusCode, nil +} + // DeleteReference unpins a reference so that it will be garbage collected by the Swarm network. func (s *Client) DeleteReference(address []byte) error { // TODO uncomment after unpinning is fixed diff --git a/pkg/blockstore/bee/mock/client.go b/pkg/blockstore/bee/mock/client.go index 44b2c3d5..91965bf6 100644 --- a/pkg/blockstore/bee/mock/client.go +++ b/pkg/blockstore/bee/mock/client.go @@ -132,6 +132,11 @@ func (m *BeeClient) DownloadBlob(address []byte) ([]byte, int, error) { return nil, http.StatusInternalServerError, fmt.Errorf("error downloading data") } +// DownloadBzz downloads bzz data from the Swarm network. +func (m *BeeClient) DownloadBzz(_ []byte) ([]byte, int, error) { + return nil, 0, nil +} + // DeleteReference unpins chunk in swarm func (m *BeeClient) DeleteReference(address []byte) error { m.storerMu.Lock() diff --git a/pkg/blockstore/client.go b/pkg/blockstore/client.go index 83bc28d4..19566eb6 100644 --- a/pkg/blockstore/client.go +++ b/pkg/blockstore/client.go @@ -30,6 +30,7 @@ type Client interface { UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) DownloadChunk(ctx context.Context, address []byte) (data []byte, err error) DownloadBlob(address []byte) (data []byte, respCode int, err error) + DownloadBzz(address []byte) (data []byte, respCode int, err error) DeleteReference(address []byte) error CreateTag(address []byte) (uint32, error) GetTag(tag uint32) (int64, int64, int64, error) diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 3e3378a1..438fcf51 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -27,7 +27,7 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { } s := &SubscriptionConfig{ - DataHubAddress: "0x1949beB6CC2db0241Dd625dcaC09891DF5c3756b", + DataHubAddress: "0xBE41b272e3cDe3aeC8fE4a144C5b7cE71D9e6498", } return e, s } diff --git a/pkg/contracts/datahub/Datahub.go b/pkg/contracts/datahub/Datahub.go index e670f854..7910b61f 100644 --- a/pkg/contracts/datahub/Datahub.go +++ b/pkg/contracts/datahub/Datahub.go @@ -71,7 +71,7 @@ type DataHubSubRequest struct { // DatahubMetaData contains all meta data concerning the Datahub contract. var DatahubMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROLE_REPORTER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getActiveBidsByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64[]\",\"name\":\"subIdxs\",\"type\":\"uint64[]\"}],\"internalType\":\"structDataHub.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubByIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubItemBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getUserStats\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numListedSubs\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"release\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"reportSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"previousAdminRole\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"newAdminRole\",\"type\":\"bytes32\"}],\"name\":\"RoleAdminChanged\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleGranted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"}],\"name\":\"RoleRevoked\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"DEFAULT_ADMIN_ROLE\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ROLE_REPORTER\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"}],\"name\":\"bidSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"}],\"name\":\"enableSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"feesCollected\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fundsTransfer\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getActiveBidAt\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getActiveBids\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getActiveBidsByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.ActiveBid\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getAllSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nameHash\",\"type\":\"bytes32\"}],\"name\":\"getAllSubItemsForNameHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"}],\"name\":\"getCategory\",\"outputs\":[{\"components\":[{\"internalType\":\"uint64[]\",\"name\":\"subIdxs\",\"type\":\"uint64[]\"}],\"internalType\":\"structDataHub.Category\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_fee\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"getFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getListedSubs\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"nameHash\",\"type\":\"bytes32\"}],\"name\":\"getNameHashSubItems\",\"outputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"\",\"type\":\"bytes32[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getPortableAddress\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"}],\"name\":\"getRoleAdmin\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubBy\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubByIndex\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"forAddress\",\"type\":\"address\"}],\"name\":\"getSubInfoBalance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubItemAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"start\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"length\",\"type\":\"uint256\"}],\"name\":\"getSubItems\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"unlockKeyLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"validTill\",\"type\":\"uint256\"}],\"internalType\":\"structDataHub.SubItem[]\",\"name\":\"items\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"last\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"index\",\"type\":\"uint256\"}],\"name\":\"getSubRequestAt\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"getSubRequestByHash\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getSubRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fdpBuyerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"buyer\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"internalType\":\"structDataHub.SubRequest[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"getSubSubscribers\",\"outputs\":[{\"internalType\":\"address[]\",\"name\":\"\",\"type\":\"address[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getSubs\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"internalType\":\"structDataHub.Sub[]\",\"name\":\"\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"getUserStats\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"numSubRequests\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numSubItems\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numActiveBids\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"numListedSubs\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"grantRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"hasRole\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"inEscrow\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"dataSwarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bytes32\",\"name\":\"category\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"podAddress\",\"type\":\"address\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"name\":\"listSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"marketFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"minListingFee\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"release\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"}],\"name\":\"removeUserActiveBid\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"renounceRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"}],\"name\":\"reportSub\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"role\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"revokeRole\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"requestHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"encryptedKeyLocation\",\"type\":\"bytes32\"}],\"name\":\"sellSub\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newFee\",\"type\":\"uint256\"}],\"name\":\"setFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"newListingFee\",\"type\":\"uint256\"}],\"name\":\"setListingFee\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"addr\",\"type\":\"address\"}],\"name\":\"setPortableAddress\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"subscriptionIds\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"name\":\"subscriptions\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"subHash\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"fdpSellerNameHash\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"seller\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"swarmLocation\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"price\",\"type\":\"uint256\"},{\"internalType\":\"bool\",\"name\":\"active\",\"type\":\"bool\"},{\"internalType\":\"uint256\",\"name\":\"earned\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"bids\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"sells\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"reports\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"daysValid\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"stateMutability\":\"payable\",\"type\":\"receive\"}]", } // DatahubABI is the input ABI used to generate the binding from. @@ -468,6 +468,37 @@ func (_Datahub *DatahubCallerSession) GetAllSubItems(addr common.Address) ([]Dat return _Datahub.Contract.GetAllSubItems(&_Datahub.CallOpts, addr) } +// GetAllSubItemsForNameHash is a free data retrieval call binding the contract method 0xb62fe12f. +// +// Solidity: function getAllSubItemsForNameHash(bytes32 nameHash) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubCaller) GetAllSubItemsForNameHash(opts *bind.CallOpts, nameHash [32]byte) ([]DataHubSubItem, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getAllSubItemsForNameHash", nameHash) + + if err != nil { + return *new([]DataHubSubItem), err + } + + out0 := *abi.ConvertType(out[0], new([]DataHubSubItem)).(*[]DataHubSubItem) + + return out0, err + +} + +// GetAllSubItemsForNameHash is a free data retrieval call binding the contract method 0xb62fe12f. +// +// Solidity: function getAllSubItemsForNameHash(bytes32 nameHash) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubSession) GetAllSubItemsForNameHash(nameHash [32]byte) ([]DataHubSubItem, error) { + return _Datahub.Contract.GetAllSubItemsForNameHash(&_Datahub.CallOpts, nameHash) +} + +// GetAllSubItemsForNameHash is a free data retrieval call binding the contract method 0xb62fe12f. +// +// Solidity: function getAllSubItemsForNameHash(bytes32 nameHash) view returns((bytes32,bytes32,uint256)[]) +func (_Datahub *DatahubCallerSession) GetAllSubItemsForNameHash(nameHash [32]byte) ([]DataHubSubItem, error) { + return _Datahub.Contract.GetAllSubItemsForNameHash(&_Datahub.CallOpts, nameHash) +} + // GetCategory is a free data retrieval call binding the contract method 0x473b084c. // // Solidity: function getCategory(bytes32 category) view returns((uint64[])) @@ -561,6 +592,37 @@ func (_Datahub *DatahubCallerSession) GetListedSubs(addr common.Address) ([][32] return _Datahub.Contract.GetListedSubs(&_Datahub.CallOpts, addr) } +// GetNameHashSubItems is a free data retrieval call binding the contract method 0x2c3ca35a. +// +// Solidity: function getNameHashSubItems(bytes32 nameHash) view returns(bytes32[]) +func (_Datahub *DatahubCaller) GetNameHashSubItems(opts *bind.CallOpts, nameHash [32]byte) ([][32]byte, error) { + var out []interface{} + err := _Datahub.contract.Call(opts, &out, "getNameHashSubItems", nameHash) + + if err != nil { + return *new([][32]byte), err + } + + out0 := *abi.ConvertType(out[0], new([][32]byte)).(*[][32]byte) + + return out0, err + +} + +// GetNameHashSubItems is a free data retrieval call binding the contract method 0x2c3ca35a. +// +// Solidity: function getNameHashSubItems(bytes32 nameHash) view returns(bytes32[]) +func (_Datahub *DatahubSession) GetNameHashSubItems(nameHash [32]byte) ([][32]byte, error) { + return _Datahub.Contract.GetNameHashSubItems(&_Datahub.CallOpts, nameHash) +} + +// GetNameHashSubItems is a free data retrieval call binding the contract method 0x2c3ca35a. +// +// Solidity: function getNameHashSubItems(bytes32 nameHash) view returns(bytes32[]) +func (_Datahub *DatahubCallerSession) GetNameHashSubItems(nameHash [32]byte) ([][32]byte, error) { + return _Datahub.Contract.GetNameHashSubItems(&_Datahub.CallOpts, nameHash) +} + // GetPortableAddress is a free data retrieval call binding the contract method 0xc3b4dde9. // // Solidity: function getPortableAddress(address addr) view returns(address) @@ -747,37 +809,6 @@ func (_Datahub *DatahubCallerSession) GetSubItemAt(addr common.Address, index *b return _Datahub.Contract.GetSubItemAt(&_Datahub.CallOpts, addr, index) } -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_Datahub *DatahubCaller) GetSubItemBy(opts *bind.CallOpts, addr common.Address, subHash [32]byte) (DataHubSubItem, error) { - var out []interface{} - err := _Datahub.contract.Call(opts, &out, "getSubItemBy", addr, subHash) - - if err != nil { - return *new(DataHubSubItem), err - } - - out0 := *abi.ConvertType(out[0], new(DataHubSubItem)).(*DataHubSubItem) - - return out0, err - -} - -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_Datahub *DatahubSession) GetSubItemBy(addr common.Address, subHash [32]byte) (DataHubSubItem, error) { - return _Datahub.Contract.GetSubItemBy(&_Datahub.CallOpts, addr, subHash) -} - -// GetSubItemBy is a free data retrieval call binding the contract method 0x9aad57bb. -// -// Solidity: function getSubItemBy(address addr, bytes32 subHash) view returns((bytes32,bytes32,uint256)) -func (_Datahub *DatahubCallerSession) GetSubItemBy(addr common.Address, subHash [32]byte) (DataHubSubItem, error) { - return _Datahub.Contract.GetSubItemBy(&_Datahub.CallOpts, addr, subHash) -} - // GetSubItems is a free data retrieval call binding the contract method 0xd3fbc74c. // // Solidity: function getSubItems(address addr, uint256 start, uint256 length) view returns((bytes32,bytes32,uint256)[] items, uint256 last) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index f1c2df74..1cd0c314 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -647,7 +647,12 @@ func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { return nil, errNilSubManager } - subscriptions, err := ui.GetPod().GetSubscriptions() + nameHash, err := a.users.GetNameHash(ui.GetAccount().GetUserAccountInfo().GetAddress().Hex()) + if err != nil { + return nil, err + } + + subscriptions, err := ui.GetPod().GetSubscriptions(nameHash) if err != nil { return nil, err } @@ -683,13 +688,15 @@ func (a *API) GetSubscribablePodInfo(sessionId string, subHash [32]byte) (*rpc.S } // OpenSubscribedPod -func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, error) { +func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation string) (*pod.Info, error) { sub, err := a.sm.GetSub(subHash) if err != nil { return nil, err } + subHasshString := utils.Encode(subHash[:]) + _, ownerPublicKey, err := a.users.GetUserInfoFromENS(sub.FdpSellerNameHash) if err != nil { return nil, err @@ -701,8 +708,12 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, return nil, ErrUserNotLoggedIn } + swarmAddr, err := hex.DecodeString(infoLocation) + if err != nil { + return nil, err + } // open the pod - pi, err := ui.GetPod().OpenSubscribedPod(subHash, ownerPublicKey) + pi, err := ui.GetPod().OpenSubscribedPod(swarmAddr, ownerPublicKey) if err != nil { return nil, err } @@ -711,7 +722,7 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte) (*pod.Info, return nil, err } // Add podName in the login user session - ui.AddPodName(pi.GetPodName(), pi) + ui.AddPodName("0x"+subHasshString, pi) return pi, nil } diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index 5e305b92..3fd4be9d 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -102,8 +102,8 @@ func (p *Pod) RequestSubscription(subHash, nameHash [32]byte) error { } // GetSubscriptions will query the smart contract and list my subscriptions -func (p *Pod) GetSubscriptions() ([]datahub.DataHubSubItem, error) { - return p.sm.GetSubscriptions(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex())) +func (p *Pod) GetSubscriptions(nameHash [32]byte) ([]datahub.DataHubSubItem, error) { + return p.sm.GetSubscriptions(nameHash) } // GetMarketplace will query the smart contract make the `list` all the pod from the marketplace @@ -117,10 +117,10 @@ func (p *Pod) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInf } // OpenSubscribedPod will open a subscribed pod -func (p *Pod) OpenSubscribedPod(subHash [32]byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { +func (p *Pod) OpenSubscribedPod(infoLocation []byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) secret := sha256.Sum256(a.Bytes()) - info, err := p.sm.GetSubscription(common.HexToAddress(p.acc.GetUserAccountInfo().GetAddress().Hex()), subHash, secret) + info, err := p.sm.GetSubscription(infoLocation, secret) if err != nil { return nil, err } diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 84682569..2b5fd38d 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -35,12 +35,13 @@ type SubscriptionInfoPutter interface { type SubscriptionInfoGetter interface { DownloadBlob(address []byte) (data []byte, respCode int, err error) + DownloadBzz(address []byte) (data []byte, respCode int, err error) } type SubscriptionItemInfo struct { Category string `json:"category"` Description string `json:"description"` - FdpSellerNameHash string `json:"fdpSellerNameHash"` + FdpSellerNameHash string `json:"sellerNameHash"` ImageURL string `json:"imageUrl"` PodAddress string `json:"podAddress"` PodName string `json:"podName"` @@ -185,13 +186,8 @@ func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, request return nil } -func (c *Client) GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*ShareInfo, error) { - opts := &bind.CallOpts{} - item, err := c.datahub.GetSubItemBy(opts, subscriber, subHash) - if err != nil { - return nil, err - } - encData, resp, err := c.getter.DownloadBlob(item.UnlockKeyLocation[:]) +func (c *Client) GetSubscription(infoLocation []byte, secret [32]byte) (*ShareInfo, error) { + encData, resp, err := c.getter.DownloadBlob(infoLocation[:]) if err != nil { // skipcq: TCV-001 return nil, err } @@ -219,8 +215,7 @@ func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo if err != nil { return nil, err } - - data, respCode, err := c.getter.DownloadBlob(item.SwarmLocation[:]) + data, respCode, err := c.getter.DownloadBzz(item.SwarmLocation[:]) if err != nil { // skipcq: TCV-001 return nil, err } @@ -233,13 +228,12 @@ func (c *Client) GetSubscribablePodInfo(subHash [32]byte) (*SubscriptionItemInfo if err != nil { // skipcq: TCV-001 return nil, err } - return info, nil } -func (c *Client) GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) { +func (c *Client) GetSubscriptions(nameHash [32]byte) ([]datahub.DataHubSubItem, error) { opts := &bind.CallOpts{} - return c.datahub.GetAllSubItems(opts, subscriber) + return c.datahub.GetAllSubItemsForNameHash(opts, nameHash) } func (c *Client) GetAllSubscribablePods() ([]datahub.DataHubSub, error) { diff --git a/pkg/subscriptionManager/subscriptionManager.go b/pkg/subscriptionManager/subscriptionManager.go index 38cfb17e..a25c8782 100644 --- a/pkg/subscriptionManager/subscriptionManager.go +++ b/pkg/subscriptionManager/subscriptionManager.go @@ -13,8 +13,8 @@ type SubscriptionManager interface { HidePodFromMarketplace(owner common.Address, subHash [32]byte, hide bool, key *ecdsa.PrivateKey) error RequestAccess(subscriber common.Address, subHash, nameHash [32]byte, key *ecdsa.PrivateKey) error AllowAccess(owner common.Address, si *rpc.ShareInfo, requestHash, secret [32]byte, key *ecdsa.PrivateKey) error - GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) - GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) + GetSubscription(infoLocation []byte, secret [32]byte) (*rpc.ShareInfo, error) + GetSubscriptions(nameHash [32]byte) ([]datahub.DataHubSubItem, error) GetAllSubscribablePods() ([]datahub.DataHubSub, error) GetOwnSubscribablePods(owner common.Address) ([]datahub.DataHubSub, error) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInfo, error) diff --git a/wasm/main.go b/wasm/main.go index 9e58b98e..445b288a 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -2020,12 +2020,13 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { resolve := args[0] reject := args[1] - if len(funcArgs) != 2 { - reject.Invoke("not enough arguments. \"openSubscribedPod(sessionId, subHash)\"") + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"openSubscribedPod(sessionId, subHash, keyLocation)\"") return nil } sessionId := funcArgs[0].String() subHashStr := funcArgs[1].String() + keyLocation := funcArgs[2].String() subHash, err := utils.Decode(subHashStr) if err != nil { @@ -2037,7 +2038,7 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { copy(s[:], subHash) go func() { - pi, err := api.OpenSubscribedPod(sessionId, s) + pi, err := api.OpenSubscribedPod(sessionId, s, keyLocation) if err != nil { reject.Invoke(fmt.Sprintf("openSubscribedPod failed : %s", err.Error())) return From caf254d289959feb9cd61c2ce499025ab4e71168 Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 22 Mar 2023 14:38:03 +0530 Subject: [PATCH 45/48] fix: tests --- pkg/subscriptionManager/rpc/mock/rpc.go | 22 +++++++++++++--------- pkg/test/subscription_test.go | 4 ++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pkg/subscriptionManager/rpc/mock/rpc.go b/pkg/subscriptionManager/rpc/mock/rpc.go index 5a3f7edb..c3cd15c8 100644 --- a/pkg/subscriptionManager/rpc/mock/rpc.go +++ b/pkg/subscriptionManager/rpc/mock/rpc.go @@ -2,6 +2,7 @@ package mock import ( "crypto/ecdsa" + "encoding/hex" "encoding/json" "fmt" "math/big" @@ -133,13 +134,16 @@ func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInf return fmt.Errorf("request not available") } + addrBytes, _ := utils.GetRandBytes(32) + + var addr [32]byte + copy(addr[:], addrBytes) item := &datahub.DataHubSubItem{ SubHash: i.SubHash, - UnlockKeyLocation: [32]byte{}, + UnlockKeyLocation: addr, ValidTill: new(big.Int).SetInt64(time.Now().AddDate(0, 1, 0).Unix()), } - - s.subscriptionMap[i.Buyer.Hex()+utils.Encode(requestHash[:])] = item + s.subscriptionMap[utils.Encode(i.FdpBuyerNameHash[:])+utils.Encode(requestHash[:])] = item dt, err := json.Marshal(si) if err != nil { @@ -151,19 +155,19 @@ func (s *SubscriptionManager) AllowAccess(owner common.Address, si *rpc.ShareInf return err } - s.subscribedMap[utils.Encode(i.SubHash[:])] = encDt + s.subscribedMap[hex.EncodeToString(addrBytes)] = encDt return nil } -func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) ([]datahub.DataHubSubItem, error) { +func (s *SubscriptionManager) GetSubscriptions(nameHash [32]byte) ([]datahub.DataHubSubItem, error) { s.lock.Lock() defer s.lock.Unlock() - subscriberHex := subscriber.Hex() + subscriber := utils.Encode(nameHash[:]) pods := []datahub.DataHubSubItem{} for i, v := range s.subscriptionMap { - if strings.HasPrefix(i, subscriberHex) { + if strings.HasPrefix(i, subscriber) { pods = append(pods, *v) } } @@ -171,11 +175,11 @@ func (s *SubscriptionManager) GetSubscriptions(subscriber common.Address) ([]dat return pods, nil } -func (s *SubscriptionManager) GetSubscription(subscriber common.Address, subHash, secret [32]byte) (*rpc.ShareInfo, error) { +func (s *SubscriptionManager) GetSubscription(infoLocation []byte, secret [32]byte) (*rpc.ShareInfo, error) { s.lock.Lock() defer s.lock.Unlock() - encDt := s.subscribedMap[utils.Encode(subHash[:])] + encDt := s.subscribedMap[hex.EncodeToString(infoLocation)] dt, err := utils.DecryptBytes(secret[:], encDt) if err != nil { return nil, err diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index 5462e1a6..1a612712 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -109,7 +109,7 @@ func TestSubscription(t *testing.T) { t.Fatal(err) } - subs, err := pod2.GetSubscriptions() + subs, err := pod2.GetSubscriptions(nameHash2) if err != nil { t.Fatal(err) } @@ -121,7 +121,7 @@ func TestSubscription(t *testing.T) { assert.Equal(t, len(subs), 1) assert.Equal(t, podInfo.PodName, randomLongPodName1) - pi, err := pod2.OpenSubscribedPod(subs[0].SubHash, acc1.GetUserAccountInfo().GetPublicKey()) + pi, err := pod2.OpenSubscribedPod(subs[0].UnlockKeyLocation[:], acc1.GetUserAccountInfo().GetPublicKey()) if err != nil { t.Fatal("failed to open subscribed pod") } From fc394ca310275e3c35d85dd6c8745f0ee9614bd5 Mon Sep 17 00:00:00 2001 From: asabya Date: Thu, 23 Mar 2023 15:11:38 +0530 Subject: [PATCH 46/48] feat: bzz upload --- pkg/blockstore/bee/client.go | 59 ++++++++++++++++++++++++-- pkg/blockstore/bee/mock/client.go | 5 +++ pkg/blockstore/client.go | 1 + pkg/dfs/pod_api.go | 28 ++++++------ pkg/dir/ls.go | 2 +- pkg/dir/sync.go | 2 +- pkg/pod/subscription.go | 5 ++- pkg/subscriptionManager/rpc/manager.go | 8 ++-- pkg/test/subscription_test.go | 2 +- pkg/user/login.go | 3 ++ 10 files changed, 89 insertions(+), 26 deletions(-) diff --git a/pkg/blockstore/bee/client.go b/pkg/blockstore/bee/client.go index f3d67546..6ad979f2 100644 --- a/pkg/blockstore/bee/client.go +++ b/pkg/blockstore/bee/client.go @@ -54,7 +54,8 @@ const ( swarmEncryptHeader = "Swarm-Encrypt" swarmPostageBatchId = "Swarm-Postage-Batch-Id" //swarmDeferredUploadHeader = "Swarm-Deferred-Upload" - swarmTagHeader = "Swarm-Tag" + swarmTagHeader = "Swarm-Tag" + contentTypeHeader = "Content-Type" ) // Client is a bee http client that satisfies blockstore.Client @@ -463,6 +464,58 @@ func (s *Client) DownloadBlob(address []byte) ([]byte, int, error) { return respData, response.StatusCode, nil } +// UploadBzz uploads a file through bzz api +func (s *Client) UploadBzz(data []byte, fileName string) (address []byte, err error) { + to := time.Now() + + fullUrl := s.url + bzzUrl + "?name=" + fileName + req, err := http.NewRequest(http.MethodPost, fullUrl, bytes.NewBuffer(data)) + if err != nil { + return nil, err + } + + req.Header.Set(swarmPostageBatchId, s.postageBlockId) + req.Header.Set(contentTypeHeader, "application/json") + + response, err := s.client.Do(req) + if err != nil { + return nil, err + } + defer response.Body.Close() + + req.Close = true + + respData, err := io.ReadAll(response.Body) + if err != nil { + return nil, errors.New("error downloading bzz") + } + + if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusCreated { + var beeErr *beeError + err = json.Unmarshal(respData, &beeErr) + if err != nil { + return nil, errors.New(string(respData)) + } + return nil, errors.New(beeErr.Message) + } + + var resp bytesPostResponse + err = json.Unmarshal(respData, &resp) + + fields := logrus.Fields{ + "reference": resp.Reference.String(), + "size": len(respData), + "duration": time.Since(to).String(), + } + s.logger.WithFields(fields).Log(logrus.DebugLevel, "upload bzz: ") + + // add the data and ref if it is not in cache + if !s.inBlockCache(s.downloadBlockCache, resp.Reference.String()) { + s.addToBlockCache(s.downloadBlockCache, resp.Reference.String(), data) + } + return resp.Reference.Bytes(), nil +} + // DownloadBzz downloads bzz data from the Swarm network. func (s *Client) DownloadBzz(address []byte) ([]byte, int, error) { to := time.Now() @@ -489,7 +542,7 @@ func (s *Client) DownloadBzz(address []byte) ([]byte, int, error) { respData, err := io.ReadAll(response.Body) if err != nil { - return nil, response.StatusCode, errors.New("error downloading blob") + return nil, response.StatusCode, errors.New("error downloading bzz") } if response.StatusCode != http.StatusOK { @@ -506,7 +559,7 @@ func (s *Client) DownloadBzz(address []byte) ([]byte, int, error) { "size": len(respData), "duration": time.Since(to).String(), } - s.logger.WithFields(fields).Log(logrus.DebugLevel, "download blob: ") + s.logger.WithFields(fields).Log(logrus.DebugLevel, "download bzz: ") // add the data and ref if it is not in cache if !s.inBlockCache(s.downloadBlockCache, addrString) { diff --git a/pkg/blockstore/bee/mock/client.go b/pkg/blockstore/bee/mock/client.go index 91965bf6..04e01ee6 100644 --- a/pkg/blockstore/bee/mock/client.go +++ b/pkg/blockstore/bee/mock/client.go @@ -132,6 +132,11 @@ func (m *BeeClient) DownloadBlob(address []byte) ([]byte, int, error) { return nil, http.StatusInternalServerError, fmt.Errorf("error downloading data") } +// UploadBzz downloads data to bzz api from the Swarm network. +func (m *BeeClient) UploadBzz(_ []byte, _ string) ([]byte, error) { + return nil, nil +} + // DownloadBzz downloads bzz data from the Swarm network. func (m *BeeClient) DownloadBzz(_ []byte) ([]byte, int, error) { return nil, 0, nil diff --git a/pkg/blockstore/client.go b/pkg/blockstore/client.go index 19566eb6..97fcc943 100644 --- a/pkg/blockstore/client.go +++ b/pkg/blockstore/client.go @@ -28,6 +28,7 @@ type Client interface { UploadSOC(owner string, id string, signature string, data []byte) (address []byte, err error) UploadChunk(ch swarm.Chunk) (address []byte, err error) UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) + UploadBzz(data []byte, fileName string) (address []byte, err error) DownloadChunk(ctx context.Context, address []byte) (data []byte, err error) DownloadBlob(address []byte) (data []byte, respCode int, err error) DownloadBzz(address []byte) (data []byte, respCode int, err error) diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 1cd0c314..2aa43bc5 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -551,6 +551,7 @@ func (a *API) RequestSubscription(sessionId string, subHash [32]byte) error { if err != nil { return err } + return ui.GetPod().RequestSubscription(subHash, nameHash) } @@ -636,7 +637,7 @@ type SubscriptionInfo struct { } // GetSubscriptions -func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { +func (a *API) GetSubscriptions(sessionId string) ([]SubscriptionInfo, error) { // get the loggedin user information ui := a.users.GetLoggedInUserInfo(sessionId) if ui == nil { @@ -647,7 +648,7 @@ func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { return nil, errNilSubManager } - nameHash, err := a.users.GetNameHash(ui.GetAccount().GetUserAccountInfo().GetAddress().Hex()) + nameHash, err := a.users.GetNameHash(ui.GetUserName()) if err != nil { return nil, err } @@ -657,21 +658,24 @@ func (a *API) GetSubscriptions(sessionId string) ([]*SubscriptionInfo, error) { return nil, err } - subs := []*SubscriptionInfo{} - for _, item := range subscriptions { + subs := make([]SubscriptionInfo, len(subscriptions)) + for i, item := range subscriptions { info, err := ui.GetPod().GetSubscribablePodInfo(item.SubHash) if err != nil { return subs, err } - sub := &SubscriptionInfo{ + var infoLocation = make([]byte, 32) + copy(infoLocation, item.UnlockKeyLocation[:]) + sub := SubscriptionInfo{ SubHash: item.SubHash, PodName: info.PodName, PodAddress: info.PodAddress, - InfoLocation: item.UnlockKeyLocation[:], + InfoLocation: infoLocation, ValidTill: item.ValidTill.Int64(), Category: info.Category, } - subs = append(subs, sub) + + subs[i] = sub } return subs, nil @@ -695,7 +699,7 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation return nil, err } - subHasshString := utils.Encode(subHash[:]) + subHashString := utils.Encode(subHash[:]) _, ownerPublicKey, err := a.users.GetUserInfoFromENS(sub.FdpSellerNameHash) if err != nil { @@ -708,12 +712,8 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation return nil, ErrUserNotLoggedIn } - swarmAddr, err := hex.DecodeString(infoLocation) - if err != nil { - return nil, err - } // open the pod - pi, err := ui.GetPod().OpenSubscribedPod(swarmAddr, ownerPublicKey) + pi, err := ui.GetPod().OpenSubscribedPodFromReference(infoLocation, ownerPublicKey) if err != nil { return nil, err } @@ -722,7 +722,7 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation return nil, err } // Add podName in the login user session - ui.AddPodName("0x"+subHasshString, pi) + ui.AddPodName("0x"+subHashString, pi) return pi, nil } diff --git a/pkg/dir/ls.go b/pkg/dir/ls.go index ec39ba09..8160a4b1 100644 --- a/pkg/dir/ls.go +++ b/pkg/dir/ls.go @@ -75,7 +75,7 @@ func (d *Directory) ListDir(dirNameWithPath, podPassword string) ([]Entry, []str lsTask := newLsTask(d, dirTopic, dirPath, podPassword, listEntries, mtx, wg) _, err := d.syncManager.Go(lsTask) if err != nil { - return nil, nil, fmt.Errorf("list dir : %v", err) + wg.Done() } } else if strings.HasPrefix(fileOrDirName, "_F_") { fileName := strings.TrimPrefix(fileOrDirName, "_F_") diff --git a/pkg/dir/sync.go b/pkg/dir/sync.go index eccc6118..dad0186e 100644 --- a/pkg/dir/sync.go +++ b/pkg/dir/sync.go @@ -85,7 +85,7 @@ func (d *Directory) SyncDirectoryAsync(ctx context.Context, dirNameWithPath, pod syncTask := newSyncTask(d, filePath, podPassword, wg) _, err = d.syncManager.Go(syncTask) if err != nil { // skipcq: TCV-001 - return err + wg.Done() } } else if strings.HasPrefix(fileOrDirName, "_D_") { dirName := strings.TrimPrefix(fileOrDirName, "_D_") diff --git a/pkg/pod/subscription.go b/pkg/pod/subscription.go index 3fd4be9d..101dfda8 100644 --- a/pkg/pod/subscription.go +++ b/pkg/pod/subscription.go @@ -117,10 +117,10 @@ func (p *Pod) GetSubscribablePodInfo(subHash [32]byte) (*rpc.SubscriptionItemInf } // OpenSubscribedPod will open a subscribed pod -func (p *Pod) OpenSubscribedPod(infoLocation []byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { +func (p *Pod) OpenSubscribedPod(reference []byte, ownerPublicKey *ecdsa.PublicKey) (*Info, error) { a, _ := ownerPublicKey.Curve.ScalarMult(ownerPublicKey.X, ownerPublicKey.Y, p.acc.GetUserAccountInfo().GetPrivateKey().D.Bytes()) secret := sha256.Sum256(a.Bytes()) - info, err := p.sm.GetSubscription(infoLocation, secret) + info, err := p.sm.GetSubscription(reference, secret) if err != nil { return nil, err } @@ -156,6 +156,7 @@ func (p *Pod) OpenSubscribedPodFromReference(reference string, ownerPublicKey *e if err != nil { return nil, err } + var info *rpc.ShareInfo err = json.Unmarshal(data, &info) if err != nil { diff --git a/pkg/subscriptionManager/rpc/manager.go b/pkg/subscriptionManager/rpc/manager.go index 2b5fd38d..812213f1 100644 --- a/pkg/subscriptionManager/rpc/manager.go +++ b/pkg/subscriptionManager/rpc/manager.go @@ -31,6 +31,7 @@ const ( type SubscriptionInfoPutter interface { UploadBlob(data []byte, tag uint32, encrypt bool) (address []byte, err error) + UploadBzz(data []byte, fileName string) (address []byte, err error) } type SubscriptionInfoGetter interface { @@ -86,7 +87,7 @@ func (c *Client) AddPodToMarketplace(podAddress, owner common.Address, pod, titl if err != nil { // skipcq: TCV-001 return err } - ref, err := c.putter.UploadBlob(data, 0, false) + ref, err := c.putter.UploadBzz(data, fmt.Sprintf("%d.sub.json", time.Now().Unix())) if err != nil { // skipcq: TCV-001 return err } @@ -187,12 +188,11 @@ func (c *Client) AllowAccess(owner common.Address, shareInfo *ShareInfo, request } func (c *Client) GetSubscription(infoLocation []byte, secret [32]byte) (*ShareInfo, error) { - encData, resp, err := c.getter.DownloadBlob(infoLocation[:]) + encData, respCode, err := c.getter.DownloadBlob(infoLocation[:]) if err != nil { // skipcq: TCV-001 return nil, err } - - if resp != http.StatusOK { // skipcq: TCV-001 + if respCode != http.StatusOK { // skipcq: TCV-001 return nil, fmt.Errorf("ReceivePodInfo: could not download blob") } diff --git a/pkg/test/subscription_test.go b/pkg/test/subscription_test.go index 1a612712..7e4ec857 100644 --- a/pkg/test/subscription_test.go +++ b/pkg/test/subscription_test.go @@ -109,7 +109,7 @@ func TestSubscription(t *testing.T) { t.Fatal(err) } - subs, err := pod2.GetSubscriptions(nameHash2) + subs, err := pod2.GetSubscriptions(requests[0].FdpBuyerNameHash) if err != nil { t.Fatal(err) } diff --git a/pkg/user/login.go b/pkg/user/login.go index 9fbe523f..993ed455 100644 --- a/pkg/user/login.go +++ b/pkg/user/login.go @@ -66,6 +66,9 @@ func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Clien if err != nil { // skipcq: TCV-001 return nil, "", "", err } + if publicKey == nil { + return nil, "", "", fmt.Errorf("public key not found") + } pb := crypto.FromECDSAPub(publicKey) // decrypt and remove pad from private ley From 8efe5b397ea6587f3eb5caf347551bfd9af57100 Mon Sep 17 00:00:00 2001 From: asabya Date: Fri, 24 Mar 2023 18:19:54 +0530 Subject: [PATCH 47/48] nameHash, address in wasm login --- pkg/dfs/user_api.go | 2 +- pkg/user/login.go | 19 ++++++++------ wasm/main.go | 61 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/pkg/dfs/user_api.go b/pkg/dfs/user_api.go index 9f22af70..79d0c261 100644 --- a/pkg/dfs/user_api.go +++ b/pkg/dfs/user_api.go @@ -85,7 +85,7 @@ func (a *API) ConnectPortableAccountWithWallet(userName, passPhrase, addressHex, } // LoginWithWallet is a controller function which calls the users login function. -func (a *API) LoginWithWallet(addressHex, signature, sessionId string) (*user.Info, error) { +func (a *API) LoginWithWallet(addressHex, signature, sessionId string) (*user.Info, string, error) { return a.users.LoginWithWallet(addressHex, signature, a.client, a.tm, a.sm, sessionId) } diff --git a/pkg/user/login.go b/pkg/user/login.go index 993ed455..0307191a 100644 --- a/pkg/user/login.go +++ b/pkg/user/login.go @@ -189,10 +189,11 @@ func (u *Users) ConnectWallet(userName, passPhrase, walletAddressHex, signature } // LoginWithWallet logs user in with wallet and signature -func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*Info, error) { +func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*Info, string, error) { address := common.HexToAddress(addressHex) // create account + acc := account.New(u.logger) accountInfo := acc.GetUserAccountInfo() // load encrypted private key @@ -200,22 +201,27 @@ func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore. key, err := u.downloadPortableAccount(utils.Address(address), addressHex, signature, fd) if err != nil { u.logger.Errorf(err.Error()) - return nil, ErrInvalidPassword + return nil, "", ErrInvalidPassword } // decrypt and remove pad from private ley seed, username, err := accountInfo.RemovePadFromSeedName(key, signature) if err != nil { // skipcq: TCV-001 - return nil, err + return nil, "", err + } + + nameHash, err := u.GetNameHash(username) + if err != nil { // skipcq: TCV-001 + return nil, "", err } // load user account err = acc.LoadUserAccountFromSeed(seed) if err != nil { // skipcq: TCV-001 - return nil, err + return nil, "", err } if u.IsUserLoggedIn(sessionId) { // skipcq: TCV-001 - return nil, ErrUserAlreadyLoggedIn + return nil, "", ErrUserAlreadyLoggedIn } // Instantiate pod, dir & file objects @@ -236,7 +242,6 @@ func (u *Users) LoginWithWallet(addressHex, signature string, client blockstore. openPods: make(map[string]*p.Info), openPodsMu: &sync.RWMutex{}, } - // set cookie and add user to map - return ui, u.addUserAndSessionToMap(ui) + return ui, utils.Encode(nameHash[:]), u.addUserAndSessionToMap(ui) } diff --git a/wasm/main.go b/wasm/main.go index 445b288a..9e2617d4 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -39,6 +39,8 @@ func registerWasmFunctions() { js.Global().Set("connect", js.FuncOf(connect)) js.Global().Set("stop", js.FuncOf(stop)) + js.Global().Set("publicKvEntryGet", js.FuncOf(publicKvEntryGet)) + js.Global().Set("connectWallet", js.FuncOf(connectWallet)) js.Global().Set("login", js.FuncOf(login)) js.Global().Set("walletLogin", js.FuncOf(walletLogin)) @@ -112,7 +114,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { resolve := args[0] reject := args[1] if len(funcArgs) != 6 { - reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, false, rpc, subRpc, subContractAddress)\"") + reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, rpc, network, subRpc, subContractAddress)\"") return nil } beeEndpoint := funcArgs[0].String() @@ -171,6 +173,53 @@ func stop(js.Value, []js.Value) interface{} { return nil } +func publicKvEntryGet(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + + if len(funcArgs) != 3 { + reject.Invoke("not enough arguments. \"publicKvEntryGet(sharingRef, tableName, key)\"") + return nil + } + sharingRef := funcArgs[0].String() + tableName := funcArgs[1].String() + key := funcArgs[2].String() + + ref, err := utils.ParseHexReference(sharingRef) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod kv get: invalid reference: %s", err.Error())) + return nil + } + + go func() { + shareInfo, err := api.PublicPodReceiveInfo(ref) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod kv get: %v", err)) + return + } + columns, data, err := api.PublicPodKVEntryGet(shareInfo, tableName, key) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod kv get: %s", err.Error())) + return + } + var res KVResponse + if columns != nil { + res.Keys = columns + } else { + res.Keys = []string{key} + } + res.Values = data + resp, _ := json.Marshal(res) + resolve.Invoke(resp) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func login(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] @@ -184,13 +233,15 @@ func login(_ js.Value, funcArgs []js.Value) interface{} { password := funcArgs[1].String() go func() { - ui, _, _, err := api.LoginUserV2(username, password, "") + ui, nameHash, _, err := api.LoginUserV2(username, password, "") if err != nil { reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) return } object := js.Global().Get("Object").New() object.Set("user", ui.GetUserName()) + object.Set("address", ui.GetAccount().GetUserAccountInfo().GetAddress().Hex()) + object.Set("nameHash", nameHash) object.Set("sessionId", ui.GetSessionId()) resolve.Invoke(object) @@ -216,14 +267,16 @@ func walletLogin(_ js.Value, funcArgs []js.Value) interface{} { signature := funcArgs[1].String() go func() { - ui, err := api.LoginWithWallet(address, signature, "") + ui, nameHash, err := api.LoginWithWallet(address, signature, "") if err != nil { - reject.Invoke(fmt.Sprintf("Failed to create user : %s", err.Error())) + reject.Invoke(fmt.Sprintf("Failed to login user : %s", err.Error())) return } object := js.Global().Get("Object").New() object.Set("user", ui.GetUserName()) + object.Set("address", ui.GetAccount().GetUserAccountInfo().GetAddress().Hex()) + object.Set("nameHash", nameHash) object.Set("sessionId", ui.GetSessionId()) resolve.Invoke(object) }() From 8b03007f11f820065d768fc8e17fb00eedff065e Mon Sep 17 00:00:00 2001 From: asabya Date: Wed, 29 Mar 2023 16:05:24 +0530 Subject: [PATCH 48/48] disable sub manager --- cmd/dfs/cmd/server.go | 4 ++-- pkg/contracts/config.go | 6 +----- pkg/dfs/pod_api.go | 26 +++++++++++++++++--------- wasm/main.go | 23 ++++++++--------------- 4 files changed, 28 insertions(+), 31 deletions(-) diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index 2ff2f4d0..40a1d8e0 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -206,8 +206,8 @@ can consume it.`, ctx, cancel := context.WithCancel(cmd.Context()) defer cancel() - // datadir will be removed in some future version. it is kept for migration purpose only - hdlr, err := api.New(ctx, beeApi, cookieDomain, postageBlockId, corsOrigins, ensConfig, subscriptionConfig, logger) + + hdlr, err := api.New(ctx, beeApi, cookieDomain, postageBlockId, corsOrigins, ensConfig, nil, logger) if err != nil { logger.Error(err.Error()) return err diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index 438fcf51..2ebe9bf8 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -25,11 +25,7 @@ func TestnetConfig() (*ENSConfig, *SubscriptionConfig) { PublicResolverAddress: "0xbfeCC6c32B224F7D0026ac86506Fe40A9607BD14", ProviderDomain: "fds", } - - s := &SubscriptionConfig{ - DataHubAddress: "0xBE41b272e3cDe3aeC8fE4a144C5b7cE71D9e6498", - } - return e, s + return e, nil } // PlayConfig defines the configuration for fdp-play diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 2aa43bc5..64d6b432 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -687,13 +687,23 @@ func (a *API) GetSubscribablePodInfo(sessionId string, subHash [32]byte) (*rpc.S if ui == nil { return nil, ErrUserNotLoggedIn } - + if a.sm == nil { + return nil, errNilSubManager + } return a.sm.GetSubscribablePodInfo(subHash) } // OpenSubscribedPod func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation string) (*pod.Info, error) { + // get the loggedin user information + ui := a.users.GetLoggedInUserInfo(sessionId) + if ui == nil { + return nil, ErrUserNotLoggedIn + } + if a.sm == nil { + return nil, errNilSubManager + } sub, err := a.sm.GetSub(subHash) if err != nil { return nil, err @@ -706,12 +716,6 @@ func (a *API) OpenSubscribedPod(sessionId string, subHash [32]byte, infoLocation return nil, err } - // get the loggedin user information - ui := a.users.GetLoggedInUserInfo(sessionId) - if ui == nil { - return nil, ErrUserNotLoggedIn - } - // open the pod pi, err := ui.GetPod().OpenSubscribedPodFromReference(infoLocation, ownerPublicKey) if err != nil { @@ -733,7 +737,9 @@ func (a *API) GetSubscribablePods(sessionId string) ([]datahub.DataHubSub, error if ui == nil { return nil, ErrUserNotLoggedIn } - + if a.sm == nil { + return nil, errNilSubManager + } return ui.GetPod().GetMarketplace() } @@ -744,6 +750,8 @@ func (a *API) GetSubsRequests(sessionId string) ([]datahub.DataHubSubRequest, er if ui == nil { return nil, ErrUserNotLoggedIn } - + if a.sm == nil { + return nil, errNilSubManager + } return ui.GetPod().GetSubRequests() } diff --git a/wasm/main.go b/wasm/main.go index 9e2617d4..8c19b691 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -113,37 +113,30 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] - if len(funcArgs) != 6 { - reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, rpc, network, subRpc, subContractAddress)\"") + if len(funcArgs) != 4 { + reject.Invoke("not enough arguments. \"connect(beeEndpoint, stampId, rpc, network)\"") return nil } beeEndpoint := funcArgs[0].String() stampId := funcArgs[1].String() rpc := funcArgs[2].String() network := funcArgs[3].String() - subRpc := funcArgs[4].String() - subContractAddress := funcArgs[5].String() + //subRpc := funcArgs[4].String() + //subContractAddress := funcArgs[5].String() if network != "testnet" && network != "play" { reject.Invoke("unknown network. \"use play or testnet\"") return nil } var ( - config *contracts.ENSConfig - subConfig *contracts.SubscriptionConfig + config *contracts.ENSConfig ) if network == "play" { - config, subConfig = contracts.PlayConfig() + config, _ = contracts.PlayConfig() } else { - config, subConfig = contracts.TestnetConfig() + config, _ = contracts.TestnetConfig() } config.ProviderBackend = rpc - if subRpc != "" { - subConfig.RPC = subRpc - } - if subContractAddress != "" { - subConfig.DataHubAddress = subContractAddress - } logger := logging.New(os.Stdout, logrus.DebugLevel) go func() { @@ -152,7 +145,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { beeEndpoint, stampId, config, - subConfig, + nil, logger, ) if err != nil {