Skip to content
Merged
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"tslib": "^2.3.0",
"tweetnacl": "^1.0.3",
"tweetnacl-util": "^0.15.1",
"typestub-ipfs-only-hash": "^4.0.0",
"uint8arrays": "^4.0.3"
},
"devDependencies": {
Expand Down
48 changes: 12 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 { joinSignature, sha256 } from 'ethers/lib/utils';
import { SiweMessage } from 'siwe';
import Hash from 'typestub-ipfs-only-hash';

import {
ILitResource,
Expand Down Expand Up @@ -654,40 +655,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 @@ -716,10 +685,17 @@ export class LitNodeClientNodeJs
});
}

if (!params.code) {
return throwError({
message: 'code is required',
errorKind: LIT_ERROR.INVALID_PARAM_TYPE.kind,
errorCode: LIT_ERROR.INVALID_PARAM_TYPE.name,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

As this PR is pointing to master (v7) it should be updated to use the new errors

}

// 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