Getting Timestamp not found in query response . with my dfx 0.9.3

What type of topic is this?
Discussion | Support | Bug Report

Motoko code:

import Debug "mo:base/Debug";
import Time "mo:base/Time";
import Float "mo:base/Float";

actor DBank {
  stable var currentValue : Float = 300;
  currentValue := 300;
  Debug.print(debug_show (currentValue));

  stable var startTime = Time.now();
  startTime := Time.now();
  Debug.print(debug_show (startTime));

  let id = 2348923840928349;
  // Debug.print(debug_show(id));

  public func topUp(amount : Float) {
    currentValue += amount;
    Debug.print(debug_show (currentValue));
  };

  public func withdraw(amount : Float) {
    let tempValue : Float = currentValue - amount;
    if (tempValue >= 0) {
      currentValue -= amount;
      Debug.print(debug_show (currentValue));
    } else {
      Debug.print("Amount too large, currentValue less than zero.");
    };
  };

  public query func checkBalance() : async Float {
    return currentValue;
  };

  // topUp();

  public func compound() {
    let currentTime = Time.now();
    let timeElapsedNS = currentTime - startTime;
    let timeElapsedS = timeElapsedNS / 1000000000;
    currentValue := currentValue * (1.01 ** Float.fromInt(timeElapsedS));
    startTime := currentTime;
  };

};

javascript code:

import {dbank} from "../../declarations/dbank";

window.addEventListener("load", async function() {
  const currentAmount= await dbank.checkBalance();
  console.log(response); // Log the response

  document.getElementById("value").innerText=Math.rount = (currentAmount*100)/100;
});

document.querySelector("form").addEventListener("submit",async function(event){
  console.log("Submit button clicked");

  const inputAmount = parseFloat(document.getElementById("input-amount").value);
  const outputAmount = parseFloat(document.getElementById("withdrawl-amount").value);

  await dbank.topUp(inputAmount);
  
  const currentAmount= await dbank.checkBalance();
   document.getElementById("value").innerText=Math.rount = (currentAmount*100)/100;
});

1 Like

Canister is working fine and why you use

Debug.print(debug_show (startTime));

to see the time. Also tried commenting it out still getting
error

Timestamp not found in query response. This suggests a malformed or malicious response.
    at HttpAgent._HttpAgent_requestAndRetryQuery (http://localhost:8080/index.js:1052:15)
    at async makeQuery (http://localhost:8080/index.js:796:20)
    at async Promise.all (index 0)
    at async HttpAgent.query (http://localhost:8080/index.js:811:39)
    at async caller (http://localhost:8080/index.js:207:28)
    at async http://localhost:8080/index.js:21858:24
1 Like

where can i find this

did your error got fixed ??
if yes how did you do it.

https://agent-js.icp.xyz/agent/interfaces/HttpAgentOptions.html#verifyQuerySignatures

You would pass it in the HttpAgentOptions passed to the constructor.

const agent = new HttpAgent({
   // any other options like host or identity
   verifyQuerySignatures: isLocal ? false : true
});

Can you tell me exactly were should I make this changes ? I am new to using dfx version 0.9.3 . like can you tell me the exact filepath and exactly at while should I make this changes?

If you are a beginner developer, I highly recommend you upgrade instead of worrying about backwards compatibility.

If you are using dfxvm (which I recommend), run

dfxvm update

or with dfx 0.9.3, you can run

dfx upgrade