Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitomir2 committed Nov 29, 2024
1 parent 360fda7 commit 83b4f5c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 10 deletions.
6 changes: 3 additions & 3 deletions command/sidechain/commission/commission.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ func runCommand(cmd *cobra.Command, _ []string) error {
}
}

if params.apply && !foundCommissionUpdatedLog { //nolint:gocritic
if !params.apply && !params.claim && !foundPendingCommissionLog { //nolint:gocritic
return fmt.Errorf("could not find an appropriate log in the receipt that validates the new pending commission")
} else if params.apply && !foundCommissionUpdatedLog {
return fmt.Errorf("could not find an appropriate log in the receipt that validates the new commission update")
} else if params.claim && !foundClaimCommissionLog {
return fmt.Errorf("could not find an appropriate log in the receipt that validates the commission claim")
} else if !foundPendingCommissionLog {
return fmt.Errorf("could not find an appropriate log in the receipt that validates the new pending commission")
}

outputter.WriteCommandResult(result)
Expand Down
40 changes: 33 additions & 7 deletions command/sidechain/staking/stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
var (
params stakeParams

stakeFn = contractsapi.HydraStaking.Abi.Methods["stake"]
delegateFn = contractsapi.HydraDelegation.Abi.Methods["delegate"]
// stakeFn = contractsapi.HydraStaking.Abi.Methods["stake"]
// stakeWithVestingFn = contractsapi.HydraStaking.Abi.Methods["stakeWithVesting"]
// delegateFn = contractsapi.HydraDelegation.Abi.Methods["delegate"]
stakeEventABI = contractsapi.HydraStaking.Abi.Events["Staked"]
delegateEventABI = contractsapi.HydraDelegation.Abi.Events["Delegated"]
)
Expand Down Expand Up @@ -136,6 +137,7 @@ func runCommand(cmd *cobra.Command, _ []string) error {
return err
}

fmt.Println("===params.vesting is ", params.vesting)
txn, err := createStakeTransaction(validatorAccount)

Check failure on line 141 in command/sidechain/staking/stake.go

View workflow job for this annotation

GitHub Actions / golangci_lint

assignments should only be cuddled with other assignments (wsl)
if err != nil {

Check failure on line 142 in command/sidechain/staking/stake.go

View workflow job for this annotation

GitHub Actions / golangci_lint

only one cuddle assignment allowed before if statement (wsl)
return err
Expand Down Expand Up @@ -172,6 +174,20 @@ func runCommand(cmd *cobra.Command, _ []string) error {

result.isSelfStake = true
result.amount = event["amount"].(*big.Int).String() //nolint:forcetypeassert
fmt.Println("===amount is ", result.amount)

if params.vesting {
// vito
// txn
balance, err := txRelayer.Client().Eth().GetBalance(validatorAccount.Ecdsa.Address(), receipt.BlockHash)
if err != nil {
fmt.Printf("was unable to get the total balance of the validator %s", result.validatorAddress)
} else {
result.amount = balance.String()
}

fmt.Println("===balance is ", balance.String())
}
} else if match = delegateEventABI.Match(log); match {
event, err = delegateEventABI.ParseLog(log)
if err != nil {
Expand Down Expand Up @@ -208,14 +224,24 @@ func createStakeTransaction(validatorAccount *wallet.Account) (*ethgo.Transactio
)

if params.self {
encoded, err = stakeFn.Encode([]interface{}{})
if params.vesting {
var stakeWithVestingFn = &contractsapi.StakeWithVestingHydraStakingFn{
DurationWeeks: new(big.Int).SetUint64(params.vestingPeriod),
}

encoded, err = stakeWithVestingFn.EncodeAbi()
} else {
var stakeFn = &contractsapi.StakeHydraStakingFn{}
encoded, err = stakeFn.EncodeAbi()
}

contractAddr = (*ethgo.Address)(&contracts.HydraStakingContract)
} else {
delegateToAddress := types.StringToAddress(params.delegateAddress)
var delegateFn = &contractsapi.DelegateHydraDelegationFn{
Staker: types.StringToAddress(params.delegateAddress),
}

encoded, err = delegateFn.Encode([]interface{}{
ethgo.Address(delegateToAddress),
})
encoded, err = delegateFn.EncodeAbi()
contractAddr = (*ethgo.Address)(&contracts.HydraDelegationContract)
}

Expand Down

0 comments on commit 83b4f5c

Please sign in to comment.