Skip to content

Commit

Permalink
Add validate session packes
Browse files Browse the repository at this point in the history
  • Loading branch information
Agusx1211 committed Sep 29, 2023
1 parent 8a0861e commit 61f6a4d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions intents/packets/validate_session.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package packets

import (
"encoding/json"
"fmt"

"github.com/0xsequence/go-sequence/intents"
)

type ValidateSessionPacket struct {
Code string `json:"code"`
Wallet string `json:"wallet"`
Session string `json:"session"`
}

const ValidateSessionPacketCode = "validateSession"

func (p *ValidateSessionPacket) Unmarshal(i *intents.Intent) error {
err := json.Unmarshal(i.Packet, &p)
if err != nil {
return err
}

if p.Code != ValidateSessionPacketCode {
return fmt.Errorf("packet code is not '%s', got '%s'", SignMessagePacketCode, p.Code)
}

return nil
}

const ValidateSessionPacketResponseCode = "validateSessionStarted"

type ValidateSessionPacketResponse struct {
Code string `json:"code"`

Data struct {
EmailSent bool `json:"emailSent"`
SmsSent bool `json:"smsSent"`
}
}

0 comments on commit 61f6a4d

Please sign in to comment.