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

Merge rc 1 7 next into sovereign 14 may 2024 #303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1133dc5
add NonFungibleESDTv2 to constants
BeniaminDrasovean Nov 1, 2023
fd0a900
add more token types in constants
BeniaminDrasovean Nov 2, 2023
eaf054b
update dynamic esdts
BeniaminDrasovean Nov 6, 2023
7efd30c
add new esdt roles
BeniaminDrasovean Nov 15, 2023
02b8c2d
add new built in functions
BeniaminDrasovean Nov 15, 2023
3c058f8
add new role
BeniaminDrasovean Nov 21, 2023
6296aa5
add ESDTMetaDataUpdate
BeniaminDrasovean Nov 21, 2023
f572594
refactor names
BeniaminDrasovean Nov 21, 2023
011114d
Merge remote-tracking branch 'origin/rc/v1.7.0' into update-estd-toke…
BeniaminDrasovean Nov 23, 2023
963931c
Merge branch 'rc/v1.7.0' into update-estd-token-constants
BeniaminDrasovean Nov 24, 2023
b25d8b8
Merge branch 'rc/v1.7.0' into update-estd-token-constants
BeniaminDrasovean Jan 5, 2024
460d70d
Merge remote-tracking branch 'origin/rc/v1.7.0' into update-estd-toke…
BeniaminDrasovean Jan 30, 2024
969a1a4
add unit tests
BeniaminDrasovean Jan 30, 2024
e88291d
Merge branch 'rc/v1.7.next1' into update-estd-token-constants
BeniaminDrasovean Mar 28, 2024
60f5662
Merge pull request #270 from multiversx/update-estd-token-constants
sasurobert Apr 11, 2024
6970013
added options for account with keys
raduchis Apr 18, 2024
df6d27f
Merge pull request #298 from multiversx/account-withKeys-option
raduchis Apr 19, 2024
fefea57
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-co…
sstanculeanu May 8, 2024
fea020d
Merge pull request #302 from multiversx/merge_rc170_into_rc17next1_20…
sstanculeanu May 10, 2024
72b1cac
Merge branch 'rc/v1.7.next1' into merge-rc-1-7-next-into-sovereign-14…
mariusmihaic May 14, 2024
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
63 changes: 63 additions & 0 deletions core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ const BuiltInFunctionUnGuardAccount = "UnGuardAccount"
// BuiltInFunctionMigrateDataTrie is the built-in function key for migrating the data trie
const BuiltInFunctionMigrateDataTrie = "MigrateDataTrie"

// ESDTSetTokenType represents the builtin function name to set token type
const ESDTSetTokenType = "ESDTSetTokenType"

// ESDTModifyRoyalties represents the builtin function name to modify royalties
const ESDTModifyRoyalties = "ESDTModifyRoyalties"

// ESDTSetNewURIs represents the builtin function name to set new URIs for NFTs
const ESDTSetNewURIs = "ESDTSetNewURIs"

// ESDTModifyCreator represents the builtin function name to modify creator for NFTs
const ESDTModifyCreator = "ESDTModifyCreator"

// ESDTMetaDataRecreate represents the builtin function name to recreate the metadata for ESDT tokens
const ESDTMetaDataRecreate = "ESDTMetaDataRecreate"

// ESDTMetaDataUpdate represents the builtin function name to update the metadata for ESDT tokens
const ESDTMetaDataUpdate = "ESDTMetaDataUpdate"

// ESDTRoleLocalMint is the constant string for the local role of mint for ESDT tokens
const ESDTRoleLocalMint = "ESDTRoleLocalMint"

Expand Down Expand Up @@ -155,6 +173,21 @@ const ESDTRoleNFTUpdateAttributes = "ESDTRoleNFTUpdateAttributes"
// ESDTRoleTransfer is the constant string for the local role to transfer ESDT, only for special tokens
const ESDTRoleTransfer = "ESDTTransferRole"

// ESDTRoleSetNewURI represents the role which can rewrite the URI in the token metadata
const ESDTRoleSetNewURI = "ESDTRoleSetNewURI"

// ESDTRoleModifyRoyalties represents the role which can rewrite the royalties of a token
const ESDTRoleModifyRoyalties = "ESDTRoleModifyRoyalties"

// ESDTRoleModifyCreator represents the role which can rewrite the creator in the token metadata
const ESDTRoleModifyCreator = "ESDTRoleModifyCreator"

// ESDTRoleNFTRecreate represents the role which can recreate the token metadata
const ESDTRoleNFTRecreate = "ESDTRoleNFTRecreate"

// ESDTRoleNFTUpdate represents the role which can update the token metadata
const ESDTRoleNFTUpdate = "ESDTRoleNFTUpdate"

// ESDTType defines the possible types in case of ESDT tokens
type ESDTType uint32

Expand All @@ -163,6 +196,18 @@ 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
// SemiFungible defines the token type for ESDT semi fungible tokens
SemiFungible
// MetaFungible defines the token type for ESDT meta fungible tokens
MetaFungible
// DynamicNFT defines the token type for ESDT dynamic NFT tokens
DynamicNFT
// DynamicSFT defines the token type for ESDT dynamic SFT tokens
DynamicSFT
// DynamicMeta defines the token type for ESDT dynamic meta tokens
DynamicMeta
)

