-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
chore: Address
constructor now accepts a range of inputs.
#3600
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Address
constructor now accepts a range of inputs.
Opened this PR early (need to update documentation, etc), just to ensure this is the direction we wish to pursue. Does anyone have any issues with this approach? cc @FuelLabs/sdk-ts @LuizAsFight |
@@ -240,8 +221,7 @@ export class Address { | |||
); | |||
} | |||
|
|||
const paddedAddress = padFirst12BytesOfEvmAddress(evmAddress); | |||
return new Address(paddedAddress); | |||
return new Address(evmAddress); |
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.
I don't understand why we'd want to have the Address
class represent anything but a fuel-compatible address. It seems more appropriate to me that we differentiate between an Address
and an EvmAddress
, the same way Sway does it.
@LuizAsFight @luizstacio What are your thoughts here?
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.
@nedsalk I believe this is done for simplicity since on Fuel an EVM address is represented the same way as Fuel addresses, using 32 bytes. The difference is that an EVM address is padded with zeros to make it 32 bytes.
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.
Great job @petertonysmith94 🚀
* | ||
* @param publicKey - A wallets public key | ||
* @returns A new `Address` instance | ||
* | ||
* @deprecated Use `new Address` instead | ||
*/ | ||
static fromPublicKey(publicKey: string): Address { | ||
if (!isPublicKey(publicKey)) { | ||
throw new FuelError(FuelError.CODES.INVALID_PUBLIC_KEY, `Invalid Public Key: ${publicKey}.`); | ||
} | ||
|
||
const b256Address = hexlify(sha256(arrayify(publicKey))); | ||
const b256Address = fromPublicKeyToB256(publicKey); |
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.
@petertonysmith94 Should we update the docs to conform with these new guidelines?
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.
@Torres-ssf as stated in the comment, opened this early to get feedback/confirmation to proceed.
If we're happy with the approach, I will finalise the documentation + update references :)
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.
Coverage Report:
Changed Files:
|
Addressed documentation.
Address
DX #3598Release notes
In this release, we:
Address
constructor now accepts a range of different inputsSummary
Address
constructor now accepts a range of inputs:Address
instanceB256
stringEVM
address stringChecklist