chore: update directory abi and addresses
closes: status-im/status-desktop#12569
This commit is contained in:
parent
071c431606
commit
953ed4c8e4
|
@ -9,7 +9,8 @@ import (
|
|||
var errorNotAvailableOnChainID = errors.New("not available for chainID")
|
||||
|
||||
var contractAddressByChainID = map[uint64]common.Address{
|
||||
420: common.HexToAddress("0x22EE86A14b49890957fE71990073C6C68E05F9C5"), // optimism goerli testnet
|
||||
10: common.HexToAddress("0xA8d270048a086F5807A8dc0a9ae0e96280C41e3A"), // optimism mainnet
|
||||
420: common.HexToAddress("0xB3Ef5B0825D5f665bE14394eea41E684CE96A4c5"), // optimism goerli testnet
|
||||
}
|
||||
|
||||
func ContractAddress(chainID uint64) (common.Address, error) {
|
||||
|
|
|
@ -1,6 +1,17 @@
|
|||
[
|
||||
{
|
||||
"inputs": [],
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_votingContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_featuredVotingContract",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
|
@ -17,6 +28,19 @@
|
|||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "featuredVotingContract",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "getCommunities",
|
||||
|
@ -106,5 +130,18 @@
|
|||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "votingContract",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -31,7 +31,7 @@ var (
|
|||
|
||||
// DirectoryMetaData contains all meta data concerning the Directory contract.
|
||||
var DirectoryMetaData = &bind.MetaData{
|
||||
ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"addCommunity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCommunities\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getFeaturedCommunities\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"isCommunityFeatured\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"isCommunityInDirectory\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"removeCommunity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"_featuredCommunities\",\"type\":\"bytes[]\"}],\"name\":\"setFeaturedCommunities\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]",
|
||||
ABI: "[{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_votingContract\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_featuredVotingContract\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"addCommunity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"featuredVotingContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getCommunities\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getFeaturedCommunities\",\"outputs\":[{\"internalType\":\"bytes[]\",\"name\":\"\",\"type\":\"bytes[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"isCommunityFeatured\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"isCommunityInDirectory\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"community\",\"type\":\"bytes\"}],\"name\":\"removeCommunity\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes[]\",\"name\":\"_featuredCommunities\",\"type\":\"bytes[]\"}],\"name\":\"setFeaturedCommunities\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"votingContract\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]",
|
||||
}
|
||||
|
||||
// DirectoryABI is the input ABI used to generate the binding from.
|
||||
|
@ -180,6 +180,37 @@ func (_Directory *DirectoryTransactorRaw) Transact(opts *bind.TransactOpts, meth
|
|||
return _Directory.Contract.contract.Transact(opts, method, params...)
|
||||
}
|
||||
|
||||
// FeaturedVotingContract is a free data retrieval call binding the contract method 0x7475fe93.
|
||||
//
|
||||
// Solidity: function featuredVotingContract() view returns(address)
|
||||
func (_Directory *DirectoryCaller) FeaturedVotingContract(opts *bind.CallOpts) (common.Address, error) {
|
||||
var out []interface{}
|
||||
err := _Directory.contract.Call(opts, &out, "featuredVotingContract")
|
||||
|
||||
if err != nil {
|
||||
return *new(common.Address), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// FeaturedVotingContract is a free data retrieval call binding the contract method 0x7475fe93.
|
||||
//
|
||||
// Solidity: function featuredVotingContract() view returns(address)
|
||||
func (_Directory *DirectorySession) FeaturedVotingContract() (common.Address, error) {
|
||||
return _Directory.Contract.FeaturedVotingContract(&_Directory.CallOpts)
|
||||
}
|
||||
|
||||
// FeaturedVotingContract is a free data retrieval call binding the contract method 0x7475fe93.
|
||||
//
|
||||
// Solidity: function featuredVotingContract() view returns(address)
|
||||
func (_Directory *DirectoryCallerSession) FeaturedVotingContract() (common.Address, error) {
|
||||
return _Directory.Contract.FeaturedVotingContract(&_Directory.CallOpts)
|
||||
}
|
||||
|
||||
// GetCommunities is a free data retrieval call binding the contract method 0xc251b565.
|
||||
//
|
||||
// Solidity: function getCommunities() view returns(bytes[])
|
||||
|
@ -304,6 +335,37 @@ func (_Directory *DirectoryCallerSession) IsCommunityInDirectory(community []byt
|
|||
return _Directory.Contract.IsCommunityInDirectory(&_Directory.CallOpts, community)
|
||||
}
|
||||
|
||||
// VotingContract is a free data retrieval call binding the contract method 0xc1fc006a.
|
||||
//
|
||||
// Solidity: function votingContract() view returns(address)
|
||||
func (_Directory *DirectoryCaller) VotingContract(opts *bind.CallOpts) (common.Address, error) {
|
||||
var out []interface{}
|
||||
err := _Directory.contract.Call(opts, &out, "votingContract")
|
||||
|
||||
if err != nil {
|
||||
return *new(common.Address), err
|
||||
}
|
||||
|
||||
out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address)
|
||||
|
||||
return out0, err
|
||||
|
||||
}
|
||||
|
||||
// VotingContract is a free data retrieval call binding the contract method 0xc1fc006a.
|
||||
//
|
||||
// Solidity: function votingContract() view returns(address)
|
||||
func (_Directory *DirectorySession) VotingContract() (common.Address, error) {
|
||||
return _Directory.Contract.VotingContract(&_Directory.CallOpts)
|
||||
}
|
||||
|
||||
// VotingContract is a free data retrieval call binding the contract method 0xc1fc006a.
|
||||
//
|
||||
// Solidity: function votingContract() view returns(address)
|
||||
func (_Directory *DirectoryCallerSession) VotingContract() (common.Address, error) {
|
||||
return _Directory.Contract.VotingContract(&_Directory.CallOpts)
|
||||
}
|
||||
|
||||
// AddCommunity is a paid mutator transaction binding the contract method 0x74837935.
|
||||
//
|
||||
// Solidity: function addCommunity(bytes community) returns()
|
||||
|
|
|
@ -660,20 +660,12 @@ func (m *Manager) GetStoredDescriptionForCommunities(communityIDs []types.HexByt
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: use CommunityShard instead of appending the communityID
|
||||
|
||||
response.ContractCommunities = append(response.ContractCommunities, communityID) // , CommunityShard{
|
||||
// CommunityID: communityID,
|
||||
// Shard: community.Shard(),
|
||||
// }
|
||||
response.ContractCommunities = append(response.ContractCommunities, communityID)
|
||||
|
||||
if community != nil {
|
||||
response.Descriptions[community.IDString()] = community
|
||||
} else {
|
||||
response.UnknownCommunities = append(response.UnknownCommunities, communityID) // CommunityShard{
|
||||
// CommunityID: communityID,
|
||||
// Shard: community.Shard(),
|
||||
// })
|
||||
response.UnknownCommunities = append(response.UnknownCommunities, communityID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -633,15 +633,20 @@ func (m *Messenger) CuratedCommunities() (*communities.KnownCommunitiesResponse,
|
|||
return nil, errors.New("contract maker not initialized")
|
||||
}
|
||||
|
||||
// Revert code to https://github.com/status-im/status-go/blob/e6a3f63ec7f2fa691878ed35f921413dc8acfc66/protocol/messenger_communities.go#L211-L226 once the curated communities contract is deployed to mainnet
|
||||
testNetworksEnabled, err := m.settings.GetTestNetworksEnabled()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
chainID := uint64(420) // Optimism Goerli
|
||||
chainID := uint64(10) // Optimism Mainnet
|
||||
if testNetworksEnabled {
|
||||
chainID = 420 // Optimism Goerli
|
||||
}
|
||||
|
||||
directory, err := m.contractMaker.NewDirectory(chainID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// --- end delete
|
||||
|
||||
callOpts := &bind.CallOpts{Context: context.Background(), Pending: false}
|
||||
|
||||
|
@ -664,21 +669,11 @@ func (m *Messenger) CuratedCommunities() (*communities.KnownCommunitiesResponse,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: The curated communities smart contract should also store the community shard cluster and index
|
||||
|
||||
for _, c := range featuredCommunities {
|
||||
response.ContractFeaturedCommunities = append(response.ContractFeaturedCommunities, types.HexBytes(c).String())
|
||||
// TODO: use CommunityShard instead of communityID
|
||||
/*response.ContractFeaturedCommunities = append(response.ContractFeaturedCommunities, communities.CommunityShard{
|
||||
CommunityID: types.HexBytes(c).String(),
|
||||
// Shard: c.Shard, // TODO: obtain this value
|
||||
})*/
|
||||
}
|
||||
|
||||
// TODO: this loop is added just to not revert the change from requestCommunitiesFromMailserver
|
||||
// Once support for shards is added in the contract, just pass the `response.UnknownCommunities` directly to
|
||||
// the function
|
||||
|
||||
// TODO: use mechanism to obtain shard from community ID (https://github.com/status-im/status-desktop/issues/12585)
|
||||
var unknownCommunities []communities.CommunityShard
|
||||
for _, u := range response.UnknownCommunities {
|
||||
unknownCommunities = append(unknownCommunities, communities.CommunityShard{
|
||||
|
|
Loading…
Reference in New Issue