From a12fc4b49137de778122808756e5f4af49a2e66a Mon Sep 17 00:00:00 2001 From: Ivan S Glazunov Date: Thu, 4 Apr 2024 16:42:02 +0000 Subject: [PATCH] fix --- imports/cyber.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/imports/cyber.tsx b/imports/cyber.tsx index ee26d87a..30264d24 100644 --- a/imports/cyber.tsx +++ b/imports/cyber.tsx @@ -17,7 +17,7 @@ import {debug} from './debug.js' import { Traveler as NativeTraveler } from './traveler.js'; import _ from 'lodash'; -import { createHelia } from 'helia'; +import { Helia, createHelia } from 'helia'; import { strings } from '@helia/strings'; import { CID } from 'multiformats/cid'; import { fileTypeFromBuffer } from 'file-type'; @@ -101,8 +101,8 @@ export const schema = (type, from = '', to = '', schemas: Schemas = {}) => { } }; -export const getValue = async (cid) => { - const helia = await createHelia() +export const getValue = async (cid, deep) => { + const helia = deep.helia; const s = strings(helia); const parsed = CID.parse(cid); // @ts-ignore @@ -149,8 +149,10 @@ export async function generateCyberDeepClient(options: { namespace?: string; }): Promise>> { const cyberClient = await CyberClient.connect(options.config.CYBER_NODE_URL_API); + const helia = await createHelia() return new CyberDeepClient({ cyberClient, + helia, config: options.config, minilinks: options?.minilinks, namespace: options?.namespace, @@ -163,6 +165,7 @@ export interface CyberDeepClientInstance = Link> extends export interface CyberDeepClientOptions> extends DeepClientOptions { cyberClient: CyberClient; config: CONFIG; + helia: Helia; } const deepToCyberHash = { @@ -269,7 +272,7 @@ const rewriteGettedPseudoLinksToLinks = async (links, exp, deep) => { link.type_id = 'particle'; if (!deep._loadedValues[link.id]) { console.log('_generateResult', 'rewrite', 'getValue', link.id); - deep._loadedValues[link.id] = await getValue(link.id); + deep._loadedValues[link.id] = await getValue(link.id, deep); console.log('_generateResult', 'rewrite', 'gettedValue', link.id, deep._loadedValues[link.id]); } link.value = { @@ -287,6 +290,7 @@ export class CyberDeepClient = Link> extends Deep static resolveDependency?: (path: string) => Promise cyberClient: CyberClient; + helia: Helia; config: CONFIG; accountPrefix: string; @@ -313,6 +317,7 @@ export class CyberDeepClient = Link> extends Deep }); this.cyberClient = options.cyberClient; this.config = options.config; + this.helia = options.helia; this.accountPrefix = this.config.BECH32_PREFIX_ACC_ADDR_CYBER;