diff --git a/cmd/dfs-cli/cmd/pod.go b/cmd/dfs-cli/cmd/pod.go index cedd6521..bb0cace5 100644 --- a/cmd/dfs-cli/cmd/pod.go +++ b/cmd/dfs-cli/cmd/pod.go @@ -25,6 +25,7 @@ import ( "github.com/fairdatasociety/fairOS-dfs/cmd/common" "github.com/fairdatasociety/fairOS-dfs/pkg/api" "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" ) func podNew(podName string) { @@ -43,6 +44,8 @@ func podNew(podName string) { fmt.Println("could not create pod: ", err) return } + currentPod = podName + currentDirectory = utils.PathSeperator message := strings.ReplaceAll(string(data), "\n", "") fmt.Println(message) } @@ -111,6 +114,8 @@ func openPod(podName string) { fmt.Println("pod open failed: ", err) return } + currentPod = podName + currentDirectory = utils.PathSeperator message := strings.ReplaceAll(string(data), "\n", "") fmt.Println(message) } diff --git a/cmd/dfs-cli/cmd/prompt.go b/cmd/dfs-cli/cmd/prompt.go index 4de64929..3c7bc6a5 100644 --- a/cmd/dfs-cli/cmd/prompt.go +++ b/cmd/dfs-cli/cmd/prompt.go @@ -312,7 +312,6 @@ func executor(in string) { } userName := blocks[2] userLogin(userName, apiUserLoginV2) - currentUser = userName currentPod = "" currentDirectory = "" currentPrompt = getCurrentPrompt() @@ -426,8 +425,6 @@ func executor(in string) { } podName := blocks[2] podNew(podName) - currentPod = podName - currentDirectory = utils.PathSeperator currentPrompt = getCurrentPrompt() case "del": if len(blocks) < 3 { @@ -446,8 +443,6 @@ func executor(in string) { } podName := blocks[2] openPod(podName) - currentPod = podName - currentDirectory = utils.PathSeperator currentPrompt = getCurrentPrompt() case "close": if !isPodOpened() { diff --git a/cmd/dfs-cli/cmd/user.go b/cmd/dfs-cli/cmd/user.go index 9f1c4619..b41beefc 100644 --- a/cmd/dfs-cli/cmd/user.go +++ b/cmd/dfs-cli/cmd/user.go @@ -83,6 +83,7 @@ func userLogin(userName, apiEndpoint string) { fmt.Println("login user: ", err) return } + currentUser = userName message := strings.ReplaceAll(string(data), "\n", "") fmt.Println(message) } diff --git a/cmd/dfs/cmd/config.go b/cmd/dfs/cmd/config.go index 81c639e8..e801c9ca 100644 --- a/cmd/dfs/cmd/config.go +++ b/cmd/dfs/cmd/config.go @@ -22,7 +22,6 @@ var ( optionSubdomainRegistrarAddress = "ens.subdomain-registrar-address" optionENSRegistryAddress = "ens.ens-registry-address" optionENSProviderBackend = "ens.ens-provider-backend" - optionENSProviderPrivateKey = "ens.ens-provider-private-key" defaultCORSAllowedOrigins = []string{} defaultDFSHttpPort = ":9090" diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index d021199b..6cdb36ca 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -91,7 +91,6 @@ can consume it.`, subdomainRegistrarAddress := config.GetString(optionSubdomainRegistrarAddress) ensRegistryAddress := config.GetString(optionENSRegistryAddress) ensProviderBackend := config.GetString(optionENSProviderBackend) - ensProviderPrivateKey := config.GetString(optionENSProviderPrivateKey) if providerDomain == "" { fmt.Println("\nens provider domain is missing") @@ -113,10 +112,6 @@ can consume it.`, fmt.Println("\nensProvideBackend endpoint is missing") return } - if ensProviderPrivateKey == "" { - fmt.Println("\nens provider private key is missing") - return - } ensConfig := &contracts.Config{ ENSRegistryAddress: ensRegistryAddress, @@ -124,7 +119,6 @@ can consume it.`, PublicResolverAddress: publicResolverAddress, ProviderDomain: providerDomain, ProviderBackend: ensProviderBackend, - ProviderPrivateKey: ensProviderPrivateKey, } var logger logging.Logger diff --git a/openapi/dfs.yaml b/openapi/dfs.yaml index 62c76e6b..dfeca1b8 100644 --- a/openapi/dfs.yaml +++ b/openapi/dfs.yaml @@ -1,7 +1,7 @@ openapi: 3.0.0 info: - version: 0.7.3 + version: 0.8.0 title: FairOS-dfs API description: 'A list of the currently provided Interfaces to interact with FairOS decentralised file system(dfs), implementing user, pod, file system, key value store and document store' @@ -22,7 +22,7 @@ servers: paths: '/v1/user/signup': post: - summary: 'Signup user' + summary: 'Signup user (v1)' description: 'Signs up a user and subsequently logs in returning the authentication cookie `fairOS-dfs`. The cookie needs to be sent n the request header in all subsequent requests. Input is a form object containing the login, password and optionally mnemonic. [Will be deprecated soon, use /v2/user/signup]' @@ -64,7 +64,7 @@ paths: '/v2/user/signup': post: - summary: 'Signup user' + summary: 'Signup user (v2)' description: 'Signs up a user and subsequently logs in returning the authentication cookie `fairOS-dfs`. The cookie needs to be sent n the request header in all subsequent requests. Input is a form object containing the login, password and optionally mnemonic.' @@ -104,7 +104,7 @@ paths: '/v1/user/login': post: - summary: 'Login user' + summary: 'Login user (v1)' description: 'Logs in user and returns the authentication cookie `fairOS-dfs in the header. The cookie needs to be sent n the request header in all subsequent requests. Input is a form object containing the login and password.' @@ -143,7 +143,7 @@ paths: '/v2/user/login': post: - summary: 'Login user' + summary: 'Login user (v2)' description: 'Logs in user and returns the authentication cookie `fairOS-dfs in the header. The cookie needs to be sent n the request header in all subsequent requests. Input is a form object containing the login and password.' @@ -181,7 +181,7 @@ paths: '/v1/user/present': get: - summary: 'User present' + summary: 'User present (v1)' description: 'Check if an user is present in a given dfs-server. Input contains form object containing the user name to check if it is present in the dfs server.' tags: @@ -208,7 +208,7 @@ paths: '/v2/user/present': get: - summary: 'User present' + summary: 'User present (v2)' description: 'Check if an user is present in a given dfs-server. Input contains form object containing the user name to check if it is present in the dfs server.' tags: @@ -343,7 +343,7 @@ paths: '/v1/user/delete': delete: - summary: 'Delete user' + summary: 'Delete user (v1)' description: 'Delete a logged-in user from the dfs server.' tags: - User @@ -377,7 +377,7 @@ paths: '/v2/user/delete': delete: - summary: 'Delete user' + summary: 'Delete user (v2)' description: 'Delete a logged-in user from the dfs server.' tags: - User @@ -2301,7 +2301,7 @@ components: type: string example: "user logged-in successfully" - UserSignupResponseWithMenonic: + UserSignupResponseWithMnemonic: type: object properties: address: diff --git a/pkg/contracts/config.go b/pkg/contracts/config.go index fa880762..acd4a706 100644 --- a/pkg/contracts/config.go +++ b/pkg/contracts/config.go @@ -6,5 +6,4 @@ type Config struct { PublicResolverAddress string ProviderDomain string ProviderBackend string - ProviderPrivateKey string } diff --git a/pkg/dfs/api.go b/pkg/dfs/api.go index 7503a774..62c167d0 100644 --- a/pkg/dfs/api.go +++ b/pkg/dfs/api.go @@ -1,6 +1,3 @@ -//go:build !js -// +build !js - /* Copyright © 2020 FairOS Authors diff --git a/pkg/ensm/ensm.go b/pkg/ensm/ensm.go index f1246e31..a016f77e 100644 --- a/pkg/ensm/ensm.go +++ b/pkg/ensm/ensm.go @@ -10,7 +10,7 @@ import ( type ENSManager interface { GetOwner(username string) (common.Address, error) - RegisterSubdomain(username string, owner common.Address) error + RegisterSubdomain(username string, owner common.Address, key *ecdsa.PrivateKey) error 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) diff --git a/pkg/ensm/eth/eth.go b/pkg/ensm/eth/eth.go index bd9567f6..b61a8baf 100644 --- a/pkg/ensm/eth/eth.go +++ b/pkg/ensm/eth/eth.go @@ -13,7 +13,6 @@ import ( "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/crypto" "github.com/ethereum/go-ethereum/ethclient" "github.com/fairdatasociety/fairOS-dfs/pkg/contracts" "github.com/fairdatasociety/fairOS-dfs/pkg/contracts/ens" @@ -42,9 +41,7 @@ type Client struct { subdomainRegistrar *subdomainregistrar.Subdomainregistrar publicResolver *publicresolver.Publicresolver - providerPrivateKey *ecdsa.PrivateKey - providerAddress common.Address - logger logging.Logger + logger logging.Logger } func New(ensConfig *contracts.Config, logger logging.Logger) (*Client, error) { @@ -70,18 +67,8 @@ func New(ensConfig *contracts.Config, logger logging.Logger) (*Client, error) { if err != nil { return nil, err } - privateKey, err := crypto.HexToECDSA(ensConfig.ProviderPrivateKey) - if err != nil { - return nil, err - } - publicKey := privateKey.Public() - publicKeyECDSA, ok := publicKey.(*ecdsa.PublicKey) - if !ok { - return nil, fmt.Errorf("error casting public key to ECDSA") - } - fromAddress := crypto.PubkeyToAddress(*publicKeyECDSA) + logger.Info("ensProviderBackend : ", ensConfig.ProviderBackend) - logger.Info("ensProviderAddress : ", fromAddress.Hex()) logger.Info("ensProviderDomain : ", ensConfig.ProviderDomain) c := &Client{ eth: eth, @@ -89,8 +76,6 @@ func New(ensConfig *contracts.Config, logger logging.Logger) (*Client, error) { ensRegistry: ensRegistry, subdomainRegistrar: subdomainRegistrar, publicResolver: publicResolver, - providerAddress: fromAddress, - providerPrivateKey: privateKey, logger: logger, } return c, nil @@ -105,7 +90,7 @@ func (c *Client) GetOwner(username string) (common.Address, error) { return c.ensRegistry.Owner(opts, node) } -func (c *Client) RegisterSubdomain(username string, owner common.Address) error { +func (c *Client) RegisterSubdomain(username string, owner common.Address, key *ecdsa.PrivateKey) error { balance, err := c.eth.BalanceAt(context.Background(), owner, nil) if err != nil { return err @@ -115,7 +100,7 @@ func (c *Client) RegisterSubdomain(username string, owner common.Address) error return ErrInsufficientBalance } - opts, err := c.newTransactor(c.providerPrivateKey, c.providerAddress) + opts, err := c.newTransactor(key, owner) if err != nil { return err } diff --git a/pkg/ensm/eth/mock/eth.go b/pkg/ensm/eth/mock/eth.go index 285b23d4..3f578219 100644 --- a/pkg/ensm/eth/mock/eth.go +++ b/pkg/ensm/eth/mock/eth.go @@ -44,7 +44,7 @@ func (c *MockNamespaceManager) GetInfo(username string) (*ecdsa.PublicKey, strin return pub, "", nil } -func (c *MockNamespaceManager) RegisterSubdomain(username string, owner common.Address) error { +func (c *MockNamespaceManager) RegisterSubdomain(username string, owner common.Address, _ *ecdsa.PrivateKey) error { c.storerMu.Lock() defer c.storerMu.Unlock() c.storer[username] = owner.Hex() diff --git a/pkg/feed/cacheentry.go b/pkg/feed/cacheentry.go index 04d69718..4a241be8 100644 --- a/pkg/feed/cacheentry.go +++ b/pkg/feed/cacheentry.go @@ -25,7 +25,7 @@ import ( const ( hasherCount = 8 - defaultRetrieveTimeout = 100 * time.Millisecond + defaultRetrieveTimeout = 400 * time.Millisecond ) // CacheEntry caches the last known update of a specific Swarm feed. diff --git a/pkg/user/new.go b/pkg/user/new.go index 30305861..d2be9312 100644 --- a/pkg/user/new.go +++ b/pkg/user/new.go @@ -196,7 +196,7 @@ func isUserNameValid(username string) bool { } func (u *Users) createENS(userName string, accountInfo *account.Info) (string, error) { - err := u.ens.RegisterSubdomain(userName, common.HexToAddress(accountInfo.GetAddress().Hex())) + err := u.ens.RegisterSubdomain(userName, common.HexToAddress(accountInfo.GetAddress().Hex()), accountInfo.GetPrivateKey()) if err != nil { return "", err } diff --git a/version.go b/version.go index 11735bed..c5fdcf38 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ package dfs var ( - version = "0.8.0" // manually set semantic version number + version = "0.8.1" // manually set semantic version number commit string // automatically set git commit hash Version = func() string {