diff --git a/bindings/nodejs/CHANGELOG.md b/bindings/nodejs/CHANGELOG.md index f1ac21596a..399e260f7b 100644 --- a/bindings/nodejs/CHANGELOG.md +++ b/bindings/nodejs/CHANGELOG.md @@ -21,12 +21,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 1.0.2 - 2023-MM-DD +### Changed + +- Private properties on classes are now readonly; + ### Fixed - Constructor types in `RegularTransactionEssence`; - `SenderFeature.getSender()` and `IssuerFeature.getIssuer()` now return the correct types; - ## 1.0.1 - 2023-07-25 ### Changed diff --git a/bindings/nodejs/lib/types/block/address.ts b/bindings/nodejs/lib/types/block/address.ts index e011adc1e7..ff3da06b8b 100644 --- a/bindings/nodejs/lib/types/block/address.ts +++ b/bindings/nodejs/lib/types/block/address.ts @@ -12,7 +12,7 @@ enum AddressType { } abstract class Address { - private type: AddressType; + readonly type: AddressType; constructor(type: AddressType) { this.type = type; @@ -44,7 +44,7 @@ abstract class Address { * Ed25519 Address. */ class Ed25519Address extends Address { - private pubKeyHash: HexEncodedString; + readonly pubKeyHash: HexEncodedString; constructor(address: HexEncodedString) { super(AddressType.Ed25519); @@ -63,7 +63,7 @@ class Ed25519Address extends Address { } class AliasAddress extends Address { - private aliasId: AliasId; + readonly aliasId: AliasId; constructor(address: AliasId) { super(AddressType.Alias); this.aliasId = address; @@ -83,7 +83,7 @@ class AliasAddress extends Address { * NFT address. */ class NftAddress extends Address { - private nftId: NftId; + readonly nftId: NftId; constructor(address: NftId) { super(AddressType.Nft); this.nftId = address; diff --git a/bindings/nodejs/lib/types/block/input/input.ts b/bindings/nodejs/lib/types/block/input/input.ts index 9f4a2c4210..661d737be8 100644 --- a/bindings/nodejs/lib/types/block/input/input.ts +++ b/bindings/nodejs/lib/types/block/input/input.ts @@ -14,7 +14,7 @@ enum InputType { } abstract class Input { - private type: InputType; + readonly type: InputType; constructor(type: InputType) { this.type = type; diff --git a/bindings/nodejs/lib/types/block/output/feature.ts b/bindings/nodejs/lib/types/block/output/feature.ts index dca61347f4..41a042b82f 100644 --- a/bindings/nodejs/lib/types/block/output/feature.ts +++ b/bindings/nodejs/lib/types/block/output/feature.ts @@ -15,7 +15,8 @@ enum FeatureType { } abstract class Feature { - private type: FeatureType; + readonly type: FeatureType; + constructor(type: FeatureType) { this.type = type; } @@ -33,7 +34,8 @@ class SenderFeature extends Feature { @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; + constructor(sender: Address) { super(FeatureType.Sender); this.address = sender; @@ -52,7 +54,8 @@ class IssuerFeature extends Feature { @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; + constructor(issuer: Address) { super(FeatureType.Issuer); this.address = issuer; @@ -68,7 +71,8 @@ class IssuerFeature extends Feature { * Metadata feature. */ class MetadataFeature extends Feature { - private data: string; + readonly data: string; + constructor(data: string) { super(FeatureType.Metadata); this.data = data; @@ -84,7 +88,8 @@ class MetadataFeature extends Feature { * Tag feature. */ class TagFeature extends Feature { - private tag: string; + readonly tag: string; + constructor(tag: string) { super(FeatureType.Tag); this.tag = tag; diff --git a/bindings/nodejs/lib/types/block/output/output.ts b/bindings/nodejs/lib/types/block/output/output.ts index 8186236c4b..b7ba62f3cc 100644 --- a/bindings/nodejs/lib/types/block/output/output.ts +++ b/bindings/nodejs/lib/types/block/output/output.ts @@ -27,9 +27,9 @@ enum OutputType { } abstract class Output /*implements ICommonOutput*/ { - private amount: string; + readonly amount: string; - private type: OutputType; + readonly type: OutputType; constructor(type: OutputType, amount: bigint | string) { this.type = type; @@ -80,14 +80,14 @@ abstract class CommonOutput extends Output /*implements ICommonOutput*/ { @Type(() => UnlockCondition, { discriminator: UnlockConditionDiscriminator, }) - private unlockConditions: UnlockCondition[]; + readonly unlockConditions: UnlockCondition[]; - private nativeTokens?: INativeToken[]; + readonly nativeTokens?: INativeToken[]; @Type(() => Feature, { discriminator: FeatureDiscriminator, }) - private features?: Feature[]; + readonly features?: Feature[]; constructor( type: OutputType, @@ -149,7 +149,7 @@ abstract class ImmutableFeaturesOutput extends CommonOutput { @Type(() => Feature, { discriminator: FeatureDiscriminator, }) - private immutableFeatures?: Feature[]; + readonly immutableFeatures?: Feature[]; constructor( type: OutputType, @@ -167,7 +167,7 @@ abstract class ImmutableFeaturesOutput extends CommonOutput { } abstract class StateMetadataOutput extends ImmutableFeaturesOutput /*implements IBasicOutput*/ { - private stateMetadata?: HexEncodedString; + readonly stateMetadata?: HexEncodedString; constructor( type: OutputType, @@ -185,9 +185,9 @@ abstract class StateMetadataOutput extends ImmutableFeaturesOutput /*implements } class AliasOutput extends StateMetadataOutput /*implements IAliasOutput*/ { - private aliasId: HexEncodedString; - private stateIndex: number; - private foundryCounter: number; + readonly aliasId: HexEncodedString; + readonly stateIndex: number; + readonly foundryCounter: number; constructor( unlockConditions: UnlockCondition[], @@ -225,7 +225,7 @@ class AliasOutput extends StateMetadataOutput /*implements IAliasOutput*/ { * NFT output. */ class NftOutput extends ImmutableFeaturesOutput /*implements INftOutput*/ { - private nftId: HexEncodedString; + readonly nftId: HexEncodedString; constructor( amount: bigint, @@ -247,12 +247,12 @@ class NftOutput extends ImmutableFeaturesOutput /*implements INftOutput*/ { * Foundry output. */ class FoundryOutput extends ImmutableFeaturesOutput /*implements IFoundryOutput*/ { - private serialNumber: number; + readonly serialNumber: number; @Type(() => TokenScheme, { discriminator: TokenSchemeDiscriminator, }) - private tokenScheme: TokenScheme; + readonly tokenScheme: TokenScheme; constructor( amount: bigint, diff --git a/bindings/nodejs/lib/types/block/output/token-scheme.ts b/bindings/nodejs/lib/types/block/output/token-scheme.ts index fd46c25cb6..0602ab43a2 100644 --- a/bindings/nodejs/lib/types/block/output/token-scheme.ts +++ b/bindings/nodejs/lib/types/block/output/token-scheme.ts @@ -8,7 +8,7 @@ enum TokenSchemeType { } abstract class TokenScheme { - private type: TokenSchemeType; + readonly type: TokenSchemeType; constructor(type: TokenSchemeType) { this.type = type; @@ -26,9 +26,9 @@ abstract class TokenScheme { * Simple token scheme. */ class SimpleTokenScheme extends TokenScheme { - private mintedTokens: bigint; - private meltedTokens: bigint; - private maximumSupply: bigint; + readonly mintedTokens: bigint; + readonly meltedTokens: bigint; + readonly maximumSupply: bigint; constructor( mintedTokens: bigint, diff --git a/bindings/nodejs/lib/types/block/output/unlock-condition.ts b/bindings/nodejs/lib/types/block/output/unlock-condition.ts index 6b3a8d2397..d6595e070e 100644 --- a/bindings/nodejs/lib/types/block/output/unlock-condition.ts +++ b/bindings/nodejs/lib/types/block/output/unlock-condition.ts @@ -18,7 +18,7 @@ enum UnlockConditionType { } abstract class UnlockCondition { - private type: UnlockConditionType; + readonly type: UnlockConditionType; constructor(type: UnlockConditionType) { this.type = type; @@ -75,7 +75,8 @@ class AddressUnlockCondition extends UnlockCondition /*implements IAddressUnlock @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; + constructor(address: Address) { super(UnlockConditionType.Address); this.address = address; @@ -92,12 +93,12 @@ class AddressUnlockCondition extends UnlockCondition /*implements IAddressUnlock * Storage Deposit Return Unlock Condition. */ class StorageDepositReturnUnlockCondition extends UnlockCondition /*implements IStorageDepositReturnUnlockCondition*/ { - private amount: string; + readonly amount: string; @Type(() => Address, { discriminator: AddressDiscriminator, }) - private returnAddress: Address; + readonly returnAddress: Address; constructor(returnAddress: Address, amount: bigint | string) { super(UnlockConditionType.StorageDepositReturn); @@ -126,7 +127,7 @@ class StorageDepositReturnUnlockCondition extends UnlockCondition /*implements I * Timelock Unlock Condition. */ class TimelockUnlockCondition extends UnlockCondition /*implements ITimelockUnlockCondition*/ { - private unixTime: number; + readonly unixTime: number; constructor(unixTime: number) { super(UnlockConditionType.Timelock); @@ -144,8 +145,8 @@ class ExpirationUnlockCondition extends UnlockCondition /*implements IExpiration @Type(() => Address, { discriminator: AddressDiscriminator, }) - private returnAddress: Address; - private unixTime: number; + readonly returnAddress: Address; + readonly unixTime: number; constructor(returnAddress: Address, unixTime: number) { super(UnlockConditionType.Expiration); @@ -174,7 +175,7 @@ class StateControllerAddressUnlockCondition extends UnlockCondition /*implements @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; constructor(address: Address) { super(UnlockConditionType.StateControllerAddress); this.address = address; @@ -194,7 +195,7 @@ class GovernorAddressUnlockCondition extends UnlockCondition /*implements IGover @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; constructor(address: Address) { super(UnlockConditionType.GovernorAddress); this.address = address; @@ -214,7 +215,8 @@ class ImmutableAliasAddressUnlockCondition extends UnlockCondition /*implements @Type(() => Address, { discriminator: AddressDiscriminator, }) - private address: Address; + readonly address: Address; + constructor(address: AliasAddress) { super(UnlockConditionType.ImmutableAliasAddress); this.address = address; diff --git a/bindings/nodejs/lib/types/block/payload/payload.ts b/bindings/nodejs/lib/types/block/payload/payload.ts index 82e85c9c37..f498600e47 100644 --- a/bindings/nodejs/lib/types/block/payload/payload.ts +++ b/bindings/nodejs/lib/types/block/payload/payload.ts @@ -16,7 +16,7 @@ enum PayloadType { } abstract class Payload { - private type: PayloadType; + readonly type: PayloadType; constructor(type: PayloadType) { this.type = type; diff --git a/bindings/nodejs/lib/types/block/payload/transaction/essence.ts b/bindings/nodejs/lib/types/block/payload/transaction/essence.ts index 297b8e6327..66fe8b00d2 100644 --- a/bindings/nodejs/lib/types/block/payload/transaction/essence.ts +++ b/bindings/nodejs/lib/types/block/payload/transaction/essence.ts @@ -16,7 +16,7 @@ enum TransactionEssenceType { } abstract class TransactionEssence { - private type: TransactionEssenceType; + readonly type: TransactionEssenceType; constructor(type: TransactionEssenceType) { this.type = type; diff --git a/bindings/nodejs/lib/types/block/payload/transaction/unlock.ts b/bindings/nodejs/lib/types/block/payload/transaction/unlock.ts index 0bfefd6a54..45b7f0f2ce 100644 --- a/bindings/nodejs/lib/types/block/payload/transaction/unlock.ts +++ b/bindings/nodejs/lib/types/block/payload/transaction/unlock.ts @@ -15,7 +15,7 @@ enum UnlockType { } abstract class Unlock { - private type: UnlockType; + readonly type: UnlockType; constructor(type: UnlockType) { this.type = type; diff --git a/bindings/nodejs/lib/types/block/signature.ts b/bindings/nodejs/lib/types/block/signature.ts index 9f7ec48d6a..bf7c811eaa 100644 --- a/bindings/nodejs/lib/types/block/signature.ts +++ b/bindings/nodejs/lib/types/block/signature.ts @@ -12,7 +12,7 @@ enum SignatureType { } abstract class Signature { - private type: SignatureType; + readonly type: SignatureType; constructor(type: SignatureType) { this.type = type; diff --git a/bindings/nodejs/lib/types/models/milestone_options/milestone-options.ts b/bindings/nodejs/lib/types/models/milestone_options/milestone-options.ts index d186737b4f..b094b12683 100644 --- a/bindings/nodejs/lib/types/models/milestone_options/milestone-options.ts +++ b/bindings/nodejs/lib/types/models/milestone_options/milestone-options.ts @@ -10,7 +10,7 @@ enum MilestoneOptionType { } abstract class MilestoneOption { - private type: MilestoneOptionType; + readonly type: MilestoneOptionType; constructor(type: MilestoneOptionType) { this.type = type; diff --git a/bindings/nodejs/lib/types/wallet/prepared-create-token-transaction.ts b/bindings/nodejs/lib/types/wallet/prepared-create-token-transaction.ts index 30ecb6623d..1eace7d6ff 100644 --- a/bindings/nodejs/lib/types/wallet/prepared-create-token-transaction.ts +++ b/bindings/nodejs/lib/types/wallet/prepared-create-token-transaction.ts @@ -9,7 +9,7 @@ import { PreparedTransaction } from './prepared-transaction'; * The class PreparedCreateNativeTokenTransaction represents prepared data for issuing a transaction to create a native token. */ export class PreparedCreateNativeTokenTransaction extends PreparedTransaction { - private _tokenId: string; + readonly _tokenId: string; constructor( preparedData: PreparedCreateNativeTokenTransactionData, diff --git a/bindings/nodejs/lib/types/wallet/prepared-transaction.ts b/bindings/nodejs/lib/types/wallet/prepared-transaction.ts index 00e5edacba..042b6ed75e 100644 --- a/bindings/nodejs/lib/types/wallet/prepared-transaction.ts +++ b/bindings/nodejs/lib/types/wallet/prepared-transaction.ts @@ -15,8 +15,8 @@ import { * the transaction and sign+submit/send the transaction. */ export class PreparedTransaction { - private _preparedData: PreparedTransactionData; - private _account: Account; + readonly _preparedData: PreparedTransactionData; + readonly _account: Account; constructor(preparedData: PreparedTransactionData, account: Account) { this._preparedData = preparedData;