Related
I am following the tutorial: https://youtu.be/WZWCzsB1xUE
and the error state occurs at: 50:00
I have checked multiple times using "", yet problem remains unsolved.
Help would be appreciated as I am new to JS and ReactJS.
The contract is deployed on polygon testnet with Moralis server support
and using the Ethereum bolierplate
Can anybody point out if any silly mistake?
const [contractABI, setContractABI] = useState('[
{
"inputs": [
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "price",
"type": "uint256"
}
],
"name": "createMarketItem",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
}
],
"name": "createMarketSale",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"indexed": true,
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"indexed": true,
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "seller",
"type": "address"
},
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"indexed": false,
"internalType": "bool",
"name": "sold",
"type": "bool"
}
],
"name": "MarketItemCreated",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"indexed": false,
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "MarketItemSold",
"type": "event"
},
{
"inputs": [],
"name": "fetchMarketItems",
"outputs": [
{
"components": [
{
"internalType": "uint256",
"name": "itemId",
"type": "uint256"
},
{
"internalType": "address",
"name": "nftContract",
"type": "address"
},
{
"internalType": "uint256",
"name": "tokenId",
"type": "uint256"
},
{
"internalType": "address payable",
"name": "seller",
"type": "address"
},
{
"internalType": "address payable",
"name": "owner",
"type": "address"
},
{
"internalType": "uint256",
"name": "price",
"type": "uint256"
},
{
"internalType": "bool",
"name": "sold",
"type": "bool"
}
],
"internalType": "struct marketPlaceBoilerPlate.MarketItem[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]');
const [marketAddress, setMarketAddress] = useState();
Error:
"resource": "/c:/ethereum-nft-marketplace-boilerplate/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "eslint",
"severity": 8,
"message": "Parsing error: Unterminated string constant.\n\n 7 | const [walletAddress, setWalletAddress] = useState();\n 8 | const [chainId, setChainId] = useState(); \n> 9 | const [contractABI, setContractABI] = useState('[\n | ^\n 10 | {\n 11 | \"inputs\": [\n 12 | {",
"source": "eslint",
"startLineNumber": 9,
"startColumn": 50,
"endLineNumber": 9,
"endColumn": 50
},{
"resource": "/c:ethereum-nft-marketplace-boilerplate/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1002",
"severity": 8,
"message": "Unterminated string literal.",
"source": "ts",
"startLineNumber": 9,
"startColumn": 52,
"endLineNumber": 9,
"endColumn": 52
},{
"resource": "/c:src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "',' expected.",
"source": "ts",
"startLineNumber": 10,
"startColumn": 5,
"endLineNumber": 10,
"endColumn": 6
},{
"resource": "/c:/src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "',' expected.",
"source": "ts",
"startLineNumber": 187,
"startColumn": 3,
"endLineNumber": 187,
"endColumn": 4
},{
"resource": "/c:src/providers/MoralisDappProvider/MoralisDappProvider.js",
"owner": "typescript",
"code": "1002",
"severity": 8,
"message": "Unterminated string literal.",
"source": "ts",
"startLineNumber": 187,
"startColumn": 33,
"endLineNumber": 187,
"endColumn": 33
}]```
[error image here][2]
[1]: https://github.com/ethereum-boilerplate/ethereum-boilerplate
[2]: https://i.stack.imgur.com/EgnwO.png
when i use relation referencesMAny with array in loopback. i have got error when i remove referencesMAny relation it's working. i am using loopback 3
{ "error": {
"statusCode": 500,
"name": "Error",
"message": "5d53eaa49b826748f0b72ca5is not an ObjectID string",
}}
it's my json schema :
{
"name": "Products",
"plural": "Products",
"strict": true,
"idInjection": true,
"options": {
"validateUpsert": true
},
"mixins": {
"TimeStamp": true
},
"properties": {
"name": {
"type": "string",
"default": ""
},
"image": {
"type": [],
"required": true,
"default": []
},
"about": {
"type": "string",
"required": true,
"default": ""
},
"categoryId": {
"type": [],
"required": false,
"default": []
},
"userId": {
"type": "string",
"required": true,
"default": ""
},
"storeId": {
"type": "string",
"required": true,
"default": ""
},
"location": {
"type": "geopoint",
"required": false
},
"price": {
"type": "object",
"required": true,
"default": {
"discount": "",
"actualRate": "",
"finalRate": ""
}
},
"createdAt": {
"type": "date"
},
"updatedAt": {
"type": "date"
}
},
"validations": [],
"relations": {
"userDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
},
"categories": {
"type": "referencesMany",
"model": "Categories",
"foreignKey": "categoryId"
},
"storeDeatils": {
"type": "belongsTo",
"model": "Users",
"foreignKey": "userId"
}
},
"acls": [
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{
"accessType": "WRITE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"accessType": "*",
"principalType": "ROLE",
"principalId": "$unauthenticated",
"permission": "DENY"
}
],
"methods": {}
}
my json data object like this :
{
"name": "deara",
"image": ["dsadsa"],
"about": "dear ser",
"categoryId": [
"5d53eaa49b826748f0b72ca5"
],
"userId": "dsdsadsa",
"storeId": "dsdsadsadsad",
"location": {
"lat": 0,
"lng": 0
},
"price": {
"discount": "121",
"actualRate": "321",
"finalRate": "231"
},
"createdAt": "2019-08-09T12:02:54.514Z",
"updatedAt": "2019-08-09T12:02:54.514Z"
}
i don't understand where am i wrong.
thanks in advance
Loopback expects that dsadsad232323 will be an identifier of an object of another model, so categoryId must be array of id.
I am implementing kendo treeview of checkboxes in angular. I get no error, but tree is not rendering. My code is here:
addCtrl.js
$scope.updateTree = function () {
websiteService.getWebsiteFeaturesTree(webName, function (data) {
$scope.treeOptions = {
checkboxes: {
checkChildren: true
}
};
$scope.treeDataSource = data;
});
}
add.html
<div kendo-tree-view k-options="treeOptions" k-data-source="treeDataSource"></div>
app.js
var app = angular.module('app', ['ui.bootstrap', 'ngRoute', 'kendo.directives']);
I get datasource from webservice. here is json
// 20160930204148
// http://localhost/api/Website/GetWebsiteFeaturesTree?webName=MetisEmptyTemplate
[
{
"Name": "Section",
"text": "Admin",
"checked": false,
"items": [
{
"Name": "Tab",
"text": "Matrix Analysis",
"checked": true,
"items": [
]
},
{
"Name": "Tab",
"text": "Risk Categories and Questions",
"checked": true,
"items": [
]
},
{
"Name": "Tab",
"text": "Risk Colors",
"checked": true,
"items": [
]
},
{
"Name": "Tab",
"text": "SWOT Types",
"checked": false,
"items": [
]
}
]
},
{
"Name": "Section",
"text": "Strategy",
"checked": false,
"items": [
{
"Name": "Tab",
"text": "SWOT Analysis",
"checked": false,
"items": [
{
"Name": "Grid",
"text": "SWOT Grid",
"checked": true,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": false,
"items": [
{
"Name": "Output",
"text": "SWOT Box",
"checked": false,
"items": [
]
}
]
}
]
}
]
},
{
"Name": "Section",
"text": "Portfolio",
"checked": true,
"items": [
{
"Name": "Tab",
"text": "Matrix",
"checked": true,
"items": [
{
"Name": "Grid",
"text": "Matrix Grid",
"checked": true,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": true,
"items": [
{
"Name": "Output",
"text": "Matrix Output",
"checked": true,
"items": [
]
}
]
}
]
},
{
"Name": "Tab",
"text": "Strategy",
"checked": true,
"items": [
{
"Name": "Grid",
"text": "Strategy Grid",
"checked": true,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": true,
"items": [
{
"Name": "Output",
"text": "Investment Level by Objective",
"checked": true,
"items": [
]
}
]
}
]
},
{
"Name": "Tab",
"text": "Risk",
"checked": true,
"items": [
{
"Name": "Grid",
"text": "Risk Grid",
"checked": true,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": true,
"items": [
{
"Name": "Output",
"text": "Portfolio Risk",
"checked": true,
"items": [
]
},
{
"Name": "Output",
"text": "Portfolio Risk Stacked Bar",
"checked": true,
"items": [
]
}
]
}
]
}
]
},
{
"Name": "Section",
"text": "Project",
"checked": false,
"items": [
{
"Name": "Tab",
"text": "Matrix",
"checked": true,
"items": [
{
"Name": "Grid",
"text": "Matrix Grid",
"checked": true,
"items": [
]
}
]
},
{
"Name": "Tab",
"text": "Strategy",
"checked": true,
"items": [
{
"Name": "Grid",
"text": "Strategy Grid",
"checked": true,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": true,
"items": [
{
"Name": "Output",
"text": "Project Tactic Linkage",
"checked": true,
"items": [
]
},
{
"Name": "Output",
"text": "OGTM",
"checked": true,
"items": [
]
}
]
}
]
},
{
"Name": "Tab",
"text": "Risk",
"checked": false,
"items": [
{
"Name": "Grid",
"text": "Risk Grid",
"checked": false,
"items": [
]
},
{
"Name": "Outputs",
"text": "Outputs",
"checked": true,
"items": [
{
"Name": "Output",
"text": "Risk Charts",
"checked": true,
"items": [
]
}
]
}
]
}
]
}
]
Although my data source is correct. What thing is missing in it? I am not getting any error. My tree is not rendering in html.
Try placing your data in a new kendo.data.HierarchicalDataSource
I am trying to find the tree level for one particular key in recursive object in
JavaScript. I need value of each title key in the below object and also find level of that current object like as tree, but the object recurses to infinity.
How can I get the tree level for a specified key?
Expected Output
Here is my object
var object = {
"code": 200,
"data": {
"id": "614b4da4-2910-42c5-8afe-c12521cb0b52",
"title": "Android Quick Start Guide",
"subTitles": [
{
"id": "4dc22d3a-6e10-4938-b538-f86e56afe053",
"title": "Welcome to Android",
"subTitles": [
{
"id": "4dc22d3a-6e10-4938-b538-f86e56afe053",
"title": "Welcome to Android",
"subTitles": []
},
{
"id": "4dc22d3a-6e10-4938-b538-f86e56afe053",
"title": "Welcome to Android",
"subTitles": []
}
]
}
]
},
"message": "created"
};
A recursion would help with Array#reduce() and a proper start value, like a new tag element ul
function getValues(ul, a) {
var li = document.createElement('li');
li.innerHTML = a.description;
Array.isArray(a.subTitles) && li.appendChild(a.subTitles.reduce(getValues, document.createElement('ul')));
ul.appendChild(li);
return ul;
}
var object = { "code": 200, "data": { "path": "614b4da4-2910-42c5-8afe-c12521cb0b52", "number": 100, "description": "Android Quick Start Guide", "createdTime": 1460095475590, "id": "614b4da4-2910-42c5-8afe-c12521cb0b52", "title": "Android Quick Start Guide", "isRootTitle": true, "subTitles": [{ "path": "614b4da4-2910-42c5-8afe-c12521cb0b52", "number": 100, "description": "description about the manual 1", "createdTime": 1460095516423, "id": "4dc22d3a-6e10-4938-b538-f86e56afe053", "title": "Welcome to Android", "isRootTitle": false, "subTitles": [{ "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 100, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "About Android Marshmallow", "isRootTitle": false, "subTitles": [] }, { "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 200, "description": "description about the manual 1.2", "createdTime": 1460095672614, "id": "63743f5f-6451-4792-96c6-936b7e8fe820", "title": "What's new in 6.0", "isRootTitle": false, "subTitles": [{ "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 100, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Get Started", "isRootTitle": false, "subTitles": [] }] }] }, { "path": "614b4da4-2910-42c5-8afe-c12521cb0b52", "number": 200, "description": "description about the manual 2", "createdTime": 1460095526821, "id": "42c669ca-d1cb-494c-8c7d-cbef767de919", "title": "Essentials", "isRootTitle": false, "subTitles": [{ "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 100, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Google Now", "isRootTitle": false, "subTitles": [] }, { "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 200, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Tell Google what to do", "isRootTitle": false, "subTitles": [] }] }, { "path": "614b4da4-2910-42c5-8afe-c12521cb0b52", "number": 300, "description": "description about the manual 3", "createdTime": 1460095536268, "id": "1018401c-211a-4cdc-9370-d59d75325da5", "title": "Gesture Typing", "isRootTitle": false, "subTitles": [{ "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 100, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Enter & edit text", "isRootTitle": false, "subTitles": [] }, { "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 200, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Type by speaking", "isRootTitle": false, "subTitles": [] }] }, { "path": "614b4da4-2910-42c5-8afe-c12521cb0b52", "number": 400, "description": "description about the manual 4", "createdTime": 1460095549864, "id": "e58de49c-c261-46cc-aef4-4d75c3fdcc21", "title": "Try some apps", "isRootTitle": false, "subTitles": [{ "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 100, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Enter & edit text", "isRootTitle": false, "subTitles": [] }, { "path": "4dc22d3a-6e10-4938-b538-f86e56afe053", "number": 200, "description": "About Android Marshmallow", "createdTime": 1460095604835, "id": "c431983e-e4e2-4369-8322-4358c2e6db6e", "title": "Type by speaking", "isRootTitle": false, "subTitles": [] }] }] }, "message": "created" };
document.body.appendChild([object.data].reduce(getValues, document.createElement('ul')));
can you please tell me how to validate form which is prepared dynamically using dfom plugin?
I used jquery validation but it don't work on chrome.
can you please tell me why dform with jquery validation not working in chrome ?.It is working fine in firefox but not with in chrome why ?? Here is http://jsfiddle.net/8bweG/13/?
$("#sform").dform(
{
"elements": [
{
"html": [
{
"html": [
{
"type": "number",
"id": "totalRetryCount",
"name": "totalRetryCount",
"required": false,
"value": 0,
"tabindex": 1,
"validate": {
"messages": {
"number": "Naveen Kanjush hain"
}
}
}
],
"type": "fieldset",
"caption": "Total Retry Count"
},
{
"html": [
{
"type": "number",
"id": "totalRepeatCount",
"name": "totalRepeatCount",
"required": false,
"value": 0,
"tabindex": 2,
"validate": {
"messages": {
"number": "Naveen Kanjush hain"
}
}
}
],
"type": "fieldset",
"caption": "Total Repeat Count"
},
{
"html": [
{
"type": "select",
"options": {
"true": "true",
"false": "false"
},
"id": "summaryReportRequired",
"name": "summaryReportRequired",
"required": false,
"value": "true",
"tabindex": 3,
}
],
"type": "fieldset",
"caption": "Summary Report Required"
},
{
"html": [
{
"type": "select",
"options": {
"ALWAYS": "ALWAYS",
"ON_SUCCESS": "ON_SUCCESS"
},
"id": "postConditionExecution",
"name": "postConditionExecution",
"required": false,
"value": "ON_SUCCESS",
"tabindex": 4,
}
],
"type": "fieldset",
"caption": "Post Condition Execution"
}
],
"type": "div",
"class": "inputDiv",
"caption": "<h3>Configuration Parameters</h3>"
}
],
"id": "testSuiteConfigurationform",
"name": "testSuiteConfigurationform",
"method": "post"
}
);
Problem is that
First field of type ="number".User only type number in that .If user type string or character and move to another field it gives error.if you check on firefox this fiddle it is giving validation error .But on chrome and safari same functionality not work.
please follow these steps
on first field write "abc" then click below or next field.it gives error front of first field.it is display on firefox but not on chrome
It is working but you are missing the Submit button.
This is the correct version: http://jsfiddle.net/8bweG/22/
$("#sform").dform({
"action" : "http://dgg.gg",
"method" : "get",
"elements": [
{
"html": [
{
"html": [
{
"type": "number",
"id": "totalRetryCount",
"name": "totalRetryCount",
"required": false,
"value": 0,
"tabindex": 1,
"validate": {
"messages": {
"number": "Naveen Kanjush hain"
}
}
}
],
"type": "fieldset",
"caption": "Total Retry Count"
},
{
"html": [
{
"type": "number",
"id": "totalRepeatCount",
"name": "totalRepeatCount",
"required": false,
"value": 0,
"tabindex": 2,
"validate": {
"messages": {
"number": "Naveen Kanjush hain"
}
}
}
],
"type": "fieldset",
"caption": "Total Repeat Count"
},
{
"html": [
{
"type": "select",
"options": {
"true": "true",
"false": "false"
},
"id": "summaryReportRequired",
"name": "summaryReportRequired",
"required": false,
"value": "true",
"tabindex": 3,
}
],
"type": "fieldset",
"caption": "Summary Report Required"
},
{
"html": [
{
"type": "select",
"options": {
"ALWAYS": "ALWAYS",
"ON_SUCCESS": "ON_SUCCESS"
},
"id": "postConditionExecution",
"name": "postConditionExecution",
"required": false,
"value": "ON_SUCCESS",
"tabindex": 4,
}
],
"type": "fieldset",
"caption": "Post Condition Execution"
},
{
"html": [
{
"type" : "submit",
"value" : "Login"
}
],
"type": "fieldset",
"caption": "Go away"
}
],
"type": "div",
"class": "inputDiv",
"caption": "<h3>Configuration Parameters</h3>"
}
],
"id": "testSuiteConfigurationform",
"name": "testSuiteConfigurationform",
"method": "post"
}
);