Ethereumjs-vm, run-transaction-complete example not printing storage - javascript

Running the example mentioned in the title, there is no output after the "---Storage---" line. According to my understanding, there should be a null_radix stored at the created address. (running gives no exceptions) please correct me if I’m wrong!

[update]
At the following part of the example at the runTx function I've noticed that we refresh the createdAddress variable at every transaction even though it doesn't register a new contract. Therefore it leaves us with the loss of our contract's address and the readStorage function won't print any output.
I've fixed it by checking the createdAddress property for null before saving the value.
if (returns.createdAddress) {
createdAddress = results.createdAddress
console.log('address created: ' + createdAddress.toString('hex'))
}

Related

Why am I getting this firebase/firestore error?

Here is my query
const query = messagesRef.where('members', 'in', [`${currentUserId}`]).orderBy('createdAt')
I have created an index as well.
This is the error I get
Error: {"code":"failed-precondition","name":"FirebaseError"}
Which I assume is usually an index thing
Yes, the failed-precondition can be due to a missing index. It can also be manually thrown by a user though with any user-defined description, typically from within a Firebase Function. The category is the only thing that must confine to the convention:
https://cloud.google.com/datastore/docs/concepts/errors
Here's one example of such error common in App-Checked Firebase Functions:
if (context.app == undefined) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called from an App Check verified app.')
}
You may want to check your Function Logs to get the actual error description. If the issue happens locally, then your firestore-debug.log file should contain some useful information. Just to be certain it's actually an index issue or not.
If the issue is happening only on production, you may want to verify the contents of your firestore.indexes.json and compare to what's inside the Firebase Console under https://console.firebase.google.com/u/0/project/<PROJECT-NAME>/firestore/indexes.
If it's actually an index issue, there will be a URL provided inside the logs that you can click which will generate the index for you inside Firestore:
https://firebase.google.com/docs/firestore/query-data/indexing?authuser=0&hl=en#create_a_missing_index_through_an_error_message
I hope this helps track down the issue! I used failed-precondition for several different error types, some unrelated to Firestore or indexes.

Expected null to deeply equal [Array (1)]

just a brief question. I've been struggling to figure out what this error in javascript actually means: "Timed out retrying: expected null to deeply equal [Array (1)]
I'm basically working on a LocalStorage Shopping Cart and my code is actually based on this video: https://www.youtube.com/watch?v=uR3r3GJvQDY&t=417s
It's pretty much very identical. The code perfectly works on my system without any errors but as soon as I upload it to my university's server on which the code undergoes certain tests I receive the above-named error. It also doesn't really indicate in which line of the code the error is happening. My instructor only told me this usually happens when the cart should exist in the localStorage, however, it doesn't which means the localStorage returns NULL to the system.
For reference to the code please check: https://gist.github.com/prof3ssorSt3v3/3e15d06a8128d6ca7deaa831a7a1e52b
So, we basically create a cart called contents and we never remove empty the LocalStorage at any point in the code. How can the LocalStorage return null at some point then and cause the error?
For the init function I have this:
init(){
//check localStorage and initialize the contents of CART.contents
let _contents = localStorage.getItem(cart.KEY);
if(_contents){
cart.contents = JSON.parse(_contents);
}
else{
cart.contents = [];
cart.sync();
}
},
Thank you for your help in advance!

AfterSave on PFUser checking if on creation or update

I am having difficulty in distinguishing between if a PFUser is being updated or if it is being saved for the first time. I implemented the solution found on parse.com here. However, it is not working as explained in the answer found at the link. I always get a false regardless of if it is on the creation or an update. Here is the code that I have implemented.
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
//this error log prints false regardless of if the user is signing up.
// or having a key updated.
console.error(request.object.existed());
if (!request.object.existed()) {
//This is on sign up, the user has not existed prior.
//This doesn't work. This block of code is always run.
}
else {
//This is supposedly when the user is having a key updated.
//Unfortunately, this code is never run regardless.
}
)}
This code does not behave as I expect it to because the request.object.existed() always returns false. I think this may have to do that this is saving a PFUser and not some generic PFObject. Is there something I am missing using request.object.existed() on a PFUser afterSave? Thanks.
This seems to be an unresolved Parse cloud bug
Possible workaround is to check the difference between create and update times to see if your object is being updated or is being created.

Cloud code (javascript) failed wtih: {"code":1,"message":"internal error"}

I'm trying to run the following code:
if(req.query.currentPosition) {
console.log("[DEBUG] My current position: " + req.query.currentPosition);
var maxRadius = 10;
var coordinates = req.query.currentPosition.split(",");
var latitude = parseFloat(coordinates[0]);
var longitude = parseFloat(coordinates[1]);
var point = new Parse.GeoPoint({latitude: latitude, longitude: longitude});
query.withinKilometers("coordinates", point, maxRadius);
}
return query.find({});
where I read some coordinates from the requests query parameters and I pass those onto a query as a geolocation constraint. Whenever the code runs I get the error
{"code":1,"message":"internal error"}
and nothing more specific. If I remove the above code block, I don't have any error at all.
I've done some research, and I have found that some other developers have also stumbled upon this message, though in a different context.
https://www.parse.com/questions/cloud-code-failed-with-code-1message
https://www.parse.com/questions/facebook-login-code-1-internal-error
Yet no satisfying conclusion was reached or provided.
What have I tried so far:
Multiple redeploys (my favourite)
adding and removing the "coordinates" columns
One of the suggestions from the links I found was that it could a parse internal issue, so waited a day or so to see if anything could be magically solved
Added a ridiculously amount of logs to see if I could print anything that it could give me a better description of what was happening
Also checked if anything could be wrong with the data
Compared with other running applications that have the same code block and are working to see what could be wrong.
None of the above proved to be helpful.
SDK Version
Parse JavaScript SDK v1.3.3
Any enlightenment is appreciated.
Cheers.
I just found the problem. I was setting the wrong key when adding the "withinKilometers" constraint.
Cheers

CPRangeException thrown when objects added to an CPArray

In my cappuccino app, I am reading from an RoR backend via JSON and putting the results onto a list. When the app first loads everything is fine, but when I edit an item (and write the edit to the database) there is an error generated when the items list is refreshed.
The error is CPRangeException: -[_CPJavaScriptArray objectAtIndex:]: index (-1) beyond bounds (3).
I get this error even if I edit an item without making any actual changes. The JSON string received by the app remains exactly the same in this case, there are no items added or removed and therefore the array should not be written to out of bounds.
Here is my code:
- (void)connection:(CPRURLConnection)connection didReceiveData:(CPString)data
{
if(connection === listConnection)
{
var results = JSON.parse(data) ;
var posts = [Post initFromJSONObjects:results];
[postListView setContent:posts] ;
// My error occurs at the above line
[postListView setSelectionIndexes:[[CPIndexSet alloc] initWithIndex:0]] ;
}
}
I am not sure if it's an error with my code or if it's some kind of inconsistency with the cappuccino framework. Does anybody know what I can do to fix this?
The rest of the code can be found here
You should probably simply log what's in posts before setting it. CPLog.info('posts: ' + posts); should work, or console.log(posts). Next you can set a 'break on uncaught exception' debug point in Chrome or Safari to stop at the actual error you are seeing. Make sure you run your app using index-debug.html so that you get full method names. Then it should be an easy matter to look at the calling stack to see where things are going wrong. There's a lot of information on debugging a Cappuccino app here.

Categories