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

🧠 Logic: 📪 bech32_address/2 predicate #297

Merged
merged 9 commits into from
Feb 28, 2023
Merged

Conversation

bdeneux
Copy link
Contributor

@bdeneux bdeneux commented Feb 22, 2023

Implement #295 :

📝 Purpose

In the logic module, purpose an utility function to manipulate bech32 address.

🧪 Expected behavior

bech32_address/2 is a predicate that convert a bech32 encoded string into base64 bytes and give the address prefix or convert a prefix and base64 encoded bytes to bech32 encoded string. The signature is as follow:

bech32_address(-Address, +Bech32)
bech32_address(+Address, -Bech32)
bech32_address(+Address, +Bech32)

Where:

  • Address is a pair containing HRP (Human-Readable Part) containing the address prefix and the list of integers between 0 and 255 (byte) that represent the base64 encoded bech32 address string. Represented like this : -(HRP, Address)
  • Bech32 is an Atom or string representing the bech32 encoded string address

🎯 Example

bech32_address(-(Hrp, Address), 'okp415wn30a9z4uc692s0kkx5fp5d4qfr3ac7sj9dqn').

Give :

{
    "Hrp":     "okp4",
    "Address": "[163,167,23,244,162,175,49,162,170,15,181,141,68,134,141,168,18,56,247,30]",
}

@bdeneux bdeneux changed the title 🧠 Logic: bech32_address/3 predicate 🧠 Logic: 📪 bech32_address/3 predicate Feb 22, 2023
@bdeneux bdeneux linked an issue Feb 22, 2023 that may be closed by this pull request
3 tasks
@bdeneux bdeneux changed the title 🧠 Logic: 📪 bech32_address/3 predicate 🧠 Logic: 📪 bech32_address/2 predicate Feb 23, 2023
@bdeneux bdeneux marked this pull request as ready for review February 23, 2023 09:19
@bdeneux bdeneux requested review from amimart and ccamel February 23, 2023 09:30
@bdeneux bdeneux self-assigned this Feb 23, 2023
Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

The implementation is quite good! Thanks for the job. ☺️

However, I have a few concerns about the error messages, their consistency (especially in relation to other predicates), and their formalization. But I think we can address this in a second step.

It would also be helpful to provide a thorough description of this predicate, as the generated documentation will be very useful for understanding the predicates supported by the module.

x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
x/logic/predicate/address.go Outdated Show resolved Hide resolved
@bdeneux bdeneux requested a review from ccamel February 23, 2023 14:54
Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

Great job! Thanks 😎

Copy link
Member

@amimart amimart left a comment

Choose a reason for hiding this comment

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

Great! 💪

@bdeneux bdeneux merged commit 7330922 into main Feb 28, 2023
@bdeneux bdeneux deleted the feat/logic-bech32 branch February 28, 2023 06:12
@bot-anik
Copy link
Member

🎉 This PR is included in version 4.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

🧠 Logic: 📪 bech32_address/2 predicate
4 participants