Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit 1f42ca3

Browse files
committed
Fixed idl loading
1 parent eaa30d5 commit 1f42ca3

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mean-dao/msp",
3-
"version": "2.6.0-alpha.3",
3+
"version": "2.6.0-alpha.4",
44
"description": "MSP Typescript SDK",
55
"private": false,
66
"main": "lib/index.js",

src/utils.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ const parseStreamItemData = (
621621

622622
let idl_legacy_after_1645224519: any = null;
623623
let idl_legacy_before_1645224519: any = null;
624+
const idlPaths: string[] = [
625+
'./msp_idl_001',
626+
]
624627
const idls: { [fileVersion: number]: any } = {};
625628

626629
async function parseStreamInstructionAfter1645224519(
@@ -819,23 +822,18 @@ async function parseVersionedStreamInstruction(
819822
return null;
820823
}
821824

822-
if(idlFileVersion <= 0 || idlFileVersion > 255){
825+
if(idlFileVersion <= 0 || idlFileVersion > LATEST_IDL_FILE_VERSION){
823826
return null;
824827
}
825828

826-
let idlFileVersionStr = idlFileVersion.toString();
827-
if(idlFileVersion < 10) {
828-
idlFileVersionStr = '00' + idlFileVersionStr;
829-
} else if(idlFileVersion < 200) {
830-
idlFileVersionStr = '0' + idlFileVersionStr;
831-
}
832-
833-
const idlFileName = `msp_idl_${idlFileVersionStr}`;
834-
835829
try {
836830
if (!idls[idlFileVersion]) {
837-
const importedIdl = await import(`./${idlFileName}`);
838-
idls[idlFileVersion] = importedIdl.IDL;
831+
if (idlFileVersion === 1) { // TODO: to avoid this if else, find a way to do dynamic imports passign concatenated paths
832+
const importedIdl = await import('./msp_idl_001');
833+
idls[idlFileVersion] = importedIdl.IDL;
834+
} else {
835+
return null;
836+
}
839837
}
840838

841839
const coder = new BorshInstructionCoder(idls[idlFileVersion] as Idl);

0 commit comments

Comments
 (0)