-
Notifications
You must be signed in to change notification settings - Fork 0
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
Admin cli commands #251
base: main
Are you sure you want to change the base?
Admin cli commands #251
Conversation
return nil, err | ||
} | ||
|
||
_, _ = outputter.Write([]byte(fmt.Sprintf("-Addresses on %s chain (retrieved from validator data): \n", chainID))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove - prefix
Add number of unfiltered utxos (for both cases) like this too
|
```shell | ||
$ apex-bridge bridge-admin get-validators-data \ | ||
--bridge-url http://localhost:12013 \ | ||
--bridging-addr 0xeefcd00000000000000000000000000000000022 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this flag is bridge-addr
if !ethcommon.IsHexAddress(v.bridgeSCAddr) { | ||
return fmt.Errorf("invalid --%s flag", bridgeSCAddrFlag) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also validate that v.config is not empty and that the file exists
nexusWalletAddressFlag = "nexus-wallet-addr" | ||
indexerDbsPathFlag = "indexer-dbs-path" | ||
|
||
primeWalletAddressFlagDesc = "prime wallet address" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"prime hot wallet/bridging/multisig address"
indexerDbsPathFlag = "indexer-dbs-path" | ||
|
||
primeWalletAddressFlagDesc = "prime wallet address" | ||
vectorWalletAddressFlagDesc = "vector wallet address" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"vector hot wallet/bridging/multisig address"
|
||
primeWalletAddressFlagDesc = "prime wallet address" | ||
vectorWalletAddressFlagDesc = "vector wallet address" | ||
nexusWalletAddressFlagDesc = "nexus wallet address" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"nexus NativeTokenWallet Proxy sc address"
} | ||
|
||
if b.config == "" { | ||
return fmt.Errorf("invalid config path: --%s", indexerDbsPathFlag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
configFlag instead of indexerDbsPathFlag
return fmt.Errorf("invalid address: --%s", nexusWalletAddressFlag) | ||
} | ||
|
||
if b.config == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also validate for b.config that the file exists
if b.config == "" { | ||
return fmt.Errorf("invalid config path: --%s", indexerDbsPathFlag) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe also validate:
if b.indexerDbsPath != "" && dirNotExists(b.indexerDbsPath) { error }
// Retrieve UTXOs for Cardano BridgingAddresses from the DB | ||
for chainID, cardanoIndexerDB := range cardanoIndexerDbs { | ||
var bridgingAddress string | ||
if chainID == common.ChainIDStrPrime { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
above if, create:
chainWalletAddr map[string]string{
common.ChainIDStrPrime: b.primeWalletAddress,
common.ChainIDStrVector : b.vectorWalletAddress,
common.ChainIDStrNexus: b.nexusWalletAddress,
}
and use bridgingAddr := chainWalletAddr[chainID], instead of:
var bridgingAddress string
if chainID == common.ChainIDStrPrime {
bridgingAddress = b.primeWalletAddress
} else if chainID == common.ChainIDStrVector {
bridgingAddress = b.vectorWalletAddress
}
return nil, err | ||
} | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract in a private func:
var (
multisigBalance uint64
filteredCount int
)
for _, utxo := range multisigUtxos {
if len(utxo.Tokens) == 0 {
multisigBalance += utxo.Amount
filteredCount++
}
}
_, _ = outputter.Write([]byte(fmt.Sprintf("Balances on %s chain: \n", chainID)))
_, _ = outputter.Write([]byte(fmt.Sprintf("Bridging Address = %s\n", bridgingAddress)))
_, _ = outputter.Write([]byte(fmt.Sprintf("Balance = %d\n", multisigBalance)))
_, _ = outputter.Write([]byte(fmt.Sprintf("All UTXOs = %d\n", len(multisigUtxos))))
_, _ = outputter.Write([]byte(fmt.Sprintf("Filtered UTXOs = %d\n", filteredCount)))
outputter.WriteOutput()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because this is repeated code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you can first only store the utxos in a map[chainId]UTxO[], and later iterate over appConfig.CardanoChains, and print out the balances
cardanoIndexerDbs := make(map[string]indexer.Database, len(appConfig.CardanoChains)) | ||
|
||
// Open connections to the DB for Cardano chains | ||
for chainID := range appConfig.CardanoChains { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after you are finished using the dbs, iterate over them, and close them
No description provided.