---          
apiVersion: v1
kind: Service
metadata:
  name: {{ .NAME }}-eth-1
  namespace: {{ .NAMESPACE }}
  labels:
    app: {{ .NAME }}-eth-1
spec:
  selector:
    app: {{ .NAME }}-eth-1
  ports:
    - port: {{ .PORT }}
      targetPort: {{ .PORT }}
      name: {{ .NAME }}-eth-1
      protocol: TCP
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: blockchain-watcher-eth-1-pvc
  namespace: {{ .NAMESPACE }}
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Mi
  storageClassName: gp2
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .NAME }}-eth-1-jobs
  namespace: {{ .NAMESPACE }}
data:
  testnet-jobs.json: |-
    [
      {
        "id": "poll-log-message-published-optimism",
        "chain": "optimism",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 15000,
            "addresses": ["0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35"],
            "chain": "optimism"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x6b9C8671cdDC8dEab9c719bB87cBd3e782bA6a35"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-base",
        "chain": "base",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "finalized",
            "interval": 15000,
            "addresses": ["0x23908A62110e21C04F3A4e011d24F901F911744A"],
            "chain": "base"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x23908A62110e21C04F3A4e011d24F901F911744A"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-celo",
        "chain": "celo",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 15000,
            "addresses": ["0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56"],
            "chain": "celo"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x88505117CA88e7dd2eC6EA1E13f0948db2D50D56"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-oasis",
        "chain": "oasis",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 15000,
            "addresses": ["0xc1C338397ffA53a2Eb12A7038b4eeb34791F8aCb"],
            "chain": "oasis"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xc1C338397ffA53a2Eb12A7038b4eeb34791F8aCb"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-klaytn",
        "chain": "klaytn",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 15000,
            "addresses": ["0x1830CC6eE66c84D2F177B94D544967c774E624cA"],
            "chain": "klaytn"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x1830CC6eE66c84D2F177B94D544967c774E624cA"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-arbitrum",
        "chain": "arbitrum",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 30000,
            "addresses": ["0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e"],
            "chain": "arbitrum"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xC7A204bDBFe983FCD8d8E61D02b475D4073fF97e"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-polygon",
        "chain": "polygon",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 15000,
            "addresses": ["0x0CBE91CF822c73C2315FB05100C2F714765d5c20"],
            "chain": "polygon"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x0CBE91CF822c73C2315FB05100C2F714765d5c20"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      }
    ]
  mainnet-jobs.json: |-
    [
      {
        "id": "poll-log-message-published-optimism",
        "chain": "optimism",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 5000,
            "addresses": ["0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722"],
            "chain": "optimism"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xEe91C335eab126dF5fDB3797EA9d6aD93aeC9722"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-base",
        "chain": "base",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "finalized",
            "interval": 5000,
            "addresses": ["0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6"],
            "chain": "base"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xbebdb6C8ddC678FfA9f8748f85C815C556Dd8ac6"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-celo",
        "chain": "celo",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 5000,
            "addresses": ["0xa321448d90d4e5b0A732867c18eA198e75CAC48E"],
            "chain": "celo"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xa321448d90d4e5b0A732867c18eA198e75CAC48E"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-oasis",
        "chain": "oasis",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 5000,
            "addresses": ["0xfE8cD454b4A1CA468B57D79c0cc77Ef5B6f64585"],
            "chain": "oasis"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xfE8cD454b4A1CA468B57D79c0cc77Ef5B6f64585"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-klaytn",
        "chain": "klaytn",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 5000,
            "addresses": ["0x0C21603c4f3a6387e241c0091A7EA39E43E90bb7"],
            "chain": "klaytn"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x0C21603c4f3a6387e241c0091A7EA39E43E90bb7"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-arbitrum",
        "chain": "arbitrum",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 30000,
            "addresses": ["0xa5f208e072434bC67592E4C49C1B991BA79BCA46"],
            "chain": "arbitrum"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0xa5f208e072434bC67592E4C49C1B991BA79BCA46"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      },
      {
        "id": "poll-log-message-published-polygon",
        "chain": "polygon",
        "source": {
          "action": "PollEvm",
          "config": {
            "blockBatchSize": 100,
            "commitment": "latest",
            "interval": 5000,
            "addresses": ["0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7"],
            "chain": "polygon"
          }
        },
        "handlers": [
          {
            "action": "HandleEvmLogs",
            "target": "sns",
            "mapper": "evmLogMessagePublishedMapper",
            "config": {
              "abi": "event LogMessagePublished(address indexed sender, uint64 sequence, uint32 nonce, bytes payload, uint8 consistencyLevel)",
              "filter": {
                "addresses": ["0x7A4B5a56256163F07b2C80A7cA55aBE66c4ec4d7"],
                "topics": ["0x6eb224fb001ed210e379b335e35efe88672a8ce935d981a6896b27ffdf52a3b2"]
              }
            }
          }
        ]
      }
    ]
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .NAME }}-eth-1
  namespace: {{ .NAMESPACE }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: {{ .NAME }}-eth-1
  template:
    metadata:
      labels:
        app: {{ .NAME }}-eth-1
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/port: "{{ .PORT }}"
    spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      serviceAccountName: event-watcher
      containers:
        - name: {{ .NAME }}
          image: {{ .IMAGE_NAME }}
          env:
            - name: NODE_ENV
              value: {{ .NODE_ENV }}
            - name: PORT
              value: "{{ .PORT }}"
            - name: LOG_LEVEL
              value: {{ .LOG_LEVEL }}
            - name: BLOCKCHAIN_ENV
              value: {{ .BLOCKCHAIN_ENV }}
            - name: DRY_RUN_ENABLED
              value: "{{ .DRY_RUN_ENABLED }}"
            - name: SNS_TOPIC_ARN
              value: {{ .SNS_TOPIC_ARN }}
            - name: SNS_REGION
              value: {{ .SNS_REGION }}
            - name: JOBS_DIR
              value: /home/node/app/jobs
            {{ if .BASE_RPCS }}
            - name: BASE_RPCS
              value: '{{ .BASE_RPCS }}'
            {{ end }}
          resources:
            limits:
              memory: {{ .RESOURCES_LIMITS_MEMORY }}
              cpu: {{ .RESOURCES_LIMITS_CPU }}
            requests:
              memory: {{ .RESOURCES_REQUESTS_MEMORY }}
              cpu: {{ .RESOURCES_REQUESTS_CPU }}
          volumeMounts:
            - name: metadata-volume
              mountPath: /home/node/app/metadata-repo 
            - name: jobs-volume
              mountPath: /home/node/app/jobs
      volumes:
        - name: metadata-volume
          persistentVolumeClaim:
            claimName: blockchain-watcher-eth-1-pvc
        - name: jobs-volume
          configMap:
            name: {{ .NAME }}-eth-1-jobs
            items:
              - key: {{ .BLOCKCHAIN_ENV }}-jobs.json
                path: jobs.json
