We’re encountering a recurring error when initializing the Fireblocks SDK on our client. Our client is based on Next.js, and the initialization code is as follows.
The init function is triggered when the “Init Fireblocks” button is clicked. Upon inspecting the messages within the messagesHandler’s handleOutgoingMessage, the console logs display messages for the get_service_certificates, get_cloud_signer_certificate, and report_event methods. However, the following error appears right after these logs:
Error: B: must load certificates before validating
Your guidance on this issue would be greatly appreciated. Thank you!
const initFireblocks = async () => {
if (!deviceId) {
throw Error("deviceId is not set");
}
try {
const secureStorageProvider = new InMemorySecureStorageProvider();
const messagesHandler: IMessagesHandler = {
handleOutgoingMessage: async (message: string) => {
console.log("What Message? :", message);
if (!deviceId) {
throw new Error("deviceId is not set");
}
return custodyPostAction(
api/fireblocks/${deviceId},
message
);
}
};
const eventsHandler: IEventsHandler = {
handleEvent: (event: TEvent) => {
console.log("eventsHandler: ", event);
if (
event.type === "key_descriptor_changed"
event.type === "key_takeover_changed"
event.type === "transaction_signature_changed" ||
event.type === "join_wallet_descriptor"
) {
console.log("What event?", event);
}
}
};
const ncwInstance = getFireblocksNCWInstance(deviceId);
if (ncwInstance) {
console.log("NCW already exist!");
setFireblocksNCW(ncwInstance);
} else {
setFireblocksNCW(
await FireblocksNCWFactory({
env: "sandbox",
deviceId,
messagesHandler,
eventsHandler,
secureStorageProvider
})
);
}
} catch (e) {
console.error(e);
}
};