-
Notifications
You must be signed in to change notification settings - Fork 116
make public import to support SOV L1s #2746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
f415cbb
ab219b3
6fad984
de52a0e
486ead2
34606a1
81eb798
7c46fd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ var ( | |
| useSubnetEvm bool | ||
| useCustomVM bool | ||
| rpcURL string | ||
| noRPCAvailable bool | ||
| ) | ||
|
|
||
| // avalanche blockchain import public | ||
|
|
@@ -70,6 +71,7 @@ plag.`, | |
| "the blockchain ID", | ||
| ) | ||
| cmd.Flags().StringVar(&rpcURL, "rpc", "", "rpc endpoint for the blockchain") | ||
| cmd.Flags().BoolVar(&noRPCAvailable, "no-rpc-available", false, "use this when an RPC if offline and can't be accesed") | ||
felipemadero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return cmd | ||
| } | ||
|
|
||
|
|
@@ -95,7 +97,7 @@ func importPublic(*cobra.Command, []string) error { | |
| } | ||
| } | ||
|
|
||
| sc, genBytes, err := importBlockchain(network, rpcURL, blockchainID, ux.Logger.PrintToUser) | ||
| sc, genBytes, err := importBlockchain(network, rpcURL, !noRPCAvailable, blockchainID, ux.Logger.PrintToUser) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
@@ -181,21 +183,25 @@ func importPublic(*cobra.Command, []string) error { | |
| func importBlockchain( | ||
| network models.Network, | ||
| rpcURL string, | ||
| rpcIsAvailable bool, | ||
| blockchainID ids.ID, | ||
| printFunc func(msg string, args ...interface{}), | ||
| ) (models.Sidecar, []byte, error) { | ||
| var err error | ||
|
|
||
| if rpcURL == "" { | ||
| if rpcIsAvailable && rpcURL == "" { | ||
| rpcURL, err = app.Prompt.CaptureURL("What is the RPC endpoint?", false) | ||
| if err != nil { | ||
| return models.Sidecar{}, nil, err | ||
| } | ||
| } | ||
|
|
||
| if blockchainID == ids.Empty { | ||
| blockchainID, err = precompiles.WarpPrecompileGetBlockchainID(rpcURL) | ||
| if err != nil { | ||
| var err error | ||
| if rpcIsAvailable { | ||
| blockchainID, _ = precompiles.WarpPrecompileGetBlockchainID(rpcURL) | ||
| } | ||
| if blockchainID == ids.Empty { | ||
| blockchainID, err = app.Prompt.CaptureID("What is the Blockchain ID?") | ||
| if err != nil { | ||
| return models.Sidecar{}, nil, err | ||
|
|
@@ -230,7 +236,6 @@ func importBlockchain( | |
| network.Name(): { | ||
| SubnetID: subnetID, | ||
| BlockchainID: blockchainID, | ||
| RPCEndpoints: []string{rpcURL}, | ||
| }, | ||
| }, | ||
| Subnet: blockchainName, | ||
|
|
@@ -239,25 +244,33 @@ func importBlockchain( | |
| ImportedFromAPM: true, | ||
| } | ||
|
|
||
| if rpcIsAvailable { | ||
| e := sc.Networks[network.Name()] | ||
| e.RPCEndpoints = []string{rpcURL} | ||
| sc.Networks[network.Name()] = e | ||
| } | ||
|
|
||
| if !subnetInfo.IsPermissioned { | ||
| sc.Sovereign = true | ||
| validatorManagerAddress = "0x" + hex.EncodeToString(subnetInfo.ManagerAddress) | ||
| e := sc.Networks[network.Name()] | ||
| e.ValidatorManagerAddress = validatorManagerAddress | ||
| sc.Networks[network.Name()] = e | ||
| sc.ValidatorManagement, err = validatorManagerSDK.GetValidatorManagerType(rpcURL, common.HexToAddress(validatorManagerAddress)) | ||
| if err != nil { | ||
| return models.Sidecar{}, nil, fmt.Errorf("could not obtain validator manager type: %w", err) | ||
| } | ||
| printFunc(" Validator Manager Address: %s", validatorManagerAddress) | ||
| printFunc(" Validation Kind: %s", sc.ValidatorManagement) | ||
| if sc.ValidatorManagement == validatormanagertypes.ProofOfAuthority { | ||
| owner, err := contract.GetContractOwner(rpcURL, common.HexToAddress(validatorManagerAddress)) | ||
| if rpcIsAvailable { | ||
| sc.ValidatorManagement, err = validatorManagerSDK.GetValidatorManagerType(rpcURL, common.HexToAddress(validatorManagerAddress)) | ||
| if err != nil { | ||
| return models.Sidecar{}, nil, err | ||
| return models.Sidecar{}, nil, fmt.Errorf("could not obtain validator manager type: %w", err) | ||
| } | ||
| printFunc(" Validation Kind: %s", sc.ValidatorManagement) | ||
| if sc.ValidatorManagement == validatormanagertypes.ProofOfAuthority { | ||
| owner, err := contract.GetContractOwner(rpcURL, common.HexToAddress(validatorManagerAddress)) | ||
| if err != nil { | ||
| return models.Sidecar{}, nil, err | ||
| } | ||
| sc.ValidatorManagerOwner = owner.String() | ||
| printFunc(" Validator Manager Owner: %s", sc.ValidatorManagerOwner) | ||
felipemadero marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| sc.ValidatorManagerOwner = owner.String() | ||
| printFunc(" Validator Manager Owner: %s", sc.ValidatorManagerOwner) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.