-
Notifications
You must be signed in to change notification settings - Fork 10
createCollection() SDK method #121
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
Conversation
| // Sharing methods | ||
| export type { CreateCollectionResponse } from "./sharing/createCollection.js" |
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.
Trying something here to slow down this file growth: the method file will own its types, just re-exporting them here.
| export type CreateCollectionResponse = { | ||
| collectionId: AddressOrENS; | ||
| }; |
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.
Trying something here to slow down types.ts file growth: the method file will own its types as we can see here.
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 aggree, maybe extracting common types in from types from types.ts to avoid circular imports
flowchart
TYPES(types.ts) --> COMMON(common-types.ts)
MODULE_1(createCollection.ts) --> COMMON
TYPES --> MODULE_1
MODULE_2(xxx.ts) --> COMMON
TYPES --> MODULE_2
PierreJeanjacquot
left a comment
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.
good job, see the comments for improvement suggestions
| export type CreateCollectionResponse = { | ||
| collectionId: AddressOrENS; | ||
| }; |
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 aggree, maybe extracting common types in from types from types.ts to avoid circular imports
flowchart
TYPES(types.ts) --> COMMON(common-types.ts)
MODULE_1(createCollection.ts) --> COMMON
TYPES --> MODULE_1
MODULE_2(xxx.ts) --> COMMON
TYPES --> MODULE_2
| const mintedTokenId = transactionReceipt.logs.find( | ||
| ({ eventName }) => eventName === 'Transfer' | ||
| )?.args[2]; | ||
|
|
||
| return { | ||
| collectionId: mintedTokenId, | ||
| }; |
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.
As tokenid is an uint256 in the ABI mintedTokenId is going to be a bigint. Assuming we are using a sequence for collectionIds, we can safely cast it into a number that will fit into safe integers.
| const mintedTokenId = transactionReceipt.logs.find( | |
| ({ eventName }) => eventName === 'Transfer' | |
| )?.args[2]; | |
| return { | |
| collectionId: mintedTokenId, | |
| }; | |
| const mintedTokenId = transactionReceipt.logs.find( | |
| ({ eventName }) => eventName === 'Transfer' | |
| )?.args[2]; | |
| return { | |
| collectionId: Number(mintedTokenId), | |
| }; |
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.
Would it make sense to add as bigint line 37 to better understand the Number casting line 40?
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.
yes! It will make it clearer
No description provided.