Skip to content
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
17 changes: 9 additions & 8 deletions rpc/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,16 @@ func (v *InfoGetDeployResult) UnmarshalJSON(data []byte) error {

if !strings.HasPrefix(version.ApiVersion, "2") {
var v1Compatible infoGetDeployResultV1Compatible
if err := json.Unmarshal(data, &v1Compatible); err == nil {
*v = InfoGetDeployResult{
ApiVersion: v1Compatible.ApiVersion,
Deploy: v1Compatible.Deploy,
ExecutionResults: types.DeployExecutionInfoFromV1(v1Compatible.ExecutionResults, v1Compatible.BlockHeight),
rawJSON: data,
}
return nil
if err := json.Unmarshal(data, &v1Compatible); err != nil {
return err
}
*v = InfoGetDeployResult{
ApiVersion: v1Compatible.ApiVersion,
Deploy: v1Compatible.Deploy,
ExecutionResults: types.DeployExecutionInfoFromV1(v1Compatible.ExecutionResults, v1Compatible.BlockHeight),
rawJSON: data,
}
return nil
}

var resp struct {
Expand Down
14 changes: 8 additions & 6 deletions types/execution_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ func NewExecutionResultFromV1(v1 ExecutionResultV1) ExecutionResult {
Kind: TransformKind(transform.Transform),
})
}
}

return ExecutionResult{
ErrorMessage: &v1.Failure.ErrorMessage,
Consumed: v1.Failure.Cost,
Effects: transforms,
originExecutionResultV1: &v1,
return ExecutionResult{
ErrorMessage: &v1.Failure.ErrorMessage,
Consumed: v1.Failure.Cost,
Effects: transforms,
originExecutionResultV1: &v1,
}
}

return ExecutionResult{}
}

// ExecutionResultV2 represents the result of executing a single deploy for V2 version
Expand Down
8 changes: 6 additions & 2 deletions types/transaction_scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package types
import (
"encoding/json"
"errors"
"fmt"
"time"

"github.com/make-software/casper-go-sdk/v2/types/clvalue"
Expand Down Expand Up @@ -73,14 +74,17 @@ func (t *TransactionScheduling) UnmarshalJSON(data []byte) error {
}

var key string
if err := json.Unmarshal(data, &key); err == nil && key == "Standard" {
if err := json.Unmarshal(data, &key); err != nil {
return err
}
if key == "Standard" {
*t = TransactionScheduling{
Standard: &struct{}{},
}
return nil
}

return nil
return fmt.Errorf("unknown transaction scheduling type: %s", key)
}

func (t TransactionScheduling) MarshalJSON() ([]byte, error) {
Expand Down
8 changes: 6 additions & 2 deletions types/transaction_target.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/hex"
"encoding/json"
"errors"
"fmt"

"github.com/make-software/casper-go-sdk/v2/types/clvalue"
"github.com/make-software/casper-go-sdk/v2/types/key"
Expand Down Expand Up @@ -104,14 +105,17 @@ func (t *TransactionTarget) UnmarshalJSON(data []byte) error {
}

var key string
if err := json.Unmarshal(data, &key); err == nil && key == "Native" {
if err := json.Unmarshal(data, &key); err != nil {
return err
}
if key == "Native" {
*t = TransactionTarget{
Native: &struct{}{},
}
return nil
}

return nil
return fmt.Errorf("unknown transaction target type: %s", key)
}

func (t TransactionTarget) MarshalJSON() ([]byte, error) {
Expand Down