From 6d95d6ad15369b95fe1a93ddc4229d8df224bebc Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Mon, 9 Jan 2023 18:53:31 +0100 Subject: [PATCH] #135 Introduced usage of card class to new card page and fixed sequency shit --- src/components/elements/CardComponent.vue | 1 + src/model/Card.js | 70 ++++- src/model/Card.ts | 71 ++++- src/plugins/cardChain.js | 4 +- .../module/index.js | 215 +++++++++++--- .../module/index.ts | 262 +++++++++++++++--- src/views/NewCardPage.vue | 31 ++- 7 files changed, 552 insertions(+), 102 deletions(-) diff --git a/src/components/elements/CardComponent.vue b/src/components/elements/CardComponent.vue index fc12084d..55dfe646 100644 --- a/src/components/elements/CardComponent.vue +++ b/src/components/elements/CardComponent.vue @@ -23216,6 +23216,7 @@ export default { let firstLetterToLower = string => { return string[0].toLowerCase() + string.substring(1) } + console.log(this.model) this.model.Keywords.forEach(ability => { ability.forEach(keyword => { this.keywordDescriptions = R.concat(this.keywordDescriptions, diff --git a/src/model/Card.js b/src/model/Card.js index cbe0cc87..d245ef79 100644 --- a/src/model/Card.js +++ b/src/model/Card.js @@ -22,6 +22,7 @@ class ChainCard { card.Attack = parseInt(content[cardType].Attack); card.Delay = parseInt(content[cardType].Delay); card.RulesTexts = content[cardType].RulesTexts; + card.Effects = content[cardType].Effects; card.Keywords = []; content[cardType].Keywords.forEach(keyword => { card.Keywords.push(JSON.parse(keyword)); @@ -50,7 +51,7 @@ exports.ChainCard = ChainCard; class Card { constructor() { this.notes = ""; - this.type = ""; + this.type = "Entity"; this.owner = ""; this.status = ""; this.artist = ""; @@ -66,10 +67,10 @@ class Card { this.underpoweredVotes = 0; this.votePool = new Coin_1.Coin(); this.Abilities = []; - this.CardName = ""; + this.CardName = "Name"; this.FlavourText = ""; this.Tags = []; - this.Class = new CardClass(); + this.Class = CardClass.technology(); this.CastingCost = -1; this.AdditionalCost = {}; this.Health = 0; @@ -77,10 +78,56 @@ class Card { this.Delay = 0; this.RulesTexts = []; this.Keywords = []; + this.Effects = []; } static from(json) { return Object.assign(new Card(), json); } + toChainCard() { + console.log("trying to parse ", this); + let cardContent = Object.assign(new CardContent(), { + CardName: this.CardName, + Tags: this.Tags.filter(tag => { + return tag != null; + }), + FlavourText: this.FlavourText, + Class: this.Class, + Keywords: [], + RulesTexts: this.RulesTexts + }); + this.Keywords.forEach(keyword => { + cardContent.Keywords.push(JSON.stringify(keyword)); + }); + // in the following part we check things that are only required for specific card types + if (this.type !== "Headquarter") { + cardContent.CastingCost = this.CastingCost; + if (!this.AdditionalCost) { + cardContent.AdditionalCost = this.AdditionalCost; + } + } + if (this.type !== "Action") { + cardContent.Health = this.Health; + cardContent.Abilities = this.Abilities; + } + if (this.type === "Entity") { + cardContent.Attack = this.Attack; + } + else if (this.type === "Action") { + cardContent.Effects = this.Effects; + } + else if (this.type === "Headquarter") { + cardContent.Delay = this.Delay; + } + let cc = new ChainCard(); + cc.content = { + [this.type]: cardContent + }; + cc.image = this.image ? this.image : "if you read this, someone was able to upload a card without proper image..."; + cc.fullArt = this.fullArt; + cc.notes = this.notes; + console.log("parsed into:", cc); + return cc; + } } exports.Card = Card; class CardClass { @@ -115,3 +162,20 @@ class CardClass { } } exports.CardClass = CardClass; +class CardContent { + constructor() { + this.Abilities = []; + this.CardName = ""; + this.FlavourText = ""; + this.Tags = []; + this.Class = new CardClass(); + this.CastingCost = -1; + this.AdditionalCost = undefined; + this.Health = 0; + this.Attack = 0; + this.Delay = 0; + this.RulesTexts = []; + this.Keywords = []; + this.Effects = []; + } +} diff --git a/src/model/Card.ts b/src/model/Card.ts index 9e92ab8b..069d9624 100644 --- a/src/model/Card.ts +++ b/src/model/Card.ts @@ -4,7 +4,7 @@ export class ChainCard { owner: string; status: string; artist: string; - content: string; + content: any; image: string; fullArt: boolean; nerflevel: string; @@ -37,6 +37,7 @@ export class ChainCard { card.Attack = parseInt(content[cardType].Attack); card.Delay = parseInt(content[cardType].Delay); card.RulesTexts = content[cardType].RulesTexts; + card.Effects = content[cardType].Effects; card.Keywords = []; content[cardType].Keywords.forEach(keyword => { card.Keywords.push(JSON.parse(keyword)); @@ -66,7 +67,7 @@ export class ChainCard { export class Card { notes: string = ""; - type: string = ""; + type: string = "Entity"; owner: string = ""; status: string = ""; artist: string = ""; @@ -83,10 +84,10 @@ export class Card { votePool: Coin = new Coin(); Abilities: Array = []; - CardName: string = ""; + CardName: string = "Name"; FlavourText: string = ""; Tags: Array = []; - Class: CardClass = new CardClass(); + Class: CardClass = CardClass.technology(); CastingCost: number = -1; AdditionalCost: any = {}; Health: number = 0; @@ -94,10 +95,56 @@ export class Card { Delay: number = 0; RulesTexts: Array = []; Keywords: Array> = []; + Effects: Array = []; static from(json) { return Object.assign(new Card(), json); } + + toChainCard() { + console.log("trying to parse ", this); + let cardContent = Object.assign(new CardContent(), { + CardName: this.CardName, + Tags: this.Tags.filter(tag => { + return tag != null; + }), + FlavourText: this.FlavourText, + Class: this.Class, + Keywords: [], + RulesTexts: this.RulesTexts + }); + this.Keywords.forEach(keyword => { + cardContent.Keywords.push(JSON.stringify(keyword)); + }); + // in the following part we check things that are only required for specific card types + if (this.type !== "Headquarter") { + cardContent.CastingCost = this.CastingCost; + if (!this.AdditionalCost) { + cardContent.AdditionalCost = this.AdditionalCost; + } + } + if (this.type !== "Action") { + cardContent.Health = this.Health; + cardContent.Abilities = this.Abilities; + } + if (this.type === "Entity") { + cardContent.Attack = this.Attack; + } else if (this.type === "Action") { + cardContent.Effects = this.Effects; + } else if (this.type === "Headquarter") { + cardContent.Delay = this.Delay; + } + + let cc = new ChainCard(); + cc.content = { + [this.type]: cardContent + }; + cc.image = this.image ? this.image : "if you read this, someone was able to upload a card without proper image..."; + cc.fullArt = this.fullArt; + cc.notes = this.notes; + console.log("parsed into:", cc); + return cc; + } } export class CardClass { @@ -136,3 +183,19 @@ export class CardClass { return obj; } } + +class CardContent { + Abilities: Array = []; + CardName: string = ""; + FlavourText: string = ""; + Tags: Array = []; + Class: CardClass = new CardClass(); + CastingCost: number = -1; + AdditionalCost: any = undefined; + Health: number = 0; + Attack: number = 0; + Delay: number = 0; + RulesTexts: Array = []; + Keywords: Array = []; + Effects: Array = []; +} diff --git a/src/plugins/cardChain.js b/src/plugins/cardChain.js index 37e220b7..d2dfc29e 100644 --- a/src/plugins/cardChain.js +++ b/src/plugins/cardChain.js @@ -4,8 +4,8 @@ import { entropyToMnemonic } from 'bip39' //import { signTx, createWalletFromMnemonic } from '@tendermint/sig/dist/web' //import { coin } from "@cosmjs/proto-signing"; // import { Coin } from "../store/generated/cosmos/cosmos-sdk/cosmos.bank.v1beta1/module/types/cosmos/base/v1beta1/coin.js" -import { creditsFromCoins, emptyCard } from '../components/utils/utils.js' -import {GenericAuthorization} from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/cosmos/authz/v1beta1/authz.js" +import { creditsFromCoins } from '@/components/utils/utils.js' +import { GenericAuthorization } from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/cosmos/authz/v1beta1/authz.js" import { Card, ChainCard } from "@/model/Card"; //import {Any} from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/google/protobuf/any.js" diff --git a/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.js b/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.js index 44a1de79..5833c29b 100644 --- a/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.js +++ b/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.js @@ -73,13 +73,17 @@ const types = [ ["/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", tx_31.MsgSubmitCollectionProposal], ["/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", tx_32.MsgDonateToCard], ["/DecentralCardGame.cardchain.cardchain.MsgTransferCard", tx_33.MsgTransferCard], - ["/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", tx_34.MsgAddCardToCollection], + ["/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", tx_34.MsgAddCardToCollection] ]; exports.MissingWalletError = new Error("wallet is required"); exports.registry = new proto_signing_1.Registry(types); const defaultFee = { amount: [], - gas: "200000", + gas: "200000" +}; +let sequenceInfo = { + height: null, + sequence: null }; const txClient = async (wallet, { addr: addr } = { addr: "http://localhost:26657" }) => { if (!wallet) @@ -93,41 +97,178 @@ const txClient = async (wallet, { addr: addr } = { addr: "http://localhost:26657 } const { address } = (await wallet.getAccounts())[0]; return { - signAndBroadcast: (msgs, { fee, memo } = { fee: defaultFee, memo: "" }) => client.signAndBroadcast(address, msgs, fee, memo), - msgApointMatchReporter: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgApointMatchReporter", value: tx_1.MsgApointMatchReporter.fromPartial(data) }), - msgSetProfileCard: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetProfileCard", value: tx_2.MsgSetProfileCard.fromPartial(data) }), - msgCreateuser: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateuser", value: tx_3.MsgCreateuser.fromPartial(data) }), - msgRevealCouncilResponse: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRevealCouncilResponse", value: tx_4.MsgRevealCouncilResponse.fromPartial(data) }), - msgBuyCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCollection", value: tx_5.MsgBuyCollection.fromPartial(data) }), - msgAddArtwork: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtwork", value: tx_6.MsgAddArtwork.fromPartial(data) }), - msgChangeArtist: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgChangeArtist", value: tx_7.MsgChangeArtist.fromPartial(data) }), - msgRemoveCardFromCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveCardFromCollection", value: tx_8.MsgRemoveCardFromCollection.fromPartial(data) }), - msgCreateCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCollection", value: tx_9.MsgCreateCollection.fromPartial(data) }), - msgSaveCardContent: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSaveCardContent", value: tx_10.MsgSaveCardContent.fromPartial(data) }), - msgAddArtworkToCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtworkToCollection", value: tx_11.MsgAddArtworkToCollection.fromPartial(data) }), - msgFinalizeCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgFinalizeCollection", value: tx_12.MsgFinalizeCollection.fromPartial(data) }), - msgRewokeCouncilRegistration: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRewokeCouncilRegistration", value: tx_13.MsgRewokeCouncilRegistration.fromPartial(data) }), - msgSubmitMatchReporterProposal: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitMatchReporterProposal", value: tx_14.MsgSubmitMatchReporterProposal.fromPartial(data) }), - msgRestartCouncil: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRestartCouncil", value: tx_15.MsgRestartCouncil.fromPartial(data) }), - msgSubmitCopyrightProposal: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCopyrightProposal", value: tx_16.MsgSubmitCopyrightProposal.fromPartial(data) }), - msgSetCardRarity: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetCardRarity", value: tx_17.MsgSetCardRarity.fromPartial(data) }), - msgRemoveSellOffer: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveSellOffer", value: tx_18.MsgRemoveSellOffer.fromPartial(data) }), - msgRegisterForCouncil: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRegisterForCouncil", value: tx_19.MsgRegisterForCouncil.fromPartial(data) }), - msgCreateCouncil: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCouncil", value: tx_20.MsgCreateCouncil.fromPartial(data) }), - msgReportMatch: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgReportMatch", value: tx_21.MsgReportMatch.fromPartial(data) }), - msgBuyCardScheme: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCardScheme", value: tx_22.MsgBuyCardScheme.fromPartial(data) }), - msgConfirmMatch: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgConfirmMatch", value: tx_23.MsgConfirmMatch.fromPartial(data) }), - msgCommitCouncilResponse: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCommitCouncilResponse", value: tx_24.MsgCommitCouncilResponse.fromPartial(data) }), - msgAddContributorToCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddContributorToCollection", value: tx_25.MsgAddContributorToCollection.fromPartial(data) }), - msgCreateSellOffer: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateSellOffer", value: tx_26.MsgCreateSellOffer.fromPartial(data) }), - msgBuyCard: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCard", value: tx_27.MsgBuyCard.fromPartial(data) }), - msgVoteCard: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgVoteCard", value: tx_28.MsgVoteCard.fromPartial(data) }), - msgRemoveContributorFromCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveContributorFromCollection", value: tx_29.MsgRemoveContributorFromCollection.fromPartial(data) }), - msgAddStoryToCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddStoryToCollection", value: tx_30.MsgAddStoryToCollection.fromPartial(data) }), - msgSubmitCollectionProposal: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", value: tx_31.MsgSubmitCollectionProposal.fromPartial(data) }), - msgDonateToCard: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", value: tx_32.MsgDonateToCard.fromPartial(data) }), - msgTransferCard: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgTransferCard", value: tx_33.MsgTransferCard.fromPartial(data) }), - msgAddCardToCollection: (data) => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", value: tx_34.MsgAddCardToCollection.fromPartial(data) }), + signAndBroadcast: (msgs, { fee, memo } = { + fee: defaultFee, + memo: "" + }) => { + // code injection to get sequence fast firing working + client.getSequence = async function (address) { + const height = await this.getHeight(); + const account = await this.getAccount(address); + if (!account) { + throw new Error("Account does not exist on chain. Send some tokens there before trying to query sequence."); + } + // if sequence info is not yet defined, do it here + if (!sequenceInfo.height) { + sequenceInfo = { + height: height, + sequence: account.sequence + }; + } + // if the sequence info is outdated, we update it + else if (sequenceInfo.height < height) { + // we don't update the sequence if it is from last block + // this fixes sequence error is tx got into new block and update would reset the sequence + if (sequenceInfo.height + 1 < height) { + sequenceInfo.sequence = account.sequence; + } + sequenceInfo.height = height; + } + let returnSequence = sequenceInfo.sequence; + sequenceInfo.sequence++; + return { + accountNumber: account.accountNumber, + sequence: returnSequence + }; + }; + return client.signAndBroadcast(address, msgs, fee, memo); + }, + msgApointMatchReporter: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgApointMatchReporter", + value: tx_1.MsgApointMatchReporter.fromPartial(data) + }), + msgSetProfileCard: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetProfileCard", + value: tx_2.MsgSetProfileCard.fromPartial(data) + }), + msgCreateuser: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateuser", + value: tx_3.MsgCreateuser.fromPartial(data) + }), + msgRevealCouncilResponse: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRevealCouncilResponse", + value: tx_4.MsgRevealCouncilResponse.fromPartial(data) + }), + msgBuyCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCollection", + value: tx_5.MsgBuyCollection.fromPartial(data) + }), + msgAddArtwork: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtwork", + value: tx_6.MsgAddArtwork.fromPartial(data) + }), + msgChangeArtist: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgChangeArtist", + value: tx_7.MsgChangeArtist.fromPartial(data) + }), + msgRemoveCardFromCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveCardFromCollection", + value: tx_8.MsgRemoveCardFromCollection.fromPartial(data) + }), + msgCreateCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCollection", + value: tx_9.MsgCreateCollection.fromPartial(data) + }), + msgSaveCardContent: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSaveCardContent", + value: tx_10.MsgSaveCardContent.fromPartial(data) + }), + msgAddArtworkToCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtworkToCollection", + value: tx_11.MsgAddArtworkToCollection.fromPartial(data) + }), + msgFinalizeCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgFinalizeCollection", + value: tx_12.MsgFinalizeCollection.fromPartial(data) + }), + msgRewokeCouncilRegistration: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRewokeCouncilRegistration", + value: tx_13.MsgRewokeCouncilRegistration.fromPartial(data) + }), + msgSubmitMatchReporterProposal: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitMatchReporterProposal", + value: tx_14.MsgSubmitMatchReporterProposal.fromPartial(data) + }), + msgRestartCouncil: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRestartCouncil", + value: tx_15.MsgRestartCouncil.fromPartial(data) + }), + msgSubmitCopyrightProposal: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCopyrightProposal", + value: tx_16.MsgSubmitCopyrightProposal.fromPartial(data) + }), + msgSetCardRarity: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetCardRarity", + value: tx_17.MsgSetCardRarity.fromPartial(data) + }), + msgRemoveSellOffer: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveSellOffer", + value: tx_18.MsgRemoveSellOffer.fromPartial(data) + }), + msgRegisterForCouncil: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRegisterForCouncil", + value: tx_19.MsgRegisterForCouncil.fromPartial(data) + }), + msgCreateCouncil: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCouncil", + value: tx_20.MsgCreateCouncil.fromPartial(data) + }), + msgReportMatch: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgReportMatch", + value: tx_21.MsgReportMatch.fromPartial(data) + }), + msgBuyCardScheme: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCardScheme", + value: tx_22.MsgBuyCardScheme.fromPartial(data) + }), + msgConfirmMatch: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgConfirmMatch", + value: tx_23.MsgConfirmMatch.fromPartial(data) + }), + msgCommitCouncilResponse: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCommitCouncilResponse", + value: tx_24.MsgCommitCouncilResponse.fromPartial(data) + }), + msgAddContributorToCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddContributorToCollection", + value: tx_25.MsgAddContributorToCollection.fromPartial(data) + }), + msgCreateSellOffer: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateSellOffer", + value: tx_26.MsgCreateSellOffer.fromPartial(data) + }), + msgBuyCard: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCard", + value: tx_27.MsgBuyCard.fromPartial(data) + }), + msgVoteCard: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgVoteCard", + value: tx_28.MsgVoteCard.fromPartial(data) + }), + msgRemoveContributorFromCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveContributorFromCollection", + value: tx_29.MsgRemoveContributorFromCollection.fromPartial(data) + }), + msgAddStoryToCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddStoryToCollection", + value: tx_30.MsgAddStoryToCollection.fromPartial(data) + }), + msgSubmitCollectionProposal: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", + value: tx_31.MsgSubmitCollectionProposal.fromPartial(data) + }), + msgDonateToCard: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", + value: tx_32.MsgDonateToCard.fromPartial(data) + }), + msgTransferCard: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgTransferCard", + value: tx_33.MsgTransferCard.fromPartial(data) + }), + msgAddCardToCollection: (data) => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", + value: tx_34.MsgAddCardToCollection.fromPartial(data) + }) }; }; exports.txClient = txClient; diff --git a/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.ts b/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.ts index dc23f2c9..b3ce2685 100755 --- a/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.ts +++ b/src/store/generated/DecentralCardGame/Cardchain/DecentralCardGame.cardchain.cardchain/module/index.ts @@ -74,7 +74,7 @@ const types = [ ["/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", MsgSubmitCollectionProposal], ["/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", MsgDonateToCard], ["/DecentralCardGame.cardchain.cardchain.MsgTransferCard", MsgTransferCard], - ["/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", MsgAddCardToCollection], + ["/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", MsgAddCardToCollection] ]; export const MissingWalletError = new Error("wallet is required"); @@ -83,11 +83,11 @@ export const registry = new Registry(types); const defaultFee = { amount: [], - gas: "200000", + gas: "200000" }; interface TxClientOptions { - addr: string + addr: string; } interface SignAndBroadcastOptions { @@ -95,58 +95,236 @@ interface SignAndBroadcastOptions { memo?: string } +let sequenceInfo = { + height: null, + sequence: null +}; const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = { addr: "http://localhost:26657" }) => { if (!wallet) throw MissingWalletError; let client; if (addr) { client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry }); - }else{ - client = await SigningStargateClient.offline( wallet, { registry }); + } else { + client = await SigningStargateClient.offline(wallet, { registry }); } const { address } = (await wallet.getAccounts())[0]; return { - signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgApointMatchReporter: (data: MsgApointMatchReporter): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgApointMatchReporter", value: MsgApointMatchReporter.fromPartial( data ) }), - msgSetProfileCard: (data: MsgSetProfileCard): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetProfileCard", value: MsgSetProfileCard.fromPartial( data ) }), - msgCreateuser: (data: MsgCreateuser): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateuser", value: MsgCreateuser.fromPartial( data ) }), - msgRevealCouncilResponse: (data: MsgRevealCouncilResponse): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRevealCouncilResponse", value: MsgRevealCouncilResponse.fromPartial( data ) }), - msgBuyCollection: (data: MsgBuyCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCollection", value: MsgBuyCollection.fromPartial( data ) }), - msgAddArtwork: (data: MsgAddArtwork): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtwork", value: MsgAddArtwork.fromPartial( data ) }), - msgChangeArtist: (data: MsgChangeArtist): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgChangeArtist", value: MsgChangeArtist.fromPartial( data ) }), - msgRemoveCardFromCollection: (data: MsgRemoveCardFromCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveCardFromCollection", value: MsgRemoveCardFromCollection.fromPartial( data ) }), - msgCreateCollection: (data: MsgCreateCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCollection", value: MsgCreateCollection.fromPartial( data ) }), - msgSaveCardContent: (data: MsgSaveCardContent): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSaveCardContent", value: MsgSaveCardContent.fromPartial( data ) }), - msgAddArtworkToCollection: (data: MsgAddArtworkToCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtworkToCollection", value: MsgAddArtworkToCollection.fromPartial( data ) }), - msgFinalizeCollection: (data: MsgFinalizeCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgFinalizeCollection", value: MsgFinalizeCollection.fromPartial( data ) }), - msgRewokeCouncilRegistration: (data: MsgRewokeCouncilRegistration): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRewokeCouncilRegistration", value: MsgRewokeCouncilRegistration.fromPartial( data ) }), - msgSubmitMatchReporterProposal: (data: MsgSubmitMatchReporterProposal): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitMatchReporterProposal", value: MsgSubmitMatchReporterProposal.fromPartial( data ) }), - msgRestartCouncil: (data: MsgRestartCouncil): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRestartCouncil", value: MsgRestartCouncil.fromPartial( data ) }), - msgSubmitCopyrightProposal: (data: MsgSubmitCopyrightProposal): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCopyrightProposal", value: MsgSubmitCopyrightProposal.fromPartial( data ) }), - msgSetCardRarity: (data: MsgSetCardRarity): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetCardRarity", value: MsgSetCardRarity.fromPartial( data ) }), - msgRemoveSellOffer: (data: MsgRemoveSellOffer): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveSellOffer", value: MsgRemoveSellOffer.fromPartial( data ) }), - msgRegisterForCouncil: (data: MsgRegisterForCouncil): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRegisterForCouncil", value: MsgRegisterForCouncil.fromPartial( data ) }), - msgCreateCouncil: (data: MsgCreateCouncil): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCouncil", value: MsgCreateCouncil.fromPartial( data ) }), - msgReportMatch: (data: MsgReportMatch): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgReportMatch", value: MsgReportMatch.fromPartial( data ) }), - msgBuyCardScheme: (data: MsgBuyCardScheme): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCardScheme", value: MsgBuyCardScheme.fromPartial( data ) }), - msgConfirmMatch: (data: MsgConfirmMatch): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgConfirmMatch", value: MsgConfirmMatch.fromPartial( data ) }), - msgCommitCouncilResponse: (data: MsgCommitCouncilResponse): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCommitCouncilResponse", value: MsgCommitCouncilResponse.fromPartial( data ) }), - msgAddContributorToCollection: (data: MsgAddContributorToCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddContributorToCollection", value: MsgAddContributorToCollection.fromPartial( data ) }), - msgCreateSellOffer: (data: MsgCreateSellOffer): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateSellOffer", value: MsgCreateSellOffer.fromPartial( data ) }), - msgBuyCard: (data: MsgBuyCard): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCard", value: MsgBuyCard.fromPartial( data ) }), - msgVoteCard: (data: MsgVoteCard): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgVoteCard", value: MsgVoteCard.fromPartial( data ) }), - msgRemoveContributorFromCollection: (data: MsgRemoveContributorFromCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveContributorFromCollection", value: MsgRemoveContributorFromCollection.fromPartial( data ) }), - msgAddStoryToCollection: (data: MsgAddStoryToCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddStoryToCollection", value: MsgAddStoryToCollection.fromPartial( data ) }), - msgSubmitCollectionProposal: (data: MsgSubmitCollectionProposal): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", value: MsgSubmitCollectionProposal.fromPartial( data ) }), - msgDonateToCard: (data: MsgDonateToCard): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", value: MsgDonateToCard.fromPartial( data ) }), - msgTransferCard: (data: MsgTransferCard): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgTransferCard", value: MsgTransferCard.fromPartial( data ) }), - msgAddCardToCollection: (data: MsgAddCardToCollection): EncodeObject => ({ typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", value: MsgAddCardToCollection.fromPartial( data ) }), + signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = { + fee: defaultFee, + memo: "" + }) => { + // code injection to get sequence fast firing working + client.getSequence = async function(address) { + const height = await this.getHeight(); + const account = await this.getAccount(address); + + if (!account) { + throw new Error("Account does not exist on chain. Send some tokens there before trying to query sequence."); + } + + // if sequence info is not yet defined, do it here + if (!sequenceInfo.height) { + sequenceInfo = { + height: height, + sequence: account.sequence + }; + } + // if the sequence info is outdated, we update it + else if (sequenceInfo.height < height) { + // we don't update the sequence if it is from last block + // this fixes sequence error is tx got into new block and update would reset the sequence + if (sequenceInfo.height + 1 < height) { + sequenceInfo.sequence = account.sequence; + } + sequenceInfo.height = height; + } + + let returnSequence = sequenceInfo.sequence; + sequenceInfo.sequence++; + return { + accountNumber: account.accountNumber, + sequence: returnSequence + }; + }; + return client.signAndBroadcast(address, msgs, fee, memo); + }, + msgApointMatchReporter: + (data: MsgApointMatchReporter): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgApointMatchReporter", + value: MsgApointMatchReporter.fromPartial(data) + }), + msgSetProfileCard: + (data: MsgSetProfileCard): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetProfileCard", + value: MsgSetProfileCard.fromPartial(data) + }), + msgCreateuser: + (data: MsgCreateuser): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateuser", + value: MsgCreateuser.fromPartial(data) + }), + msgRevealCouncilResponse: + (data: MsgRevealCouncilResponse): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRevealCouncilResponse", + value: MsgRevealCouncilResponse.fromPartial(data) + }), + msgBuyCollection: + (data: MsgBuyCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCollection", + value: MsgBuyCollection.fromPartial(data) + }), + msgAddArtwork: + (data: MsgAddArtwork): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtwork", + value: MsgAddArtwork.fromPartial(data) + }), + msgChangeArtist: + (data: MsgChangeArtist): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgChangeArtist", + value: MsgChangeArtist.fromPartial(data) + }), + msgRemoveCardFromCollection: + (data: MsgRemoveCardFromCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveCardFromCollection", + value: MsgRemoveCardFromCollection.fromPartial(data) + }), + msgCreateCollection: + (data: MsgCreateCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCollection", + value: MsgCreateCollection.fromPartial(data) + }), + msgSaveCardContent: + (data: MsgSaveCardContent): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSaveCardContent", + value: MsgSaveCardContent.fromPartial(data) + }), + msgAddArtworkToCollection: + (data: MsgAddArtworkToCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddArtworkToCollection", + value: MsgAddArtworkToCollection.fromPartial(data) + }), + msgFinalizeCollection: + (data: MsgFinalizeCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgFinalizeCollection", + value: MsgFinalizeCollection.fromPartial(data) + }), + msgRewokeCouncilRegistration: + (data: MsgRewokeCouncilRegistration): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRewokeCouncilRegistration", + value: MsgRewokeCouncilRegistration.fromPartial(data) + }), + msgSubmitMatchReporterProposal: + (data: MsgSubmitMatchReporterProposal): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitMatchReporterProposal", + value: MsgSubmitMatchReporterProposal.fromPartial(data) + }), + msgRestartCouncil: + (data: MsgRestartCouncil): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRestartCouncil", + value: MsgRestartCouncil.fromPartial(data) + }), + msgSubmitCopyrightProposal: + (data: MsgSubmitCopyrightProposal): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCopyrightProposal", + value: MsgSubmitCopyrightProposal.fromPartial(data) + }), + msgSetCardRarity: + (data: MsgSetCardRarity): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSetCardRarity", + value: MsgSetCardRarity.fromPartial(data) + }), + msgRemoveSellOffer: + (data: MsgRemoveSellOffer): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveSellOffer", + value: MsgRemoveSellOffer.fromPartial(data) + }), + msgRegisterForCouncil: + (data: MsgRegisterForCouncil): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRegisterForCouncil", + value: MsgRegisterForCouncil.fromPartial(data) + }), + msgCreateCouncil: + (data: MsgCreateCouncil): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateCouncil", + value: MsgCreateCouncil.fromPartial(data) + }), + msgReportMatch: + (data: MsgReportMatch): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgReportMatch", + value: MsgReportMatch.fromPartial(data) + }), + msgBuyCardScheme: + (data: MsgBuyCardScheme): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCardScheme", + value: MsgBuyCardScheme.fromPartial(data) + }), + msgConfirmMatch: + (data: MsgConfirmMatch): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgConfirmMatch", + value: MsgConfirmMatch.fromPartial(data) + }), + msgCommitCouncilResponse: + (data: MsgCommitCouncilResponse): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCommitCouncilResponse", + value: MsgCommitCouncilResponse.fromPartial(data) + }), + msgAddContributorToCollection: + (data: MsgAddContributorToCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddContributorToCollection", + value: MsgAddContributorToCollection.fromPartial(data) + }), + msgCreateSellOffer: + (data: MsgCreateSellOffer): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgCreateSellOffer", + value: MsgCreateSellOffer.fromPartial(data) + }), + msgBuyCard: + (data: MsgBuyCard): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgBuyCard", + value: MsgBuyCard.fromPartial(data) + }), + msgVoteCard: + (data: MsgVoteCard): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgVoteCard", + value: MsgVoteCard.fromPartial(data) + }), + msgRemoveContributorFromCollection: + (data: MsgRemoveContributorFromCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgRemoveContributorFromCollection", + value: MsgRemoveContributorFromCollection.fromPartial(data) + }), + msgAddStoryToCollection: + (data: MsgAddStoryToCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddStoryToCollection", + value: MsgAddStoryToCollection.fromPartial(data) + }), + msgSubmitCollectionProposal: + (data: MsgSubmitCollectionProposal): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgSubmitCollectionProposal", + value: MsgSubmitCollectionProposal.fromPartial(data) + }), + msgDonateToCard: + (data: MsgDonateToCard): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgDonateToCard", + value: MsgDonateToCard.fromPartial(data) + }), + msgTransferCard: + (data: MsgTransferCard): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgTransferCard", + value: MsgTransferCard.fromPartial(data) + }), + msgAddCardToCollection: + (data: MsgAddCardToCollection): EncodeObject => ({ + typeUrl: "/DecentralCardGame.cardchain.cardchain.MsgAddCardToCollection", + value: MsgAddCardToCollection.fromPartial(data) + }) }; }; interface QueryClientOptions { - addr: string + addr: string; } const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { @@ -155,5 +333,5 @@ const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http:// export { txClient, - queryClient, + queryClient }; diff --git a/src/views/NewCardPage.vue b/src/views/NewCardPage.vue index bb3efae6..1fd5a4f4 100644 --- a/src/views/NewCardPage.vue +++ b/src/views/NewCardPage.vue @@ -650,13 +650,13 @@ import AbilityComponent from "../components/elements/AbilityComponent.vue"; import { atPath, - emptyCard, uploadImg, } from "@/components/utils/utils.js"; -import { sampleGradientImg } from '../components/utils/sampleCards.js' +import { sampleGradientImg } from '@/components/utils/sampleCards.js' import { Cropper } from 'vue-advanced-cropper' import 'vue-advanced-cropper/dist/style.css'; +import { Card } from "@/model/Card"; export default { @@ -673,7 +673,7 @@ export default { abilities: [], abilityDialog: {}, cropImage: sampleGradientImg, - model: R.clone(emptyCard), + model: new Card(), cardID: 0, }; }, @@ -705,10 +705,11 @@ export default { // here a card is loaded if edit card via gallery was selected if (this.isEditCardMode()) { console.log("edit card: ", this.$store.getters['getCardCreatorEditCard']); - this.model = R.merge( - this.model, + this.model = Object.assign( + new Card(), this.$store.getters['getCardCreatorEditCard'] ); + console.log(this.model) this.cropImage = this.$store.getters['getCardCreatorEditCard'].image @@ -722,20 +723,20 @@ export default { !R.isEmpty(this.$store.getters['getCardCreatorDraft']) && this.$store.getters['getCardCreatorDraft'].model ) { - this.model = JSON.parse(this.$store.getters['getCardCreatorDraft'].model); + this.model = Object.assign(new Card(), JSON.parse(this.$store.getters['getCardCreatorDraft'].model)); console.log("loaded model:", this.model, R.is(Object, this.model)); // if the loaded model is not an object, something is 100% wrong if (!R.is(Object, this.model)) { console.error("loaded model is not an object, overwriting with empty model") - this.model = R.clone(emptyCard) + this.model = new Card() } // this is automated fix for old (and wrong) data in store if (this.isEditCardMode()) { console.log("automated fix!"); - this.$store.commit("setCardCreatorDraft", R.clone(emptyCard)); + this.$store.commit("setCardCreatorDraft", new Card()); } } if ( @@ -773,7 +774,7 @@ export default { }, toggleAdditionalCost() { if (!this.isAdditionalCostVisible) { - this.model.AdditionalCost = emptyCard.AdditionalCost + this.model.AdditionalCost = {} } }, setAdditionalCost(event) { @@ -1032,6 +1033,7 @@ export default { // finalize abilties or effects // this should potentially moved to somewhere else? maybe where abilities are saved let newModel = this.model; + console.log(newModel) if (this.model.type !== "Action") { // check if the old abilities should be restored @@ -1093,10 +1095,11 @@ export default { this.updateRulesTexts() } - let newCard = this.$cardChain.cardWebModelToCardobject( - newModel, - this.getCardImage - ) + console.log(newModel) + newModel.image = this.getCardImage + let newCard = newModel.toChainCard() + + console.log("yes", this.$cardChain.cardWebModelToCardobject(newModel, newModel.image)) console.log("newCard", newCard) // check if a card is edited with pre-existing ID @@ -1135,7 +1138,7 @@ export default { this.isEditCardMode() ? "setCardCreatorEditCard" : "setCardCreatorDraft", {} ) - this.model = R.clone(emptyCard) + this.model = new Card() this.cropImage = sampleGradientImg this.$store.commit( this.isEditCardMode() ? "setCardCreatorEditCardImg" : "setCardCreatorDraftImg",