Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
sudo chown -R $USER:$USER ${{ github.workspace }}
sudo chmod -R 755 ${{ github.workspace }}
continue-on-error: true
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
clean: true
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version: 18
node-version: 24
- name: Setup pnpm
run: npm install -g pnpm
- name: Remove node_modules
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/package-lock-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v6

- name: Use Node.js LTS
uses: actions/setup-node@v1
uses: actions/setup-node@v6
with:
node-version: '18.x'
node-version: 24

- name: Copy package-lock.json file
run: cp package-lock.json package-lock-copy.json
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ jobs:
sudo chown -R $USER:$USER ${{ github.workspace }}
sudo chmod -R 755 ${{ github.workspace }}
continue-on-error: true
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.ref }}
clean: true
- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v6
with:
node-version: 18
node-version: 24
registry-url: https://registry.npmjs.org/
- name: Setup pnpm
run: npm install -g pnpm
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [[v3.1.0]](https://github.com/multiversx/mx-sdk-dapp-utils/pull/29) - 2026-07-02

- [Ship native Node ESM](https://github.com/multiversx/mx-sdk-dapp-utils/pull/28)

## [[v3.0.2]](https://github.com/multiversx/mx-sdk-dapp-utils/pull/27) - 2025-09-16

- [Refactored parseAmount to mimic sdk-core v.14 implementation](https://github.com/multiversx/mx-sdk-dapp-utils/pull/26)
Expand Down
106 changes: 0 additions & 106 deletions eslint.config.mjs

This file was deleted.

5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module.exports = {
moduleDirectories: ['node_modules', 'src'],
modulePaths: ['<rootDir>/src'],
roots: ['<rootDir>/src'],
// Source uses explicit .js extensions on relative imports (for native-Node ESM
// output), but the on-disk source is .ts — strip the extension so Jest resolves it.
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1'
},
transform: {
'^.+\\.(ts|js|tsx|jsx)$': ['@swc/jest']
},
Expand Down
56 changes: 52 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,63 @@
{
"name": "@multiversx/sdk-dapp-utils",
"version": "3.0.2",
"version": "3.1.0",
"description": "SDK for DApp utilities",
"main": "out/index.js",
"types": "out/index.d.js",
"main": "./out/index.js",
"module": "./out/esm/index.js",
"types": "./out/index.d.ts",
"sideEffects": false,
"exports": {
".": {
"types": "./out/index.d.ts",
"import": "./out/esm/index.js",
"require": "./out/index.js"
},
"./out": {
"types": "./out/index.d.ts",
"import": "./out/esm/index.js",
"require": "./out/index.js"
},
"./out/constants": {
"types": "./out/constants/index.d.ts",
"import": "./out/esm/constants/index.js",
"require": "./out/constants/index.js"
},
"./out/helpers": {
"types": "./out/helpers/index.d.ts",
"import": "./out/esm/helpers/index.js",
"require": "./out/helpers/index.js"
},
"./out/enums": {
"types": "./out/enums/index.d.ts",
"import": "./out/esm/enums/index.js",
"require": "./out/enums/index.js"
},
"./out/models": {
"types": "./out/models/index.d.ts",
"import": "./out/esm/models/index.js",
"require": "./out/models/index.js"
},
"./out/types": {
"types": "./out/types/index.d.ts",
"import": "./out/esm/types/index.js",
"require": "./out/types/index.js"
},
"./out/*": {
"types": "./out/*.d.ts",
"import": "./out/esm/*.js",
"require": "./out/*.js"
},
"./package.json": "./package.json"
},
"files": [
"out/**/*"
],
"scripts": {
"publish-verdaccio": "npm unpublish --registry http://localhost:4873 @multiversx/sdk-dapp-utils@3.0.0 && rm -rf out && yarn compile && npm publish --registry http://localhost:4873",
"compile": "tsc -p tsconfig.json",
"clean-out": "node -e \"require('fs').rmSync('out',{recursive:true,force:true})\"",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:esm": "tsc -p tsconfig.esm.json && node scripts/write-esm-package-json.js",
"compile": "npm run clean-out && npm run build:cjs && npm run build:esm",
"pretest": "npm run compile",
"prepare": "npm run compile",
"test": "jest"
Expand Down
4 changes: 4 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allowBuilds:
'@swc/core': false
keccak: false
protobufjs: false
12 changes: 12 additions & 0 deletions scripts/write-esm-package-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Marks out/esm as an ES module scope.

const fs = require('fs');
const path = require('path');

const esmDir = path.resolve(__dirname, '..', 'out', 'esm');

fs.mkdirSync(esmDir, { recursive: true });
fs.writeFileSync(
path.join(esmDir, 'package.json'),
JSON.stringify({ type: 'module' }, null, 2) + '\n'
);
4 changes: 2 additions & 2 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from "./browserConstants";
export * from './dappConstants';
export * from "./browserConstants.js";
export * from './dappConstants.js';
2 changes: 1 addition & 1 deletion src/enums/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./signMessageStatusEnum";
export * from "./signMessageStatusEnum.js";
6 changes: 3 additions & 3 deletions src/helpers/formatAmount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import BigNumber from 'bignumber.js';
import { DECIMALS, DIGITS, ZERO } from '../constants';
import { stringIsInteger } from './stringIsInteger';
import { pipe } from './pipe';
import { DECIMALS, DIGITS, ZERO } from '../constants/index.js';
import { stringIsInteger } from './stringIsInteger.js';
import { pipe } from './pipe.js';

/**
* Configuration options for formatting blockchain token amounts.
Expand Down
15 changes: 8 additions & 7 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export * from './formatAmount';
export * from './isWindowAvailable';
export * from './parseAmount';
export * from './pipe';
export * from './providerNotInitializedError';
export * from './stringIsFloat';
export * from './stringIsInteger';
export * from './formatAmount.js';
export * from './isWindowAvailable.js';
export * from './parseAmount.js';
export * from './pipe.js';
export * from './providerNotInitializedError.js';
export * from './recommendGasPrice.js';
export * from './stringIsFloat.js';
export * from './stringIsInteger.js';
2 changes: 1 addition & 1 deletion src/helpers/parseAmount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BigNumber from 'bignumber.js';
import { DECIMALS } from '../constants';
import { DECIMALS } from '../constants/index.js';

export function parseAmount(amount: string, numDecimals = DECIMALS): string {
const result = new BigNumber(amount).shiftedBy(numDecimals).decimalPlaces(0);
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/stringIsFloat.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import BigNumber from 'bignumber.js';
import { ZERO } from '../constants';
import { ZERO } from '../constants/index.js';

export const stringIsFloat = (amount: string) => {
if (isNaN(amount as any)) {
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from "./constants";
export * from "./enums";
export * from "./models";
export * from "./types";
export * from "./helpers";
export * from "./constants/index.js";
export * from "./enums/index.js";
export * from "./models/index.js";
export * from "./types/index.js";
export * from "./helpers/index.js";
2 changes: 1 addition & 1 deletion src/models/dappProviderBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Transaction, Message } from "@multiversx/sdk-core";
import type { Nullable } from "../types";
import type { Nullable } from "../types/index.js";

export interface IDAppProviderOptions {
[key: PropertyKey]: unknown;
Expand Down
2 changes: 1 addition & 1 deletion src/models/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./dappProviderBase";
export * from "./dappProviderBase.js";
2 changes: 1 addition & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from "./nullable";
export * from "./nullable.js";
30 changes: 30 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"target": "es2015",
"lib": [
"ES2015",
"DOM"
],
"sourceMap": true,
"allowJs": true,
"strict": true,
"strictPropertyInitialization": true,
"strictNullChecks": true,
"skipLibCheck": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"declaration": false
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"out",
"**/*.spec.ts",
"**/*.test.ts",
"src/setupTests.js"
]
}
9 changes: 9 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "out",
"declaration": true
}
}
8 changes: 8 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "Bundler",
"outDir": "out/esm"
}
}
Loading
Loading