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

New relayed v3 #332

Open
wants to merge 5 commits into
base: rc/spica-patch-relayedv3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions data/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ type GuardedTransactionHandler interface {
GetDataForSigning(encoder Encoder, marshaller Marshaller, hasher Hasher) ([]byte, error)
}

// RelayedTransactionHandler defines functionality for the relayed transactions
type RelayedTransactionHandler interface {
GetRelayerAddr() []byte
GetRelayerSignature() []byte
GetSignature() []byte
GetDataForSigning(encoder Encoder, marshaller Marshaller, hasher Hasher) ([]byte, error)
}

// LogHandler defines the type for a log resulted from executing a transaction or smart contract call
type LogHandler interface {
// GetAddress returns the address of the sc that was originally called by the user
Expand Down
1 change: 1 addition & 0 deletions data/transaction/apiTransactionResult.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type ApiTransactionResult struct {
IsRefund bool `json:"isRefund,omitempty"`
CallType string `json:"callType,omitempty"`
RelayerAddress string `json:"relayerAddress,omitempty"`
RelayerSignature string `json:"relayerSignature,omitempty"`
RelayedValue string `json:"relayedValue,omitempty"`
ChainID string `json:"chainID,omitempty"`
Version uint32 `json:"version,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions data/transaction/frontendTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ type FrontendTransaction struct {
Options uint32 `json:"options,omitempty"`
GuardianAddr string `json:"guardian,omitempty"`
GuardianSignature string `json:"guardianSignature,omitempty"`
RelayerAddr string `json:"relayer,omitempty"`
RelayerSignature string `json:"relayerSignature,omitempty"`
}
9 changes: 9 additions & 0 deletions data/transaction/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ func (tx *Transaction) GetDataForSigning(encoder data.Encoder, marshaller data.M
ftx.GuardianAddr = guardianAddr
}

if len(tx.RelayerAddr) > 0 {
relayerAddr, errRelayer := encoder.Encode(tx.RelayerAddr)
if errRelayer != nil {
return nil, errRelayer
}

ftx.RelayerAddr = relayerAddr
}

ftxBytes, err := marshaller.Marshal(ftx)
if err != nil {
return nil, err
Expand Down
199 changes: 161 additions & 38 deletions data/transaction/transaction.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions data/transaction/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ message Transaction {
uint32 Options = 13 [(gogoproto.jsontag) = "options,omitempty"];
bytes GuardianAddr = 14 [(gogoproto.jsontag) = "guardian,omitempty"];
bytes GuardianSignature = 15 [(gogoproto.jsontag) = "guardianSignature,omitempty"];
bytes RelayerAddr = 16 [(gogoproto.jsontag) = "relayer,omitempty"];
bytes RelayerSignature = 17 [(gogoproto.jsontag) = "relayerSignature,omitempty"];
}
Loading