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 a805f8d commit 93ff2a0
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,30 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
// Add the callback to the request
const callback = setTransactionCallback(resolved, this.buoyUrl)

const request = resolved.request.encode(true, false)

const signManually = () => {
console.log('sign manually')
context.ui?.prompt({
title: 'Sign manually',
body: 'Scan the QR-code with Anchor on another device or use the button to open it here.',
elements: [
{
type: 'qr',
data: String(request),
},
{
type: 'button',
label: 'Open Anchor',
data: {
href: String(request),
label: '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: 'Sign',
Expand All @@ -210,10 +234,10 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
data: expiration.toISOString(),
},
{
type: 'link',
type: 'button',
label: 'Sign manually or with another device',
data: {
href: resolved.request.encode(true, false),
onClick: signManually,
label: 'Trigger Manually',
},
},
Expand Down

0 comments on commit 93ff2a0

Please sign in to comment.