Skip to content

Conversation

@cedric25
Copy link
Contributor

No description provided.

@cedric25 cedric25 self-assigned this Jan 16, 2024
@cedric25 cedric25 marked this pull request as ready for review January 16, 2024 15:06
@cedric25 cedric25 changed the title [WIP] Start createCollection() SDK method createCollection() SDK method Jan 16, 2024
Comment on lines 351 to 352
// Sharing methods
export type { CreateCollectionResponse } from "./sharing/createCollection.js"
Copy link
Contributor Author

@cedric25 cedric25 Jan 16, 2024

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.

Comment on lines 7 to 9
export type CreateCollectionResponse = {
collectionId: AddressOrENS;
};
Copy link
Contributor Author

@cedric25 cedric25 Jan 16, 2024

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.

Copy link
Member

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
Loading

Copy link
Member

@PierreJeanjacquot PierreJeanjacquot left a 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

Comment on lines 7 to 9
export type CreateCollectionResponse = {
collectionId: AddressOrENS;
};
Copy link
Member

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
Loading

Comment on lines 35 to 41
const mintedTokenId = transactionReceipt.logs.find(
({ eventName }) => eventName === 'Transfer'
)?.args[2];

return {
collectionId: mintedTokenId,
};
Copy link
Member

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.

Suggested change
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),
};

Copy link
Contributor Author

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?

Copy link
Member

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

@cedric25 cedric25 merged commit 1ade31b into v2 Jan 22, 2024
@cedric25 cedric25 deleted the feature/sdk-create-collection branch January 22, 2024 09:28
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