1
This commit is contained in:
parent
c79822cab4
commit
4510a9795e
@ -4,6 +4,7 @@ const (
|
||||
NFT_TYPE_CFHERO = 1
|
||||
NFT_TYPE_GOLD_BULLION = 11
|
||||
NFT_TYPE_CFHERO_NORMAL = 12
|
||||
NFT_TYPE_FOUNDER_TAG = 13
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -38,7 +38,7 @@ WHERE A.idx > %d AND A.net_id = %d AND A.owner_address=? `,
|
||||
} else if filterType == 2 {
|
||||
sql += " AND (B.status IS NULL OR B.status <> '" + jccommon.ORDER_STATUS_ACTIVE + "') "
|
||||
} else if filterType == 3 {
|
||||
lockMeta := mt.Table.Contract.GetByName(jccommon.CONTRACT_NAME_NFTLock)
|
||||
lockMeta := mt.Table.Contract.GetByNetIdName(int32(netId), jccommon.CONTRACT_NAME_NFTLock)
|
||||
if lockMeta != nil {
|
||||
sql += " AND A.last_lock_address = ? AND A.token_type <> ?"
|
||||
params = []string{
|
||||
|
@ -43,7 +43,7 @@ func (this *MarketApi) LockList(c *gin.Context) {
|
||||
|
||||
pageSize := q5.AdjustRangeValue(q5.SafeToInt32(reqJson.PageSize), 1, 20)
|
||||
cursor := q5.SafeToInt64(reqJson.Cursor)
|
||||
nftLockMeta := mt.Table.Contract.GetByName(jccommon.CONTRACT_NAME_NFTLock)
|
||||
nftLockMeta := mt.Table.Contract.GetByNetIdName(int32(netId), jccommon.CONTRACT_NAME_NFTLock)
|
||||
sql := fmt.Sprintf(`
|
||||
SELECT * FROM t_nft
|
||||
WHERE idx > %d AND net_id = %d AND owner_address = '%s' AND token_type IN (%d, %d, %d) AND last_lock_address = ? `,
|
||||
|
@ -26,9 +26,9 @@ func (this *NftApi) Unlock(c *gin.Context) {
|
||||
f5.RspErr(c, 401, "params parse error")
|
||||
return
|
||||
}
|
||||
lockMeta := mt.Table.Contract.GetByName(jccommon.CONTRACT_NAME_NFTLock)
|
||||
heroMeta := mt.Table.Contract.GetByName(jccommon.CONTRACT_NAME_CFHero)
|
||||
normalHeroMeta := mt.Table.Contract.GetByName(jccommon.CONTRACT_NAME_CFNormalHero)
|
||||
lockMeta := mt.Table.Contract.GetByNetIdName(q5.SafeToInt32(reqJson.NetId), jccommon.CONTRACT_NAME_NFTLock)
|
||||
heroMeta := mt.Table.Contract.GetByNetIdName(q5.SafeToInt32(reqJson.NetId), jccommon.CONTRACT_NAME_CFHero)
|
||||
normalHeroMeta := mt.Table.Contract.GetByNetIdName(q5.SafeToInt32(reqJson.NetId), jccommon.CONTRACT_NAME_CFNormalHero)
|
||||
if (heroMeta == nil && normalHeroMeta == nil) || lockMeta == nil {
|
||||
f5.RspErr(c, 1, "contract_address params error")
|
||||
return
|
||||
@ -60,12 +60,15 @@ func (this *NftApi) Unlock(c *gin.Context) {
|
||||
params := map[string]string{
|
||||
"c": "BcService",
|
||||
"a": "nftUnlock",
|
||||
"account_address": ds.GetByName("last_lock_sender"),
|
||||
"account_address": accountAddress,
|
||||
"to_address": ds.GetByName("last_lock_sender"),
|
||||
"net_id": ds.GetByName("net_id"),
|
||||
"nft_address": ds.GetByName("contract_address"),
|
||||
"to_address": accountAddress,
|
||||
"token_ids": ds.GetByName("token_id"),
|
||||
}
|
||||
if q5.ToInt32(ds.GetByName("token_type")) == jccommon.NFT_TYPE_FOUNDER_TAG {
|
||||
params["account_address"] = ds.GetByName("last_lock_sender")
|
||||
}
|
||||
rspObj := &struct {
|
||||
ErrCode interface{} `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
|
@ -1,17 +1,109 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"mtb"
|
||||
"q5"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"encoding/json"
|
||||
"bufio"
|
||||
)
|
||||
|
||||
type Contract struct {
|
||||
mtb.Contract
|
||||
name string
|
||||
address string
|
||||
}
|
||||
|
||||
type ContractTable struct {
|
||||
f5.NameMetaTable[Contract]
|
||||
netIdNameHash *q5.ConcurrentMap[string, *Contract]
|
||||
netIdAddressHash *q5.ConcurrentMap[string, *Contract]
|
||||
}
|
||||
|
||||
func (this *Contract) Init1() {
|
||||
func (this *Contract) GetName() string {
|
||||
return this.name
|
||||
}
|
||||
|
||||
func (this *Contract) GetAddress() string {
|
||||
return this.address
|
||||
}
|
||||
|
||||
func (this *ContractTable) IsNoLoad() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *ContractTable) Load() {
|
||||
this.netIdNameHash = new(q5.ConcurrentMap[string, *Contract])
|
||||
this.netIdAddressHash = new(q5.ConcurrentMap[string, *Contract])
|
||||
nets := []interface{}{}
|
||||
{
|
||||
if f, err := os.Open("../config/nets.json"); err == nil {
|
||||
jsonStr, _ := bufio.NewReader(f).ReadString(0)
|
||||
if err := json.Unmarshal([]byte(jsonStr), &nets); err != nil {
|
||||
panic(fmt.Sprintf("load metafile json decode error %s %s", "nets.json", err))
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "nets.json", err))
|
||||
}
|
||||
}
|
||||
{
|
||||
for _, val := range nets {
|
||||
netId := q5.SafeToInt32(val)
|
||||
fileName := fmt.Sprintf("../config/nets/%d/contract.json", netId)
|
||||
if f, err := os.Open(fileName); err == nil {
|
||||
jsonStr, _ := bufio.NewReader(f).ReadString(0)
|
||||
contracts := []struct {
|
||||
Name string `json:"name"`
|
||||
Address string `json:"address"`
|
||||
}{}
|
||||
if err := json.Unmarshal([]byte(jsonStr), &contracts); err != nil {
|
||||
panic(fmt.Sprintf("load metafile json decode error %s %s", "contract.json", err))
|
||||
}
|
||||
for _, val2 := range contracts {
|
||||
p := new(Contract)
|
||||
p.name = q5.SafeToString(val2.Name)
|
||||
p.address = strings.ToLower(q5.SafeToString(val2.Address))
|
||||
{
|
||||
key := fmt.Sprintf("%d_%s", netId, p.name)
|
||||
this.netIdNameHash.Store(key, p)
|
||||
}
|
||||
{
|
||||
key := fmt.Sprintf("%d_%s", netId, p.address)
|
||||
this.netIdAddressHash.Store(key, p)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
panic(fmt.Sprintf("load metafile error %s %s", "contract.json", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ContractTable) PreInit1() {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) ElementsInit(int) {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) PostInit1() {
|
||||
|
||||
}
|
||||
|
||||
func (this *ContractTable) GetByNetIdName(netId int32, name string) *Contract {
|
||||
key := fmt.Sprintf("%d_%s", netId, name)
|
||||
if v, ok := this.netIdNameHash.Load(key); ok {
|
||||
return *v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contract {
|
||||
key := fmt.Sprintf("%d_%s", netId, address)
|
||||
if v, ok := this.netIdAddressHash.Load(key); ok {
|
||||
return *v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,7 @@ var Table = f5.New(func(this *table) {
|
||||
this.PrimKey = "info"
|
||||
})
|
||||
|
||||
this.Contract = f5.New(func(this *ContractTable) {
|
||||
this.FileName = "../config/contract.json"
|
||||
this.PrimKey = "name"
|
||||
})
|
||||
this.Contract = new(ContractTable)
|
||||
|
||||
this.Web3ServiceCluster = f5.New(func(this *Web3ServiceClusterTable) {
|
||||
this.FileName = "../config/web3service.cluster.json"
|
||||
|
@ -78,14 +78,6 @@ type Language struct {
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
type Contract struct {
|
||||
name string
|
||||
address string
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
type Web3ServiceCluster struct {
|
||||
url string
|
||||
|
||||
@ -356,22 +348,6 @@ func (this *Language) HasEn() bool {
|
||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||
}
|
||||
|
||||
func (this *Contract) GetName() string {
|
||||
return this.name
|
||||
}
|
||||
|
||||
func (this *Contract) HasName() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *Contract) GetAddress() string {
|
||||
return this.address
|
||||
}
|
||||
|
||||
func (this *Contract) HasAddress() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
func (this *Web3ServiceCluster) GetUrl() string {
|
||||
return this.url
|
||||
}
|
||||
@ -442,11 +418,6 @@ func (this *Language) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.en, "en", &this._flags1_, 2, kv)
|
||||
}
|
||||
|
||||
func (this *Contract) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.address, "address", &this._flags1_, 4, kv)
|
||||
}
|
||||
|
||||
func (this *Web3ServiceCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.url, "url", &this._flags1_, 1, kv)
|
||||
}
|
||||
|
@ -62,12 +62,6 @@ message Language
|
||||
optional string en = 2;
|
||||
}
|
||||
|
||||
message Contract
|
||||
{
|
||||
optional string name = 1;
|
||||
optional string address = 4;
|
||||
}
|
||||
|
||||
message Web3ServiceCluster
|
||||
{
|
||||
optional string url = 1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user