Skip to content

Commit

Permalink
feat: support multiple contract filters (#451)
Browse files Browse the repository at this point in the history
This PR enables support for multiple contract filter support.
  • Loading branch information
roshaans committed Dec 14, 2023
1 parent 28bc9f3 commit 663d4bc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useState, useEffect } from "react";
import { InputGroup, Alert } from "react-bootstrap";
import Form from "react-bootstrap/Form";
import { IndexerDetailsContext } from '../../contexts/IndexerDetailsContext';
import { validateContractId } from "../../utils/validators";
import { validateContractIds } from "../../utils/validators";
const GENESIS_BLOCK_HEIGHT = 9820210;
const IndexerConfigOptions = ({ updateConfig }) => {
const { indexerDetails, showPublishModal, isCreateNewIndexer, latestHeight } = useContext(IndexerDetailsContext);
Expand Down Expand Up @@ -31,7 +31,7 @@ const IndexerConfigOptions = ({ updateConfig }) => {
function handleSetContractFilter(e) {
const contractFilter = e.target.value;
setContractFilter(contractFilter);
const isContractFilterValid = validateContractId(contractFilter);
const isContractFilterValid = validateContractIds(contractFilter);
setIsContractFilterValid(isContractFilterValid);
}

Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/Modals/ForkIndexerModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useContext, useState } from "react";
import { Button, Modal, Alert, InputGroup, Form } from "react-bootstrap";
import IndexerConfigOptions from "../Form/IndexerConfigOptionsInputGroup";
import { IndexerDetailsContext } from "../../contexts/IndexerDetailsContext";
import { validateContractId } from "../../utils/validators";

export const ForkIndexerModal = ({ registerFunction, forkIndexer }) => {
const {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Modals/PublishModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext, useState } from "react";
import { Button, Modal, Alert } from "react-bootstrap";
import IndexerConfigOptions from "../Form/IndexerConfigOptionsInputGroup";
import { IndexerDetailsContext } from '../../contexts/IndexerDetailsContext';
import { validateContractId } from "../../utils/validators";
import { validateContractIds } from "../../utils/validators";

export const PublishModal = ({
registerFunction,
Expand Down Expand Up @@ -30,7 +30,7 @@ export const PublishModal = ({
return
}

if (!validateContractId(indexerConfig.filter)) {
if (!validateContractIds(indexerConfig.filter)) {
setError( () => "Please provide a valid contract name")
return
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ export function validateContractId(accountId) {
);
}

export function validateContractIds(accountIds) {
const ids = accountIds.split(',').map(id => id.trim());
return ids.every(accountId => validateContractId(accountId));
}

0 comments on commit 663d4bc

Please sign in to comment.