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

Rc/v1.7.next1 #294

Draft
wants to merge 71 commits into
base: rc/v1.7.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
158ecb0
inner transactions on transaction
sstanculeanu Sep 8, 2023
6ac41d9
fix test
sstanculeanu Sep 8, 2023
b0fb328
added extra check
sstanculeanu Sep 8, 2023
132204a
added RelayedV3TransactionHandler
sstanculeanu Sep 8, 2023
8f1a379
only one inner tx
sstanculeanu Sep 20, 2023
6724a64
added missing pointer
sstanculeanu Sep 20, 2023
978c5de
prepare proper inner tx
sstanculeanu Sep 20, 2023
d7df575
fix unmarshal of inner
sstanculeanu Sep 20, 2023
2791fda
proper implementation
sstanculeanu Sep 20, 2023
4b6ee19
fixed inner tx preparation
sstanculeanu Sep 20, 2023
7aa5258
use inner tx signature when returning data for signing
sstanculeanu Sep 20, 2023
afd6941
added optional relayer address on tx
sstanculeanu Sep 21, 2023
48fd7cc
removed previously added method from interface
sstanculeanu Sep 21, 2023
1e73b4f
fix typo after self review
sstanculeanu Sep 25, 2023
ab2114e
fixes after first review
sstanculeanu Sep 26, 2023
61487cb
switched the innerTransaction field to a slice of transactions
sstanculeanu Oct 5, 2023
ce615bc
Merge pull request #260 from multiversx/inner_txs_on_tx
sstanculeanu Oct 11, 2023
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
e81c072
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-co…
sstanculeanu Nov 27, 2023
1dc309d
Merge pull request #277 from multiversx/merge_rc170_into_feat_relayed…
sstanculeanu Nov 27, 2023
b25d8b8
Merge branch 'rc/v1.7.0' into update-estd-token-constants
BeniaminDrasovean Jan 5, 2024
ad95182
Merge branch 'rc/v1.7.0' of https://github.com/multiversx/mx-chain-co…
sstanculeanu Jan 30, 2024
ccdebf0
Merge pull request #286 from multiversx/merge_rc170_into_feat_relayed…
sstanculeanu Jan 30, 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
5960a89
fix indentation
sstanculeanu Mar 21, 2024
a3ee465
Merge pull request #293 from multiversx/merge_rc170_into_rc17next1_20…
sstanculeanu Mar 22, 2024
95b7c29
Merge branch 'rc/v1.7.next1' of https://github.com/multiversx/mx-chai…
sstanculeanu Mar 22, 2024
ef6f4a3
Merge pull request #295 from multiversx/merge_rc170_into_feat_relayed…
sstanculeanu Mar 27, 2024
e88291d
Merge branch 'rc/v1.7.next1' into update-estd-token-constants
BeniaminDrasovean Mar 28, 2024
237b5ab
Merge branch 'feat/relayedv3' of https://github.com/multiversx/mx-cha…
sstanculeanu Apr 4, 2024
48e2da5
update ApiTransactionResult as well
sstanculeanu Apr 4, 2024
60f5662
Merge pull request #270 from multiversx/update-estd-token-constants
sasurobert Apr 11, 2024
9ba698b
FEAT: Common token prefix utility func
mariusmihaic Apr 23, 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
7d0b8a1
Merge pull request #263 from multiversx/rc/v1.7.0
iulianpascalau May 10, 2024
756a4f3
Merge branch 'rc/v1.7.next1' into MX-15387-token-prefix-common
mariusmihaic May 15, 2024
3415a1d
Merge branch 'rc/v1.7.next1' of https://github.com/multiversx/mx-chai…
sstanculeanu May 15, 2024
21cfaa8
Merge pull request #304 from multiversx/merge_rc17next1into_featrelay…
sstanculeanu May 15, 2024
bb09ab4
Merge branch 'feat/relayedv3' of https://github.com/multiversx/mx-cha…
sstanculeanu May 15, 2024
2f76860
FIX: Comm
mariusmihaic May 17, 2024
7befa59
Merge pull request #299 from multiversx/MX-15387-token-prefix-common
mariusmihaic May 17, 2024
8b6faa7
update ApiTransactionResult to use FrontEndTransaction for better vis…
sstanculeanu May 28, 2024
1559f92
added RelayedTransactionV3 constant
sstanculeanu May 29, 2024
139a833
reverted last commit
sstanculeanu May 29, 2024
f6c188a
type in altered account
miiu96 May 30, 2024
4587051
string method
miiu96 May 30, 2024
88bd243
fixes after review
sstanculeanu Jun 4, 2024
86ff8cd
added GetUserTransactions on TransactionWithFeeHandler
sstanculeanu Jun 11, 2024
844ddbc
Merge pull request #266 from multiversx/multiple_inner_txs_on_v3
AdoAdoAdo Jun 13, 2024
e5daea9
Merge branch 'rc/v1.7.next1' of https://github.com/multiversx/mx-chai…
sstanculeanu Jul 3, 2024
182030e
Merge pull request #309 from multiversx/merge_rc17next1_into_feat_rel…
sstanculeanu Jul 3, 2024
a77b241
Merge pull request #305 from multiversx/token-type-altered-account
miiu96 Jul 3, 2024
550eebf
Merge branch 'rc/v1.7.next1' of https://github.com/multiversx/mx-chai…
sstanculeanu Jul 3, 2024
626328c
Merge pull request #310 from multiversx/merge_rc17next1_into_feat_rel…
sstanculeanu Jul 3, 2024
953ec5c
Merge pull request #276 from multiversx/feat/relayedv3
AdoAdoAdo Jul 19, 2024
6e9bfee
Merge branch 'main' of https://github.com/multiversx/mx-chain-core-go…
sstanculeanu Jul 25, 2024
f9259f6
Merge pull request #313 from multiversx/merge_main_into_rc17next1_202…
sstanculeanu Jul 25, 2024
8c8c402
generate MetaDataVersion struct
BeniaminDrasovean Aug 23, 2024
22b7004
add empty line
BeniaminDrasovean Aug 23, 2024
1ec562b
Merge pull request #318 from multiversx/save-DynamicNFT-metaData-on-user
BeniaminDrasovean Aug 28, 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
87 changes: 87 additions & 0 deletions core/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,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 @@ -159,6 +177,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 @@ -167,17 +200,71 @@ 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
)

// String will convert number type in string
func (t ESDTType) String() string {
switch t {
case Fungible:
return FungibleESDT
case NonFungible:
return NonFungibleESDT
case NonFungibleV2:
return NonFungibleESDTv2
case SemiFungible:
return SemiFungibleESDT
case MetaFungible:
return MetaESDT
case DynamicNFT:
return DynamicNFTESDT
case DynamicSFT:
return DynamicSFTESDT
case DynamicMeta:
return DynamicMetaESDT
default:
return "Unknown"
}
}

// FungibleESDT defines the string for the token type of fungible ESDT
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)))
}
Loading
Loading