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
Conversation
lib/ae_mdw/contract.ex
Outdated
{:ok, {:id, :contract, pubkey}} -> | ||
pubkey | ||
|
||
{:error, _} -> |
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.
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
lib/ae_mdw/contract.ex
Outdated
"contract_pubkey" | ||
|> :aec_chain.resolve_namehash(name_pk) | ||
|> case do | ||
{:ok, {:id, :contract, pubkey}} -> |
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.
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)
3b5db43
to
043638c
Compare
043638c
to
066925e
Compare
04a0007
to
a48729d
Compare
lib/ae_mdw/db/name.ex
Outdated
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) |
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.
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?
Depends on #1708 since it's branched out from it