Skip to content
Merged
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

[*.rs]
indent_size = 4
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"tslib": "^2.7.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"typestub-ipfs-only-hash": "^4.0.0",
"uint8arrays": "^4.0.3"
},
"devDependencies": {
Expand Down
51 changes: 15 additions & 36 deletions packages/lit-node-client-nodejs/src/lib/lit-node-client-nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { computeAddress } from '@ethersproject/transactions';
import { BigNumber, ethers } from 'ethers';
import { sha256 } from 'ethers/lib/utils';
import { SiweMessage } from 'siwe';
import * as Hash from 'typestub-ipfs-only-hash';

import {
LitAccessControlConditionResource,
Expand Down Expand Up @@ -665,40 +666,8 @@ export class LitNodeClientNodeJs
};

// ========== Promise Handlers ==========
getIpfsId = async ({
dataToHash,
sessionSigs,
}: {
dataToHash: string;
sessionSigs: SessionSigsMap;
debug?: boolean;
}) => {
const res = await this.executeJs({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were we using a LA for this? Seems like a tremendous overkill

ipfsId: LIT_ACTION_IPFS_HASH,
sessionSigs,
jsParams: {
dataToHash,
},
}).catch((e) => {
logError('Error getting IPFS ID', e);
throw e;
});

let data;

if (typeof res.response === 'string') {
try {
data = JSON.parse(res.response).res;
} catch (e) {
data = res.response;
}
}

if (!data.success) {
logError('Error getting IPFS ID', data.data);
}

return data.data;
getIpfsId = async ({ str }: { str: string }): Promise<`Qm${string}`> => {
return (await Hash.of(Buffer.from(str))) as `Qm${string}`;
};

/**
Expand Down Expand Up @@ -730,10 +699,20 @@ export class LitNodeClientNodeJs
);
}

if (!params.code) {
throw new InvalidParamType(
{
info: {
params,
},
},
'code is required'
);
}

// determine which node to run on
const ipfsId = await this.getIpfsId({
dataToHash: params.code!,
sessionSigs: params.sessionSigs,
str: params.code,
});

// select targetNodeRange number of random index of the bootstrapUrls.length
Expand Down
Loading
Loading