// FungibleESDT defines the string for the token type of fungible ESDT
Expand All @@ -171,9 +216,27 @@ 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"

// Dynamic is the prefix used for dynamic ESDT tokens
const Dynamic = "Dynamic"

// DynamicNFTESDT defines the string for the token type of dynamic NFT ESDT
const DynamicNFTESDT = Dynamic + NonFungibleESDT

// DynamicSFTESDT defines the string for the token type of dynamic SFT ESDT
const DynamicSFTESDT = Dynamic + SemiFungibleESDT

// DynamicMetaESDT defines the string for the token type of dynamic meta ESDT
const DynamicMetaESDT = Dynamic + MetaESDT

// MaxRoyalty defines 100% as uint32
const MaxRoyalty = uint32(10000)

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

return str
}

// ConvertESDTTypeToUint32 converts the esdt type to uint32
func ConvertESDTTypeToUint32(esdtType string) (uint32, error) {
switch esdtType {
case FungibleESDT:
return uint32(Fungible), nil
case NonFungibleESDT:
return uint32(NonFungible), nil
case NonFungibleESDTv2:
return uint32(NonFungibleV2), nil
case MetaESDT:
return uint32(MetaFungible), nil
case SemiFungibleESDT:
return uint32(SemiFungible), nil
case DynamicNFTESDT:
return uint32(DynamicNFT), nil
case DynamicSFTESDT:
return uint32(DynamicSFT), nil
case DynamicMetaESDT:
return uint32(DynamicMeta), nil
default:
return math.MaxUint32, fmt.Errorf("invalid esdt type: %s", esdtType)
}
}

// IsDynamicESDT returns true if the esdt type is dynamic
func IsDynamicESDT(esdtType uint32) bool {
return esdtType == uint32(DynamicNFT) || esdtType == uint32(DynamicSFT) || esdtType == uint32(DynamicMeta)
}
53 changes: 53 additions & 0 deletions core/converters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,56 @@ func TestConvertShardIDToUint32(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, uint32(0), shardID)
}

func TestConvertESDTTypeToUint32(t *testing.T) {
t.Parallel()

tokenTypeId, err := core.ConvertESDTTypeToUint32(core.FungibleESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.Fungible), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.NonFungibleESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.NonFungible), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.NonFungibleESDTv2)
assert.Nil(t, err)
assert.Equal(t, uint32(core.NonFungibleV2), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.MetaESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.MetaFungible), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.SemiFungibleESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.SemiFungible), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.DynamicNFTESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.DynamicNFT), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.DynamicSFTESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.DynamicSFT), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32(core.DynamicMetaESDT)
assert.Nil(t, err)
assert.Equal(t, uint32(core.DynamicMeta), tokenTypeId)

tokenTypeId, err = core.ConvertESDTTypeToUint32("wrongType")
assert.NotNil(t, err)
assert.Equal(t, uint32(math.MaxUint32), tokenTypeId)
}

func TestIsDynamicESDT(t *testing.T) {
t.Parallel()

assert.True(t, core.IsDynamicESDT(uint32(core.DynamicNFT)))
assert.True(t, core.IsDynamicESDT(uint32(core.DynamicSFT)))
assert.True(t, core.IsDynamicESDT(uint32(core.DynamicMeta)))
assert.False(t, core.IsDynamicESDT(uint32(core.Fungible)))
assert.False(t, core.IsDynamicESDT(uint32(core.NonFungible)))
assert.False(t, core.IsDynamicESDT(uint32(core.NonFungibleV2)))
assert.False(t, core.IsDynamicESDT(uint32(core.SemiFungible)))
assert.False(t, core.IsDynamicESDT(uint32(core.MetaFungible)))
}
21 changes: 11 additions & 10 deletions data/api/apiAccountResponse.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package api

// AccountResponse is the data transfer object to be returned on API when requesting an address data
type AccountResponse struct {
Address string `json:"address"`
Nonce uint64 `json:"nonce"`
Balance string `json:"balance"`
Username string `json:"username"`
Code string `json:"code"`
CodeHash []byte `json:"codeHash"`
RootHash []byte `json:"rootHash"`
CodeMetadata []byte `json:"codeMetadata"`
DeveloperReward string `json:"developerReward"`
OwnerAddress string `json:"ownerAddress"`
Address string `json:"address"`
Nonce uint64 `json:"nonce"`
Balance string `json:"balance"`
Username string `json:"username"`
Code string `json:"code"`
CodeHash []byte `json:"codeHash"`
RootHash []byte `json:"rootHash"`
CodeMetadata []byte `json:"codeMetadata"`
DeveloperReward string `json:"developerReward"`
OwnerAddress string `json:"ownerAddress"`
Pairs map[string]string `json:"pairs,omitempty"`
}
1 change: 1 addition & 0 deletions data/api/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type AccountQueryOptions struct {
BlockHash []byte
BlockRootHash []byte
HintEpoch core.OptionalUint32
WithKeys bool
}

// BlockQueryOptions holds options for block queries
Expand Down
Loading