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

One-click Auth getting error "Signature verification failed" #60

Open
tuonght93 opened this issue Nov 21, 2024 · 0 comments
Open

One-click Auth getting error "Signature verification failed" #60

tuonght93 opened this issue Nov 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@tuonght93
Copy link

tuonght93 commented Nov 21, 2024

Describe the bug
Follow document: https://docs.reown.com/walletkit/ios/one-click-auth
`let sessionAuthenticate = sessionAuthenticateMap[id]
guard let sessionAuthenticate = sessionAuthenticate else {
reject("", "", NSError(domain: "", code: 0))
return
}

    let requestedChains = Set(sessionAuthenticate.payload.chains.compactMap { Blockchain($0) })
    let supportedChains = Set(chains.compactMap{Blockchain($0)})
    let commonChains = requestedChains.intersection(supportedChains)
    let supportedMethods = [
      "personal_sign"
    ]
    
    var authObjects = [AuthObject]()
    
    for chain in commonChains {
      let accountForChain = Account("\(chain):\(address)")!
      let supportedAuthPayload = try WalletKit.instance.buildAuthPayload(
          payload: sessionAuthenticate.payload,
          supportedEVMChains: Array(supportedChains),
          supportedMethods: supportedMethods
      )
      let formattedMessage = try WalletKit.instance.formatAuthMessage(payload: supportedAuthPayload, account: accountForChain)
      let signature = try messageSigner.sign(message: formattedMessage, privateKey: Data(hex: privateKey), type: .eip191)

      let authObject = try WalletKit.instance.buildSignedAuthObject(
          authPayload: supportedAuthPayload,
          signature: signature,
          account: accountForChain
      )
      authObjects.append(authObject)
    }
    
    let session = try await WalletKit.instance.approveSessionAuthenticate(requestId: sessionAuthenticate.id, auths: authObjects)
    if(session != nil) {
      print(session!)
    }`

I follow a document but getting error when approveSessionAuthenticate. I don't know what is the problem with signature.

SDK Version

  • Client: [Swift]
  • Version [1.0.7]

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Device (please complete the following information):

  • Device: [iPhone13]
  • OS: [iOS17.4]
@tuonght93 tuonght93 added the bug Something isn't working label Nov 21, 2024
@llbartekll llbartekll self-assigned this Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants