github.com/ChainSafe/chainbridge-core@v1.4.2/chains/evm/calls/contracts/centrifuge/assetStore.go (about)

     1  package centrifuge
     2  
     3  import (
     4  	"github.com/ChainSafe/chainbridge-core/chains/evm/calls"
     5  	"github.com/ChainSafe/chainbridge-core/chains/evm/calls/contracts"
     6  	"github.com/ChainSafe/chainbridge-core/chains/evm/calls/transactor"
     7  	"github.com/ethereum/go-ethereum/common/hexutil"
     8  	"github.com/rs/zerolog/log"
     9  	"strings"
    10  
    11  	"github.com/ChainSafe/chainbridge-core/chains/evm/calls/consts"
    12  	"github.com/ethereum/go-ethereum/accounts/abi"
    13  	"github.com/ethereum/go-ethereum/common"
    14  )
    15  
    16  type AssetStoreContract struct {
    17  	contracts.Contract
    18  }
    19  
    20  func NewAssetStoreContract(
    21  	client calls.ContractCallerDispatcher,
    22  	assetStoreContractAddress common.Address,
    23  	transactor transactor.Transactor,
    24  ) *AssetStoreContract {
    25  	a, _ := abi.JSON(strings.NewReader(consts.CentrifugeAssetStoreABI))
    26  	b := common.FromHex(consts.CentrifugeAssetStoreBin)
    27  	return &AssetStoreContract{contracts.NewContract(assetStoreContractAddress, a, b, client, transactor)}
    28  }
    29  
    30  func (c *AssetStoreContract) IsCentrifugeAssetStored(hash [32]byte) (bool, error) {
    31  	log.Debug().
    32  		Str("hash", hexutil.Encode(hash[:])).
    33  		Msgf("Getting is centrifuge asset stored")
    34  	res, err := c.CallContract("_assetsStored", hash)
    35  	if err != nil {
    36  		return false, err
    37  	}
    38  
    39  	isAssetStored := *abi.ConvertType(res[0], new(bool)).(*bool)
    40  	return isAssetStored, nil
    41  }