diff --git a/package.json b/package.json index 7520975c..dac1fde6 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,12 @@ "name": "@entropyxyz/entropy-js", "version": "0.1.2", "description": "JS SDK for entropy blockchain ", - "main": "dist/index.cjs", - "type": "module", + "main": "dist/index.js", "files": [ "dist" ], "types": "dist/index.d.ts", - "module": "dist/index.cjs", + "module": "dist/index.js", "browser": "dist/index.js", "scripts": { "test": "yarn test:setup && yarn removedb && jest --runInBand --detectOpenHandles", diff --git a/src/keys/index.ts b/src/keys/index.ts index 036c4245..84d1f107 100644 --- a/src/keys/index.ts +++ b/src/keys/index.ts @@ -6,9 +6,7 @@ import { keyFromPath, keyExtractPath, } from '@polkadot/util-crypto' -import { Keypair } from '@polkadot/util-crypto/types' import { Keyring } from '@polkadot/keyring' -import { KeyringPair } from '@polkadot/keyring/types' import { hexToU8a } from '@polkadot/util' import { Signer } from '../types' @@ -37,10 +35,10 @@ export function isValidPair (pair: Signer): boolean { * @returns A function that takes a `Signer` or seed string and returns a Promise resolving to an object containing the wallet and its associated `Signer`. */ -function setupGetWallet (): (input: string) => Promise | undefined { +function setupGetWallet (): (input: string) => Promise { const keyring = new Keyring({ type: 'sr25519' }) - return async (input: Keypair | string) => { + return async (input: string): Promise => { // do a string typecheck if (typeof input === 'string') { @@ -62,7 +60,7 @@ function setupGetWallet (): (input: string) => Promise | undefined { * @returns A Promise resolving to an object containing the wallet and its associated `Signer`, or undefined if the input is invalid. */ -export const getWallet: (pair: Signer | string) => Promise<{ wallet: KeyringPair, pair: Keypair }> | undefined = setupGetWallet() +export const getWallet: (input: string) => Promise = setupGetWallet() /** * Generates a new mnemonic phrase or derives a wallet from an existing mnemonic and an optional derivation path. diff --git a/tsup.config.ts b/tsup.config.ts index 2a5d3636..bb81f6f8 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -4,7 +4,7 @@ export default defineConfig((options) => { return { entry: [`src/index.ts`, 'src/keys/index.ts', 'src/utils/index.ts', 'src/utils/crypto.ts'], replaceNodeEnv: true, - format: ['esm'], + format: ['esm', 'cjs'], dts: true, // todo: env var for this? sourcemap: false,