Skip to content

Commit

Permalink
fix: manual button now opens qr code
Browse files Browse the repository at this point in the history
closes #30
  • Loading branch information
dafuga committed Sep 15, 2023
1 parent 5572347 commit c3bb0c6
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,29 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
// Add the callback to the request
const callback = setTransactionCallback(modifiedRequest, this.buoyUrl)

const request = modifiedRequest.encode(true, false)

const signManually = () => {
context.ui?.prompt({
title: t('transact.sign_manually.title', { default: 'Sign manually' }),
body: t('transact.sign_manually.body', { default: 'Scan the QR-code with Anchor on another device or use the button to open it here.' }),
elements: [
{
type: 'qr',
data: String(request),
},
{
type: 'link',
label: t('transact.sign_manually.link.title', { default: 'Open Anchor' }),
data: {
href: String(request),
label: t('transact.sign_manually.link.title', { default: 'Open Anchor' }),
},
},
],
})
}

// Tell Wharf we need to prompt the user with a QR code and a button
const promptPromise: Cancelable<PromptResponse> = context.ui.prompt({
title: t('transact.title', {default: 'Complete using Anchor'}),
Expand All @@ -240,10 +263,11 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
},
},
{
type: 'link',
type: 'button',
label: t('transact.label', {default: 'Sign manually or with another device'}),
data: {
href: modifiedRequest.encode(true, false, 'esr:'),
onClick: signManually,
label: t('transact.label', {
default: 'Sign manually or with another device',
}),
Expand Down

0 comments on commit c3bb0c6

Please sign in to comment.