You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

532 lines
19 KiB

4 years ago
  1. package eth
  2. import (
  3. "context"
  4. "fmt"
  5. "math/big"
  6. "strings"
  7. "github.com/ethereum/go-ethereum"
  8. "github.com/ethereum/go-ethereum/accounts/abi"
  9. "github.com/ethereum/go-ethereum/accounts/abi/bind"
  10. ethCommon "github.com/ethereum/go-ethereum/common"
  11. "github.com/ethereum/go-ethereum/core/types"
  12. "github.com/ethereum/go-ethereum/crypto"
  13. "github.com/ethereum/go-ethereum/ethclient"
  14. WithdrawalDelayer "github.com/hermeznetwork/hermez-node/eth/contracts/withdrawdelayer"
  15. )
  16. // WDelayerConstants are the constants of the Rollup Smart Contract
  17. type WDelayerConstants struct {
  18. // Max Withdrawal Delay
  19. MaxWithdrawalDelay uint64
  20. // Max Emergency mode time
  21. MaxEmergencyModeTime uint64
  22. // HermezRollup smartcontract address
  23. HermezRollup ethCommon.Address
  24. }
  25. // DepositState is the state of Deposit
  26. type DepositState struct {
  27. Amount *big.Int
  28. DepositTimestamp uint64
  29. }
  30. // WDelayerEventDeposit is an event of the WithdrawalDelayer Smart Contract
  31. type WDelayerEventDeposit struct {
  32. Owner ethCommon.Address
  33. Token ethCommon.Address
  34. Amount *big.Int
  35. DepositTimestamp uint64
  36. }
  37. // WDelayerEventWithdraw is an event of the WithdrawalDelayer Smart Contract
  38. type WDelayerEventWithdraw struct {
  39. Owner ethCommon.Address
  40. Token ethCommon.Address
  41. Amount *big.Int
  42. }
  43. // WDelayerEventEmergencyModeEnabled an event of the WithdrawalDelayer Smart Contract
  44. type WDelayerEventEmergencyModeEnabled struct {
  45. }
  46. // WDelayerEventNewWithdrawalDelay an event of the WithdrawalDelayer Smart Contract
  47. type WDelayerEventNewWithdrawalDelay struct {
  48. WithdrawalDelay uint64
  49. }
  50. // WDelayerEventEscapeHatchWithdrawal an event of the WithdrawalDelayer Smart Contract
  51. type WDelayerEventEscapeHatchWithdrawal struct {
  52. Who ethCommon.Address
  53. To ethCommon.Address
  54. Token ethCommon.Address
  55. Amount *big.Int
  56. }
  57. // WDelayerEventNewHermezKeeperAddress an event of the WithdrawalDelayer Smart Contract
  58. type WDelayerEventNewHermezKeeperAddress struct {
  59. NewHermezKeeperAddress ethCommon.Address
  60. }
  61. // WDelayerEventNewWhiteHackGroupAddress an event of the WithdrawalDelayer Smart Contract
  62. type WDelayerEventNewWhiteHackGroupAddress struct {
  63. NewWhiteHackGroupAddress ethCommon.Address
  64. }
  65. // WDelayerEventNewHermezGovernanceDAOAddress an event of the WithdrawalDelayer Smart Contract
  66. type WDelayerEventNewHermezGovernanceDAOAddress struct {
  67. NewHermezGovernanceDAOAddress ethCommon.Address
  68. }
  69. // WDelayerEvents is the lis of events in a block of the WithdrawalDelayer Smart Contract
  70. type WDelayerEvents struct {
  71. Deposit []WDelayerEventDeposit
  72. Withdraw []WDelayerEventWithdraw
  73. EmergencyModeEnabled []WDelayerEventEmergencyModeEnabled
  74. NewWithdrawalDelay []WDelayerEventNewWithdrawalDelay
  75. EscapeHatchWithdrawal []WDelayerEventEscapeHatchWithdrawal
  76. NewHermezKeeperAddress []WDelayerEventNewHermezKeeperAddress
  77. NewWhiteHackGroupAddress []WDelayerEventNewWhiteHackGroupAddress
  78. NewHermezGovernanceDAOAddress []WDelayerEventNewHermezGovernanceDAOAddress
  79. }
  80. // NewWDelayerEvents creates an empty WDelayerEvents with the slices initialized.
  81. func NewWDelayerEvents() WDelayerEvents {
  82. return WDelayerEvents{
  83. Deposit: make([]WDelayerEventDeposit, 0),
  84. Withdraw: make([]WDelayerEventWithdraw, 0),
  85. EmergencyModeEnabled: make([]WDelayerEventEmergencyModeEnabled, 0),
  86. NewWithdrawalDelay: make([]WDelayerEventNewWithdrawalDelay, 0),
  87. EscapeHatchWithdrawal: make([]WDelayerEventEscapeHatchWithdrawal, 0),
  88. NewHermezKeeperAddress: make([]WDelayerEventNewHermezKeeperAddress, 0),
  89. NewWhiteHackGroupAddress: make([]WDelayerEventNewWhiteHackGroupAddress, 0),
  90. NewHermezGovernanceDAOAddress: make([]WDelayerEventNewHermezGovernanceDAOAddress, 0),
  91. }
  92. }
  93. // WDelayerInterface is the inteface to WithdrawalDelayer Smart Contract
  94. type WDelayerInterface interface {
  95. //
  96. // Smart Contract Methods
  97. //
  98. WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error)
  99. WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error)
  100. WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error)
  101. WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error)
  102. WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error)
  103. WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error)
  104. WDelayerIsEmergencyMode() (bool, error)
  105. WDelayerGetWithdrawalDelay() (*big.Int, error)
  106. WDelayerGetEmergencyModeStartingTime() (*big.Int, error)
  107. WDelayerEnableEmergencyMode() (*types.Transaction, error)
  108. WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error)
  109. WDelayerDepositInfo(owner, token ethCommon.Address) (*big.Int, uint64)
  110. WDelayerDeposit(onwer, token ethCommon.Address, amount *big.Int) (*types.Transaction, error)
  111. WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error)
  112. WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address, amount *big.Int) (*types.Transaction, error)
  113. }
  114. //
  115. // Implementation
  116. //
  117. // WDelayerClient is the implementation of the interface to the WithdrawDelayer Smart Contract in ethereum.
  118. type WDelayerClient struct {
  119. client *EthereumClient
  120. address ethCommon.Address
  121. gasLimit uint64
  122. contractAbi abi.ABI
  123. }
  124. // NewWDelayerClient creates a new WDelayerClient
  125. func NewWDelayerClient(client *EthereumClient, address ethCommon.Address) (*WDelayerClient, error) {
  126. contractAbi, err := abi.JSON(strings.NewReader(string(WithdrawalDelayer.WithdrawalDelayerABI)))
  127. if err != nil {
  128. return nil, err
  129. }
  130. return &WDelayerClient{
  131. client: client,
  132. address: address,
  133. gasLimit: 1000000, //nolint:gomnd
  134. contractAbi: contractAbi,
  135. }, nil
  136. }
  137. // WDelayerGetHermezGovernanceDAOAddress is the interface to call the smart contract function
  138. func (c *WDelayerClient) WDelayerGetHermezGovernanceDAOAddress() (*ethCommon.Address, error) {
  139. var hermezGovernanceDAOAddress ethCommon.Address
  140. if err := c.client.Call(func(ec *ethclient.Client) error {
  141. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  142. if err != nil {
  143. return err
  144. }
  145. hermezGovernanceDAOAddress, err = wdelayer.GetHermezGovernanceDAOAddress(nil)
  146. return err
  147. }); err != nil {
  148. return nil, err
  149. }
  150. return &hermezGovernanceDAOAddress, nil
  151. }
  152. // WDelayerSetHermezGovernanceDAOAddress is the interface to call the smart contract function
  153. func (c *WDelayerClient) WDelayerSetHermezGovernanceDAOAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
  154. var tx *types.Transaction
  155. var err error
  156. if tx, err = c.client.CallAuth(
  157. c.gasLimit,
  158. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  159. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  160. if err != nil {
  161. return nil, err
  162. }
  163. return wdelayer.SetHermezGovernanceDAOAddress(auth, newAddress)
  164. },
  165. ); err != nil {
  166. return nil, fmt.Errorf("Failed setting hermezGovernanceDAOAddress: %w", err)
  167. }
  168. return tx, nil
  169. }
  170. // WDelayerGetHermezKeeperAddress is the interface to call the smart contract function
  171. func (c *WDelayerClient) WDelayerGetHermezKeeperAddress() (*ethCommon.Address, error) {
  172. var hermezKeeperAddress ethCommon.Address
  173. if err := c.client.Call(func(ec *ethclient.Client) error {
  174. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  175. if err != nil {
  176. return err
  177. }
  178. hermezKeeperAddress, err = wdelayer.GetHermezKeeperAddress(nil)
  179. return err
  180. }); err != nil {
  181. return nil, err
  182. }
  183. return &hermezKeeperAddress, nil
  184. }
  185. // WDelayerSetHermezKeeperAddress is the interface to call the smart contract function
  186. func (c *WDelayerClient) WDelayerSetHermezKeeperAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
  187. var tx *types.Transaction
  188. var err error
  189. if tx, err = c.client.CallAuth(
  190. c.gasLimit,
  191. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  192. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  193. if err != nil {
  194. return nil, err
  195. }
  196. return wdelayer.SetHermezKeeperAddress(auth, newAddress)
  197. },
  198. ); err != nil {
  199. return nil, fmt.Errorf("Failed setting hermezKeeperAddress: %w", err)
  200. }
  201. return tx, nil
  202. }
  203. // WDelayerGetWhiteHackGroupAddress is the interface to call the smart contract function
  204. func (c *WDelayerClient) WDelayerGetWhiteHackGroupAddress() (*ethCommon.Address, error) {
  205. var whiteHackGroupAddress ethCommon.Address
  206. if err := c.client.Call(func(ec *ethclient.Client) error {
  207. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  208. if err != nil {
  209. return err
  210. }
  211. whiteHackGroupAddress, err = wdelayer.GetWhiteHackGroupAddress(nil)
  212. return err
  213. }); err != nil {
  214. return nil, err
  215. }
  216. return &whiteHackGroupAddress, nil
  217. }
  218. // WDelayerSetWhiteHackGroupAddress is the interface to call the smart contract function
  219. func (c *WDelayerClient) WDelayerSetWhiteHackGroupAddress(newAddress ethCommon.Address) (*types.Transaction, error) {
  220. var tx *types.Transaction
  221. var err error
  222. if tx, err = c.client.CallAuth(
  223. c.gasLimit,
  224. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  225. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  226. if err != nil {
  227. return nil, err
  228. }
  229. return wdelayer.SetWhiteHackGroupAddress(auth, newAddress)
  230. },
  231. ); err != nil {
  232. return nil, fmt.Errorf("Failed setting whiteHackGroupAddress: %w", err)
  233. }
  234. return tx, nil
  235. }
  236. // WDelayerIsEmergencyMode is the interface to call the smart contract function
  237. func (c *WDelayerClient) WDelayerIsEmergencyMode() (bool, error) {
  238. var ermergencyMode bool
  239. if err := c.client.Call(func(ec *ethclient.Client) error {
  240. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  241. if err != nil {
  242. return err
  243. }
  244. ermergencyMode, err = wdelayer.IsEmergencyMode(nil)
  245. return err
  246. }); err != nil {
  247. return false, err
  248. }
  249. return ermergencyMode, nil
  250. }
  251. // WDelayerGetWithdrawalDelay is the interface to call the smart contract function
  252. func (c *WDelayerClient) WDelayerGetWithdrawalDelay() (*big.Int, error) {
  253. var withdrawalDelay *big.Int
  254. if err := c.client.Call(func(ec *ethclient.Client) error {
  255. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  256. if err != nil {
  257. return err
  258. }
  259. withdrawalDelay, err = wdelayer.GetWithdrawalDelay(nil)
  260. return err
  261. }); err != nil {
  262. return nil, err
  263. }
  264. return withdrawalDelay, nil
  265. }
  266. // WDelayerGetEmergencyModeStartingTime is the interface to call the smart contract function
  267. func (c *WDelayerClient) WDelayerGetEmergencyModeStartingTime() (*big.Int, error) {
  268. var emergencyModeStartingTime *big.Int
  269. if err := c.client.Call(func(ec *ethclient.Client) error {
  270. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  271. if err != nil {
  272. return err
  273. }
  274. emergencyModeStartingTime, err = wdelayer.GetEmergencyModeStartingTime(nil)
  275. return err
  276. }); err != nil {
  277. return nil, err
  278. }
  279. return emergencyModeStartingTime, nil
  280. }
  281. // WDelayerEnableEmergencyMode is the interface to call the smart contract function
  282. func (c *WDelayerClient) WDelayerEnableEmergencyMode() (*types.Transaction, error) {
  283. var tx *types.Transaction
  284. var err error
  285. if tx, err = c.client.CallAuth(
  286. c.gasLimit,
  287. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  288. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  289. if err != nil {
  290. return nil, err
  291. }
  292. return wdelayer.EnableEmergencyMode(auth)
  293. },
  294. ); err != nil {
  295. return nil, fmt.Errorf("Failed setting enable emergency mode: %w", err)
  296. }
  297. return tx, nil
  298. }
  299. // WDelayerChangeWithdrawalDelay is the interface to call the smart contract function
  300. func (c *WDelayerClient) WDelayerChangeWithdrawalDelay(newWithdrawalDelay uint64) (*types.Transaction, error) {
  301. var tx *types.Transaction
  302. var err error
  303. if tx, err = c.client.CallAuth(
  304. c.gasLimit,
  305. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  306. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  307. if err != nil {
  308. return nil, err
  309. }
  310. return wdelayer.ChangeWithdrawalDelay(auth, newWithdrawalDelay)
  311. },
  312. ); err != nil {
  313. return nil, fmt.Errorf("Failed setting withdrawal delay: %w", err)
  314. }
  315. return tx, nil
  316. }
  317. // WDelayerDepositInfo is the interface to call the smart contract function
  318. func (c *WDelayerClient) WDelayerDepositInfo(owner, token ethCommon.Address) (DepositState, error) {
  319. var depositInfo DepositState
  320. if err := c.client.Call(func(ec *ethclient.Client) error {
  321. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  322. if err != nil {
  323. return err
  324. }
  325. amount, depositTimestamp, err := wdelayer.DepositInfo(nil, owner, token)
  326. depositInfo.Amount = amount
  327. depositInfo.DepositTimestamp = depositTimestamp
  328. return err
  329. }); err != nil {
  330. return depositInfo, err
  331. }
  332. return depositInfo, nil
  333. }
  334. // WDelayerDeposit is the interface to call the smart contract function
  335. func (c *WDelayerClient) WDelayerDeposit(owner, token ethCommon.Address, amount *big.Int) (*types.Transaction, error) {
  336. var tx *types.Transaction
  337. var err error
  338. if tx, err = c.client.CallAuth(
  339. c.gasLimit,
  340. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  341. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  342. if err != nil {
  343. return nil, err
  344. }
  345. return wdelayer.Deposit(auth, owner, token, amount)
  346. },
  347. ); err != nil {
  348. return nil, fmt.Errorf("Failed deposit: %w", err)
  349. }
  350. return tx, nil
  351. }
  352. // WDelayerWithdrawal is the interface to call the smart contract function
  353. func (c *WDelayerClient) WDelayerWithdrawal(owner, token ethCommon.Address) (*types.Transaction, error) {
  354. var tx *types.Transaction
  355. var err error
  356. if tx, err = c.client.CallAuth(
  357. c.gasLimit,
  358. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  359. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  360. if err != nil {
  361. return nil, err
  362. }
  363. return wdelayer.Withdrawal(auth, owner, token)
  364. },
  365. ); err != nil {
  366. return nil, fmt.Errorf("Failed withdrawal: %w", err)
  367. }
  368. return tx, nil
  369. }
  370. // WDelayerEscapeHatchWithdrawal is the interface to call the smart contract function
  371. func (c *WDelayerClient) WDelayerEscapeHatchWithdrawal(to, token ethCommon.Address, amount *big.Int) (*types.Transaction, error) {
  372. var tx *types.Transaction
  373. var err error
  374. if tx, err = c.client.CallAuth(
  375. c.gasLimit,
  376. func(ec *ethclient.Client, auth *bind.TransactOpts) (*types.Transaction, error) {
  377. wdelayer, err := WithdrawalDelayer.NewWithdrawalDelayer(c.address, ec)
  378. if err != nil {
  379. return nil, err
  380. }
  381. return wdelayer.EscapeHatchWithdrawal(auth, to, token, amount)
  382. },
  383. ); err != nil {
  384. return nil, fmt.Errorf("Failed escapeHatchWithdrawal: %w", err)
  385. }
  386. return tx, nil
  387. }
  388. var (
  389. logWDelayerDeposit = crypto.Keccak256Hash([]byte("Deposit(address,address,uint192,uint64)"))
  390. logWDelayerWithdraw = crypto.Keccak256Hash([]byte("Withdraw(address,address,uint192)"))
  391. logWDelayerEmergencyModeEnabled = crypto.Keccak256Hash([]byte("EmergencyModeEnabled()"))
  392. logWDelayerNewWithdrawalDelay = crypto.Keccak256Hash([]byte("NewWithdrawalDelay(uint64)"))
  393. logWDelayerEscapeHatchWithdrawal = crypto.Keccak256Hash([]byte("EscapeHatchWithdrawal(address,address,address,uint256)"))
  394. logWDelayerNewHermezKeeperAddress = crypto.Keccak256Hash([]byte("NewHermezKeeperAddress(address)"))
  395. logWDelayerNewWhiteHackGroupAddress = crypto.Keccak256Hash([]byte("NewWhiteHackGroupAddress(address)"))
  396. logWDelayerNewHermezGovernanceDAOAddress = crypto.Keccak256Hash([]byte("NewHermezGovernanceDAOAddress(address)"))
  397. )
  398. // WDelayerEventsByBlock returns the events in a block that happened in the
  399. // WDelayer Smart Contract and the blockHash where the eents happened. If
  400. // there are no events in that block, blockHash is nil.
  401. func (c *WDelayerClient) WDelayerEventsByBlock(blockNum int64) (*WDelayerEvents, *ethCommon.Hash, error) {
  402. var wdelayerEvents WDelayerEvents
  403. var blockHash ethCommon.Hash
  404. query := ethereum.FilterQuery{
  405. FromBlock: big.NewInt(blockNum),
  406. ToBlock: big.NewInt(blockNum),
  407. Addresses: []ethCommon.Address{
  408. c.address,
  409. },
  410. BlockHash: nil,
  411. Topics: [][]ethCommon.Hash{},
  412. }
  413. logs, err := c.client.client.FilterLogs(context.Background(), query)
  414. if err != nil {
  415. return nil, nil, err
  416. }
  417. if len(logs) > 0 {
  418. blockHash = logs[0].BlockHash
  419. }
  420. for _, vLog := range logs {
  421. if vLog.BlockHash != blockHash {
  422. return nil, nil, ErrBlockHashMismatchEvent
  423. }
  424. switch vLog.Topics[0] {
  425. case logWDelayerDeposit:
  426. var deposit WDelayerEventDeposit
  427. err := c.contractAbi.Unpack(&deposit, "Deposit", vLog.Data)
  428. if err != nil {
  429. return nil, nil, err
  430. }
  431. deposit.Owner = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  432. deposit.Token = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  433. wdelayerEvents.Deposit = append(wdelayerEvents.Deposit, deposit)
  434. case logWDelayerWithdraw:
  435. var withdraw WDelayerEventWithdraw
  436. err := c.contractAbi.Unpack(&withdraw, "Withdraw", vLog.Data)
  437. if err != nil {
  438. return nil, nil, err
  439. }
  440. withdraw.Token = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  441. withdraw.Owner = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  442. wdelayerEvents.Withdraw = append(wdelayerEvents.Withdraw, withdraw)
  443. case logWDelayerEmergencyModeEnabled:
  444. var emergencyModeEnabled WDelayerEventEmergencyModeEnabled
  445. wdelayerEvents.EmergencyModeEnabled = append(wdelayerEvents.EmergencyModeEnabled, emergencyModeEnabled)
  446. case logWDelayerNewWithdrawalDelay:
  447. var withdrawalDelay WDelayerEventNewWithdrawalDelay
  448. err := c.contractAbi.Unpack(&withdrawalDelay, "NewWithdrawalDelay", vLog.Data)
  449. if err != nil {
  450. return nil, nil, err
  451. }
  452. wdelayerEvents.NewWithdrawalDelay = append(wdelayerEvents.NewWithdrawalDelay, withdrawalDelay)
  453. case logWDelayerEscapeHatchWithdrawal:
  454. var escapeHatchWithdrawal WDelayerEventEscapeHatchWithdrawal
  455. err := c.contractAbi.Unpack(&escapeHatchWithdrawal, "EscapeHatchWithdrawal", vLog.Data)
  456. if err != nil {
  457. return nil, nil, err
  458. }
  459. escapeHatchWithdrawal.Who = ethCommon.BytesToAddress(vLog.Topics[1].Bytes())
  460. escapeHatchWithdrawal.To = ethCommon.BytesToAddress(vLog.Topics[2].Bytes())
  461. escapeHatchWithdrawal.Token = ethCommon.BytesToAddress(vLog.Topics[3].Bytes())
  462. wdelayerEvents.EscapeHatchWithdrawal = append(wdelayerEvents.EscapeHatchWithdrawal, escapeHatchWithdrawal)
  463. case logWDelayerNewHermezKeeperAddress:
  464. var keeperAddress WDelayerEventNewHermezKeeperAddress
  465. err := c.contractAbi.Unpack(&keeperAddress, "NewHermezKeeperAddress", vLog.Data)
  466. if err != nil {
  467. return nil, nil, err
  468. }
  469. wdelayerEvents.NewHermezKeeperAddress = append(wdelayerEvents.NewHermezKeeperAddress, keeperAddress)
  470. case logWDelayerNewWhiteHackGroupAddress:
  471. var whiteHackGroupAddress WDelayerEventNewWhiteHackGroupAddress
  472. err := c.contractAbi.Unpack(&whiteHackGroupAddress, "NewWhiteHackGroupAddress", vLog.Data)
  473. if err != nil {
  474. return nil, nil, err
  475. }
  476. wdelayerEvents.NewWhiteHackGroupAddress = append(wdelayerEvents.NewWhiteHackGroupAddress, whiteHackGroupAddress)
  477. case logWDelayerNewHermezGovernanceDAOAddress:
  478. var governanceDAOAddress WDelayerEventNewHermezGovernanceDAOAddress
  479. err := c.contractAbi.Unpack(&governanceDAOAddress, "NewHermezGovernanceDAOAddress", vLog.Data)
  480. if err != nil {
  481. return nil, nil, err
  482. }
  483. wdelayerEvents.NewHermezGovernanceDAOAddress = append(wdelayerEvents.NewHermezGovernanceDAOAddress, governanceDAOAddress)
  484. }
  485. }
  486. return &wdelayerEvents, &blockHash, nil
  487. }