feat: Added ClientForName
@@ -2,6 +2,7 @@ package hedera
import (
"encoding/json"
+ "fmt"
"io/ioutil"
"os"
)
@@ -107,6 +108,19 @@ func newClient(network map[string]AccountID, mirrorNetwork []string) *Client {
return &client
}
+func ClientForName(name string) (*Client, error) {
+ switch name {
+ case "testnet":
+ return ClientForTestnet(), nil
+ case "previewnet":
+ return ClientForPreviewnet(), nil
+ case "mainnet":
+ return ClientForMainnet(), nil
+ default:
+ return &Client{}, fmt.Errorf("%q is not recognized as a valid Hedera network", name)
+ }
+}
+
type configOperator struct {
AccountID string `json:"accountId"`
PrivateKey string `json:"privateKey"`
