diff --git a/frontend/src/components/Editor/EditorButtons.jsx b/frontend/src/components/Editor/EditorButtons.jsx
index 0ad440a2a..67679249b 100644
--- a/frontend/src/components/Editor/EditorButtons.jsx
+++ b/frontend/src/components/Editor/EditorButtons.jsx
@@ -83,7 +83,7 @@ const EditorButtons = ({
Contract Filter
{
const [blockHeightError, setBlockHeightError] = useState(null)
useEffect(() => {
- if (indexerDetails.config?.startBlockHeight) {
+ if (indexerDetails.rule?.affected_account_id) {
+ setContractFilter(indexerDetails.rule.affected_account_id)
+ }
+
+ if (indexerDetails.startBlock?.HEIGHT) {
setStartBlock(START_BLOCK.HEIGHT)
- setBlockHeight(indexerDetails.config.startBlockHeight)
+ setBlockHeight(indexerDetails.startBlock.HEIGHT)
+ return;
}
- if (indexerDetails.config?.filter) {
- setContractFilter(indexerDetails.config.filter)
+
+ if (indexerDetails.startBlock == "LATEST") {
+ setStartBlock(START_BLOCK.LATEST)
+ return;
+ }
+
+ if (indexerDetails.startBlock == "CONTINUE") {
+ setStartBlock(START_BLOCK.CONTINUE)
+ return;
}
}, [indexerDetails])
@@ -36,7 +48,7 @@ const IndexerConfigOptions = ({ updateConfig }) => {
setStartBlock(e.target.value)
if (e.target.value === START_BLOCK.CONTINUE) {
- handleSetContractFilter(indexerDetails.config.filter)
+ handleSetContractFilter(indexerDetails.rule.affected_account_id)
}
}
@@ -110,7 +122,7 @@ const IndexerConfigOptions = ({ updateConfig }) => {
Contract Filter
handleSetContractFilter(e.target.value)}
isValid={isContractFilterValid}
type="text"
diff --git a/frontend/src/components/Logs/LogButtons.jsx b/frontend/src/components/Logs/LogButtons.jsx
index cab283b36..49963a8b8 100644
--- a/frontend/src/components/Logs/LogButtons.jsx
+++ b/frontend/src/components/Logs/LogButtons.jsx
@@ -78,7 +78,7 @@ const LogButtons = ({
Contract Filter
{ },
showPublishModal: false,
@@ -65,16 +65,13 @@ export const IndexerDetailsProvider = ({ children }) => {
const requestIndexerDetails = async () => {
const data = await queryIndexerFunctionDetails(accountId, indexerName);
if (data) {
- const indexerConfig = {
- startBlockHeight: data.start_block_height,
- filter: data.filter.matching_rule.affected_account_id,
- }
const details = {
accountId: accountId,
indexerName: indexerName,
code: wrapCode(data.code),
schema: data.schema,
- config: indexerConfig
+ startBlock: data.start_block,
+ rule: data.rule
}
return details
}
@@ -102,7 +99,8 @@ export const IndexerDetailsProvider = ({ children }) => {
indexerName: indexer.indexerName,
code: indexer.code,
schema: indexer.schema,
- config: indexer.config
+ startBlock: indexer.startBlock,
+ rule: indexer.rule
}
setIndexerDetails(details);
})();
diff --git a/frontend/src/utils/queryIndexerFunction.js b/frontend/src/utils/queryIndexerFunction.js
index 06ee177e7..70ea7b20f 100644
--- a/frontend/src/utils/queryIndexerFunction.js
+++ b/frontend/src/utils/queryIndexerFunction.js
@@ -8,21 +8,27 @@ const provider = new providers.JsonRpcProvider(
);
export const queryIndexerFunctionDetails = async (accountId, functionName) => {
- let args = { account_id: accountId, function_name: functionName };
+ let args = { account_id: accountId };
try {
const result = await provider.query({
request_type: "call_function",
account_id: REGISTRY_CONTRACT,
- method_name: "read_indexer_function",
+ // TODO Create method to query single indexer
+ method_name: "list_by_account",
args_base64: Buffer.from(JSON.stringify(args)).toString("base64"),
finality: "optimistic",
});
- return (
- result.result &&
+
+ const indexers = result.result &&
result.result.length > 0 &&
- JSON.parse(Buffer.from(result.result).toString())
- );
+ JSON.parse(Buffer.from(result.result).toString());
+
+ if (!indexers) {
+ return null;
+ }
+
+ return indexers[functionName];
} catch (error) {
console.log(`Could not query indexer function details from registry ${REGISTRY_CONTRACT}, for ${accountId}/${functionName}`)
console.log(error, "error");