Skip to content

Commit

Permalink
added nativeERC20 approve
Browse files Browse the repository at this point in the history
  • Loading branch information
dusannosovic-ethernal authored and Stefan-Ethernal committed Nov 28, 2023
1 parent 87002cf commit db9e2b6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions consensus/polybft/contracts_initializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ func initStakeManager(polyBFTConfig PolyBFTConfig, transition *state.Transition)
Stake: validator.Stake,
BlsKey: key.ToBigInt(),
}

approveFn := &contractsapi.ApproveNativeERC20Fn{
Spender: contracts.StakeManagerContract,
Amount: validator.Stake,
}

input, err := approveFn.EncodeAbi()
if err != nil {
return fmt.Errorf("NativeERC20.approve params encoding failed: %w", err)
}

err = callContract(validator.Address, contracts.NativeERC20TokenContract, input, "NativeERC20.approve", transition)
if err != nil {
return fmt.Errorf("Error while calling contract %w", err)
}
}

initFn := &contractsapi.InitializeStakeManagerFn{
Expand Down
1 change: 1 addition & 0 deletions consensus/polybft/contractsapi/bindings-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func main() {
false,
[]string{
"initialize",
"approve",
},
[]string{},
},
Expand Down
17 changes: 17 additions & 0 deletions consensus/polybft/contractsapi/contractsapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit db9e2b6

Please sign in to comment.