create faucet link generator
@@ -32,8 +32,6 @@ import (
"github.com/onflow/flow-cli/pkg/flowkit/util"
)
-const faucetHost = "https://testnet-faucet.onflow.org/"
-
var Cmd = &cobra.Command{
Use: "keys",
Short: "Utilities to manage keys",
@@ -68,11 +66,7 @@ func (k *KeyResult) String() string {
if k.privateKey != nil {
// build the faucet link
- link := fmt.Sprintf("%s?key=%x", faucetHost, k.publicKey.Encode())
- if k.privateKey.Algorithm() != crypto.ECDSA_P256 {
- link = fmt.Sprintf("%s&sig-algo=%s", link, k.privateKey.Algorithm().String())
- }
-
+ link := TestnetFaucetURL(k.publicKey.String(), k.accountKey.SigAlgo)
fmt.Printf(
"%s If you want to create an account on testnet with the generated keys use this link:\n%s \n\n",
output.TryEmoji(),
@@ -109,3 +103,14 @@ func (k *KeyResult) Oneliner() string {
return result
}
+
+func TestnetFaucetURL(publicKey string, sigAlgo crypto.SignatureAlgorithm) string {
+ const testnetFaucetHost = "https://testnet-faucet.onflow.org/"
+
+ link := fmt.Sprintf("%s?key=%x", testnetFaucetHost, publicKey)
+ if sigAlgo != crypto.ECDSA_P256 {
+ link = fmt.Sprintf("%s&sig-algo=%s", link, sigAlgo)
+ }
+
+ return link
+}
