-
Notifications
You must be signed in to change notification settings - Fork 37
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
Conversation
@@ -8,6 +8,7 @@ import { TransactionBuilder } from "./transactionBuilder"; | |||
|
|||
interface IConfig { | |||
chainID: string; | |||
addressHrp: string; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use this.esdtContractAddress
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Address
with the specs, as much as possible (but avoid breaking changes): https://github.com/multiversx/mx-sdk-specs/blob/main/core/address.md.ensureValidTransactionFields
, drop the logic that checks address length