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

refactor: generalize aexn create contract mutation #699

Merged
merged 5 commits into from
Jun 3, 2022

Conversation

jyeshe
Copy link
Member

@jyeshe jyeshe commented Jun 1, 2022

What

  • Generalize creation of AEX-N contract (aex9, aex141, ...)
  • Detect NFT contracts

Why

Refs #629

This PR indexes data that allows listing NFT contracts along with metainfo and with the known pubkeys interact with them to provide endpoints such as NFT owner, owner balance, etc.

Validation steps

Unit tests

elixir --sname aeternity@localhost -S mix test test/ae_mdw/db/sync/contract_test.exs
elixir --sname aeternity@localhost -S mix test test/ae_mdw/db/sync/transaction_test.exs
elixir --sname aeternity@localhost -S mix test test/ae_mdw/db/aexn_create_contract_mutation_test.exs

Sync tests

  1. Delete a contract by running on iex -S mix:
    iex(aeternity@localhost)1> pk = AeMdw.Db.Origin.pubkey({:contract, 4072415}); Database.dirty_delete(Model.AexnContract, {:aex9, pk})
  2. Rename the migration mv priv/migrations/20220506104325_reprocess_contract_txs.ex priv/migrations/20220601104325_reprocess_contract_txs.ex
  3. Change line 31 to: do_migrate(first_kbi..(first_kbi + 10))
  4. Put an underscore on unused variable at line 27: _last_kbi
  5. Run the iex -S mix to run the migration
  6. Check contract creation with:
iex(aeternity@localhost)1> pk = AeMdw.Db.Origin.pubkey({:contract, 4072415}); Database.read(Model.AexnContract, {:aex9, pk})        
[
  {:aexn_contract,
   {:aex9,
    <<40, 189, 109, 123, 71, 195, 48, 205, 12, 53, 140, 168, 137, 35, 40, 4,
      104, 189, 96, 192, 213, 164, 48, 203, 240, 42, 163, 44, 94, 202, 204,
      232>>}, 4072415, {"Test", "TT", 0}}
]

@jyeshe jyeshe self-assigned this Jun 1, 2022
commit 93d48d3
Author: Rogerio Pontual <rppontual@gmail.com>
Date:   Tue May 31 15:02:11 2022 +0100

    fix: remove nil from spec

commit 116ef5d
Author: Rogerio Pontual <rppontual@gmail.com>
Date:   Tue May 31 14:33:09 2022 +0100

    fix: handle update aex9 state on contract create logs
@jyeshe jyeshe marked this pull request as ready for review June 1, 2022 11:26
@jyeshe jyeshe requested review from sborrazas and thepiwo June 1, 2022 11:26
@jyeshe jyeshe merged commit 57c0070 into master Jun 3, 2022
@jyeshe jyeshe deleted the aexn-create-mutation branch June 3, 2022 13:31
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