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

Add SRC-7 helper functions #194

Merged
merged 16 commits into from
Oct 4, 2023
Merged

Add SRC-7 helper functions #194

merged 16 commits into from
Oct 4, 2023

Conversation

bitzoic
Copy link
Member

@bitzoic bitzoic commented Sep 13, 2023

Type of change

  • New feature

Changes

The following changes have been made:

  • Splits the single file into multiple files and groups functions by standard
  • Adds helper functions for the Metadata type of the SRC-7 standard

Notes

@bitzoic bitzoic added New Feature New addition that does not currently exist Lib: Asset Label used to filter for the library issue labels Sep 13, 2023
@bitzoic bitzoic requested a review from a team as a code owner September 13, 2023 08:58
@bitzoic bitzoic self-assigned this Sep 13, 2023
libs/token/SPECIFICATION.md Show resolved Hide resolved
libs/token/SPECIFICATION.md Outdated Show resolved Hide resolved
libs/token/SPECIFICATION.md Outdated Show resolved Hide resolved
libs/token/SPECIFICATION.md Outdated Show resolved Hide resolved
libs/token/SPECIFICATION.md Outdated Show resolved Hide resolved
libs/token/src/src_20.sw Outdated Show resolved Hide resolved
libs/token/src/src_20.sw Outdated Show resolved Hide resolved
libs/token/src/src_7.sw Outdated Show resolved Hide resolved
libs/token/src/src_7.sw Outdated Show resolved Hide resolved
libs/token/src/src_7.sw Outdated Show resolved Hide resolved
@bitzoic bitzoic requested review from Braqzen and a team October 2, 2023 12:11
@bitzoic bitzoic added the Breaking This will break user's code label Oct 2, 2023
K1-R1
K1-R1 previously approved these changes Oct 2, 2023
Copy link
Member

@K1-R1 K1-R1 left a comment

Choose a reason for hiding this comment

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

lgtm

match metadata {
Metadata::Int(data) => {
write(hashed_key, 0, data);
write(sha256((hashed_key, self.slot)), 0, 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the last number in the second write increment for each metadata type while the first write seems to remain the same?

Doesn't the hashed key keep the collisions down to 0?

Copy link
Member Author

Choose a reason for hiding this comment

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

The first write stores the data itself while the second write describes the type. This is needed as String and Bytes are pointer types and therefore cannot be stored, hence the use of the StorageMetadata type in the first place

Copy link
Member Author

Choose a reason for hiding this comment

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

If you have a better suggestion as to how to handle this case I'm all ears

libs/token/src/metadata.sw Outdated Show resolved Hide resolved
libs/token/src/metadata.sw Outdated Show resolved Hide resolved
libs/token/src/metadata.sw Outdated Show resolved Hide resolved
libs/token/src/metadata.sw Outdated Show resolved Hide resolved
libs/token/src/metadata.sw Outdated Show resolved Hide resolved
@bitzoic bitzoic requested review from Braqzen, K1-R1 and a team October 3, 2023 10:51
Copy link
Contributor

@Braqzen Braqzen left a comment

Choose a reason for hiding this comment

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

Haven't considered a redesign for the 2 writes.

@bitzoic bitzoic merged commit 5257dc7 into master Oct 4, 2023
3 checks passed
@bitzoic bitzoic deleted the bitzoic-metadata-standard branch October 4, 2023 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking This will break user's code Lib: Asset Label used to filter for the library issue New Feature New addition that does not currently exist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants