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

Feature: Ledger Wallet Support for Signing Messages #562

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions src/i18n/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -981,9 +981,14 @@ msgid "Share"
msgstr "Teilen"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Nachricht signieren"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Unterzeichner"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Signiere Transaktionen..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -960,9 +960,14 @@ msgid "Share"
msgstr ""

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr ""

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr ""

#: src/views/SetupSwapSuccess.vue:651
msgid "Signing transactions..."
msgstr ""
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,14 @@ msgid "Share"
msgstr "Compartir"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Firmar Mensaje"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Firmador"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Firmando transacciones..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/fil.po
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,14 @@ msgid "Share"
msgstr "Magbahagi"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Mensahe sa Pag-sign"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Signer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing translations should be left empty, otherwise, our translators don't know that they'll need to work on those.

Also, missing translations automatically fall back to English, so no English fallback needs to be provided manually.


#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Pag-sign ng mga transaksyon ..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -976,9 +976,14 @@ msgid "Share"
msgstr "Partager"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Signer le message"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Signataire"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Signature des transactions..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/nl.po
Original file line number Diff line number Diff line change
Expand Up @@ -973,9 +973,14 @@ msgid "Share"
msgstr "Delen"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Bericht ondertekenen"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Ondertekenaar"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Transacties ondertekenen..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/pt.po
Original file line number Diff line number Diff line change
Expand Up @@ -969,9 +969,14 @@ msgid "Share"
msgstr "Partilhar"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Assinar Mensagem"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Signatário"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "A assinar transações..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -972,9 +972,14 @@ msgid "Share"
msgstr "Поделиться"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Подписать сообщение"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Отправитель"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Подписание транзакций..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,14 @@ msgid "Share"
msgstr "Paylaş"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Mesajı imzala"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Signer"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "İşlemler imzalanıyor..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/uk.po
Original file line number Diff line number Diff line change
Expand Up @@ -965,9 +965,14 @@ msgid "Share"
msgstr "Поділитися"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "Підписати повідомлення"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "Підписант"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "Підписання переказу..."
Expand Down
5 changes: 5 additions & 0 deletions src/i18n/zh.po
Original file line number Diff line number Diff line change
Expand Up @@ -955,9 +955,14 @@ msgid "Share"
msgstr "分享"

#: src/views/SignMessage.vue:5
#: src/views/SignMessageLedger.vue:5
msgid "Sign Message"
msgstr "签名信息"

#: src/views/SignMessageLedger.vue:17
msgid "Signer"
msgstr "签署者"

#: src/views/SetupSwapSuccess.vue:649
msgid "Signing transactions..."
msgstr "正在签署交易..."
Expand Down
7 changes: 5 additions & 2 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ const Migrate = () => import(/*webpackChunkName: "migrate"*/ './
const SignMessage = () => import(/*webpackChunkName: "sign-message"*/ './views/SignMessage.vue');
const SignMessageSuccess = () => import(/*webpackChunkName: "sign-message"*/ './views/SignMessageSuccess.vue');

const SignMessageLedger = () => import(/*webpackChunkName: "sign-message-ledger"*/
'./views/SignMessageLedger.vue');

const SimpleSuccess = () => import(/*webpackChunkName: "common"*/ './views/SimpleSuccess.vue');
const ErrorHandler = () => import(/*webpackChunkName: "common"*/ './views/ErrorHandler.vue');

Expand Down Expand Up @@ -340,8 +343,8 @@ export default new Router({
},
{
path: `/${RequestType.SIGN_MESSAGE}/ledger`,
component: ErrorHandlerUnsupportedLedger,
// not specifying a name here to not trigger automatic routing to this view in RpcApi.ts
component: SignMessageLedger,
name: `${RequestType.SIGN_MESSAGE}-ledger`,
},
{
path: `/${RequestType.SIGN_BTC_TRANSACTION}`,
Expand Down
40 changes: 24 additions & 16 deletions src/views/SignMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<AccountSelector
:wallets="processedWallets"
disableContracts
disableLedgerAccounts
@account-selected="setAccount"
@login="() => goToOnboarding(false)"/>
</SmallPage>
Expand Down Expand Up @@ -55,14 +54,14 @@ export default class SignMessage extends Vue {
private async created() {
if (this.request.signer) {
const wallet = this.findWalletByAddress(this.request.signer.toUserFriendlyAddress(), false);
if (wallet && wallet.type !== WalletType.LEDGER) {
if (wallet) {
this.setAccount(wallet.id, this.request.signer.toUserFriendlyAddress(), true);
return;
}
}

// If account not specified / found or is an unsupported Ledger account let the user pick another account.
// Don't automatically reject to not directly leak the information whether an account exists / is a Ledger.
// If account not specified / found let the user pick another account.
// Don't automatically reject to not directly leak the information whether an account exists.
this.showAccountSelector = true;
}

Expand Down Expand Up @@ -93,23 +92,32 @@ export default class SignMessage extends Vue {
});
}

// Forward to Keyguard
const request: KeyguardClient.SignMessageRequest = {
appName: this.request.appName,
// proceed to message signing
switch (walletInfo.type) {
case WalletType.LEDGER:
this.$router.push({name: `${RequestType.SIGN_MESSAGE}-ledger`});
return;
Comment on lines +97 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have to ensure the active account is set to the signer address, even when the address was not selected by the user but requested via the API. Otherwise, SignTransactionLedger will sign with the wrong address.

case WalletType.LEGACY:
case WalletType.BIP39:
// Forward to Keyguard
const request: KeyguardClient.SignMessageRequest = {
appName: this.request.appName,

keyId: walletInfo.keyId,
keyPath: accountInfo.path,
keyId: walletInfo.keyId,
keyPath: accountInfo.path,

message: this.request.message,
message: this.request.message,

signer: accountInfo.address.serialize(),
signerLabel: accountInfo.label,
};
signer: accountInfo.address.serialize(),
signerLabel: accountInfo.label,
};

staticStore.keyguardRequest = request;
staticStore.keyguardRequest = request;

const client = this.$rpc.createKeyguardClient(isFromRequest);
client.signMessage(request);
const client = this.$rpc.createKeyguardClient(isFromRequest);
client.signMessage(request);
return;
}
}

private goToOnboarding(useReplace?: boolean) {
Expand Down
Loading