Skip to content

Commit

Permalink
fix: getting the sign method to respond properly
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Dec 24, 2024
1 parent 2d8db6b commit 87221d8
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import {createIdentityRequest} from '@wharfkit/protocol-esr'
import {
createIdentityRequest,
extractSignaturesFromCallback,
isCallback,
} from '@wharfkit/protocol-esr'
import {
AbstractWalletPlugin,
Checksum256,
Expand Down Expand Up @@ -135,6 +139,37 @@ export class WalletPluginWebAuthenticator extends AbstractWalletPlugin implement
}`
const response = await this.openPopup(signUrl)

console.log('response', response)

const wasSuccessful =
isCallback(response.payload) &&
extractSignaturesFromCallback(response.payload).length > 0

console.log('wasSuccessful', wasSuccessful)
console.log('isCallback', isCallback(response.payload))
console.log(
'extractSignaturesFromCallback',
extractSignaturesFromCallback(response.payload)
)

if (wasSuccessful) {
// If the callback was resolved, create a new request from the response
const resolvedRequest = await ResolvedSigningRequest.fromPayload(
response.payload,
context.esrOptions
)

console.log('resolvedRequest', resolvedRequest)

// Return the new request and the signatures from the wallet
return {
signatures: extractSignaturesFromCallback(response.payload),
resolved: resolvedRequest,
}
} else {
throw new Error('Signing failed: No signatures returned')
}

return {
signatures: response.signatures.map((sig: string) => Signature.from(sig)),
}
Expand Down

0 comments on commit 87221d8

Please sign in to comment.