From b96b334ea60e184bfdff8ca1c2689fb6cf98f724 Mon Sep 17 00:00:00 2001 From: Antonio Mindov Date: Thu, 12 Oct 2023 17:12:49 +0300 Subject: [PATCH] Fix treasury account on reset scripts (#910) Signed-off-by: Antonio Mindov --- .../from-config/cmd/setup-from-config.go | 22 +++++++++---------- scripts/bridge/setup/setup.go | 4 ++-- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/scripts/bridge/setup/from-config/cmd/setup-from-config.go b/scripts/bridge/setup/from-config/cmd/setup-from-config.go index 6d7e321c..e366053d 100644 --- a/scripts/bridge/setup/from-config/cmd/setup-from-config.go +++ b/scripts/bridge/setup/from-config/cmd/setup-from-config.go @@ -54,7 +54,6 @@ func main() { privateKey := flag.String("privateKey", "0x0", "Hedera Private Key") accountID := flag.String("accountID", "0.0", "Hedera Account ID") network := flag.String("network", "testnet", "Hedera Network Type") - members := flag.Int("members", 1, "The count of the members") memberPrivateKeys := flag.String("memberPrivateKeys", "", "Member private keys array, seperated by ','") adminKey := flag.String("adminKey", "", "The admin key") configPath := flag.String("configPath", "scripts/bridge/setup/extend-config/extended-bridge.yml", "Path to the 'bridge.yaml' config file") @@ -63,6 +62,8 @@ func main() { prKeysSlice := strings.Split(*memberPrivateKeys, ",") var hederaPrivateKeys []hedera.PrivateKey + members := len(prKeysSlice) + // element [0] can be empty string if the user does not provide any private keys if prKeysSlice[0] != "" { for i := 0; i < len(prKeysSlice); i++ { @@ -74,16 +75,16 @@ func main() { } } - treshold := uint(math.Ceil(float64(*members) * float64(0.51))) + treshold := uint(math.Ceil(float64(members) * 0.51)) - validateArguments(privateKey, accountID, adminKey, members, configPath, network) + validateArguments(privateKey, accountID, adminKey, configPath, network) if *network == "testnet" { hederaNetworkId = HederaTestnetNetworkId } else { hederaNetworkId = HederaMainnetNetworkId } parsedBridgeCfgForDeploy := parseExtendedBridge(configPath) - bridgeDeployResult := deployBridge(privateKey, accountID, adminKey, network, members, hederaPrivateKeys, treshold, parsedBridgeCfgForDeploy) + bridgeDeployResult := deployBridge(privateKey, accountID, adminKey, network, &members, hederaPrivateKeys, treshold, parsedBridgeCfgForDeploy) createAndAssociateTokens( &treshold, bridgeDeployResult, @@ -196,24 +197,21 @@ func createAndAssociateWrappedTokens(network uint64, networkInfo *parser.Network fmt.Printf("Creating Hedera Wrapped Fungible Token based on info of token with address [%s] ...\n", tokenAddress) tokenId, err := wrappedFungibleCreate.WrappedFungibleToken( client, - client.GetOperatorAccountID(), + *bridgeDeployResult.BridgeAccountID, client.GetOperatorPublicKey(), supplyKey, bridgeDeployResult.MembersPrivateKeys, tokenInfo.Name, tokenInfo.Symbol, tokenInfo.Decimals, - tokenInfo.Supply, + 0, ) if err != nil { fmt.Printf("[ERROR] Failed to Create Hedera Wrapped Fungible Token based on info of token [%s]. Error: [%s]\n", tokenAddress, err) continue } fmt.Printf("Successfully Created Hedera Wrapped Fungible Token with address [%s] based on info of token [%s]\n", tokenId.String(), tokenAddress) - err = associateToken(tokenId, client, *bridgeDeployResult.BridgeAccountID, "Bridge", bridgeDeployResult.MembersPrivateKeys) - if err == nil { - ExtendedBridge.Networks[network].Tokens.Fungible[tokenAddress].Networks[hederaNetworkId] = tokenId.String() - } + ExtendedBridge.Networks[network].Tokens.Fungible[tokenAddress].Networks[hederaNetworkId] = tokenId.String() } } @@ -323,8 +321,8 @@ func parseParams(content []byte, topicId *string, executorId *string, nodeAccoun return content, topicIdParsed, executor, nodeAccount } -func validateArguments(privateKey *string, accountID *string, adminKey *string, members *int, configPath *string, network *string) { - err := bridgeSetup.ValidateArguments(privateKey, accountID, adminKey, members) +func validateArguments(privateKey *string, accountID *string, adminKey *string, configPath *string, network *string) { + err := bridgeSetup.ValidateArguments(privateKey, accountID, adminKey) if err != nil { panic(err) } diff --git a/scripts/bridge/setup/setup.go b/scripts/bridge/setup/setup.go index 2d24a895..9a36012b 100644 --- a/scripts/bridge/setup/setup.go +++ b/scripts/bridge/setup/setup.go @@ -41,7 +41,7 @@ type DeployResult struct { func Deploy(privateKey *string, accountID *string, adminKey *string, network *string, members *int, previousPrivateKeys []hedera.PrivateKey, treshold uint) DeployResult { result := DeployResult{} - err := ValidateArguments(privateKey, accountID, adminKey, members) + err := ValidateArguments(privateKey, accountID, adminKey) if err != nil { result.Error = err return result @@ -167,7 +167,7 @@ func Deploy(privateKey *string, accountID *string, adminKey *string, network *st return result } -func ValidateArguments(privateKey *string, accountID *string, adminKey *string, members *int) error { +func ValidateArguments(privateKey *string, accountID *string, adminKey *string) error { if *privateKey == "0x0" { return errors.New("private key was not provided") }