Skip to content

Commit

Permalink
Merge pull request #83 from thesixnetwork/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dDeedev authored Sep 6, 2023
2 parents 79d9cbb + d9dab54 commit fdc8447
Show file tree
Hide file tree
Showing 39 changed files with 3,712 additions and 1,946 deletions.
35 changes: 35 additions & 0 deletions app/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ func (app *App) MigrationFromV1ToV2Handlers(ctx sdk.Context) {
ExecutorAddress: systemActioner,
Creator: nftSchemaV1.Owner,
})

val, found := app.NftmngrKeeper.GetExecutorOfSchema(ctx, nftSchemaV1.Code)
if !found {
val = nftmngrtypes.ExecutorOfSchema{
NftSchemaCode: nftSchemaV1.Code,
ExecutorAddress: []string{},
}
}

// set executorOfSchema
val.ExecutorAddress = append(val.ExecutorAddress, systemActioner)

app.NftmngrKeeper.SetExecutorOfSchema(ctx, nftmngrtypes.ExecutorOfSchema{
NftSchemaCode: nftSchemaV1.Code,
ExecutorAddress: val.ExecutorAddress,
})
}

// migrate schema to new schema
Expand All @@ -40,6 +56,7 @@ func (app *App) MigrationFromV1ToV2Handlers(ctx sdk.Context) {
})

// migrate NFT attributes to new schema attributes
var schemaAttributes []*nftmngrtypes.SchemaAttribute
for _, nftAttribute := range nftSchemaV1.OnchainData.NftAttributes {
schemaAttibuteConverted, _ := NftmngrKeeper.ConvertDefaultMintValueToSchemaAttributeValue(nftAttribute.DefaultMintValue)
app.NftmngrKeeper.SetSchemaAttribute(ctx, nftmngrtypes.SchemaAttribute{
Expand All @@ -54,8 +71,26 @@ func (app *App) MigrationFromV1ToV2Handlers(ctx sdk.Context) {
HiddenToMarketplace: nftAttribute.HiddenToMarketplace,
Creator: nftSchemaV1.Owner,
})

schemaAttributes = append(schemaAttributes, &nftmngrtypes.SchemaAttribute{
NftSchemaCode: nftSchemaV1.Code,
Name: nftAttribute.Name,
DataType: nftAttribute.DataType,
Required: nftAttribute.Required,
DisplayValueField: nftAttribute.DisplayValueField,
DisplayOption: nftAttribute.DisplayOption,
CurrentValue: schemaAttibuteConverted,
HiddenOveride: nftAttribute.HiddenOveride,
HiddenToMarketplace: nftAttribute.HiddenToMarketplace,
Creator: nftSchemaV1.Owner,
})
}

app.NftmngrKeeper.SetAttributeOfSchema(ctx, nftmngrtypes.AttributeOfSchema{
NftSchemaCode: nftSchemaV1.Code,
SchemaAttributes: schemaAttributes,
})

// migrate NFT actions to new schema actions
for i, nftAction := range nftSchemaV1.OnchainData.Actions {
app.NftmngrKeeper.SetActionOfSchema(ctx, nftmngrtypes.ActionOfSchema{
Expand Down
Loading

0 comments on commit fdc8447

Please sign in to comment.