|
|
@@ -10,6 +10,7 @@ import (
|
|
|
|
|
|
"github.com/btcsuite/btcutil/bech32"
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
+ "github.com/holiman/uint256"
|
|
|
"github.com/mr-tron/base58"
|
|
|
"github.com/spf13/pflag"
|
|
|
"github.com/tendermint/tendermint/libs/rand"
|
|
|
@@ -60,6 +61,16 @@ var ibcUpdateChannelChainChainId *string
|
|
|
var recoverChainIdEvmChainId *string
|
|
|
var recoverChainIdNewChainId *string
|
|
|
|
|
|
+var accountantModifyBalanceModule *string
|
|
|
+var accountantModifyBalanceTargetChainId *string
|
|
|
+var accountantModifyBalanceSequence *string
|
|
|
+var accountantModifyBalanceChainId *string
|
|
|
+var accountantModifyBalanceTokenChainId *string
|
|
|
+var accountantModifyBalanceTokenAddress *string
|
|
|
+var accountantModifyBalanceAction *string
|
|
|
+var accountantModifyBalanceAmount *string
|
|
|
+var accountantModifyBalanceReason *string
|
|
|
+
|
|
|
var governanceContractAddress *string
|
|
|
var governanceTargetAddress *string
|
|
|
var governanceTargetChain *string
|
|
|
@@ -177,6 +188,21 @@ func init() {
|
|
|
AdminClientRecoverChainIdCmd.Flags().AddFlagSet(moduleFlagSet)
|
|
|
TemplateCmd.AddCommand(AdminClientRecoverChainIdCmd)
|
|
|
|
|
|
+ // flags for the accountant-modify-balance command
|
|
|
+ accountantModifyBalanceFlagSet := pflag.NewFlagSet("accountant-modify-balance", pflag.ExitOnError)
|
|
|
+ accountantModifyBalanceModule = accountantModifyBalanceFlagSet.String("module", "GlobalAccountant", "Module identifier of the accountant")
|
|
|
+ accountantModifyBalanceTargetChainId = accountantModifyBalanceFlagSet.String("target-chain-id", "", "ID of the chain to receive this modification")
|
|
|
+ accountantModifyBalanceSequence = accountantModifyBalanceFlagSet.String("sequence", "", "The sequence number of this modification. Each modification must be uniquely identifiable just by its sequence number")
|
|
|
+ accountantModifyBalanceChainId = accountantModifyBalanceFlagSet.String("chain-id", "", "Chain ID of the account to be modified")
|
|
|
+ accountantModifyBalanceTokenChainId = accountantModifyBalanceFlagSet.String("token-chain-id", "", "Chain ID of the native chain for the token")
|
|
|
+ accountantModifyBalanceTokenAddress = accountantModifyBalanceFlagSet.String("token-address", "", "Address of the token on its native chain, hex string encoded")
|
|
|
+ accountantModifyBalanceAction = accountantModifyBalanceFlagSet.String("action", "", "Kind of modification to be made (1 = add, 2 = sub)")
|
|
|
+ accountantModifyBalanceAmount = accountantModifyBalanceFlagSet.String("amount", "", `Amount to be modified (decimal formatted string indicating the"raw" amount, not adjusted by the decimals of the token`)
|
|
|
+ accountantModifyBalanceReason = accountantModifyBalanceFlagSet.String("reason", "", "human-readable reason for the modification")
|
|
|
+ AdminClientAccountantModifyBalanceCmd.Flags().AddFlagSet(accountantModifyBalanceFlagSet)
|
|
|
+ AdminClientAccountantModifyBalanceCmd.Flags().AddFlagSet(moduleFlagSet)
|
|
|
+ TemplateCmd.AddCommand(AdminClientAccountantModifyBalanceCmd)
|
|
|
+
|
|
|
// flags for general-purpose governance call command
|
|
|
generalPurposeGovernanceFlagSet := pflag.NewFlagSet("general-purpose-governance", pflag.ExitOnError)
|
|
|
governanceContractAddress = generalPurposeGovernanceFlagSet.String("governance-contract", "", "Governance contract address")
|
|
|
@@ -226,6 +252,12 @@ var AdminClientRecoverChainIdCmd = &cobra.Command{
|
|
|
Run: runRecoverChainIdTemplate,
|
|
|
}
|
|
|
|
|
|
+var AdminClientAccountantModifyBalanceCmd = &cobra.Command{
|
|
|
+ Use: "accountant-modify-balance",
|
|
|
+ Short: "Generate an empty accountant modify balance template at specified path",
|
|
|
+ Run: runAccountantModifyBalanceTemplate,
|
|
|
+}
|
|
|
+
|
|
|
var AdminClientCircleIntegrationUpdateWormholeFinalityCmd = &cobra.Command{
|
|
|
Use: "circle-integration-update-wormhole-finality",
|
|
|
Short: "Generate an empty circle integration update wormhole finality template at specified path",
|
|
|
@@ -348,7 +380,7 @@ func runGuardianSetTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -381,7 +413,7 @@ func runContractUpgradeTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -414,7 +446,7 @@ func runTokenBridgeRegisterChainTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -448,7 +480,7 @@ func runTokenBridgeUpgradeContractTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -490,7 +522,104 @@ func runRecoverChainIdTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
+ }
|
|
|
+ fmt.Print(string(b))
|
|
|
+}
|
|
|
+
|
|
|
+func runAccountantModifyBalanceTemplate(cmd *cobra.Command, args []string) {
|
|
|
+ if *accountantModifyBalanceModule == "" {
|
|
|
+ log.Fatal("--module must be specified.")
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceTargetChainId == "" {
|
|
|
+ log.Fatal("--target-chain-id must be specified.")
|
|
|
+ }
|
|
|
+ targetChainID, err := parseChainID(*accountantModifyBalanceTargetChainId)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse target chain id: ", err)
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceSequence == "" {
|
|
|
+ log.Fatal("--sequence must be specified")
|
|
|
+ }
|
|
|
+ sequence, err := strconv.ParseUint(*accountantModifyBalanceSequence, 10, 64)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse sequence as uint64: ", err)
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceChainId == "" {
|
|
|
+ log.Fatal("--chain-id must be specified.")
|
|
|
+ }
|
|
|
+ chainID, err := parseChainID(*accountantModifyBalanceChainId)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse chain id: ", err)
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceTokenChainId == "" {
|
|
|
+ log.Fatal("--token-chain-id must be specified.")
|
|
|
+ }
|
|
|
+ tokenChainID, err := parseChainID(*accountantModifyBalanceTokenChainId)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse token chain id: ", err)
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceTokenAddress == "" {
|
|
|
+ log.Fatal("--token-address must be specified.")
|
|
|
+ }
|
|
|
+ tokenAddress, err := parseAddress(*accountantModifyBalanceTokenAddress)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse token address: ", err)
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceAction == "" {
|
|
|
+ log.Fatal("--action must be specified")
|
|
|
+ }
|
|
|
+ action, err := strconv.ParseUint(*accountantModifyBalanceAction, 10, 8)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to parse modification action as uint8: ", err)
|
|
|
+ }
|
|
|
+ if action != uint64(nodev1.ModificationKind_MODIFICATION_KIND_ADD) && action != uint64(nodev1.ModificationKind_MODIFICATION_KIND_SUBTRACT) {
|
|
|
+ log.Fatal("invalid modification action, must be 1 (add) or 2 (subtract)")
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceAmount == "" {
|
|
|
+ log.Fatal("--amount must be specified.")
|
|
|
+ }
|
|
|
+ amount_big := big.NewInt(0)
|
|
|
+ amount_big, ok := amount_big.SetString(*accountantModifyBalanceAmount, 10)
|
|
|
+ if !ok {
|
|
|
+ log.Fatal("failed to parse amount")
|
|
|
+ }
|
|
|
+ _, overflow := uint256.FromBig(amount_big)
|
|
|
+ if overflow {
|
|
|
+ log.Fatal("amount overflowed uint256")
|
|
|
+ }
|
|
|
+ if *accountantModifyBalanceReason == "" {
|
|
|
+ log.Fatal("--reason must be specified.")
|
|
|
+ }
|
|
|
+ if len(*accountantModifyBalanceReason) > vaa.AccountantModifyBalanceReasonLength {
|
|
|
+ log.Fatalf("reason is too long, can be at most %d bytes", vaa.AccountantModifyBalanceReasonLength)
|
|
|
+ }
|
|
|
+ m := &nodev1.InjectGovernanceVAARequest{
|
|
|
+ CurrentSetIndex: uint32(*templateGuardianIndex),
|
|
|
+ Messages: []*nodev1.GovernanceMessage{
|
|
|
+ {
|
|
|
+ Sequence: rand.Uint64(),
|
|
|
+ Nonce: rand.Uint32(),
|
|
|
+ Payload: &nodev1.GovernanceMessage_AccountantModifyBalance{
|
|
|
+ AccountantModifyBalance: &nodev1.AccountantModifyBalance{
|
|
|
+ Module: *accountantModifyBalanceModule,
|
|
|
+ TargetChainId: uint32(targetChainID),
|
|
|
+ Sequence: uint64(sequence),
|
|
|
+ ChainId: uint32(chainID),
|
|
|
+ TokenChain: uint32(tokenChainID),
|
|
|
+ TokenAddress: tokenAddress,
|
|
|
+ Kind: nodev1.ModificationKind(action),
|
|
|
+ Amount: *accountantModifyBalanceAmount,
|
|
|
+ Reason: *accountantModifyBalanceReason,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -529,7 +658,7 @@ func runCircleIntegrationUpdateWormholeFinalityTemplate(cmd *cobra.Command, args
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -584,7 +713,7 @@ func runCircleIntegrationRegisterEmitterAndDomainTemplate(cmd *cobra.Command, ar
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -623,7 +752,7 @@ func runCircleIntegrationUpgradeContractImplementationTemplate(cmd *cobra.Comman
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -661,7 +790,7 @@ func runWormchainStoreCodeTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -700,7 +829,7 @@ func runWormchainInstantiateContractTemplate(cmd *cobra.Command, args []string)
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -739,7 +868,7 @@ func runWormchainMigrateContractTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -783,7 +912,7 @@ func runWormchainWasmInstantiateAllowlistTemplate(action nodev1.WormchainWasmIns
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -820,7 +949,7 @@ func runGatewayScheduleUpgradeTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -839,7 +968,7 @@ func runGatewayCancelUpgradeTemplate(cmd *cobra.Command, args []string) {
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -866,7 +995,7 @@ func runGatewayIbcComposabilityMwSetContractTemplate(cmd *cobra.Command, args []
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -923,7 +1052,7 @@ func runIbcUpdateChannelChainTemplate(module nodev1.IbcUpdateChannelChainModule)
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
|
|
|
@@ -957,7 +1086,7 @@ func runWormholeRelayerSetDefaultDeliveryProviderTemplate(cmd *cobra.Command, ar
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -1008,7 +1137,7 @@ func runGeneralPurposeGovernanceEvmCallTemplate(cmd *cobra.Command, args []strin
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -1051,7 +1180,7 @@ func runGeneralPurposeGovernanceSolanaCallTemplate(cmd *cobra.Command, args []st
|
|
|
|
|
|
b, err := prototext.MarshalOptions{Multiline: true}.Marshal(m)
|
|
|
if err != nil {
|
|
|
- panic(err)
|
|
|
+ log.Fatal("failed to marshal request: ", err)
|
|
|
}
|
|
|
fmt.Print(string(b))
|
|
|
}
|
|
|
@@ -1097,10 +1226,10 @@ func parseChainID(name string) (vaa.ChainID, error) {
|
|
|
return s, nil
|
|
|
}
|
|
|
|
|
|
- // parse as uint32
|
|
|
- i, err := strconv.ParseUint(name, 10, 32)
|
|
|
+ // parse as uint16
|
|
|
+ i, err := strconv.ParseUint(name, 10, 16)
|
|
|
if err != nil {
|
|
|
- return 0, fmt.Errorf("failed to parse as name or uint32: %v", err)
|
|
|
+ return 0, fmt.Errorf("failed to parse as name or uint16: %v", err)
|
|
|
}
|
|
|
|
|
|
return vaa.ChainID(i), nil
|