Skip to content

Commit

Permalink
Creating a new request based on what was previously resolved
Browse files Browse the repository at this point in the history
Using the original request from within the resolved request was undoing the placeholder resolution that occurs already in the session kit.

Since we need a new request here (modified with the link key), we'll just create a new request and pass that instead.
  • Loading branch information
aaroncox committed Sep 13, 2023
1 parent 326f8e7 commit ca657f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
// Add the callback to the request
const callback = setTransactionCallback(resolved, this.buoyUrl)

// Create a new signing request based on the existing resolved request
const modifiedRequest = await context.createRequest({transaction: resolved.transaction})

// 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,7 +243,7 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
type: 'link',
label: t('transact.label', {default: 'Sign manually or with another device'}),
data: {
href: resolved.request.encode(true, false, 'esr:'),
href: modifiedRequest.encode(true, false, 'esr:'),
label: t('transact.label', {
default: 'Sign manually or with another device',
}),
Expand All @@ -263,7 +266,7 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
promptPromise.catch(() => clearTimeout(timer))

// Set the expiration on the request LinkInfo
resolved.request.setInfoKey(
modifiedRequest.setInfoKey(
'link',
LinkInfo.from({
expiration,
Expand All @@ -277,7 +280,7 @@ export class WalletPluginAnchor extends AbstractWalletPlugin {
const service = new URL(this.data.channelUrl).origin
const channel = new URL(this.data.channelUrl).pathname.substring(1)
const sealedMessage = sealMessage(
resolved.request.encode(true, false, 'esr:'),
modifiedRequest.encode(true, false, 'esr:'),
PrivateKey.from(this.data.privateKey),
PublicKey.from(this.data.signerKey)
)
Expand Down

0 comments on commit ca657f2

Please sign in to comment.