fix: minor issues and adding method to retrieve the stickermarket contract address
This commit is contained in:
parent
efae55539a
commit
c59335aa86
|
@ -134,8 +134,6 @@ func (api *API) Market(chainID uint64) ([]StickerPack, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case <-doneChan:
|
case <-doneChan:
|
||||||
// TODO: add an attribute to indicate if the sticker pack
|
|
||||||
// is bought, but the transaction is still pending confirmation.
|
|
||||||
var result []StickerPack
|
var result []StickerPack
|
||||||
for _, pack := range allStickerPacks {
|
for _, pack := range allStickerPacks {
|
||||||
packID := uint(pack.ID.Uint64())
|
packID := uint(pack.ID.Uint64())
|
||||||
|
@ -147,6 +145,7 @@ func (api *API) Market(chainID uint64) ([]StickerPack, error) {
|
||||||
}
|
}
|
||||||
result = append(result, pack)
|
result = append(result, pack)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,6 +326,7 @@ func (api *API) fetchStickerPacks(chainID uint64, resultChan chan<- *StickerPack
|
||||||
resultChan <- stickerPack
|
resultChan <- stickerPack
|
||||||
}(i)
|
}(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.WaitAllDone()
|
c.WaitAllDone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,25 @@ func (api *API) Pending() (map[uint]StickerPack, error) {
|
||||||
|
|
||||||
for packID, stickerPack := range stickerPacks {
|
for packID, stickerPack := range stickerPacks {
|
||||||
stickerPack.Status = statusPending
|
stickerPack.Status = statusPending
|
||||||
|
|
||||||
|
stickerPack.Preview, err = decodeStringHash(stickerPack.Preview)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
stickerPack.Thumbnail, err = decodeStringHash(stickerPack.Thumbnail)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, sticker := range stickerPack.Stickers {
|
||||||
|
sticker.URL, err = decodeStringHash(sticker.Hash)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
stickerPack.Stickers[i] = sticker
|
||||||
|
}
|
||||||
|
|
||||||
stickerPacks[packID] = stickerPack
|
stickerPacks[packID] = stickerPack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,25 +7,30 @@ import (
|
||||||
const maxNumberRecentStickers = 24
|
const maxNumberRecentStickers = 24
|
||||||
|
|
||||||
func (api *API) recentStickers() ([]Sticker, error) {
|
func (api *API) recentStickers() ([]Sticker, error) {
|
||||||
var recentStickersList []Sticker
|
recentStickersList := make([]Sticker, 0)
|
||||||
|
|
||||||
recentStickersJSON, err := api.accountsDB.GetRecentStickers()
|
recentStickersJSON, err := api.accountsDB.GetRecentStickers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return recentStickersList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if recentStickersJSON == nil {
|
if recentStickersJSON == nil {
|
||||||
return nil, nil
|
return recentStickersList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(*recentStickersJSON, &recentStickersList)
|
err = json.Unmarshal(*recentStickersJSON, &recentStickersList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return recentStickersList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return recentStickersList, nil
|
return recentStickersList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *API) ClearRecent() error {
|
||||||
|
recentStickersList := []Sticker{}
|
||||||
|
return api.accountsDB.SaveSetting("stickers/recent-stickers", recentStickersList)
|
||||||
|
}
|
||||||
|
|
||||||
func (api *API) Recent() ([]Sticker, error) {
|
func (api *API) Recent() ([]Sticker, error) {
|
||||||
recentStickersList, err := api.recentStickers()
|
recentStickersList, err := api.recentStickers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -29,11 +29,6 @@ func (api *API) getSigner(chainID uint64, from types.Address, password string) b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) Buy(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, packID *bigint.BigInt, password string) (string, error) {
|
func (api *API) Buy(ctx context.Context, chainID uint64, txArgs transactions.SendTxArgs, packID *bigint.BigInt, password string) (string, error) {
|
||||||
err := api.AddPending(chainID, packID)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
|
|
||||||
snt, err := api.contractMaker.NewSNT(chainID)
|
snt, err := api.contractMaker.NewSNT(chainID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -78,6 +73,11 @@ func (api *API) Buy(ctx context.Context, chainID uint64, txArgs transactions.Sen
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = api.AddPending(chainID, packID)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: track pending transaction (do this in ENS service too)
|
// TODO: track pending transaction (do this in ENS service too)
|
||||||
|
|
||||||
go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(types.Hash(tx.Hash()))
|
go api.rpcFiltersSrvc.TriggerTransactionSentToUpstreamEvent(types.Hash(tx.Hash()))
|
||||||
|
@ -140,3 +140,7 @@ func (api *API) BuyEstimate(ctx context.Context, chainID uint64, from types.Addr
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (api *API) StickerMarketAddress(ctx context.Context, chainID uint64) (common.Address, error) {
|
||||||
|
return stickers.StickerMarketContractAddress(chainID)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue