Skip to content

improve(Address): Support new Address from nontraditional encoding #974

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pxrl
Copy link
Contributor

@pxrl pxrl commented Apr 8, 2025

SVM events emit addresses with base58-encoding. At least two addresses emitted within an FundsDeposited or FilledRelay event will need to be converted to a base16 EVM address. Make it easy by permitting the caller of EvmAddress.from() to specify the encoding, defaulting to base16. Also do the same for the SVM side (i.e. permit base16-encoded 32-byte addresses).

SVM events emit addresses with base58-encoding. At least two addresses
emitted within an FundsDeposited or FilledRelay event will need to be
converted to a base16 EVM address. Make it easy by permitting the caller
of EvmAddress.from() to specify the encoding, defaulting to base16.
@pxrl pxrl changed the title improve(Address): Support new EVM address from Base58 encoding improve(Address): Support new Address from nontraditional encoding Apr 9, 2025
@@ -223,8 +223,20 @@ export class EvmAddress extends Address {
}

// Constructs a new EvmAddress type.
static from(hexString: string): EvmAddress {
return new this(utils.arrayify(hexString));
static from(address: string, encoding: "base16" | "base58" = "base16"): EvmAddress {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nb. We have the option of inferring the encoding with a regex. That'd definitely be a UX improvement...not sure if we want to go there though.

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