Skip to content

Commit

Permalink
add safeTransferFrom for contract v4
Browse files Browse the repository at this point in the history
  • Loading branch information
jollyjoker992 committed Mar 27, 2024
1 parent c0191ac commit ea2ef0c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions contracts/feralfile-exhibition-v4/feralfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,30 @@ func (c *FeralfileExhibitionV4Contract) Call(
t.GasLimit = gasLimit

return contract.SetApprovalForAll(t, operator, approved)
case "safeTransferFrom":
if len(params) != 3 {
return nil, fmt.Errorf("invalid params")
}

from, ok := params[0].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid from params")
}

to, ok := params[1].(common.Address)
if !ok {
return nil, fmt.Errorf("invalid to params")
}

tokenID, ok := params[2].(*big.Int)
if !ok {
return nil, fmt.Errorf("invalid token id params")
}

return contract.SafeTransferFrom(t,
from,
to,
tokenID)
default:
return nil, fmt.Errorf("unsupported method")
}
Expand Down Expand Up @@ -358,6 +382,17 @@ func (c *FeralfileExhibitionV4Contract) Parse(
}

return []interface{}{r32Val, s32Val, uint8(vVal), saleData}, nil
case "safeTransferFrom":
var params struct {
From common.Address `json:"from"`
To common.Address `json:"to"`
TokenID ethereum.BigInt `json:"token_id"`
}
if err := json.Unmarshal(arguments, &params); err != nil {
return nil, err
}

return []interface{}{params.From, params.To, &params.TokenID.Int}, nil
default:
return nil, fmt.Errorf("unsupported method")
}
Expand Down

0 comments on commit ea2ef0c

Please sign in to comment.