nft质押任务逻辑

This commit is contained in:
lianghuanjie
2024-12-27 18:06:13 +08:00
parent a22f73df20
commit 31a674080d
39 changed files with 1532 additions and 99 deletions

View File

@@ -2,9 +2,11 @@ package task
import (
"context"
"encoding/json"
"errors"
"github.com/spf13/cast"
"github.com/zeromicro/go-zero/core/logx"
"nova_task/internal/consts"
"nova_task/internal/model"
"nova_task/internal/pkg/aptos"
"nova_task/internal/pkg/errs"
@@ -99,12 +101,28 @@ func (l *VerifyTaskResultLogic) VerifyTaskResult(req *types.VerifyTaskResultReq)
}
func (l *VerifyTaskResultLogic) checkoutTranscation(uid int, txHash string) bool {
address, err := aptos.GetTransactionOwnerAddress(l.svcCtx.Config.DailyPay.Contract, txHash, l.svcCtx.Config.DailyPay.Network)
conf := struct {
Contract string `json:"contract"`
Network string `json:"network"`
}{}
cf, err := l.svcCtx.ConfigModel.FindOneByName(l.ctx, consts.DailyPayConf)
if err != nil {
if !errors.Is(err, model.ErrNotFound) {
l.Errorw("find daily pay conf error", logx.Field("err", err))
}
return false
}
err = json.Unmarshal([]byte(cf.Value), &conf)
if err != nil {
l.Errorw("unmarshal daily pay conf error", logx.Field("err", err), logx.Field("value", cf.Value))
return false
}
address, err := aptos.GetTransactionOwnerAddress(conf.Contract, txHash, conf.Network)
if err != nil {
l.Errorw("get transaction owner address error", logx.Field("err", err))
return false
}
targetUid, err := l.svcCtx.WalletModel.FindWalletByAddress(l.ctx, address)
targetUid, err := l.svcCtx.WalletModel.FindUidByAddress(l.ctx, address)
if err != nil {
l.Errorw("find wallet by address error", logx.Field("err", err), logx.Field("address", address), logx.Field("target_uid", targetUid))
return false