Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/soroban-transactions' into sorob…
Browse files Browse the repository at this point in the history
…an-transactions
  • Loading branch information
lucasmagnus committed Oct 23, 2023
2 parents a8dc7b9 + 018403d commit 1df62e9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions backend/internal/entity/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ type (
PublicKey string `json:"publicKey"`
}

SorobanTransactionResponse struct {
Id int `json:"id"`
Envelope string `json:"envelope"`
}

SubmitRequest struct {
Id int `json:"id"`
Envelope string `json:"envelope"`
Expand Down
4 changes: 2 additions & 2 deletions backend/migrations/000024_refact_permissions.up.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DELETE FROM permission WHERE ID = 2;
DELETE FROM permission WHERE ID = 6;
DELETE FROM permission WHERE ID = 2 ;
DELETE FROM permission WHERE ID = 6 ;
UPDATE permission SET name = 'Token management' WHERE ID = 3;
UPDATE permission SET name = 'Transfer internally' WHERE ID = 4;
UPDATE permission SET name = 'Transfer externally' WHERE ID = 5;
13 changes: 13 additions & 0 deletions backend/pkg/kafka/deserializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ func (d *Deserializer) DeserializeMessage(msg *kafka.Message, chanName string) (
return d.deserializeHorizonMessage(msg)
case entity.EnvelopeChannel:
return d.deserializeEnvelopeMessage(msg)
case entity.SignChannel:
return d.deserializeEnvelopSorobanTransaction(msg)
case entity.SubmitTransactionChannel:
return d.deserializeEnvelopeMessage(msg)
default:
return nil, fmt.Errorf("invalid channel name: %s", chanName)
}
Expand Down Expand Up @@ -55,6 +59,15 @@ func (d *Deserializer) deserializeEnvelopeMessage(msg *kafka.Message) (entity.En
return data, nil
}

func (d *Deserializer) deserializeEnvelopSorobanTransaction(msg *kafka.Message) (entity.SignTransactionRequest, error) {
data := entity.SignTransactionRequest{}
err := d.unmarshalMessage(msg, &data)
if err != nil {
return data, fmt.Errorf("failed to deserialize envelope response: %w", err)
}
return data, nil
}

func (d *Deserializer) unmarshalMessage(msg *kafka.Message, v interface{}) error {
if d.schemaEnabled {
return d.exec.DeserializeInto(*msg.TopicPartition.Topic, msg.Value, v)
Expand Down

0 comments on commit 1df62e9

Please sign in to comment.