-
Notifications
You must be signed in to change notification settings - Fork 367
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
Conversation
0xaptosj
commented
Oct 19, 2023
•
edited
Loading
edited
- setup ci to test move code
- add publish script
- displaying all aptogotchi holders to demonstrate indexer usage (probably need to update the ui to make it more friendly)
- make get aptogotchi address a view function so we can call it to get token data then collection data.
} | ||
`, | ||
variables: { | ||
collection_id: collectionResponse.collection_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.
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 |
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.
Is it possible to handle this properly?
0aa8380
to
3bc2e80
Compare
frontend/src/app/home/Connected.tsx
Outdated
const { account, network } = useWallet(); | ||
|
||
const fetchPet = useCallback(async () => { | ||
if (!account?.address) return; | ||
|
||
const payload = { | ||
const getAptogotchiPayload = { |
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.
nit: inline to L25 if this variable isn't being used anywhere else
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.
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
const noPet = ["", "0", "0", "0x"]; | ||
|
||
if (JSON.stringify(response) !== JSON.stringify(noPet)) { | ||
if (JSON.stringify(aptogotchiResponse) !== JSON.stringify(noPet)) { |
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.
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
frontend/src/app/home/Connected.tsx
Outdated
.split("0") | ||
.slice(2) | ||
.map(Number), | ||
}); | ||
} | ||
}, [account?.address]); | ||
|
||
const fetchCollectionID = useCallback(async () => { |
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.
nit: I would inline this function into L66 if it's the only place used.
frontend/src/app/home/Connected.tsx
Outdated
|
||
const aptogotchiCollectionIDResponse = (await provider.view( | ||
getAptogotchiCollectionIDPayload | ||
)) as string[]; |
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.
more tight typing if it as [string]
or [0x${string}
]
const [collectionHolders, setCollectionHolders] = | ||
useState<CollectionHolder[]>(); | ||
|
||
const fetchCollection = useCallback(async () => { |
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.
nit: can also be inlined
frontend/src/app/home/Connected.tsx
Outdated
const { account, network } = useWallet(); | ||
|
||
const fetchPet = useCallback(async () => { | ||
if (!account?.address) return; | ||
|
||
const payload = { | ||
const getAptogotchiPayload = { |
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.
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.