Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Apr 4, 2024
1 parent 58309f8 commit a12fc4b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions imports/cyber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -149,8 +149,10 @@ export async function generateCyberDeepClient(options: {
namespace?: string;
}): Promise<CyberDeepClient<Link<string>>> {
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,
Expand All @@ -163,6 +165,7 @@ export interface CyberDeepClientInstance<L extends Link<Id> = Link<Id>> extends
export interface CyberDeepClientOptions<L extends Link<Id>> extends DeepClientOptions<L> {
cyberClient: CyberClient;
config: CONFIG;
helia: Helia;
}

const deepToCyberHash = {
Expand Down Expand Up @@ -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 = {
Expand All @@ -287,6 +290,7 @@ export class CyberDeepClient<L extends Link<string> = Link<string>> extends Deep
static resolveDependency?: (path: string) => Promise<any>

cyberClient: CyberClient;
helia: Helia;
config: CONFIG;

accountPrefix: string;
Expand All @@ -313,6 +317,7 @@ export class CyberDeepClient<L extends Link<string> = Link<string>> extends Deep
});
this.cyberClient = options.cyberClient;
this.config = options.config;
this.helia = options.helia;

this.accountPrefix = this.config.BECH32_PREFIX_ACC_ADDR_CYBER;

Expand Down

0 comments on commit a12fc4b

Please sign in to comment.