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

esdts-improvements #270

Merged
merged 14 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ const (
Fungible ESDTType = iota
// NonFungible defines the token type for ESDT non fungible tokens
NonFungible
// NonFungibleV2 defines the token type for ESDT non fungible tokens
NonFungibleV2
// Meta defines the token type for ESDT meta tokens
Meta
Copy link
Contributor

Choose a reason for hiding this comment

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

We have SFT as well. Plus bring here the DynamicNFT, DynamicSFT, DynamicMeta as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

Copy link
Contributor

Choose a reason for hiding this comment

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

change the order of semiFungible and Meta - maybe add MetaFungible - to have a complete name.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

)

// FungibleESDT defines the string for the token type of fungible ESDT
Expand All @@ -175,6 +179,12 @@ const FungibleESDT = "FungibleESDT"
// NonFungibleESDT defines the string for the token type of non fungible ESDT
const NonFungibleESDT = "NonFungibleESDT"

// NonFungibleESDTv2 defines the string for the token type of non fungible ESDT
const NonFungibleESDTv2 = "NonFungibleESDTv2"

// MetaESDT defines the string for the token type of meta ESDT
const MetaESDT = "MetaESDT"

// SemiFungibleESDT defines the string for the token type of semi fungible ESDT
const SemiFungibleESDT = "SemiFungibleESDT"

Expand Down
16 changes: 16 additions & 0 deletions core/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,19 @@ func ConvertToEvenHexBigInt(value *big.Int) string {

return str
}

// ConvertESDTTypeToUint32 converts the esdt type to uint32
func ConvertESDTTypeToUint32(esdtType string) (uint32, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

switch esdtType {
case FungibleESDT:
return uint32(Fungible), nil
case NonFungibleESDT:
return uint32(NonFungible), nil
case NonFungibleESDTv2:
return uint32(NonFungibleV2), nil
case MetaESDT:
Copy link
Contributor

Choose a reason for hiding this comment

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

add the more types, dynamics as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

MetaFungibleESDT

return uint32(Meta), nil
default:
return math.MaxUint32, fmt.Errorf("invalid esdt type: %s", esdtType)
}
}