diff --git a/sdk/scripts/generateIndex.js b/sdk/scripts/generateIndex.js index 4f428a9cc5..b1912ab144 100644 --- a/sdk/scripts/generateIndex.js +++ b/sdk/scripts/generateIndex.js @@ -1,6 +1,12 @@ import fs from 'fs'; import path from 'path'; +const deprecateMessage = (message) => ( +`/** + * @deprecated ${message} + */\n` +); + const dirname = path.dirname(new URL(import.meta.url).pathname); // Read the JSON file @@ -12,8 +18,17 @@ const moduleData = JSON.parse(fileData); // Get the release type from the environment variable or default to 'alpha' const releaseType = process.env.RELEASE_TYPE || 'alpha'; + +let indexFileContent = `import * as imxClient from './immutablex_client'; +import * as imxProvider from './provider'; + +export const x = { + client: imxClient, + provider: imxProvider, +}; +`; + // Generate the index.ts file contents based on the release type -let indexFileContent = ''; Object.keys(moduleData.modules).forEach((moduleName) => { const moduleReleaseType = moduleData.modules[moduleName]; @@ -31,6 +46,13 @@ Object.keys(moduleData.modules).forEach((moduleName) => { }) .join(''); + if (moduleName === 'immutablex_client') { + indexFileContent += deprecateMessage(`Use x.client or /x/client instead.`); + }; + if (moduleName === 'provider') { + indexFileContent += deprecateMessage(`Use x.provider or /x/provider instead.`); + }; + const modulePath = `./${moduleName}`; const exportStatement = `export * as ${moduleNameCapitalized} from '${modulePath}';\n`; indexFileContent += exportStatement; diff --git a/sdk/src/index.ts b/sdk/src/index.ts index fa5c47888e..69175a9e2b 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -1,7 +1,20 @@ +import * as imxClient from './immutablex_client'; +import * as imxProvider from './provider'; + +export const x = { + client: imxClient, + provider: imxProvider, +}; export * as config from './config'; export * as blockchainData from './blockchain_data'; +/** + * @deprecated Use x.client or /x/client instead. + */ export * as immutablexClient from './immutablex_client'; export * as passport from './passport'; export * as orderbook from './orderbook'; +/** + * @deprecated Use x.provider or /x/provider instead. + */ export * as provider from './provider'; export * as checkout from './checkout';