Skip to content

Commit 737036d

Browse files
authored
Merge pull request #333 from multiversx/merge_master_into_rc_barnard_2025.02.18
Merge master into rc barnard 2025.02.18
2 parents d8b8161 + 0301055 commit 737036d

File tree

3 files changed

+140
-1
lines changed

3 files changed

+140
-1
lines changed

integrationtests/nftIssueCreateBurn_test.go

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,127 @@ func TestIssueNFTCreateAndBurn(t *testing.T) {
146146
require.Nil(t, err)
147147
require.False(t, genericResponse.Docs[0].Found)
148148
}
149+
150+
func TestIssueNFTCreateAndBurnNonFungibleV2(t *testing.T) {
151+
setLogLevelDebug()
152+
153+
esClient, err := createESClient(esURL)
154+
require.Nil(t, err)
155+
156+
// ################ ISSUE NON FUNGIBLE TOKEN #########################
157+
158+
esProc, err := CreateElasticProcessor(esClient)
159+
require.Nil(t, err)
160+
161+
body := &dataBlock.Body{}
162+
header := &dataBlock.Header{
163+
Round: 50,
164+
TimeStamp: 5040,
165+
ShardID: core.MetachainShardId,
166+
}
167+
168+
tokenIdentifier := "NON-v2"
169+
170+
address1 := "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99"
171+
pool := &outport.TransactionPool{
172+
Logs: []*outport.LogData{
173+
{
174+
TxHash: hex.EncodeToString([]byte("h1")),
175+
Log: &transaction.Log{
176+
Address: decodeAddress(address1),
177+
Events: []*transaction.Event{
178+
{
179+
Address: decodeAddress(address1),
180+
Identifier: []byte("issueNonFungible"),
181+
Topics: [][]byte{[]byte(tokenIdentifier), []byte("NON-token"), []byte("NON"), []byte(core.NonFungibleESDTv2)},
182+
},
183+
nil,
184+
},
185+
},
186+
},
187+
},
188+
}
189+
190+
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
191+
require.Nil(t, err)
192+
193+
// ################ CREATE NON FUNGIBLE TOKEN ##########################
194+
esProc, err = CreateElasticProcessor(esClient)
195+
require.Nil(t, err)
196+
197+
header = &dataBlock.Header{
198+
Round: 51,
199+
TimeStamp: 5600,
200+
ShardID: 0,
201+
}
202+
203+
esdtData := &esdt.ESDigitalToken{
204+
TokenMetaData: &esdt.MetaData{
205+
Creator: decodeAddress(address1),
206+
},
207+
}
208+
esdtDataBytes, _ := json.Marshal(esdtData)
209+
210+
pool = &outport.TransactionPool{
211+
Logs: []*outport.LogData{
212+
{
213+
TxHash: hex.EncodeToString([]byte("h1")),
214+
Log: &transaction.Log{
215+
Address: decodeAddress(address1),
216+
Events: []*transaction.Event{
217+
{
218+
Address: decodeAddress(address1),
219+
Identifier: []byte(core.BuiltInFunctionESDTNFTCreate),
220+
Topics: [][]byte{[]byte(tokenIdentifier), big.NewInt(2).Bytes(), big.NewInt(1).Bytes(), esdtDataBytes},
221+
},
222+
nil,
223+
},
224+
},
225+
},
226+
},
227+
}
228+
229+
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
230+
require.Nil(t, err)
231+
232+
ids := []string{tokenIdentifier + "-02"}
233+
genericResponse := &GenericResponse{}
234+
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TokensIndex, true, genericResponse)
235+
require.Nil(t, err)
236+
require.JSONEq(t, readExpectedResult("./testdata/nftIssueCreateBurn/non-fungible-v2-after-create.json"), string(genericResponse.Docs[0].Source))
237+
238+
// ################ BURN NON FUNGIBLE TOKEN ##########################
239+
240+
header = &dataBlock.Header{
241+
Round: 52,
242+
TimeStamp: 5666,
243+
ShardID: 0,
244+
}
245+
246+
pool = &outport.TransactionPool{
247+
Logs: []*outport.LogData{
248+
{
249+
TxHash: hex.EncodeToString([]byte("h1")),
250+
Log: &transaction.Log{
251+
Address: decodeAddress(address1),
252+
Events: []*transaction.Event{
253+
{
254+
Address: decodeAddress(address1),
255+
Identifier: []byte(core.BuiltInFunctionESDTNFTBurn),
256+
Topics: [][]byte{[]byte(tokenIdentifier), big.NewInt(2).Bytes(), big.NewInt(1).Bytes(), decodeAddress(address1)},
257+
},
258+
nil,
259+
},
260+
},
261+
},
262+
},
263+
}
264+
265+
err = esProc.SaveTransactions(createOutportBlockWithHeader(body, header, pool, nil, testNumOfShards))
266+
require.Nil(t, err)
267+
268+
genericResponse = &GenericResponse{}
269+
err = esClient.DoMultiGet(context.Background(), ids, indexerdata.TokensIndex, true, genericResponse)
270+
require.Nil(t, err)
271+
require.False(t, genericResponse.Docs[0].Found)
272+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"identifier": "NON-v2-02",
3+
"token": "NON-v2",
4+
"currentOwner": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99",
5+
"numDecimals": 0,
6+
"type": "NonFungibleESDTv2",
7+
"nonce": 2,
8+
"timestamp": 5600,
9+
"data": {
10+
"creator": "erd1ju8pkvg57cwdmjsjx58jlmnuf4l9yspstrhr9tgsrt98n9edpm2qtlgy99",
11+
"nonEmptyURIs": false,
12+
"whiteListedStorage": false
13+
}
14+
}

process/elasticproc/logsevents/serialize.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ func serializeTokenTransferOwnership(tokenData *data.TokenInfo, index string) ([
284284
// SerializeSupplyData will serialize the provided supply data
285285
func (lep *logsAndEventsProcessor) SerializeSupplyData(tokensSupply data.TokensHandler, buffSlice *data.BufferSlice, index string) error {
286286
for _, supplyData := range tokensSupply.GetAll() {
287-
if supplyData.Type != core.NonFungibleESDT {
287+
shouldSkip := supplyData.Type != core.NonFungibleESDT && supplyData.Type != core.NonFungibleESDTv2 && supplyData.Type != core.DynamicNFTESDT
288+
if shouldSkip {
288289
continue
289290
}
290291

0 commit comments

Comments
 (0)