Skip to content

Commit

Permalink
remove buy artwork func from v4_2
Browse files Browse the repository at this point in the history
  • Loading branch information
hvthhien committed Jun 17, 2024
1 parent ef0c53b commit d02d0a4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 102 deletions.
99 changes: 0 additions & 99 deletions contracts/feralfile-exhibition-v4_2/feralfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,32 +158,6 @@ func (c *FeralfileExhibitionV4_2Contract) Call(
}

return contract.TransferOwnership(t, newOwner)
case "buyArtworks":
if len(params) != 4 {
return nil, errors.New("Invalid parameters")
}

r, ok := params[0].([32]byte)
if !ok {
return nil, fmt.Errorf("invalid r")
}

s, ok := params[1].([32]byte)
if !ok {
return nil, fmt.Errorf("invalid s")
}

v, ok := params[2].(uint8)
if !ok {
return nil, fmt.Errorf("invalid v")
}

saleData, ok := params[3].(feralfilev4.IFeralfileSaleDataSaleData)
if !ok {
return nil, fmt.Errorf("invalid sale data")
}

return contract.BuyArtworks(t, r, s, v, saleData)
case "buyBulkArtworks":
if len(params) != 4 {
return nil, errors.New("Invalid parameters")
Expand Down Expand Up @@ -322,79 +296,6 @@ func (c *FeralfileExhibitionV4_2Contract) Parse(
}

return []interface{}{params.Operator, params.Approved}, nil
case "buyArtworks":
var params struct {
SaleData struct {
Price ethereum.BigInt `json:"price"`
Cost ethereum.BigInt `json:"cost"`
ExpiryTime ethereum.BigInt `json:"expiryTime"`
Destination common.Address `json:"destination"`
TokenIds []ethereum.BigInt `json:"tokenIds"`
RevenueShares [][]struct {
Recipient common.Address `json:"recipient"`
Bps ethereum.BigInt `json:"bps"`
} `json:"revenueShares"`
PayByVaultContract bool `json:"payByVaultContract"`
} `json:"saleData"`
R string `json:"r"`
S string `json:"s"`
V string `json:"v"`
}

if err := json.Unmarshal(arguments, &params); err != nil {
return nil, err
}

rVal, err := hex.DecodeString(strings.Replace(params.R, "0x", "", -1))
if err != nil {
return nil, err
}
sVal, err := hex.DecodeString(strings.Replace(params.S, "0x", "", -1))
if err != nil {
return nil, err
}
vVal, err := strconv.ParseUint(strings.Replace(params.V, "0x", "", -1), 16, 64)
if err != nil {
return nil, err
}
if len(rVal) != 32 || len(sVal) != 32 {
return nil, errors.New("required signature length is 32")
}
var r32Val [32]byte
var s32Val [32]byte
copy(r32Val[:], rVal)
copy(s32Val[:], sVal)

tokenIDs := make([]*big.Int, 0)
for _, v := range params.SaleData.TokenIds {
tokenID := v.Int
tokenIDs = append(tokenIDs, &tokenID)
}

revenueShares := make([][]feralfilev4.IFeralfileSaleDataRevenueShare, 0)
for _, v := range params.SaleData.RevenueShares {
revenueShare := make([]feralfilev4.IFeralfileSaleDataRevenueShare, 0)
for _, vv := range v {
bps := vv.Bps.Int
revenueShare = append(revenueShare, feralfilev4.IFeralfileSaleDataRevenueShare{
Recipient: vv.Recipient,
Bps: &bps,
})
}
revenueShares = append(revenueShares, revenueShare)
}

saleData := feralfilev4.IFeralfileSaleDataSaleData{
Price: &params.SaleData.Price.Int,
Cost: &params.SaleData.Cost.Int,
ExpiryTime: &params.SaleData.ExpiryTime.Int,
Destination: params.SaleData.Destination,
TokenIds: tokenIDs,
RevenueShares: revenueShares,
PayByVaultContract: params.SaleData.PayByVaultContract,
}

return []interface{}{r32Val, s32Val, uint8(vVal), saleData}, nil
case "buyBulkArtworks":
var params struct {
SaleData struct {
Expand Down
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/bitmark-inc/account-vault-ethereum
go 1.20

require (
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240614091658-dbebe04cccb7
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240617045334-b5d26d3a3dec
github.com/ethereum/go-ethereum v1.13.10
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240614091658-dbebe04cccb7 h1:6tuC/1cXXRWopf8NSOOOvG6IGNSp6SHLMbvrYNoHx/k=
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240614091658-dbebe04cccb7/go.mod h1:shvtsuJyQJnByXKqf9n/jpjL4++FSJCFjXR/08iBnFY=
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240617045334-b5d26d3a3dec h1:XlRCTNovfqBGhXDVqsuiCLtSoDF4qQszXRdjimicw04=
github.com/bitmark-inc/feralfile-exhibition-smart-contract/go-binding v0.0.0-20240617045334-b5d26d3a3dec/go.mod h1:shvtsuJyQJnByXKqf9n/jpjL4++FSJCFjXR/08iBnFY=
github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88=
github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
Expand Down

0 comments on commit d02d0a4

Please sign in to comment.