Skip to content

Add TokensByOwner for cw721-base#122

Merged
ethanfrey merged 12 commits intosecondary-indexesfrom
tokens-by-owner
Oct 16, 2020
Merged

Add TokensByOwner for cw721-base#122
ethanfrey merged 12 commits intosecondary-indexesfrom
tokens-by-owner

Conversation

@ethanfrey
Copy link
Copy Markdown
Contributor

@ethanfrey ethanfrey commented Oct 13, 2020

Closes #81

Builds on #108 (merge that first)

Ports to use cw-storage-plus rather than cosmwasm-storage, then makes use of IndexedMap

  • Port to cw-storage-plus
  • Better support for &str Map keys
  • Use IndexedMap
  • Enable query by owner
  • Cover query by owner with tests
  • Allow setting bounds (pagination)
  • Raise issues for remaining TODOs

Copy link
Copy Markdown
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

Looks good. I think the use of bounds is still a little bit confusing / needlessly complex.

Added some comments to try and help clarifying the design.

@ethanfrey
Copy link
Copy Markdown
Contributor Author

My takeaways. Only use one type:

pub enum Bound {
  Inclusive(Vec<u8>),
  Exclusive(Vec<u8>)
}

and accept Option<Bound> in range.

This will lead to lines like:

`let start: Option = start_after.map(|human| Ok(Bound::Exclusive(deps.api.canonical_addr(&human)?)).transpose()?;

Which is not so legible or user-friendly. I guess having a function for handling the human_addr case is good. For a string/int, we could get:

let start: Option<Bound> = start_after.map(|s| Bound::Exclusive(s.into()))

or

let start: Option<Bound> = start_after.map(|i| Bound::Exclusive(i.to_be_bytes().into()))

both of which are simple enough, without all these helpers.


Does the above make sense to you? Other suggestion?

@maurolacy
Copy link
Copy Markdown
Contributor

Makes sense. Will review later again with the IDE, to see and try some variants.

Copy link
Copy Markdown
Contributor

@maurolacy maurolacy left a comment

Choose a reason for hiding this comment

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

I understand this is WIP, but what I see looks good to me.

Powerful stuff here, and in the storage-plus.

@ethanfrey ethanfrey mentioned this pull request Oct 16, 2020
@ethanfrey ethanfrey merged commit 234b937 into secondary-indexes Oct 16, 2020
@ethanfrey ethanfrey deleted the tokens-by-owner branch October 16, 2020 17:27
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.

2 participants