From 3296a11923c8c38afc1f90aa42e759de0d030ce7 Mon Sep 17 00:00:00 2001 From: sreeshnap Date: Tue, 29 Nov 2022 17:34:07 +0530 Subject: [PATCH 1/9] marketplace dapp metamask message --- .../common/NetworkChangeOverlay/index.js | 19 ++++++++++++++++++- src/utility/snetSdk.js | 9 +++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/utility/snetSdk.js diff --git a/src/components/common/NetworkChangeOverlay/index.js b/src/components/common/NetworkChangeOverlay/index.js index f4ba1a3c7..1793689ff 100644 --- a/src/components/common/NetworkChangeOverlay/index.js +++ b/src/components/common/NetworkChangeOverlay/index.js @@ -12,7 +12,12 @@ import { useStyles } from "./styles"; import { walletTypes } from "../../../Redux/actionCreators/UserActions"; import { initSdk } from "../../../utility/sdk"; import { Networks } from "../../../config/Networks"; -// import { type } from "jquery"; +import { ethereumEvents,ethereumMethods } from "../../../utility/snetSdk"; +import { isNil } from "lodash"; +import Web3 from "web3"; + +const ethereum = window.ethereum; +const web3 = new Web3(ethereum, null, {}); const accountChangeAlert = { header: "Incorrect Metamask Account", @@ -36,8 +41,20 @@ class NetworkChangeOverlay extends Component { } sdk; + validateChainId = chainIdHex => { + 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 From 4dd341d8817b9824d057834e8088e190f729fbf8 Mon Sep 17 00:00:00 2001 From: sreeshnap Date: Fri, 2 Dec 2022 15:30:17 +0530 Subject: [PATCH 2/9] create model restriction --- .../ServiceDetails/ExistingModel/index.js | 5 ++- .../CreateModel/ModelInfo/index.js | 14 ++++++-- .../TrainingModels/CreateModel/index.js | 5 +-- .../ServiceDetails/TrainingModels/index.js | 33 +++++++++++-------- src/components/ServiceDetails/index.js | 15 +++++++-- 5 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/components/ServiceDetails/ExistingModel/index.js b/src/components/ServiceDetails/ExistingModel/index.js index 7a72328bf..63c6c2d67 100644 --- a/src/components/ServiceDetails/ExistingModel/index.js +++ b/src/components/ServiceDetails/ExistingModel/index.js @@ -28,6 +28,9 @@ const ExistingModel = ({ haveANewModel, wallet, editModel, + createModelRestrict, + createModelRestrictChange, + setCreateModel }) => { const [metamaskConnected, setMetamaskConnected] = useState(false); const [existingModels, setExistingModels] = useState([]); @@ -35,7 +38,6 @@ const ExistingModel = ({ const [sdkService, setSdkService] = useState(); const [alert, setAlert] = useState({}); const dispatch = useDispatch(); - const getServiceName = () => { return training.training_methods[0].split(".")[1].split("/")[0]; }; @@ -52,6 +54,7 @@ const ExistingModel = ({ }; const response = await serviceClient.getExistingModel(params); console.log("=====existingModel==", response.flat()); + setCreateModel (response.flat().length) setExistingModels(response.flat()); stopLoader(); }; diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js index 3a8ae098e..f4d6dd92c 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js @@ -33,6 +33,8 @@ const ModelInfo = ({ cancelEditModel, updateModel, deleteModel, + createModelRestrict, + createModelRestrictChange }) => { const [enableAccessModel, setEnableAccessModel] = useState( modelDetailsOnEdit && modelDetailsOnEdit.publicAccess === true ? true : false @@ -57,9 +59,16 @@ const ModelInfo = ({ publicAccess: enableAccessModel, address: !enableAccessModel ? ethAddress : [], }; - return await serviceClient.createModel(address, params); + if(createModelRestrict < 10) + { + createModelRestrictChange(); + return await serviceClient.createModel(address, params); + } + else + { + console.log("20 is over"); + } }; - const onUpdate = () => { const updateModelParams = { trainingModelName, @@ -70,6 +79,7 @@ const ModelInfo = ({ updateModel(updateModelParams); }; + const onNext = async () => { try { startMMconnectLoader(); diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/index.js index fbd48f2a4..b394dfb8f 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,createModelRestrict,createModelRestrictChange } = 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", @@ -32,6 +31,8 @@ const CreateModel = (props) => { cancelEditModel={cancelEditModel} updateModel={updateModel} deleteModel={deleteModel} + createModelRestrict={createModelRestrict} + createModelRestrictChange={createModelRestrictChange} /> ), }, diff --git a/src/components/ServiceDetails/TrainingModels/index.js b/src/components/ServiceDetails/TrainingModels/index.js index 04b109bae..7fcf738f1 100644 --- a/src/components/ServiceDetails/TrainingModels/index.js +++ b/src/components/ServiceDetails/TrainingModels/index.js @@ -9,19 +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, + createModelRestrict, + createModelRestrictChange, + setCreateModel + } = props const [showCreateModel, setShowCreateModel] = useState(false); - const handleRequestModel = () => { setShowCreateModel(true); }; @@ -34,6 +37,9 @@ const TrainingModels = ({ haveANewModel={training?.training_methods?.length || false} training={training} editModel={editModel} + createModelRestrict={createModelRestrict} + createModelRestrictChange={createModelRestrictChange} + setCreateModel ={ setCreateModel } /> ); } @@ -69,7 +75,8 @@ const TrainingModels = ({ {showCreateModel ? ( - + ) : ( <>
diff --git a/src/components/ServiceDetails/index.js b/src/components/ServiceDetails/index.js index 586abaa6f..9697c3d5c 100644 --- a/src/components/ServiceDetails/index.js +++ b/src/components/ServiceDetails/index.js @@ -40,8 +40,17 @@ class ServiceDetails extends Component { }, createModelCalled: "new", modelDetailsOnEdit: undefined, + createModelRestrict: 0 }; } + + setCreateModel = (response)=>{ + this.setState({ ...this.state, createModelRestrict: response }) + } + + createModelRestrictChange = () =>{ + this.setState({ ...this.state, createModelRestrict: this.state.createModelRestrict+1 }) + } initializeService = async () => { const { org_id, service_id } = this.props.service; @@ -184,7 +193,7 @@ class ServiceDetails extends Component { render() { const { classes, service, pricing, loading, error, history, groupInfo, match, training, isLoggedIn } = this.props; - const { offlineNotication } = this.state; + const { offlineNotication,createModelRestrict } = this.state; const { params: { orgId, serviceId }, } = match; @@ -239,13 +248,15 @@ class ServiceDetails extends Component { updateModel={this.onUpdateModel} editModel={this.editModel} deleteModel={this.deleteModel} + createModelRestrict={createModelRestrict} + createModelRestrictChange={this.createModelRestrictChange} + setCreateModel ={this.setCreateModel} /> ), }); } const seoURL = `${process.env.REACT_APP_BASE_URL}/servicedetails/org/${orgId}/service/${serviceId}`; - return (
Date: Fri, 2 Dec 2022 15:37:03 +0530 Subject: [PATCH 3/9] change in restrict create model --- .../TrainingModels/CreateModel/ModelInfo/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js index f4d6dd92c..f7323d4ce 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js @@ -59,7 +59,7 @@ const ModelInfo = ({ publicAccess: enableAccessModel, address: !enableAccessModel ? ethAddress : [], }; - if(createModelRestrict < 10) + if(createModelRestrict < 20) { createModelRestrictChange(); return await serviceClient.createModel(address, params); From 83bae97259170908d4e993dd420da9e25f68ac83 Mon Sep 17 00:00:00 2001 From: sreeshnap Date: Fri, 2 Dec 2022 15:48:09 +0530 Subject: [PATCH 4/9] removed the console --- .../TrainingModels/CreateModel/ModelInfo/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js index f7323d4ce..cf5e74b98 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js @@ -64,10 +64,6 @@ const ModelInfo = ({ createModelRestrictChange(); return await serviceClient.createModel(address, params); } - else - { - console.log("20 is over"); - } }; const onUpdate = () => { const updateModelParams = { From c6b297708a934e8e05dd10c191cea155a1837c3c Mon Sep 17 00:00:00 2001 From: sreeshnap Date: Fri, 9 Dec 2022 10:38:48 +0530 Subject: [PATCH 5/9] changes for restrict model --- .../ServiceDetails/ExistingModel/index.js | 4 ---- .../TrainingModels/CreateModel/ModelInfo/index.js | 12 +++++++----- .../TrainingModels/CreateModel/index.js | 4 +--- .../ServiceDetails/TrainingModels/index.js | 12 +++--------- src/components/ServiceDetails/index.js | 14 +------------- 5 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/components/ServiceDetails/ExistingModel/index.js b/src/components/ServiceDetails/ExistingModel/index.js index 63c6c2d67..4981d8823 100644 --- a/src/components/ServiceDetails/ExistingModel/index.js +++ b/src/components/ServiceDetails/ExistingModel/index.js @@ -28,9 +28,6 @@ const ExistingModel = ({ haveANewModel, wallet, editModel, - createModelRestrict, - createModelRestrictChange, - setCreateModel }) => { const [metamaskConnected, setMetamaskConnected] = useState(false); const [existingModels, setExistingModels] = useState([]); @@ -54,7 +51,6 @@ const ExistingModel = ({ }; const response = await serviceClient.getExistingModel(params); console.log("=====existingModel==", response.flat()); - setCreateModel (response.flat().length) setExistingModels(response.flat()); stopLoader(); }; diff --git a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js index cf5e74b98..d50acfdd7 100644 --- a/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js +++ b/src/components/ServiceDetails/TrainingModels/CreateModel/ModelInfo/index.js @@ -33,8 +33,6 @@ const ModelInfo = ({ cancelEditModel, updateModel, deleteModel, - createModelRestrict, - createModelRestrictChange }) => { const [enableAccessModel, setEnableAccessModel] = useState( modelDetailsOnEdit && modelDetailsOnEdit.publicAccess === true ? true : false @@ -59,9 +57,14 @@ const ModelInfo = ({ publicAccess: enableAccessModel, address: !enableAccessModel ? ethAddress : [], }; - if(createModelRestrict < 20) + const param = { + grpcMethod: training.training_methods[0], + grpcService: serviceName, + address, + }; + const response = await serviceClient.getExistingModel(param); + if(response.length < 20) { - createModelRestrictChange(); return await serviceClient.createModel(address, params); } }; @@ -83,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 b394dfb8f..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,createModelRestrict,createModelRestrictChange } = props; + const { service, classes, training, modelDetailsOnEdit, cancelEditModel, updateModel, deleteModel } = props; const [activeSection, setActiveSection] = React.useState(1); const [modelData, setModelData] = useState({}); const [trainModelId, setTrainModelId] = useState(); @@ -31,8 +31,6 @@ const CreateModel = (props) => { cancelEditModel={cancelEditModel} updateModel={updateModel} deleteModel={deleteModel} - createModelRestrict={createModelRestrict} - createModelRestrictChange={createModelRestrictChange} /> ), }, diff --git a/src/components/ServiceDetails/TrainingModels/index.js b/src/components/ServiceDetails/TrainingModels/index.js index 7fcf738f1..2f53bc0fc 100644 --- a/src/components/ServiceDetails/TrainingModels/index.js +++ b/src/components/ServiceDetails/TrainingModels/index.js @@ -19,14 +19,12 @@ const TrainingModels = (props) => { cancelEditModel, updateModel, editModel, - deleteModel, - createModelRestrict, - createModelRestrictChange, - setCreateModel + deleteModel } = props const [showCreateModel, setShowCreateModel] = useState(false); const handleRequestModel = () => { setShowCreateModel(true); + }; const RenderExistingModel = useCallback(() => { @@ -37,9 +35,6 @@ const TrainingModels = (props) => { haveANewModel={training?.training_methods?.length || false} training={training} editModel={editModel} - createModelRestrict={createModelRestrict} - createModelRestrictChange={createModelRestrictChange} - setCreateModel ={ setCreateModel } /> ); } @@ -75,8 +70,7 @@ const TrainingModels = (props) => { {showCreateModel ? ( - + ) : ( <>
diff --git a/src/components/ServiceDetails/index.js b/src/components/ServiceDetails/index.js index 9697c3d5c..1436e49d5 100644 --- a/src/components/ServiceDetails/index.js +++ b/src/components/ServiceDetails/index.js @@ -40,18 +40,9 @@ class ServiceDetails extends Component { }, createModelCalled: "new", modelDetailsOnEdit: undefined, - createModelRestrict: 0 }; } - setCreateModel = (response)=>{ - this.setState({ ...this.state, createModelRestrict: response }) - } - - createModelRestrictChange = () =>{ - this.setState({ ...this.state, createModelRestrict: this.state.createModelRestrict+1 }) - } - initializeService = async () => { const { org_id, service_id } = this.props.service; const sdk = await initSdk(); @@ -193,7 +184,7 @@ class ServiceDetails extends Component { render() { const { classes, service, pricing, loading, error, history, groupInfo, match, training, isLoggedIn } = this.props; - const { offlineNotication,createModelRestrict } = this.state; + const { offlineNotication } = this.state; const { params: { orgId, serviceId }, } = match; @@ -248,9 +239,6 @@ class ServiceDetails extends Component { updateModel={this.onUpdateModel} editModel={this.editModel} deleteModel={this.deleteModel} - createModelRestrict={createModelRestrict} - createModelRestrictChange={this.createModelRestrictChange} - setCreateModel ={this.setCreateModel} /> ), }); From 9298a0c62b6ab3785362ddfa5500036b5acfaaa6 Mon Sep 17 00:00:00 2001 From: Marina Fedyantceva Date: Wed, 6 Mar 2024 13:28:55 +0300 Subject: [PATCH 6/9] added resolutions to package.json --- .gitignore | 2 ++ package.json | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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..ee8d0ac1f 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,11 @@ "validate.js": "^0.13.1", "web3": "1.0.0-beta.52" }, + "resolutions": { + "concat-stream": "github:singnet/concat-stream" + }, "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", From 67ef662b249237e3c4ae31f971158cd3fe692926 Mon Sep 17 00:00:00 2001 From: Marina Fedyantceva Date: Mon, 11 Mar 2024 13:31:39 +0300 Subject: [PATCH 7/9] fixed changing height of filter row after click --- .../AiMarketplace/MainSection/Filter/ToolBar/styles.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 }, From 63b8388a9578574aebc4466ad17bc97315b9fbf8 Mon Sep 17 00:00:00 2001 From: Marina Fedyantceva Date: Mon, 11 Mar 2024 13:35:29 +0300 Subject: [PATCH 8/9] removed resolutions from package.json couse give errors after install and start app --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index ee8d0ac1f..71dadf893 100644 --- a/package.json +++ b/package.json @@ -61,9 +61,6 @@ "validate.js": "^0.13.1", "web3": "1.0.0-beta.52" }, - "resolutions": { - "concat-stream": "github:singnet/concat-stream" - }, "scripts": { "start": "react-scripts --openssl-legacy-provider start", "build": "npm run sitemap && react-scripts --max_old_space_size=8192 build", From be05a158311681149249a5094d72687d5aadd005 Mon Sep 17 00:00:00 2001 From: Marina Fedyantceva Date: Mon, 11 Mar 2024 16:30:53 +0300 Subject: [PATCH 9/9] [SPT-221] fixed display of service contact information --- .../ServiceDetails/CreatorDetails/Contacts/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 }) => {