Skip to content

Commit

Permalink
fix/fixed_transfers_parsing
Browse files Browse the repository at this point in the history
Fixed transfers parsing from Deploy
  • Loading branch information
ZhmakAS committed Aug 12, 2024
1 parent 690206e commit 14432cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions tests/rpc/rpc_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ func Test_DefaultClient_GetTransaction_Example(t *testing.T) {

if tt.withTransfers {
assert.NotEmpty(t, result.ExecutionInfo.ExecutionResult.Transfers)
assert.NotEmpty(t, result.ExecutionInfo.ExecutionResult.Transfers[0].TransactionHash.TransactionV1)
}
})
}
Expand Down
19 changes: 9 additions & 10 deletions types/execution_result.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,10 @@ func (v *ExecutionResult) UnmarshalJSON(data []byte) error {
}

func NewExecutionResultFromV1(v1 ExecutionResultV1) ExecutionResult {
transforms := make([]Transform, 0)
if v1.Success != nil {
for _, transform := range v1.Success.Effect.Transforms {
transforms = append(transforms, Transform{
Key: transform.Key,
Kind: transform.Transform,
})
}
transforms := make([]Transform, 0, len(v1.Success.Effect.Transforms))
transfers := make([]Transfer, 0)

transfers := make([]Transfer, 0)
if v1.Success != nil {
for _, transform := range v1.Success.Effect.Transforms {
if !transform.Transform.IsWriteTransfer() {
continue
Expand All @@ -122,7 +116,7 @@ func NewExecutionResultFromV1(v1 ExecutionResultV1) ExecutionResult {
transfers = append(transfers, Transfer{
Amount: writeTransfer.Amount,
TransactionHash: TransactionHash{
TransactionV1: transform.Key.Hash,
TransactionV1: &transform.Key.Transfer.Hash,
},
From: InitiatorAddr{
AccountHash: &writeTransfer.From,
Expand All @@ -133,6 +127,11 @@ func NewExecutionResultFromV1(v1 ExecutionResultV1) ExecutionResult {
Target: writeTransfer.Target,
To: toHash,
})

transforms = append(transforms, Transform{
Key: transform.Key,
Kind: transform.Transform,
})
}
return ExecutionResult{
Limit: 0, // limit is unknown field for V1 Deploy
Expand Down

0 comments on commit 14432cf

Please sign in to comment.