Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hiero-ledger/hiero-sdk-js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.43.0
Choose a base ref
...
head repository: hiero-ledger/hiero-sdk-js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.44.0
Choose a head ref
  • 5 commits
  • 13 files changed
  • 2 contributors

Commits on Apr 15, 2024

  1. chore(ci): update the publish workflow to release the cryptography an…

    …d proto artifacts if needed (#2198)
    
    Signed-off-by: Nathan Klick <nathan@swirldslabs.com>
    nathanklick authored Apr 15, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    627462e View commit details
  2. fix: integer overflow isuue for defaultMaxQueryPayment field (#2213)

    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Apr 15, 2024

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    f868f1f View commit details
  3. update: add a new getter to the TransferTransaction class (#2214)

    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Apr 15, 2024
    Copy the full SHA
    f067bbb View commit details
  4. fix: set correct autoRenrewAccountId (#2217)

    * fix: set correct autoRenrewAccountId
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: update releated integration tests
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: integration test
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: TokenCreateTransaction integration tests
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: unit test
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * chore: formatting
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: network tag to 0.48.0
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * chore: fix typo
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    ---------
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Apr 15, 2024
    Copy the full SHA
    def492a View commit details
  5. release: stable version 2.44.0 (#2262)

    * update: version
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: changelog
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: network tag to 0.48.0
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    ---------
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Apr 15, 2024
    Copy the full SHA
    65a2323 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -102,7 +102,7 @@ jobs:
id: start-local-node
if: ${{ steps.build-sdk.conclusion == 'success' && !cancelled() && always() }}
run: |
npx @hashgraph/hedera-local start -d --network local --balance=100000
npx @hashgraph/hedera-local start -d --network-tag=0.48.0 --balance=100000
# Wait for the network to fully start
sleep 30
44 changes: 42 additions & 2 deletions .github/workflows/publish_release.yaml
Original file line number Diff line number Diff line change
@@ -177,6 +177,32 @@ jobs:
- name: Install Playwright Dependencies
run: sudo npx playwright install-deps

- name: Check Proto Subpackage Publish Status
id: proto
working-directory: packages/proto
run: |
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
PUBLISH_REQUIRED="false"
if ! curl -sSLf "https://registry.npmjs.org/@hashgraph/proto/${PACKAGE_VERSION}" >/dev/null 2>&1; then
PUBLISH_REQUIRED="true"
fi
echo "version=${PACKAGE_VERSION}" >>"${GITHUB_OUTPUT}"
echo "publish-required=${PUBLISH_REQUIRED}" >>"${GITHUB_OUTPUT}"
- name: Check Cryptography Subpackage Publish Status
id: cryptography
working-directory: packages/cryptography
run: |
PACKAGE_VERSION="$(node -p "require('./package.json').version")"
PUBLISH_REQUIRED="false"
if ! curl -sSLf "https://registry.npmjs.org/@hashgraph/cryptography/${PACKAGE_VERSION}" >/dev/null 2>&1; then
PUBLISH_REQUIRED="true"
fi
echo "version=${PACKAGE_VERSION}" >>"${GITHUB_OUTPUT}"
echo "publish-required=${PUBLISH_REQUIRED}" >>"${GITHUB_OUTPUT}"
- name: Calculate Publish Arguments
id: publish
run: |
@@ -188,14 +214,28 @@ jobs:
# Add the registry authentication stanza with variable substitution to the .npmrc configuration file.
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >>".npmrc"
- name: Publish Release
- name: Publish Proto Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: packages/proto
if: ${{ steps.proto.outputs.publish-required == 'true' && !cancelled() && !failure() }}
run: task publish -- ${{ steps.publish.outputs.args }}

- name: Publish Cryptography Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
working-directory: packages/cryptography
if: ${{ steps.cryptography.outputs.publish-required == 'true' && !cancelled() && !failure() }}
run: task publish -- ${{ steps.publish.outputs.args }}

- name: Publish SDK Release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: task publish -- ${{ steps.publish.outputs.args }}

- name: Generate Github Release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0
if: ${{ github.event.inputs.dry-run-enabled != 'true' }}
if: ${{ github.event.inputs.dry-run-enabled != 'true' && !cancelled() && !failure() }}
with:
tag: ${{ steps.validate-release.outputs.tag }}
prerelease: ${{ needs.validate-release.outputs.prerelease == 'true' }}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## v2.44.0

## What's Changed

* fix: set correct autoRenrewAccountId by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2217
* update: add a new getter to the TransferTransaction class by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2214
* fix: integer overflow isuue for defaultMaxQueryPayment field by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2213
* chore(ci): update the publish workflow to release the cryptography and proto artifacts if needed by @nathanklick in https://github.com/hashgraph/hedera-sdk-js/pull/2198

## v2.43.0

## What's Changed
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/sdk",
"version": "2.43.0",
"version": "2.44.0",
"description": "Hedera™ Hashgraph SDK",
"types": "./lib/index.d.ts",
"main": "./lib/index.cjs",
@@ -129,4 +129,4 @@
"optional": true
}
}
}
}
7 changes: 7 additions & 0 deletions src/account/TransferTransaction.js
Original file line number Diff line number Diff line change
@@ -368,6 +368,13 @@ export default class TransferTransaction extends Transaction {
return map;
}

/**
* @returns {Transfer[]}
*/
get hbarTransfersList() {
return this._hbarTransfers;
}

/**
* @internal
* @param {AccountId | string} accountId
5 changes: 4 additions & 1 deletion src/client/Client.js
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ import LedgerId from "../LedgerId.js";
import FileId from "../file/FileId.js";
import CACHE from "../Cache.js";
import Logger from "../logger/Logger.js"; // eslint-disable-line
import { convertToNumber } from "../util.js";

/**
* @typedef {import("../channel/Channel.js").default} Channel
@@ -449,7 +450,9 @@ export default class Client {
* @returns {Client<ChannelT, MirrorChannelT>}
*/
setDefaultMaxQueryPayment(defaultMaxQueryPayment) {
if (defaultMaxQueryPayment.toTinybars().toInt() < 0) {
const isMaxQueryPaymentNegative =
convertToNumber(defaultMaxQueryPayment.toTinybars()) < 0;
if (isMaxQueryPaymentNegative) {
throw new Error("defaultMaxQueryPayment must be non-negative");
}
this._defaultMaxQueryPayment = defaultMaxQueryPayment;
32 changes: 6 additions & 26 deletions src/token/TokenCreateTransaction.js
Original file line number Diff line number Diff line change
@@ -172,7 +172,12 @@ export default class TokenCreateTransaction extends Transaction {
* @private
* @type {?Timestamp}
*/
this._expirationTime = null;
this._expirationTime = new Timestamp(
Math.floor(
Date.now() / 1000 + DEFAULT_AUTO_RENEW_PERIOD.toNumber(),
),
0,
);

/**
* @private
@@ -657,7 +662,6 @@ export default class TokenCreateTransaction extends Transaction {
*/
setExpirationTime(time) {
this._requireNotFrozen();
this._autoRenewPeriod = null;
this._expirationTime =
time instanceof Timestamp ? time : Timestamp.fromDate(time);

@@ -791,30 +795,6 @@ export default class TokenCreateTransaction extends Transaction {
return this;
}

/**
* @override
* @param {AccountId} accountId
*/
_freezeWithAccountId(accountId) {
super._freezeWithAccountId(accountId);

if (this._autoRenewPeriod != null && accountId != null) {
this._autoRenewAccountId = accountId;
}
}

/**
* @param {?import("../client/Client.js").default<Channel, *>} client
* @returns {this}
*/
freezeWith(client) {
if (client != null && client.operatorAccountId != null) {
this._freezeWithAccountId(client.operatorAccountId);
}

return super.freezeWith(client);
}

/**
* @param {Client} client
*/
18 changes: 18 additions & 0 deletions test/integration/ClientIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -172,6 +172,24 @@ describe("ClientIntegration", function () {
expect(clientTestnet.isTransportSecurity()).to.be.an("boolean");
});

it("should return the following error message `defaultMaxQueryPayment must be non-negative` when the user tries to set a negative value to the defaultMaxQueryPayment field", async function () {
this.timeout(120000);
try {
env.client.setDefaultMaxQueryPayment(new Hbar(1).negated());
} catch (error) {
expect(error.message).to.be.equal(
"defaultMaxQueryPayment must be non-negative",
);
}
});

it("should set defaultMaxQueryPayment field", async function () {
this.timeout(120000);
const value = new Hbar(100);
env.client.setDefaultMaxQueryPayment(value);
expect(env.client.defaultMaxQueryPayment).to.be.equal(value);
});

after(async function () {
await env.close();
clientTestnet.close();
106 changes: 94 additions & 12 deletions test/integration/TokenCreateIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
PrivateKey,
Status,
Timestamp,
TokenCreateTransaction,
TokenDeleteTransaction,
TokenInfoQuery,
@@ -59,12 +60,8 @@ describe("TokenCreate", function () {
expect(info.defaultFreezeStatus).to.be.false;
expect(info.defaultKycStatus).to.be.false;
expect(info.isDeleted).to.be.false;
expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
expect(info.autoRenewPeriod).to.be.not.null;
expect(info.autoRenewPeriod.seconds.toInt()).to.be.eql(7776000);
expect(info.autoRenewAccountId).to.be.null;
expect(info.autoRenewPeriod).to.be.null;
expect(info.expirationTime).to.be.not.null;
});

@@ -101,12 +98,8 @@ describe("TokenCreate", function () {
expect(info.defaultFreezeStatus).to.be.null;
expect(info.defaultKycStatus).to.be.null;
expect(info.isDeleted).to.be.false;
expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
expect(info.autoRenewPeriod).to.be.not.null;
expect(info.autoRenewPeriod.seconds.toInt()).to.be.eql(7776000);
expect(info.autoRenewAccountId).to.be.null;
expect(info.autoRenewPeriod).to.be.null;
expect(info.expirationTime).to.be.not.null;

let err = false;
@@ -126,6 +119,95 @@ describe("TokenCreate", function () {
}
});

it("when autoRenewAccountId is set", async function () {
this.timeout(120000);

const operatorId = env.operatorId;

const response = await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setTreasuryAccountId(operatorId)
.setAutoRenewAccountId(operatorId)
.execute(env.client);

const tokenId = (await response.getReceipt(env.client)).tokenId;

const info = await new TokenInfoQuery()
.setTokenId(tokenId)
.execute(env.client);

expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
});

it("when expirationTime is set", async function () {
this.timeout(120000);

const operatorId = env.operatorId;
const DAYS_45_IN_SECONDS = 3888000;
const expirationTime = new Timestamp(
Math.floor(Date.now() / 1000 + DAYS_45_IN_SECONDS),
0,
);

const response = await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setTreasuryAccountId(operatorId)
.setExpirationTime(expirationTime)
.execute(env.client);

const tokenId = (await response.getReceipt(env.client)).tokenId;

const info = await new TokenInfoQuery()
.setTokenId(tokenId)
.execute(env.client);

expect(info.expirationTime).to.be.not.null;
expect(info.expirationTime.toString()).to.be.eql(
expirationTime.toString(),
);
});

it("when autoRenewAccountId and expirationTime are set", async function () {
this.timeout(120000);

const operatorId = env.operatorId;
const DAYS_90_IN_SECONDS = 7776000;
const expirationTime = new Timestamp(
Math.floor(Date.now() / 1000 + DAYS_90_IN_SECONDS),
0,
);

const response = await new TokenCreateTransaction()
.setTokenName("ffff")
.setTokenSymbol("F")
.setTreasuryAccountId(operatorId)
.setExpirationTime(expirationTime)
.setAutoRenewAccountId(operatorId)
.execute(env.client);

const tokenId = (await response.getReceipt(env.client)).tokenId;

const info = await new TokenInfoQuery()
.setTokenId(tokenId)
.execute(env.client);

expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
expect(info.autoRenewPeriod).to.be.not.null;
expect(info.autoRenewPeriod.seconds.toInt()).to.be.eql(7776000);
expect(info.expirationTime).to.be.not.null;
expect(info.expirationTime.toString()).to.be.eql(
expirationTime.toString(),
);
});

it("should error when token name is not set", async function () {
this.timeout(120000);

16 changes: 4 additions & 12 deletions test/integration/TokenInfoIntegrationTest.js
Original file line number Diff line number Diff line change
@@ -59,12 +59,8 @@ describe("TokenInfo", function () {
expect(info.defaultFreezeStatus).to.be.false;
expect(info.defaultKycStatus).to.be.false;
expect(info.isDeleted).to.be.false;
expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
expect(info.autoRenewPeriod).to.be.not.null;
expect(info.autoRenewPeriod.seconds.toInt()).to.be.eql(7776000);
expect(info.autoRenewAccountId).to.be.null;
expect(info.autoRenewPeriod).to.be.null;
expect(info.expirationTime).to.be.not.null;
});

@@ -101,12 +97,8 @@ describe("TokenInfo", function () {
expect(info.defaultFreezeStatus).to.be.null;
expect(info.defaultKycStatus).to.be.null;
expect(info.isDeleted).to.be.false;
expect(info.autoRenewAccountId).to.be.not.null;
expect(info.autoRenewAccountId.toString()).to.be.eql(
operatorId.toString(),
);
expect(info.autoRenewPeriod).to.be.not.null;
expect(info.autoRenewPeriod.seconds.toInt()).to.be.eql(7776000);
expect(info.autoRenewAccountId).to.be.null;
expect(info.autoRenewPeriod).to.be.null;
expect(info.expirationTime).to.be.not.null;
});

Loading