Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

close moonpay staging branch (merge to master) #1137

Merged
merged 6 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions backend/accounts/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcutil"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts/notes"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts/safello"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/coin"
"github.com/digitalbitbox/bitbox-wallet-app/backend/signing"
"github.com/digitalbitbox/bitbox-wallet-app/util/observable"
Expand Down Expand Up @@ -82,12 +81,6 @@ type Interface interface {
CanVerifyAddresses() (bool, bool, error)
VerifyAddress(addressID string) (bool, error)

// SafelloBuySupported returns true if the Safello Buy widget can be used with this account.
SafelloBuySupported() bool
// Safello returns the infos needed to load the Safello Buy widget. panics() if Safello is not
// supported for this coin. Check support with `SafelloBuySupported()` before calling this.
SafelloBuy() *safello.Buy

Notes() *notes.Notes
// ProposeTxnote stores a note. The note is is persisted in the notes database upon calling
// SendTx(). This function must be called before `SendTx()`.
Expand Down
79 changes: 0 additions & 79 deletions backend/accounts/safello/safello.go

This file was deleted.

55 changes: 0 additions & 55 deletions backend/accounts/safello/safello_test.go

This file was deleted.

8 changes: 7 additions & 1 deletion backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,12 @@ func (backend *Backend) SystemOpen(url string) error {
"https://www.coingecko.com",
"https://bitcoincore.org/en/2016/01/26/segwit-benefits/",
"https://en.bitcoin.it/wiki/Bech32_adoption",
"https://help.safello.com",
// Moonpay onramp
"https://www.moonpay.com",
"https://support.moonpay.com",
"https://support.moonpay.io",
"https://help.moonpay.io",
"https://help.moonpay.com",
} {
if url == whitelistedURL {
blocked = false
Expand All @@ -1133,6 +1138,7 @@ func (backend *Backend) SystemOpen(url string) error {
"^https://etherscan\\.io/tx/",
"^https://rinkeby\\.etherscan\\.io/tx/",
"^https://ropsten\\.etherscan\\.io/tx/",
"^https://support.moonpay.com/",
}

if runtime.GOOS != "android" { // TODO: fix DownloadsDir() for android
Expand Down
43 changes: 0 additions & 43 deletions backend/coins/btc/exchange.go

This file was deleted.

41 changes: 21 additions & 20 deletions backend/coins/btc/handlers/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"encoding/json"
"net/http"
"os"
"path"
"path/filepath"
"strconv"
"strings"
Expand All @@ -30,11 +29,11 @@ import (
"github.com/btcsuite/btcutil"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts/errors"
"github.com/digitalbitbox/bitbox-wallet-app/backend/accounts/safello"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/btc/util"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/coin"
"github.com/digitalbitbox/bitbox-wallet-app/backend/coins/eth"
"github.com/digitalbitbox/bitbox-wallet-app/backend/exchanges"
"github.com/digitalbitbox/bitbox-wallet-app/backend/keystore"
"github.com/digitalbitbox/bitbox-wallet-app/util/config"
"github.com/digitalbitbox/bitbox-wallet-app/util/errp"
Expand Down Expand Up @@ -68,9 +67,8 @@ func NewHandlers(
handleFunc("/can-verify-extended-public-key", handlers.ensureAccountInitialized(handlers.getCanVerifyExtendedPublicKey)).Methods("GET")
handleFunc("/verify-extended-public-key", handlers.ensureAccountInitialized(handlers.postVerifyExtendedPublicKey)).Methods("POST")
handleFunc("/has-secure-output", handlers.ensureAccountInitialized(handlers.getHasSecureOutput)).Methods("GET")
handleFunc("/exchange/safello/buy-supported", handlers.ensureAccountInitialized(handlers.getExchangeSafelloBuySupported)).Methods("GET")
handleFunc("/exchange/safello/buy", handlers.ensureAccountInitialized(handlers.getExchangeSafelloBuy)).Methods("GET")
handleFunc("/exchange/safello/process-message", handlers.ensureAccountInitialized(handlers.postExchangeSafelloProcessMessage)).Methods("POST")
handleFunc("/exchange/moonpay/buy-supported", handlers.ensureAccountInitialized(handlers.getExchangeMoonpayBuySupported)).Methods("GET")
handleFunc("/exchange/moonpay/buy", handlers.ensureAccountInitialized(handlers.getExchangeMoonpayBuy)).Methods("GET")
handleFunc("/propose-tx-note", handlers.ensureAccountInitialized(handlers.postProposeTxNote)).Methods("POST")
handleFunc("/notes/tx", handlers.ensureAccountInitialized(handlers.postSetTxNote)).Methods("POST")
return handlers
Expand Down Expand Up @@ -486,24 +484,27 @@ func (handlers *Handlers) getHasSecureOutput(r *http.Request) (interface{}, erro
}, nil
}

func (handlers *Handlers) getExchangeSafelloBuySupported(r *http.Request) (interface{}, error) {
return handlers.account.SafelloBuySupported(), nil
func (handlers *Handlers) getExchangeMoonpayBuySupported(r *http.Request) (interface{}, error) {
return exchanges.IsMoonpaySupported(handlers.account.Coin().Code()), nil
}

func (handlers *Handlers) getExchangeSafelloBuy(r *http.Request) (interface{}, error) {
return handlers.account.SafelloBuy(), nil
}

func (handlers *Handlers) postExchangeSafelloProcessMessage(r *http.Request) (interface{}, error) {
var message map[string]json.RawMessage
if err := json.NewDecoder(r.Body).Decode(&message); err != nil {
return nil, errp.WithStack(err)
func (handlers *Handlers) getExchangeMoonpayBuy(r *http.Request) (interface{}, error) {
params := exchanges.BuyMoonpayParams{
Fiat: "CHF", // TODO: Get this from app config
Lang: "en", // TODO: Get this from the backend
}

return nil, safello.StoreCallbackJSONMessage(
path.Join(handlers.account.FilesFolder(), "safello-buy.json"),
message,
)
buy, err := exchanges.BuyMoonpay(handlers.account, params)
if err != nil {
return nil, err
}
resp := struct {
URL string `json:"url"`
Address string `json:"address"`
}{
URL: buy.URL,
Address: buy.Address,
}
return resp, nil
}

func (handlers *Handlers) postProposeTxNote(r *http.Request) (interface{}, error) {
Expand Down
27 changes: 0 additions & 27 deletions backend/coins/eth/exchange.go

This file was deleted.

10 changes: 1 addition & 9 deletions backend/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,9 @@ func (proxy proxyConfig) ProxyAddressOrDefault() string {
return defaultProxyAddress
}

type servicesConfig struct {
Safello bool `json:"safello"`
}

// Backend holds the backend specific configuration.
type Backend struct {
Proxy proxyConfig `json:"proxy"`
Services servicesConfig `json:"services"`
Proxy proxyConfig `json:"proxy"`

BitcoinActive bool `json:"bitcoinActive"`
LitecoinActive bool `json:"litecoinActive"`
Expand Down Expand Up @@ -158,9 +153,6 @@ func NewDefaultAppConfig() AppConfig {
UseProxy: false,
ProxyAddress: defaultProxyAddress,
},
Services: servicesConfig{
Safello: true,
},
BitcoinActive: true,
LitecoinActive: true,
EthereumActive: true,
Expand Down
Loading