Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
124 changes: 124 additions & 0 deletions integrationtests/nftIssueCreateBurn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,127 @@ func TestIssueNFTCreateAndBurn(t *testing.T) {
require.Nil(t, err)
require.False(t, genericResponse.Docs[0].Found)
}

func TestIssueNFTCreateAndBurnNonFungibleV2(t *testing.T) {
setLogLevelDebug()

esClient, err := createESClient(esURL)
require.Nil(t, err)

// ################ ISSUE NON FUNGIBLE TOKEN #########################

esProc, err := CreateElasticProcessor(esClient)
require.Nil(t, err)

body := &dataBlock.Body{}
header := &dataBlock.Header{
Round: 50,
TimeStamp: 5040,
ShardID: core.MetachainShardId,
}

tokenIdentifier := "NON-v2"

address1 := "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99"
pool := &outport.TransactionPool{
Logs: []*outport.LogData{
{
TxHash: hex.EncodeToString([]byte("h1")),
Log: &transaction.Log{
Address: decodeAddress(address1),
Events: []*transaction.Event{
{
Address: decodeAddress(address1),
Identifier: []byte("issueNonFungible"),
Topics: [][]byte{[]byte(tokenIdentifier), []byte("NON-token"), []byte("NON"), []byte(core.NonFungibleESDTv2)},
},
nil,
},
},
},
},
}

err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

// ################ CREATE NON FUNGIBLE TOKEN ##########################
esProc, err = CreateElasticProcessor(esClient)
require.Nil(t, err)

header = &dataBlock.Header{
Round: 51,
TimeStamp: 5600,
ShardID: 0,
}

esdtData := &esdt.ESDigitalToken{
TokenMetaData: &esdt.MetaData{
Creator: decodeAddress(address1),
},
}
esdtDataBytes, _ := json.Marshal(esdtData)

pool = &outport.TransactionPool{
Logs: []*outport.LogData{
{
TxHash: hex.EncodeToString([]byte("h1")),
Log: &transaction.Log{
Address: decodeAddress(address1),
Events: []*transaction.Event{
{
Address: decodeAddress(address1),
Identifier: []byte(core.BuiltInFunctionESDTNFTCreate),
Topics: [][]byte{[]byte(tokenIdentifier), big.NewInt(2).Bytes(), big.NewInt(1).Bytes(), esdtDataBytes},
},
nil,
},
},
},
},
}

err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

ids := []string{tokenIdentifier + "-02"}
genericResponse := &GenericResponse{}
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TokensIndex, true, genericResponse)
require.Nil(t, err)
require.JSONEq(t, readExpectedResult("./testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json"), string(genericResponse.Docs[0].Source))

// ################ BURN NON FUNGIBLE TOKEN ##########################

header = &dataBlock.Header{
Round: 52,
TimeStamp: 5666,
ShardID: 0,
}

pool = &outport.TransactionPool{
Logs: []*outport.LogData{
{
TxHash: hex.EncodeToString([]byte("h1")),
Log: &transaction.Log{
Address: decodeAddress(address1),
Events: []*transaction.Event{
{
Address: decodeAddress(address1),
Identifier: []byte(core.BuiltInFunctionESDTNFTBurn),
Topics: [][]byte{[]byte(tokenIdentifier), big.NewInt(2).Bytes(), big.NewInt(1).Bytes(), decodeAddress(address1)},
},
nil,
},
},
},
},
}

err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
require.Nil(t, err)

genericResponse = &GenericResponse{}
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TokensIndex, true, genericResponse)
require.Nil(t, err)
require.False(t, genericResponse.Docs[0].Found)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"identifier": "NON-v2-02",
"token": "NON-v2",
"currentOwner": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99",
"numDecimals": 0,
"type": "NonFungibleESDTv2",
"nonce": 2,
"timestamp": 5600,
"data": {
"creator": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99",
"nonEmptyURIs": false,
"whiteListedStorage": false
}
}
3 changes: 2 additions & 1 deletion process/elasticproc/logsevents/serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ func serializeTokenTransferOwnership(tokenData *data.TokenInfo, index string) ([
// SerializeSupplyData will serialize the provided supply data
func (lep *logsAndEventsProcessor) SerializeSupplyData(tokensSupply data.TokensHandler, buffSlice *data.BufferSlice, index string) error {
for _, supplyData := range tokensSupply.GetAll() {
if supplyData.Type != core.NonFungibleESDT {
shouldSkip := supplyData.Type != core.NonFungibleESDT && supplyData.Type != core.NonFungibleESDTv2 && supplyData.Type != core.DynamicNFTESDT
if shouldSkip {
continue
}

Expand Down