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.46.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.47.0
Choose a head ref
  • 4 commits
  • 64 files changed
  • 1 contributor

Commits on Jun 12, 2024

  1. revert: mirror node queries changes (#2328)

    * revert changes
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: workflow
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: workflow
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: status codes
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: status codes
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * chore: correct status code name
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: tests
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: test
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    ---------
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Jun 12, 2024
    Copy the full SHA
    484f0f9 View commit details

Commits on Jun 14, 2024

  1. feature: change or remove existing keys from a token [HIP-540] (#2299)

    * feature: change or remove token keys + tests + example
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * chore: remove import
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * fix: unit test
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * chore: remove only
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: public key class and tests
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: example
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    ---------
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Jun 14, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    72f4656 View commit details
  2. update: v2.15.0-beta.1 (#2351)

    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Jun 14, 2024
    Copy the full SHA
    6e7433c View commit details
  3. release: v2.47.0 (#2352)

    * update: version
    
    * revert: task release command
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: proto package version
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    * update: changelog
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    
    ---------
    
    Signed-off-by: svetoslav-nikol0v <svetoslav.nikolov@limechain.tech>
    svetoslav-nikol0v authored Jun 14, 2024
    Copy the full SHA
    24c57a8 View commit details
Showing with 3,322 additions and 1,588 deletions.
  1. +11 −11 .github/workflows/build.yml
  2. +8 −0 CHANGELOG.md
  3. +1 −1 Taskfile.yml
  4. +205 −0 examples/change-or-remove-token-keys.js
  5. +2 −2 package.json
  6. +1 −1 packages/proto/package.json
  7. +1 −1 packages/proto/src/proto
  8. +0 −23 src/Executable.js
  9. +13 −0 src/PublicKey.js
  10. +18 −0 src/Status.js
  11. +10 −0 src/account/AccountBalance.js
  12. +6 −69 src/account/AccountBalanceQuery.js
  13. +10 −74 src/account/AccountInfoQuery.js
  14. +3 −18 src/account/TokenRelationship.js
  15. +2 −0 src/client/ManagedNetwork.js
  16. +0 −4 src/client/NodeClient.js
  17. +10 −67 src/contract/ContractInfoQuery.js
  18. +1 −2 src/exports.js
  19. +0 −115 src/network/MirrorNodeGateway.js
  20. +0 −87 src/network/MirrorNodeRouter.js
  21. +0 −205 src/network/MirrorNodeService.js
  22. +88 −0 src/token/TokenKeyValidation.js
  23. +42 −0 src/token/TokenUpdateTransaction.js
  24. +33 −34 test/integration/AccountBalanceIntegrationTest.js
  25. +0 −9 test/integration/AccountCreateIntegrationTest.js
  26. +0 −1 test/integration/AccountDeleteIntegrationTest.js
  27. +33 −30 test/integration/AccountInfoIntegrationTest.js
  28. +0 −1 test/integration/AccountUpdateIntegrationTest.js
  29. +61 −65 test/integration/ClientIntegrationTest.js
  30. +0 −1 test/integration/ContractCreateIntegrationTest.js
  31. +0 −2 test/integration/ContractDeleteIntegrationTest.js
  32. +18 −3 test/integration/ContractFunctionParametersIntegrationTest.js
  33. +0 −3 test/integration/ContractInfoIntegrationTest.js
  34. +0 −2 test/integration/ContractUpdateIntegrationTest.js
  35. +2 −1 test/integration/CustomFeesIntegrationTest.js
  36. +0 −5 test/integration/GetCostIntegrationTest.js
  37. +1 −1 test/integration/NftAllowancesIntegrationTest.js
  38. +3 −1 test/integration/ScheduleCreateIntegrationTest.js
  39. +27 −6 test/integration/TokenAllowancesIntegrationTest.js
  40. +70 −69 test/integration/TokenAssociateIntegrationTest.js
  41. +52 −48 test/integration/TokenBurnIntegrationTest.js
  42. +90 −89 test/integration/TokenDissociateIntegrationTest.js
  43. +71 −67 test/integration/TokenFreezeIntegrationTest.js
  44. +71 −67 test/integration/TokenGrantKycIntegrationTest.js
  45. +94 −91 test/integration/TokenRevokeKycIntegrationTest.js
  46. +0 −2 test/integration/TokenTransferIntegrationTest.js
  47. +94 −91 test/integration/TokenUnfreezeIntegrationTest.js
  48. +2,015 −4 test/integration/TokenUpdateIntegrationTest.js
  49. +98 −95 test/integration/TokenWipeIntegrationTest.js
  50. +22 −23 test/integration/TopicMessageIntegrationTest.js
  51. +7 −12 test/integration/TopicMessageQueryTest.js
  52. +6 −1 test/integration/TransactionRecordIntegrationTest.js
  53. +3 −1 test/integration/client/BaseIntegrationTestEnv.js
  54. +2 −9 test/unit/AccountInfoMocking.js
  55. +2 −7 test/unit/ContractCreateFlowMocking.js
  56. +2 −7 test/unit/EthereumFlowMocking.js
  57. +0 −43 test/unit/MirrorNodeService.js
  58. +1 −3 test/unit/Mocker.js
  59. +3 −0 test/unit/TokenUpdateTransaction.js
  60. +2 −7 test/unit/TopicMessageMocking.js
  61. +1 −0 test/unit/TransactionReceipt.js
  62. +2 −7 test/unit/TransactionReceiptMocking.js
  63. +2 −0 test/unit/TransactionRecord.js
  64. +2 −0 test/unit/TransactionResponse.js
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -156,38 +156,38 @@ jobs:
id: start-local-node
if: ${{ steps.build-sdk.conclusion == 'success' && !cancelled() && always() }}
run: |
${{ env.CG_EXEC }} npx @hashgraph/hedera-local start -d --network-tag=0.49.7 --balance=100000
${{ env.CG_EXEC }} npx @hashgraph/hedera-local start -d -network local --balance=100000
# Wait for the network to fully start
sleep 30
- name: Run Hedera SDK Integration Tests Codecov
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task test:integration:codecov

- name: Stop the local node
id: stop-local-node
if: ${{ steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} npx @hashgraph/hedera-local stop

- name: Build @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
if: ${{ steps.build-sdk.conclusion == 'success' && steps.stop-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task build

- name: Unit Test @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
if: ${{ steps.build-sdk.conclusion == 'success' && steps.stop-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task test:unit

- name: Codecov @hashgraph/cryptography
working-directory: packages/cryptography
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
if: ${{ steps.build-sdk.conclusion == 'success' && steps.stop-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task test:unit:codecov

- name: Unit Test @hashgraph/sdk
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && steps.playwright-deps.conclusion == 'success' && !cancelled() && always() }}
if: ${{ steps.build-sdk.conclusion == 'success' && steps.stop-local-node.conclusion == 'success' && steps.playwright-deps.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task test:unit

- name: Codecov @hashgraph/sdk
if: ${{ steps.build-sdk.conclusion == 'success' && steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
if: ${{ steps.build-sdk.conclusion == 'success' && steps.stop-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} task test:unit:codecov

- name: Stop the local node
id: stop-local-node
if: ${{ steps.start-local-node.conclusion == 'success' && !cancelled() && always() }}
run: ${{ env.CG_EXEC }} npx @hashgraph/hedera-local stop
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,14 @@ 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.47.0

## What's Changed

* revert: mirror node queries changes by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2328
* feature: change or remove existing keys from a token [HIP-540] by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2299
* release: proto v2.15.0-beta.1 by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2351

## v2.46.0

## What's Changed
2 changes: 1 addition & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ tasks:
"test:release":
cmds:
- task: build
# - task: test:unit
- task: test:unit
- task: examples:build
- task: simple_rest_signature_provider:build
- task: common_js_test:build
205 changes: 205 additions & 0 deletions examples/change-or-remove-token-keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import {
AccountId,
Client,
PrivateKey,
Logger,
LogLevel,
PublicKey,
KeyList,
TokenUpdateTransaction,
TokenKeyValidation,
TokenCreateTransaction,
TokenType,
TokenInfoQuery,
} from "@hashgraph/sdk";
import dotenv from "dotenv";

/**
* @description Change ot remove token keys
*/

async function main() {
// Ensure required environment variables are available
dotenv.config();
if (
!process.env.OPERATOR_KEY ||
!process.env.OPERATOR_ID ||
!process.env.HEDERA_NETWORK
) {
throw new Error("Please set required keys in .env file.");
}

const network = process.env.HEDERA_NETWORK;

// Configure client using environment variables
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromStringED25519(process.env.OPERATOR_KEY);

const client = Client.forName(network).setOperator(operatorId, operatorKey);

// Set logger
const infoLogger = new Logger(LogLevel.Info);
client.setLogger(infoLogger);

const adminKey = PrivateKey.generateED25519();
const supplyKey = PrivateKey.generateED25519();
const newSupplyKey = PrivateKey.generateED25519();
const wipeKey = PrivateKey.generateED25519();
const freezeKey = PrivateKey.generateED25519();
const pauseKey = PrivateKey.generateED25519();
const feeScheduleKey = PrivateKey.generateED25519();
const metadataKey = PrivateKey.generateED25519();

// This HIP introduces ability to remove lower-privilege keys (Wipe, KYC, Freeze, Pause, Supply, Fee Schedule, Metadata) from a Token:
// - using an update with the empty KeyList;
const emptyKeyList = KeyList.of();
// - updating with an “invalid” key such as an Ed25519 0x0000000000000000000000000000000000000000000000000000000000000000 public key,
// since it is (presumably) impossible to find the 32-byte string whose SHA-512 hash begins with 32 bytes of zeros.
const unusableKey = PublicKey.unusableKey();

console.log("=====================================================");
console.log("Initializing token keys...");
console.log("-----------------------------------------------------");
console.log("Admin key:", adminKey.publicKey.toString());
console.log("Supply key:", supplyKey.publicKey.toString());
console.log("New supply key:", newSupplyKey.publicKey.toString());
console.log("Wipe key:", wipeKey.publicKey.toString());
console.log("Freeze key:", freezeKey.publicKey.toString());
console.log("Pause key:", pauseKey.publicKey.toString());
console.log("Fee schedule key:", feeScheduleKey.publicKey.toString());
console.log("Metadata key:", metadataKey.publicKey.toString());
console.log("Unusable key:", unusableKey.toString());
console.log("=====================================================");
console.log("\n");

let token, tokenInfo, response, receipt, update;

console.log("=====================================================");
console.log("Creating token...");
console.log("-----------------------------------------------------");
token = new TokenCreateTransaction()
.setTokenName("Token")
.setTokenSymbol("T")
.setTokenType(TokenType.NonFungibleUnique)
.setTreasuryAccountId(operatorId)
.setAdminKey(adminKey)
.setWipeKey(wipeKey)
.setFreezeKey(freezeKey)
.setPauseKey(pauseKey)
.setSupplyKey(supplyKey)
.setFeeScheduleKey(feeScheduleKey)
.setMetadataKey(metadataKey)
.freezeWith(client);

response = await (await token.sign(adminKey)).execute(client);

receipt = await response.getReceipt(client);
console.log("Token create transction status:", receipt.status.toString());

const tokenId = receipt.tokenId;
console.log("Token id:", tokenId.toString());
console.log("=====================================================");
console.log("\n");
console.log("=====================================================");
console.log("Token keys:");
console.log("-----------------------------------------------------");
tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client);

console.log("Token admin key:", tokenInfo.adminKey.toString());
console.log("Token pause key:", tokenInfo.pauseKey.toString());
console.log("Token freeze key:", tokenInfo.freezeKey.toString());
console.log("Token wipe key:", tokenInfo.wipeKey.toString());
console.log("Token supply key:", tokenInfo.supplyKey.toString());
console.log("Token fee schedule key:", tokenInfo.feeScheduleKey.toString());
console.log("Token metadata key:", tokenInfo.metadataKey.toString());
console.log("=====================================================");
console.log("\n");
console.log("=====================================================");
console.log("Removing Wipe Key...");
console.log("-----------------------------------------------------");
update = new TokenUpdateTransaction()
.setTokenId(tokenId)
.setWipeKey(emptyKeyList)
.setKeyVerificationMode(TokenKeyValidation.FullValidation)
.freezeWith(client);
response = await (await update.sign(adminKey)).execute(client);

receipt = await response.getReceipt(client);
console.log("Token update transaction status:", receipt.status.toString());

tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client);
console.log("Token wipeKey is", tokenInfo.wipeKey);
console.log("=====================================================");
console.log("\n");
console.log("=====================================================");
console.log("Removing Admin Key...");
console.log("-----------------------------------------------------");
update = new TokenUpdateTransaction()
.setTokenId(tokenId)
.setAdminKey(emptyKeyList)
.setKeyVerificationMode(TokenKeyValidation.NoValidation)
.freezeWith(client);
response = await (await update.sign(adminKey)).execute(client);

receipt = await response.getReceipt(client);
console.log("Token update transaction status:", receipt.status.toString());

tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client);
console.log("Token adminKey is", tokenInfo.adminKey);
console.log("=====================================================");
console.log("\n");
console.log("=====================================================");
console.log("Updating Supply Key...");
console.log("-----------------------------------------------------");
console.log(
"Token supplyKey (before update) is",
tokenInfo.supplyKey.toString(),
);
update = new TokenUpdateTransaction()
.setTokenId(tokenId)
.setSupplyKey(newSupplyKey)
.setKeyVerificationMode(TokenKeyValidation.FullValidation)
.freezeWith(client);
response = await (
await (await update.sign(supplyKey)).sign(newSupplyKey)
).execute(client);

receipt = await response.getReceipt(client);
console.log("Token update transaction status:", receipt.status.toString());

tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client);
console.log(
"Token suppleyKey (after update) is",
tokenInfo.supplyKey.toString(),
);
console.log("=====================================================");
console.log("\n");
console.log("=====================================================");
console.log("Updating Supply Key to unusable format...");
console.log("-----------------------------------------------------");
console.log(
"Token supplyKey (before update) is",
tokenInfo.supplyKey.toString(),
);
update = new TokenUpdateTransaction()
.setTokenId(tokenId)
.setSupplyKey(unusableKey)
.setKeyVerificationMode(TokenKeyValidation.NoValidation)
.freezeWith(client);
response = await (await update.sign(newSupplyKey)).execute(client);

receipt = await response.getReceipt(client);
console.log("Token update transaction status:", receipt.status.toString());

tokenInfo = await new TokenInfoQuery().setTokenId(tokenId).execute(client);

console.log(
"Token suppleyKey (after update) is",
tokenInfo.supplyKey.toString(),
);
console.log("=====================================================");

client.close();
}

void main();
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.46.0",
"version": "2.47.0",
"description": "Hedera™ Hashgraph SDK",
"types": "./lib/index.d.ts",
"main": "./lib/index.cjs",
@@ -58,7 +58,7 @@
"@ethersproject/rlp": "^5.7.0",
"@grpc/grpc-js": "1.8.2",
"@hashgraph/cryptography": "1.4.8-beta.5",
"@hashgraph/proto": "2.15.0",
"@hashgraph/proto": "2.15.0-beta.1",
"axios": "^1.6.4",
"bignumber.js": "^9.1.1",
"bn.js": "^5.1.1",
2 changes: 1 addition & 1 deletion packages/proto/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/proto",
"version": "2.15.0",
"version": "2.15.0-beta.1",
"description": "Protobufs for the Hedera™ Hashgraph SDK",
"main": "lib/index.js",
"browser": "src/index.js",
23 changes: 0 additions & 23 deletions src/Executable.js
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@ import HttpError from "./http/HttpError.js";
* @typedef {import("./Signer.js").Signer} Signer
* @typedef {import("./PublicKey.js").default} PublicKey
* @typedef {import("./logger/Logger.js").default} Logger
* @typedef {import("./LedgerId.js").default} LedgerId
*/

/**
@@ -135,20 +134,6 @@ export default class Executable {
* @type {Logger | null}
*/
this._logger = null;

/**
* List of mirror network nodes with which execution will be attempted.
* @protected
* @type {string[]}
*/
this._mirrorNetworkNodes = [];

/**
* Current LedgerId of the network with which execution will be attempted.
* @protected
* @type {LedgerId | null}
*/
this._ledgerId = null;
}

/**
@@ -526,14 +511,6 @@ export default class Executable {
* @returns {Promise<OutputT>}
*/
async execute(client, requestTimeout) {
// Set list of mirror network nodes with
// which execution will be attempted
this._mirrorNetworkNodes = client.mirrorNetwork;

// Set current LedgerId of the network with
// which execution will be attempted
this._ledgerId = client.ledgerId;

// If the logger on the request is not set, use the logger in client
// (if set, otherwise do not use logger)
this._logger =
13 changes: 13 additions & 0 deletions src/PublicKey.js
Original file line number Diff line number Diff line change
@@ -282,6 +282,19 @@ export default class PublicKey extends Key {
toAccountId(shard, realm) {
return CACHE.accountIdConstructor(shard, realm, this);
}

/**
* Returns an "unusable" public key.
* “Unusable” refers to a key such as an Ed25519 0x00000... public key,
* since it is (presumably) impossible to find the 32-byte string whose SHA-512 hash begins with 32 bytes of zeros.
*
* @returns {PublicKey}
*/
static unusableKey() {
return PublicKey.fromStringED25519(
"0000000000000000000000000000000000000000000000000000000000000000",
);
}
}

CACHE.setPublicKeyED25519((key) => PublicKey.fromBytesED25519(key));
Loading