Commit 227b3081 authored by duanjinfei's avatar duanjinfei

add api and change test runmode

parent d2847d49
appname = nft-event appname = nft-event-test
httpport = 9000 httpport = 9001
runmode = dev runmode = test
mysql = debian-sys-maint:H4khSGKhjhMJogpE@tcp(127.0.0.1:3306)/nftEvent?charset=utf8 mysql = debian-sys-maint:H4khSGKhjhMJogpE@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 = 17385225 deployedBlock = 17475300
isSyncLog = true isSyncLog = true
beforeEndReqUrl = https://meta.hapeprime.com/ beforeEndReqUrl = https://nftstorage.link/ipfs/
httpUrlRegex = ^(http|https):\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}(\/\S*)?$ httpUrlRegex = ^(http|https):\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,}(\/\S*)?$
goBackBlockNum = 5 goBackBlockNum = 5
lotteryContract = "0x0d593A2e848306506602f266F7434430f9d8E121;0x3fD11D9B782f7F1505B0C494efD13eA56D0da965"
lotteryContract = 0x847bF863DB75e25853DE42516bb4E0eFA715d9de
secret = 0x2Fc9Ba75f1c78ECc77D1a8fD3BDd6bA83eA68b7e secret = 0x2Fc9Ba75f1c78ECc77D1a8fD3BDd6bA83eA68b7e
signAccPrv = 84ffa1fd6216691a968ad3ce78ca66a5d3d2c56772fcd78b6b8e2a7976487e0f signAccPrv = 84ffa1fd6216691a968ad3ce78ca66a5d3d2c56772fcd78b6b8e2a7976487e0f
# redis config # redis config
......
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient" "github.com/ethereum/go-ethereum/ethclient"
...@@ -16,9 +17,10 @@ import ( ...@@ -16,9 +17,10 @@ import (
"github.com/wuban/nft-event/models" "github.com/wuban/nft-event/models"
"github.com/wuban/nft-event/utils" "github.com/wuban/nft-event/utils"
"io/ioutil" "io/ioutil"
"math/big"
"net/http" "net/http"
"os" "os"
"regexp" "strings"
) )
type LotteryController struct { type LotteryController struct {
...@@ -27,16 +29,18 @@ type LotteryController struct { ...@@ -27,16 +29,18 @@ type LotteryController struct {
func (c *LotteryController) GetTokenIdList() { func (c *LotteryController) GetTokenIdList() {
poolAddr := c.GetString("poolAddr") poolAddr := c.GetString("poolAddr")
if poolAddr == "" || !utils.IsAddress(poolAddr) { contractAddr := c.GetString("lotteryContract")
if !utils.IsNilString(contractAddr, poolAddr) || !utils.IsAddress(poolAddr, contractAddr) {
c.ResponseInfo(500, models.PARAM_ERR, "") c.ResponseInfo(500, models.PARAM_ERR, "")
return
} }
contractAddr := beego.AppConfig.String("lotteryContract")
o := orm.NewOrm() o := orm.NewOrm()
var lotteries []*models.Lottery var lotteries []*models.Lottery
_, err := o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).Distinct().OrderBy("period").All(&lotteries, "token_id", "period") _, err := o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).Distinct().OrderBy("period").All(&lotteries, "token_id", "period")
if err != nil { if err != nil {
c.ResponseInfo(500, models.PERIOD_ERR, err.Error()) c.ResponseInfo(500, models.PERIOD_ERR, err.Error())
return
} }
res := &models.LotteryPeriodListRes{ res := &models.LotteryPeriodListRes{
PoolAddr: poolAddr, PoolAddr: poolAddr,
...@@ -51,19 +55,22 @@ func (c *LotteryController) GetTokenIdList() { ...@@ -51,19 +55,22 @@ func (c *LotteryController) GetTokenIdList() {
func (c *LotteryController) GetUserList() { func (c *LotteryController) GetUserList() {
poolAddr := c.GetString("poolAddr") poolAddr := c.GetString("poolAddr")
if poolAddr == "" || !utils.IsAddress(poolAddr) { contractAddr := c.GetString("lotteryContract")
if !utils.IsNilString(contractAddr, poolAddr) || !utils.IsAddress(poolAddr, contractAddr) {
c.ResponseInfo(500, models.PARAM_ERR, "") c.ResponseInfo(500, models.PARAM_ERR, "")
return
} }
period, err := c.GetInt64("period") period, err := c.GetInt64("period")
if err != nil { if err != nil {
c.ResponseInfo(500, models.PARAM_ERR, err.Error()) c.ResponseInfo(500, models.PARAM_ERR, err.Error())
return
} }
contractAddr := beego.AppConfig.String("lotteryContract")
o := orm.NewOrm() o := orm.NewOrm()
var lotteries []*models.Lottery var lotteries []*models.Lottery
_, err = o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).Filter("period", period).OrderBy("-sort_by").All(&lotteries, "user", "value", "hash") _, err = o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).Filter("period", period).OrderBy("-sort_by").All(&lotteries, "user", "value", "hash")
if err != nil { if err != nil {
c.ResponseInfo(500, models.USER_ERR, err.Error()) c.ResponseInfo(500, models.USER_ERR, err.Error())
return
} }
res := make([]*models.LotteryUserList, 0) res := make([]*models.LotteryUserList, 0)
for i := 0; i < len(lotteries); i++ { for i := 0; i < len(lotteries); i++ {
...@@ -81,15 +88,17 @@ func (c *LotteryController) GetUserList() { ...@@ -81,15 +88,17 @@ func (c *LotteryController) GetUserList() {
func (c *LotteryController) GetHashSortByCondition() { func (c *LotteryController) GetHashSortByCondition() {
poolAddr := c.GetString("poolAddr") poolAddr := c.GetString("poolAddr")
period := c.GetString("period") period := c.GetString("period")
if period == "" || poolAddr == "" || !utils.IsAddress(poolAddr) { contractAddr := c.GetString("lotteryContract")
if !utils.IsNilString(period, contractAddr, poolAddr) || !utils.IsAddress(poolAddr, contractAddr) {
c.ResponseInfo(500, models.PARAM_ERR, nil) c.ResponseInfo(500, models.PARAM_ERR, nil)
return
} }
contractAddr := beego.AppConfig.String("lotteryContract")
o := orm.NewOrm() o := orm.NewOrm()
lotteries := make([]models.Lottery, 0) lotteries := make([]models.Lottery, 0)
_, err := o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("poolAddr", poolAddr).Filter("period", period).OrderBy("-sort_by").All(&lotteries) _, err := o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("poolAddr", poolAddr).Filter("period", period).OrderBy("-sort_by").All(&lotteries)
if err != nil { if err != nil {
c.ResponseInfo(500, models.SORTBY_ERR, err.Error()) c.ResponseInfo(500, models.SORTBY_ERR, err.Error())
return
} }
if len(lotteries) == 0 { if len(lotteries) == 0 {
c.ResponseInfo(200, models.DATA_NIL, nil) c.ResponseInfo(200, models.DATA_NIL, nil)
...@@ -103,33 +112,60 @@ func (c *LotteryController) GetHashSortByCondition() { ...@@ -103,33 +112,60 @@ func (c *LotteryController) GetHashSortByCondition() {
} }
func (c *LotteryController) ForwardReq() { func (c *LotteryController) ForwardReq() {
nftAddr := c.GetString("nftAddr")
id := c.GetString("id") id := c.GetString("id")
urlPattern := beego.AppConfig.String("httpUrlRegex") regex := utils.GetHttpRegex()
// 编译正则表达式 if !utils.IsNilString(id, nftAddr) || regex == nil || regex.MatchString(id) || regex.MatchString(nftAddr) {
regex, err := regexp.Compile(urlPattern) c.ResponseInfo(500, models.PARAM_ERR, nil)
return
}
rpc := beego.AppConfig.String("rpcUrl")
ethClient, err := ethclient.Dial(rpc)
if err != nil { if err != nil {
c.ResponseInfo(500, models.FAILED, err.Error()) log.Error(models.DIAL_RPC_ERR, err.Error())
c.ResponseInfo(500, models.DIAL_RPC_ERR, err.Error())
return
} }
if id == "" { if !utils.IsContractAddr(nftAddr, ethClient) {
c.ResponseInfo(500, models.PARAM_ERR, nil) c.ResponseInfo(500, models.PARAM_ERR, nil)
return
} }
if regex.MatchString(id) { defer ethClient.Close()
erc721, err := utils.NewERC721(utils.HexToAddr(nftAddr), ethClient)
if err != nil {
c.ResponseInfo(500, models.BUILD_ERR, nil)
return
}
idBigInt := big.NewInt(0)
_, setRes := idBigInt.SetString(id, 10)
if !setRes {
c.ResponseInfo(500, models.PARAM_ERR, nil) c.ResponseInfo(500, models.PARAM_ERR, nil)
return
}
uri, err := erc721.TokenURI(&bind.CallOpts{}, idBigInt)
if err != nil || uri == "" {
c.ResponseInfo(500, models.FAILED, nil)
return
}
if strings.HasPrefix(uri, "ipfs://") {
uri = beego.AppConfig.String("beforeEndReqUrl") + uri[7:]
} }
url := beego.AppConfig.String("beforeEndReqUrl") + id
client := &http.Client{} client := &http.Client{}
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", uri, nil)
if err != nil { if err != nil {
c.ResponseInfo(500, models.FAILED, err.Error()) c.ResponseInfo(500, models.FAILED, err.Error())
return
} }
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
c.ResponseInfo(500, models.FAILED, err.Error()) c.ResponseInfo(500, models.FAILED, err.Error())
return
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
c.ResponseInfo(500, models.FAILED, err.Error()) c.ResponseInfo(500, models.FAILED, err.Error())
return
} }
res := map[string]interface{}{} res := map[string]interface{}{}
json.Unmarshal(body, &res) json.Unmarshal(body, &res)
...@@ -137,30 +173,42 @@ func (c *LotteryController) ForwardReq() { ...@@ -137,30 +173,42 @@ func (c *LotteryController) ForwardReq() {
} }
func (c *LotteryController) GetPoolInfo() { func (c *LotteryController) GetPoolInfo() {
contractStr := c.GetString("lotteryContract")
if !utils.IsNilString(contractStr) {
c.ResponseInfo(500, models.PARAM_ERR, nil)
return
}
rpc := beego.AppConfig.String("rpcUrl") rpc := beego.AppConfig.String("rpcUrl")
client, err := ethclient.Dial(rpc) client, err := ethclient.Dial(rpc)
if err != nil { if err != nil {
log.Error(models.DIAL_RPC_ERR, err.Error()) log.Error(models.DIAL_RPC_ERR, err.Error())
c.ResponseInfo(500, models.DIAL_RPC_ERR, err.Error()) c.ResponseInfo(500, models.DIAL_RPC_ERR, err.Error())
return
}
if !utils.IsContractAddr(contractStr, client) {
c.ResponseInfo(500, models.PARAM_ERR, nil)
return
} }
defer client.Close() defer client.Close()
abiBytes, err := os.Open("./sync/Lottery_Func.json") 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())
return
} }
// 解析ABI文件 // 解析ABI文件
contractAbi, err := abi.JSON(bufio.NewReader(abiBytes)) contractAbi, err := abi.JSON(bufio.NewReader(abiBytes))
if err != nil { if err != nil {
log.Error(models.PARSE_ABI_ERR, err) log.Error(models.PARSE_ABI_ERR, err)
c.ResponseInfo(500, models.PARSE_ABI_ERR, err.Error()) c.ResponseInfo(500, models.PARSE_ABI_ERR, err.Error())
return
} }
data, err := contractAbi.Pack("getPoolInfo") 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())
return
} }
contractStr := beego.AppConfig.String("lotteryContract")
contractAddr := common.HexToAddress(contractStr) contractAddr := common.HexToAddress(contractStr)
// 执行合约调用 // 执行合约调用
log.Info("data:", data) log.Info("data:", data)
...@@ -171,6 +219,7 @@ func (c *LotteryController) GetPoolInfo() { ...@@ -171,6 +219,7 @@ func (c *LotteryController) GetPoolInfo() {
if err != nil { if err != nil {
log.Error(models.CALL_CONTRACT_ERR, err) log.Error(models.CALL_CONTRACT_ERR, err)
c.ResponseInfo(500, models.CALL_CONTRACT_ERR, err.Error()) c.ResponseInfo(500, models.CALL_CONTRACT_ERR, err.Error())
return
} }
res := &models.PoolInfoRes{} res := &models.PoolInfoRes{}
// 解析返回值 // 解析返回值
...@@ -178,52 +227,83 @@ func (c *LotteryController) GetPoolInfo() { ...@@ -178,52 +227,83 @@ func (c *LotteryController) GetPoolInfo() {
if err != nil { if err != nil {
log.Error(models.UNPACK_ABI_RETURN_PARM_ERR, err) log.Error(models.UNPACK_ABI_RETURN_PARM_ERR, err)
c.ResponseInfo(500, models.UNPACK_ABI_RETURN_PARM_ERR, err.Error()) c.ResponseInfo(500, models.UNPACK_ABI_RETURN_PARM_ERR, err.Error())
return
} }
c.ResponseInfo(200, models.SUCCESS, res) c.ResponseInfo(200, models.SUCCESS, res)
} }
func (c *LotteryController) GetBeforePeriodWinnerAndSign() { func (c *LotteryController) GetBeforePeriodWinnerAndSign() {
poolAddr := c.GetString("poolAddr") poolAddr := c.GetString("poolAddr")
contractAddr := c.GetString("lotteryContract")
period, err := c.GetInt64("period") period, err := c.GetInt64("period")
beforeNum, err := c.GetInt64("beforeNum") beforeNum, err := c.GetInt64("beforeNum")
if err != nil || poolAddr == "" { rewardNum, err := c.GetInt("rewardNum", 1)
if err != nil || !utils.IsNilString(contractAddr, poolAddr) || period <= 0 || rewardNum <= 0 {
c.ResponseInfo(500, models.PARAM_ERR, nil) c.ResponseInfo(500, models.PARAM_ERR, nil)
return
} }
if beforeNum >= period { var startNum int64 = 0
c.ResponseInfo(500, models.PARAM_ERR, nil) if period-beforeNum > 0 {
startNum = period - beforeNum
} }
contractAddr := beego.AppConfig.String("lotteryContract")
signPrv, err := crypto.HexToECDSA(beego.AppConfig.String("signAccPrv")) signPrv, err := crypto.HexToECDSA(beego.AppConfig.String("signAccPrv"))
if err != nil { if err != nil {
c.ResponseInfo(200, models.FAILED, err.Error()) c.ResponseInfo(200, models.FAILED, err.Error())
return
} }
o := orm.NewOrm() o := orm.NewOrm()
winnerListRes := make([]*models.WinnerListRes, 0) periodArr := make([][]int64, 0)
for i := period - beforeNum; i < period; i++ { winnerArr := make([][]string, 0)
lottery := &models.Lottery{} txHashArr := make([][]string, 0)
o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("period", i).OrderBy("-sort_by").One(lottery) signArr := make([][]string, 0)
periodBytes := make([]byte, 8) highPeriodLottery := &models.Lottery{}
binary.BigEndian.PutUint64(periodBytes, uint64(lottery.Period)) o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).OrderBy("-period").One(highPeriodLottery, "period")
winnerAddr := utils.HexToAddr(lottery.User) if highPeriodLottery.Period < period {
hashData := []byte(lottery.Hash) period = highPeriodLottery.Period
hash := crypto.Keccak256Hash(common.LeftPadBytes(periodBytes, 32), winnerAddr.Bytes(), hashData) }
signature, err := crypto.Sign(hash.Bytes(), signPrv) if period == 0 {
if err != nil { period += 1
c.ResponseInfo(500, models.FAILED, nil) }
for i := startNum; i < period; i++ {
lotteries := make([]*models.Lottery, 0)
o.QueryTable("lottery").Filter("contract_addr", contractAddr).Filter("pool_addr", poolAddr).Filter("period", i).OrderBy("-sort_by").Limit(rewardNum).All(&lotteries)
if len(lotteries) == 0 {
continue
} }
signature[64] += 27 periodTemp := make([]int64, 0)
winnerRes := &models.WinnerListRes{ winnerTemp := make([]string, 0)
PoolAddr: lottery.PoolAddr, txHashTemp := make([]string, 0)
Period: lottery.Period, signTemp := make([]string, 0)
Winner: lottery.User, for j := 0; j < len(lotteries); j++ {
TxHash: lottery.Hash, lottery := lotteries[j]
Sign: "0x" + common.Bytes2Hex(signature), periodBytes := make([]byte, 8)
binary.BigEndian.PutUint64(periodBytes, uint64(lottery.Period))
winnerAddr := utils.HexToAddr(lottery.User)
hashData := []byte(lottery.Hash)
hash := crypto.Keccak256Hash(common.LeftPadBytes(periodBytes, 32), winnerAddr.Bytes(), hashData)
signature, err := crypto.Sign(hash.Bytes(), signPrv)
if err != nil {
c.ResponseInfo(500, models.FAILED, nil)
return
}
signature[64] += 27
periodTemp = append(periodTemp, lottery.Period)
winnerTemp = append(winnerTemp, lottery.User)
txHashTemp = append(txHashTemp, lottery.Hash)
log.Info(signature)
signTemp = append(signTemp, "0x"+common.Bytes2Hex(signature))
} }
winnerListRes = append(winnerListRes, winnerRes) periodArr = append(periodArr, periodTemp)
winnerArr = append(winnerArr, winnerTemp)
txHashArr = append(txHashArr, txHashTemp)
signArr = append(signArr, signTemp)
} }
if len(winnerListRes) > 0 { winnerRes := &models.WinnerListRes{
c.ResponseInfo(200, models.SUCCESS, winnerListRes) PoolAddr: poolAddr,
} else { PeriodArr: periodArr,
c.ResponseInfo(200, models.DATA_NIL, nil) WinnerArr: winnerArr,
TxHashArr: txHashArr,
SignArr: signArr,
} }
c.ResponseInfo(200, models.SUCCESS, winnerRes)
} }
...@@ -5,6 +5,7 @@ go 1.19 ...@@ -5,6 +5,7 @@ go 1.19
require github.com/astaxie/beego v1.12.1 require github.com/astaxie/beego v1.12.1
require ( require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/ethereum/go-ethereum v1.12.0 github.com/ethereum/go-ethereum v1.12.0
github.com/garyburd/redigo v1.6.4 github.com/garyburd/redigo v1.6.4
github.com/go-sql-driver/mysql v1.7.1 github.com/go-sql-driver/mysql v1.7.1
...@@ -17,9 +18,10 @@ require ( ...@@ -17,9 +18,10 @@ require (
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-stack/stack v1.8.1 // indirect github.com/go-stack/stack v1.8.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect github.com/gorilla/websocket v1.4.2 // indirect
github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect
......
...@@ -14,6 +14,7 @@ github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPx ...@@ -14,6 +14,7 @@ github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPx
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE= github.com/casbin/casbin v1.7.0/go.mod h1:c67qKN6Oum3UF5Q1+BByfFxkwKvhwW57ITjqwtzR1KE=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8=
...@@ -43,6 +44,7 @@ github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2 ...@@ -43,6 +44,7 @@ github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2
github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/garyburd/redigo v1.6.4 h1:LFu2R3+ZOPgSMWMOL+saa/zXRjw0ID2G8FepO53BGlg= github.com/garyburd/redigo v1.6.4 h1:LFu2R3+ZOPgSMWMOL+saa/zXRjw0ID2G8FepO53BGlg=
github.com/garyburd/redigo v1.6.4/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw= github.com/garyburd/redigo v1.6.4/go.mod h1:rTb6epsqigu3kYKBnaF028A7Tf/Aw5s0cqA47doKKqw=
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
...@@ -64,6 +66,7 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l ...@@ -64,6 +66,7 @@ github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8l
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
...@@ -148,6 +151,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h ...@@ -148,6 +151,7 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
......
...@@ -14,4 +14,5 @@ const ( ...@@ -14,4 +14,5 @@ const (
CALL_CONTRACT_ERR = "Failed to pack contract call data" CALL_CONTRACT_ERR = "Failed to pack contract call data"
PACK_ABI_ERR = "ABI pack func name err" PACK_ABI_ERR = "ABI pack func name err"
UNPACK_ABI_RETURN_PARM_ERR = "Failed to unpack contract output" UNPACK_ABI_RETURN_PARM_ERR = "Failed to unpack contract output"
BUILD_ERR = "Build contract error"
) )
...@@ -36,9 +36,9 @@ type PoolInfoRes struct { ...@@ -36,9 +36,9 @@ type PoolInfoRes struct {
} }
type WinnerListRes struct { type WinnerListRes struct {
PoolAddr string `json:"poolAddr"` PoolAddr string `json:"poolAddr"`
Period int64 `json:"period"` PeriodArr [][]int64 `json:"periodArr"`
Winner string `json:"winner"` WinnerArr [][]string `json:"winnerArr"`
TxHash string `json:"txHash"` TxHashArr [][]string `json:"txHashArr"`
Sign string `json:"sign"` SignArr [][]string `json:"signArr"`
} }
...@@ -2,7 +2,6 @@ package sync ...@@ -2,7 +2,6 @@ package sync
import ( import (
"bufio" "bufio"
"github.com/astaxie/beego"
"github.com/astaxie/beego/logs" "github.com/astaxie/beego/logs"
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi"
...@@ -20,8 +19,7 @@ import ( ...@@ -20,8 +19,7 @@ import (
// LotteryTopic ERC721 transfer event topic // LotteryTopic ERC721 transfer event topic
var LotteryTopic = crypto.Keccak256Hash([]byte("Lottery(address,uint256,uint256,address,uint256)")).Hex() var LotteryTopic = crypto.Keccak256Hash([]byte("Lottery(address,uint256,uint256,address,uint256)")).Hex()
func LotteryContractHandler(vLog types.Log) error { func LotteryContractHandler(vLog types.Log, contractAddr common.Address) error {
contractAddr := beego.AppConfig.String("lotteryContract")
logs.Info("handler lottery contract logs") logs.Info("handler lottery contract logs")
file, err := os.Open("./sync/Lottery_Event.json") file, err := os.Open("./sync/Lottery_Event.json")
if err != nil { if err != nil {
...@@ -51,7 +49,7 @@ func LotteryContractHandler(vLog types.Log) error { ...@@ -51,7 +49,7 @@ func LotteryContractHandler(vLog types.Log) error {
log.Info("value:", value.String()) log.Info("value:", value.String())
tokenId, _ := utils.HexToInt64(vLog.Topics[3].Hex()) tokenId, _ := utils.HexToInt64(vLog.Topics[3].Hex())
lottery := &models.Lottery{ lottery := &models.Lottery{
ContractAddr: contractAddr, ContractAddr: contractAddr.Hex(),
PoolAddr: utils.HexToAddr(vLog.Topics[1].Hex()).String(), PoolAddr: utils.HexToAddr(vLog.Topics[1].Hex()).String(),
Period: period, Period: period,
User: userAddr, User: userAddr,
......
...@@ -26,7 +26,7 @@ var ( ...@@ -26,7 +26,7 @@ var (
bigEight = big.NewInt(700) bigEight = big.NewInt(700)
) )
type logHandler func(log types.Log) error type logHandler func(log types.Log, contractAddr common.Address) error
type PullEvent struct { type PullEvent struct {
ctx context.Context ctx context.Context
...@@ -64,13 +64,15 @@ func init() { ...@@ -64,13 +64,15 @@ func init() {
pullTask.ctx = context.Background() pullTask.ctx = context.Background()
pullTask.contractList = make([]common.Address, 0) pullTask.contractList = make([]common.Address, 0)
{ {
lotteryAddr := beego.AppConfig.String("lotteryContract") lotteryAddrArr := beego.AppConfig.Strings("lotteryContract")
if lotteryAddr == "" { if len(lotteryAddrArr) == 0 {
return return
} }
addr := common.HexToAddress(lotteryAddr) for _, lotteryAddr := range lotteryAddrArr {
pullTask.contractList = append(pullTask.contractList, addr) addr := common.HexToAddress(lotteryAddr)
pullTask.contractHandler[addr] = LotteryContractHandler pullTask.contractList = append(pullTask.contractList, addr)
pullTask.contractHandler[addr] = LotteryContractHandler
}
} }
} }
...@@ -113,7 +115,7 @@ func (p *PullEvent) GetLogs() { ...@@ -113,7 +115,7 @@ func (p *PullEvent) GetLogs() {
log.Info("Logs to be processed:", vlog) log.Info("Logs to be processed:", vlog)
handle, exist := p.contractHandler[vlog.Address] handle, exist := p.contractHandler[vlog.Address]
if exist { if exist {
handle(vlog) handle(vlog, vlog.Address)
} }
} }
} }
......
// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.
package utils
import (
"errors"
"math/big"
"strings"
ethereum "github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/event"
)
// Reference imports to suppress errors if they are not otherwise used.
var (
_ = errors.New
_ = big.NewInt
_ = strings.NewReader
_ = ethereum.NotFound
_ = bind.Bind
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
)
// ERC721MetaData contains all meta data concerning the ERC721 contract.
var ERC721MetaData = &bind.MetaData{
ABI: "[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"name_\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"symbol_\",\"type\":\"string\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"approved\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"ApprovalForAll\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256[]\",\"name\":\"tokenIds\",\"type\":\"uint256[]\"}],\"name\":\"batchMint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"getApproved\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"}],\"name\":\"isApprovedForAll\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"mint\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"ownerOf\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"safeTransferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAll\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"operator\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"approved\",\"type\":\"bool\"}],\"name\":\"setApprovalForAllFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes4\",\"name\":\"interfaceId\",\"type\":\"bytes4\"}],\"name\":\"supportsInterface\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"tokenURI\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"tokenId\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
Bin: "0x60806040523480156200001157600080fd5b5060405162002cf138038062002cf18339818101604052810190620000379190620001f6565b8160009081620000489190620004c6565b5080600190816200005a9190620004c6565b505050620005ad565b6000604051905090565b600080fd5b600080fd5b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b620000cc8262000081565b810181811067ffffffffffffffff82111715620000ee57620000ed62000092565b5b80604052505050565b60006200010362000063565b9050620001118282620000c1565b919050565b600067ffffffffffffffff82111562000134576200013362000092565b5b6200013f8262000081565b9050602081019050919050565b60005b838110156200016c5780820151818401526020810190506200014f565b60008484015250505050565b60006200018f620001898462000116565b620000f7565b905082815260208101848484011115620001ae57620001ad6200007c565b5b620001bb8482856200014c565b509392505050565b600082601f830112620001db57620001da62000077565b5b8151620001ed84826020860162000178565b91505092915050565b6000806040838503121562000210576200020f6200006d565b5b600083015167ffffffffffffffff81111562000231576200023062000072565b5b6200023f85828601620001c3565b925050602083015167ffffffffffffffff81111562000263576200026262000072565b5b6200027185828601620001c3565b9150509250929050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680620002ce57607f821691505b602082108103620002e457620002e362000286565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026200034e7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200030f565b6200035a86836200030f565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b6000620003a7620003a16200039b8462000372565b6200037c565b62000372565b9050919050565b6000819050919050565b620003c38362000386565b620003db620003d282620003ae565b8484546200031c565b825550505050565b600090565b620003f2620003e3565b620003ff818484620003b8565b505050565b5b8181101562000427576200041b600082620003e8565b60018101905062000405565b5050565b601f82111562000476576200044081620002ea565b6200044b84620002ff565b810160208510156200045b578190505b620004736200046a85620002ff565b83018262000404565b50505b505050565b600082821c905092915050565b60006200049b600019846008026200047b565b1980831691505092915050565b6000620004b6838362000488565b9150826002028217905092915050565b620004d1826200027b565b67ffffffffffffffff811115620004ed57620004ec62000092565b5b620004f98254620002b5565b620005068282856200042b565b600060209050601f8311600181146200053e576000841562000529578287015190505b620005358582620004a8565b865550620005a5565b601f1984166200054e86620002ea565b60005b82811015620005785784890151825560018201915060208501945060208101905062000551565b8683101562000598578489015162000594601f89168262000488565b8355505b6001600288020188555050505b505050505050565b61273480620005bd6000396000f3fe608060405234801561001057600080fd5b50600436106101005760003560e01c806357b375f411610097578063a22cb46511610066578063a22cb465146102a9578063b88d4fde146102c5578063c87b56dd146102e1578063e985e9c51461031157610100565b806357b375f41461020f5780636352211e1461022b57806370a082311461025b57806395d89b411461028b57610100565b806323b872dd116100d357806323b872dd1461019f57806340c10f19146101bb57806342842e0e146101d75780634684d7e9146101f357610100565b806301ffc9a71461010557806306fdde0314610135578063081812fc14610153578063095ea7b314610183575b600080fd5b61011f600480360381019061011a9190611877565b610341565b60405161012c91906118bf565b60405180910390f35b61013d610423565b60405161014a919061196a565b60405180910390f35b61016d600480360381019061016891906119c2565b6104b5565b60405161017a9190611a30565b60405180910390f35b61019d60048036038101906101989190611a77565b6104fb565b005b6101b960048036038101906101b49190611ab7565b610612565b005b6101d560048036038101906101d09190611a77565b610672565b005b6101f160048036038101906101ec9190611ab7565b610680565b005b61020d60048036038101906102089190611b6f565b6106a0565b005b61022960048036038101906102249190611bfb565b6106ea565b005b610245600480360381019061024091906119c2565b6106fa565b6040516102529190611a30565b60405180910390f35b61027560048036038101906102709190611c4e565b610780565b6040516102829190611c8a565b60405180910390f35b610293610837565b6040516102a0919061196a565b60405180910390f35b6102c360048036038101906102be9190611ca5565b6108c9565b005b6102df60048036038101906102da9190611e15565b6108df565b005b6102fb60048036038101906102f691906119c2565b610941565b604051610308919061196a565b60405180910390f35b61032b60048036038101906103269190611e98565b6109a9565b60405161033891906118bf565b60405180910390f35b60007fd71f2d39000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916148061040c57507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b8061041c575061041b82610a3d565b5b9050919050565b60606000805461043290611f07565b80601f016020809104026020016040519081016040528092919081815260200182805461045e90611f07565b80156104ab5780601f10610480576101008083540402835291602001916104ab565b820191906000526020600020905b81548152906001019060200180831161048e57829003601f168201915b5050505050905090565b60006104c082610aa7565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610506826106fa565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610576576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161056d90611faa565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610595610af2565b73ffffffffffffffffffffffffffffffffffffffff1614806105c457506105c3816105be610af2565b6109a9565b5b610603576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105fa9061203c565b60405180910390fd5b61060d8383610afa565b505050565b61062361061d610af2565b82610bb3565b610662576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610659906120ce565b60405180910390fd5b61066d838383610c48565b505050565b61067c8282610f41565b5050565b61069b838383604051806020016040528060008152506108df565b505050565b60005b828290508110156106e4576106d1848484848181106106c5576106c46120ee565b5b90506020020135610f41565b80806106dc9061214c565b9150506106a3565b50505050565b6106f5838383610f5f565b505050565b600080610706836110cb565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610777576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161076e906121e0565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036107f0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107e790612272565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606001805461084690611f07565b80601f016020809104026020016040519081016040528092919081815260200182805461087290611f07565b80156108bf5780601f10610894576101008083540402835291602001916108bf565b820191906000526020600020905b8154815290600101906020018083116108a257829003601f168201915b5050505050905090565b6108db6108d4610af2565b8383610f5f565b5050565b6108f06108ea610af2565b83610bb3565b61092f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610926906120ce565b60405180910390fd5b61093b84848484611108565b50505050565b606061094c82610aa7565b6000610956611164565b9050600081511161097657604051806020016040528060008152506109a1565b806109808461117b565b6040516020016109919291906122ce565b6040516020818303038152906040525b915050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b610ab081611249565b610aef576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ae6906121e0565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610b6d836106fa565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610bbf836106fa565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480610c015750610c0081856109a9565b5b80610c3f57508373ffffffffffffffffffffffffffffffffffffffff16610c27846104b5565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16610c68826106fa565b73ffffffffffffffffffffffffffffffffffffffff1614610cbe576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cb590612364565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d2d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d24906123f6565b60405180910390fd5b610d3a838383600161128a565b8273ffffffffffffffffffffffffffffffffffffffff16610d5a826106fa565b73ffffffffffffffffffffffffffffffffffffffff1614610db0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610da790612364565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610f3c8383836001611290565b505050565b610f5b828260405180602001604052806000815250611296565b5050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610fcd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fc490612462565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516110be91906118bf565b60405180910390a3505050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b611113848484610c48565b61111f848484846112f1565b61115e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611155906124f4565b60405180910390fd5b50505050565b606060405180602001604052806000815250905090565b60606000600161118a84611478565b01905060008167ffffffffffffffff8111156111a9576111a8611cea565b5b6040519080825280601f01601f1916602001820160405280156111db5781602001600182028036833780820191505090505b509050600082602001820190505b60011561123e578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a858161123257611231612514565b5b049450600085036111e9575b819350505050919050565b60008073ffffffffffffffffffffffffffffffffffffffff1661126b836110cb565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b50505050565b50505050565b6112a083836115cb565b6112ad60008484846112f1565b6112ec576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016112e3906124f4565b60405180910390fd5b505050565b60006113128473ffffffffffffffffffffffffffffffffffffffff166117e8565b1561146b578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261133b610af2565b8786866040518563ffffffff1660e01b815260040161135d9493929190612598565b6020604051808303816000875af192505050801561139957506040513d601f19601f8201168201806040525081019061139691906125f9565b60015b61141b573d80600081146113c9576040519150601f19603f3d011682016040523d82523d6000602084013e6113ce565b606091505b506000815103611413576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161140a906124f4565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050611470565b600190505b949350505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083106114d6577a184f03e93ff9f4daa797ed6e38ed64bf6a1f01000000000000000083816114cc576114cb612514565b5b0492506040810190505b6d04ee2d6d415b85acef81000000008310611513576d04ee2d6d415b85acef8100000000838161150957611508612514565b5b0492506020810190505b662386f26fc10000831061154257662386f26fc10000838161153857611537612514565b5b0492506010810190505b6305f5e100831061156b576305f5e100838161156157611560612514565b5b0492506008810190505b612710831061159057612710838161158657611585612514565b5b0492506004810190505b606483106115b357606483816115a9576115a8612514565b5b0492506002810190505b600a83106115c2576001810190505b80915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361163a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161163190612672565b60405180910390fd5b61164381611249565b15611683576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161167a906126de565b60405180910390fd5b61169160008383600161128a565b61169a81611249565b156116da576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016116d1906126de565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a46117e4600083836001611290565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b6118548161181f565b811461185f57600080fd5b50565b6000813590506118718161184b565b92915050565b60006020828403121561188d5761188c611815565b5b600061189b84828501611862565b91505092915050565b60008115159050919050565b6118b9816118a4565b82525050565b60006020820190506118d460008301846118b0565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b838110156119145780820151818401526020810190506118f9565b60008484015250505050565b6000601f19601f8301169050919050565b600061193c826118da565b61194681856118e5565b93506119568185602086016118f6565b61195f81611920565b840191505092915050565b600060208201905081810360008301526119848184611931565b905092915050565b6000819050919050565b61199f8161198c565b81146119aa57600080fd5b50565b6000813590506119bc81611996565b92915050565b6000602082840312156119d8576119d7611815565b5b60006119e6848285016119ad565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611a1a826119ef565b9050919050565b611a2a81611a0f565b82525050565b6000602082019050611a456000830184611a21565b92915050565b611a5481611a0f565b8114611a5f57600080fd5b50565b600081359050611a7181611a4b565b92915050565b60008060408385031215611a8e57611a8d611815565b5b6000611a9c85828601611a62565b9250506020611aad858286016119ad565b9150509250929050565b600080600060608486031215611ad057611acf611815565b5b6000611ade86828701611a62565b9350506020611aef86828701611a62565b9250506040611b00868287016119ad565b9150509250925092565b600080fd5b600080fd5b600080fd5b60008083601f840112611b2f57611b2e611b0a565b5b8235905067ffffffffffffffff811115611b4c57611b4b611b0f565b5b602083019150836020820283011115611b6857611b67611b14565b5b9250929050565b600080600060408486031215611b8857611b87611815565b5b6000611b9686828701611a62565b935050602084013567ffffffffffffffff811115611bb757611bb661181a565b5b611bc386828701611b19565b92509250509250925092565b611bd8816118a4565b8114611be357600080fd5b50565b600081359050611bf581611bcf565b92915050565b600080600060608486031215611c1457611c13611815565b5b6000611c2286828701611a62565b9350506020611c3386828701611a62565b9250506040611c4486828701611be6565b9150509250925092565b600060208284031215611c6457611c63611815565b5b6000611c7284828501611a62565b91505092915050565b611c848161198c565b82525050565b6000602082019050611c9f6000830184611c7b565b92915050565b60008060408385031215611cbc57611cbb611815565b5b6000611cca85828601611a62565b9250506020611cdb85828601611be6565b9150509250929050565b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611d2282611920565b810181811067ffffffffffffffff82111715611d4157611d40611cea565b5b80604052505050565b6000611d5461180b565b9050611d608282611d19565b919050565b600067ffffffffffffffff821115611d8057611d7f611cea565b5b611d8982611920565b9050602081019050919050565b82818337600083830152505050565b6000611db8611db384611d65565b611d4a565b905082815260208101848484011115611dd457611dd3611ce5565b5b611ddf848285611d96565b509392505050565b600082601f830112611dfc57611dfb611b0a565b5b8135611e0c848260208601611da5565b91505092915050565b60008060008060808587031215611e2f57611e2e611815565b5b6000611e3d87828801611a62565b9450506020611e4e87828801611a62565b9350506040611e5f878288016119ad565b925050606085013567ffffffffffffffff811115611e8057611e7f61181a565b5b611e8c87828801611de7565b91505092959194509250565b60008060408385031215611eaf57611eae611815565b5b6000611ebd85828601611a62565b9250506020611ece85828601611a62565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680611f1f57607f821691505b602082108103611f3257611f31611ed8565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000611f946021836118e5565b9150611f9f82611f38565b604082019050919050565b60006020820190508181036000830152611fc381611f87565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b6000612026603d836118e5565b915061203182611fca565b604082019050919050565b6000602082019050818103600083015261205581612019565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b60006120b8602d836118e5565b91506120c38261205c565b604082019050919050565b600060208201905081810360008301526120e7816120ab565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006121578261198c565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036121895761218861211d565b5b600182019050919050565b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b60006121ca6018836118e5565b91506121d582612194565b602082019050919050565b600060208201905081810360008301526121f9816121bd565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b600061225c6029836118e5565b915061226782612200565b604082019050919050565b6000602082019050818103600083015261228b8161224f565b9050919050565b600081905092915050565b60006122a8826118da565b6122b28185612292565b93506122c28185602086016118f6565b80840191505092915050565b60006122da828561229d565b91506122e6828461229d565b91508190509392505050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b600061234e6025836118e5565b9150612359826122f2565b604082019050919050565b6000602082019050818103600083015261237d81612341565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b60006123e06024836118e5565b91506123eb82612384565b604082019050919050565b6000602082019050818103600083015261240f816123d3565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b600061244c6019836118e5565b915061245782612416565b602082019050919050565b6000602082019050818103600083015261247b8161243f565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b60006124de6032836118e5565b91506124e982612482565b604082019050919050565b6000602082019050818103600083015261250d816124d1565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b600081519050919050565b600082825260208201905092915050565b600061256a82612543565b612574818561254e565b93506125848185602086016118f6565b61258d81611920565b840191505092915050565b60006080820190506125ad6000830187611a21565b6125ba6020830186611a21565b6125c76040830185611c7b565b81810360608301526125d9818461255f565b905095945050505050565b6000815190506125f38161184b565b92915050565b60006020828403121561260f5761260e611815565b5b600061261d848285016125e4565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b600061265c6020836118e5565b915061266782612626565b602082019050919050565b6000602082019050818103600083015261268b8161264f565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006126c8601c836118e5565b91506126d382612692565b602082019050919050565b600060208201905081810360008301526126f7816126bb565b905091905056fea26469706673582212201043a78e09b47736c056c4a25b4904389874842b94452f3305f64e642dd7d19364736f6c63430008130033",
}
// ERC721ABI is the input ABI used to generate the binding from.
// Deprecated: Use ERC721MetaData.ABI instead.
var ERC721ABI = ERC721MetaData.ABI
// ERC721Bin is the compiled bytecode used for deploying new contracts.
// Deprecated: Use ERC721MetaData.Bin instead.
var ERC721Bin = ERC721MetaData.Bin
// DeployERC721 deploys a new Ethereum contract, binding an instance of ERC721 to it.
func DeployERC721(auth *bind.TransactOpts, backend bind.ContractBackend, name_ string, symbol_ string) (common.Address, *types.Transaction, *ERC721, error) {
parsed, err := ERC721MetaData.GetAbi()
if err != nil {
return common.Address{}, nil, nil, err
}
if parsed == nil {
return common.Address{}, nil, nil, errors.New("GetABI returned nil")
}
address, tx, contract, err := bind.DeployContract(auth, *parsed, common.FromHex(ERC721Bin), backend, name_, symbol_)
if err != nil {
return common.Address{}, nil, nil, err
}
return address, tx, &ERC721{ERC721Caller: ERC721Caller{contract: contract}, ERC721Transactor: ERC721Transactor{contract: contract}, ERC721Filterer: ERC721Filterer{contract: contract}}, nil
}
// ERC721 is an auto generated Go binding around an Ethereum contract.
type ERC721 struct {
ERC721Caller // Read-only binding to the contract
ERC721Transactor // Write-only binding to the contract
ERC721Filterer // Log filterer for contract events
}
// ERC721Caller is an auto generated read-only Go binding around an Ethereum contract.
type ERC721Caller struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ERC721Transactor is an auto generated write-only Go binding around an Ethereum contract.
type ERC721Transactor struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ERC721Filterer is an auto generated log filtering Go binding around an Ethereum contract events.
type ERC721Filterer struct {
contract *bind.BoundContract // Generic contract wrapper for the low level calls
}
// ERC721Session is an auto generated Go binding around an Ethereum contract,
// with pre-set call and transact options.
type ERC721Session struct {
Contract *ERC721 // Generic contract binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// ERC721CallerSession is an auto generated read-only Go binding around an Ethereum contract,
// with pre-set call options.
type ERC721CallerSession struct {
Contract *ERC721Caller // Generic contract caller binding to set the session for
CallOpts bind.CallOpts // Call options to use throughout this session
}
// ERC721TransactorSession is an auto generated write-only Go binding around an Ethereum contract,
// with pre-set transact options.
type ERC721TransactorSession struct {
Contract *ERC721Transactor // Generic contract transactor binding to set the session for
TransactOpts bind.TransactOpts // Transaction auth options to use throughout this session
}
// ERC721Raw is an auto generated low-level Go binding around an Ethereum contract.
type ERC721Raw struct {
Contract *ERC721 // Generic contract binding to access the raw methods on
}
// ERC721CallerRaw is an auto generated low-level read-only Go binding around an Ethereum contract.
type ERC721CallerRaw struct {
Contract *ERC721Caller // Generic read-only contract binding to access the raw methods on
}
// ERC721TransactorRaw is an auto generated low-level write-only Go binding around an Ethereum contract.
type ERC721TransactorRaw struct {
Contract *ERC721Transactor // Generic write-only contract binding to access the raw methods on
}
// NewERC721 creates a new instance of ERC721, bound to a specific deployed contract.
func NewERC721(address common.Address, backend bind.ContractBackend) (*ERC721, error) {
contract, err := bindERC721(address, backend, backend, backend)
if err != nil {
return nil, err
}
return &ERC721{ERC721Caller: ERC721Caller{contract: contract}, ERC721Transactor: ERC721Transactor{contract: contract}, ERC721Filterer: ERC721Filterer{contract: contract}}, nil
}
// NewERC721Caller creates a new read-only instance of ERC721, bound to a specific deployed contract.
func NewERC721Caller(address common.Address, caller bind.ContractCaller) (*ERC721Caller, error) {
contract, err := bindERC721(address, caller, nil, nil)
if err != nil {
return nil, err
}
return &ERC721Caller{contract: contract}, nil
}
// NewERC721Transactor creates a new write-only instance of ERC721, bound to a specific deployed contract.
func NewERC721Transactor(address common.Address, transactor bind.ContractTransactor) (*ERC721Transactor, error) {
contract, err := bindERC721(address, nil, transactor, nil)
if err != nil {
return nil, err
}
return &ERC721Transactor{contract: contract}, nil
}
// NewERC721Filterer creates a new log filterer instance of ERC721, bound to a specific deployed contract.
func NewERC721Filterer(address common.Address, filterer bind.ContractFilterer) (*ERC721Filterer, error) {
contract, err := bindERC721(address, nil, nil, filterer)
if err != nil {
return nil, err
}
return &ERC721Filterer{contract: contract}, nil
}
// bindERC721 binds a generic wrapper to an already deployed contract.
func bindERC721(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader(ERC721ABI))
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_ERC721 *ERC721Raw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _ERC721.Contract.ERC721Caller.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_ERC721 *ERC721Raw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _ERC721.Contract.ERC721Transactor.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_ERC721 *ERC721Raw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _ERC721.Contract.ERC721Transactor.contract.Transact(opts, method, params...)
}
// Call invokes the (constant) contract method with params as input values and
// sets the output to result. The result type might be a single field for simple
// returns, a slice of interfaces for anonymous returns and a struct for named
// returns.
func (_ERC721 *ERC721CallerRaw) Call(opts *bind.CallOpts, result *[]interface{}, method string, params ...interface{}) error {
return _ERC721.Contract.contract.Call(opts, result, method, params...)
}
// Transfer initiates a plain transaction to move funds to the contract, calling
// its default method if one is available.
func (_ERC721 *ERC721TransactorRaw) Transfer(opts *bind.TransactOpts) (*types.Transaction, error) {
return _ERC721.Contract.contract.Transfer(opts)
}
// Transact invokes the (paid) contract method with params as input values.
func (_ERC721 *ERC721TransactorRaw) Transact(opts *bind.TransactOpts, method string, params ...interface{}) (*types.Transaction, error) {
return _ERC721.Contract.contract.Transact(opts, method, params...)
}
// BalanceOf is a free data retrieval call binding the contract method 0x70a08231.
//
// Solidity: function balanceOf(address owner) view returns(uint256)
func (_ERC721 *ERC721Caller) BalanceOf(opts *bind.CallOpts, owner common.Address) (*big.Int, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "balanceOf", owner)
if err != nil {
return *new(*big.Int), err
}
out0 := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int)
return out0, err
}
// BalanceOf is a free data retrieval call binding the contract method 0x70a08231.
//
// Solidity: function balanceOf(address owner) view returns(uint256)
func (_ERC721 *ERC721Session) BalanceOf(owner common.Address) (*big.Int, error) {
return _ERC721.Contract.BalanceOf(&_ERC721.CallOpts, owner)
}
// BalanceOf is a free data retrieval call binding the contract method 0x70a08231.
//
// Solidity: function balanceOf(address owner) view returns(uint256)
func (_ERC721 *ERC721CallerSession) BalanceOf(owner common.Address) (*big.Int, error) {
return _ERC721.Contract.BalanceOf(&_ERC721.CallOpts, owner)
}
// GetApproved is a free data retrieval call binding the contract method 0x081812fc.
//
// Solidity: function getApproved(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721Caller) GetApproved(opts *bind.CallOpts, tokenId *big.Int) (common.Address, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "getApproved", tokenId)
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// GetApproved is a free data retrieval call binding the contract method 0x081812fc.
//
// Solidity: function getApproved(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721Session) GetApproved(tokenId *big.Int) (common.Address, error) {
return _ERC721.Contract.GetApproved(&_ERC721.CallOpts, tokenId)
}
// GetApproved is a free data retrieval call binding the contract method 0x081812fc.
//
// Solidity: function getApproved(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721CallerSession) GetApproved(tokenId *big.Int) (common.Address, error) {
return _ERC721.Contract.GetApproved(&_ERC721.CallOpts, tokenId)
}
// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5.
//
// Solidity: function isApprovedForAll(address owner, address operator) view returns(bool)
func (_ERC721 *ERC721Caller) IsApprovedForAll(opts *bind.CallOpts, owner common.Address, operator common.Address) (bool, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "isApprovedForAll", owner, operator)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5.
//
// Solidity: function isApprovedForAll(address owner, address operator) view returns(bool)
func (_ERC721 *ERC721Session) IsApprovedForAll(owner common.Address, operator common.Address) (bool, error) {
return _ERC721.Contract.IsApprovedForAll(&_ERC721.CallOpts, owner, operator)
}
// IsApprovedForAll is a free data retrieval call binding the contract method 0xe985e9c5.
//
// Solidity: function isApprovedForAll(address owner, address operator) view returns(bool)
func (_ERC721 *ERC721CallerSession) IsApprovedForAll(owner common.Address, operator common.Address) (bool, error) {
return _ERC721.Contract.IsApprovedForAll(&_ERC721.CallOpts, owner, operator)
}
// Name is a free data retrieval call binding the contract method 0x06fdde03.
//
// Solidity: function name() view returns(string)
func (_ERC721 *ERC721Caller) Name(opts *bind.CallOpts) (string, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "name")
if err != nil {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
}
// Name is a free data retrieval call binding the contract method 0x06fdde03.
//
// Solidity: function name() view returns(string)
func (_ERC721 *ERC721Session) Name() (string, error) {
return _ERC721.Contract.Name(&_ERC721.CallOpts)
}
// Name is a free data retrieval call binding the contract method 0x06fdde03.
//
// Solidity: function name() view returns(string)
func (_ERC721 *ERC721CallerSession) Name() (string, error) {
return _ERC721.Contract.Name(&_ERC721.CallOpts)
}
// OwnerOf is a free data retrieval call binding the contract method 0x6352211e.
//
// Solidity: function ownerOf(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721Caller) OwnerOf(opts *bind.CallOpts, tokenId *big.Int) (common.Address, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "ownerOf", tokenId)
if err != nil {
return *new(common.Address), err
}
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
return out0, err
}
// OwnerOf is a free data retrieval call binding the contract method 0x6352211e.
//
// Solidity: function ownerOf(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721Session) OwnerOf(tokenId *big.Int) (common.Address, error) {
return _ERC721.Contract.OwnerOf(&_ERC721.CallOpts, tokenId)
}
// OwnerOf is a free data retrieval call binding the contract method 0x6352211e.
//
// Solidity: function ownerOf(uint256 tokenId) view returns(address)
func (_ERC721 *ERC721CallerSession) OwnerOf(tokenId *big.Int) (common.Address, error) {
return _ERC721.Contract.OwnerOf(&_ERC721.CallOpts, tokenId)
}
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
//
// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool)
func (_ERC721 *ERC721Caller) SupportsInterface(opts *bind.CallOpts, interfaceId [4]byte) (bool, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "supportsInterface", interfaceId)
if err != nil {
return *new(bool), err
}
out0 := *abi.ConvertType(out[0], new(bool)).(*bool)
return out0, err
}
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
//
// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool)
func (_ERC721 *ERC721Session) SupportsInterface(interfaceId [4]byte) (bool, error) {
return _ERC721.Contract.SupportsInterface(&_ERC721.CallOpts, interfaceId)
}
// SupportsInterface is a free data retrieval call binding the contract method 0x01ffc9a7.
//
// Solidity: function supportsInterface(bytes4 interfaceId) view returns(bool)
func (_ERC721 *ERC721CallerSession) SupportsInterface(interfaceId [4]byte) (bool, error) {
return _ERC721.Contract.SupportsInterface(&_ERC721.CallOpts, interfaceId)
}
// Symbol is a free data retrieval call binding the contract method 0x95d89b41.
//
// Solidity: function symbol() view returns(string)
func (_ERC721 *ERC721Caller) Symbol(opts *bind.CallOpts) (string, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "symbol")
if err != nil {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
}
// Symbol is a free data retrieval call binding the contract method 0x95d89b41.
//
// Solidity: function symbol() view returns(string)
func (_ERC721 *ERC721Session) Symbol() (string, error) {
return _ERC721.Contract.Symbol(&_ERC721.CallOpts)
}
// Symbol is a free data retrieval call binding the contract method 0x95d89b41.
//
// Solidity: function symbol() view returns(string)
func (_ERC721 *ERC721CallerSession) Symbol() (string, error) {
return _ERC721.Contract.Symbol(&_ERC721.CallOpts)
}
// TokenURI is a free data retrieval call binding the contract method 0xc87b56dd.
//
// Solidity: function tokenURI(uint256 tokenId) view returns(string)
func (_ERC721 *ERC721Caller) TokenURI(opts *bind.CallOpts, tokenId *big.Int) (string, error) {
var out []interface{}
err := _ERC721.contract.Call(opts, &out, "tokenURI", tokenId)
if err != nil {
return *new(string), err
}
out0 := *abi.ConvertType(out[0], new(string)).(*string)
return out0, err
}
// TokenURI is a free data retrieval call binding the contract method 0xc87b56dd.
//
// Solidity: function tokenURI(uint256 tokenId) view returns(string)
func (_ERC721 *ERC721Session) TokenURI(tokenId *big.Int) (string, error) {
return _ERC721.Contract.TokenURI(&_ERC721.CallOpts, tokenId)
}
// TokenURI is a free data retrieval call binding the contract method 0xc87b56dd.
//
// Solidity: function tokenURI(uint256 tokenId) view returns(string)
func (_ERC721 *ERC721CallerSession) TokenURI(tokenId *big.Int) (string, error) {
return _ERC721.Contract.TokenURI(&_ERC721.CallOpts, tokenId)
}
// Approve is a paid mutator transaction binding the contract method 0x095ea7b3.
//
// Solidity: function approve(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Transactor) Approve(opts *bind.TransactOpts, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "approve", to, tokenId)
}
// Approve is a paid mutator transaction binding the contract method 0x095ea7b3.
//
// Solidity: function approve(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Session) Approve(to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.Approve(&_ERC721.TransactOpts, to, tokenId)
}
// Approve is a paid mutator transaction binding the contract method 0x095ea7b3.
//
// Solidity: function approve(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721TransactorSession) Approve(to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.Approve(&_ERC721.TransactOpts, to, tokenId)
}
// BatchMint is a paid mutator transaction binding the contract method 0x4684d7e9.
//
// Solidity: function batchMint(address to, uint256[] tokenIds) returns()
func (_ERC721 *ERC721Transactor) BatchMint(opts *bind.TransactOpts, to common.Address, tokenIds []*big.Int) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "batchMint", to, tokenIds)
}
// BatchMint is a paid mutator transaction binding the contract method 0x4684d7e9.
//
// Solidity: function batchMint(address to, uint256[] tokenIds) returns()
func (_ERC721 *ERC721Session) BatchMint(to common.Address, tokenIds []*big.Int) (*types.Transaction, error) {
return _ERC721.Contract.BatchMint(&_ERC721.TransactOpts, to, tokenIds)
}
// BatchMint is a paid mutator transaction binding the contract method 0x4684d7e9.
//
// Solidity: function batchMint(address to, uint256[] tokenIds) returns()
func (_ERC721 *ERC721TransactorSession) BatchMint(to common.Address, tokenIds []*big.Int) (*types.Transaction, error) {
return _ERC721.Contract.BatchMint(&_ERC721.TransactOpts, to, tokenIds)
}
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
//
// Solidity: function mint(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Transactor) Mint(opts *bind.TransactOpts, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "mint", to, tokenId)
}
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
//
// Solidity: function mint(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Session) Mint(to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.Mint(&_ERC721.TransactOpts, to, tokenId)
}
// Mint is a paid mutator transaction binding the contract method 0x40c10f19.
//
// Solidity: function mint(address to, uint256 tokenId) returns()
func (_ERC721 *ERC721TransactorSession) Mint(to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.Mint(&_ERC721.TransactOpts, to, tokenId)
}
// SafeTransferFrom is a paid mutator transaction binding the contract method 0x42842e0e.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Transactor) SafeTransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "safeTransferFrom", from, to, tokenId)
}
// SafeTransferFrom is a paid mutator transaction binding the contract method 0x42842e0e.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Session) SafeTransferFrom(from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.SafeTransferFrom(&_ERC721.TransactOpts, from, to, tokenId)
}
// SafeTransferFrom is a paid mutator transaction binding the contract method 0x42842e0e.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721TransactorSession) SafeTransferFrom(from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.SafeTransferFrom(&_ERC721.TransactOpts, from, to, tokenId)
}
// SafeTransferFrom0 is a paid mutator transaction binding the contract method 0xb88d4fde.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) returns()
func (_ERC721 *ERC721Transactor) SafeTransferFrom0(opts *bind.TransactOpts, from common.Address, to common.Address, tokenId *big.Int, data []byte) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "safeTransferFrom0", from, to, tokenId, data)
}
// SafeTransferFrom0 is a paid mutator transaction binding the contract method 0xb88d4fde.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) returns()
func (_ERC721 *ERC721Session) SafeTransferFrom0(from common.Address, to common.Address, tokenId *big.Int, data []byte) (*types.Transaction, error) {
return _ERC721.Contract.SafeTransferFrom0(&_ERC721.TransactOpts, from, to, tokenId, data)
}
// SafeTransferFrom0 is a paid mutator transaction binding the contract method 0xb88d4fde.
//
// Solidity: function safeTransferFrom(address from, address to, uint256 tokenId, bytes data) returns()
func (_ERC721 *ERC721TransactorSession) SafeTransferFrom0(from common.Address, to common.Address, tokenId *big.Int, data []byte) (*types.Transaction, error) {
return _ERC721.Contract.SafeTransferFrom0(&_ERC721.TransactOpts, from, to, tokenId, data)
}
// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465.
//
// Solidity: function setApprovalForAll(address operator, bool approved) returns()
func (_ERC721 *ERC721Transactor) SetApprovalForAll(opts *bind.TransactOpts, operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "setApprovalForAll", operator, approved)
}
// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465.
//
// Solidity: function setApprovalForAll(address operator, bool approved) returns()
func (_ERC721 *ERC721Session) SetApprovalForAll(operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.Contract.SetApprovalForAll(&_ERC721.TransactOpts, operator, approved)
}
// SetApprovalForAll is a paid mutator transaction binding the contract method 0xa22cb465.
//
// Solidity: function setApprovalForAll(address operator, bool approved) returns()
func (_ERC721 *ERC721TransactorSession) SetApprovalForAll(operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.Contract.SetApprovalForAll(&_ERC721.TransactOpts, operator, approved)
}
// SetApprovalForAllFrom is a paid mutator transaction binding the contract method 0x57b375f4.
//
// Solidity: function setApprovalForAllFrom(address from, address operator, bool approved) returns()
func (_ERC721 *ERC721Transactor) SetApprovalForAllFrom(opts *bind.TransactOpts, from common.Address, operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "setApprovalForAllFrom", from, operator, approved)
}
// SetApprovalForAllFrom is a paid mutator transaction binding the contract method 0x57b375f4.
//
// Solidity: function setApprovalForAllFrom(address from, address operator, bool approved) returns()
func (_ERC721 *ERC721Session) SetApprovalForAllFrom(from common.Address, operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.Contract.SetApprovalForAllFrom(&_ERC721.TransactOpts, from, operator, approved)
}
// SetApprovalForAllFrom is a paid mutator transaction binding the contract method 0x57b375f4.
//
// Solidity: function setApprovalForAllFrom(address from, address operator, bool approved) returns()
func (_ERC721 *ERC721TransactorSession) SetApprovalForAllFrom(from common.Address, operator common.Address, approved bool) (*types.Transaction, error) {
return _ERC721.Contract.SetApprovalForAllFrom(&_ERC721.TransactOpts, from, operator, approved)
}
// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd.
//
// Solidity: function transferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Transactor) TransferFrom(opts *bind.TransactOpts, from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.contract.Transact(opts, "transferFrom", from, to, tokenId)
}
// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd.
//
// Solidity: function transferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721Session) TransferFrom(from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.TransferFrom(&_ERC721.TransactOpts, from, to, tokenId)
}
// TransferFrom is a paid mutator transaction binding the contract method 0x23b872dd.
//
// Solidity: function transferFrom(address from, address to, uint256 tokenId) returns()
func (_ERC721 *ERC721TransactorSession) TransferFrom(from common.Address, to common.Address, tokenId *big.Int) (*types.Transaction, error) {
return _ERC721.Contract.TransferFrom(&_ERC721.TransactOpts, from, to, tokenId)
}
// ERC721ApprovalIterator is returned from FilterApproval and is used to iterate over the raw logs and unpacked data for Approval events raised by the ERC721 contract.
type ERC721ApprovalIterator struct {
Event *ERC721Approval // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *ERC721ApprovalIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(ERC721Approval)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(ERC721Approval)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *ERC721ApprovalIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *ERC721ApprovalIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// ERC721Approval represents a Approval event raised by the ERC721 contract.
type ERC721Approval struct {
Owner common.Address
Approved common.Address
TokenId *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterApproval is a free log retrieval operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925.
//
// Solidity: event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) FilterApproval(opts *bind.FilterOpts, owner []common.Address, approved []common.Address, tokenId []*big.Int) (*ERC721ApprovalIterator, error) {
var ownerRule []interface{}
for _, ownerItem := range owner {
ownerRule = append(ownerRule, ownerItem)
}
var approvedRule []interface{}
for _, approvedItem := range approved {
approvedRule = append(approvedRule, approvedItem)
}
var tokenIdRule []interface{}
for _, tokenIdItem := range tokenId {
tokenIdRule = append(tokenIdRule, tokenIdItem)
}
logs, sub, err := _ERC721.contract.FilterLogs(opts, "Approval", ownerRule, approvedRule, tokenIdRule)
if err != nil {
return nil, err
}
return &ERC721ApprovalIterator{contract: _ERC721.contract, event: "Approval", logs: logs, sub: sub}, nil
}
// WatchApproval is a free log subscription operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925.
//
// Solidity: event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) WatchApproval(opts *bind.WatchOpts, sink chan<- *ERC721Approval, owner []common.Address, approved []common.Address, tokenId []*big.Int) (event.Subscription, error) {
var ownerRule []interface{}
for _, ownerItem := range owner {
ownerRule = append(ownerRule, ownerItem)
}
var approvedRule []interface{}
for _, approvedItem := range approved {
approvedRule = append(approvedRule, approvedItem)
}
var tokenIdRule []interface{}
for _, tokenIdItem := range tokenId {
tokenIdRule = append(tokenIdRule, tokenIdItem)
}
logs, sub, err := _ERC721.contract.WatchLogs(opts, "Approval", ownerRule, approvedRule, tokenIdRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(ERC721Approval)
if err := _ERC721.contract.UnpackLog(event, "Approval", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseApproval is a log parse operation binding the contract event 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925.
//
// Solidity: event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) ParseApproval(log types.Log) (*ERC721Approval, error) {
event := new(ERC721Approval)
if err := _ERC721.contract.UnpackLog(event, "Approval", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// ERC721ApprovalForAllIterator is returned from FilterApprovalForAll and is used to iterate over the raw logs and unpacked data for ApprovalForAll events raised by the ERC721 contract.
type ERC721ApprovalForAllIterator struct {
Event *ERC721ApprovalForAll // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *ERC721ApprovalForAllIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(ERC721ApprovalForAll)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(ERC721ApprovalForAll)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *ERC721ApprovalForAllIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *ERC721ApprovalForAllIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// ERC721ApprovalForAll represents a ApprovalForAll event raised by the ERC721 contract.
type ERC721ApprovalForAll struct {
Owner common.Address
Operator common.Address
Approved bool
Raw types.Log // Blockchain specific contextual infos
}
// FilterApprovalForAll is a free log retrieval operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31.
//
// Solidity: event ApprovalForAll(address indexed owner, address indexed operator, bool approved)
func (_ERC721 *ERC721Filterer) FilterApprovalForAll(opts *bind.FilterOpts, owner []common.Address, operator []common.Address) (*ERC721ApprovalForAllIterator, error) {
var ownerRule []interface{}
for _, ownerItem := range owner {
ownerRule = append(ownerRule, ownerItem)
}
var operatorRule []interface{}
for _, operatorItem := range operator {
operatorRule = append(operatorRule, operatorItem)
}
logs, sub, err := _ERC721.contract.FilterLogs(opts, "ApprovalForAll", ownerRule, operatorRule)
if err != nil {
return nil, err
}
return &ERC721ApprovalForAllIterator{contract: _ERC721.contract, event: "ApprovalForAll", logs: logs, sub: sub}, nil
}
// WatchApprovalForAll is a free log subscription operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31.
//
// Solidity: event ApprovalForAll(address indexed owner, address indexed operator, bool approved)
func (_ERC721 *ERC721Filterer) WatchApprovalForAll(opts *bind.WatchOpts, sink chan<- *ERC721ApprovalForAll, owner []common.Address, operator []common.Address) (event.Subscription, error) {
var ownerRule []interface{}
for _, ownerItem := range owner {
ownerRule = append(ownerRule, ownerItem)
}
var operatorRule []interface{}
for _, operatorItem := range operator {
operatorRule = append(operatorRule, operatorItem)
}
logs, sub, err := _ERC721.contract.WatchLogs(opts, "ApprovalForAll", ownerRule, operatorRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(ERC721ApprovalForAll)
if err := _ERC721.contract.UnpackLog(event, "ApprovalForAll", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseApprovalForAll is a log parse operation binding the contract event 0x17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31.
//
// Solidity: event ApprovalForAll(address indexed owner, address indexed operator, bool approved)
func (_ERC721 *ERC721Filterer) ParseApprovalForAll(log types.Log) (*ERC721ApprovalForAll, error) {
event := new(ERC721ApprovalForAll)
if err := _ERC721.contract.UnpackLog(event, "ApprovalForAll", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
// ERC721TransferIterator is returned from FilterTransfer and is used to iterate over the raw logs and unpacked data for Transfer events raised by the ERC721 contract.
type ERC721TransferIterator struct {
Event *ERC721Transfer // Event containing the contract specifics and raw log
contract *bind.BoundContract // Generic contract to use for unpacking event data
event string // Event name to use for unpacking event data
logs chan types.Log // Log channel receiving the found contract events
sub ethereum.Subscription // Subscription for errors, completion and termination
done bool // Whether the subscription completed delivering logs
fail error // Occurred error to stop iteration
}
// Next advances the iterator to the subsequent event, returning whether there
// are any more events found. In case of a retrieval or parsing error, false is
// returned and Error() can be queried for the exact failure.
func (it *ERC721TransferIterator) Next() bool {
// If the iterator failed, stop iterating
if it.fail != nil {
return false
}
// If the iterator completed, deliver directly whatever's available
if it.done {
select {
case log := <-it.logs:
it.Event = new(ERC721Transfer)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
default:
return false
}
}
// Iterator still in progress, wait for either a data or an error event
select {
case log := <-it.logs:
it.Event = new(ERC721Transfer)
if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil {
it.fail = err
return false
}
it.Event.Raw = log
return true
case err := <-it.sub.Err():
it.done = true
it.fail = err
return it.Next()
}
}
// Error returns any retrieval or parsing error occurred during filtering.
func (it *ERC721TransferIterator) Error() error {
return it.fail
}
// Close terminates the iteration process, releasing any pending underlying
// resources.
func (it *ERC721TransferIterator) Close() error {
it.sub.Unsubscribe()
return nil
}
// ERC721Transfer represents a Transfer event raised by the ERC721 contract.
type ERC721Transfer struct {
From common.Address
To common.Address
TokenId *big.Int
Raw types.Log // Blockchain specific contextual infos
}
// FilterTransfer is a free log retrieval operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef.
//
// Solidity: event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) FilterTransfer(opts *bind.FilterOpts, from []common.Address, to []common.Address, tokenId []*big.Int) (*ERC721TransferIterator, error) {
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
var tokenIdRule []interface{}
for _, tokenIdItem := range tokenId {
tokenIdRule = append(tokenIdRule, tokenIdItem)
}
logs, sub, err := _ERC721.contract.FilterLogs(opts, "Transfer", fromRule, toRule, tokenIdRule)
if err != nil {
return nil, err
}
return &ERC721TransferIterator{contract: _ERC721.contract, event: "Transfer", logs: logs, sub: sub}, nil
}
// WatchTransfer is a free log subscription operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef.
//
// Solidity: event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) WatchTransfer(opts *bind.WatchOpts, sink chan<- *ERC721Transfer, from []common.Address, to []common.Address, tokenId []*big.Int) (event.Subscription, error) {
var fromRule []interface{}
for _, fromItem := range from {
fromRule = append(fromRule, fromItem)
}
var toRule []interface{}
for _, toItem := range to {
toRule = append(toRule, toItem)
}
var tokenIdRule []interface{}
for _, tokenIdItem := range tokenId {
tokenIdRule = append(tokenIdRule, tokenIdItem)
}
logs, sub, err := _ERC721.contract.WatchLogs(opts, "Transfer", fromRule, toRule, tokenIdRule)
if err != nil {
return nil, err
}
return event.NewSubscription(func(quit <-chan struct{}) error {
defer sub.Unsubscribe()
for {
select {
case log := <-logs:
// New log arrived, parse the event and forward to the user
event := new(ERC721Transfer)
if err := _ERC721.contract.UnpackLog(event, "Transfer", log); err != nil {
return err
}
event.Raw = log
select {
case sink <- event:
case err := <-sub.Err():
return err
case <-quit:
return nil
}
case err := <-sub.Err():
return err
case <-quit:
return nil
}
}
}), nil
}
// ParseTransfer is a log parse operation binding the contract event 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef.
//
// Solidity: event Transfer(address indexed from, address indexed to, uint256 indexed tokenId)
func (_ERC721 *ERC721Filterer) ParseTransfer(log types.Log) (*ERC721Transfer, error) {
event := new(ERC721Transfer)
if err := _ERC721.contract.UnpackLog(event, "Transfer", log); err != nil {
return nil, err
}
event.Raw = log
return event, nil
}
package utils package utils
import ( import (
"context"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"github.com/astaxie/beego" "github.com/astaxie/beego"
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"regexp"
) )
func IsAddress(val string) bool { func IsAddress(params ...string) bool {
return common.IsHexAddress(val) res := true
for _, param := range params {
res = common.IsHexAddress(param)
}
return res
} }
func HexToAddr(val string) common.Address { func HexToAddr(val string) common.Address {
return common.HexToAddress(val) return common.HexToAddress(val)
} }
func IsContractAddr(address string, client *ethclient.Client) bool {
contractAddress := common.HexToAddress(address)
bytecode, err := client.CodeAt(context.Background(), contractAddress, nil)
if err != nil {
return false
}
isContract := len(bytecode) > 0
return isContract
}
func IsNilString(params ...string) bool {
for _, param := range params {
if param == "" {
return false
}
}
return true
}
func GetHttpRegex() *regexp.Regexp {
urlPattern := beego.AppConfig.String("httpUrlRegex")
// 编译正则表达式
regex, err := regexp.Compile(urlPattern)
if err != nil {
return nil
}
return regex
}
func HexToInt64(hexStr string) (int64, error) { func HexToInt64(hexStr string) (int64, error) {
// 去除十六进制字符串的前缀 "0x" // 去除十六进制字符串的前缀 "0x"
if len(hexStr) > 2 && hexStr[0:2] == "0x" { if len(hexStr) > 2 && hexStr[0:2] == "0x" {
......
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