diff --git a/contract-watcher/builder/watcher.go b/contract-watcher/builder/watcher.go index 9a4f289a..0eed286c 100644 --- a/contract-watcher/builder/watcher.go +++ b/contract-watcher/builder/watcher.go @@ -82,3 +82,16 @@ func CreateMoonbeamWatcher(rateLimit int, chainURL string, wb config.WatcherBloc MethodsByAddress: wb.MethodsByAddress} return watcher.NewEvmStandarWatcher(moonbeamClient, params, repo, logger) } + +func CreateCeloWatcher(rateLimit int, chainURL string, wb config.WatcherBlockchainAddresses, logger *zap.Logger, repo *storage.Repository) watcher.ContractWatcher { + celoLimiter := ratelimit.New(rateLimit, ratelimit.Per(time.Second)) + celoClient := evm.NewEvmSDK(chainURL, celoLimiter) + params := watcher.EVMParams{ + ChainID: wb.ChainID, + Blockchain: wb.Name, + SizeBlocks: wb.SizeBlocks, + WaitSeconds: wb.WaitSeconds, + InitialBlock: wb.InitialBlock, + MethodsByAddress: wb.MethodsByAddress} + return watcher.NewEvmStandarWatcher(celoClient, params, repo, logger) +} diff --git a/contract-watcher/cmd/backfiller/run.go b/contract-watcher/cmd/backfiller/run.go index b98450a8..f6856e02 100644 --- a/contract-watcher/cmd/backfiller/run.go +++ b/contract-watcher/cmd/backfiller/run.go @@ -80,6 +80,8 @@ func newWatcherForMainnet(cfg *config.BackfillerConfiguration, repo *storage.Rep watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_MAINNET, logger, repo) case config.MOONBEAM_MAINNET.ChainID.String(): watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_MAINNET, logger, repo) + case config.CELO_MAINNET.ChainID.String(): + watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_MAINNET, logger, repo) default: logger.Fatal("chain not supported") } @@ -107,6 +109,8 @@ func newWatcherForTestnet(cfg *config.BackfillerConfiguration, repo *storage.Rep watcher = builder.CreateOasisWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.OASIS_TESTNET, logger, repo) case config.MOONBEAM_TESTNET.ChainID.String(): watcher = builder.CreateMoonbeamWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.MOONBEAM_TESTNET, logger, repo) + case config.CELO_TESTNET.ChainID.String(): + watcher = builder.CreateCeloWatcher(cfg.RateLimitPerSecond, cfg.ChainUrl, config.CELO_TESTNET, logger, repo) default: logger.Fatal("chain not supported") } diff --git a/contract-watcher/cmd/service/run.go b/contract-watcher/cmd/service/run.go index a361b897..a0c2494e 100644 --- a/contract-watcher/cmd/service/run.go +++ b/contract-watcher/cmd/service/run.go @@ -42,6 +42,7 @@ type watchersConfig struct { aptos *config.WatcherBlockchain oasis *config.WatcherBlockchainAddresses moonbeam *config.WatcherBlockchainAddresses + celo *config.WatcherBlockchainAddresses rateLimit rateLimitConfig } @@ -52,6 +53,7 @@ type rateLimitConfig struct { aptos int oasis int moonbeam int + celo int } func Run() { @@ -174,6 +176,10 @@ func newWatchers(config *config.ServiceConfiguration, repo *storage.Repository, result = append(result, moonbeamWatcher) } + if watchers.celo != nil { + celoWatcher := builder.CreateCeloWatcher(watchers.rateLimit.evm, config.CeloUrl, *watchers.celo, logger, repo) + result = append(result, celoWatcher) + } return result } @@ -191,6 +197,7 @@ func newWatchersForMainnet() *watchersConfig { aptos: &config.APTOS_MAINNET, oasis: &config.OASIS_MAINNET, moonbeam: &config.MOONBEAM_MAINNET, + celo: &config.CELO_MAINNET, rateLimit: rateLimitConfig{ evm: 1000, solana: 3, @@ -215,6 +222,7 @@ func newWatchersForTestnet() *watchersConfig { aptos: &config.APTOS_TESTNET, oasis: &config.OASIS_TESTNET, moonbeam: &config.MOONBEAM_TESTNET, + celo: &config.CELO_TESTNET, rateLimit: rateLimitConfig{ evm: 10, solana: 2, diff --git a/contract-watcher/config/config.go b/contract-watcher/config/config.go index 8e84d8d1..0e917ecc 100644 --- a/contract-watcher/config/config.go +++ b/contract-watcher/config/config.go @@ -20,6 +20,7 @@ type ServiceConfiguration struct { AptosUrl string `env:"APTOS_URL,required"` OasisUrl string `env:"OASIS_URL,required"` MoonbeamUrl string `env:"MOONBEAM_URL,required"` + CeloUrl string `env:"CELO_URL,required"` PprofEnabled bool `env:"PPROF_ENABLED,default=false"` P2pNetwork string `env:"P2P_NETWORK,required"` } diff --git a/contract-watcher/config/mainnet.go b/contract-watcher/config/mainnet.go index f2dd89b0..c41362bf 100644 --- a/contract-watcher/config/mainnet.go +++ b/contract-watcher/config/mainnet.go @@ -264,3 +264,37 @@ var MOONBEAM_MAINNET = WatcherBlockchainAddresses{ }, }, } + +var CELO_MAINNET = WatcherBlockchainAddresses{ + ChainID: vaa.ChainIDCelo, + Name: "celo", + SizeBlocks: 50, + WaitSeconds: 10, + InitialBlock: 12947239, + MethodsByAddress: map[string][]BlockchainMethod{ + strings.ToLower("0x796Dff6D74F3E27060B71255Fe517BFb23C93eed"): { + { + ID: MethodIDCompleteTransfer, + Name: MethodCompleteTransfer, + }, + { + ID: MethodIDCompleteAndUnwrapETH, + Name: MethodCompleteAndUnwrapETH, + }, + { + ID: MethodIDCreateWrapped, + Name: MethodCreateWrapped, + }, + { + ID: MethodIDUpdateWrapped, + Name: MethodUpdateWrapped, + }, + }, + strings.ToLower("0xcafd2f0a35a4459fa40c0517e17e6fa2939441ca"): { + { + ID: MetehodIDCompleteTransferWithRelay, + Name: MetehodCompleteTransferWithRelay, + }, + }, + }, +} diff --git a/contract-watcher/config/testnet.go b/contract-watcher/config/testnet.go index 8fc84e55..14dc814b 100644 --- a/contract-watcher/config/testnet.go +++ b/contract-watcher/config/testnet.go @@ -255,3 +255,37 @@ var MOONBEAM_TESTNET = WatcherBlockchainAddresses{ }, }, } + +var CELO_TESTNET = WatcherBlockchainAddresses{ + ChainID: vaa.ChainIDCelo, + Name: "celo", + SizeBlocks: 50, + WaitSeconds: 10, + InitialBlock: 10625129, + MethodsByAddress: map[string][]BlockchainMethod{ + strings.ToLower("0x05ca6037eC51F8b712eD2E6Fa72219FEaE74E153"): { + { + ID: MethodIDCompleteTransfer, + Name: MethodCompleteTransfer, + }, + { + ID: MethodIDCompleteAndUnwrapETH, + Name: MethodCompleteAndUnwrapETH, + }, + { + ID: MethodIDCreateWrapped, + Name: MethodCreateWrapped, + }, + { + ID: MethodIDUpdateWrapped, + Name: MethodUpdateWrapped, + }, + }, + strings.ToLower("0x9563a59C15842a6f322B10f69d1dD88b41f2E97B"): { + { + ID: MetehodIDCompleteTransferWithRelay, + Name: MetehodCompleteTransferWithRelay, + }, + }, + }, +} diff --git a/deploy/contract-watcher/contract-watcher-service.yaml b/deploy/contract-watcher/contract-watcher-service.yaml index ecb0036b..8fd44f07 100644 --- a/deploy/contract-watcher/contract-watcher-service.yaml +++ b/deploy/contract-watcher/contract-watcher-service.yaml @@ -87,6 +87,11 @@ spec: secretKeyRef: name: blockchain key: moonbeam-url + - name: CELO_URL + valueFrom: + secretKeyRef: + name: blockchain + key: celo-url resources: limits: memory: {{ .RESOURCES_LIMITS_MEMORY }} diff --git a/deploy/contract-watcher/env/production.env b/deploy/contract-watcher/env/production.env index 93700658..52dcb94d 100644 --- a/deploy/contract-watcher/env/production.env +++ b/deploy/contract-watcher/env/production.env @@ -14,4 +14,5 @@ SOLANA_URL= TERRA_URL= APTOS_URL= OASIS_URL= -MOONBEAM_URL= \ No newline at end of file +MOONBEAM_URL= +CELO_URL= \ No newline at end of file diff --git a/deploy/contract-watcher/env/staging.env b/deploy/contract-watcher/env/staging.env index 53230b60..8457a1b5 100644 --- a/deploy/contract-watcher/env/staging.env +++ b/deploy/contract-watcher/env/staging.env @@ -14,4 +14,5 @@ SOLANA_URL= TERRA_URL= APTOS_URL= OASIS_URL= -MOONBEAM_URL= \ No newline at end of file +MOONBEAM_URL= +CELO_URL= \ No newline at end of file diff --git a/deploy/contract-watcher/env/test.env b/deploy/contract-watcher/env/test.env index 283a61f4..2ab2dc67 100644 --- a/deploy/contract-watcher/env/test.env +++ b/deploy/contract-watcher/env/test.env @@ -14,4 +14,5 @@ SOLANA_URL= TERRA_URL= APTOS_URL= OASIS_URL= -MOONBEAM_URL= \ No newline at end of file +MOONBEAM_URL= +CELO_URL= \ No newline at end of file diff --git a/deploy/contract-watcher/secrets.yaml b/deploy/contract-watcher/secrets.yaml index fe9a90c4..0e8bfcb6 100644 --- a/deploy/contract-watcher/secrets.yaml +++ b/deploy/contract-watcher/secrets.yaml @@ -11,4 +11,5 @@ data: aptos-url: {{ .APTOS_URL | b64enc }} oasis-url: {{ .OASIS_URL | b64enc }} moonbeam-url: {{ .MOONBEAM_URL | b64enc }} + celo-url: {{ .CELO_URL | b64enc }} type: Opaque