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
24 changes: 5 additions & 19 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: Build and Test

on:
pull_request:
branches: [main]
branches: [main, development]
workflow_dispatch:

jobs:
publish-npm:
build:
runs-on: ubuntu-latest
steps:
- name: Fix permissions
Expand All @@ -24,23 +24,9 @@ jobs:
node-version: 18
- name: Setup pnpm
run: npm install -g pnpm
- name: Get node_modules cache
uses: actions/cache@v4
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Remove node_modules
if: steps.node_modules.outputs.cache-hit != 'true'
run: rm -rf node_modules
- name: Install Dependencies
uses: nick-fields/retry@v3
if: steps.node_modules.outputs.cache-hit != 'true'
with:
timeout_minutes: 120
retry_on: error
max_attempts: 3
command: pnpm install
- run: npm run compile
- run: npm run test
run: pnpm install
- run: pnpm run compile
- run: pnpm run test
16 changes: 1 addition & 15 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,10 @@ jobs:
registry-url: https://registry.npmjs.org/
- name: Setup pnpm
run: npm install -g pnpm
- name: Get node_modules cache
uses: actions/cache@v4
id: node_modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Remove node_modules
if: steps.node_modules.outputs.cache-hit != 'true'
run: rm -rf node_modules
- name: Install Dependencies
uses: nick-fields/retry@v3
if: steps.node_modules.outputs.cache-hit != 'true'
with:
timeout_minutes: 120
retry_on: error
max_attempts: 3
command: pnpm install
run: pnpm install
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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.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)

## [[v3.0.1]](https://github.com/multiversx/mx-sdk-dapp-utils/pull/25) - 2025-08-05

- [Migrate to sdk-core v15](https://github.com/multiversx/mx-sdk-dapp-utils/pull/22)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiversx/sdk-dapp-utils",
"version": "3.0.1",
"version": "3.0.2",
"description": "SDK for DApp utilities",
"main": "out/index.js",
"types": "out/index.d.js",
Expand Down
11 changes: 2 additions & 9 deletions src/helpers/parseAmount.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import BigNumber from 'bignumber.js';
import { DECIMALS } from '../constants';

export function parseAmount(amount: string, numDecimals: number = DECIMALS) {
const amountBN = new BigNumber(amount);
const multiplier = new BigNumber(10).pow(numDecimals);
const result = amountBN.multipliedBy(multiplier);

if (!result.isInteger()) {
throw new Error('Amount has too many decimal places');
}

export function parseAmount(amount: string, numDecimals = DECIMALS): string {
const result = new BigNumber(amount).shiftedBy(numDecimals).decimalPlaces(0);
return result.toFixed(0);
}