diff --git a/.env.development b/.env.development index 1a9c969d..48e86e8e 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,7 @@ -VUE_APP_API_COSMOS=https://cardchain.crowdcontrol.network/cosmos -VUE_APP_WS_TENDERMINT=wss://cardchain.crowdcontrol.network/tendermint/websocket -VUE_APP_API_TENDERMINT=https://cardchain.crowdcontrol.network/tendermint/ -VUE_APP_FAUCET=https://cardchain.crowdcontrol.network/faucet/claimTokens +#VUE_APP_API_COSMOS=https://cardchain.crowdcontrol.network/cosmos +#VUE_APP_WS_TENDERMINT=wss://cardchain.crowdcontrol.network/tendermint/websocket +#VUE_APP_API_TENDERMINT=https://cardchain.crowdcontrol.network/tendermint/ +#VUE_APP_FAUCET=https://cardchain.crowdcontrol.network/faucet/claimTokens VUE_APP_FAUCET_SITEKEY="ea68532a-a9e6-4f99-9361-db90a3071b72" VUE_APP_ADDRESS_PREFIX=cc @@ -11,12 +11,12 @@ VUE_APP_CARDIMG_MAXKB=500 VUE_APP_UCREDITS_FACTOR=1000000 NODE_VERSION=v12.18.3 -VUE_APP_API_COSMOS_FALLBACK=https://cardchain2.crowdcontrol.network/cosmos -VUE_APP_WS_TENDERMINT_FALLBACK=wss://cardchain2.crowdcontrol.network/tendermint/websocket -VUE_APP_API_TENDERMINT_FALLBACK=https://cardchain2.crowdcontrol.network/tendermint/ -VUE_APP_FAUCET_FALLBACK=https://cardchain2.crowdcontrol.network/faucet/claimTokens +#VUE_APP_API_COSMOS_FALLBACK=https://cardchain2.crowdcontrol.network/cosmos +#VUE_APP_WS_TENDERMINT_FALLBACK=wss://cardchain2.crowdcontrol.network/tendermint/websocket +#VUE_APP_API_TENDERMINT_FALLBACK=https://cardchain2.crowdcontrol.network/tendermint/ +#VUE_APP_FAUCET_FALLBACK=https://cardchain2.crowdcontrol.network/faucet/claimTokens -#VUE_APP_API_COSMOS=http://localhost:1317 -#VUE_APP_WS_TENDERMINT=ws://localhost:26657/websocket -#VUE_APP_API_TENDERMINT=http://localhost:26657 -#VUE_APP_FAUCET="http://localhost:4500/claimTokens" +VUE_APP_API_COSMOS=http://localhost:1317 +VUE_APP_WS_TENDERMINT=ws://localhost:26657/websocket +VUE_APP_API_TENDERMINT=http://localhost:26657 +VUE_APP_FAUCET="http://localhost:4500/claimTokens" diff --git a/src/model/Coin.js b/src/model/Coin.js index 2e326d9a..9105f346 100644 --- a/src/model/Coin.js +++ b/src/model/Coin.js @@ -16,5 +16,8 @@ class Coin { pretty() { return this.amount + this.denom; } + static from(json) { + return Object.assign(new Coin(), json); + } } exports.Coin = Coin; diff --git a/src/model/Coin.ts b/src/model/Coin.ts index 4273c71b..11daa800 100644 --- a/src/model/Coin.ts +++ b/src/model/Coin.ts @@ -18,4 +18,8 @@ export class Coin { pretty() { return this.amount + this.denom; } + + static from(json) { + return Object.assign(new Coin(), json); + } } \ No newline at end of file diff --git a/src/model/User.js b/src/model/User.js new file mode 100644 index 00000000..78c2042f --- /dev/null +++ b/src/model/User.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.User = void 0; +class User { + constructor() { + this.ReportMatches = false; + this.airDrops = new AirDrops(); + this.alias = ""; + this.biography = ""; + this.boosterPacks = []; + this.cards = []; + this.councilParticipation = new CouncilParticipation(); + this.ownedCardSchemes = []; + this.ownedPrototypes = []; + this.profileCard = 0; + this.voteRights = []; + this.website = ""; + } + static from(json) { + let user = Object.assign(new User(), json); + user.airDrops = AirDrops.from(json.airDrops); + user.councilParticipation = CouncilParticipation.from(json.councilParticipation); + return user; + } +} +exports.User = User; +class AirDrops { + constructor() { + this.vote = false; + this.create = false; + this.buy = false; + this.play = false; + this.user = false; + } + static from(json) { + return Object.assign(new AirDrops(), json); + } +} +class CouncilParticipation { + constructor() { + this.council = 0; + this.status = ""; + } + static from(json) { + return Object.assign(new CouncilParticipation(), json); + } +} diff --git a/src/model/User.ts b/src/model/User.ts new file mode 100644 index 00000000..60d7c9d6 --- /dev/null +++ b/src/model/User.ts @@ -0,0 +1,42 @@ +export class User { + ReportMatches: boolean = false + airDrops: AirDrops = new AirDrops() + alias: string = "" + biography: string = "" + boosterPacks: Array = [] + cards: Array = [] + councilParticipation: CouncilParticipation = new CouncilParticipation() + ownedCardSchemes: Array = [] + ownedPrototypes: Array = [] + profileCard: number = 0 + voteRights: Array = [] + website: string = "" + + static from(json) { + let user: User = Object.assign(new User(), json); + user.airDrops = AirDrops.from(json.airDrops) + user.councilParticipation = CouncilParticipation.from(json.councilParticipation) + return user + } +} + +class AirDrops { + vote: boolean = false + create: boolean = false + buy: boolean = false + play: boolean = false + user: boolean = false + + static from(json) { + return Object.assign(new AirDrops(), json); + } +} + +class CouncilParticipation { + council: number = 0 + status: string = "" + + static from(json) { + return Object.assign(new CouncilParticipation(), json); + } +} \ No newline at end of file diff --git a/src/plugins/cardChain.js b/src/plugins/cardChain.js index d2dfc29e..5a18d385 100644 --- a/src/plugins/cardChain.js +++ b/src/plugins/cardChain.js @@ -7,6 +7,8 @@ import { entropyToMnemonic } from 'bip39' 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 { User } from "@/model/User"; +import { Coin } from "@/model/Coin"; //import {Any} from "../store/generated/cosmos/cosmos-sdk/cosmos.authz.v1beta1/module/types/google/protobuf/any.js" export default { @@ -91,53 +93,6 @@ export default { }) } } - cardWebModelToCardobject (webModel, cardImageUrl) { - console.log('trying to parse ', webModel) - let cardContent = { - CardName: webModel.CardName, - Tags: R.reject(R.isNil, webModel.Tags), - FlavourText: webModel.FlavourText, - Class: { - Nature: webModel.Class.Nature == true, - Technology: webModel.Class.Technology == true, - Culture: webModel.Class.Culture == true, - Mysticism: webModel.Class.Mysticism == true, - }, - Keywords: R.map(JSON.stringify, webModel.Keywords), - RulesTexts: webModel.RulesTexts - } - // in the following part we check things that are only required for specific card types - if (webModel.type !== "Headquarter") { - cardContent.CastingCost = webModel.CastingCost - console.log("additionalcost empty?", R.isEmpty(webModel.AdditionalCost)) - if (!R.isEmpty(webModel.AdditionalCost)) { - cardContent.AdditionalCost = webModel.AdditionalCost - } - } - if (webModel.type !== "Action") { - cardContent.Health = webModel.Health - cardContent.Abilities = webModel.Abilities - } - if (webModel.type === "Entity") { - cardContent.Attack = webModel.Attack - } - else if (webModel.type === "Action") { - cardContent.Effects = webModel.Effects - } - else if (webModel.type === "Headquarter") { - cardContent.Delay = webModel.Delay - } - let cardobject = { - content: { - [webModel.type]: cardContent - }, - image: cardImageUrl ? cardImageUrl : "if you read this, someone was able to upload a card without proper image...", - fullArt: webModel.fullArt, - notes: webModel.notes, - } - console.log('parsed into:', cardobject) - return cardobject - } saveContentToUnusedCardSchemeTx (card) { return this.getUserInfo(this.vue.$store.getters['common/wallet/address']) .then(user => { @@ -328,7 +283,7 @@ export default { this.vue.notifyFail('YOU SHALL NOT PASS!', address + ' is not registered. Please click Join and register in the blockchain.') throw new Error('account ' + address + ' is not registered') } else { - return res.data + return User.from(res.data) } }) handleGetGrants = R.curry((res, address) => { @@ -340,8 +295,12 @@ export default { this.vue.notifyFail('Account not registered', address + ' is not registered on the blockchain.') throw new Error(address + ' is not registered on the blockchain.') } else { + let coins = [] + res.data.balances.forEach(coin => { + coins.push(Coin.from(coin)) + }) return { - coins: res.data.balances + coins: coins } } }) diff --git a/src/views/UserView.vue b/src/views/UserView.vue index b745bff6..76e31863 100644 --- a/src/views/UserView.vue +++ b/src/views/UserView.vue @@ -43,7 +43,7 @@
Owned cards: {{ user.cards.length }} @@ -51,19 +51,19 @@
- Council status: {{ user.CouncilStatus }}
+ Council status: {{ user.councilParticipation.status }}