Skip to content

Commit

Permalink
path field fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
magiodev committed May 12, 2024
1 parent 0e8e911 commit 5498ba2
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 39 deletions.
3 changes: 2 additions & 1 deletion frontend-ms/src/components/Game/BidComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
Balance: {{ userBalance || '...' }}
<CoinComponent/>
</div>
<div v-if="userAddress" class="small">
<div v-if="userAddress && cw721Contract" class="small">
<span v-if="userCw721Balance.length">You hodl {{ userCw721Balance.length }} MS so you're eligible for a discount of {{ displayAmount(maxBid / 2 - minBid)
}} <CoinComponent/> on the min bet amount.</span>
<span v-else>You own {{ userCw721Balance.length }} MS so you're not eligible for a discount on the min. bet amount.</span>
Expand Down Expand Up @@ -110,6 +110,7 @@ export default {
return {
isBusy: false,
bidAmount: 0,
cw721Contract: process.env.VUE_APP_CONTRACT_CW721,
currentImage: null,
imageWait,
imageCook,
Expand Down
34 changes: 23 additions & 11 deletions frontend-ms/src/components/Game/PlayersAllocations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,35 @@
<th scope="col">Total</th>
<th scope="col">Winning</th>
<th scope="col">Losing</th>
<th scope="col">Share of Prize ({{ displayAmount(totalPrizeOnlyLosingDistribution + (calculateInitialFundsShare({
pot_id: this.pots[0].pot_id,
amount: this.pots[0].amount
}) * this.winningPots.length), 2) }})</th>
<th scope="col">Share of Prize
({{ displayAmount(totalPrizeOnlyLosingDistribution + (calculateInitialFundsShare({
pot_id: this.pots[0].pot_id,
amount: this.pots[0].amount
}) * this.winningPots.length), 2) }})
</th>
<th scope="col">Receives</th>
</tr>
</thead>
<tbody>
<tr v-for="(stats, address) in statistics.playerStatistics" :key="address">
<td>{{ address.substring(0, 15) }}...</td>
<td>{{ displayAmount(stats.totalBet, 2) }} <CoinComponent/></td>
<td>{{ displayAmount(stats.winningPots, 2) }} <CoinComponent/></td>
<td>{{ displayAmount(stats.losingPots, 2) }} <CoinComponent/></td>
<td>{{ displayAmount(stats.redistributionShare, 2) }} <CoinComponent/> ({{ stats.sharesInPercentage }}%)
<td>{{ displayAmount(stats.totalBet, 2) }}
<CoinComponent/>
</td>
<td>{{ displayAmount(stats.winningPots, 2) }}
<CoinComponent/>
</td>
<td>{{ displayAmount(stats.losingPots, 2) }}
<CoinComponent/>
</td>
<td>{{ displayAmount(stats.redistributionShare, 2) }}
<CoinComponent/>
({{ stats.sharesInPercentage }}%)
<!--{{ displayAmount(stats.winningFee) }} fee. <CoinComponent/> -->
</td>
<td>{{ displayAmount(stats.winningPots + stats.redistributionShare, 2) }} <CoinComponent/></td>
<td>{{ displayAmount(stats.winningPots + stats.redistributionShare, 2) }}
<CoinComponent/>
</td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -197,7 +209,7 @@ export default {
let totalFees = 0;
let totalRedistributed = 0;
this.allPlayersAllocations.forEach(([address, {allocations}]) => {
this.allPlayersAllocations.forEach(([address, allocations]) => {
let stats = {
totalBet: 0,
winningPots: 0,
Expand Down Expand Up @@ -268,7 +280,7 @@ export default {
const potInitialFunds = parseInt(pot.amount);
const totalPotAllocations = this.calculateTotalInPots(
this.allPlayersAllocations.flatMap(([, alloc]) =>
alloc.allocations.filter(a => a.pot_id === pot.pot_id)
alloc.filter(a => a.pot_id === pot.pot_id)
)
);
return potInitialFunds - totalPotAllocations;
Expand Down
1 change: 0 additions & 1 deletion frontend-ms/src/mixin/pot.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const mxPot = {
},

formattedPotNames(potIds) {
console.log(typeof potIds)
if (Array.isArray(potIds)) {
return potIds.map(potId => this.getPotName(potId)).join(', ');
}
Expand Down
22 changes: 11 additions & 11 deletions frontend-ms/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export default createStore({

const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT,
{bid_range: {cw721_count: state.user.cw721balance.length}}
{bid_range: {address: state.user.address}}
);
commit("setBidRange", {min_bid: Number(data.min_bid), max_bid: Number(data.max_bid)});
},
Expand Down Expand Up @@ -493,17 +493,17 @@ export default createStore({
return;
}

const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT_CW721,
{
tokens: {
owner: state.user.address
if (process.env.VUE_APP_CONTRACT_CW721) {
const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT_CW721,
{
tokens: {
owner: state.user.address
}
}
}
);
commit("setUserCw721Balance", data.tokens);
console.log("fetchCw721Tokens done.")

);
commit("setUserCw721Balance", data.tokens);
}
},
},

Expand Down
5 changes: 3 additions & 2 deletions frontend/src/components/Game/BidComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
Balance: {{ userBalance || '...' }}
<CoinComponent/>
</div>
<div v-if="userAddress" class="small">
<div v-if="userAddress && cw721Contract" class="small">
<span v-if="userCw721Balance.length">You hodl {{ userCw721Balance.length }} {NFT_NAME} so you're eligible for a discount of {{ displayAmount(maxBid / 2 - minBid)
}} <CoinComponent/> on the min bet amount.</span>
<span v-else>You own {{ userCw721Balance.length }} {NFT_NAME} so you're not eligible for a discount on the min. bet amount.</span>
Expand Down Expand Up @@ -100,7 +100,8 @@ export default {
data() {
return {
isBusy: false,
bidAmount: 0
bidAmount: 0,
cw721Contract: process.env.VUE_APP_CONTRACT_CW721
};
},
created() {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Game/PlayersAllocations.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default {
let totalFees = 0;
let totalRedistributed = 0;
this.allPlayersAllocations.forEach(([address, {allocations}]) => {
this.allPlayersAllocations.forEach(([address, allocations]) => {
let stats = {
totalBet: 0,
winningPots: 0,
Expand Down Expand Up @@ -270,7 +270,7 @@ export default {
const potInitialFunds = parseInt(pot.amount);
const totalPotAllocations = this.calculateTotalInPots(
this.allPlayersAllocations.flatMap(([, alloc]) =>
alloc.allocations.filter(a => a.pot_id === pot.pot_id)
alloc.filter(a => a.pot_id === pot.pot_id)
)
);
return potInitialFunds - totalPotAllocations;
Expand Down
1 change: 0 additions & 1 deletion frontend/src/mixin/pot.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ const mxPot = {
},

formattedPotNames(potIds) {
console.log(typeof potIds)
if (Array.isArray(potIds)) {
return potIds.map(potId => this.getPotName(potId)).join(', ');
}
Expand Down
22 changes: 12 additions & 10 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export default createStore({
);
// TODO: This could be avoided in favor of allPlayersAllocation.find(address => this.user) (pseudo code)
// Filter out allocations where the amount is "0"
const filteredAllocations = allocationsResponse.allocations.allocations.filter(allocation => allocation.amount !== "0");
const filteredAllocations = allocationsResponse.allocations.filter(allocation => allocation.amount !== "0");
commit("setPlayerAllocations", filteredAllocations);

// Player Reallocations
Expand Down Expand Up @@ -409,7 +409,7 @@ export default createStore({

const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT,
{bid_range: {cw721_count: state.user.cw721balance.length}}
{bid_range: {address: state.user.address}}
);
commit("setBidRange", {min_bid: Number(data.min_bid), max_bid: Number(data.max_bid)});
},
Expand Down Expand Up @@ -492,15 +492,17 @@ export default createStore({
return;
}

const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT_CW721,
{
tokens: {
owner: state.user.address
if (process.env.VUE_APP_CONTRACT_CW721) {
const data = await state.user.querier.queryContractSmart(
process.env.VUE_APP_CONTRACT_CW721,
{
tokens: {
owner: state.user.address
}
}
}
);
commit("setUserCw721Balance", data.tokens);
);
commit("setUserCw721Balance", data.tokens);
}
},
},

Expand Down

0 comments on commit 5498ba2

Please sign in to comment.