diff --git a/.gitignore b/.gitignore index 35a747e88..011bf7796 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ logs npm-debug.log* yarn-debug.log* yarn-error.log* +yarn.lock +package-lock.json # Runtime data pids diff --git a/package.json b/package.json index ed2f460c1..71dadf893 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "web3": "1.0.0-beta.52" }, "scripts": { - "start": "react-scripts start", + "start": "react-scripts --openssl-legacy-provider start", "build": "npm run sitemap && react-scripts --max_old_space_size=8192 build", "test": "react-scripts test", "eject": "react-scripts eject", diff --git a/src/components/AiMarketplace/MainSection/Filter/ToolBar/styles.js b/src/components/AiMarketplace/MainSection/Filter/ToolBar/styles.js index 8ea82aaee..39e065fc3 100644 --- a/src/components/AiMarketplace/MainSection/Filter/ToolBar/styles.js +++ b/src/components/AiMarketplace/MainSection/Filter/ToolBar/styles.js @@ -62,6 +62,7 @@ export const useStyles = makeStyles(theme => ({ "@media(max-width: 548px)": { margin: "15px 0 0" }, }, iconsContainer: { + minHeight: 34, display: "flex", alignItems: "center", justifyContent: "flex-end", @@ -73,7 +74,7 @@ export const useStyles = makeStyles(theme => ({ cursor: "pointer", "& span": { color: theme.palette.text.lightShadedGray, - fontSize: 17, + fontSize: 18, }, }, "@media(max-width: 768px)": { paddingTop: 15 }, diff --git a/src/components/ServiceDetails/CreatorDetails/Contacts/index.js b/src/components/ServiceDetails/CreatorDetails/Contacts/index.js index 689239a91..abc132969 100644 --- a/src/components/ServiceDetails/CreatorDetails/Contacts/index.js +++ b/src/components/ServiceDetails/CreatorDetails/Contacts/index.js @@ -55,10 +55,10 @@ const Contacts = ({ contacts, show, handleClose, classes }) => { { return training.training_methods[0].split(".")[1].split("/")[0]; }; diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js index 3a8ae098e..d50acfdd7 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js @@ -57,9 +57,17 @@ const ModelInfo = ({ publicAccess: enableAccessModel, address: !enableAccessModel ? ethAddress : [], }; - return await serviceClient.createModel(address, params); + const param = { + grpcMethod: training.training_methods[0], + grpcService: serviceName, + address, + }; + const response = await serviceClient.getExistingModel(param); + if(response.length < 20) + { + return await serviceClient.createModel(address, params); + } }; - const onUpdate = () => { const updateModelParams = { trainingModelName, @@ -70,6 +78,7 @@ const ModelInfo = ({ updateModel(updateModelParams); }; + const onNext = async () => { try { startMMconnectLoader(); @@ -77,7 +86,6 @@ const ModelInfo = ({ const address = await sdk.account.getAddress(); const availableUserWallets = await fetchAvailableUserWallets(); const addressAlreadyRegistered = availableUserWallets.some(wallet => wallet.address.toLowerCase() === address); - if (!addressAlreadyRegistered) { await registerWallet(address, walletTypes.METAMASK); } diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/index.js index fbd48f2a4..dea51e3ba 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/index.js @@ -9,7 +9,7 @@ import Payment from "./Payment"; import Finish from "./Finish"; const CreateModel = (props) => { - const { service, classes, training, modelDetailsOnEdit, cancelEditModel, updateModel, deleteModel, } = props; + const { service, classes, training, modelDetailsOnEdit, cancelEditModel, updateModel, deleteModel } = props; const [activeSection, setActiveSection] = React.useState(1); const [modelData, setModelData] = useState({}); const [trainModelId, setTrainModelId] = useState(); @@ -19,7 +19,6 @@ const CreateModel = (props) => { const onBackClick = () => { setActiveSection(activeSection - 1); }; - const createModelTabs = [ { key: "modelInfo", diff --git a/src/components/ServiceDetails/TrainingModels/index.js b/src/components/ServiceDetails/TrainingModels/index.js index 04b109bae..2f53bc0fc 100644 --- a/src/components/ServiceDetails/TrainingModels/index.js +++ b/src/components/ServiceDetails/TrainingModels/index.js @@ -9,21 +9,22 @@ import ProjectDetails from "../ProjectDetails"; import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined"; import CreateModel from "./CreateModel"; -const TrainingModels = ({ - classes, - service, - training, - createModelCalled, - modelDetailsOnEdit, - cancelEditModel, - updateModel, - editModel, - deleteModel, -}) => { +const TrainingModels = (props) => { + const { + classes, + service, + training, + createModelCalled, + modelDetailsOnEdit, + cancelEditModel, + updateModel, + editModel, + deleteModel + } = props const [showCreateModel, setShowCreateModel] = useState(false); - const handleRequestModel = () => { setShowCreateModel(true); + }; const RenderExistingModel = useCallback(() => { diff --git a/src/components/ServiceDetails/index.js b/src/components/ServiceDetails/index.js index 586abaa6f..1436e49d5 100644 --- a/src/components/ServiceDetails/index.js +++ b/src/components/ServiceDetails/index.js @@ -42,7 +42,7 @@ class ServiceDetails extends Component { modelDetailsOnEdit: undefined, }; } - + initializeService = async () => { const { org_id, service_id } = this.props.service; const sdk = await initSdk(); @@ -245,7 +245,6 @@ class ServiceDetails extends Component { } const seoURL = `${process.env.REACT_APP_BASE_URL}/servicedetails/org/${orgId}/service/${serviceId}`; - return (
{ + const chainId = web3.utils.hexToNumber(chainIdHex); + if (chainId !== Number(process.env.REACT_APP_ETH_NETWORK)) { + this.setState({ invalidMetaMaskDetails: true, alert: networkChangeAlert }); + } else { + this.setState({ invalidMetaMaskDetails: false, alert: {} }); + } + }; componentDidMount() { + if (!isNil(ethereum)) { + ethereum.request({ method: ethereumMethods.REQUEST_CHAIN_ID }).then(this.validateChainId); + ethereum.on(ethereumEvents.CHAIN_CHANGED, this.validateChainId); + } window.addEventListener("snetMMAccountChanged", this.handleMetaMaskAccountChange); window.addEventListener("snetMMNetworkChanged", this.handleMetaMaskNetworkChange); } diff --git a/src/utility/snetSdk.js b/src/utility/snetSdk.js new file mode 100644 index 000000000..cb09f312f --- /dev/null +++ b/src/utility/snetSdk.js @@ -0,0 +1,9 @@ +var ethereumMethods = { + REQUEST_ACCOUNTS: "eth_requestAccounts", + REQUEST_CHAIN_ID: "eth_chainId" + }; + exports.ethereumMethods = ethereumMethods; + var ethereumEvents = { + CHAIN_CHANGED: "chainChanged" + }; + exports.ethereumEvents = ethereumEvents; \ No newline at end of file