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

display all aptogotchi holders to demonstrate indexer usage #26

Merged
merged 7 commits into from
Oct 20, 2023

Conversation

0xaptosj
Copy link
Contributor

@0xaptosj 0xaptosj commented Oct 19, 2023

  1. setup ci to test move code
  2. add publish script
  3. displaying all aptogotchi holders to demonstrate indexer usage (probably need to update the ui to make it more friendly)
  4. make get aptogotchi address a view function so we can call it to get token data then collection data.
Screenshot 2023-10-18 at 6 50 19 PM

@0xaptosj 0xaptosj requested review from angieyth, darren-wangg, blakezimmerman and 0xZihan and removed request for angieyth and darren-wangg October 19, 2023 01:52
@0xaptosj 0xaptosj changed the title use displaying aptogotchi holders to demonstrate indexer usage display all aptogotchi holders to demonstrate indexer usage Oct 19, 2023
move/Move.toml Show resolved Hide resolved
}
`,
variables: {
collection_id: collectionResponse.collection_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

can collection_id be queried from a view function in the contract? it's never gonna change so doesn't seem clean to query it every time with the token address.

console.log(JSON.stringify(tokenDataResponse, null, 2));
console.log(
JSON.stringify(
// @ts-ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to handle this properly?

const { account, network } = useWallet();

const fetchPet = useCallback(async () => {
if (!account?.address) return;

const payload = {
const getAptogotchiPayload = {

Choose a reason for hiding this comment

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

nit: inline to L25 if this variable isn't being used anywhere else

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel it's kinda nice to give a name to it to improve readability. But maybe I missed some benefit of making it inline.

const noPet = ["", "0", "0", "0x"];

if (JSON.stringify(response) !== JSON.stringify(noPet)) {
if (JSON.stringify(aptogotchiResponse) !== JSON.stringify(noPet)) {

Choose a reason for hiding this comment

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

We shouldn't stringify just to do a comparison. We should compare named values so that it's more readable.

For example:

const [name, birthday, energyPoints, parts) = await provider.view(getAptogotchiPayload);
const noPet = {name: "", birthday: 0, energyPoints: 0, parts: 0x};
if (birthday !== noPet.birthday) {
...
}
if (aptogotchiResponse

.split("0")
.slice(2)
.map(Number),
});
}
}, [account?.address]);

const fetchCollectionID = useCallback(async () => {

Choose a reason for hiding this comment

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

nit: I would inline this function into L66 if it's the only place used.


const aptogotchiCollectionIDResponse = (await provider.view(
getAptogotchiCollectionIDPayload
)) as string[];

Choose a reason for hiding this comment

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

more tight typing if it as [string] or [0x${string}]

const [collectionHolders, setCollectionHolders] =
useState<CollectionHolder[]>();

const fetchCollection = useCallback(async () => {

Choose a reason for hiding this comment

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

nit: can also be inlined

frontend/src/utils/address.ts Outdated Show resolved Hide resolved
const { account, network } = useWallet();

const fetchPet = useCallback(async () => {
if (!account?.address) return;

const payload = {
const getAptogotchiPayload = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel it's kinda nice to give a name to it to improve readability. But maybe I missed some benefit of making it inline.

frontend/src/app/home/Connected.tsx Outdated Show resolved Hide resolved
@0xaptosj 0xaptosj requested a review from 0xZihan October 19, 2023 21:37
@0xaptosj 0xaptosj merged commit 656b3fa into main Oct 20, 2023
1 check passed
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