Skip to content

Commit

Permalink
Merge pull request #18 from kehiy/main
Browse files Browse the repository at this point in the history
update the origional branch
  • Loading branch information
jwmdev authored Dec 30, 2023
2 parents eb69305 + 8d7f798 commit 151845e
Show file tree
Hide file tree
Showing 29 changed files with 2,099 additions and 63 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ pactus-*
cmd/data/wallet.json
cmd/data/config.json
cmd/data/validators.json
cmd/bin
cmd/bin
__pycache__
/scripts/go/referral.json
/scripts/go/top10.json
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ check:
golangci-lint run --build-tags "${BUILD_TAG}" --timeout=20m0s

### building
build:
discord-bot:
go build -o build/main cmd/app.go

9 changes: 9 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ func (c *Client) LastBlockTime() (uint32, error) {
return lastBlockTime.BlockTime, err
}

func (c *Client) GetNodeInfo() (*pactus.GetNodeInfoResponse, error) {
info, err := c.networkClient.GetNodeInfo(context.Background(), &pactus.GetNodeInfoRequest{})
if err != nil {
return &pactus.GetNodeInfoResponse{}, err
}

return info, err
}

func (c *Client) Close() error {
return c.conn.Close()
}
5 changes: 4 additions & 1 deletion client/client_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ func (cm *Mgr) GetPeerInfo(address string) (*pactus.PeerInfo, *bls.PublicKey, er

if networkInfo != nil {
for _, p := range networkInfo.Peers {
for _, key := range p.ConsensusKeys {
for i, key := range p.ConsensusKeys {
pub, _ := bls.PublicKeyFromString(key)
if pub != nil {
if pub.ValidatorAddress().String() == address {
if i != 0 {
return nil, nil, errors.New("please enter the first validator address")
}
return p, pub, nil
}
}
Expand Down
9 changes: 8 additions & 1 deletion cmd/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,15 @@ func main() {
return
}

// load list of validators already received faucet
rs, err := discord.LoadReferralData(cfg)
if err != nil {
log.Println(err)
return
}

///start discord bot
bot, err := discord.Start(cfg, w, ss)
bot, err := discord.Start(cfg, w, ss, rs)
if err != nil {
log.Printf("could not start discord bot: %v\n", err)
return
Expand Down
16 changes: 9 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import (
)

type Config struct {
DiscordToken string `json:"discord_token"`
WalletPath string `json:"wallet_path"`
WalletPassword string `json:"wallet_password"`
Servers []string `json:"servers"`
FaucetAddress string `json:"faucet_address"`
FaucetAmount float64 `json:"faucet_amount"`
ValidatorDataPath string `json:"validator_data_path"`
DiscordToken string `json:"discord_token"`
WalletPath string `json:"wallet_path"`
WalletPassword string `json:"wallet_password"`
Servers []string `json:"servers"`
FaucetAddress string `json:"faucet_address"`
FaucetAmount float64 `json:"faucet_amount"`
ReferralerStakeAmount float64 `json:"referraler_stake_amount"` // who get faucet
ValidatorDataPath string `json:"validator_data_path"`
ReferralDataPath string `json:"referral_data_path"`
}

func Load(path string) (*Config, error) {
Expand Down
Loading

0 comments on commit 151845e

Please sign in to comment.