Skip to content

Commit

Permalink
Fix: decode enums
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Nov 29, 2023
1 parent 262f895 commit abd0381
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/dipdup-io/starknet-indexer
go 1.21

require (
github.com/dipdup-io/starknet-go-api v0.0.0-20230912113406-c699cdbd6582
github.com/dipdup-io/starknet-go-api v0.0.0-20231129152335-877b37e86db0
github.com/dipdup-io/workerpool v0.0.4
github.com/dipdup-net/go-lib v0.3.3
github.com/dipdup-net/indexer-sdk v0.0.4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/denisenkom/go-mssqldb v0.12.3 h1:pBSGx9Tq67pBOTLmxNuirNTeB8Vjmf886Kx+8Y+8shw=
github.com/dipdup-io/starknet-go-api v0.0.0-20230912113406-c699cdbd6582 h1:Mo5MDCO9Bqdj62Jrn1at/f44KOOzWCPF+ohu5jqlb4o=
github.com/dipdup-io/starknet-go-api v0.0.0-20230912113406-c699cdbd6582/go.mod h1:Pbi1et2OC3ZWhzv/76nDg5C0/v4Mrj7YWkZPXcZFys0=
github.com/dipdup-io/starknet-go-api v0.0.0-20231129152335-877b37e86db0 h1:kN20Ov/U90n3qRQti4PfjkWWlnoU/XcfTPmlAJvjRc8=
github.com/dipdup-io/starknet-go-api v0.0.0-20231129152335-877b37e86db0/go.mod h1:Pbi1et2OC3ZWhzv/76nDg5C0/v4Mrj7YWkZPXcZFys0=
github.com/dipdup-io/workerpool v0.0.4 h1:m58fuFY3VIPRc+trWpjw2Lsm4FvIgtjP/4VRe79r+/s=
github.com/dipdup-io/workerpool v0.0.4/go.mod h1:m6YMqx7M+fORTyabHD/auKymBRpbDax0t1aPZ1i7GZA=
github.com/dipdup-net/go-lib v0.3.3 h1:vTUI+sT4L+x+eiMf712Cg8EtlqUCMiN6M3vcNaPlCw8=
Expand Down
14 changes: 7 additions & 7 deletions pkg/indexer/decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func CalldataBySelector(contractAbi abi.Abi, selector []byte, calldata []string)
return nil, function.Name, nil
}

parsed, err := abi.DecodeFunctionCallData(calldata, *function, contractAbi.Structs)
parsed, err := abi.DecodeFunctionCallData(calldata, *function, contractAbi.Structs, contractAbi.Enums)
return parsed, function.Name, err
}

Expand All @@ -36,7 +36,7 @@ func CalldataForConstructor(classAbi abi.Abi, calldata []string) (map[string]any
}
}

return abi.DecodeFunctionCallData(calldata, *function, classAbi.Structs)
return abi.DecodeFunctionCallData(calldata, *function, classAbi.Structs, classAbi.Enums)
}

// CalldataForL1Handler -
Expand All @@ -50,7 +50,7 @@ func CalldataForL1Handler(contractAbi abi.Abi, selector []byte, calldata []strin
return nil, function.Name, nil
}

parsed, err := abi.DecodeFunctionCallData(calldata, *function, contractAbi.Structs)
parsed, err := abi.DecodeFunctionCallData(calldata, *function, contractAbi.Structs, contractAbi.Enums)
return parsed, function.Name, err
}

Expand All @@ -64,7 +64,7 @@ func Event(contractAbi abi.Abi, keys []string, data []string) (map[string]any, s
if !ok {
return nil, "", nil
}
parsed, err := abi.DecodeEventData(data, *event, contractAbi.Structs)
parsed, err := abi.DecodeEventData(data, *event, contractAbi.Structs, contractAbi.Enums)
return parsed, event.Name, err
}

Expand All @@ -79,7 +79,7 @@ func ResultForFunction(contractAbi abi.Abi, data []string, selector []byte) (map
return nil, errors.Wrapf(ErrUnknownSelector, "function %x", selector)
}

return abi.DecodeFunctionResult(data, *function, contractAbi.Structs)
return abi.DecodeFunctionResult(data, *function, contractAbi.Structs, contractAbi.Enums)
}

// ResultForL1Handler -
Expand All @@ -93,7 +93,7 @@ func ResultForL1Handler(contractAbi abi.Abi, data []string, selector []byte) (ma
return nil, errors.Wrapf(ErrUnknownSelector, "l1_handler %x", selector)
}

return abi.DecodeFunctionResult(data, *function, contractAbi.Structs)
return abi.DecodeFunctionResult(data, *function, contractAbi.Structs, contractAbi.Enums)
}

// ResultForConstructor -
Expand All @@ -107,7 +107,7 @@ func ResultForConstructor(contractAbi abi.Abi, data []string, selector []byte) (
return nil, errors.Wrapf(ErrUnknownSelector, "constructor %x", selector)
}

return abi.DecodeFunctionResult(data, *function, contractAbi.Structs)
return abi.DecodeFunctionResult(data, *function, contractAbi.Structs, contractAbi.Enums)
}

// Result -
Expand Down

0 comments on commit abd0381

Please sign in to comment.