Skip to content

Commit

Permalink
Release/v2.38.0 (#2034)
Browse files Browse the repository at this point in the history
* Remove all warnings (#2033)

* remove all warnings

Signed-off-by: svetoslav-nikol0v <[email protected]>

* wrap warning  in a condition

Signed-off-by: svetoslav-nikol0v <[email protected]>

* add additional warning

Signed-off-by: svetoslav-nikol0v <[email protected]>

* add note in description

Signed-off-by: svetoslav-nikol0v <[email protected]>

* use new method

Signed-off-by: svetoslav-nikol0v <[email protected]>

---------

Signed-off-by: svetoslav-nikol0v <[email protected]>

* eslint adjustments

Signed-off-by: svetoslav-nikol0v <[email protected]>

* cryptography package new beta version

Signed-off-by: svetoslav-nikol0v <[email protected]>

* notes for stable release

Signed-off-by: svetoslav-nikol0v <[email protected]>

* after test release

Signed-off-by: svetoslav-nikol0v <[email protected]>

---------

Signed-off-by: svetoslav-nikol0v <[email protected]>
  • Loading branch information
svetoslav-nikol0v authored Nov 27, 2023
1 parent 25880cc commit 2b7d727
Show file tree
Hide file tree
Showing 32 changed files with 84 additions and 67 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ 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.38.0

## What's Changed

* Add two grpc-web endpoints for node27/28 to ClientConstants.js by @ElijahLynn in https://github.com/hashgraph/hedera-sdk-js/pull/2019
* LocalProvider - close method by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2020
* Method fromEvmAddress() fails to return the contract id from long zero address by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2018
* Add support for Long and BigNumber to the array methods of ContractFunctionParameters by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2013
* Added fromStringDer() method (and tests) and deprecated fromString() method by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2030
* Remove all warnings by @svetoslav-nikol0v in https://github.com/hashgraph/hedera-sdk-js/pull/2033

## v2.37.0

## What's Changed
Expand Down
2 changes: 1 addition & 1 deletion examples/account-create-with-hts.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const nodes = {
"127.0.0.1:50211": new AccountId(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/consensus-pub-sub.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/contract-nonces.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function main() {
try {
const fileCreateTxResponse = await (
await new FileCreateTransaction()
.setKeys([PrivateKey.fromString(process.env.OPERATOR_KEY)])
.setKeys([PrivateKey.fromStringDer(process.env.OPERATOR_KEY)])
.setContents(SMART_CONTRACT_BYTECODE)
.setMaxTransactionFee(new Hbar(2))
.freezeWithSigner(wallet)
Expand All @@ -48,7 +48,7 @@ async function main() {

const contractCreateTxResponse = await (
await new ContractCreateTransaction()
.setAdminKey(PrivateKey.fromString(process.env.OPERATOR_KEY))
.setAdminKey(PrivateKey.fromStringDer(process.env.OPERATOR_KEY))
.setGas(100000)
.setBytecodeFileId(newFileId)
.setContractMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const nodes = {
"127.0.0.1:50211": new AccountId(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/create-account-with-alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const nodes = {
"127.0.0.1:50211": new AccountId(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/exempt-custom-fees.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function main() {
}
// Configure accounts and client, and generate needed keys
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const provider = new LocalProvider();

Expand Down
2 changes: 1 addition & 1 deletion examples/generate-txid-on-demand.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

let client;

Expand Down
8 changes: 4 additions & 4 deletions examples/hts-nftP1-fee-create-mint-burn-associate-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ dotenv.config();

// Configure accounts and client, and generate needed keys
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
const treasuryId = AccountId.fromString(process.env.TREASURY_ID);
const treasuryKey = PrivateKey.fromString(process.env.TREASURY_KEY);
const treasuryKey = PrivateKey.fromStringDer(process.env.TREASURY_KEY);
const aliceId = AccountId.fromString(process.env.ALICE_ID);
const aliceKey = PrivateKey.fromString(process.env.ALICE_KEY);
const aliceKey = PrivateKey.fromStringDer(process.env.ALICE_KEY);
const bobId = AccountId.fromString(process.env.BOB_ID);
const bobKey = PrivateKey.fromString(process.env.BOB_KEY);
const bobKey = PrivateKey.fromStringDer(process.env.BOB_KEY);
const nodes = {
"127.0.0.1:50211": new AccountId(3),
};
Expand Down
8 changes: 4 additions & 4 deletions examples/hts-nftP2-kyc-upate-schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ dotenv.config();

// Configure accounts and client, and generate needed keys
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
const treasuryId = AccountId.fromString(process.env.TREASURY_ID);
const treasuryKey = PrivateKey.fromString(process.env.TREASURY_KEY);
const treasuryKey = PrivateKey.fromStringDer(process.env.TREASURY_KEY);
const aliceId = AccountId.fromString(process.env.ALICE_ID);
const aliceKey = PrivateKey.fromString(process.env.ALICE_KEY);
const aliceKey = PrivateKey.fromStringDer(process.env.ALICE_KEY);
const bobId = AccountId.fromString(process.env.BOB_ID);
const bobKey = PrivateKey.fromString(process.env.BOB_KEY);
const bobKey = PrivateKey.fromStringDer(process.env.BOB_KEY);
const nodes = {
"127.0.0.1:50211": new AccountId(3),
};
Expand Down
8 changes: 4 additions & 4 deletions examples/hts-nftP3-pause-freeze-wipe-delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ dotenv.config();

// Configure accounts and client, and generate needed keys
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
const treasuryId = AccountId.fromString(process.env.TREASURY_ID);
const treasuryKey = PrivateKey.fromString(process.env.TREASURY_KEY);
const treasuryKey = PrivateKey.fromStringDer(process.env.TREASURY_KEY);
const aliceId = AccountId.fromString(process.env.ALICE_ID);
const aliceKey = PrivateKey.fromString(process.env.ALICE_KEY);
const aliceKey = PrivateKey.fromStringDer(process.env.ALICE_KEY);
const bobId = AccountId.fromString(process.env.BOB_ID);
const bobKey = PrivateKey.fromString(process.env.BOB_KEY);
const bobKey = PrivateKey.fromStringDer(process.env.BOB_KEY);
const nodes = {
"127.0.0.1:50211": new AccountId(3),
};
Expand Down
2 changes: 1 addition & 1 deletion examples/lazy-create-transfer-tx.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const nodes = {
"127.0.0.1:50211": new AccountId(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/logger-functionalities.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
}

const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

let debugLogger = new Logger(LogLevel.Debug);
let infoLogger = new Logger(LogLevel.Info);
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-sig-offline.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function main() {

const client = Client.forName(process.env.HEDERA_NETWORK).setOperator(
AccountId.fromString(process.env.OPERATOR_ID),
PrivateKey.fromString(process.env.OPERATOR_KEY)
PrivateKey.fromStringDer(process.env.OPERATOR_KEY)
);

user1Key = PrivateKey.generate();
Expand Down
2 changes: 1 addition & 1 deletion examples/nft-add-remove-allowances.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);
const nodes = {
"127.0.0.1:50211": new AccountId(3),
};
Expand Down
2 changes: 1 addition & 1 deletion examples/solidity-precompile-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function main() {
provider
);

const operatorPrivateKey = hashgraph.PrivateKey.fromString(
const operatorPrivateKey = hashgraph.PrivateKey.fromStringDer(
process.env.OPERATOR_KEY
);
const operatorPublicKey = operatorPrivateKey.publicKey;
Expand Down
2 changes: 1 addition & 1 deletion examples/time-drift.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function main() {

const client = Client.forName(process.env.HEDERA_NETWORK).setOperator(
AccountId.fromString(process.env.OPERATOR_ID),
PrivateKey.fromString(process.env.OPERATOR_KEY)
PrivateKey.fromStringDer(process.env.OPERATOR_KEY)
);

await sync();
Expand Down
2 changes: 1 addition & 1 deletion examples/topic-message-submit-get-all-chunks-status.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/transfer-using-evm-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function main() {
);
}
const operatorId = AccountId.fromString(process.env.OPERATOR_ID);
const operatorKey = PrivateKey.fromString(process.env.OPERATOR_KEY);
const operatorKey = PrivateKey.fromStringDer(process.env.OPERATOR_KEY);

const nodes = {
"127.0.0.1:50211": new AccountId(3),
Expand Down
2 changes: 1 addition & 1 deletion examples/zeroTokenOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function main() {
provider
);

const operatorPrivateKey = hashgraph.PrivateKey.fromString(
const operatorPrivateKey = hashgraph.PrivateKey.fromStringDer(
process.env.OPERATOR_KEY
);
const operatorPublicKey = operatorPrivateKey.publicKey;
Expand Down
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.37.0",
"version": "2.38.0",
"description": "Hedera™ Hashgraph SDK",
"types": "./lib/index.d.ts",
"main": "./lib/index.cjs",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/rlp": "^5.7.0",
"@grpc/grpc-js": "1.8.2",
"@hashgraph/cryptography": "1.4.8-beta.3",
"@hashgraph/cryptography": "1.4.8-beta.4",
"@hashgraph/proto": "2.14.0-beta.2",
"axios": "^1.3.1",
"bignumber.js": "^9.1.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/cryptography/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hashgraph/cryptography",
"version": "1.4.8-beta.3",
"version": "1.4.8-beta.4",
"description": "Cryptographic utilities and primitives for the Hedera™ Hashgraph SDK",
"main": "./lib/index.cjs",
"types": "./lib/index.d.ts",
Expand Down
7 changes: 7 additions & 0 deletions packages/cryptography/src/PrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ export default class PrivateKey extends Key {
*/
static fromBytes(data) {
let message;

if (data.length == 32) {
console.warn(
"WARNING: Consider using fromStringECDSA() or fromStringED2551() on a HEX-encoded string and fromStringDer() on a HEX-encoded string with DER prefix instead.",
);
}

try {
return new PrivateKey(Ed25519PrivateKey.fromBytes(data));
} catch (error) {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions src/PrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,10 @@ export default class PrivateKey extends Key {
* @deprecated - Use fromStringECDSA() or fromStringED2551() on a HEX-encoded string
* and fromStringDer() on a HEX-encoded string with DER prefix instead.
* Construct a private key from a hex-encoded string. Requires DER header.
*
* @param {string} text
* @returns {PrivateKey}
*/
static fromString(text) {
console.warn(
"WARNING: Consider using fromStringECDSA() or fromStringED2551() on a HEX-encoded string and fromStringDer() on a HEX-encoded string with DER prefix instead."
);
return new PrivateKey(cryptography.PrivateKey.fromString(text));
}

Expand Down
4 changes: 3 additions & 1 deletion src/Wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ import * as util from "./util.js";
*/
export default class Wallet {
/**
* NOTE: When using string for private key, the string needs to contain DER headers
*
* @param {AccountId | string} accountId
* @param {PrivateKey | string} privateKey
* @param {Provider=} provider
*/
constructor(accountId, privateKey, provider) {
const key =
typeof privateKey === "string"
? PrivateKey.fromString(privateKey)
? PrivateKey.fromStringDer(privateKey)
: privateKey;

this.publicKey = key.publicKey;
Expand Down
3 changes: 2 additions & 1 deletion src/client/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export default class Client {

/**
* Set the account that will, by default, pay for transactions and queries built with this client.
* NOTE: When using string for private key, the string needs to contain DER headers
*
* @param {AccountId | string} accountId
* @param {PrivateKey | string} privateKey
Expand All @@ -288,7 +289,7 @@ export default class Client {
setOperator(accountId, privateKey) {
const key =
typeof privateKey === "string"
? PrivateKey.fromString(privateKey)
? PrivateKey.fromStringDer(privateKey)
: privateKey;

return this.setOperatorWith(accountId, key.publicKey, (message) =>
Expand Down
10 changes: 5 additions & 5 deletions test/unit/EcdsaPrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("EcdsaPrivateKey", function () {
});

it("fromStringRaw and fromStringDer work", function () {
PrivateKey.fromString(
PrivateKey.fromStringDer(
hex.encode(PrivateKey.fromStringECDSA(RAW_KEY).toBytesDer())
);
});
Expand Down Expand Up @@ -328,25 +328,25 @@ describe("EcdsaPrivateKey", function () {
const PUBLIC_KEY4 =
"03b69a75a5ddb1c0747e995d47555019e5d8a28003ab5202bd92f534361fb4ec8a";

const ecdsaPrivateKey1 = PrivateKey.fromString(PRIVATE_KEY_DER1);
const ecdsaPrivateKey1 = PrivateKey.fromStringDer(PRIVATE_KEY_DER1);
expect(ecdsaPrivateKey1.toStringRaw()).to.be.equal(PRIVATE_KEY1);
expect(ecdsaPrivateKey1.publicKey.toStringRaw()).to.be.equal(
PUBLIC_KEY1
);

const ecdsaPrivateKey2 = PrivateKey.fromString(PRIVATE_KEY_DER2);
const ecdsaPrivateKey2 = PrivateKey.fromStringDer(PRIVATE_KEY_DER2);
expect(ecdsaPrivateKey2.toStringRaw()).to.be.equal(PRIVATE_KEY2);
expect(ecdsaPrivateKey2.publicKey.toStringRaw()).to.be.equal(
PUBLIC_KEY2
);

const ecdsaPrivateKey3 = PrivateKey.fromString(PRIVATE_KEY_DER3);
const ecdsaPrivateKey3 = PrivateKey.fromStringDer(PRIVATE_KEY_DER3);
expect(ecdsaPrivateKey3.toStringRaw()).to.be.equal(PRIVATE_KEY3);
expect(ecdsaPrivateKey3.publicKey.toStringRaw()).to.be.equal(
PUBLIC_KEY3
);

const ecdsaPrivateKey4 = PrivateKey.fromString(PRIVATE_KEY_DER4);
const ecdsaPrivateKey4 = PrivateKey.fromStringDer(PRIVATE_KEY_DER4);
expect(ecdsaPrivateKey4.toStringRaw()).to.be.equal(PRIVATE_KEY4);
expect(ecdsaPrivateKey4.publicKey.toStringRaw()).to.be.equal(
PUBLIC_KEY4
Expand Down
6 changes: 3 additions & 3 deletions test/unit/Ed25519PrivateKey.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ describe("Ed25519PrivateKey", function () {
await PrivateKey.generateED25519Async();
});

it("fromStringRaw and fromStringDer work", function () {
PrivateKey.fromString(
it("fromStringDer works", function () {
PrivateKey.fromStringDer(
hex.encode(PrivateKey.fromStringED25519(RAW_KEY).toBytesDer())
);
});
Expand Down Expand Up @@ -263,7 +263,7 @@ describe("Ed25519PrivateKey", function () {
var PUBLIC_KEY1 =
"8ccd31b53d1835b467aac795dab19b274dd3b37e3daf12fcec6bc02bac87b53d";

var ed25519PrivateKey1 = PrivateKey.fromString(PRIVATE_KEY_DER1);
var ed25519PrivateKey1 = PrivateKey.fromStringDer(PRIVATE_KEY_DER1);
expect(ed25519PrivateKey1.toStringRaw()).to.be.equal(PRIVATE_KEY1);
expect(ed25519PrivateKey1.publicKey.toStringRaw()).to.be.equal(
PUBLIC_KEY1
Expand Down
Loading

0 comments on commit 2b7d727

Please sign in to comment.