From 33fcfb452b7340b73a13300e19cfeb83a94406c2 Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 28 Jul 2023 22:16:39 +0600 Subject: [PATCH 1/2] fix: use `Number` instead of unary plus for BigInt Fixes bug in fdf55787dacd87393546299f110facf3947da7ca --- src/contract/Contract.ts | 2 +- src/tx/builder/field-types/u-int.ts | 2 +- test/integration/contract-aci.ts | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/contract/Contract.ts b/src/contract/Contract.ts index bd2748aa97..373a165090 100644 --- a/src/contract/Contract.ts +++ b/src/contract/Contract.ts @@ -312,7 +312,7 @@ class Contract { if (fn == null) throw new MissingFunctionNameError(); if (fn === 'init' && callStatic !== true) throw new InvalidMethodInvocationError('"init" can be called only via dryRun'); - if (fn !== 'init' && opt.amount != null && +opt.amount > 0 && !fnAci.payable) { + if (fn !== 'init' && opt.amount != null && Number(opt.amount) > 0 && !fnAci.payable) { throw new NotPayableFunctionError(opt.amount, fn); } diff --git a/src/tx/builder/field-types/u-int.ts b/src/tx/builder/field-types/u-int.ts index 5c10b3e11d..3dbf92054f 100644 --- a/src/tx/builder/field-types/u-int.ts +++ b/src/tx/builder/field-types/u-int.ts @@ -5,7 +5,7 @@ import { toBytes } from '../../../utils/bytes'; export default { serialize(value: Int): Buffer { - if (+value < 0) throw new ArgumentError('value', 'greater or equal to 0', value); + if (Number(value) < 0) throw new ArgumentError('value', 'greater or equal to 0', value); return toBytes(value, true); }, diff --git a/test/integration/contract-aci.ts b/test/integration/contract-aci.ts index 3a90103ade..75f1805da5 100644 --- a/test/integration/contract-aci.ts +++ b/test/integration/contract-aci.ts @@ -412,6 +412,15 @@ describe('Contract instance', () => { balanceAfter.should.be.equal(`${+contractBalance + 100}`); }); + it('pays to payable function using BigInt', async () => { + assertNotNull(testContract.$options.address); + const contractBalance = await aeSdk.getBalance(testContract.$options.address); + // bigint is not assignable to amount + await testContract.stringFn('test', { amount: 100n as unknown as string, callStatic: false }); + const balanceAfter = await aeSdk.getBalance(testContract.$options.address); + balanceAfter.should.be.equal(`${+contractBalance + 100}`); + }); + it('calls on specific account', async () => { const onAccount = aeSdk.accounts[aeSdk.addresses()[1]]; const { result } = await testContract.intFn(123, { onAccount }); From e99d1696fe1702d0d2fdda526098d05b6865049d Mon Sep 17 00:00:00 2001 From: Denis Davidyuk Date: Fri, 28 Jul 2023 22:31:48 +0600 Subject: [PATCH 2/2] chore(release): 13.2.1 --- docs/CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index df115129cf..9490c0a772 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [13.2.1](https://github.com/aeternity/aepp-sdk-js/compare/v13.2.0...v13.2.1) (2023-07-28) + + +### Bug Fixes + +* use `Number` instead of unary plus for BigInt ([33fcfb4](https://github.com/aeternity/aepp-sdk-js/commit/33fcfb452b7340b73a13300e19cfeb83a94406c2)) + ## [13.2.0](https://github.com/aeternity/aepp-sdk-js/compare/v13.1.0...v13.2.0) (2023-07-28) diff --git a/package-lock.json b/package-lock.json index 702ef52de9..d24651aca9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aeternity/aepp-sdk", - "version": "13.2.0", + "version": "13.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@aeternity/aepp-sdk", - "version": "13.2.0", + "version": "13.2.1", "license": "ISC", "dependencies": { "@aeternity/aepp-calldata": "^1.4.0", diff --git a/package.json b/package.json index 1f59170031..167192c09d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aeternity/aepp-sdk", - "version": "13.2.0", + "version": "13.2.1", "description": "SDK for the æternity blockchain", "main": "dist/aepp-sdk.js", "types": "es/index.d.ts",