Skip to content

Commit

Permalink
temporarily use only devnet api for SC Explainer until mainnet issues…
Browse files Browse the repository at this point in the history
… are fixed
  • Loading branch information
radumojic committed Nov 23, 2023
1 parent c7bdc2d commit 8b802e6
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions src/helpers/assistantApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,44 @@ export const AssistantApiSSETypes = {
codeExplanation: {
streamChunk: 'code-explanation-stream-chunk',
chunkFinished: 'code-explanation-chunk-finished',
streamFailed: 'code-explanation-stream-failed'
}
streamFailed: 'code-explanation-stream-failed',
},
};

const AssistantApiEndpoints = {
utils: {
smartContractExplanation: '/utils/smart_contract_explanation/'
}
smartContractExplanation: '/utils/smart_contract_explanation/',
},
};

const getBaseAssistantApiUrl = (chain: EnvironmentsEnum) => {
switch (chain) {
case EnvironmentsEnum.mainnet:
return ApiBaseUrls.mainnet;
case EnvironmentsEnum.devnet:
return ApiBaseUrls.devnet;
case EnvironmentsEnum.testnet:
return ApiBaseUrls.testnet;
default:
return ApiBaseUrls.mainnet;
}
// temporarily use only devnet until mainnet issues are fixed
return ApiBaseUrls.devnet;
// switch (chain) {
// case EnvironmentsEnum.mainnet:
// return ApiBaseUrls.mainnet;
// case EnvironmentsEnum.devnet:
// return ApiBaseUrls.devnet;
// case EnvironmentsEnum.testnet:
// return ApiBaseUrls.testnet;
// default:
// return ApiBaseUrls.mainnet;
// }
};

export const assistantApi = {
getCodeExplanationEventSource: (
parameters: GetExplanationEventSourceParameters
parameters: GetExplanationEventSourceParameters,
) => {
const { repositoryUrl } = parameters;
const getExplanationEndpointUrl = `${getBaseAssistantApiUrl(
parameters.chain
parameters.chain,
)}${explainerApiUrl}${
AssistantApiEndpoints.utils.smartContractExplanation
}`;

return new EventSource(
`${getExplanationEndpointUrl}?repository_url=${repositoryUrl}`
`${getExplanationEndpointUrl}?repository_url=${repositoryUrl}`,
);
}
},
};

0 comments on commit 8b802e6

Please sign in to comment.