fix: packId type and recent stickers comparison

This commit is contained in:
Richard Ramos 2022-02-14 19:25:56 -04:00
parent 8c7549bf5e
commit efae55539a
2 changed files with 7 additions and 6 deletions

View File

@ -52,7 +52,7 @@ func (api *API) AddRecent(sticker Sticker) error {
// Remove duplicated // Remove duplicated
idx := -1 idx := -1
for i, currSticker := range recentStickersList { for i, currSticker := range recentStickersList {
if currSticker.PackID.Cmp(sticker.PackID.Int) == 0 { if currSticker.PackID.Cmp(sticker.PackID.Int) == 0 && currSticker.Hash == sticker.Hash {
idx = i idx = i
} }
} }

View File

@ -56,7 +56,7 @@ func (api *API) Buy(ctx context.Context, chainID uint64, txArgs transactions.Sen
return "", err return "", err
} }
extraData, err := stickerMarketABI.Pack("buyToken", packID, packInfo.Price) extraData, err := stickerMarketABI.Pack("buyToken", packID.Int, txArgs.From, packInfo.Price)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -84,7 +84,7 @@ func (api *API) Buy(ctx context.Context, chainID uint64, txArgs transactions.Sen
return tx.Hash().String(), nil return tx.Hash().String(), nil
} }
func (api *API) BuyEstimate(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, packID *big.Int) (uint64, error) { func (api *API) BuyEstimate(ctx context.Context, chainID uint64, from types.Address, packID *bigint.BigInt) (uint64, error) {
callOpts := &bind.CallOpts{Context: api.ctx, Pending: false} callOpts := &bind.CallOpts{Context: api.ctx, Pending: false}
stickerType, err := api.contractMaker.NewStickerType(chainID) stickerType, err := api.contractMaker.NewStickerType(chainID)
@ -92,7 +92,7 @@ func (api *API) BuyEstimate(ctx context.Context, chainID uint64, txArgs transact
return 0, err return 0, err
} }
packInfo, err := stickerType.GetPackData(callOpts, packID) packInfo, err := stickerType.GetPackData(callOpts, packID.Int)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -102,7 +102,7 @@ func (api *API) BuyEstimate(ctx context.Context, chainID uint64, txArgs transact
return 0, err return 0, err
} }
extraData, err := stickerMarketABI.Pack("buyToken", packID, packInfo.Price) extraData, err := stickerMarketABI.Pack("buyToken", packID.Int, from, packInfo.Price)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -133,9 +133,10 @@ func (api *API) BuyEstimate(ctx context.Context, chainID uint64, txArgs transact
} }
return ethClient.EstimateGas(ctx, ethereum.CallMsg{ return ethClient.EstimateGas(ctx, ethereum.CallMsg{
From: common.Address(txArgs.From), From: common.Address(from),
To: &sntAddress, To: &sntAddress,
Value: big.NewInt(0), Value: big.NewInt(0),
Data: data, Data: data,
}) })
} }