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

feat: resolve aens name to contract address when calling contract #1710

Merged
merged 9 commits into from Apr 4, 2024

Conversation

yaboiishere
Copy link
Contributor

@yaboiishere yaboiishere commented Mar 22, 2024

Depends on #1708 since it's branched out from it

@yaboiishere yaboiishere self-assigned this Mar 22, 2024
@yaboiishere yaboiishere marked this pull request as ready for review March 26, 2024 13:16
@yaboiishere yaboiishere requested review from sborrazas and removed request for sborrazas March 26, 2024 13:17
{:ok, {:id, :contract, pubkey}} ->
pubkey

{:error, _} ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why credo didn't catch this but unused variables should contain a reference to what it actually is (_reason in this case). But maybe it would be even better to include the reason as part of the error being raised

"contract_pubkey"
|> :aec_chain.resolve_namehash(name_pk)
|> case do
{:ok, {:id, :contract, pubkey}} ->
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid exposing the aeser_id structure and instead use the getters to retrieve the value? Something like

{:ok, contract_id} -> :aeser_id.specialize(contract_id, :contract)

@yaboiishere yaboiishere marked this pull request as draft March 29, 2024 09:14
Base automatically changed from ceres-raw-data-pointers to master April 2, 2024 13:00
@yaboiishere yaboiishere marked this pull request as ready for review April 2, 2024 13:21
def ptr_resolve(state, block_index, name_hash, pointer_key) do
with {:ok, id} <-
:aens.resolve_hash(pointer_key, name_hash, ns_tree!(state, block_index)) do
Validate.id(id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate.id/1 might return {:error, Error.Id}, which isn't what ptr_resolve returns here. Since we know it's a valid ID we don't need to validate, and we can use :aeser_id.specialize instead, right?

@sborrazas sborrazas merged commit 65575cb into master Apr 4, 2024
7 checks passed
@sborrazas sborrazas deleted the ceres-call-contract-name branch April 4, 2024 10:54
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.

None yet

2 participants