Skip to content

Commit

Permalink
use dcrdex branding in extension-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Aug 22, 2024
1 parent 6449ec9 commit bd39432
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 19 deletions.
5 changes: 5 additions & 0 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -10755,3 +10755,8 @@ func (c *Core) checkEpochResolution(host string, mktID string) {

}
}

// ExtensionModeConfig is the configuration parsed from the extension-mode file.
func (c *Core) ExtensionModeConfig() *ExtensionModeConfig {
return c.extensionModeConfig
}
1 change: 1 addition & 0 deletions client/core/example-extension-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"useDEXBranding": true,
"restrictedWallets": {
"dcr": {
"hiddenFields": [
Expand Down
3 changes: 3 additions & 0 deletions client/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ type FeeState struct {
type ExtensionModeConfig struct {
// Name of embedding application. Used for messaging with disable features.
Name string `json:"name"`
// UseDEXBranding will tell the front end to use DCRDEX branding instead
// of Bison Wallet branding where possible.
UseDEXBranding bool `json:"useDEXBranding"`
// RestrictedWallets are wallets that need restrictions on reconfiguration
// options.
RestrictedWallets map[string] /*symbol*/ struct {
Expand Down
10 changes: 6 additions & 4 deletions client/webserver/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,17 @@ func (s *WebServer) sendTemplate(w http.ResponseWriter, tmplID string, data any)
// CommonArguments are common page arguments that must be supplied to every
// page to populate the <title> and <header> elements.
type CommonArguments struct {
UserInfo *userInfo
Title string
UserInfo *userInfo
Title string
UseDEXBranding bool
}

// Create the CommonArguments for the request.
func (s *WebServer) commonArgs(r *http.Request, title string) *CommonArguments {
return &CommonArguments{
UserInfo: extractUserInfo(r),
Title: title,
UserInfo: extractUserInfo(r),
Title: title,
UseDEXBranding: s.useDEXBranding,
}
}

Expand Down
4 changes: 4 additions & 0 deletions client/webserver/live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,10 @@ func (c *TCore) TakeAction(assetID uint32, actionID string, actionB json.RawMess
return nil
}

func (*TCore) ExtensionModeConfig() *core.ExtensionModeConfig {
return nil
}

func newMarketDay() *libxc.MarketDay {
avgPrice := tenToThe(7)
return &libxc.MarketDay{
Expand Down
2 changes: 1 addition & 1 deletion client/webserver/locales/de-de.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ var DeDE = map[string]*intl.Translation{
"Show pop-up notifications": {T: "Popup-Benachrichtigungen anzeigen"},
"Account ID": {T: "Account ID"},
"Export Account": {T: "Account exportieren"},
"simultaneous_servers_msg": {T: "Der Bison Wallet unterstützt die gleichzeitige Nutzung einer beliebigen Anzahl von DEX-Servern."},
"simultaneous_servers_msg": {T: "Der <span class=brand></span> unterstützt die gleichzeitige Nutzung einer beliebigen Anzahl von DEX-Servern."},
"Change App Password": {T: "App-Passwort ändern"},
"Build ID": {T: "Build ID"},
"Connect": {T: "Verbinden"},
Expand Down
10 changes: 5 additions & 5 deletions client/webserver/locales/en-us.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var EnUS = map[string]*intl.Translation{
"verify_market": {T: "This is a market order and will match the best available order(s) on the book. Based on the current market mid-gap rate, you might receive about"},
"auth_order_app_pw": {T: "Authorize this order with your app password."},
"lots": {T: "lots"},
"order_disclaimer": {Version: 1, T: `<span class="red">IMPORTANT</span>: Trades take time to settle, and you cannot turn off the Bison Wallet software,
"order_disclaimer": {Version: 1, T: `<span class="red">IMPORTANT</span>: Trades take time to settle, and you cannot turn off the <span class=brand></span> software,
or the <span data-quote-ticker></span> or <span data-base-ticker></span> blockchain and/or wallet software, until
settlement is complete. Settlement can complete as quickly as a few minutes or take as long as a few hours.`},
"acknowledge_and_hide": {T: "acknowledge and hide"},
Expand Down Expand Up @@ -152,7 +152,7 @@ var EnUS = map[string]*intl.Translation{
"Assets": {T: "Assets"},
"Trade": {T: "Trade"},
"Set App Password": {Version: 1, T: "New Password"},
"reg_set_app_pw_msg": {Version: 1, T: "Set your password. This is the password that unlocks Bison Wallet for use."},
"reg_set_app_pw_msg": {Version: 1, T: "Set your password. This is the password that unlocks <span class=brand></span> for use."},
"Password Again": {T: "Password Again"},
"Add a DEX": {Version: 1, T: "Add a DCRDEX Server"},
"Pick a server": {T: "Pick a server"},
Expand All @@ -161,7 +161,7 @@ var EnUS = map[string]*intl.Translation{
"Show pop-up notifications": {T: "Show pop-up notifications"},
"Account ID": {T: "Account ID"},
"Export Account": {T: "Export Account"},
"simultaneous_servers_msg": {Version: 1, T: "Bison Wallet supports simultaneous use of any number of DEX servers."},
"simultaneous_servers_msg": {Version: 1, T: "<span class=brand></span> supports simultaneous use of any number of DEX servers."},
"Change App Password": {T: "Change App Password"},
"enable_browser_ntfn": {T: "Enable desktop notifications"},
"browser_ntfn_blocked": {T: "Browser notifications are currently blocked. Please unblock this site in your browser to receive notifications."},
Expand All @@ -179,7 +179,7 @@ var EnUS = map[string]*intl.Translation{
"Amount": {T: "Amount"},
"Authorize the transfer with your app password.": {T: "Authorize the transfer with your app password."},
"Reconfigure": {T: "Reconfigure"},
"pw_change_instructions": {T: "Changing the password below does not change the password for Bison Wallet. Use this form to update Bison Wallet after you have changed your password with the wallet software directly."},
"pw_change_instructions": {T: "Changing the password below does not change the password for <span class=brand></span>. Use this form to update <span class=brand></span> after you have changed your password with the wallet software directly."},
"New Wallet Password": {T: "New Wallet Password"},
"pw_change_warn": {T: "Note: Changing to a different wallet while having active trades might cause funds to be lost."},
"Show more options": {T: "Show more options"},
Expand Down Expand Up @@ -323,7 +323,7 @@ var EnUS = map[string]*intl.Translation{
"Mempool": {T: "Mempool"},
"disable_wallet": {T: "Disable Wallet"},
"enable_wallet": {T: "Enable Wallet"},
"disable_wallet_warning": {T: "Note: This wallet will not be connected to when you start the Bison Wallet software and cannot be used until it is enabled. This will also disable all token wallets that depend on this wallet."},
"disable_wallet_warning": {T: "Note: This wallet will not be connected to when you start <span class=brand></span> software and cannot be used until it is enabled. This will also disable all token wallets that depend on this wallet."},
"enable_wallet_message": {T: "This wallet will resume operation and might take some time to sync. If this is a token wallet, the wallet for the chain's primary asset will also be enabled."},
"Disabled": {T: "Disabled"},
"txfee_not_available": {T: "Transaction fee currently unavailable"},
Expand Down
32 changes: 30 additions & 2 deletions client/webserver/site/src/css/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,19 @@ div.note-indicator {
z-index: 10;
}

span.brand::before {
content: "Bison Wallet";
}

img.dex-logo {
content: var(--dex-url);
}

img.bison-logo-square {
img.logo-square {
content: url("/img/bison-square_50.png");
}

img.bison-logo-full {
img.logo-full {
content: url("/img/bison-full_97x50.png");

&.small {
Expand All @@ -119,6 +123,30 @@ img.bison-logo-full {
}
}

body.dex-branding {
img.logo-square,
img.logo-full {
width: 50px;
height: 50px;
content: url("/img/softened-icon.png");
}

&.dark img.logo-square,
&.dark img.logo-full {
content: url("/img/softened-icon-dark.png");
}

img.logo-square.small,
img.logo-full.small {
height: 25px;
width: 25px;
}

span.brand::before {
content: "DCRDEX";
}
}

#noteIndicator {
position: absolute;
top: 0;
Expand Down
8 changes: 4 additions & 4 deletions client/webserver/site/src/html/bodybuilder.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<title>{{.Title}}</title>
<link href="/css/style.css?v={{commitHash}}" rel="stylesheet">
</head>
<body >
<body {{if .UseDEXBranding}}class="dex-branding"{{end}}>
<div class="popup-notes d-hide" id="popupNotes">
<span data-tmpl="note" class="fs15">
<div class="note-indicator d-inline-block" data-tmpl="indicator"></div>
Expand All @@ -26,10 +26,10 @@
<header id="header" class="border-bottom mb-2">
{{$authed := .UserInfo.Authed}}
<a href="/" class="d-none d-md-block pointer hoverbg mx-2">
<img src="/img/bison-full_97x50.png">
<img class="logo-full">
</a>
<a href="/" class="d-block d-md-none pointer hoverbg mx-2">
<img class="bison-logo-square">
<img class="logo-square">
</a>
<div id="headerSpace"></div>
<div class="mainlinks fs18 pe-2 text-nowrap">
Expand All @@ -52,7 +52,7 @@
</div>
<div id="loader" class="fill-abs d-hide">
<div class="fill-abs flex-center blurry-bg">
<img class="d-inline-block bison-logo-square small-icon spinner">
<img class="d-inline-block logo-square small-icon spinner">
<div id="loaderMsg" class="mx-2 d-hide"></div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/webserver/site/src/html/forms.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@
<tbody>
<tr>
<td class="no-stretch ps-3">
<img class="bison-logo-square small-icon">
<img class="logo-square small-icon">
</td>
<td class="text-end">
<div class="d-inline-flex flex-column align-items-end text-nowrap">
Expand Down
2 changes: 1 addition & 1 deletion client/webserver/site/src/html/mm.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
</div>
<div class="flex-center ps-2 pb-2 border-start">
<div class="d-inline-block">
<img class="bison-logo-full small">
<img class="logo-full small">
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion client/webserver/site/src/html/mmsettings.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
<div data-tmpl="balanceBreakdown">
<div class="d-flex align-items-center">
<span class="fs16 lh1">├─</span>
<img class="bison-logo-square micro-icon mx-1">
<img class="logo-square micro-icon mx-1">
<span data-tmpl="dexAvail" class="fs14"></span>
</div>
<div class="d-flex align-items-center fs14">
Expand Down
9 changes: 9 additions & 0 deletions client/webserver/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ type clientCore interface {
SetLanguage(string) error
Language() string
TakeAction(assetID uint32, actionID string, actionB json.RawMessage) error
ExtensionModeConfig() *core.ExtensionModeConfig
}

type MMCore interface {
Expand Down Expand Up @@ -269,6 +270,8 @@ type WebServer struct {

bondBufMtx sync.Mutex
bondBuf map[uint32]valStamp

useDEXBranding bool
}

// New is the constructor for a new WebServer. CustomSiteDir in the Config can
Expand Down Expand Up @@ -371,6 +374,11 @@ func New(cfg *Config) (*WebServer, error) {
langs = append(langs, l)
}

var useDEXBranding bool
if xCfg := cfg.Core.ExtensionModeConfig(); xCfg != nil {
useDEXBranding = xCfg.UseDEXBranding
}

// Make the server here so its methods can be registered.
s := &WebServer{
langs: langs,
Expand All @@ -385,6 +393,7 @@ func New(cfg *Config) (*WebServer, error) {
authTokens: make(map[string]bool),
cachedPasswords: make(map[string]*cachedPassword),
bondBuf: map[uint32]valStamp{},
useDEXBranding: useDEXBranding,
}
s.lang.Store(lang)

Expand Down
4 changes: 4 additions & 0 deletions client/webserver/webserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ func (*TCore) Language() string { return "en-US" }

func (*TCore) TakeAction(assetID uint32, actionID string, actionB json.RawMessage) error { return nil }

func (*TCore) ExtensionModeConfig() *core.ExtensionModeConfig {
return nil
}

type TWriter struct {
b []byte
}
Expand Down

0 comments on commit bd39432

Please sign in to comment.