Skip to content

Commit

Permalink
Merge pull request #82 from thesixnetwork/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dDeedev authored Sep 4, 2023
2 parents 96c67c2 + 7a56129 commit 79d9cbb
Show file tree
Hide file tree
Showing 164 changed files with 30,617 additions and 21,072 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

.DS_Store
.vscode/
test/
./test/
ts-client/*
vue/node_modules/
build/
vue/
vue/src/store/*
scripts/secrets/*
69 changes: 69 additions & 0 deletions app/migration.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package app

import (
sdk "github.com/cosmos/cosmos-sdk/types"

NftmngrKeeper "github.com/thesixnetwork/sixnft/x/nftmngr/keeper"
nftmngrtypes "github.com/thesixnetwork/sixnft/x/nftmngr/types"
)

func (app *App) MigrationFromV1ToV2Handlers(ctx sdk.Context) {

// get all NFTSchema
nftSchemasV1 := app.NftmngrKeeper.GetAllNFTSchemaV1(ctx)

for _, nftSchemaV1 := range nftSchemasV1 {
// migrate list of system actioners to new map
for _, systemActioner := range nftSchemaV1.SystemActioners {
// set system actioner to new map
app.NftmngrKeeper.SetActionExecutor(ctx, nftmngrtypes.ActionExecutor{
NftSchemaCode: nftSchemaV1.Code,
ExecutorAddress: systemActioner,
Creator: nftSchemaV1.Owner,
})
}

// migrate schema to new schema
app.NftmngrKeeper.SetNFTSchema(ctx, nftmngrtypes.NFTSchema{
Code: nftSchemaV1.Code,
Name: nftSchemaV1.Name,
Owner: nftSchemaV1.Owner,
Description: nftSchemaV1.Name,
OriginData: nftSchemaV1.OriginData,
OnchainData: &nftmngrtypes.OnChainData{
TokenAttributes: nftSchemaV1.OnchainData.TokenAttributes,
Actions: nftSchemaV1.OnchainData.Actions,
Status: nftSchemaV1.OnchainData.Status,
},
IsVerified: nftSchemaV1.IsVerified,
MintAuthorization: nftSchemaV1.MintAuthorization,
})

// migrate NFT attributes to new schema attributes
for _, nftAttribute := range nftSchemaV1.OnchainData.NftAttributes {
schemaAttibuteConverted, _ := NftmngrKeeper.ConvertDefaultMintValueToSchemaAttributeValue(nftAttribute.DefaultMintValue)
app.NftmngrKeeper.SetSchemaAttribute(ctx, 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,
})
}

// migrate NFT actions to new schema actions
for i, nftAction := range nftSchemaV1.OnchainData.Actions {
app.NftmngrKeeper.SetActionOfSchema(ctx, nftmngrtypes.ActionOfSchema{
NftSchemaCode: nftSchemaV1.Code,
Name: nftAction.Name,
Index: uint64(i),
})
}
}

}
10 changes: 6 additions & 4 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ validator:
name: alice
staked: "2000000000stake"
client:
openapi:
path: "docs/static/openapi.yml"
vuex:
path: "vue/src/store"
openapi:
path: "docs/static/openapi.yml"
typescript:
path: "ts-client"
vuex:
path: "vue/src/store"
faucet:
name: bob
coins: ["5token", "100000stake"]
Expand Down
Loading

0 comments on commit 79d9cbb

Please sign in to comment.