Skip to content

Commit

Permalink
Remove text retyping and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
martonp committed Jul 8, 2022
1 parent 0753102 commit ef36ba8
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 156 deletions.
7 changes: 4 additions & 3 deletions client/asset/eth/eth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2037,14 +2037,15 @@ func (w *assetWallet) RestorationInfo(seed []byte) ([]*asset.WalletRestoration,

return []*asset.WalletRestoration{
&asset.WalletRestoration{
Target: "MetaMask",
Seed: hex.EncodeToString(privateKey),
Target: "MetaMask",
Seed: hex.EncodeToString(privateKey),
SeedName: "Private Key",
Instructions: "Accounts can be imported by private key only if MetaMask has already be initialized. " +
"If this is your first time installing MetaMask, create a new wallet and secret recovery phrase. " +
"Then, to import your DEX account into MetaMask, follow the steps below:\n" +
`1. Open the settings menu
2. Select "Import Account"
3. Make sure "Private Key" is selected, and paste the private key above into the box`,
3. Make sure "Private Key" is selected, and enter the private key above into the box`,
},
}, nil
}
Expand Down
7 changes: 5 additions & 2 deletions client/asset/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,11 @@ type FeeRater interface {
// WalletRestoration contains all the information needed for a user to restore
// their wallet in an external wallet.
type WalletRestoration struct {
Target string `json:"target"`
Seed string `json:"seed"`
Target string `json:"target"`
Seed string `json:"seed"`
// SeedName is the name of the seed used for this particular wallet, i.e
// Private Key.
SeedName string `json:"seedName"`
Instructions string `json:"instructions"`
}

Expand Down
2 changes: 1 addition & 1 deletion client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -7081,7 +7081,7 @@ func (c *Core) WalletRestorationInfo(pw []byte, assetID uint32) ([]*asset.Wallet

restorer, ok := wallet.Wallet.(asset.WalletRestorer)
if !ok {
return nil, fmt.Errorf("wallet for asset %d cannot be restored", assetID)
return nil, fmt.Errorf("wallet for asset %d doesn't support exporting functionality", assetID)
}

restorationInfo, err := restorer.RestorationInfo(seed)
Expand Down
5 changes: 2 additions & 3 deletions client/webserver/locales/en-us.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ var EnUS = map[string]string{
"copied": "Copied!",
"export_wallet": "Export Wallet",
"pw_for_wallet_seed": "Enter your app password to show the wallet seed. Make sure nobody else can see your screen. If anyone gets access to the wallet seed, they will be able to steal all of your funds.",
"export_wallet_disclaimer": "Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS. It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.",
"retype_instructions": `Please type the following to confirm that you understand the risks of exporting the wallet:`,
"export_wallet_disclaimer": `<span class="warning-text">Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS.</span> It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.`,
"export_wallet_msg": "Below are the seeds needed to restore your wallet in some popular external wallets. DO NOT make transactions with your external wallet while you have active trades running on the DEX.",
"restore_wallet_retype_text": "I will not use any external wallet while I have active trades in the DEX",
"clipboard_warning": "Copy/Pasting a wallet seed is a potential security risk. Do this at your own risk.",
}
8 changes: 7 additions & 1 deletion client/webserver/site/src/css/wallets.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ table.wallets {
}

#restoreWalletInfo,
#exportWalletDisclaimer,
#exportWalletAuth {
width: 450px;
}

.warning-text {
text-decoration: underline;
text-decoration-color: #d11414;
color: #d11414;
font-size: bold;
}
33 changes: 10 additions & 23 deletions client/webserver/site/src/html/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,26 +282,6 @@
<div class="fs15 pt-3 text-center d-hide errcolor" id="recoverWalletErr"></div>
</form>

{{- /* EXPORT WALLET DISCLAIMER */ -}}
<form class="d-hide" id="exportWalletDisclaimer">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
<div class="py-1 text-center position-relative fs22 sans-light">
[[[export_wallet]]]
</div>
<div class="fs15 text-start mt-2">
[[[export_wallet_disclaimer]]]
</div>
<div class="fs15 text-start mt-2">
[[[retype_instructions]]]
</div>
<span id="retypeText" class="fs15 text-start bold underline">[[[restore_wallet_retype_text]]]</span>
<input class="form-control mt-2" id="disclaimerInput" >
<div class="d-flex justify-content-end mt-4">
<button id="disclaimerSubmit" type="button" class="justify-content-center fs15 bg2 selected">[[[Submit]]]</button>
</div>
<div class="fs15 pt-3 text-center d-hide errcolor text-break" id="disclaimerErr"></div>
</form>

{{- /* EXPORT WALLET AUTHORIZATION */ -}}
<form class="d-hide" id="exportWalletAuth">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
Expand All @@ -311,6 +291,9 @@
<div class="fs15 text-start mt-2">
[[[pw_for_wallet_seed]]]
</div>
<div id="exportDisclaimer" class="fs15 text-start mt-2">
[[[export_wallet_disclaimer]]]
</div>
<div class="text-start mt-2">
<label for="exportWalletPW" class="ps-1 mb-1">[[[Password]]]</label>
<input type="password" class="form-control select" id="exportWalletPW" autocomplete="current-password">
Expand All @@ -330,15 +313,19 @@
<div class="fs15 text-start mt-2">
[[[export_wallet_msg]]]
</div>
<div class="fs15 text-start mt-2 warning-text">
[[[clipboard_warning]]]
</div>
<hr />
<div id="restoreInfoCardsList">
<div id="restoreInfoCard">
<span data-tmpl="name" class="text-left position-relative fs20 sans-light bold underline"></span>
<br />
<span>Seed:</span>
<br />
<span data-tmpl="seed" class="sans-light text-break"></span>
<span data-tmpl="seedName"></span>
<br />
<div>
<span data-tmpl="seed" class="mono fs14"></span>
</div>
<span>Instructions:</span>
<br />
<span data-tmpl="instructions" class="sans-light text-break preline"></span>
Expand Down
39 changes: 8 additions & 31 deletions client/webserver/site/src/js/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ interface RescanRecoveryRequest {
interface WalletRestoration {
target: string
seed: string
seedName: string
instructions: string
}

Expand Down Expand Up @@ -182,10 +183,9 @@ export default class WalletsPage extends BasePage {
bind(document, 'keyup', this.keyup)

bind(page.downloadLogs, 'click', async () => { this.downloadLogs() })
bind(page.exportWallet, 'click', async () => { this.displayExportWalletDisclaimer() })
bind(page.exportWallet, 'click', async () => { this.displayExportWalletAuth() })
bind(page.recoverWallet, 'click', async () => { this.showRecoverWallet() })
bindForm(page.exportWalletAuth, page.exportWalletAuthSubmit, async () => { this.exportWalletAuthSubmit() })
bindForm(page.exportWalletDisclaimer, page.disclaimerSubmit, async () => { this.disclaimerSubmit() })
bindForm(page.recoverWalletConfirm, page.recoverWalletSubmit, () => { this.recoverWallet() })
bindForm(page.confirmForce, page.confirmForceSubmit, async () => { this.confirmForceSubmit() })

Expand Down Expand Up @@ -695,38 +695,13 @@ export default class WalletsPage extends BasePage {
window.open(url.toString())
}

// displayExportWalletDisclaimer displays a popup which prompts the user to
// retype a text confirming that they understand the risks of exporting the
// wallet.
async displayExportWalletDisclaimer () {
// displayExportWalletAuth displays a form to warn the user about the
// dangers of exporting a wallet, and asks them to enter their password.
async displayExportWalletAuth () {
const page = this.page
Doc.hide(page.disclaimerErr)
page.disclaimerInput.value = ''
this.showForm(page.exportWalletDisclaimer)
}

// disclaimerSubmit checks that the user correctly retyped the text, and if
// so loads a popup where they have to input their password in order to
// see their wallet seed.
async disclaimerSubmit () {
const page = this.page
const inputValueMatches : () => boolean = () => {
const inputValue = page.disclaimerInput.value
if (!inputValue) return false
if (!page.retypeText.textContent) {
// this is needed to satisfy the typescript compiler
console.error('retypeText not populated')
return false
}
return inputValue.trim().toLowerCase() === page.retypeText.textContent.trim().toLowerCase()
}
Doc.hide(page.exportWalletErr)
page.exportWalletPW.value = ''
if (inputValueMatches()) this.showForm(page.exportWalletAuth)
else {
page.disclaimerErr.textContent = 'Your entry does not match'
Doc.show(page.disclaimerErr)
}
this.showForm(page.exportWalletAuth)
}

// exportWalletAuthSubmit is called after the user enters their password to
Expand All @@ -743,6 +718,7 @@ export default class WalletsPage extends BasePage {
const res = await postJSON(url, req)
loaded()
if (app().checkResponse(res)) {
page.exportWalletPW.value = ''
this.displayRestoreWalletInfo(res.restorationinfo)
} else {
page.exportWalletErr.textContent = res.msg
Expand All @@ -760,6 +736,7 @@ export default class WalletsPage extends BasePage {
const tmpl = Doc.parseTemplate(card)
tmpl.name.textContent = wr.target
tmpl.seed.textContent = wr.seed
tmpl.seedName.textContent = `${wr.seedName}:`
tmpl.instructions.textContent = wr.instructions
page.restoreInfoCardsList.appendChild(card)
}
Expand Down
33 changes: 10 additions & 23 deletions client/webserver/site/src/localized_html/en-US/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,26 +282,6 @@
<div class="fs15 pt-3 text-center d-hide errcolor" id="recoverWalletErr"></div>
</form>

{{- /* EXPORT WALLET DISCLAIMER */ -}}
<form class="d-hide" id="exportWalletDisclaimer">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
<div class="py-1 text-center position-relative fs22 sans-light">
Export Wallet
</div>
<div class="fs15 text-start mt-2">
Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS. It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="fs15 text-start mt-2">
Please type the following to confirm that you understand the risks of exporting the wallet:
</div>
<span id="retypeText" class="fs15 text-start bold underline">I will not use any external wallet while I have active trades in the DEX</span>
<input class="form-control mt-2" id="disclaimerInput" >
<div class="d-flex justify-content-end mt-4">
<button id="disclaimerSubmit" type="button" class="justify-content-center fs15 bg2 selected">Submit</button>
</div>
<div class="fs15 pt-3 text-center d-hide errcolor text-break" id="disclaimerErr"></div>
</form>

{{- /* EXPORT WALLET AUTHORIZATION */ -}}
<form class="d-hide" id="exportWalletAuth">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
Expand All @@ -311,6 +291,9 @@
<div class="fs15 text-start mt-2">
Enter your app password to show the wallet seed. Make sure nobody else can see your screen. If anyone gets access to the wallet seed, they will be able to steal all of your funds.
</div>
<div id="exportDisclaimer" class="fs15 text-start mt-2">
<span class="warning-text">Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS.</span> It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="text-start mt-2">
<label for="exportWalletPW" class="ps-1 mb-1">Password</label>
<input type="password" class="form-control select" id="exportWalletPW" autocomplete="current-password">
Expand All @@ -330,15 +313,19 @@
<div class="fs15 text-start mt-2">
Below are the seeds needed to restore your wallet in some popular external wallets. DO NOT make transactions with your external wallet while you have active trades running on the DEX.
</div>
<div class="fs15 text-start mt-2 warning-text">
Copy/Pasting a wallet seed is a potential security risk. Do this at your own risk.
</div>
<hr />
<div id="restoreInfoCardsList">
<div id="restoreInfoCard">
<span data-tmpl="name" class="text-left position-relative fs20 sans-light bold underline"></span>
<br />
<span>Seed:</span>
<br />
<span data-tmpl="seed" class="sans-light text-break"></span>
<span data-tmpl="seedName"></span>
<br />
<div>
<span data-tmpl="seed" class="mono fs14"></span>
</div>
<span>Instructions:</span>
<br />
<span data-tmpl="instructions" class="sans-light text-break preline"></span>
Expand Down
33 changes: 10 additions & 23 deletions client/webserver/site/src/localized_html/pl-PL/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,26 +282,6 @@
<div class="fs15 pt-3 text-center d-hide errcolor" id="recoverWalletErr"></div>
</form>

{{- /* EXPORT WALLET DISCLAIMER */ -}}
<form class="d-hide" id="exportWalletDisclaimer">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
<div class="py-1 text-center position-relative fs22 sans-light">
Export Wallet
</div>
<div class="fs15 text-start mt-2">
Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS. It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="fs15 text-start mt-2">
Please type the following to confirm that you understand the risks of exporting the wallet:
</div>
<span id="retypeText" class="fs15 text-start bold underline">I will not use any external wallet while I have active trades in the DEX</span>
<input class="form-control mt-2" id="disclaimerInput" >
<div class="d-flex justify-content-end mt-4">
<button id="disclaimerSubmit" type="button" class="justify-content-center fs15 bg2 selected">Wyślij</button>
</div>
<div class="fs15 pt-3 text-center d-hide errcolor text-break" id="disclaimerErr"></div>
</form>

{{- /* EXPORT WALLET AUTHORIZATION */ -}}
<form class="d-hide" id="exportWalletAuth">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
Expand All @@ -311,6 +291,9 @@
<div class="fs15 text-start mt-2">
Enter your app password to show the wallet seed. Make sure nobody else can see your screen. If anyone gets access to the wallet seed, they will be able to steal all of your funds.
</div>
<div id="exportDisclaimer" class="fs15 text-start mt-2">
<span class="warning-text">Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS.</span> It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="text-start mt-2">
<label for="exportWalletPW" class="ps-1 mb-1">Hasło</label>
<input type="password" class="form-control select" id="exportWalletPW" autocomplete="current-password">
Expand All @@ -330,15 +313,19 @@
<div class="fs15 text-start mt-2">
Below are the seeds needed to restore your wallet in some popular external wallets. DO NOT make transactions with your external wallet while you have active trades running on the DEX.
</div>
<div class="fs15 text-start mt-2 warning-text">
Copy/Pasting a wallet seed is a potential security risk. Do this at your own risk.
</div>
<hr />
<div id="restoreInfoCardsList">
<div id="restoreInfoCard">
<span data-tmpl="name" class="text-left position-relative fs20 sans-light bold underline"></span>
<br />
<span>Seed:</span>
<br />
<span data-tmpl="seed" class="sans-light text-break"></span>
<span data-tmpl="seedName"></span>
<br />
<div>
<span data-tmpl="seed" class="mono fs14"></span>
</div>
<span>Instructions:</span>
<br />
<span data-tmpl="instructions" class="sans-light text-break preline"></span>
Expand Down
33 changes: 10 additions & 23 deletions client/webserver/site/src/localized_html/pt-BR/wallets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -282,26 +282,6 @@
<div class="fs15 pt-3 text-center d-hide errcolor" id="recoverWalletErr"></div>
</form>

{{- /* EXPORT WALLET DISCLAIMER */ -}}
<form class="d-hide" id="exportWalletDisclaimer">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
<div class="py-1 text-center position-relative fs22 sans-light">
Export Wallet
</div>
<div class="fs15 text-start mt-2">
Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS. It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="fs15 text-start mt-2">
Please type the following to confirm that you understand the risks of exporting the wallet:
</div>
<span id="retypeText" class="fs15 text-start bold underline">I will not use any external wallet while I have active trades in the DEX</span>
<input class="form-control mt-2" id="disclaimerInput" >
<div class="d-flex justify-content-end mt-4">
<button id="disclaimerSubmit" type="button" class="justify-content-center fs15 bg2 selected">Enviar</button>
</div>
<div class="fs15 pt-3 text-center d-hide errcolor text-break" id="disclaimerErr"></div>
</form>

{{- /* EXPORT WALLET AUTHORIZATION */ -}}
<form class="d-hide" id="exportWalletAuth">
<div class="form-closer hoverbg"><span class="ico-cross"></span></div>
Expand All @@ -311,6 +291,9 @@
<div class="fs15 text-start mt-2">
Enter your app password to show the wallet seed. Make sure nobody else can see your screen. If anyone gets access to the wallet seed, they will be able to steal all of your funds.
</div>
<div id="exportDisclaimer" class="fs15 text-start mt-2">
<span class="warning-text">Using an externally restored wallet while you have active trades running in the DEX could result in failed trades and LOST FUNDS.</span> It is recommended that you do not export your wallet unless you are an experienced user and you know what are doing.
</div>
<div class="text-start mt-2">
<label for="exportWalletPW" class="ps-1 mb-1">Senha</label>
<input type="password" class="form-control select" id="exportWalletPW" autocomplete="current-password">
Expand All @@ -330,15 +313,19 @@
<div class="fs15 text-start mt-2">
Below are the seeds needed to restore your wallet in some popular external wallets. DO NOT make transactions with your external wallet while you have active trades running on the DEX.
</div>
<div class="fs15 text-start mt-2 warning-text">
Copy/Pasting a wallet seed is a potential security risk. Do this at your own risk.
</div>
<hr />
<div id="restoreInfoCardsList">
<div id="restoreInfoCard">
<span data-tmpl="name" class="text-left position-relative fs20 sans-light bold underline"></span>
<br />
<span>Seed:</span>
<br />
<span data-tmpl="seed" class="sans-light text-break"></span>
<span data-tmpl="seedName"></span>
<br />
<div>
<span data-tmpl="seed" class="mono fs14"></span>
</div>
<span>Instructions:</span>
<br />
<span data-tmpl="instructions" class="sans-light text-break preline"></span>
Expand Down
Loading

0 comments on commit ef36ba8

Please sign in to comment.