Skip to content

Commit

Permalink
Add faucetBindAddress to account wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrvivian committed Oct 31, 2023
1 parent a66065a commit 1befd23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions accountwallet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func AvailableCommands(cmd string) bool {

type Configuration struct {
BindAddress string `json:"bindAddress,omitempty"`
FaucetBindAddress string `json:"faucetBindAddress,omitempty"`
AccountStatesFile string `json:"accountStatesFile,omitempty"`
GenesisSeed string `json:"genesisSeed,omitempty"`
BlockIssuerPrivateKey string `json:"blockIssuerPrivateKey,omitempty"`
Expand All @@ -75,6 +76,7 @@ var accountConfigFile = "config.json"
var (
dockerAccountConfigJSON = `{
"bindAddress": "http://localhost:8080",
"faucetBindAddress": "http://localhost:8088",
"accountStatesFile": "wallet.dat",
"genesisSeed": "7R1itJx5hVuo9w9hjg5cwKFmek4HMSoBDgJZN8hKGxih",
"blockIssuerPrivateKey": "db39d2fde6301d313b108dc9db1ee724d0f405f6fde966bd776365bc5f4a5fb31e4b21eb51dcddf65c20db1065e1f1514658b23a3ddbf48d30c0efc926a9a648",
Expand Down
6 changes: 6 additions & 0 deletions accountwallet/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ func WithClientURL(url string) options.Option[AccountWallet] {
}
}

func WithFaucetURL(url string) options.Option[AccountWallet] {
return func(w *AccountWallet) {
w.optsFaucetURL = url
}
}

func WithAccountStatesFile(fileName string) options.Option[AccountWallet] {
return func(w *AccountWallet) {
w.optsAccountStatesFile = fileName
Expand Down
6 changes: 5 additions & 1 deletion accountwallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func Run(config *Configuration) (*AccountWallet, error) {
if config.BindAddress != "" {
opts = append(opts, WithClientURL(config.BindAddress))
}
if config.FaucetBindAddress != "" {
opts = append(opts, WithFaucetURL(config.FaucetBindAddress))
}
if config.AccountStatesFile != "" {
opts = append(opts, WithAccountStatesFile(config.AccountStatesFile))
}
Expand Down Expand Up @@ -69,6 +72,7 @@ type AccountWallet struct {
client *models.WebClient

optsClientBindAddress string
optsFaucetURL string
optsAccountStatesFile string
optsFaucetParams *faucetParams
optsRequestTimeout time.Duration
Expand All @@ -83,7 +87,7 @@ func NewAccountWallet(opts ...options.Option[AccountWallet]) (*AccountWallet, er
optsRequestTimeout: time.Second * 120,
optsRequestTicker: time.Second * 5,
}, opts, func(w *AccountWallet) {
w.client, initErr = models.NewWebClient(w.optsClientBindAddress)
w.client, initErr = models.NewWebClient(w.optsClientBindAddress, w.optsFaucetURL)
if initErr != nil {
log.Errorf("failed to create web client: %s", initErr.Error())

Expand Down

0 comments on commit 1befd23

Please sign in to comment.