diff --git a/integrationtests/nftIssueCreateBurn_test.go b/integrationtests/nftIssueCreateBurn_test.go index 02fda26b..083729cc 100644 --- a/integrationtests/nftIssueCreateBurn_test.go +++ b/integrationtests/nftIssueCreateBurn_test.go @@ -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) +} diff --git a/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json new file mode 100644 index 00000000..ec233947 --- /dev/null +++ b/integrationtests/testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json @@ -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 + } +} diff --git a/process/elasticproc/logsevents/serialize.go b/process/elasticproc/logsevents/serialize.go index 22508c3c..57d69f7e 100644 --- a/process/elasticproc/logsevents/serialize.go +++ b/process/elasticproc/logsevents/serialize.go @@ -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 }