Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Address with sdk-specs, as much as possible (without breaking changes) #448

Merged
merged 11 commits into from
May 27, 2024

Conversation

andreibancioiu
Copy link
Contributor

@andreibancioiu andreibancioiu commented May 14, 2024

@andreibancioiu andreibancioiu self-assigned this May 14, 2024
@andreibancioiu andreibancioiu marked this pull request as ready for review May 14, 2024 11:56
@@ -8,6 +8,7 @@ import { TransactionBuilder } from "./transactionBuilder";

interface IConfig {
chainID: string;
addressHrp: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negligible breaking change.

@@ -13,6 +13,7 @@ import { TransactionBuilder } from "./transactionBuilder";

interface IConfig {
chainID: string;
addressHrp: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negligible breaking change.

@@ -8,6 +8,7 @@ import { TransactionBuilder } from "./transactionBuilder";

interface IConfig {
chainID: string;
addressHrp: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negligible breaking change.

@@ -140,7 +165,7 @@ export class Address {
const prefix = decoded?.prefix;
const pubkey = decoded ? Buffer.from(bech32.fromWords(decoded.words)) : undefined;

if (prefix !== HRP || pubkey?.length !== PUBKEY_LENGTH) {
if (prefix !== LibraryConfig.DefaultAddressHrp || pubkey?.length !== PUBKEY_LENGTH) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the address considered not valid if the hrp is different than the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question!

In order to avoid a breaking change with respect to the behavior of isValid (public method). We will change this in the future (a major version).

@@ -83,7 +86,7 @@ export class TokenManagementTransactionsFactory {
return new TransactionBuilder({
config: this.config,
sender: options.sender,
receiver: Address.fromBech32(ESDT_CONTRACT_ADDRESS),
receiver: Address.fromHex(ESDT_CONTRACT_ADDRESS_HEX, this.config.addressHrp),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this.esdtContractAddress

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

popenta
popenta previously approved these changes May 27, 2024
danielailie
danielailie previously approved these changes May 27, 2024
@andreibancioiu andreibancioiu dismissed stale reviews from danielailie and popenta via 734c042 May 27, 2024 11:17
@andreibancioiu andreibancioiu merged commit 1e2ee14 into main May 27, 2024
1 check passed
@andreibancioiu andreibancioiu deleted the custom-hrp branch May 27, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants