Skip to content

Commit

Permalink
Merge pull request singnet#898 from singnet/development
Browse files Browse the repository at this point in the history
merge development
  • Loading branch information
Eljaja authored Mar 14, 2024
2 parents 49131fa + e6ca278 commit 2021a4f
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock
package-lock.json

# Runtime data
pids
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ const Contacts = ({ contacts, show, handleClose, classes }) => {
<ListItem alignItems="flex-start" divider>
<ListItemText
primary="Support email"
secondary={supportContact.email_id}
secondary={supportContact.email}
secondaryTypographyProps={{
component: "a",
href: `mailTo:${supportContact.email_id}`,
href: `mailTo:${supportContact.email}`,
target: "_blank",
rel: "noopener noreferrer",
className: classes.anchor,
Expand Down
1 change: 0 additions & 1 deletion src/components/ServiceDetails/ExistingModel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -70,14 +78,14 @@ const ModelInfo = ({
updateModel(updateModelParams);
};


const onNext = async () => {
try {
startMMconnectLoader();
const sdk = await initSdk();
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -19,7 +19,6 @@ const CreateModel = (props) => {
const onBackClick = () => {
setActiveSection(activeSection - 1);
};

const createModelTabs = [
{
key: "modelInfo",
Expand Down
25 changes: 13 additions & 12 deletions src/components/ServiceDetails/TrainingModels/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/ServiceDetails/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ServiceDetails extends Component {
modelDetailsOnEdit: undefined,
};
}

initializeService = async () => {
const { org_id, service_id } = this.props.service;
const sdk = await initSdk();
Expand Down Expand Up @@ -245,7 +245,6 @@ class ServiceDetails extends Component {
}

const seoURL = `${process.env.REACT_APP_BASE_URL}/servicedetails/org/${orgId}/service/${serviceId}`;

return (
<div>
<SeoMetadata
Expand Down
19 changes: 18 additions & 1 deletion src/components/common/NetworkChangeOverlay/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
}
Expand Down
9 changes: 9 additions & 0 deletions src/utility/snetSdk.js
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 2021a4f

Please sign in to comment.