Commit ccf12b48 authored by duanjinfei's avatar duanjinfei

change getPoolInfo Api

parent d33ea02d
appname = nft-event-test appname = nft-event-test
httpport = 9001 httpport = 9000
runmode = test runmode = test
mysql = debian-sys-maint:H4khSGKhjhMJogpE@tcp(127.0.0.1:3306)/nftEventTest?charset=utf8 mysql = root:mysql2022@tcp(127.0.0.1:3306)/nftEventTest?charset=utf8
rpcUrl = https://eth-mainnet.g.alchemy.com/v2/1GbX5zRzYZHK-ZoFbbI2zQM2WOjafq2s rpcUrl = https://eth-mainnet.g.alchemy.com/v2/1GbX5zRzYZHK-ZoFbbI2zQM2WOjafq2s
deployedBlock = 17475300 deployedBlock = 17475300
isSyncLog = true isSyncLog = true
...@@ -16,5 +16,5 @@ signAccPrv = 84ffa1fd6216691a968ad3ce78ca66a5d3d2c56772fcd78b6b8e2a7976487e0f ...@@ -16,5 +16,5 @@ signAccPrv = 84ffa1fd6216691a968ad3ce78ca66a5d3d2c56772fcd78b6b8e2a7976487e0f
collectionName = redis collectionName = redis
conn = 127.0.0.1:6379 conn = 127.0.0.1:6379
dbNum = 1 dbNum = 1
password = c4HNxt6nyUoqzMby password = 123456
...@@ -173,6 +173,7 @@ func (c *LotteryController) ForwardReq() { ...@@ -173,6 +173,7 @@ func (c *LotteryController) ForwardReq() {
} }
func (c *LotteryController) GetPoolInfo() { func (c *LotteryController) GetPoolInfo() {
maxHistory := c.GetString("maxHistory")
contractStr := c.GetString("lotteryContract") contractStr := c.GetString("lotteryContract")
if !utils.IsNilString(contractStr) { if !utils.IsNilString(contractStr) {
c.ResponseInfo(500, models.PARAM_ERR, nil) c.ResponseInfo(500, models.PARAM_ERR, nil)
...@@ -190,7 +191,12 @@ func (c *LotteryController) GetPoolInfo() { ...@@ -190,7 +191,12 @@ func (c *LotteryController) GetPoolInfo() {
return return
} }
defer client.Close() defer client.Close()
abiBytes, err := os.Open("./sync/Lottery_Func.json") abiBytes := &os.File{}
if maxHistory != "" {
abiBytes, err = os.Open("./sync/Lottery_Duration.json")
} else {
abiBytes, err = os.Open("./sync/Lottery_Func.json")
}
if err != nil { if err != nil {
log.Error(models.READ_ABI_ERR, err) log.Error(models.READ_ABI_ERR, err)
c.ResponseInfo(500, models.READ_ABI_ERR, err.Error()) c.ResponseInfo(500, models.READ_ABI_ERR, err.Error())
...@@ -203,7 +209,23 @@ func (c *LotteryController) GetPoolInfo() { ...@@ -203,7 +209,23 @@ func (c *LotteryController) GetPoolInfo() {
c.ResponseInfo(500, models.PARSE_ABI_ERR, err.Error()) c.ResponseInfo(500, models.PARSE_ABI_ERR, err.Error())
return return
} }
data, err := contractAbi.Pack("getPoolInfo") data := make([]byte, 0)
if maxHistory != "" {
maxHistoryParam := big.NewInt(0)
_, setRes := maxHistoryParam.SetString(maxHistory, 10)
if !setRes {
c.ResponseInfo(500, models.PARAM_ERR, nil)
return
}
data, err = contractAbi.Pack("getPoolInfo", maxHistoryParam)
if err != nil {
log.Error(models.PACK_ABI_ERR, err)
c.ResponseInfo(500, models.PACK_ABI_ERR, err.Error())
return
}
} else {
data, err = contractAbi.Pack("getPoolInfo")
}
if err != nil { if err != nil {
log.Error(models.PACK_ABI_ERR, err) log.Error(models.PACK_ABI_ERR, err)
c.ResponseInfo(500, models.PACK_ABI_ERR, err.Error()) c.ResponseInfo(500, models.PACK_ABI_ERR, err.Error())
......
[
{
"inputs": [
{
"internalType": "address",
"name": "_pool",
"type": "address"
},
{
"internalType": "uint256[]",
"name": "duration_",
"type": "uint256[]"
},
{
"internalType": "address payable[][]",
"name": "winner_",
"type": "address[][]"
},
{
"internalType": "string[][]",
"name": "tx_hash_",
"type": "string[][]"
},
{
"internalType": "bytes[][]",
"name": "sign_",
"type": "bytes[][]"
}
],
"name": "drawLottery",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "maxHistory_",
"type": "uint256"
}
],
"name": "getPoolInfo",
"outputs": [
{
"internalType": "bool[]",
"name": "started_",
"type": "bool[]"
},
{
"internalType": "address[]",
"name": "nftAddrs_",
"type": "address[]"
},
{
"internalType": "string[][]",
"name": "nftInfo_",
"type": "string[][]"
},
{
"internalType": "uint256[][]",
"name": "poolInfo_",
"type": "uint256[][]"
},
{
"internalType": "uint256[][]",
"name": "poolHistory_",
"type": "uint256[][]"
}
],
"stateMutability": "view",
"type": "function"
}
]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment